oasis-editor 0.0.308 → 0.0.309
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/{OasisEditorApp-BqUwnU1g.js → OasisEditorApp-CINghPsi.js} +1 -1
- package/dist/defaultToolbar-CSM7SoWl.js +1 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/defaultToolbar-CTtskguI.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,$a as t,$n as n,$o as o,$t as r,A as a,Aa as i,An as l,Ao as s,Ar as c,B as d,Ba as u,Bi as p,Bn as g,Bo as f,Br as m,Bt as h,C as b,Ca as y,Ci as v,Cn as x,Co as w,Cr as S,Ct as C,D as I,Da as T,Di as k,Dn as P,Do as R,Dr as B,Dt as A,E as M,Ea as F,Ei as O,En as D,Eo as E,Er as L,Et as N,F as $,Fa as z,Fn as H,Fr as W,Ft as U,G as j,Ga as V,Gi as K,Gn as _,Go as X,Gr as G,Gt as q,H as Y,Ha as Z,Hi as J,Hn as Q,Ho as ee,Hr as te,Ht as ne,I as oe,Ia as re,Ii as ae,In as ie,Io as le,Ir as se,It as ce,J as de,Ja as ue,Ji as pe,Jn as ge,Jo as fe,Jr as me,Jt as he,K as be,Ka as ye,Ki as ve,Kn as xe,Ko as we,Kr as Se,Kt as Ce,L as Ie,La as Te,Li as ke,Ln as Pe,Lo as Re,Lr as Be,Lt as Ae,M as Me,Ma as Fe,Mi as Oe,Mn as De,Mo as Ee,Mr as Le,N as Ne,Na as $e,Ni as ze,Nn as He,No as We,Nr as Ue,Nt as je,O as Ve,Oa as Ke,Oi as _e,On as Xe,Oo as Ge,Or as qe,P as Ye,Pa as Ze,Pi as Je,Pn as Qe,Po as et,Pr as tt,Pt as nt,Q as ot,Qa as rt,Qn as at,Qo as it,Qt as lt,R as st,Ra as ct,Ri as dt,Rn as ut,Rr as pt,Rt as gt,S as ft,Sa as mt,Si as ht,Sn as bt,So as yt,Sr as vt,St as xt,T as wt,Ta as St,Ti as Ct,Tn as It,To as Tt,Tr as kt,Tt as Pt,U as Rt,Ua as Bt,Ui as At,Un as Mt,Uo as Ft,Ur as Ot,Ut as Dt,V as Et,Va as Lt,Vi as Nt,Vn as $t,Vo as zt,Vr as Ht,Vt as Wt,W as Ut,Wa as jt,Wi as Vt,Wn as Kt,Wo as _t,Wr as Xt,Wt as Gt,X as qt,Xa as Yt,Xn as Zt,Xo as Jt,Xr as Qt,Xt as en,Y as tn,Ya as nn,Yi as on,Yn as rn,Yo as an,Yr as ln,Yt as sn,Z as cn,Za as dn,Zn as un,Zt as pn,_ as gn,_a as fn,_i as mn,_n as hn,_o as bn,_r as yn,_t as vn,a as xn,aa as wn,ai as Sn,an as Cn,ao as In,ar as Tn,at as kn,b as Pn,ba as Rn,bi as Bn,bn as An,bo as Mn,br as Fn,bt as On,c as Dn,ca as En,cn as Ln,co as Nn,cr as $n,ct as zn,d as Hn,da as Wn,di as Un,dn as jn,do as Vn,dr as Kn,dt as _n,ei as Xn,en as Gn,eo as qn,er as Yn,es as Zn,et as Jn,f as Qn,fa as eo,fn as to,fo as no,fr as oo,ft as ro,g as ao,ga as io,gi as lo,gn as so,go as co,gr as uo,gt as po,h as go,ha as fo,hi as mo,hn as ho,ho as bo,hr as yo,ht as vo,i as xo,ia as wo,in as So,io as Co,ir as Io,it as To,j as ko,ja as Po,ji as Ro,jn as Bo,jo as Ao,jr as Mo,k as Fo,ka as Oo,kn as Do,kr as Eo,l as Lo,la as No,ln as $o,lo as zo,lr as Ho,lt as Wo,m as Uo,ma as jo,mi as Vo,mn as Ko,mo as _o,mr as Xo,mt as Go,n as qo,nn as Yo,no as Zo,nr as Jo,ns as Qo,nt as er,o as tr,oa as nr,oi as or,on as rr,oo as ar,or as ir,ot as lr,p as sr,pa as cr,pi as dr,pn as ur,po as pr,pr as gr,pt as fr,q as mr,qa as hr,qi as br,qn as yr,qo as vr,qr as xr,qt as wr,r as Sr,rn as Cr,ro as Ir,rr as Tr,s as kr,sa as Pr,si as Rr,sn as Br,so as Ar,sr as Mr,st as Fr,t as Or,tn as Dr,to as Er,tr as Lr,tt as Nr,u as $r,ua as zr,un as Hr,uo as Wr,ur as Ur,ut as jr,v as Vr,va as Kr,vi as _r,vn as Xr,vo as Gr,vr as qr,vt as Yr,w as Zr,wa as Jr,wi as Qr,wn as ea,wo as ta,wr as na,wt as oa,x as ra,xa as aa,xi as ia,xn as la,xo as sa,xr as ca,xt as da,y as ua,ya as pa,yi as ga,yn as fa,yo as ma,yr as ha,yt as ba,z as ya,za as va,zi as xa,zn as wa,zo as Sa,zr as Ca,zt as Ia}from"./defaultToolbar-CTtskguI.js";function Ta(e,t){return{document:e.document,selection:t}}function ka(e,t){if(!zr(e.selection))return ko(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=Ne(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,oe(Z(i,Math.min(r,u(i)))))}function Pa(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=Ne(e),i=u(o);if(t<0&&a>0)return Ta(e,{anchor:e.selection.anchor,focus:Z(o,a-1)});if(t>0&&a<i)return Ta(e,{anchor:e.selection.anchor,focus:Z(o,a+1)});if(t<0&&r>0){const t=n[r-1];return Ta(e,{anchor:e.selection.anchor,focus:Z(t,u(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return Ta(e,{anchor:e.selection.anchor,focus:Z(t,0)})}return e}function Ra(e,t){const{paragraphs:n,index:o,offset:r}=Ne(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,{anchor:e.selection.anchor,focus:Z(i,Math.min(r,u(i)))})}function Ba(e){const t=Wn(e);if(t.isCollapsed)return"";const n=Kr(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return Lt(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(Lt(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(Lt(n[i]));return o.push(Lt(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Aa(e,t){return{...e,selection:{anchor:nr(e,t.anchor),focus:nr(e,t.focus)}}}function Ma(e){if(!zr(e.selection))return ko(e,"start");const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o>0)return{document:e.document,selection:oe(Z(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:oe(Z(a,u(a)))}}function Fa(e){if(!zr(e.selection))return ko(e,"end");const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o<u(t))return{document:e.document,selection:oe(Z(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:oe(Z(a,0))}}function Oa(e){const t=Wn(e);if(t.isCollapsed)return"";const n=Kr(e),o=[];let r=null;const a=()=>{r&&(o.push("bullet"===r?"</ul>":"</ol>"),r=null)};for(let i=t.startIndex;i<=t.endIndex;i+=1){const l=n[i];if(!l)continue;const s=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:u(l),d=Rt(l,s,c),p=ke(l.style),g=p.length>0?` style="${p}"`:"",f=ae(d,e.document);if(l.list?.kind){const e="bullet"===l.list.kind?"ul":"ol";r!==l.list.kind&&(a(),o.push(`<${e}>`),r=l.list.kind),o.push(`<li${g}>${f}</li>`);continue}a(),o.push(`<p${g}>${f}</p>`)}return a(),o.join("")}function Da(e,t){if(0===t.length)return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Kr(n),s=Rt(o,0,i),c=Rt(o,i,u(o)),d=t.map(e=>{const t=_o(e.runs.map(e=>({text:e.text,styles:Yo(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let p,g=oe(Z(o,i));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=Ut(o,[...s,...e.runs.map(Gn),...c],Y(o,i));n.style=o.style?{...o.style}:e.style?{...e.style}:void 0,n.list=o.list?{...o.list}:e.list?{...e.list}:void 0,p=[...r(l.slice(0,a)),n,...r(l.slice(a+1))],g=oe(Z(n,s.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=d[0],t=d[d.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),u=Ut(o,[...s,...e.runs.map(Gn)],Y(o,i));u.style=o.style?{...o.style}:e.style?{...e.style}:void 0,u.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(pn),m=Ut(t,[...t.runs.map(Gn),...c],void 0);m.list=t.list?{...t.list}:void 0,p=[...r(l.slice(0,a)),u,...f,m,...r(l.slice(a+1))],g=oe(Z(m,n))}return Ie(n,p,g)}function Ea(e){return e.map(Gn)}function La(e){return e.reduce((e,t)=>e+t.text.length,0)}function Na(e,t,n){if(0===n.length)return e;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=Bt(a,t),l=Ea(n[0].runs);if(1===n.length){const t=d(a,i,l),n=o.map((e,n)=>n===r?t:e),s=La(l),c=Z(t,i),u=Z(t,i+s);return Ie(e,n,{anchor:c,focus:u})}const s=Rt(a,0,i),c=Rt(a,i,u(a)),p=n[n.length-1],g=n.slice(1,-1),f=Ut(pn(n[0].paragraphTemplate),[...s,...l],Y(a,i)),m=g.map(e=>Ut(pn(e.paragraphTemplate),Ea(e.runs))),h=Ut(pn(p.paragraphTemplate),[...Ea(p.runs),...c],Y(a,i)),b=[...o.slice(0,r),f,...m,h,...o.slice(r+1)],y=Z(f,La(s)),v=Z(h,La(p.runs));return Ie(e,b,{anchor:y,focus:v})}function $a(e,t,n={}){if(Wn(e).isCollapsed)return e;if(function(e,t){const n=Wn(e);if(n.isCollapsed)return!1;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return!1;if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r],i=Bt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,t))return e;const o=function(e){const t=Wn(e);if(t.isCollapsed)return[];const n=Kr(e),o=[];for(let r=t.startIndex;r<=t.endIndex;r+=1){const e=n[r],a=r===t.startIndex?t.startParagraphOffset:0,i=r===t.endIndex?t.endParagraphOffset:u(e),l=Rt(e,a,i);o.push({paragraphTemplate:pn(e),runs:l})}return o}(e);if(0===o.length)return e;if(n.copy)return Na(e,t,o);const r=function(e,t){const n=Wn(e),o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=Bt(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return Z(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,t);return Na(Me(e),r,o)}function za(e,t,n){if(0===t.length)return e;const o=zr(e.selection)?e:Me(e),{paragraph:r,index:a,offset:i}=Ne(o),l=n?{...n}:Y(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:l,kind:"text"};o.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=d(r,i,[s]),u=Kr(o).map((e,t)=>t===a?c:e);return Ie(o,u,oe(Z(c,i+t.length)))}function Ha(e){return za(e,"\v")}function Wa(e,t,n){if(0===t.length)return e;const o=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!o.includes("\n"))return za(e,o,n);const r=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ne(r),s=o.split("\n"),c=n?{...n}:Y(a,l),d=Rt(a,0,l),p=Ut(a,[...d,co(s[0],c)],c),g=Rt(a,l,u(a)),f=s.slice(1,-1).map(e=>mr([{text:e,styles:c}])),m=mr([{text:s[s.length-1],styles:c},...g.map(e=>({text:e.text,styles:e.styles}))]),h=Kr(r),b=[...h.slice(0,i),p,...f,m,...h.slice(i+1)];return Ie(r,b,oe(Z(m,s[s.length-1].length)))}function Ua(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o>0){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<=t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o-1),...Rt(t,o,u(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o-1)))}const c=i.text[s-1],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...Rt(t,0,o-1),d,...Rt(t,o,u(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o-1)))}}const a=Ut(t,[...Rt(t,0,o-1),...Rt(t,o,u(t))],Y(t,o-1)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o-1)))}if(0===n)return e;const a=r[n-1],i=Ut(a,[...a.runs.map(Gn),...t.runs.map(Gn)]),l=[...r.slice(0,n-1),i,...r.slice(n+1)];return Ie(e,l,oe(Z(i,u(a))))}function ja(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o<u(t)){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o),...Rt(t,o+1,u(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o)))}const c=i.text[s],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...Rt(t,0,o),d,...Rt(t,o+1,u(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o)))}}const a=Ut(t,[...Rt(t,0,o),...Rt(t,o+1,u(t))],Y(t,o)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o)))}if(n>=r.length-1)return e;const a=r[n+1],i=Ut(t,[...t.runs.map(Gn),...a.runs.map(Gn)]),l=[...r.slice(0,n),i,...r.slice(n+2)];return Ie(e,l,oe(Z(i,o)))}function Va(e,t,n,o,r){let a=Cr(n,o,r);const i=Te(a,t.style?.styleId,e.document.styles);return!r&&i[o]&&(a={...a,[o]:!1}),!r||"superscript"!==o&&"subscript"!==o||(a=Va(e,t,a,"superscript"===o?"subscript":"superscript",!1)),a}function Ka(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((t,o)=>{const r=n.startIndex+o,a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:u(t);return Rt(t,a,i).map(n=>({...n,styles:Te(n.styles,t.style?.styleId,e.document.styles)}))}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.[t])),i=o.map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const i=r===n.startIndex?n.startParagraphOffset:0,l=r===n.endIndex?n.endParagraphOffset:u(o);return Ye(o,i,l,n=>({...n,styles:Va(e,o,n.styles,t,a)}))});return Ie(e,i,$(i,n))}function _a(e,t,n){const o=Wn(e);if(o.isCollapsed)return e;const r=Kr(e).map((e,r)=>{if(r<o.startIndex||r>o.endIndex)return e;const a=r===o.startIndex?o.startParagraphOffset:0,i=r===o.endIndex?o.endParagraphOffset:u(e);return Ye(e,a,i,e=>({...e,styles:So(e.styles,t,n)}))});return Ie(e,r,$(r,o))}function Xa(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e),r=e.document.styles,a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:u(e);return Ye(e,a,i,n=>{const o=(Te(n.styles,e.style?.styleId,r).fontSize??14.6667)*ar,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:So(n.styles,"fontSize",a/ar)}})});return Ie(e,a,$(a,n))}var Ga={width:.5,type:"solid",color:"#000000"};function qa(e,t){const n={...e??{}};return t?n.textBorder=Ga:delete n.textBorder,Object.keys(n).length>0?n:void 0}function Ya(e){return/\p{L}/u.test(e)}function Za(e,t){switch(t){case"lower":return e.toLowerCase();case"upper":return e.toUpperCase();case"capitalize":return function(e){let t="",n=!1;for(const o of e){const e=Ya(o);t+=e&&!n?o.toUpperCase():o,n=e}return t}(e);case"toggle":return function(e){let t="";for(const n of e){const e=n.toUpperCase(),o=n.toLowerCase();t+=n===o&&n!==e?e:n===e&&n!==o?o:n}return t}(e);default:return function(e){let t="",n=!0;for(const o of e.toLowerCase())n&&Ya(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function Ja(e,t){return function(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e).map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:u(e),i=t(Rt(e,r,a).map(e=>e.text).join(""));let l=0;return Ye(e,r,a,e=>{const t=e.text.length,n=i.slice(l,l+t);return l+=t,{...e,text:n}})});return Ie(e,o,$(o,n))}(e,e=>Za(e,t))}var Qa=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function ei(e,t){const n=Yo(e)??{};delete n.link;for(const o of Qa)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function ti(e,t){if(0===t.length)return[];const n=Wn(e),o=Kr(e)[n.startIndex];if(!o)return t;const r=Y(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:ei(r,e.styles)})),style:Dr(o.style),list:o.list?{...o.list}:void 0}))}function ni(e){if("undefined"==typeof document||0===e.trim().length)return[];const t=document.createElement("template");t.innerHTML=e;const n=[],o=Array.from(t.content.childNodes),r=(e,t,o)=>{const r=t.length>0?t:[co("")];n.push({runs:r.map(e=>{const t=qn(e);return{text:e.text,styles:Yo(e.styles),image:t?{...t}:void 0}}),style:e?ve(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,br(n,void 0),{kind:t,level:0})};for(const i of o){if(i.nodeType===Node.TEXT_NODE){const e=i.textContent??"";e.trim().length>0&&r(null,[co(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=on(e.tagName);if(t){a(e,t);continue}if(pe(e.tagName)){r(e,br(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=br(e,void 0);n.length>0&&r(null,n)}return n}async function oi(e,t){if(e.isReadOnly())return!1;if("undefined"==typeof navigator||!Boolean(navigator.clipboard?.read||navigator.clipboard?.readText))return e.onIssue?.("access-denied"),!1;const n=e.state(),o={anchor:{...n.selection.anchor},focus:{...n.selection.focus}};let r;try{r=await async function(e){const t=navigator.clipboard;let n=/* @__PURE__ */new Error("Clipboard access unavailable"),o=!1,r=!1;const a="text"===e&&Boolean(t?.readText);if(a)try{const e=await t.readText();return e?{kind:"content",text:e,html:""}:{kind:"empty"}}catch(i){n=i}if(t?.read)try{const n=await t.read();let a="",i="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(a=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(i=await(await t.getType("text/plain")).text());if(a||i)return{kind:"content",html:a,text:i};o=!0,r=n.length>0}catch(i){n=i}if(!a&&t?.readText)try{const e=await t.readText();if(e)return{kind:"content",text:e,html:""};o=!0}catch(i){n=i}if(o)return{kind:r?"unsupported":"empty"};throw n}(t)}catch(s){return e.onError?.(s),e.onIssue?.("access-denied"),!1}if(e.isReadOnly())return!1;if(e.state().document!==n.document)return e.onIssue?.("document-changed"),!1;if("content"!==r.kind)return e.onIssue?.(r.kind),!1;const a="text"!==t?ni(r.html):[],i="merge"===t?ti({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return e.onIssue?.("unsupported"),!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let l=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},s=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Da(e,i):Wa(e,r.text));return l=s.document!==t.document,s}),l&&e.focusInput(),l}function ri(e){if("undefined"==typeof document||"function"!=typeof document.execCommand)return!1;const t=document.activeElement,n=document.createElement("textarea");n.value=e,n.readOnly=!0,n.setAttribute("aria-hidden","true"),n.style.cssText="position:fixed;opacity:0;left:-9999px;top:0",document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),document.execCommand("copy")}catch{return!1}finally{n.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}}function ai(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>ri(e))}catch{}return Promise.resolve(ri(e))}async function ii(e,t){const n=await function(e){const t=Ba(e);if(!t)return Promise.resolve(!1);const n="undefined"!=typeof navigator?navigator.clipboard:void 0;if(n?.write&&"undefined"!=typeof ClipboardItem)try{const o=Oa(e),r=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})});return n.write([r]).then(()=>!0,()=>ai(t))}catch{}return ai(t)}(e);return!n&&Ba(e)&&t?.("access-denied"),n}function li(e){return function(e){const[t,n]=an();let r,a=0;Jt()&&o(()=>{a++});const i=()=>{n(void 0),r=void 0},l=()=>{a++,i()},s=async(t,o="rich")=>{const l=++a;i();const s=e.state(),c=i=>{l===a&&(n({action:t,issue:i,..."paste"===t?{mode:o}:{}}),"access-denied"!==i&&"unsupported"!==i||("paste"!==t||"unsupported"===i&&"rich"!==o||(r={document:s.document,mode:o}),e.focusInput()),e.onIssue?.(i))};if("copy"===t)return ii(s,c);const d={...e,onIssue:c,isReadOnly:()=>l!==a||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.state();if(!Ba(t))return!1;if(!(await ii(t,e.onIssue))||e.isReadOnly())return!1;if(e.state().document!==t.document)return e.onIssue?.("document-changed"),!1;const n={anchor:{...t.selection.anchor},focus:{...t.selection.focus}};let o=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==t.document)return r;const a={...r,selection:n},i=e.applyTableAwareParagraphEdit(a,e=>Ua(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):oi(d,o)},c=()=>{const t=r;return l(),t?.document===e.state().document?t.mode:void 0};return{notice:t,dismiss:l,consumePasteMode:c,copy:()=>s("copy"),cut:()=>s("cut"),paste:(e="rich")=>s("paste",e),hasSelection:()=>Ba(e.state()).length>0}}(e)}var si=/*#__PURE__*/f("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),ci=/*#__PURE__*/f("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function di(e){const t=R();let n;const[r,a]=an(12);we(()=>{if(!e.notice())return;const t=n?.parentElement;if(!t)return;const r=()=>{const e=t.getBoundingClientRect(),o=t.querySelector(".oasis-editor-toolbar"),r=o?o.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),l=window.innerHeight-e.top-(n?.offsetHeight??0)-12;a(Math.max(i,Math.min(r,l)))};queueMicrotask(r);const i=new ResizeObserver(r);i.observe(t),n&&i.observe(n);const l=t.querySelector(".oasis-editor-toolbar");l&&i.observe(l),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),o(()=>{i.disconnect(),window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)})});return i=si(),"function"==typeof n?zt(n,i):n=i,We(i,X(Ft,{get when(){return e.notice()},children:n=>{return o=ci(),We(o,X(Qr,{name:"clipboard"}),null),We(o,X(ia,{get children(){return(e=>{const n=`${/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+"}${"copy"===e.action?"C":"cut"===e.action?"X":"V"}`,o="access-denied"===e.issue?`clipboard.${e.action}Denied`:"empty"===e.issue?"clipboard.empty":"document-changed"===e.issue?"clipboard.documentChanged":e.mode&&"rich"!==e.mode?"clipboard.unsupportedOption":"clipboard.unsupported";return t(o,[n])})(n())}}),null),We(o,X(A,{variant:"ghost",size:"sm",icon:"x",get label(){return t("generic.close")},get onClick(){return e.onDismiss},"data-testid":"editor-clipboard-feedback-close"}),null),o;var o}})),fe(e=>Re(i,"top",`${r()}px`)),i;var i}var ui=/[\s\-–—/_([{]/;function pi(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=t.toLowerCase();if(o===n)return 1e3;const r=o.indexOf(n);if(r>=0){let e=400;return 0===r?e+=400:!function(e,t){return 0===t||ui.test(e[t-1]??"")}(o,r)?e+=100:e+=200,e+=Math.round(n.length/o.length*50),e}let a=0,i=-1,l=-1,s=0;for(const d of n){const e=o.indexOf(d,a);if(-1===e)return null;-1===i&&(i=e),s+=e-a,a=e+1,l=e}const c=l-i+1;return Math.max(1,120-s-4*Math.abs(c-n.length))}function gi(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=pi(n,t.label),r=pi(n,t.command),a=Math.max(o??Number.NEGATIVE_INFINITY,(r??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var fi=/*#__PURE__*/f("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),mi=/*#__PURE__*/f("<div class=oasis-command-search-overlay role=presentation data-testid=editor-command-search-overlay><div class=oasis-command-search role=dialog aria-modal=true data-testid=editor-command-search>"),hi=/*#__PURE__*/f("<kbd class=oasis-command-search-shortcut>"),bi=/*#__PURE__*/f("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function yi(e){const t=R(),[n,o]=an(""),[r,a]=an(0);let i;we(()=>{e.isOpen&&(o(""),a(0),queueMicrotask(()=>{i?.focus()}))});const l=vr(()=>function(e,t,n=24){const o=e.trim().toLowerCase();if(0===o.length)return t.map(e=>({...e,score:0})).sort((e,t)=>e.label.localeCompare(t.label)).slice(0,n);const r=[];for(const a of t){const e=gi(o,a);null!==e&&r.push({...a,score:e})}return r.sort((e,t)=>t.score-e.score||e.label.length-t.label.length),r.slice(0,n)}(n(),e.entries,12));we(()=>{l(),a(e=>Math.min(e,Math.max(0,l().length-1)))});const c=t=>e.isEnabled(t.command,t.payload),d=t=>{c(t)&&e.onExecute(t)},u=e=>{const t=l().length;0!==t&&a(n=>(n+e+t)%t)},p=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),u(1);break;case"ArrowUp":t.preventDefault(),u(-1);break;case"Enter":{t.preventDefault();const e=l()[r()];e&&d(e);break}case"Escape":t.preventDefault(),e.onClose()}};return X(Ft,{get when(){return e.isOpen},get children(){var u=mi(),g=u.firstChild;return s(u,"click",e.onClose,!0),g.$$keydown=p,g.$$click=e=>e.stopPropagation(),We(g,X(po,{id:"editor-command-search-input",get placeholder(){return t("commandSearch.placeholder")},get value(){return n()},onChange:e=>{o(e)},ref(e){"function"==typeof i?i(e):i=e},role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":"editor-command-search-listbox",get"aria-activedescendant"(){return et(()=>!!l()[r()])()?`editor-command-search-option-${r()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),We(g,X(ia,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),We(g,X(Ft,{get when(){return l().length>0},get fallback(){return X(ia,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=fi();return We(e,X(ee,{get each(){return l()},children:(e,t)=>{const n=()=>t()===r(),o=()=>c(e);return(i=bi()).$$click=()=>d(e),i.addEventListener("mouseenter",()=>{a(t())}),We(i,X(ia,{as:"span",get children(){return e.label}}),null),We(i,X(Ft,{get when(){return e.shortcut},get children(){var t=hi();return We(t,()=>e.shortcut),t}}),null),fe(r=>{var a=`editor-command-search-option-${t()}`,l=n(),s=!o()||void 0,c=!!n(),d=!o(),u=e.command;return a!==r.e&&le(i,"id",r.e=a),l!==r.t&&le(i,"aria-selected",r.t=l),s!==r.a&&le(i,"aria-disabled",r.a=s),c!==r.o&&i.classList.toggle("oasis-command-search-option-active",r.o=c),d!==r.i&&i.classList.toggle("oasis-command-search-option-disabled",r.i=d),u!==r.n&&le(i,"data-command",r.n=u),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i;var i}})),e}}),null),We(g,X(ht,{size:"sm",variant:"ghost",class:"oasis-command-search-close",get onClick(){return e.onClose},"data-testid":"editor-command-search-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),fe(()=>le(g,"aria-label",t("commandSearch.title"))),u}})}function vi(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function xi(e){return vi(e.command)}Ee(["click","keydown"]);var wi=/*#__PURE__*/f("<div class=oasis-quick-access role=region data-testid=editor-quick-access>"),Si=/*#__PURE__*/f("<button type=button class=oasis-editor-line-spacing-item role=menuitemcheckbox><span class=oasis-editor-line-spacing-item-check aria-hidden=true></span><span class=oasis-editor-line-spacing-item-label>");function Ci(e){const t=R(),n=vr(()=>{e.tick();const t={};for(const n of e.catalog)t[n.command]=e.canExecute(n.command);return t});return o=wi(),We(o,X(ee,{get each(){return e.catalog.filter(t=>e.visible().includes(t.command))},children:o=>X(dr,{get icon(){return o.icon},get tooltip(){return t(o.labelKey)},get"aria-label"(){return t(o.labelKey)},get"data-testid"(){return`editor-qat-${o.command}`},get disabled(){return!n()[o.command]},onClick:()=>e.onExecute(o.command)})}),null),We(o,X(Un,{icon:"chevron-down",testId:"editor-qat-customize",get tooltip(){return t("quickAccess.customize")},hideChevron:!0,panelClass:"oasis-quick-access-menu",get children(){return X(ee,{get each(){return e.catalog},children:n=>{const o=()=>e.visible().includes(n.command);return r=Si(),a=r.firstChild,i=a.nextSibling,r.$$click=()=>e.onToggle(n.command),We(a,X(Ft,{get when(){return o()},get children(){return X(v,{size:14})}})),We(i,()=>t(n.labelKey)),fe(e=>{var a=!!o(),i=o(),l=t(n.labelKey),s=`editor-qat-toggle-${n.command}`;return a!==e.e&&r.classList.toggle("oasis-editor-line-spacing-item-active",e.e=a),i!==e.t&&le(r,"aria-checked",e.t=i),l!==e.a&&le(r,"aria-label",e.a=l),s!==e.o&&le(r,"data-testid",e.o=s),e},{e:void 0,t:void 0,a:void 0,o:void 0}),r;var r,a,i}})}}),null),fe(()=>le(o,"aria-label",t("quickAccess.title"))),o;var o}Ee(["click"]);var Ii=/*#__PURE__*/f("<div class=oasis-chrome-strip data-testid=editor-chrome-strip>");function Ti(e){const t=R();return n=Ii(),We(n,X(Ci,{get catalog(){return e.catalog},get visible(){return e.visible},get onToggle(){return e.onToggle},get onExecute(){return e.onExecute},get canExecute(){return e.canExecute},get tick(){return e.tick}}),null),We(n,X(ia,{as:"span",class:"oasis-chrome-strip-spacer","aria-hidden":"true"}),null),We(n,X(dr,{icon:"search",get label(){return t("toolbar.tellMe")},wide:!0,get tooltip(){return`${t("toolbar.tellMe")} (Alt+Q)`},"data-testid":"editor-toolbar-tell-me",get onClick(){return e.onOpenCommandSearch}}),null),n;var n}var ki="oasis-quick-access-v1",Pi=["saveDocument","undo","redo","repeatLastAction"];function Ri(e){const t=new Set(e.map(e=>e.command)),n=function(){try{const e=globalThis.localStorage?.getItem(ki);if(!e)return[...Pi];const t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e):[...Pi]}catch{return[...Pi]}}().filter(e=>t.has(e)),o=n.length>0?[...n,...Pi.filter(e=>t.has(e)&&!n.includes(e))]:[...Pi],[r,a]=an(o);return we(()=>{!function(e){try{globalThis.localStorage?.setItem(ki,JSON.stringify(e))}catch{}}(r())}),{catalog:e,visible:r,isShown:e=>r().includes(e),toggle:e=>{t.has(e)&&a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}}}var Bi=[{command:"saveDocument",icon:"save",labelKey:"generic.save"},{command:"undo",icon:"undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z"},{command:"redo",icon:"redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y"},{command:"repeatLastAction",icon:"repeat",labelKey:"quickAccess.repeat",shortcut:"F4"},{command:"find",icon:"search",labelKey:"find.title",shortcut:"Ctrl+F"},{command:"print",icon:"printer",labelKey:"menu.file.print",shortcut:"Ctrl+P"},{command:"exportDocx",icon:"file-text",labelKey:"toolbar.exportDocx"},{command:"exportPdf",icon:"file-down",labelKey:"toolbar.exportPdf"},{command:"toggleTrackChanges",icon:"file-check",labelKey:"toolbar.trackChanges"},{command:"toggleRevisionMarkup",icon:"highlighter",labelKey:"toolbar.revisionMarkup"},{command:"toggleCommentsPanel",icon:"list-filter",labelKey:"review.commentsPanel"},{command:"toggleRevisionsPanel",icon:"list-checks",labelKey:"toolbar.revisionsPanel"},{command:"toggleOutlinePanel",icon:"list",labelKey:"menu.view.outline"},{command:"togglePreciseFonts",icon:"type",labelKey:"menu.view.preciseFonts"},{command:"toggleShowParagraphMarks",icon:"pilcrow",labelKey:"menu.view.paragraphMarks"},{command:"toggleShowMargins",icon:"scan",labelKey:"menu.view.margins"}],Ai=!1,Mi=null,Fi=null,Oi=null,Di=[];function Ei(){"undefined"!=typeof window&&(!function(){const e={BASE_URL:"./",DEV:!1,MODE:"lib",PROD:!0,SSR:!1},t=globalThis.process?.env??{};return!0===e.DEV||"test"===e.MODE||"test"===t.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?Ai&&(delete window.__oasisCanvasDebug,Ai=!1):Ai||(window.__oasisCanvasDebug={getLastHit:()=>Mi?{...Mi}:null,getLayoutSnapshot:()=>Fi?{...Fi,surfaceRect:{...Fi.surfaceRect},pages:Fi.pages.map(e=>({...e})),paragraphs:Fi.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:Fi.inlineImages.map(e=>({...e})),inlineTextBoxes:Fi.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:Fi.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Oi?{anchor:{...Oi.anchor},focus:{...Oi.focus},activeZone:Oi.activeZone,activeSectionIndex:Oi.activeSectionIndex}:null,getMissEvents:()=>Di.map(e=>({...e})),clearMissEvents:()=>{Di=[]}},Ai=!0))}function Li(e){Ai&&e&&(Mi={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Ni=["Aptos, sans-serif","Aptos Display, sans-serif","Arial","Arial Black","Bahnschrift, sans-serif","Book Antiqua, serif","Calibri, sans-serif","Calibri Light, sans-serif","Cambria, serif","Candara, sans-serif","Century Gothic, sans-serif","Comic Sans MS","Consolas, monospace","Constantia, serif","Corbel, sans-serif","Courier New","Franklin Gothic Medium, sans-serif","Garamond, serif","Georgia","Gill Sans, sans-serif","Helvetica, sans-serif","Impact","Inter","Lucida Console, monospace","Lucida Sans Unicode, sans-serif","Open Sans, sans-serif","Palatino Linotype, serif","Segoe UI, sans-serif","Tahoma, sans-serif","Times New Roman","Trebuchet MS, sans-serif","Verdana, sans-serif","Wingdings"];function $i(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function zi(e){return function(e){const[t,n]=an([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))$i(r,o,i.textStyle?.fontFamily);$i(r,o,t.fontFamily);for(const i of n)$i(a,o,i);for(const i of Ni)$i(a,o,i);return[...r.sort((e,t)=>e.localeCompare(t)),...a.sort((e,t)=>e.localeCompare(t))]}(e.state().document,e.toolbarStyleState(),t()),r=()=>function(e,t){const n=new Set(qo);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(xo(e))}const o=xo(Number(t.fontSize));return Number.isFinite(o)&&o>0&&n.add(o),Array.from(n).sort((e,t)=>e-t)}(e.state().document,e.toolbarStyleState());return{computeFontFamilyOptions:o,computeFontSizeOptions:r,loadLocalFontFamilyOptions:async()=>{if(t().length>0)return;const e=await $t();e.length>0&&n(e)}}}(e)}var Hi="insertText",Wi="composition",Ui="insertImage",ji="insertTable",Vi="moveImage",Ki="splitListItem",_i="link",Xi="imageAlt",Gi="imageCaption",qi="imageResize",Yi="imageCrop",Zi="imageFlip",Ji="imageRotate",Qi="imageTransparency",el="imageReset",tl="layoutWrapPolygon",nl="specialIndent",ol="paraBorders",rl="paragraphMoveUp",al="paragraphMoveDown",il="findReplace",ll="findReplaceAll",sl="tableProperties",cl="paragraph-dialog",dl="font-dialog",ul="copyTextByDrag",pl="moveTextByDrag",gl="collapseSelectionByClick",fl="mergeTable",ml="splitTable",hl="insertTableColumn",bl="deleteTableColumn",yl="insertTableRow",vl="deleteTableRow",xl="tableShading",wl="tableBorders",Sl="tableWidth",Cl="tableAlign",Il="tableCellAlignment",Tl="tableCellVerticalAlign",kl="tableCellTextDirection",Pl="tableCellWidth",Rl="tableColumnWidth",Bl="tableToText",Al="textToTable",Ml="tableSplitAtRow",Fl="tableSortAscending",Ol="tableSortDescending",Dl="tableDelete",El="deleteTableCell",Ll="tableAutoFit",Nl="tableRepeatHeaderRows",$l="tableCellMargins",zl="tableFormula",Hl="tableRowHeight",Wl="tableStyleOptions",Ul="tableStyleGallery",jl="tableDistribute",Vl="layoutWrapPreset",Kl="layoutFixedPosition",_l="shapeFill",Xl="shapeOutline",Gl="shapeOutlineWidth",ql="floatingAlign",Yl="floatingReorder",Zl="floatingNudge",Jl="floatingFixedPosition",Ql="floatingRotation",es="floatingWrap",ts="floatingWrapText",ns="floatingPositionPreset",os="shapePreset",rs="textBoxTextDirection",as="textBoxVerticalAlign",is="textBoxAlt",ls="textBoxRotate",ss="textBoxWidthCm",cs="textBoxHeightCm";function ds(e,t){const n={...e},o=(e,t)=>{null==t?delete n[e]:n[e]=t};return o("align",t.align),o("indentLeft",t.indentLeft),o("indentRight",t.indentRight),o("indentFirstLine",t.indentFirstLine),o("indentHanging",t.indentHanging),n.mirrorIndents=t.mirrorIndents,o("spacingBefore",t.spacingBefore),o("spacingAfter",t.spacingAfter),o("lineHeight",t.lineHeight),o("lineRule",t.lineRule),n.contextualSpacing=t.contextualSpacing,o("outlineLevel",t.outlineLevel),o("shading",t.shading),o("borderTop",t.borders.top),o("borderRight",t.borders.right),o("borderBottom",t.borders.bottom),o("borderLeft",t.borders.left),n.pageBreakBefore=t.pageBreakBefore,n.keepWithNext=t.keepWithNext,n.keepLinesTogether=t.keepLinesTogether,n.widowControl=t.widowControl,o("tabs",t.tabs.length>0?t.tabs:null),n}function us(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function ps(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function gs(e,t){const n=Fe(e.document).map(e=>({...e,blocks:t(e.blocks),header:e.header?t(e.header):void 0,firstPageHeader:e.firstPageHeader?t(e.firstPageHeader):void 0,evenPageHeader:e.evenPageHeader?t(e.evenPageHeader):void 0,footer:e.footer?t(e.footer):void 0,firstPageFooter:e.firstPageFooter?t(e.firstPageFooter):void 0,evenPageFooter:e.evenPageFooter?t(e.evenPageFooter):void 0})),o=e.document.footnotes?{...e.document.footnotes,items:Object.fromEntries(Object.entries(e.document.footnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0,r=e.document.endnotes?{...e.document.endnotes,items:Object.fromEntries(Object.entries(e.document.endnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0;return{...e,document:{...e.document,sections:n,footnotes:o,endnotes:r}}}function fs(e,t){return e.map(e=>{if("paragraph"===e.type)return e;const n=t(e);return{...n,rows:n.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:fs(e.blocks,t)}))}))}})}function ms(e,t,n){const o=Fe(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function hs(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function bs(e){const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:hs(n)}:null}function ys(e,t,n){const o=t[0];if(!o)return e;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return e;if(1===t.length){const t=n(r);if(t===r)return e;const a=[...e];return a[o.tableBlockIndex]=t,a}const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return e;const l=ys(i.blocks,t.slice(1),n);if(l===i.blocks)return e;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function vs(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function xs(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?vs(e.firstPageHeader,n)?"firstPage":vs(e.evenPageHeader,n)?"evenPage":"default":vs(e.firstPageFooter,n)?"firstPage":vs(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[Rn(t,o)]??null}return null}function ws(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?vs(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:vs(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?vs(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:vs(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function Ss(e,t){const n=t[0];if(!n||!e)return null;const o=e[n.tableBlockIndex];if(!o||"table"!==o.type)return null;if(1===t.length)return o;const r=o.rows[n.rowIndex],a=r?.cells[n.cellIndex];return r&&a?Ss(a.blocks,t.slice(1)):null}function Cs(e,t,n){const o=t[0];if(!o)return null;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return null;if(1===t.length)return[...e.slice(0,o.tableBlockIndex),...n,...e.slice(o.tableBlockIndex+1)];const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return null;const l=Cs(i.blocks,t.slice(1),n);if(!l)return null;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function Is(e){const t=bs(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return ks(e,r);const a=Fe(e.document)[n];return a?xs(a,o.zone,r):null}function Ts(e){const t=e.selection.focus.paragraphId,n=io(e);if("footnote"===n)return ks(e,t);const o=fo(e),r=Fe(e.document)[o];return r?xs(r,n,t):null}function ks(e,t){const n=Jr(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function Ps(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>Cs(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Jr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Fe(e.document).map((e,t)=>t===o?ws(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function Rs(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>ys(e,r.tablePath,t);if("footnote"===r.zone){const t=Jr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Fe(e.document).map((e,t)=>t===o?ws(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var Bs={width:.5,type:"solid",color:"#000000"},As={width:0,type:"none",color:"transparent"};function Ms(e){const t=fo(e),n=F(e.document,e.selection.anchor.paragraphId,t),o=F(e.document,e.selection.focus.paragraphId,t);if(!n||!o||n.zone!==o.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(n.tablePath,o.tablePath))return null;const r=ms(e.document,t,n.zone);if(!r)return null;const a=i(r,n.tablePath),l=i(r,o.tablePath),s=a?.[a.length-1],c=l?.[l.length-1];if(!s||!c||s.table!==c.table)return null;const d=n.tablePath[n.tablePath.length-1],u=o.tablePath[o.tablePath.length-1];if(!d||!u)return null;const p=ln(s.table),g=p.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex),f=p.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex);if(!g||!f)return null;const m=Math.min(g.visualRowIndex,f.visualRowIndex),h=Math.max(g.visualRowIndex+g.rowSpan-1,f.visualRowIndex+f.rowSpan-1),b=Math.min(g.visualColumnIndex,f.visualColumnIndex),y=Math.max(g.visualColumnIndex+g.colSpan-1,f.visualColumnIndex+f.colSpan-1);return{entries:p,selectedEntries:p.filter(e=>e.visualRowIndex<=h&&e.visualRowIndex+e.rowSpan-1>=m&&e.visualColumnIndex<=y&&e.visualColumnIndex+e.colSpan-1>=b),startRow:m,endRow:h,startCol:b,endCol:y}}function Fs(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=Ms(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of Po(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=Wn(e),o=Kr(e);for(let r=n.startIndex;r<=n.endIndex;r+=1)t.add(o[r].id);return t}(e))o.add(i);const r=o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...us(),type:"property",previous:{...r??{}}}}),{...o,style:ps(r,t,n)}},a=Fe(e.document).map(e=>({...e,blocks:ya(e.blocks,o,r),header:e.header?ya(e.header,o,r):void 0,footer:e.footer?ya(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function Os(e,t){let n=Fs(e,"borderTop",t);return n=Fs(n,"borderRight",t),n=Fs(n,"borderBottom",t),n=Fs(n,"borderLeft",t),n}function Ds(e,t,n){const o=function(e){const t=Wn(e),n=Kr(e),o=/* @__PURE__ */new Set;for(let r=t.startIndex;r<=t.endIndex;r+=1)o.add(n[r].id);return o}(e),r=a=>a.map(a=>{if("paragraph"===a.type)return a;const i=a.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:r(e.blocks)}))})),l={...a,rows:i};return function(e,t){return e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>"paragraph"===e.type&&t.has(e.id))))}(a,o)?(o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&!r?.revision&&(r={...r??{},revision:{...us(),type:"property",previous:{...r??{}}}}),{...o,style:ps(r,t,n)}})(l):l});return gs(e,r)}function Es(e,t,n,o){const r=r=>{if(r.id!==t)return r;let a=r.style;return e.trackChangesEnabled&&"revision"!==n&&!a?.revision&&(a={...a??{},revision:{...us(),type:"property",previous:{...a??{}}}}),{...r,style:ps(a,n,o)}};return gs(e,e=>fs(e,r))}function Ls(e,t,n){const o=bs(e);if(!o)return e;return Rs(e,r=>{const a=r.rows.map((r,a)=>a===o.loc.rowIndex?(()=>{let o=r.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...us(),type:"property",previous:{...o??{}}}}),{...r,style:ps(o,t,n)}})():r);return{...r,rows:a}})}function Ns(e,t){const n=bs(e);if(!n)return e;return Rs(e,o=>({...o,rows:o.rows.map((o,r)=>{if(r!==n.loc.rowIndex)return o;let a=o.style;e.trackChangesEnabled&&!a?.propertyRevision&&(a={...a??{},propertyRevision:{...us(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:ps(a,"isHeader",i??null)}})}))}function $s(e,t,n){const o=o=>{if(o.id!==t)return o;const r=o.rows.map((t,o)=>{if(!Object.prototype.hasOwnProperty.call(n,o))return t;let r=t.style;return e.trackChangesEnabled&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...us(),type:"property",previous:{...r??{}}}}),{...t,style:ps(r,"height",n[o])}});return{...o,rows:r}};return gs(e,e=>fs(e,o))}function zs(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"!=typeof e)return null;const t=e.trim().toLowerCase();if(!t||t.includes("%"))return null;if(t.endsWith("pt")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}if(t.endsWith("px")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e*ar:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Hs(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=ln(a),l=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),s=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(s);let d=!1,u=!0;for(let e=0;e<s;e+=1){const t=zs(n[e]);if(null!==t){c[e]=Math.max(1,t),d=!0;continue}const o=a.gridCols?.[e];if(!("number"==typeof o&&Number.isFinite(o)&&o>0)){u=!1;break}c[e]=o}const p=a.rows.map((t,o)=>{const r=t.cells.map((t,r)=>{const a=l.get(`${o}:${r}`);if(!a)return t;const i=n[a.visualColumnIndex+a.colSpan-1];if(void 0!==i&&1===a.colSpan){const n=e.trackChangesEnabled&&!t.style?.propertyRevision?{...us(),type:"property",previous:{...t.style??{}}}:t.style?.propertyRevision;return{...t,style:{...t.style??{},width:i,...n?{propertyRevision:n}:{}}}}return t});return{...t,cells:r}}),g={...a.style??{}};return!e.trackChangesEnabled||g.revision||void 0===o&&void 0===r||(g.revision={...us(),type:"property",previous:{...a.style??{}}}),void 0!==o&&(g.width=o),void 0!==r&&(g.indentLeft="number"==typeof r?r:Number(r)),{...a,rows:p,gridCols:d&&u?c:a.gridCols,gridRevision:e.trackChangesEnabled&&d&&u&&!a.gridRevision?{...us(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return gs(e,e=>fs(e,a))}function Ws(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=function(e){const t=[];for(const n of e.rows)for(const e of n.cells)for(const n of e.blocks)"paragraph"===n.type&&t.push(pn(n));return t}(o);if(0===r.length)return e;const a=Ps(e,r);if(a===e)return e;const i=r[0];return{...a,selection:oe(Z(i,0))}}function Us(e){if(bs(e))return e;if(!Ts(e))return e;const t=Kr(e);if(0===t.length)return e;const n=Wn(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(js),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>ma(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:no("paragraph"),type:"paragraph",runs:o.length>0?o:[bo("")]};return Gr([r])})));return bn(o)}(o),a=o[0].id,i=o[o.length-1].id;let l=null,s=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=io(e),r=fo(e);if("footnote"===o){const o=Jr(e.document,n)?.footnoteId??e.activeFootnoteId,r=e.document.footnotes,a=o?r?.items[o]:void 0;return o&&r&&a?{...e,document:{...e.document,footnotes:{...r,items:{...r.items,[o]:{...a,blocks:t(a.blocks)}}}}}:e}const a=Fe(e.document).map((e,a)=>a===r?ws(e,o,n,t):e);return{...e,document:{...e.document,sections:a}}}(e,e=>{const{nextBlocks:t,cell:n}=function(e,t,n,o){let r=-1,a=-1;for(let l=0;l<e.length;l+=1){const o=e[l];"paragraph"===o.type&&(o.id===t&&(r=l),o.id===n&&(a=l))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let l=r;l<=a;l+=1)if("paragraph"!==e[l].type)return{nextBlocks:null,cell:null};const i=o.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return{nextBlocks:[...e.slice(0,r),o,...e.slice(a+1)],cell:i??null}}(e,a,i,r);return t&&n?(l=n,s=!0,t):e});return s&&l?{...c,selection:oe(Z(l,0))}:e}function js(e){const t=[];let n=[];const o=()=>{n.length>0&&t.push(n),n=[]};for(const r of e.runs){const e=r.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&o();const a=e[t];if(a.length>0){const e=Gn(r);e.id=`run:${Math.random().toString(36).slice(2,9)}`,e.text=a,n.push(e)}}}return n.length>0&&t.push(n),t}function Vs(e,t){const n=bs(e);if(!n)return e;const o=n.loc.cellIndex;return Rs(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const s of e.rows)s.isHeader?o.push(s):r.push(s);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=Ks(e.cells[t]),r=Ks(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),l=[...o,...i];return l.length===e.rows.length&&l.every((t,n)=>t===e.rows[n])?e.rows:l}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function Ks(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function _s(e){return!0===e.isHeader}function Xs(e){return null!==bs(e)}function Gs(e){return null!==bs(e)}var qs=/* @__PURE__ */new Set(["left","center","right"]);function Ys(e,t){const n=bs(e);if(!n)return e;if(null!==t&&!qs.has(t))return e;const o=function(e,t){const n=bs(e);if(!n)return null;const o=i(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,ms(e.document,n.activeSectionIndex,n.loc.zone)??[]);if(!o)return e;const r=o.style?.align,a=null===t?void 0:t;return r===a?e:Ds(e,"align",a)}function Zs(e){return null!==bs(e)}var Js=["SUM","AVERAGE","COUNT","MIN","MAX"];function Qs(e,t){const n=function(e){const t=/^\s*=\s*([A-Z]+)\s*\(\s*([A-Z]+)\s*\)\s*$/i.exec(e);if(!t)return null;const n=t[1].toUpperCase(),o=t[2].toUpperCase();return Js.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=bs(e);if(!o)return e;const r=Is(e);if(!r)return e;const a=Ss(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=ln(e),r=o.find(e=>e.rowIndex===n.rowIndex&&e.cellIndex===n.cellIndex);if(!r)return[];const a=[];for(const i of o){if(i.rowIndex===n.rowIndex&&i.cellIndex===n.cellIndex)continue;if(!tc(r,i,t))continue;if(!nc(r,i,t))continue;const e=oc(ec(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const l=function(e){if(Number.isInteger(e)||!Number.isFinite(e))return String(e);const t=Math.round(1e6*e)/1e6;return String(t)}(function(e,t){switch(e){case"SUM":return t.reduce((e,t)=>e+t,0);case"AVERAGE":return t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0;case"COUNT":return t.length;case"MIN":return t.length>0?Math.min(...t):0;case"MAX":return t.length>0?Math.max(...t):0}}(n.function,i)),s=o.loc.rowIndex,c=o.loc.cellIndex,d=Rs(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[pr(l)]})})}));if(d===e)return e;const u=pr(l);return{...d,selection:oe(Z(u,l.length))}}function ec(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function tc(e,t,n){if("LEFT"===n||"RIGHT"===n){const n=e.visualRowIndex+e.rowSpan,o=t.visualRowIndex+t.rowSpan;return e.visualRowIndex<o&&t.visualRowIndex<n}const o=e.visualColumnIndex+e.colSpan,r=t.visualColumnIndex+t.colSpan;return e.visualColumnIndex<r&&t.visualColumnIndex<o}function nc(e,t,n){switch(n){case"ABOVE":return t.visualRowIndex+t.rowSpan<=e.visualRowIndex;case"BELOW":return t.visualRowIndex>=e.visualRowIndex+e.rowSpan;case"LEFT":return t.visualColumnIndex+t.colSpan<=e.visualColumnIndex;case"RIGHT":return t.visualColumnIndex>=e.visualColumnIndex+e.colSpan}}function oc(e){const t=/\d+(?:[.,]\d+)?/.exec(e);if(!t)return null;const n=t[0].replace(",","."),o=Number(n);return Number.isFinite(o)?o:null}function rc(e,t){const n=function(e){const t=bs(e);if(!t)return null;const n=Is(e);if(!n)return null;const o=Ss(n,t.loc.tablePath);if(!o)return null;const r=ln(o),a=r.find(e=>e.rowIndex===t.loc.rowIndex&&e.cellIndex===t.loc.cellIndex);return a?{table:o,entries:r,active:a}:null}(e);if(!n)return e;const{table:o,entries:r,active:a}=n,i=function(e,t,n,o){switch(o){case"cell":return[n];case"row":{const e=n.visualRowIndex,o=n.visualRowIndex+n.rowSpan;return t.filter(t=>{const n=t.visualRowIndex,r=t.visualRowIndex+t.rowSpan;return n<o&&e<r})}case"column":{const e=n.visualColumnIndex,o=n.visualColumnIndex+n.colSpan;return t.filter(t=>{const n=t.visualColumnIndex,r=t.visualColumnIndex+t.colSpan;return n<o&&e<r})}case"table":return[...t]}}(0,r,a,t);if(0===i.length)return e;const l=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),s=l[0].cell,c=l[l.length-1].cell,d=ac(s),u=ac(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:Z(p,0),focus:Z(g,Lt(g).length)}}:e}function ac(e){return e.blocks.flatMap(Po)}function ic(e){const t=function(e){const t=bs(e);if(!t)return null;const n=Is(e);if(!n)return null;const o=Ss(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function lc(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex,a=t.loc.cellIndex,i=o.rows[r];if(!i||i.cells.length<=1||a>=i.cells.length)return e;const l=Rs(e,e=>{const t=e.rows.map((e,t)=>{if(t!==r)return e;const n=e.cells.filter((e,t)=>t!==a);return{...e,cells:n}});return{...e,rows:t}});if(l===e)return e;const s=i.cells[Math.min(a,i.cells.length-2)],c=s?s.blocks.flatMap(Po)[0]??null:null;return c?{...l,selection:oe(Z(c,0))}:l}var sc={activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""};function cc(e){const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=i(function(e,t){const n=Fe(e.document)[fo(e)];return n?"header"===t?n.header??[]:"footer"===t?n.footer??[]:n.blocks:[]}(e,n.zone),n.tablePath),a=r?.[r.length-1]?.table;if(!a)return null;const l=ln(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:l?.visualColumnIndex??o.cellIndex}}function dc(e){if("number"==typeof e&&Number.isFinite(e))return{value:String(e),unit:"points"};if("string"==typeof e){const t=e.trim();if(t.endsWith("%"))return{value:t.slice(0,-1),unit:"percent"};const n=t.match(/^([0-9.]+)(pt)?$/i);if(n?.[1])return{value:n[1],unit:"points"}}return{value:"",unit:"points"}}function uc(e){return!!e&&"none"!==e.type&&e.width>0}function pc(e,t="table"){const n=dc(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=dc(o?.style?.height),i=dc(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=dc(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(uc)[0],u=function(e){const t=e.style?.floating;return t&&0!==Object.keys(t).length?Object.entries(t).map(([e,t])=>`${e}=${t}`).join(", "):""}(e.table);return{...sc,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:dc(e.table.style?.indentLeft).value,tableWrapping:u?"around":"none",floatingSummary:u,floatingHorizontalAnchor:e.table.style?.floating?.horizontalAnchor??"margin",floatingVerticalAnchor:e.table.style?.floating?.verticalAnchor??"text",floatingX:null!=e.table.style?.floating?.x?String(e.table.style.floating.x):"0",floatingY:null!=e.table.style?.floating?.y?String(e.table.style.floating.y):"0",floatingXAlign:e.table.style?.floating?.xAlign??"",floatingYAlign:e.table.style?.floating?.yAlign??"",floatingDistanceTop:String(e.table.style?.floating?.distanceTop??0),floatingDistanceRight:String(e.table.style?.floating?.distanceRight??0),floatingDistanceBottom:String(e.table.style?.floating?.distanceBottom??0),floatingDistanceLeft:String(e.table.style?.floating?.distanceLeft??0),floatingOverlap:e.table.style?.tblOverlap??"overlap",rowHeight:a.value,rowHeightRule:o?.style?.heightRule??"",repeatHeader:Boolean(o?.isHeader),allowBreakAcrossPages:!0!==o?.style?.cantSplit,hiddenRow:!0===o?.style?.hidden,columnWidth:s.value,cellWidth:i.value,cellVerticalAlign:c.verticalAlign??"",cellTextDirection:c.textDirection??"",cellNoWrap:!0===c.noWrap,cellFitText:!0===c.fitText,cellHideMark:!0===c.hideMark,marginTop:null!=c.paddingTop?String(c.paddingTop):"",marginRight:null!=c.paddingRight?String(c.paddingRight):"",marginBottom:null!=c.paddingBottom?String(c.paddingBottom):"",marginLeft:null!=c.paddingLeft?String(c.paddingLeft):"",borderStyle:d?.type??"none",borderWidth:d?String(d.width):"",borderColor:d?.color??"",borderTop:uc(c.borderTop),borderRight:uc(c.borderRight),borderBottom:uc(c.borderBottom),borderLeft:uc(c.borderLeft),borderStart:uc(c.borderStart),borderEnd:uc(c.borderEnd),borderTopLeftToBottomRight:uc(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:uc(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function gc(e,t,n){return Fs(e,t,n)}function fc(e){return Boolean(cc(e))}function mc(e,t="table"){const n=cc(e);return n?pc(n,t):null}function hc(e){const t=()=>fc(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=mc(e.state(),t);n&&(e.setContextMenu({isOpen:!1,x:0,y:0}),e.setTablePropertiesDialog({isOpen:!0,initial:n}))},applyTablePropertiesDialogValues:n=>{e.isReadOnly()||t()&&(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>function(e,t){const n=cc(e);if(!n)return e;let o=e;return o=Es(o,n.tableId,"width",t.tableWidth),o=Es(o,n.tableId,"align",t.tableAlign),o=Es(o,n.tableId,"indentLeft",t.tableIndentLeft),o=Es(o,n.tableId,"floating",t.tableFloating),o=Es(o,n.tableId,"tblOverlap",t.tableOverlap),o=Es(o,n.tableId,"altTitle",t.altTitle),o=Es(o,n.tableId,"altDescription",t.altDescription),o=Ns(o,t.repeatHeader),o=Ls(o,"height",t.rowHeight),o=Ls(o,"heightRule",t.rowHeightRule),o=Ls(o,"cantSplit",t.cantSplit),o=Ls(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Hs(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=gc(o,"width",t.cellWidth),o=gc(o,"verticalAlign",t.cellVerticalAlign),o=gc(o,"textDirection",t.cellTextDirection),o=gc(o,"noWrap",t.cellNoWrap),o=gc(o,"fitText",t.cellFitText),o=gc(o,"hideMark",t.cellHideMark),o=gc(o,"paddingTop",t.margins.top),o=gc(o,"paddingRight",t.margins.right),o=gc(o,"paddingBottom",t.margins.bottom),o=gc(o,"paddingLeft",t.margins.left),o=gc(o,"borderTop",t.borders.top),o=gc(o,"borderRight",t.borders.right),o=gc(o,"borderBottom",t.borders.bottom),o=gc(o,"borderLeft",t.borders.left),o=gc(o,"borderStart",t.borders.start),o=gc(o,"borderEnd",t.borders.end),o=gc(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=gc(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=gc(o,"shading",t.shading),o}(e,n),{mergeKey:sl}),e.focusInput())}}}function bc(e){return function(e){const t=e.t,n=e.clipboardActions??li({...e,onIssue:t=>e.logger.warn("contextMenu:clipboard:not-completed",{issue:t})}),o=n.copy,r=n.cut,a=()=>n.paste("rich"),i=()=>{const n=!zr(e.state().selection),i=e.isReadOnly(),l=[{id:"cut",label:t("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!n,testId:"editor-context-menu-cut",onSelect:()=>{r()}},{id:"copy",label:t("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!n,testId:"editor-context-menu-copy",onSelect:()=>{o()}},{id:"paste",label:t("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{a()}},{id:"sep1",type:"separator"},{id:"link",label:t("contextmenu.link"),icon:"link",disabled:i||!n,testId:"editor-context-menu-link",onSelect:e.promptForLink},{id:"font",label:t("contextmenu.font"),icon:"type",disabled:i||!n,testId:"editor-context-menu-font",onSelect:e.openFontDialog},{id:"paragraph",label:t("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:e.openParagraphDialog}],s=e.table;return s?.isInsideTable()&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:t("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},l=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},s=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:i,closeContextMenu:s,handleEditorContextMenu:l,programmaticCopy:o,programmaticCut:r,programmaticPaste:a}}(e)}function yc(e){const{state:t,tableOps:n,applyTableContextCommand:o}=e;return{isInsideTable:e.isInsideTable,canMerge:()=>n.canMergeSelectedTable(t()),canSplit:()=>n.canSplitSelectedTable(t()),canEditColumn:()=>n.canEditSelectedTableColumn(t()),canEditRow:()=>n.canEditSelectedTableRow(t()),openProperties:()=>e.openTablePropertiesDialog("table"),openBordersAndShading:()=>e.openTablePropertiesDialog("cell"),merge:()=>o(e=>n.mergeSelectedTable(e),fl),split:()=>o(e=>n.splitSelectedTable(e),ml),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),hl),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),hl),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),bl),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),yl),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),yl),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),vl)}}function vc(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=zi({state:e.state,toolbarStyleState:e.toolbarStyleState}),r=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:xn(t.fontSize),color:t.color??"",colorMode:t.color?"custom":"automatic",highlight:t.highlight??"",shading:t.textShading??"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underlineStyle?t.underlineStyle:null,underlineColor:t.underlineColor??"",strike:Boolean(t.strike),doubleStrike:Boolean(t.doubleStrike),superscript:Boolean(t.superscript),subscript:Boolean(t.subscript),smallCaps:Boolean(t.smallCaps),allCaps:Boolean(t.allCaps),hidden:Boolean(t.hidden),characterScale:t.characterScale??"",characterSpacing:t.characterSpacing??"",baselineShift:t.baselineShift??"",kerningThreshold:t.kerningThreshold??"",ligatures:t.ligatures??"",numberSpacing:t.numberSpacing??"",numberForm:t.numberForm??"",stylisticSet:t.stylisticSet??"",contextualAlternates:Boolean(t.contextualAlternates)})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(t,n)=>{e.isReadOnly()||(zr(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=_a(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=_a(o,"fontSize",kr(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=_a(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=_a(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=_a(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=Ka(o,"bold")),t.italic!==Boolean(n.italic)&&(o=Ka(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=_a(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=_a(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=Ka(o,"underline")),t.strike!==Boolean(n.strike)&&(o=Ka(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=Ka(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=Ka(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=Ka(o,"subscript")),t.superscript&&t.subscript&&(o=Ka(o,"subscript")),t.strike&&t.doubleStrike&&(o=Ka(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=Ka(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=Ka(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=Ka(o,"hidden"));const l=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(l??null)&&(o=_a(o,"characterScale",t.characterScale));const s=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(s??null)&&(o=_a(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=_a(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=_a(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=_a(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=_a(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=_a(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=_a(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=Ka(o,"contextualAlternates")),o},{mergeKey:dl})),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,selection:e.selection,isReadOnly:e.isReadOnly,loadLocalFontFamilyOptions:o,setFontDialog:e.setFontDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),a=r.openFontDialog,i=function(e){return{openParagraphDialog:()=>{var t;e.setParagraphDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{align:t.align??"",indentLeft:t.indentLeft??"",indentRight:t.indentRight??"",indentFirstLine:t.indentFirstLine??"",indentHanging:t.indentHanging??"",mirrorIndents:t.mirrorIndents??!1,spacingBefore:t.spacingBefore??"",spacingAfter:t.spacingAfter??"",lineHeight:t.lineHeight??"",lineRule:t.lineRule??"",contextualSpacing:t.contextualSpacing??!1,outlineLevel:t.outlineLevel??"",shading:t.shading??"",borderStyle:t.borderStyle??"",borderWidth:t.borderWidth??"",borderColor:t.borderColor??"",borderSideTop:t.borderSideTop??!1,borderSideRight:t.borderSideRight??!1,borderSideBottom:t.borderSideBottom??!1,borderSideLeft:t.borderSideLeft??!1,pageBreakBefore:t.pageBreakBefore??!1,keepWithNext:t.keepWithNext??!1,keepLinesTogether:t.keepLinesTogether??!1,widowControl:t.widowControl??!0,tabs:t.tabs??[]})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(t,n)=>{if(e.isReadOnly())return;e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e=>{if(""===e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null};e.applyTransactionalState(e=>{let r=e;t.align!==(n.align||null)&&(r=Ve(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=Ve(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=Ve(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=Ve(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=Ve(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=Ve(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=Ve(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=Ve(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=Ve(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=Ve(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=Ve(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=Ve(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=Ve(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=Ve(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=Ve(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=Ve(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=Ve(r,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=Ve(r,"tabs",t.tabs.length>0?t.tabs:null));const l="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,s={borderTop:n.borderSideTop?l:null,borderRight:n.borderSideRight?l:null,borderBottom:n.borderSideBottom?l:null,borderLeft:n.borderSideLeft?l:null},c={borderTop:t.borders.top,borderRight:t.borders.right,borderBottom:t.borders.bottom,borderLeft:t.borders.left};for(const t of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(c[t])!==JSON.stringify(s[t])&&(r=Ve(r,t,c[t]));return r},{mergeKey:cl}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=z(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:ds(r.paragraphStyle??{},t)}}}}}),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,isReadOnly:e.isReadOnly,setParagraphDialog:e.setParagraphDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),l=i.openParagraphDialog,s=hc({state:e.state,isReadOnly:e.isReadOnly,setTablePropertiesDialog:e.setTablePropertiesDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),c=s.openTablePropertiesDialog,d=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},u=bc({clipboardActions:e.clipboardActions,state:e.state,isReadOnly:e.isReadOnly,t:e.t,logger:e.logger,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.applyTableAwareParagraphEdit,focusInput:e.focusInput,promptForLink:e.promptForLink,openFontDialog:a,openParagraphDialog:l,table:yc({state:e.state,tableOps:e.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function xc(e){const t=vr(()=>{const t=e.targetPos(),n=e.surfaceRef;if(!n)return null;const o=e.snapshotProvider.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});let r=0,a=0,i=28;if(o){const n=Kr(e.state).find(e=>e.id===t.paragraphId),r=n?Bt(n,t):0,a=mo(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=mn(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const l=e.caretViewport?.()??null;if(l)return r=l.left,a=l.top,i=Math.max(12,Math.min(36,l.height)),{viewportLeft:r,viewportTop:a,height:i};const s=e.pointerPos?.()??null;return s?(r=s.x,a=s.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return X(Ft,{get when(){return t()},children:e=>X(H,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var wc=/*#__PURE__*/f("<div class=oasis-editor-table-resize-guide>"),Sc=/*#__PURE__*/f("<div class=oasis-editor-table-resize-outline>"),Cc=/*#__PURE__*/f("<img class=oasis-editor-image-ghost>"),Ic=/*#__PURE__*/f("<div class=oasis-editor-table-ghost>");function Tc(e){return[X(Ft,{get when(){return e.tableResize.resizing()},children:e=>{return t=wc(),fe(n=>{var o=!("column"!==e().type),r=!("row"!==e().type),a={..."column"===e().type?{left:`${e().currentPos}px`,top:`${e().guideBounds.top}px`,width:"0px",height:`${e().guideBounds.height}px`}:{left:`${e().guideBounds.left}px`,top:`${e().currentPos}px`,width:`${e().guideBounds.width}px`,height:"0px"}};return o!==n.e&&t.classList.toggle("oasis-editor-table-resize-guide-column",n.e=o),r!==n.t&&t.classList.toggle("oasis-editor-table-resize-guide-row",n.t=r),n.a=Sa(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),X(Ft,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Sc(),fe(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&Re(t,"left",n.e=o),r!==n.t&&Re(t,"top",n.t=r),a!==n.a&&Re(t,"width",n.a=a),i!==n.o&&Re(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),X(Ft,{get when(){return et(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=Cc(),fe(o=>{var r=t().src,a=`${t().width}px`,i=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",s=e.imageOps.mousePos().y-t().offsetY+"px";return r!==o.e&&le(n,"src",o.e=r),a!==o.t&&Re(n,"width",o.t=a),i!==o.a&&Re(n,"height",o.a=i),l!==o.o&&Re(n,"left",o.o=l),s!==o.i&&Re(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),X(Ft,{get when(){return et(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=Ic(),fe(o=>{var r=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",l=e.tableDrag.mousePos().y-t().offsetY+"px";return r!==o.e&&Re(n,"width",o.e=r),a!==o.t&&Re(n,"height",o.t=a),i!==o.a&&Re(n,"left",o.a=i),l!==o.o&&Re(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),X(Ft,{get when(){return et(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),X(Ft,{get when(){return et(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),X(Ft,{get when(){return et(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t,get pointerPos(){return e.textDrag.pointerPos},get caretViewport(){return e.textDrag.caretViewport}})})]}function kc(e){return[X(Qe,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),X(Qe,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Pc(e){const t=R(),[n,o]=an(e.initialValue);let r;we(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return X(xt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return X(kc,{get onCancel(){return e.onClose},onConfirm:a,get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return e.confirmLabel},get cancelTestId(){return e.testIds?.cancel},get confirmTestId(){return e.testIds?.confirm}})},get children(){return X(po,{ref(e){"function"==typeof r?r(e):r=e},get label(){return e.label},get value(){return n()},onChange:o,onKeyDown:e=>"Enter"===e.key&&a(),get placeholder(){return e.placeholder},get"data-testid"(){return e.testIds?.input}})}})}function Rc(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.link.title")},get label(){return t("dialog.link.label")},get placeholder(){return t("dialog.link.placeholder")},get initialValue(){return e.initialHref},get confirmLabel(){return t("generic.apply")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm},testIds:{input:"editor-link-dialog-input",cancel:"editor-link-dialog-cancel",confirm:"editor-link-dialog-apply"}})}function Bc(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageAlt.title")},get label(){return t("dialog.imageAlt.label")},get placeholder(){return t("dialog.imageAlt.placeholder")},get initialValue(){return e.initialAlt},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}function Ac(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageCaption.title")},get label(){return t("dialog.imageCaption.label")},get placeholder(){return t("dialog.imageCaption.placeholder")},get initialValue(){return e.initialCaption},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}var Mc=/*#__PURE__*/f("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Fc=/*#__PURE__*/f("<div class=oasis-editor-comment-composer>");function Oc(e){const t=R(),[n,o]=an(""),[r,a]=an("");let i;const l=e.composer.draft,s=()=>("edit"===l()?.mode||n().trim().length>0)&&r().trim().length>0,c=()=>{s()&&e.composer.submit(n(),r())};return we(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),X(xt,{get isOpen(){return null!==l()},get title(){return t("edit"===l()?.mode?"toolbar.editComment":"reply"===l()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[X(Qe,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",get disabled(){return!s()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var s=Fc();return We(s,X(Ft,{get when(){return"reply"===l()?.mode},get children(){var e=Mc();return We(e,X(ia,{as:"strong",get children(){return[et(()=>t("comment.replyTo"))," ",et(()=>l()?.parentAuthor)]}}),null),We(e,X(ia,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),We(s,X(po,{get label(){return t("comment.author")},get value(){return n()},onChange:o,maxLength:150,required:!0,get disabled(){return"edit"===l()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),We(s,X(vo,{ref(e){"function"==typeof i?i(e):i=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return r()},onChange:a,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),c())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),s}})}var Dc=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],Ec=[33,50,66,75,90,100,105,110,115,120,150,200];function Lc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Nc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function $c(e){return null==e||""===e?"":String(e)}function zc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Hc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function Wc(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Uc(e){switch(e){case"none":return"none";case"standard":return"common-ligatures";case"contextual":return"contextual";case"historical":return"historical-ligatures";case"standardContextual":return"common-ligatures contextual";default:return}}function jc(e,t){const n=[];return"proportional"===e&&n.push("proportional-nums"),"tabular"===e&&n.push("tabular-nums"),"lining"===t&&n.push("lining-nums"),"oldStyle"===t&&n.push("oldstyle-nums"),n.join(" ")||void 0}function Vc(e,t){const n=[],o=Wc(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Kc(e){return{familyFilter:"",fontFamily:e.fontFamily??"",fontSize:e.fontSize??"",colorMode:e.colorMode,color:e.color||"#111827",highlight:e.highlight||"",shading:e.shading||"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underline?e.underlineStyle??"single":"none",underlineColor:e.underlineColor||"#111827",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden)}}function _c(e){return{characterScale:$c(e.characterScale),spacingMode:zc(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Hc(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:$c(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:$c(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function Xc(e){const t=R(),[n,o]=an("font"),[r,a]=an(Kc(e.initial)),[i,l]=an(_c(e.initial));we(()=>{e.isOpen&&(o("font"),a(Kc(e.initial)),l(_c(e.initial)))});const s=vr(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=vr(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=vr(()=>{const t=new Set(Dc);for(const o of e.sizeOptions)t.add(o);const n=Number(r().fontSize);return Number.isFinite(n)&&n>0&&t.add(n),Array.from(t).sort((e,t)=>e-t)}),u=vr(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=vr(()=>{const e=i();return e.characterScale.trim()&&null===Lc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Nc(e.spacingAmount)||"normal"!==e.positionMode&&null===Nc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Nc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===Wc(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=vr(()=>function(e,t){const n=Number(e.fontSize),o=Lc(t.characterScale)??100,r="normal"===t.spacingMode?null:Nc(t.spacingAmount),a="normal"===t.positionMode?null:Nc(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,l=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,s=[];return e.underline&&"none"!==e.underlineStyle&&s.push("underline"),e.strike&&s.push("line-through"),e.doubleStrike&&s.push("line-through"),{"font-family":e.fontFamily||"inherit","font-size":Number.isFinite(n)&&n>0?`${n}pt`:void 0,"font-weight":e.bold?700:400,"font-style":e.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":l??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":Uc(t.ligatures),"font-variant-numeric":jc(t.numberSpacing,t.numberForm),"font-feature-settings":Vc(t.stylisticSet,t.contextualAlternates)}}(r(),i()));return{activeTab:n,setActiveTab:e=>o(e),fontTabValues:r,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{l(n=>({...n,[e]:t}))},selectedFontStyle:s,visibleFamilyOptions:c,effectiveSizeOptions:d,customSizeError:u,advancedValidationError:p,previewStyle:g,applyFontStylePreset:e=>{a(t=>({...t,bold:"bold"===e||"boldItalic"===e,italic:"italic"===e||"boldItalic"===e}))},handleApply:()=>{if(p())return;const t=function(e,t){const n=Number(e.fontSize),o=Number.isFinite(n)&&n>0,r="none"===e.underlineStyle?null:e.underlineStyle,a=null!==r,i=t.characterScale.trim()?Lc(t.characterScale):null,l="normal"===t.spacingMode?null:Nc(t.spacingAmount),s="normal"===t.positionMode?null:Nc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Nc(t.kerningThreshold):null,d=Wc(t.stylisticSet);return{fontFamily:e.fontFamily.trim()?e.fontFamily.trim():null,fontSize:o?n:null,colorMode:e.colorMode,color:"automatic"===e.colorMode?null:e.color||null,highlight:e.highlight||null,shading:e.shading||null,bold:e.bold,italic:e.italic,underline:a,underlineStyle:r,underlineColor:a&&e.underlineColor||null,strike:e.strike,doubleStrike:e.doubleStrike,superscript:e.superscript,subscript:e.subscript,smallCaps:e.smallCaps,allCaps:e.allCaps,hidden:e.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===t.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===t.positionMode?-s:s,kerningThreshold:c,ligatures:t.ligatures||null,numberSpacing:t.numberSpacing||null,numberForm:t.numberForm||null,stylisticSet:d,contextualAlternates:t.contextualAlternates}}(r(),i());e.onApply(t,e.initial),e.onClose()}}}var Gc=/*#__PURE__*/f("<div>");function qc(e){const t=R();return n=Gc(),We(n,()=>t("dialog.font.previewText")),fe(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&Ao(n,t.e=o),r!==t.t&&le(n,"data-testid",t.t=r),t.a=Sa(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Yc=/*#__PURE__*/f('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Zc(e){const t=R(),{ctrl:n}=e;return o=Yc(),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:12,get children(){return X(po,{get label(){return t("dialog.font.familyFilter")},get value(){return n.fontTabValues().familyFilter},onChange:e=>n.updateFontTab("familyFilter",e),"data-testid":"editor-font-dialog-family-filter"})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.family")},get value(){return n.fontTabValues().fontFamily},onChange:e=>n.updateFontTab("fontFamily",e),"data-testid":"editor-font-dialog-family",get options(){return[{value:"",label:"—"},...n.visibleFamilyOptions().map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.size")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-size",get options(){return[{value:"",label:"—"},...n.effectiveSizeOptions().map(e=>({value:String(e),label:String(e)}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return[X(po,{get label(){return t("dialog.font.customSize")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-custom-size"}),X(On,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.styleList")},get value(){return n.selectedFontStyle()},onChange:e=>n.applyFontStylePreset(e),"data-testid":"editor-font-dialog-style-list",get options(){return[{value:"regular",label:t("dialog.font.styleRegular")},{value:"italic",label:t("dialog.font.styleItalic")},{value:"bold",label:t("dialog.font.styleBold")},{value:"boldItalic",label:t("dialog.font.styleBoldItalic")}]}})}})]}}),null),We(o,X(Yr,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().colorMode},onChange:e=>n.updateFontTab("colorMode",e),"data-testid":"editor-font-dialog-color-mode",get options(){return[{value:"automatic",label:t("toolbar.colorAutomatic")},{value:"custom",label:t("dialog.font.customColor")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(Go,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().color},get disabled(){return"automatic"===n.fontTabValues().colorMode},onChange:e=>n.setFontTabValues(t=>({...t,color:e,colorMode:"custom"})),"data-testid":"editor-font-dialog-color"})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Go,{get label(){return t("dialog.font.highlight")},get value(){return n.fontTabValues().highlight||"#fef08a"},onChange:e=>n.updateFontTab("highlight",e),"data-testid":"editor-font-dialog-highlight"})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Go,{get label(){return t("dialog.font.shading")},get value(){return n.fontTabValues().shading||"#fef3c7"},onChange:e=>n.updateFontTab("shading",e),"data-testid":"editor-font-dialog-shading"})}})]}}),null),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.underlineStyle")},get value(){return n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineStyle:e,underline:"none"!==e})),"data-testid":"editor-font-dialog-underline-style",get options(){return[{value:"none",label:t("toolbar.underlineRemove")},...ot.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(Go,{get label(){return t("dialog.font.underlineColor")},get value(){return n.fontTabValues().underlineColor||"#111827"},get disabled(){return"none"===n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineColor:e,underline:"none"!==t.underlineStyle})),"data-testid":"editor-font-dialog-underline-color"})}})]}}),null),We(o,X(vn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return X(ee,{get each(){return[{testId:"editor-font-dialog-bold",label:t("dialog.font.bold"),labelStyle:{"font-weight":700},checked:()=>n.fontTabValues().bold,onChange:e=>n.updateFontTab("bold",e)},{testId:"editor-font-dialog-italic",label:t("dialog.font.italic"),labelStyle:{"font-style":"italic"},checked:()=>n.fontTabValues().italic,onChange:e=>n.updateFontTab("italic",e)},{testId:"editor-font-dialog-underline",label:t("dialog.font.underline"),labelStyle:{"text-decoration":"underline"},checked:()=>n.fontTabValues().underline,onChange:e=>n.setFontTabValues(t=>({...t,underline:e,underlineStyle:e?"none"===t.underlineStyle?"single":t.underlineStyle:"none"}))},{testId:"editor-font-dialog-strike",label:t("dialog.font.strike"),labelStyle:{"text-decoration":"line-through"},checked:()=>n.fontTabValues().strike,onChange:e=>n.setFontTabValues(t=>({...t,strike:e,doubleStrike:!e&&t.doubleStrike}))},{testId:"editor-font-dialog-double-strike",label:t("dialog.font.doubleStrike"),checked:()=>n.fontTabValues().doubleStrike,onChange:e=>n.setFontTabValues(t=>({...t,doubleStrike:e,strike:!e&&t.strike}))},{testId:"editor-font-dialog-superscript",label:t("toolbar.superscript"),checked:()=>n.fontTabValues().superscript,onChange:e=>n.setFontTabValues(t=>({...t,superscript:e,subscript:!e&&t.subscript}))},{testId:"editor-font-dialog-subscript",label:t("toolbar.subscript"),checked:()=>n.fontTabValues().subscript,onChange:e=>n.setFontTabValues(t=>({...t,subscript:e,superscript:!e&&t.superscript}))},{testId:"editor-font-dialog-small-caps",label:t("dialog.font.smallCaps"),checked:()=>n.fontTabValues().smallCaps,onChange:e=>n.updateFontTab("smallCaps",e)},{testId:"editor-font-dialog-all-caps",label:t("dialog.font.allCaps"),checked:()=>n.fontTabValues().allCaps,onChange:e=>n.updateFontTab("allCaps",e)},{testId:"editor-font-dialog-hidden",label:t("dialog.font.hidden"),checked:()=>n.fontTabValues().hidden,onChange:e=>n.updateFontTab("hidden",e)}]},children:e=>X(Fr,{get label(){return e.label},get labelStyle(){return e.labelStyle},get checked(){return e.checked()},get onChange(){return e.onChange},get"data-testid"(){return e.testId}})})}})}}),null),We(o,X(vn,{get label(){return t("dialog.font.preview")},get children(){return X(qc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var Jc=/*#__PURE__*/f("<div class=oasis-editor-font-dialog-kerning-line>"),Qc=/*#__PURE__*/f('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function ed(e){const t=R(),{ctrl:n}=e;return o=Qc(),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.advancedScale")},get value(){return n.advancedTabValues().characterScale||"100"},onChange:e=>n.updateAdvancedTab("characterScale",e),"data-testid":"editor-font-dialog-advanced-scale",get options(){return Ec.map(e=>({value:String(e),label:`${e}%`}))}})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.advancedSpacing")},get value(){return n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingMode",e),"data-testid":"editor-font-dialog-advanced-spacing-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"expanded",label:t("dialog.font.advancedExpanded")},{value:"condensed",label:t("dialog.font.advancedCondensed")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(po,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().spacingAmount},get disabled(){return"normal"===n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingAmount",e),"data-testid":"editor-font-dialog-advanced-spacing-amount"})}})]}})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.advancedPosition")},get value(){return n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionMode",e),"data-testid":"editor-font-dialog-advanced-position-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"raised",label:t("dialog.font.advancedRaised")},{value:"lowered",label:t("dialog.font.advancedLowered")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(po,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().positionAmount},get disabled(){return"normal"===n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionAmount",e),"data-testid":"editor-font-dialog-advanced-position-amount"})}}),X(Yr,{size:12,get children(){var e=Jc();return We(e,X(fr,{class:"oasis-editor-font-dialog-kerning-toggle",get label(){return t("dialog.font.advancedKerning")},get checked(){return n.advancedTabValues().kerningEnabled},onChange:e=>n.setAdvancedTabValues(t=>({...t,kerningEnabled:e,kerningThreshold:e?t.kerningThreshold||"1":t.kerningThreshold})),"data-testid":"editor-font-dialog-advanced-kerning-enabled"}),null),We(e,X(po,{class:"oasis-editor-font-dialog-kerning-input",get value(){return n.advancedTabValues().kerningThreshold},get disabled(){return!n.advancedTabValues().kerningEnabled},onChange:e=>n.updateAdvancedTab("kerningThreshold",e),"data-testid":"editor-font-dialog-advanced-kerning"}),null),We(e,X(On,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedLigatures")},get value(){return n.advancedTabValues().ligatures},onChange:e=>n.updateAdvancedTab("ligatures",e),"data-testid":"editor-font-dialog-advanced-ligatures",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"none",label:t("dialog.font.advancedLigaturesNone")},{value:"standard",label:t("dialog.font.advancedLigaturesStandard")},{value:"contextual",label:t("dialog.font.advancedLigaturesContextual")},{value:"historical",label:t("dialog.font.advancedLigaturesHistorical")},{value:"standardContextual",label:t("dialog.font.advancedLigaturesStandardContextual")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedNumberSpacing")},get value(){return n.advancedTabValues().numberSpacing},onChange:e=>n.updateAdvancedTab("numberSpacing",e),"data-testid":"editor-font-dialog-advanced-number-spacing",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"proportional",label:t("dialog.font.advancedNumberSpacingProportional")},{value:"tabular",label:t("dialog.font.advancedNumberSpacingTabular")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedNumberForm")},get value(){return n.advancedTabValues().numberForm},onChange:e=>n.updateAdvancedTab("numberForm",e),"data-testid":"editor-font-dialog-advanced-number-form",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"lining",label:t("dialog.font.advancedNumberFormLining")},{value:"oldStyle",label:t("dialog.font.advancedNumberFormOldStyle")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedStylisticSet")},get value(){return n.advancedTabValues().stylisticSet},onChange:e=>n.updateAdvancedTab("stylisticSet",e),"data-testid":"editor-font-dialog-advanced-stylistic-set",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},...Array.from({length:20},(e,t)=>t+1).map(e=>({value:String(e),label:String(e)}))]}})}})]}}),X(fr,{class:"oasis-editor-font-dialog-contextual-toggle",get label(){return t("dialog.font.advancedContextualAlternates")},get checked(){return n.advancedTabValues().contextualAlternates},onChange:e=>n.updateAdvancedTab("contextualAlternates",e),"data-testid":"editor-font-dialog-advanced-contextual-alternates"})]}}),null),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return X(qc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),We(o,X(On,{as:"p",class:"oasis-editor-dialog-help-text","data-testid":"editor-font-dialog-advanced-placeholder",get children(){return n.advancedValidationError()||t("dialog.font.advancedPlaceholder")}}),null),o;var o}function td(e){const t=R(),n=Xc(e);return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.font.title")},get onClose(){return e.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-font-dialog-cancel",confirmTestId:"editor-font-dialog-apply"})},get children(){return X(da,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return t("dialog.font.title")},get value(){return n.activeTab()},onChange:e=>n.setActiveTab(e),get items(){return[{id:"font",label:t("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:X(Zc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:X(ed,{ctrl:n})}]}})}})}var nd=/*#__PURE__*/f("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),od=/*#__PURE__*/f("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function rd(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function ad(e){const t=R(),[n,o]=an([]);we(()=>{e.isOpen&&o(e.initial.map(rd))});const r=(e,t)=>{o(n=>n.map((n,o)=>o===e?{...n,...t}:n))},a=()=>{o(e=>[...e,{position:null,type:"left",leader:"none"}])},i=()=>{const t=n().filter(e=>null!==e.position).map(e=>({position:e.position,type:e.type,..."none"!==e.leader?{leader:e.leader}:{}})).sort((e,t)=>e.position-t.position);e.onApply(t),e.onClose()};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=od(),r=n.firstChild,a=r.nextSibling,We(r,X(Qe,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),We(a,X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),We(a,X(Qe,{variant:"primary",onClick:i,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){var e=nd(),i=e.firstChild;return We(e,X(ee,{get each(){return n()},get fallback(){return X(On,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>X(Yr,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),X(Yr,{size:{xs:6,md:3},get children(){return X(ro,{get label(){return t("paragraph.tabsAlignment")},get value(){return e.type},onChange:e=>r(n(),{type:e}),get options(){return[{value:"left",label:t("paragraph.tabAlignLeft")},{value:"center",label:t("paragraph.tabAlignCenter")},{value:"right",label:t("paragraph.tabAlignRight")},{value:"decimal",label:t("paragraph.tabAlignDecimal")},{value:"bar",label:t("paragraph.tabAlignBar")}]}})}}),X(Yr,{size:{xs:6,md:3},get children(){return X(ro,{get label(){return t("paragraph.tabsLeader")},get value(){return e.leader},onChange:e=>r(n(),{leader:e}),get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:t("paragraph.tabLeaderDot")},{value:"hyphen",label:t("paragraph.tabLeaderHyphen")},{value:"underscore",label:t("paragraph.tabLeaderUnderscore")}]}})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Qe,{variant:"ghost",onClick:()=>(e=>{o(t=>t.filter((t,n)=>n!==e))})(n()),"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsRemove")}})}})]}})}),i),We(i,X(Qe,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var id=96/72;function ld(e){const[t,n]=an(""),[o,r]=an(""),[a,i]=an(null),[l,s]=an(null),[c,d]=an("none"),[u,p]=an(null),[g,f]=an(!1),[m,h]=an(null),[b,y]=an(null),[v,x]=an("multiple"),[w,S]=an(null),[C,I]=an(!1),[T,k]=an(""),[P,R]=an("none"),[B,A]=an(null),[M,F]=an(""),[O,D]=an(!1),[E,L]=an(!1),[N,$]=an(!1),[z,H]=an(!1),[W,U]=an(!1),[j,V]=an(!1),[K,_]=an(!1),[X,G]=an(!0),[q,Y]=an([]);we(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(cn(e.initial.indentLeft??"")),s(cn(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(cn(e.initial.spacingBefore??"")),y(cn(e.initial.spacingAfter??"")),I(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=cn(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/id):null}:null===o?{mode:"multiple",at:null}:1===o?{mode:"single",at:null}:1.5===o?{mode:"onePointFive",at:null}:2===o?{mode:"double",at:null}:{mode:"multiple",at:o});x(a),S(l);const c=e.initial.borderStyle;R("solid"===c||"dashed"===c||"dotted"===c?c:"none"),A(cn(e.initial.borderWidth??"")),F(e.initial.borderColor??""),D(e.initial.borderSideTop??!1),L(e.initial.borderSideRight??!1),$(e.initial.borderSideBottom??!1),H(e.initial.borderSideLeft??!1),U(e.initial.pageBreakBefore??!1),V(e.initial.keepWithNext??!1),_(e.initial.keepLinesTogether??!1),G(e.initial.widowControl??!0),Y(e.initial.tabs??[]);const u=cn(e.initial.indentFirstLine??""),g=cn(e.initial.indentHanging??"");null!==g&&g>0?(d("hanging"),p(g)):null!==u&&u>0?(d("firstLine"),p(u)):(d("none"),p(null))}var t,o});const Z=()=>{switch(v()){case"single":return{lineHeight:1,lineRule:null};case"onePointFive":return{lineHeight:1.5,lineRule:null};case"double":return{lineHeight:2,lineRule:null};case"multiple":return{lineHeight:w(),lineRule:null};case"atLeast":return{lineHeight:null!==w()?w()*id:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*id:null,lineRule:"exact"}}},J=vr(()=>{const e=a(),n=l(),o="firstLine"===c()?u():null,r="hanging"===c()?u():null,i=null!==o?o:null!==r?-r:null,s="none"!==P()?`${B()??.5}pt ${P()} ${M().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=Z(),g=null===d?void 0:"exact"===p||"atLeast"===p?`${d}px`:String(d);return{"text-align":t()||void 0,"line-height":g,"padding-left":null!==e?`${e+(r??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==i?`${i}pt`:void 0,"background-color":T().trim()||void 0,"border-top":s&&O()?s:void 0,"border-right":s&&E()?s:void 0,"border-bottom":s&&N()?s:void 0,"border-left":s&&z()?s:void 0}}),Q=()=>{const e=P();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=B(),n={type:e,width:null!==t&&t>0?t:.5,color:M().trim()||"#000000"};return{top:O()?n:null,right:E()?n:null,bottom:N()?n:null,left:z()?n:null}},ee=()=>{const e=u(),{lineHeight:n,lineRule:r}=Z(),i=o();return{align:t()||null,indentLeft:a(),indentRight:l(),indentFirstLine:"firstLine"===c()?e:null,indentHanging:"hanging"===c()?e:null,mirrorIndents:g(),spacingBefore:m(),spacingAfter:b(),lineHeight:n,lineRule:r,contextualSpacing:C(),outlineLevel:""===i?null:Number(i),shading:T().trim()||null,borders:Q(),pageBreakBefore:W(),keepWithNext:j(),keepLinesTogether:K(),widowControl:X(),tabs:q()}};return{align:t,setAlign:n,outlineLevel:o,setOutlineLevel:r,indentLeft:a,setIndentLeft:i,indentRight:l,setIndentRight:s,special:c,setSpecial:d,specialBy:u,setSpecialBy:p,mirrorIndents:g,setMirrorIndents:f,spacingBefore:m,setSpacingBefore:h,spacingAfter:b,setSpacingAfter:y,lineMode:v,setLineMode:x,lineAt:w,setLineAt:S,contextualSpacing:C,setContextualSpacing:I,shading:T,setShading:k,borderStyle:P,setBorderStyle:R,borderWidth:B,setBorderWidth:A,borderColor:M,setBorderColor:F,sideTop:O,setSideTop:D,sideRight:E,setSideRight:L,sideBottom:N,setSideBottom:$,sideLeft:z,setSideLeft:H,pageBreakBefore:W,setPageBreakBefore:U,keepWithNext:j,setKeepWithNext:V,keepLinesTogether:K,setKeepLinesTogether:_,widowControl:X,setWidowControl:G,tabs:q,setTabs:Y,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:J,handleApply:()=>{e.onApply(ee(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(ee()),e.onClose()}}}var sd=/*#__PURE__*/f("<div class=oasis-editor-paragraph-dialog-panel>"),cd=/*#__PURE__*/f("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),dd=/*#__PURE__*/f("<div>"),ud=/*#__PURE__*/f("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function pd(e){const t=R(),[n,o]=an(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:l,indentLeft:s,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:g,specialBy:f,setSpecialBy:m,mirrorIndents:h,setMirrorIndents:b,spacingBefore:y,setSpacingBefore:v,spacingAfter:x,setSpacingAfter:w,lineMode:S,setLineMode:C,lineAt:I,setLineAt:T,contextualSpacing:k,setContextualSpacing:P,shading:B,setShading:A,borderStyle:M,setBorderStyle:F,borderWidth:O,setBorderWidth:D,borderColor:E,setBorderColor:L,sideTop:N,setSideTop:$,sideRight:z,setSideRight:H,sideBottom:W,setSideBottom:U,sideLeft:j,setSideLeft:V,pageBreakBefore:K,setPageBreakBefore:_,keepWithNext:G,setKeepWithNext:q,keepLinesTogether:Y,setKeepLinesTogether:Z,widowControl:J,setWidowControl:Q,tabs:ee,setTabs:te,atEnabled:ne,previewStyle:oe,handleApply:re,handleSetDefault:ae}=ld(e),ie=X(ro,{get label(){return t("paragraph.alignLabel")},get value(){return r()},onChange:a,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:t("paragraph.alignLeft")},{value:"center",label:t("paragraph.alignCenter")},{value:"right",label:t("paragraph.alignRight")},{value:"justify",label:t("paragraph.alignJustify")}]}}),le=X(ro,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:l,"data-testid":"editor-paragraph-dialog-outline-level",get options(){return[{value:"",label:t("paragraph.outlineBodyText")},...Array.from({length:9},(e,n)=>({value:String(n),label:t("paragraph.outlineLevelN",[n+1])}))]}}),se=(ce=sd(),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},children:ie}),X(Yr,{size:{xs:12,md:6},children:le})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("paragraph.specialLabel")},get value(){return p()},onChange:e=>{const t=e;g(t),"none"===t&&m(null)},"data-testid":"editor-paragraph-dialog-special",get options(){return[{value:"none",label:t("paragraph.specialNone")},{value:"firstLine",label:t("paragraph.specialFirstLine")},{value:"hanging",label:t("paragraph.specialHanging")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===p()},get value(){return f()??""},onChange:m,"data-testid":"editor-paragraph-dialog-special-by"})}}),X(Yr,{size:12,get children(){return X(fr,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:b,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return y()??""},onChange:v,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return x()??""},onChange:w,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),X(Yr,{size:{xs:12,md:4}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return S()},onChange:e=>{C(e)},"data-testid":"editor-paragraph-dialog-line-mode",get options(){return[{value:"single",label:t("paragraph.lineSpacingSingle")},{value:"onePointFive",label:t("paragraph.lineSpacingOnePointFive")},{value:"double",label:t("paragraph.lineSpacingDouble")},{value:"atLeast",label:t("paragraph.lineSpacingAtLeast")},{value:"exact",label:t("paragraph.lineSpacingExact")},{value:"multiple",label:t("paragraph.lineSpacingMultiple")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===S()?"0.05":"1"},get disabled(){return!ne()},get value(){return I()??""},onChange:T,"data-testid":"editor-paragraph-dialog-line-at"})}}),X(Yr,{size:12,get children(){return X(fr,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return k()},onChange:P,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("paragraph.borderStyleLabel")},get value(){return M()},onChange:e=>{const t=e;F(t),"none"===t?($(!1),H(!1),U(!1),V(!1)):N()||z()||W()||j()||($(!0),H(!0),U(!0),V(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(_n,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===M()},get value(){return O()??""},onChange:D,"data-testid":"editor-paragraph-dialog-border-width"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===M()},get value(){return E()||"#000000"},onChange:L,"data-testid":"editor-paragraph-dialog-border-color"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:A,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),X(vn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===M()},get checked(){return N()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),X(fr,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===M()},get checked(){return z()},onChange:H,"data-testid":"editor-paragraph-dialog-border-side-right"}),X(fr,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===M()},get checked(){return W()},onChange:U,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),X(fr,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===M()},get checked(){return j()},onChange:V,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),ce);var ce;const de=(ue=sd(),We(ue,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return X(ba,{direction:"column",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.widowControlLabel")},get checked(){return J()},onChange:Q,"data-testid":"editor-paragraph-dialog-widow-control"}),X(fr,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return G()},onChange:q,"data-testid":"editor-paragraph-dialog-keep-with-next"}),X(fr,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Y()},onChange:Z,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),X(fr,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return K()},onChange:_,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ue);var ue,pe;return pe=dd(),We(pe,X(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",testId:"editor-paragraph-dialog",get footer(){return n=ud(),r=n.firstChild,a=r.nextSibling,We(r,X(Qe,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),We(r,X(Qe,{variant:"secondary",onClick:ae,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),We(a,X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),We(a,X(Qe,{variant:"primary",onClick:re,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[X(da,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:se,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:de,testId:"editor-paragraph-dialog-tab-breaks"}]}}),X(vn,{get label(){return t("paragraph.preview")},get children(){var e=cd();return We(e,()=>t("paragraph.previewText")),fe(t=>Sa(e,oe(),t)),e}})]}}),null),We(pe,X(ad,{get isOpen(){return n()},get initial(){return ee()},onClose:()=>{o(!1)},onApply:te}),null),pe}function gd(e,t){const n=cn(e);return null===n?null:"percent"===t?`${n}%`:n}function fd(e,t,n){if("none"===e)return null;const o=cn(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function md(e){const[t,n]=Ro({activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"",floatingY:"",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"",floatingDistanceRight:"",floatingDistanceBottom:"",floatingDistanceLeft:"",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTlBr:!1,borderTrBl:!1,shading:"",altTitle:"",altDescription:""});we(()=>{var t;e.isOpen&&n(Oe({activeTab:(t=e.initial).activeTab??"table",tableWidth:t.tableWidth,tableWidthUnit:t.tableWidthUnit,tableAlign:t.tableAlign,tableIndentLeft:t.tableIndentLeft,tableWrapping:t.tableWrapping,floatingHorizontalAnchor:t.floatingHorizontalAnchor,floatingVerticalAnchor:t.floatingVerticalAnchor,floatingX:t.floatingX,floatingY:t.floatingY,floatingXAlign:t.floatingXAlign,floatingYAlign:t.floatingYAlign,floatingDistanceTop:t.floatingDistanceTop,floatingDistanceRight:t.floatingDistanceRight,floatingDistanceBottom:t.floatingDistanceBottom,floatingDistanceLeft:t.floatingDistanceLeft,floatingOverlap:t.floatingOverlap,rowHeight:t.rowHeight,rowHeightRule:t.rowHeightRule,repeatHeader:t.repeatHeader,allowBreakAcrossPages:t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:t.columnWidth,cellWidth:t.cellWidth,cellVerticalAlign:t.cellVerticalAlign,cellTextDirection:t.cellTextDirection,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,marginTop:t.marginTop,marginRight:t.marginRight,marginBottom:t.marginBottom,marginLeft:t.marginLeft,borderStyle:t.borderStyle,borderWidth:t.borderWidth,borderColor:t.borderColor,borderTop:t.borderTop,borderRight:t.borderRight,borderBottom:t.borderBottom,borderLeft:t.borderLeft,borderStart:t.borderStart,borderEnd:t.borderEnd,borderTlBr:t.borderTopLeftToBottomRight,borderTrBl:t.borderTopRightToBottomLeft,shading:t.shading,altTitle:t.altTitle,altDescription:t.altDescription}))});return{form:t,set:n,handleApply:()=>{e.onApply(function(e){const t=fd(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:gd(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:gd(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:cn(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:cn(e.floatingY)??0},distanceTop:cn(e.floatingDistanceTop)??0,distanceRight:cn(e.floatingDistanceRight)??0,distanceBottom:cn(e.floatingDistanceBottom)??0,distanceLeft:cn(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:gd(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:gd(e.columnWidth,"points"),cellWidth:gd(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:cn(e.marginTop),right:cn(e.marginRight),bottom:cn(e.marginBottom),left:cn(e.marginLeft)},borders:{top:e.borderTop?t:null,right:e.borderRight?t:null,bottom:e.borderBottom?t:null,left:e.borderLeft?t:null,start:e.borderStart?t:null,end:e.borderEnd?t:null,topLeftToBottomRight:e.borderTlBr?t:null,topRightToBottomLeft:e.borderTrBl?t:null},shading:e.shading.trim()||null,altTitle:e.altTitle.trim()||null,altDescription:e.altDescription.trim()||null}}(t),e.initial),e.onClose()}}}function hd(e,t,n,o,r=!1,a=!1){return X(po,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:e,min:a?void 0:"0",step:"1",get value(){return t()},disabled:r,onChange:n,"data-testid":o})}var bd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function yd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=bd(),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.measureIn")},get value(){return n().tableWidthUnit},onChange:e=>o("tableWidthUnit",e),"data-testid":"editor-table-properties-table-width-unit",get options(){return[{value:"points",label:t("table.points")},{value:"percent",label:t("table.percent")}]}})}})]}})}}),null),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[X(jr,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return n().tableAlign},onChange:e=>o("tableAlign",e),get children(){return["left","center","right"].map(e=>X(Wo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),X(Yr,{container:!0,spacing:1.5,get children(){return X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),X(fr,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),X(Ft,{get when(){return"around"===n().tableWrapping},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.horizontalAnchor")},get value(){return n().floatingHorizontalAnchor},onChange:e=>o("floatingHorizontalAnchor",e),"data-testid":"editor-table-properties-floating-h-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.verticalAnchor")},get value(){return n().floatingVerticalAnchor},onChange:e=>o("floatingVerticalAnchor",e),"data-testid":"editor-table-properties-floating-v-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("table.horizontalAlignment")},get value(){return n().floatingXAlign},onChange:e=>o("floatingXAlign",e),"data-testid":"editor-table-properties-floating-x-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["left","center","right","inside","outside"].map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("table.verticalAlignment")},get value(){return n().floatingYAlign},onChange:e=>o("floatingYAlign",e),"data-testid":"editor-table-properties-floating-y-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["top","center","bottom","inside","outside"].map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),X(fr,{get label(){return t("table.allowOverlap")},get checked(){return"overlap"===n().floatingOverlap},onChange:e=>o("floatingOverlap",e?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),r;var r}var vd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function xd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=vd(),We(r,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.rowHeightRule")},get value(){return n().rowHeightRule},onChange:e=>o("rowHeightRule",e),"data-testid":"editor-table-properties-row-height-rule",get options(){return[{value:"",label:t("table.rowAuto")},{value:"atLeast",label:t("table.rowAtLeast")},{value:"exact",label:t("table.rowExactly")}]}})}})]}}),null),We(r,X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),X(fr,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),X(fr,{get label(){return t("table.hiddenRow")},get checked(){return n().hiddenRow},onChange:e=>o("hiddenRow",e),"data-testid":"editor-table-properties-hidden-row"})]}}),null),r;var r}var wd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Sd(e){const t=R(),n=e.ctrl.set;return o=wd(),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var Cd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),Id=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Td(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set,r=vr(()=>{const e=fd(n().borderStyle,n().borderWidth,n().borderColor),t=e?`${e.width}pt ${e.type} ${e.color}`:void 0;return{"background-color":n().shading.trim()||void 0,"border-top":t&&n().borderTop?t:"1px solid #dadce0","border-right":t&&n().borderRight?t:"1px solid #dadce0","border-bottom":t&&n().borderBottom?t:"1px solid #dadce0","border-left":t&&n().borderLeft?t:"1px solid #dadce0"}}),a=()=>"none"===n().borderStyle;return i=Id(),We(i,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return hd(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("table.verticalAlignment")},get value(){return n().cellVerticalAlign},onChange:e=>o("cellVerticalAlign",e),"data-testid":"editor-table-properties-cell-valign",get options(){return[{value:"",label:t("table.inherit")},{value:"top",label:t("table.valignTop")},{value:"middle",label:t("table.valignMiddle")},{value:"bottom",label:t("table.valignBottom")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("table.textDirection")},get value(){return n().cellTextDirection},onChange:e=>o("cellTextDirection",e),"data-testid":"editor-table-properties-cell-direction",get options(){return[{value:"",label:t("table.inherit")},{value:"lrTb",label:"lrTb"},{value:"tbRl",label:"tbRl"},{value:"btLr",label:"btLr"},{value:"lrTbV",label:"lrTbV"},{value:"tbRlV",label:"tbRlV"}]}})}})]}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),X(fr,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),X(fr,{get label(){return t("table.hideMark")},get checked(){return n().cellHideMark},onChange:e=>o("cellHideMark",e),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("paragraph.borderStyleLabel")},get value(){return n().borderStyle},onChange:e=>{const t=e;o("borderStyle",t),"none"===t?(o("borderTop",!1),o("borderRight",!1),o("borderBottom",!1),o("borderLeft",!1),o("borderStart",!1),o("borderEnd",!1),o("borderTlBr",!1),o("borderTrBl",!1)):n().borderTop||n().borderRight||n().borderBottom||n().borderLeft||(o("borderTop",!0),o("borderRight",!0),o("borderBottom",!0),o("borderLeft",!0))},"data-testid":"editor-table-properties-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.borderColorLabel")},get value(){return n().borderColor||"#000000"},get disabled(){return a()},onChange:e=>o("borderColor",e),"data-testid":"editor-table-properties-border-color"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.borderSideTop")},get checked(){return n().borderTop},get disabled(){return a()},onChange:e=>o("borderTop",e),"data-testid":"editor-table-properties-border-top"}),X(fr,{get label(){return t("paragraph.borderSideRight")},get checked(){return n().borderRight},get disabled(){return a()},onChange:e=>o("borderRight",e),"data-testid":"editor-table-properties-border-right"}),X(fr,{get label(){return t("paragraph.borderSideBottom")},get checked(){return n().borderBottom},get disabled(){return a()},onChange:e=>o("borderBottom",e),"data-testid":"editor-table-properties-border-bottom"}),X(fr,{get label(){return t("paragraph.borderSideLeft")},get checked(){return n().borderLeft},get disabled(){return a()},onChange:e=>o("borderLeft",e),"data-testid":"editor-table-properties-border-left"}),X(fr,{get label(){return t("table.borderStart")},get checked(){return n().borderStart},get disabled(){return a()},onChange:e=>o("borderStart",e),"data-testid":"editor-table-properties-border-start"}),X(fr,{get label(){return t("table.borderEnd")},get checked(){return n().borderEnd},get disabled(){return a()},onChange:e=>o("borderEnd",e),"data-testid":"editor-table-properties-border-end"}),X(fr,{get label(){return t("table.borderTlBr")},get checked(){return n().borderTlBr},get disabled(){return a()},onChange:e=>o("borderTlBr",e),"data-testid":"editor-table-properties-border-tlbr"}),X(fr,{get label(){return t("table.borderTrBl")},get checked(){return n().borderTrBl},get disabled(){return a()},onChange:e=>o("borderTrBl",e),"data-testid":"editor-table-properties-border-trbl"})]}}),(e=Cd(),fe(t=>Sa(e,r(),t)),e)];var e}}),null),i;var i}var kd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Pd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=kd(),We(r,X(po,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),We(r,X(vo,{class:"oasis-editor-dialog-input-group",get label(){return t("table.altDescription")},controlClass:"oasis-editor-table-properties-textarea",get value(){return n().altDescription},onChange:e=>o("altDescription",e),"data-testid":"editor-table-properties-alt-description"}),null),r;var r}function Rd(e){const t=R(),n=md(e);return X(xt,{get isOpen(){return e.isOpen},get title(){return t("table.propertiesTitle")},get onClose(){return e.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-table-properties-cancel",confirmTestId:"editor-table-properties-apply"})},get children(){return X(da,{get value(){return n.form.activeTab},onChange:e=>n.set("activeTab",e),get ariaLabel(){return t("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:t("table.tabTable"),testId:"editor-table-properties-tab-table",panel:X(yd,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:X(xd,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:X(Sd,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:X(Td,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:X(Pd,{ctrl:n})}]}})}})}var Bd=/*#__PURE__*/f("<p data-testid=editor-new-document-message>");function Ad(e){const t=R();return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("dialog.newDocument.discard")},cancelTestId:"editor-new-document-cancel",confirmTestId:"editor-new-document-discard"})},get children(){var e=Bd();return We(e,()=>t("dialog.newDocument.message")),e}})}function Md(e){const t=R(),n=()=>"accept"===e.action;return X(xt,{get isOpen(){return e.isOpen},get title(){return t(n()?"review.bulkAcceptTitle":"review.bulkRejectTitle")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",testId:"editor-revision-bulk-dialog",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t(n()?"toolbar.acceptAll":"toolbar.rejectAll")},cancelTestId:"editor-revision-bulk-cancel",confirmTestId:"editor-revision-bulk-confirm"})},get children(){return X(ia,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Fd=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-controls><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-font></select></label><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-category><option value=all>"),Od=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),Dd=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-layout><div class=oasis-editor-symbol-dialog-grid role=grid></div><aside class=oasis-editor-symbol-dialog-preview><span class=oasis-editor-symbol-dialog-preview-label></span><span class=oasis-editor-symbol-dialog-preview-character data-testid=editor-symbol-dialog-preview></span><label class=oasis-editor-symbol-dialog-field><span></span><input data-testid=editor-symbol-dialog-code></label><p class=oasis-editor-symbol-dialog-help>"),Ed=/*#__PURE__*/f("<option>"),Ld=/*#__PURE__*/f("<button type=button class=oasis-editor-symbol-dialog-tile>"),Nd=/*#__PURE__*/f("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),$d=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function zd(e){const t=R(),[n,o]=an("common"),[r,a]=an(Hn[0]),[i,l]=an($d[0]),[s,c]=an(Hn[0].codePoint),d=vr(()=>(e.isOpen,Lo())),u=vr(()=>"all"===n()?Qn.flatMap(e=>e.entries):Qn.find(e=>e.id===n())?.entries??Hn),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&($r(t),e.onInsert(t,i()),e.onClose())};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.symbol.title")},get onClose(){return e.onClose},class:"oasis-editor-symbol-dialog",bodyClass:"oasis-editor-symbol-dialog-body",size:"lg",closeOnOverlayClick:!1,get footer(){return[X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(w=Fd(),S=w.firstChild,C=S.firstChild,I=C.nextSibling,T=S.nextSibling.firstChild,k=T.nextSibling,P=k.firstChild,We(C,()=>t("dialog.symbol.font")),I.addEventListener("change",e=>{l(e.currentTarget.value)}),We(I,X(ee,{each:$d,children:e=>{return(t=Ed()).value=e,We(t,e),t;var t}})),We(T,()=>t("dialog.symbol.subset")),k.addEventListener("change",e=>{o(e.currentTarget.value)}),We(P,()=>t("symbols.category.all")),We(k,X(ee,{each:Qn,children:e=>{return n=Ed(),We(n,()=>t(e.labelKey)),fe(()=>n.value=e.id),n;var n}}),null),fe(()=>I.value=i()),fe(()=>k.value=n()),w),(e=Dd(),f=e.firstChild,m=f.nextSibling.firstChild,h=m.nextSibling,b=h.nextSibling,y=b.firstChild,v=y.nextSibling,x=b.nextSibling,We(f,X(Ft,{get when(){return d().length>0},get children(){var e=Od(),n=e.firstChild,o=n.nextSibling;return We(n,()=>t("dialog.symbol.recent")),We(o,X(ee,{get each(){return d()},children:e=>{return(t=Ld()).$$click=()=>p(e),We(t,()=>e.character),fe(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&le(t,"title",n.e=o),r!==n.t&&le(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),We(f,X(ee,{get each(){return u()},children:e=>{return(t=Nd()).$$dblclick=g,t.$$click=()=>p(e),We(t,()=>e.character),fe(n=>{var o=!(r().character!==e.character),a=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,l=`editor-symbol-dialog-${e.codePoint.replace(/[^A-Z0-9]/g,"-")}`;return o!==n.e&&t.classList.toggle("oasis-editor-symbol-dialog-tile-active",n.e=o),a!==n.t&&le(t,"title",n.t=a),i!==n.a&&le(t,"aria-label",n.a=i),l!==n.o&&le(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),We(m,()=>t("dialog.symbol.preview")),We(h,()=>r().character),We(y,()=>t("dialog.symbol.code")),v.$$input=e=>(e=>{c(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||a({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),le(v,"spellcheck",!1),We(x,()=>t("dialog.symbol.doubleClickHelp")),fe(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&le(f,"aria-label",e.e=n),o!==e.t&&Re(h,"font-family",e.t=o),e},{e:void 0,t:void 0}),fe(()=>v.value=s()),e)];var e,f,m,h,b,y,v,x,w,S,C,I,T,k,P}})}Ee(["input","click","dblclick"]);var Hd=/*#__PURE__*/f("<div class=oasis-editor-equation-editor><div class=oasis-editor-equation-palette></div><label class=oasis-editor-equation-linear><span></span><textarea data-testid=editor-equation-linear></textarea></label><div class=oasis-editor-equation-preview aria-live=polite data-testid=editor-equation-preview>"),Wd=/*#__PURE__*/f("<button type=button data-testid=editor-equation-template>"),Ud=[["\\frac{□}{□}","\\frac{a}{b}"],["\\sqrt{□}","\\sqrt{x}"],["x^□","x^{2}"],["x_□","x_{i}"],["∑","\\sum_{i=1}^{n} i"],["∫","∫ f(x) dx"],["[ ]","(a+b)"],["[a b]","\\matrix{a & b \\ c & d}"]];function jd(e){const t=R(),[n,o]=an(""),[r,a]=an(Ir);we(()=>{if(!e.isOpen)return;const t=e.initial??Ir;a(t),o(L(t))});const i=e=>{o(e),a(kt(e))};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.equation.title")},get onClose(){return e.onClose},size:"lg",closeOnOverlayClick:!1,class:"oasis-editor-equation-dialog",get footer(){return[X(Qe,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Hd(),o=e.firstChild,a=o.nextSibling,l=a.firstChild,s=l.nextSibling,c=a.nextSibling;return We(o,X(ee,{each:Ud,children:([e,t])=>{return(n=Wd()).$$click=()=>i(t),We(n,e),n;var n}})),We(l,()=>t("dialog.equation.linear")),s.$$input=e=>i(e.currentTarget.value),le(s,"spellcheck",!1),We(c,()=>L(r())||t("dialog.equation.empty")),fe(()=>le(o,"aria-label",t("dialog.equation.structures"))),fe(()=>s.value=n()),e}})}Ee(["input","click"]);var Vd=/*#__PURE__*/f("<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper></div></div><div class=oasis-editor-fr-input-group>");function Kd(e){const t=R(),{fr:n}=e,r=e=>{n.isOpen()&&"Escape"===e.key&&n.setIsOpen(!1)},a=e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext())};return Zn(()=>{window.addEventListener("keydown",r,!0)}),o(()=>{window.removeEventListener("keydown",r,!0)}),X(Ft,{get when(){return n.isOpen()},get children(){var e=Vd(),o=e.firstChild,r=o.nextSibling,i=r.firstChild,l=i.firstChild,s=i.nextSibling;return e.$$keydown=a,We(o,X(ia,{get children(){return t("find.title")}}),null),We(o,X(ht,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),We(l,X(po,{type:"text",get placeholder(){return t("find.placeholder")},get value(){return n.searchTerm()},onChange:e=>n.setSearchTerm(e),autofocus:!0,controlClass:"oasis-editor-fr-input"}),null),We(l,X(On,{class:"oasis-editor-fr-counter",get children(){return et(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),We(i,X(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[X(ht,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),X(ht,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),We(s,X(po,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),We(s,X(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[X(ht,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),X(ht,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replaceAll},get disabled(){return 0===n.matches().length},get children(){return t("replace.allBtn")}})]}}),null),We(r,X(ba,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[X(fr,{class:"oasis-editor-fr-checkbox",get label(){return t("find.matchCase")},get checked(){return n.findOptions().matchCase},onChange:e=>n.setFindOptions({...n.findOptions(),matchCase:e})}),X(fr,{class:"oasis-editor-fr-checkbox",get label(){return t("find.wholeWord")},get checked(){return n.findOptions().wholeWord},onChange:e=>n.setFindOptions({...n.findOptions(),wholeWord:e})})]}}),null),e}})}Ee(["keydown"]);var _d=/*#__PURE__*/f("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),Xd=/*#__PURE__*/f("<i>"),Gd=/*#__PURE__*/f("<span class=oasis-editor-context-menu-shortcut>"),qd=/*#__PURE__*/f("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),Yd=/*#__PURE__*/f("<div class=oasis-editor-context-menu-separator>"),Zd=/*#__PURE__*/f("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function Jd(e){let t;const n=t=>{e.isOpen&&"Escape"===t.key&&(t.preventDefault(),e.onClose())},r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},a=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},i=()=>{e.isOpen&&e.onClose()};return Zn(()=>{window.addEventListener("keydown",n,!0),window.addEventListener("mousedown",r,!0),window.addEventListener("contextmenu",a,!0),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i,!0)}),o(()=>{window.removeEventListener("keydown",n,!0),window.removeEventListener("mousedown",r,!0),window.removeEventListener("contextmenu",a,!0),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i,!0)}),we(()=>{if(!e.isOpen||!t)return;const n=t.getBoundingClientRect(),o=Math.max(4,window.innerWidth-n.width-4),r=Math.max(4,window.innerHeight-n.height-4),a=Math.min(e.x,o),i=Math.min(e.y,r);t.style.left=`${a}px`,t.style.top=`${i}px`}),X(Ft,{get when(){return e.isOpen},get children(){var n=_d();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?zt(t,n):t=n,We(n,X(ee,{get each(){return e.items},children:t=>X(Ft,{get when(){return"separator"!==t.type},get fallback(){return Yd()},get children(){var n=qd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},We(n,X(Ft,{get when(){return t.icon},get fallback(){return e=Zd(),We(e,X(v,{size:16})),e;var e},get children(){var e=Xd();return fe(()=>le(e,"data-lucide",t.icon)),e}}),o),We(o,()=>t.label),We(n,X(Ft,{get when(){return t.shortcut},get children(){var e=Gd();return We(e,()=>t.shortcut),e}}),null),fe(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&le(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),fe(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&Re(n,"left",t.e=o),r!==t.t&&Re(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function Qd(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:c,paragraphDialog:d,setParagraphDialog:u,tablePropertiesDialog:p,setTablePropertiesDialog:g,newDocumentDialog:f,setNewDocumentDialog:m,revisionBulkDialog:h,setRevisionBulkDialog:b,symbolDialog:y,setSymbolDialog:v,equationDialog:x,setEquationDialog:w}=e.dialogs;return[X(Ad,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),X(Md,{get isOpen(){return h().isOpen},get action(){return h().action},get count(){return h().count},onClose:()=>{b({...h(),isOpen:!1}),e.focusInput()},onConfirm:()=>{const t=h().action;b({...h(),isOpen:!1}),e.applyBulkRevisions(t)}}),X(zd,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),X(jd,{get isOpen(){return x().isOpen},get initial(){return x().initial},onClose:()=>{w({isOpen:!1}),e.focusInput()},onApply:t=>{w({isOpen:!1}),e.applyEquation(t,x().targetRunId)}}),X(Rc,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),X(Bc,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),X(Ac,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),X(Oc,{get composer(){return e.commentComposer}}),X(Kd,{get fr(){return e.findReplace}}),X(td,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...s(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),X(pd,{get isOpen(){return d().isOpen},get initial(){return d().initial},onClose:()=>{u({...d(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyParagraphDialogValues},get onSetDefault(){return e.setParagraphDialogDefault}}),X(Rd,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),X(Jd,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}Ee(["contextmenu","click"]);var eu=/*#__PURE__*/f("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function tu(e){let t,n;const o=nt(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=je({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[X(Ft,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return X(t,{get state(){return n.state()},get toolbarHost(){return n.toolbarHost},get runtimeEditor(){return n.runtimeEditor},get persistenceStatus(){return n.persistenceStatus},get toolbarRegistry(){return n.toolbarRegistry},get menuRegistry(){return n.menuRegistry},get showChrome(){return o.showChrome()},get showTitleBar(){return o.showTitleBar()},get showMenubar(){return o.showMenubar()},get showToolbar(){return o.showToolbar()},get showOutline(){return o.showOutline},get toolbarView(){return o.toolbarView()},get toolbarLayout(){return o.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get documentLayout(){return r.documentLayout},get viewportHeight(){return r.viewportHeight},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),X(Ft,{get when(){return!e.useComposedShell()},get children(){return X(N,{get editor(){return e.runtime.runtimeEditor},get children(){var l=eu(),s=l.firstChild;return We(l,X(Ft,{get when(){return e.chrome.showOutline()},get children(){return X(Vo,{get state(){return e.runtime.state()},onNavigate:i,surfaceRef:()=>t,viewportRef:()=>n,get documentLayout(){return e.view.documentLayout},get zoomFactor(){return e.view.layout.zoomFactor},snapshotProvider:o})}}),s),We(s,X(U,{get state(){return e.runtime.state},get layout(){return{...e.view.layout,documentLayout:e.view.documentLayout,measuredBlockHeights:e.view.measuredBlockHeights,measuredParagraphLayouts:e.view.measuredParagraphLayouts,readOnly:e.view.isReadOnly()}},get overlays(){return{...e.view.overlays,toolbarHost:e.runtime.toolbarHost,persistenceStatus:e.runtime.persistenceStatus}},get refs(){return{...e.view.refs,onSurfaceRef:r,onViewportRef:a}},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),l}})}})]}var nu=/*#__PURE__*/f("<div class=oasis-editor-welcome-overlay role=dialog aria-modal=true aria-labelledby=oasis-editor-welcome-title><div class=oasis-editor-welcome-card><h2 id=oasis-editor-welcome-title class=oasis-editor-welcome-title></h2><p class=oasis-editor-welcome-body></p><p class=oasis-editor-welcome-note></p><div class=oasis-editor-welcome-actions>");function ou(e){const t=R(),n=()=>{wa(),_(),e.onClose()},o=()=>{Kt(!1),_(),e.onClose()};return X(Ft,{get when(){return e.isOpen},get children(){var e=nu(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return We(r,X(Tt,{height:72,class:"oasis-editor-welcome-mark"}),a),We(a,()=>t("welcome.title")),We(i,()=>t("welcome.body")),We(l,()=>t("welcome.note")),We(s,X(Qe,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),We(s,X(Qe,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var ru=/* @__PURE__ */Qo(It(),1),au=ea(),iu="word/comments.xml";function lu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function su(e){return e.localName??e.tagName}function cu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function du(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function uu(e){let t="";for(const n of lu(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===su(n)){t+=n.textContent??"";continue}if("tab"===su(n)){t+="\t";continue}if("br"===su(n)||"cr"===su(n)){t+="\n";continue}}t+=uu(n)}return t}function pu(e){return lu(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===su(e))}function gu(e){return pu(e).map(uu).join("\n").trim()}function fu(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===su(t)?t:void 0}function mu(e,t){const n=cu(pu(t)[0]??t,"paraId");for(;t.firstChild;)t.removeChild(t.firstChild);for(let r=0;r<e.childNodes.length;r+=1){const n=e.childNodes[r];n&&t.appendChild(n.cloneNode(!0))}const o=pu(t)[0];n&&o&&o.setAttributeNS(to,"w14:paraId",n)}function hu(e,t){const n=pu(e),o=pu(t);n[0]&&o[0]&&jn(n[0],o[0]);const r=new Set(lu(t).filter(e=>e.namespaceURI!==ur).map(e=>`${e.namespaceURI??""}\0${su(e)}`));for(const a of lu(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${su(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function bu(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/comments")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(iu);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=fu(e),o=fu(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of lu(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==su(i))continue;const e=cu(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of lu(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==su(i))continue;const e=cu(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new au.XMLSerializer).serializeToString(t);du(i,t),gu(i)===gu(t)?mu(i,t):hu(i,t),(new au.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(iu,a),!0)}var yu="http://schemas.microsoft.com/office/word/2012/wordml",vu="word/commentsExtended.xml";function xu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function wu(e){return e.localName??e.tagName}function Su(e){return`${e.namespaceURI??""}\0${wu(e)}`}function Cu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Iu(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function Tu(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function ku(e){const t=/* @__PURE__ */new Map,n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(ur,"comment"))){const e=Cu(o,"id"),n=o.getElementsByTagNameNS(ur,"p").item(0),r=n?Cu(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function Pu(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===yu&&"commentsEx"===wu(t)?t:void 0}function Ru(e,t,n){for(let r=0;r<e.attributes.length;r+=1){const o=e.attributes.item(r);if(!o)continue;const a=o.localName??o.name;"paraId"!==a&&((o.namespaceURI?t.hasAttributeNS(o.namespaceURI,a):t.hasAttribute(o.name))||Iu(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(xu(t).map(Su));for(const r of xu(e))o.has(Su(r))||t.appendChild(r.cloneNode(!0))}function Bu(e,t,n,o){const r=Pu(t),a=Pu(o);if(!r||!a)return o;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||Iu(t,o,o.value)}}(r,a);const i=ku(e),l=ku(n),s=/* @__PURE__ */new Map;for(const[p,g]of i){const e=l.get(p);e&&s.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of xu(e)){if(n.namespaceURI!==yu||"commentEx"!==wu(n))continue;const e=Cu(n,"paraId");e&&t.set(e,n)}return t}(a),d=xu(r),u=new Set(xu(a).filter(e=>!(e.namespaceURI===yu&&"commentEx"===wu(e))).map(Su));for(const p of d){if(p.namespaceURI===yu&&"commentEx"===wu(p)){const e=Cu(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&Ru(p,n,s);continue}u.has(Su(p))||(a.appendChild(p.cloneNode(!0)),u.add(Su(p)))}return(new au.XMLSerializer).serializeToString(a.ownerDocument)}var Au="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Mu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Fu(e){return e.localName??e.tagName}function Ou(e){return`${e.namespaceURI??""}\0${Fu(e)}`}function Du(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Eu(e,t){return Mu(e).find(e=>e.namespaceURI===Au&&Fu(e)===t)}function Lu(e,t){return e.filter(e=>e.namespaceURI===Au&&t.has(Fu(e)))}function Nu(e){if(e.namespaceURI!==Au)return;const t=Fu(e);if("p"===t){const t=Du(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Eu(e,"sdtPr"),n=t?Eu(t,"id"):void 0,o=n?Du(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function $u(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=(new au.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==Au||i.namespaceURI!==Au||Fu(a)!==n||Fu(i)!==n)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(a,i);const l=Mu(a),s=Mu(i),c=new Set(s.map(Ou));return l.forEach((e,t)=>{if(e.namespaceURI===Au||c.has(Ou(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>Ou(t)===Ou(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new au.XMLSerializer).serializeToString(r)}function zu(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=$u(e,t,n),a=(new au.DOMParser).parseFromString(e,"application/xml"),i=(new au.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==Au||s.namespaceURI!==Au||Fu(l)!==n||Fu(s)!==n)return r;const c=Mu(l),d=Mu(s),u=function(e,t,n){const o=Lu(e,n),r=Lu(t,n);return o.length===r.length&&o.every((e,t)=>Fu(e)===Fu(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Au||o.has(Fu(e)))return;const n=Ou(e),r=p.get(n)??0;if(p.set(n,r+1),Mu(s).filter(e=>Ou(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===Au&&o.has(Fu(e)));if(!a)return;const i=Nu(a);if(i){const e=Lu(n,o).find(e=>Nu(e)===i);if(e)return e}if(!r)return;const l=Lu(e,o),s=Lu(n,o),c=l.indexOf(a);return c>=0?s[c]:void 0}(c,t,d,o,u);(a||u)&&s.insertBefore(e.cloneNode(!0),a??null)}),(new au.XMLSerializer).serializeToString(i)}var Hu="word/document.xml",Wu=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Uu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function ju(e){return e.localName??e.tagName}function Vu(e){return`${e.namespaceURI??""}\0${ju(e)}`}function Ku(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function _u(e,t){return Uu(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ju(e)===t)}function Xu(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Wu.has(ju(e))}function Gu(e){return e.filter(Xu)}function qu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=ju(e);if("p"===t){const t=Ku(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=_u(e,"sdtPr"),n=t?Ku(_u(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Yu(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml"),o=(new au.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==r.namespaceURI||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==a.namespaceURI||"document"!==ju(r)||"document"!==ju(a))return t;!function(e,t){const n=Uu(e),o=_u(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===ju(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=Uu(t).find(t=>!i.has(t)&&Vu(t)===Vu(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=_u(r,"body"),l=_u(a,"body");if(!i||!l)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(i,l);const s=Uu(i),c=Uu(l),d=function(e,t){const n=Gu(e),o=Gu(t);return n.length===o.length&&n.every((e,t)=>ju(e)===ju(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if(Xu(e))return;const n=Vu(e),o=u.get(n)??0;if(u.set(n,o+1),Uu(l).filter(e=>Vu(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(Xu);if(!o)return;const r=qu(o);return r?Gu(n).find(e=>qu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=Gu(e),r=Gu(n),a=e.slice(t+1).find(Xu);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(s,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&l.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===ju(e))}(c)??null)}),(new au.XMLSerializer).serializeToString(o)}async function Zu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(Hu);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Yu(e,$u(e,t,"document"))}(n.data,r);return a!==r&&(t.file(Hu,a),!0)}var Ju="word/document.xml",Qu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ep(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function tp(e){const t=(new au.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Qu,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function np(e){const t=[];return tp(e).forEach((e,n)=>{const o=/* @__PURE__ */new Map;for(const r of function(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}(e)){const e=r.namespaceURI===Qu&&"headerReference"===r.localName?"header":r.namespaceURI===Qu&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=ep(r,"id");if(!a)continue;const i=ep(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),t.push({key:`${n}:${e}:${i}:${s}`,kind:e,relationshipId:a})}}),t}function op(e){return new Map(e.map(e=>[e.id,e]))}async function rp(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(Ju)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=tp(n.data),a=tp(o);if(r.length!==a.length)return!1;const i=np(n.data),l=np(o),s=new Map(i.map(e=>[e.key,e])),c=op(n.relationships??[]),d=op(await async function(e){const t=await(e.file(function(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}(Ju))?.async("string"));return An(Ju,fa(t))}(t));let u=!1;for(const p of l){const n=s.get(p.key);if(!n||n.kind!==p.kind)continue;const o=c.get(n.relationshipId),r=d.get(p.relationshipId);if("External"===o?.targetMode||"External"===r?.targetMode||!o?.resolvedTarget||!r?.resolvedTarget)continue;const a=e.parts[o.resolvedTarget];if("xml"!==a?.kind)continue;const i=r.resolvedTarget,l=await(t.file(i)?.async("string"));if(!l)continue;const g="header"===p.kind?"hdr":"ftr",f=zu(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var ap="word/document.xml",ip={"/styles":"word/styles.xml","/numbering":"word/numbering.xml","/settings":"word/settings.xml","/fontTable":"word/fontTable.xml","/theme":"word/theme/theme1.xml","/footnotes":"word/footnotes.xml","/endnotes":"word/endnotes.xml","/comments":"word/comments.xml","/commentsExtended":"word/commentsExtended.xml"},lp=["/officeDocument",...Object.keys(ip)];function sp(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function cp(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function dp(e){for(const[t,n]of Object.entries(ip))if(e.type.endsWith(t))return n}function up(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=so(e);return void 0===n?t.get(e)??e:null===n?e:cp(t.get(n)??n)}function pp(e,t){for(const[n,o]of t)if(o===e)return n;return e}function gp(e,t){if(null===e)return t;const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function fp(e,t){const n=e.parts[t];return"xml"===n?.kind?fa(n.data):[]}function mp(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:fp(e,ho):e.parts[t]?.relationships??fp(e,cp(t));return An(t,n)}function hp(e,t,n){return mp(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function bp(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,lp.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=An(n,[e])[0]?.resolvedTarget,c=l?.resolvedTarget??(s?r.get(s)??s:void 0);return c?{...e,...l?{id:l.id,type:l.type}:{},target:gp(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function yp(e,t,n){const o=[...t],r=new Map(t.map(e=>[e.id,e]));for(const a of e){const e=r.get(a.id);if(e){if(sp(e)===sp(a))continue;throw new Error(`Cannot safely preserve ${n}: relationship id ${a.id} is used by both the source package and rebuilt document for different targets.`)}o.push(a)}return o}function vp(e,t,n){const o=t.parts[n];o&&("base64"===o.encoding?e.file(n,o.data,{base64:!0}):e.file(n,o.data))}function xp(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===Wt(o))}async function wp(e,t){const n=e.sourcePackage;if(!n)return t;const o=await ru.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>hn(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(ap,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=dp(o);e&&t.set(e,o.resolvedTarget)}return t}(n),i=function(e,t,n){const o=/* @__PURE__ */new Set;for(const[r,a]of t)r!==ap&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new ru.default;for(const c of Object.keys(n.parts))vp(l,n,c);for(const c of i)l.remove(c),l.remove(cp(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=so(a);if(null==i)continue;const l=mp(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=pp(i,n);o.has(cp(c))||(0===s.length?e.remove(a):e.file(a,bt(s)))}}(l,n,a,r,i);let s=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=hn(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=up(e,a),o=so(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=hp(n,r,i),c=yp(s,bp(fa(await d.async("string")),s,e,r,a),t);l.file(t,bt(c));continue}const r=await d.async("uint8array");xp(n,e,t,r)||l.file(t,r)}return s&&l.file(Ko,function(e,t,n,o){const r=Xr(t),a={};for(const[l,s]of Object.entries(r.overrides))a[n.get(l)??l]=s;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return la({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,s,a,i)),l.generateAsync({type:"arraybuffer"})}var Sp="word/document.xml",Cp=["first","even","default"];function Ip(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function Tp(e,t){const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function kp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Pp(e,t){const n=[],o=e=>{for(const r of kp(e))r.localName===t&&n.push(r),o(r)};return o(e),n}function Rp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Bp(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return r.value!==n&&(e.setAttribute(r.name,n),!0)}return!1}function Ap(e){const t=(new au.DOMParser).parseFromString(e,"application/xml"),n=[],o=Pp(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of kp(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Rp(r,"id");if(!a)continue;const i=Rp(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),n.push({key:`${t}:${e}:${i}:${s}`,sectionIndex:t,kind:e,type:i,occurrence:s,relationshipId:a})}}),{references:n,sectionCount:o.length}}function Mp(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function Fp(e,t){const n=e.parts[t]?.relationships??fa(Mp(e,Ip(t)));return An(t,n)}function Op(e,t){const n=new Map(t.map(e=>[e.id,e]));return e.flatMap(e=>{const t=n.get(e.relationshipId);if(!t||"External"===t.targetMode||!t.resolvedTarget)return[];const o="header"===e.kind?"/header":"/footer";return t.type.endsWith(o)?[{...e,relationship:t,partPath:t.resolvedTarget}]:[]})}async function Dp(e,t){const n=Mp(e,e.mainDocumentPart),o=await(t.file(Sp)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=Ap(n),a=Ap(o),i=Op(r.references,Fp(e,e.mainDocumentPart));!function(e){const t=[...e].sort((e,t)=>{if(e.sectionIndex!==t.sectionIndex)return e.sectionIndex-t.sectionIndex;if(e.kind!==t.kind)return"header"===e.kind?-1:1;const n=Cp.indexOf(e.type),o=Cp.indexOf(t.type),r=n<0?99:n,a=o<0?99:o;return r!==a?r-a:e.type!==t.type?e.type.localeCompare(t.type):e.occurrence-t.occurrence});let n=1,o=1;for(const r of t)"header"===r.kind?(r.baselinePath=`word/header${n}.xml`,n+=1):(r.baselinePath=`word/footer${o}.xml`,o+=1)}(i);const l=Op(a.references,await async function(e,t){const n=await(e.file(Ip(t))?.async("string"));return An(t,fa(n))}(t,Sp)),s=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of l){const e=s.get(p.key);e&&(c.push({current:p,source:e}),d.add(e.partPath),u.set(p.relationshipId,e.relationship))}return{matches:c,deletedSourcePartPaths:r.sectionCount===a.sectionCount?new Set(i.map(e=>e.partPath).filter(e=>!d.has(e))):/* @__PURE__ */new Set,sourceRelationshipByCurrentId:u}}function Ep(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function Lp(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===Wt(await a.async("uint8array")):void 0===r}async function Np(e,t,n,o){for(const r of n)if(!(await Lp(e,t,o?Ip(r.current.partPath):r.current.partPath,r.source.baselinePath?o?Ip(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function $p(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?Ip(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?Wt(a):"<missing>")}if(o.size>1)throw new Error(`Cannot safely preserve shared header/footer part ${t[0].source.partPath}: its section projections diverged after editing.`)}async function zp(e,t,n){const o=await(e.file(Sp)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[Sp],a=Wt((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of Pp(n,r)){const n=Rp(e,"id"),r=n?t.get(n):void 0;r&&(o=Bp(e,"id",r.id)||o)}return o?(new au.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(Sp,t)}}const r=Ip(Sp),a=fa(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:Tp(Sp,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,bt(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(Ep(e)===Ep(r))continue;throw new Error(`Cannot safely preserve ${t}: relationship id ${r.id} is used for different targets.`)}o.set(r.id,r),n.push(r)}return n}(a,r)))}async function Hp(e,t,n){const o=n[0],r=o.source.partPath;if(!(await Np(e,t,n,!1))){await $p(e,n,!1);const t=await(e.file(o.current.partPath)?.async("uint8array"));if(!t)throw new Error(`Cannot preserve ${r}: rebuilt header/footer part is missing.`);e.file(r,t)}for(const c of n)c.current.partPath!==r&&e.remove(c.current.partPath);const a=Ip(r);if(!(await Np(e,t,n,!0))){await $p(e,n,!0);const t=Ip(o.current.partPath),c=await(e.file(t)?.async("string"));c&&e.file(a,bt((i=fa(c),l=o.current.partPath,s=r,i.map(e=>{if("External"===e.targetMode)return e;const t=An(l,[e])[0]?.resolvedTarget;return t?{...e,target:Tp(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=Ip(c.current.partPath);t!==a&&e.remove(t)}}async function Wp(e,t,n){for(const o of function(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=t.get(n.source.partPath)??[];e.push(n),t.set(n.source.partPath,e)}return t}(n.matches).values())await Hp(e,t,o)}async function Up(e,t){const n=e.sourcePackage;if(!n)return t;const o=await ru.default.loadAsync(t),r=await Dp(n,o);r.matches.length>0&&(await zp(o,n,r),await Wp(o,n,r),await async function(e,t){const n=await(e.file(Ko)?.async("string"));if(!n)return;const o=Xr(n);for(const r of t.matches){const e=o.overrides[r.current.partPath];e&&(o.overrides[r.source.partPath]=e),r.current.partPath!==r.source.partPath&&delete o.overrides[r.current.partPath]}e.file(Ko,la(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return wp(function(e,t){const n=e.sourcePackage;if(!n||0===t.size)return e;const o={defaults:{...n.contentTypes.defaults},overrides:Object.fromEntries(Object.entries(n.contentTypes.overrides).filter(([e])=>!t.has(e)))},r={...n.parts};for(const d of t)delete r[d],delete r[Ip(d)];const a=r[n.mainDocumentPart],i=Fp(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=Ip(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:bt(i)});const c=r[Ko];return c&&(r[Ko]={...c,data:la(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var jp=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],Vp=/* @__PURE__ */new Set(["p","tbl"]),Kp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function _p(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Xp(e){return e.localName??e.tagName}function Gp(e){return`${e.namespaceURI??""}\0${Xp(e)}`}function qp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Yp(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function Zp(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Xp(n)===t?n:void 0}function Jp(e){const t=qp(e,"type");if(t&&Kp.has(t))return`type:${t}`;const n=qp(e,"id");return n?`id:${n}`:void 0}function Qp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Vp.has(Xp(e))}function eg(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Xp(e))return;const t=qp(e,"paraId");return t?`p:${t}`:void 0}function tg(e,t){!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(e,t);const n=_p(e),o=_p(t),r=function(e,t){const n=e.filter(Qp),o=t.filter(Qp);return n.length===o.length&&n.every((e,t)=>Xp(e)===Xp(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Qp(e))return;const l=Gp(e),s=a.get(l)??0;if(a.set(l,s+1),_p(t).filter(e=>Gp(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Qp);if(!r)return;const a=eg(r);if(a){const e=n.filter(Qp).find(e=>eg(e)===a);if(e)return e}if(!o)return;const i=e.filter(Qp),l=n.filter(Qp),s=i.indexOf(r);return s>=0?l[s]:void 0}(n,i,o,r);("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||c||r)&&t.insertBefore(e.cloneNode(!0),c??null)})}function ng(e,t,n,o){const r=Zp(t,o.rootName),a=Zp(n,o.rootName);if(!r||!a)return n;const i=_p(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xp(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of _p(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Xp(c)!==o.entryName)continue;const e=Jp(c);e&&l.set(e,c)}const s=function(e,t){const n="footnote"===t?e.footnotes?.items:e.endnotes?.items,o=/* @__PURE__ */new Set;for(const r of Object.values(n??{}))void 0!==r.docxId&&Number.isSafeInteger(r.docxId)&&r.docxId>=1&&o.add(String(r.docxId));return o}(e,o.kind);for(const c of i){const e=Jp(c);if(!e)continue;const t=l.get(e),n=qp(c,"type");if(t){n&&Kp.has(n)?a.replaceChild(c.cloneNode(!0),t):tg(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=qp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new au.XMLSerializer).serializeToString(a.ownerDocument)}var og="http://schemas.openxmlformats.org/wordprocessingml/2006/main",rg="word/numbering.xml";function ag(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function ig(e){return e.localName??e.tagName}function lg(e){return`${e.namespaceURI??""}\0${ig(e)}`}function sg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function cg(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return void e.setAttribute(r.name,n)}e.setAttributeNS(og,`w:${t}`,n)}function dg(e,t){return ag(e).find(e=>e.namespaceURI===og&&ig(e)===t)}function ug(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function pg(e,t){const n=new Set(ag(t).map(lg));for(const o of ag(e))o.namespaceURI===og||n.has(lg(o))||t.appendChild(o.cloneNode(!0))}function gg(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}var fg=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function mg(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[lg(e),e]));n.forEach((e,r)=>{const a=lg(e),i=o.get(a),l=ig(e);if(i)return ug(e,i),void(e.namespaceURI===og&&"rPr"===l?function(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[lg(e),e]));n.forEach((e,r)=>{const a=lg(e),i=o.get(a);if(i)return ug(e,i),void pg(e,i);e.namespaceURI===og&&"rFonts"===ig(e)||gg(n,r,e,t,e=>o.get(lg(e)))})}(e,i):pg(e,i));if(e.namespaceURI!==og||!fg.has(l)){if(e.namespaceURI===og&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of ag(e))o.namespaceURI===og&&"rFonts"===ig(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}gg(n,r,e,t,e=>o.get(lg(e)))}})}function hg(e){return function(e){return e.namespaceURI===og&&"lvl"===ig(e)?`${lg(e)}\0${sg(e,"ilvl")??"0"}`:lg(e)}(e)}function bg(e,t,n){const o=dg(t,"abstractNumId"),r=o?sg(o,"val"):void 0;if(!r)return;const a=ag(e).find(e=>e.namespaceURI===og&&"abstractNum"===ig(e)&&sg(e,"abstractNumId")===r);return a?ag(a).find(e=>e.namespaceURI===og&&"lvl"===ig(e)&&(sg(e,"ilvl")??"0")===n):void 0}function yg(e,t){const n=t.cloneNode(!0);mg(e,n);const o=dg(e,"pPr"),r=dg(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function vg(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=sg(dg(t,"start")??t,"val")??"1";for(const r of ag(e)){const e=ig(r);if(r.namespaceURI===og&&"startOverride"===e){const e=r.cloneNode(!0);cg(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==og||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(yg(r,t))}return n}function xg(e){if(e.namespaceURI!==og)return lg(e);const t=ig(e);return"abstractNum"===t?`${lg(e)}\0${sg(e,"abstractNumId")??""}`:"num"===t?`${lg(e)}\0${sg(e,"numId")??""}`:lg(e)}function wg(e,t){const n=function(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new au.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===og&&o.namespaceURI===og&&"numbering"===ig(n)&&"numbering"===ig(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;ug(o,r);const a=ag(o),i=new Map(ag(r).map(e=>[xg(e),e]));return a.forEach((e,t)=>{const n=xg(e),o=i.get(n),l=ig(e);if(o)return ug(e,o),void(e.namespaceURI===og&&"abstractNum"===l?function(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[hg(e),e]));n.forEach((e,r)=>{const a=hg(e),i=o.get(a);if(i)return ug(e,i),void(e.namespaceURI===og&&"lvl"===ig(e)?mg(e,i):pg(e,i));gg(n,r,e,t,e=>o.get(hg(e)))})}(e,o):e.namespaceURI===og&&"num"===l?function(e,t,n){ug(e,t);const o=dg(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of ag(t))a.namespaceURI===og&&"lvlOverride"===ig(a)&&r.set(sg(a,"ilvl")??"0",a);for(const a of ag(e)){const e=ig(a);if(a.namespaceURI!==og||"abstractNumId"!==e){if(a.namespaceURI===og&&"lvlOverride"===e){const e=sg(a,"ilvl")??"0",o=vg(a,bg(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===og||ag(t).some(e=>lg(e)===lg(a))||t.appendChild(a.cloneNode(!0))}else o&&(ug(a,o),pg(a,o))}}(e,o,r):pg(e,o));gg(a,t,e,r,e=>i.get(xg(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}async function Sg(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/numbering")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(rg);if(!n||!o)return!1;const r=await o.async("string"),a=wg(n,r);return a!==r&&(t.file(rg,a),!0)}var Cg=[{relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootLocalName:"footnotes"},{relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootLocalName:"endnotes"},{relationshipSuffix:"/comments",rebuiltPath:"word/comments.xml",rootLocalName:"comments"}];function Ig(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var Tg="http://schemas.openxmlformats.org/wordprocessingml/2006/main",kg=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function Pg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Rg(e){return e.localName??e.tagName}function Bg(e){return`${e.namespaceURI??""}\0${Rg(e)}`}function Ag(e){const t=[],n=e=>{for(const o of Pg(e))o.namespaceURI===Tg&&"sectPr"===Rg(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function Mg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function Fg(e){return e.namespaceURI===Tg&&kg.has(Rg(e))}function Og(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml"),o=(new au.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=Ag(n),l=Ag(o);return 0===i.length||i.length!==l.length?t:(Mg(r,a),i.forEach((e,t)=>{!function(e,t){Mg(e,t);const n=Pg(e),o=Pg(t),r=/* @__PURE__ */new Map;for(const i of o){const e=Bg(i),t=r.get(e);t?t.push(i):r.set(e,[i])}const a=/* @__PURE__ */new Map;for(let i=0;i<n.length;i+=1){const e=n[i],o=Bg(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){Mg(e,s);continue}if(Fg(e))continue;const c=n.slice(i+1).map(e=>r.get(Bg(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new au.XMLSerializer).serializeToString(o))}var Dg="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Eg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Lg(e){return e.localName??e.tagName}function Ng(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Dg&&Lg(n)===t?n:void 0}function $g(e){return Eg(e).length>0?(new au.XMLSerializer).serializeToString(e.ownerDocument):void 0}var zg=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),Hg=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Wg(e){const t=Ng(e,"settings");if(!t)return e;for(const n of[...Eg(t)]){if(n.namespaceURI!==Dg)continue;const e=Lg(n);if(zg.has(e)){t.removeChild(n);continue}const o=Hg.get(e);if(o){for(const e of[...Eg(n)])e.namespaceURI===Dg&&o.has(Lg(e))&&n.removeChild(e);0===Eg(n).length&&t.removeChild(n)}}return $g(t)}function Ug(e){const t=Ng(e,"styles");if(!t)return e;for(const n of[...Eg(t)])n.namespaceURI===Dg&&"style"===Lg(n)&&t.removeChild(n);return $g(t)}function jg(e){const t=Ng(e,"fonts");if(!t)return e;for(const n of[...Eg(t)])n.namespaceURI===Dg&&"font"===Lg(n)&&t.removeChild(n);return $g(t)}async function Vg(e,t,n){const o=e.file(t);if(!o)return!1;const r=await o.async("string"),a=n(r);return a!==r&&(void 0===a?e.remove(t):e.file(t,a),!0)}var Kg="word/styles.xml";function _g(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Xg(e){return e.localName??e.tagName}function Gg(e){return`${e.namespaceURI??""}\0${Xg(e)}`}function qg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Yg(e,t){return _g(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xg(e)===t)}function Zg(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Xg(e)?`${Gg(e)}\0${qg(e,"type")??""}`:Gg(e)}function Jg(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Xg(t)?t:void 0}function Qg(e,t){const n=Yg(e,"pPr");if(!n)return!1;const o=Yg(t,"pPr"),r=new au.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=rr(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Xg(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=_g(e),a=r.indexOf(n),i=_g(t),l=new Map(i.map(e=>[Zg(e),e])),s=r.slice(a+1).map(e=>l.get(Zg(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function ef(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(Kg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Jg(e),o=Jg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of _g(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xg(i))continue;const e=qg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of _g(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xg(i))continue;const e=qg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Qg(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Kg,a),!0)}function tf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function nf(e){return e.localName??e.tagName}function of(e){for(let t=0;t<e.attributes.length;t+=1){const n=e.attributes[t];if(n&&"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==n.namespaceURI&&"http://www.w3.org/2000/xmlns/"!==n.namespaceURI&&"xmlns"!==n.prefix&&"xmlns"!==n.name)return!0}return!1}function rf(e,t){const n=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===nf(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${ur}" xmlns:w14="${to}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};x(r,`<w:r xmlns:w="${ur}" xmlns:w14="${to}">${e}<w:t/></w:r>`);const a=function(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===nf(t)?t:void 0}(Br(r,o));if(!a)return t;let i=tf(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===nf(e));return!i&&of(n)&&(i=a.ownerDocument.createElementNS(ur,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(jn(n,i),0!==tf(i).length||of(i)?(new au.XMLSerializer).serializeToString(i):""):""}var af="word/styles.xml";function lf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function sf(e){return e.localName??e.tagName}function cf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function df(e,t){return lf(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&sf(e)===t)}function uf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===sf(t)?t:void 0}function pf(e,t){const n=df(e,"rPr");if(!n)return!1;const o=df(t,"rPr"),r=new au.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=rf(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===sf(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=lf(e),a=r.indexOf(n),i=lf(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&sf(t)===sf(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function gf(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(af);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=uf(e),o=uf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of lf(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==sf(i))continue;const e=cf(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of lf(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==sf(i))continue;const e=cf(i,"styleId"),t=e?r.get(e):void 0;t&&(a=pf(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(af,a),!0)}var ff="word/styles.xml",mf=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function hf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function bf(e){return e.localName??e.tagName}function yf(e){return`${e.namespaceURI??""}\0${bf(e)}`}function vf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function xf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function wf(e,t){return hf(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&bf(e)===t)}function Sf(e){return e?(new au.XMLSerializer).serializeToString(e):""}function Cf(e,t){if(!e)return;const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&bf(n)===t?n:void 0}function If(e,t,n){switch(e){case"pPr":return rr(t,n);case"rPr":return rf(t,n);case"tblPr":return $o(t,n);case"trPr":return Hr(t,n);case"tcPr":return Ln(t,n);default:return n}}function Tf(e,t,n,o){const r=hf(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&mf.has(bf(e)));return i?wf(t,bf(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===bf(e)&&mf.has(o)?hf(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===bf(e))??null:null}function kf(e,t,n){const o=wf(e,n);if(!o)return!1;const r=wf(t,n),a=Sf(r),i=If(n,Sf(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=Cf(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,Tf(e,t,o,n)),!0)}function Pf(e,t){xf(e,t);let n=!1;for(const r of mf)n=kf(e,t,r)||n;const o=new Set(hf(t).map(yf));for(const r of hf(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&mf.has(bf(r))||o.has(yf(r))||(t.appendChild(r.cloneNode(!0)),o.add(yf(r)),n=!0);return n}function Rf(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(ur,"w:tblStylePr");xf(e,n);let o=!1;for(const r of hf(e)){const e=bf(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&mf.has(e)){const t=Cf(If(e,Sf(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function Bf(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==bf(e))return;const t=vf(e,"type");return t?`tblStylePr:${t}`:void 0}function Af(e,t){let n=!1;n=kf(e,t,"tblPr")||n;const o=hf(e).filter(e=>void 0!==Bf(e)),r=/* @__PURE__ */new Map;for(const a of hf(t)){const e=Bf(a);e&&r.set(e,a)}for(const a of o){const o=Bf(a),i=r.get(o);if(i){n=Pf(a,i)||n;continue}const l=Rf(a);if(!l)continue;const s=hf(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==Bf(e)),u=d?r.get(Bf(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function Mf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===bf(t)?t:void 0}async function Ff(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(ff);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Mf(e),o=Mf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of hf(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===bf(i)){const e=vf(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of hf(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==bf(i))continue;if("table"!==vf(i,"type"))continue;const e=vf(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Af(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(ff,a),!0)}var Of="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Df(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Ef(e){return e.localName??e.tagName}function Lf(e){return`${e.namespaceURI??""}\0${Ef(e)}`}function Nf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function $f(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function zf(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=(new au.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===Of&&i.namespaceURI===Of&&Ef(a)===n&&Ef(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Hf(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}function Wf(e,t){const n=new Set(Df(t).map(Lf));for(const o of Df(e))o.namespaceURI===Of||n.has(Lf(o))||t.appendChild(o.cloneNode(!0))}var Uf=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var jf=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Vf(e){return e.namespaceURI===Of&&"tblStylePr"===Ef(e)?`${Lf(e)}\0${Nf(e,"type")??""}`:Lf(e)}function Kf(e){return e.namespaceURI===Of&&"style"===Ef(e)?`${Lf(e)}\0${Nf(e,"styleId")??""}`:Lf(e)}var _f=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function Xf(e){return e.namespaceURI===Of&&"font"===Ef(e)?`${Lf(e)}\0${Nf(e,"name")??""}`:Lf(e)}var Gf=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=zf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]),i=Df(o),l=new Map(Df(r).map(e=>[Lf(e),e]));return i.forEach((e,t)=>{const n=Lf(e),o=l.get(n),s=Ef(e),c=e.namespaceURI===Of?a.get(s):void 0;if(o)return $f(e,o),void(c?function(e,t,n){$f(e,t);const o=Df(t),r=new Map(o.map(e=>[Lf(e),e])),a=Df(e);a.forEach((e,o)=>{const i=Lf(e),l=r.get(i);if(l)return $f(e,l),void Wf(e,l);e.namespaceURI===Of&&n.has(Ef(e))||Hf(a,o,e,t,e=>r.get(Lf(e)))})}(e,o,c):Wf(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Df(e))r.namespaceURI===Of&&t.has(Ef(r))||(n.appendChild(r.cloneNode(!0)),o=!0);return o?n:void 0}(e,c);if(n){const e=i.slice(t+1).map(e=>l.get(Lf(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===Of&&Uf.has(s)||Hf(i,t,e,r,e=>l.get(Lf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=zf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=Df(o),i=new Map(Df(r).map(e=>[Kf(e),e]));return a.forEach((e,t)=>{const n=Kf(e),o=i.get(n);if(o)return $f(e,o),void(e.namespaceURI===Of&&"style"===Ef(e)?function(e,t){$f(e,t);const n=Df(e),o=new Map(Df(t).map(e=>[Vf(e),e]));n.forEach((e,r)=>{const a=Vf(e),i=o.get(a);if(i)return $f(e,i),void Wf(e,i);e.namespaceURI===Of&&jf.has(Ef(e))||Hf(n,r,e,t,e=>o.get(Vf(e)))})}(e,o):Wf(e,o));Hf(a,t,e,r,e=>i.get(Kf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=zf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=Df(o),i=new Map(Df(r).map(e=>[Xf(e),e]));return a.forEach((e,t)=>{const n=Xf(e),o=i.get(n);if(o)return $f(e,o),void(e.namespaceURI===Of&&"font"===Ef(e)&&function(e,t){$f(e,t);const n=Df(e),o=new Map(Df(t).map(e=>[Lf(e),e]));n.forEach((e,r)=>{const a=Lf(e),i=o.get(a);i?$f(e,i):e.namespaceURI===Of&&_f.has(Ef(e))||Hf(n,r,e,t,e=>o.get(Lf(e)))})}(e,o));Hf(a,t,e,r,e=>i.get(Xf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}}];function qf(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var Yf="word/document.xml";function Zf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS("*","sectPr");let n=0;for(let o=0;o<t.length;o+=1){const e=t.item(o),r=e?.parentNode;e&&"sectPrChange"!==r?.localName&&(n+=1)}return n}async function Jf(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return wp(e,t);const r=await ru.default.loadAsync(t),a=Boolean(r.file("word/numbering.xml")),i={settings:Boolean(r.file("word/settings.xml")),styles:Boolean(r.file("word/styles.xml")),fontTable:Boolean(r.file("word/fontTable.xml"))};let l=await async function(e,t){let n=!1;for(const o of Gf){const r=qf(e,o.relationshipSuffix);if(!r)continue;const a=t.file(o.rebuiltPath);if(!a){t.file(o.rebuiltPath,r),n=!0;continue}if(!o.merge)continue;const i=await a.async("string"),l=o.merge(r,i);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r);a&&(l=await Sg(n,r)||l),i.styles&&(l=await ef(n,r)||l,l=await gf(n,r)||l,l=await Ff(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await Vg(e,"word/settings.xml",Wg)||n),t.styles||(n=await Vg(e,"word/styles.xml",Ug)||n),t.fontTable||(n=await Vg(e,"word/fontTable.xml",jg)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of Cg){const r=Ig(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=$u(r,i,o.rootLocalName);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r)||l,l=await async function(e,t,n){let o=!1;for(const r of jp){const a=Yp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=ng(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await bu(n,r)||l,l=await async function(e,t){const n=Tu(e,"/comments"),o=Tu(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(vu);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=Bu(n,o,i,l);return s!==l&&(t.file(vu,s),!0)}(n,r)||l,l=await rp(n,r)||l,l=await Zu(n,r)||l;const s=await(r.file(Yf)?.async("string"));if(!s||Zf(o.data)!==Zf(s)){return wp(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=Og(o.data,s);c!==s&&(r.file(Yf,c),l=!0);return Up(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function Qf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function em(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return t&&(t.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/customXml","itemID")??t.getAttribute("ds:itemID")??t.getAttribute("itemID"))?.trim()||null}function tm(e){const t=/^(([^:[]+):)?([^[]+?)(?:\[(\d+)\])?$/.exec(e);if(!t)return null;const n=t[4]?Number.parseInt(t[4],10):1;return!Number.isFinite(n)||n<1?null:{...t[2]?{prefix:t[2]}:{},localName:t[3],index:n}}function nm(e,t,n,o){if(e.localName!==n)return!1;if(!t)return!e.namespaceURI;const r=o.get(t);return void 0!==r&&e.namespaceURI===r}function om(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function rm(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=Qf(t);for(const o of Object.values(e.parts)){if("xml"!==o.kind||!/^customXml\/item\d+\.xml$/i.test(o.path))continue;const t=(o.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/customXmlProps")&&e.resolvedTarget))?.resolvedTarget;if(!t)continue;const r=e.parts[t];if(!r||"xml"!==r.kind)continue;const a=em(r.data);if(a&&Qf(a)===n)return{storeItemId:a,itemPartPath:o.path,itemPropsPartPath:t,xml:o.data}}return null}(e,t.storeItemID);if(!o)return!1;const r=function(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=o.documentElement;if(!r)return null;const a=t.trim().replace(/\/text\(\)$/,"");if(!a.startsWith("/")||a.startsWith("//"))return null;const i=a.split("/").filter(Boolean);if(0===i.length)return null;const l=i.at(-1)?.startsWith("@")?i.pop():null,s=tm(i[0]);if(!s||1!==s.index)return null;if(!nm(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=tm(i[m]);if(!e)return null;const t=om(c).filter(t=>nm(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!l)return{document:o,element:c};const d=l.slice(1),u=d.indexOf(":");if(u<0)return{document:o,element:c,attribute:{localName:d,qualifiedName:d}};const p=d.slice(0,u),g=d.slice(u+1),f=n.get(p);return f?{document:o,element:c,attribute:{namespaceUri:f,localName:g,qualifiedName:`${p}:${g}`}}:null}(o.xml,t.xpath,function(e){const t=/* @__PURE__ */new Map;if(!e)return t;for(const n of e.matchAll(/xmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])(.*?)\2/g))t.set(n[1],n[3]);return t}(t.prefixMappings));if(!r)return!1;if(r.attribute)r.attribute.namespaceUri?r.element.setAttributeNS(r.attribute.namespaceUri,r.attribute.qualifiedName,n):r.element.setAttribute(r.attribute.localName,n);else{if(om(r.element).length>0)return!1;for(;r.element.firstChild;)r.element.removeChild(r.element.firstChild);r.element.appendChild(r.document.createTextNode(n))}const a=e.parts[o.itemPartPath];return!!a&&(a.data=(new au.XMLSerializer).serializeToString(r.document),!0)}function am(e,t,n,o){if(!t.sdtPr.dataBinding)return;const r=e.get(t.groupId);r?r.value+=`${o}${n}`:e.set(t.groupId,{wrapper:t,value:n})}function im(e){return e.blocks.map(sm).filter(Boolean).join("\n")}function lm(e){return e.cells.map(im).filter(Boolean).join("\t")}function sm(e){return"paragraph"===e.type?Lt(e):e.rows.map(lm).filter(Boolean).join("\n")}function cm(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])am(t,e,n.text,"");"textBox"===n.kind&&um(n.textBox.blocks,t)}}function dm(e,t){for(const n of e.rows){const e=lm(n);for(const o of n.sdtWrappers??[])am(t,o,e,"\n");for(const o of n.cells){const e=im(o);for(const n of o.sdtWrappers??[])am(t,n,e,"\n");um(o.blocks,t)}}}function um(e,t){if(e)for(const n of e){const e=sm(n);for(const o of n.sdtWrappers??[])am(t,o,e,"\n");"paragraph"===n.type?cm(n,t):dm(n,t)}}async function pm(e){if(!e.sourcePackage)return ne(e);const t={...e,sourcePackage:(n=e.sourcePackage,{...n,contentTypes:{defaults:{...n.contentTypes.defaults},overrides:{...n.contentTypes.overrides}},rootRelationships:n.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(n.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...n.diagnostics?{diagnostics:n.diagnostics.map(e=>({...e}))}:{},...n.rebuiltPartHashes?{rebuiltPartHashes:{...n.rebuiltPartHashes}}:{}})};var n;!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of $e(e))um(o.blocks,t),um(o.header,t),um(o.firstPageHeader,t),um(o.evenPageHeader,t),um(o.footer,t),um(o.firstPageFooter,t),um(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&rm(e.sourcePackage,t,r)&&(n+=1)}}(t);return Jf(t,await ne(t))}async function gm(e){if(!e.sourcePackage)return Dt(e);const t=await pm(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function fm(e){switch(e){case"dashed":return[tn(5),tn(3)];case"dotted":return[tn(1),tn(3)];default:return}}async function mm(e,t,n,o,r,a,i,l){const s=t.rotation;s&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,tn(o+a/2),tn(r+i/2),s)),function(e,t,n,o,r,a,i){const l=at(n.shape?.preset,tn(o),tn(r),tn(a),tn(i)),s=n.shape?.fill,c=n.shape?.borderColor,d=n.shape?.borderWidthPt??(c?.75:0);e.drawPath(t,{segments:l,fill:s,stroke:c&&d>0?c:void 0,lineWidth:d})}(e,n.pageIndex,t,o,r,a,i),await async function(e,t,n,o,r,a,i,l){if(0===t.blocks.length)return;const s=function(e){return{left:e.body?.paddingLeft??0,top:e.body?.paddingTop??0,right:e.body?.paddingRight??0,bottom:e.body?.paddingBottom??0}}(t),c=o+s.left,d=r+s.top,u=Math.max(1,a-s.left-s.right),p=Math.max(1,i-s.top-s.bottom),g=$n({blocks:t.blocks,pageSettings:{width:u,height:p,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:p,styles:n.document.styles,pageOffset:n.pageIndex})[0]?.blocks??[];if(0===g.length)return;const f=mt(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,tn(c),tn(d),tn(u),tn(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await l.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,l);break;case"table":await l.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,l);break;default:Zo(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,o,r,a,i,l),s&&e.restoreGraphicsState(n.pageIndex)}async function hm(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const p of a){const a=new Map(p.slots.map(e=>[e.offset,e]));for(const g of p.fragments){const f=g.textBox;if(!f?.floating)continue;const m=Boolean(f.floating.behindDoc);if(e.layer&&"behind"===e.layer!==m)continue;const h=l+(a.get(g.startOffset)?.left??0),b=d+p.top,y=oo({object:Kn(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await mm(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var bm=/* @__PURE__ */new WeakMap;function ym(e){const t=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(e);if(!t)return null;const n=t[1].toLowerCase(),o=Boolean(t[2]),r=t[3]??"";if(!o)return{mediaType:n,data:(new TextEncoder).encode(decodeURIComponent(r))};const a="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:n,data:Uint8Array.from(a,e=>e.charCodeAt(0))}}async function vm(e,t,n){let o=e;o.startsWith("data:")||(o=await async function(e){if("function"!=typeof fetch)return null;const t=await fetch(e);if(!t.ok)return null;const n=await t.blob(),o=new Uint8Array(await n.arrayBuffer()),r=Array.from(o,e=>String.fromCharCode(e)).join(""),a="function"==typeof btoa?btoa(r):Buffer.from(o).toString("base64");return`data:${n.type||"application/octet-stream"};base64,${a}`}(o)??o);let r=ym(o);if(!r)return null;const a="undefined"!=typeof Image?await async function(e){return"undefined"==typeof Image?null:await new Promise(t=>{const n=new Image;n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}(o):null,i=null!=a&&a.naturalWidth>0&&a.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const e=function(e){if("undefined"==typeof document)return null;const t=document.createElement("canvas");t.width=e.naturalWidth,t.height=e.naturalHeight;const n=t.getContext("2d");return n?(n.fillStyle="#ffffff",n.fillRect(0,0,t.width,t.height),n.drawImage(e,0,0),t.toDataURL("image/jpeg",.92)):null}(a);if(r=e?ym(e):null,!r)return null}const l=i?a.naturalWidth:t,s=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function xm(e,t,n){const o=Ze(t,n.src);if(!o)return null;let r=bm.get(e);r||(r=/* @__PURE__ */new Map,bm.set(e,r));const a=r.get(o);if(a)return a;const i=vm(o,n.width,n.height).then(t=>t?e.registerImageResource({width:t.width,height:t.height,data:t.data,filter:"DCTDecode"}):null);return r.set(o,i),i}async function wm(e,t,n,o,r,a,i,l){const s=await xm(e,n,o);if(!s)return;const c=o.intrinsicWidth??o.width,d=o.intrinsicHeight??o.height,u=c/Math.max(1,d),p=i/Math.max(1,l);let g=r,f=a,m=i,h=l;"fit"===o.cropFit&&u>0&&(u>p?(h=i/u,f+=(l-h)/2):(m=l*u,g+=(i-m)/2));const b="fill"!==o.cropFit||o.crop?o.crop:(()=>{if(u>p){const e=p/u,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(u<p){const e=u/p,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),y=o.cropShape?.preset,v=y?function(e,t,n,o,r,a){if(!a)return e;const i=t+o/2,l=n+r/2,s=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(s)-(t-l)*Math.sin(s),y:l+(e-i)*Math.sin(s)+(t-l)*Math.cos(s)});return e.map(e=>{if("close"===e.type)return e;if("cubic"===e.type){const t=c(e.x1,e.y1),n=c(e.x2,e.y2),o=c(e.x,e.y);return{type:"cubic",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:o.x,y:o.y}}const t=c(e.x,e.y);return{type:e.type,x:t.x,y:t.y}})}(at(y,r,a,i,l),r,a,i,l,o.rotation??0):null,x=o.transparency??0,w="fit"===o.cropFit&&Boolean(o.rotation);v&&(e.saveGraphicsState(t),e.clipPath(t,v)),w&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,o.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:s,x:g,y:f,width:m,height:h,rotation:w?void 0:o.rotation,crop:b}),x>0&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t),v&&e.restoreGraphicsState(t);const S=o.border;if(!S)return;const C=o.rotation;C&&!v&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,C));const I=Xn(S.dash);v?e.drawPath(t,{segments:v,stroke:S.color,lineWidth:S.widthPt??1}):e.drawRect(t,{x:r,y:a,width:i,height:l,stroke:S.color,lineWidth:S.widthPt??1,...I.length>0?{dashArray:I}:{}}),C&&!v&&e.restoreGraphicsState(t)}function Sm(e,t){const n=new Map(e.slots.map(e=>[e.offset,e])),o=[];for(const r of t.chars){if("\n"===r.char||"\t"===r.char)continue;const e=n.get(r.paragraphOffset);e&&o.push({char:r.char,left:e.left,offset:r.paragraphOffset})}return o}function Cm(e,t,n){const o=Sm(e,t);if(0===o.length)return null;const r=new Map(e.slots.map(e=>[e.offset,e])),a=o[0],i=o[o.length-1],l=r.get(i.offset+1);return{left:a.left,right:l?.left??i.left+.55*n}}function Im(e,t,n,o,r,a,i){const l=Cm(e,t,n.fontSize??14.6667);return l?{x:tn(o+l.left),y:tn(r+e.top+a),width:tn(Math.max(0,l.right-l.left)),height:tn(Math.max(2,e.height-i))}:null}function Tm(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=Cm(n,o,i.fontSize??14.6667);if(!s)return;const c=r+s.left,d=r+s.right,u=a+n.top,p=a+n.top+n.height,g=rn(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:tn(g.x0),y0:tn(g.y0),x1:tn(g.x1),y1:tn(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function km(e,t,n,o,r,a,i){const l=Vt(i),s=(r,i)=>{e.drawLine(t,{x1:tn(n),y1:tn(r),x2:tn(o),y2:tn(r),stroke:a,lineWidth:tn(l),dashArray:i})};if(p(i))return s(r-yr),void s(r+yr);Nt(i)?function(e,t,n,o,r,a,i){let l=n,s=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*xa;e.drawLine(t,{x1:tn(l),y1:tn(s),x2:tn(c),y2:tn(o),stroke:a,lineWidth:tn(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,At(i))}function Pm(e,t){const n=or(Sn(e));if(!n)return e;const o=Math.max(0,Math.min(1,t));return Rr(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function Rm(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=tn(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:tn(t)+u*e,y:tn(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*tn(e.radiusPt*Nn),l=Pm(e.color,.4*(e.alpha??.5)),s=[[i,0],[-i,0],[0,i],[0,-i],[.7*i,.7*i],[.7*-i,.7*i],[.7*i,.7*-i],[.7*-i,.7*-i]];for(const[c,u]of s)o.drawText(r,{...d,x:tn(t)+c,y:tn(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=tn(e.distPt*Nn);o.drawText(r,{...d,x:tn(t)+Math.cos(i)*l,y:tn(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:tn(t)+u,y:tn(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=Pm(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:tn(t),y:tn(a)+tn(e.distPt*Nn)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:tn(t),y:tn(a),text:n,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function Bm(e){for(const t of e.lines){const n=new Map(t.slots.map(e=>[e.offset,e]));for(const o of t.fragments){const r=o.image;if(!r?.floating)continue;const a=Boolean(r.floating.behindDoc);if("behind"===e.layer!==a)continue;const i=n.get(o.startOffset),l=oo({object:Ur(r),pageSettings:e.pageSettings,contentLeft:e.contentLeft,contentTop:e.contentTop,contentWidth:e.contentWidth,paragraphTop:e.paragraphTop,lineTop:e.paragraphTop+t.top,anchorLeft:e.contentLeft+(i?.left??0)});await wm(e.writer,e.pageIndex,e.document,r,tn(l.x),tn(l.y),tn(l.width),tn(l.height))}}}function Am(e,t,n,o,r,a,i,l){const s=Cm(n,o,i.fontSize??14.6667);if(!s)return;const c=a+ge(l,n.top,n.height),d=r+s.left,u=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(e.drawLine(t,{x1:tn(d),y1:tn(c-xe),x2:tn(u),y2:tn(c-xe),stroke:p,lineWidth:tn(1)}),void e.drawLine(t,{x1:tn(d),y1:tn(c+xe),x2:tn(u),y2:tn(c+xe),stroke:p,lineWidth:tn(1)})):void km(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:tn(d),y1:tn(c),x2:tn(u),y2:tn(c),stroke:p,lineWidth:tn(1)})}async function Mm(e,t,n,o,r,a,i,l,s,c){if(r.image){if(r.image.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await wm(e,t,a,r.image,tn(i+n.left),tn(l+o.top+o.height-r.image.height),tn(r.image.width),tn(r.image.height)))}if(r.textBox){if(r.textBox.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await mm(e,r.textBox,{document:a,fontRegistry:s,pageIndex:t},i+n.left,l+o.top+o.height-r.textBox.height,r.textBox.width,r.textBox.height,c))}if(r.math){const c=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!c)return;const d=Te(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:tn(i+c.left),y:tn(l+o.top+o.height*Ue),text:na(r.math),fontSize:qt(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=Te(r.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=s.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=qt(d),g=(d.baselineShift??0)*Nn,f=re(n.style,a.styles),m=W(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*Ue-g+m,b=Sm(o,r),y=b.map(e=>qe(e.char,d)).join("");if(!b[0]||0===y.length)return;!function(e,t,n,o,r,a,i){if(!i.link)return;const l=Cm(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:tn(r+l.left),y:tn(a+n.top),width:tn(l.right-l.left),height:tn(n.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.shading)return;const l=Im(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.shading})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.highlight)return;const l=Im(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.highlight})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=Im(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:tn(Math.max(.5,l.width*Nn))})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i,l,s){const c=new Map(o.slots.map(e=>[e.offset,e])),d=re(n.style,a.styles).tabs??[];for(const u of r.chars){if("\t"!==u.char)continue;const n=c.get(u.paragraphOffset),r=c.get(u.paragraphOffset+1);if(!n||!r)continue;const a=o.slots[0]?.left??0,p=n.left-a,g=d.filter(e=>"clear"!==e.type).map(e=>({...e,positionPx:e.position*Nn})).filter(e=>e.positionPx>p+.01).sort((e,t)=>e.positionPx-t.positionPx)[0],f=g?.leader&&"none"!==g.leader?g.leader:void 0;if(!f)continue;const m="underscore"===f?l+2:l;e.drawLine(t,{x1:tn(i+n.left),y1:tn(m),x2:tn(i+r.left),y2:tn(m),stroke:s,lineWidth:tn("heavy"===f?1.5:1),dashArray:"dot"===f||"middleDot"===f?[1,3]:"hyphen"===f?[5,3]:void 0})}}(e,t,n,o,r,a,i,h,d.color??"#000000");const v=re(n.style,a.styles).align??"left",x=J(d,qt(d)),w={fontSize:p,bold:d.bold,italic:d.italic,fontResourceName:u.writerResourceName,characterSpacing:d.characterSpacing??0,horizontalScale:d.characterScale??100,fontFeatures:x};!function(e,t,n,o,r,a,i){const l="justify"===i?function(e){const t=[];let n=[];for(const o of e)" "!==o.char?n.push(o):n.length>0&&(t.push(n),n=[]);return n.length>0&&t.push(n),t}(t):function(e){const t=[];let n=[];for(const o of e){const e=n[n.length-1];e&&o.offset>e.offset+1&&(t.push(n),n=[]),n.push(o)}return n.length>0&&t.push(n),t}(t);for(const s of l){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>qe(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;Rm({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&B(e.char));t.length>0&&n!==r&&a(),r=n,t.push(e)}a()}if(r.trailingHyphen&&a.endOffset>=r.endOffset){const t=r.slots.find(e=>e.offset===r.endOffset)??r.slots[r.slots.length-1];t&&Rm(e,n+t.left,"-")}}({writer:e,pageIndex:t,baselineY:h,fontSizePt:p,mainColor:"solid"===d.textFill?.type?d.textFill.color:"gradient"===d.textFill?.type&&d.textFill.stops[0]?d.textFill.stops[0].color:d.color??"#000000",gradientShadingName:Tm(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&Am(e,t,o,r,i,l,d,"underline"),d.strike&&Am(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&Am(e,t,o,r,i,l,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,o,r,a,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=dt[l];if(!s)return;const c=Sm(n,o),d="underDot"===l,u=Math.max(4,.35*n.height),p=d?a+n.top+n.height+u:a+n.top+u;for(let g=0;g<c.length;g+=1){const o=c[g];if(" "===o.char||"\t"===o.char||"\n"===o.char)continue;const a=c[g+1],l=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:tn(r+l-.25*u),y:tn(p),text:s,fontSize:tn(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function Fm(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=y(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=Te(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=S(n,r.styles),f=qt(u),m=c.length*f*.62*Nn,h=vt(n,r.styles,d.left,m);e.drawText(t,{x:tn(a+Math.max(0,h||g)),y:tn(i+o.top+o.height*Ue),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Om(e,t,n,o,r,a,i){const l=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],s=l.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!s)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=se(n),u=d.top+c+d.bottom,p=r+(n.indentLeft??0),g=r+i-(n.indentRight??0),f=a+u;n.shading&&e.drawRect(t,{x:tn(p),y:tn(a),width:tn(Math.max(0,g-p)),height:tn(u),fill:n.shading});for(const[h,b]of l){if(!h||"none"===h.type||h.width<=0)continue;const[n,o,r,i]="top"===b?[p,a,g,a]:"bottom"===b?[p,f,g,f]:"left"===b?[p,a,p,f]:[g,a,g,f];e.drawLine(t,{x1:tn(n),y1:tn(o),x2:tn(r),y2:tn(i),stroke:h.color,lineWidth:h.width,dashArray:fm(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:tn(p),y1:tn(a),x2:tn(p),y2:tn(f),stroke:m.color,lineWidth:m.width,dashArray:fm(m.type)})}async function Dm(e,t,n,o,r,a,i,l,s,c){for(const d of o){Fm(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await Mm(e,t,n,d,o,r,a,i,l,c)}}function Em(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:tn(o),y1:tn(r),x2:tn(a),y2:tn(i),stroke:n.color,lineWidth:tn(n.width),dashArray:fm(n.type)})}function Lm(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;Em(e,t,n.borders.top,a,i,l,i),Em(e,t,n.borders.right,l,i,l,s),Em(e,t,n.borders.bottom,a,s,l,s),Em(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&Em(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&Em(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function Nm(e,t,o,r,a,i,l,s,c,d){if("table"!==o.sourceBlock.type)return;const u=o.sourceBlock,p=o.tableSegment?me(u,o.tableSegment):u;if(0===p.rows.length)return;const g=n({table:p,state:{document:r},pageIndex:0,originX:0,originY:0,contentWidth:l,estimatedHeight:o.estimatedHeight});for(const n of g.cells)n.shading&&e.drawRect(t,{x:tn(a+n.left),y:tn(i+n.top),width:tn(n.width),height:tn(n.height),fill:n.shading});for(const n of g.cells)if(Lm(e,t,n,a,i),n.revision){const o="insert"===n.revision.type?"#059669":"delete"===n.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:tn(a+n.left+1),y:tn(i+n.top+1),width:tn(Math.max(0,n.width-2)),height:tn(Math.max(0,n.height-2)),stroke:o,lineWidth:tn(2)})}for(const n of g.cells)for(const o of n.paragraphs)await Dm(e,t,o.paragraph,o.lines,r,a+o.originX,i+o.originY,s,c,d)}var $m={drawParagraph:Dm,drawTableBlock:Nm};async function zm(e,t,n,o,r,a,i,l,s,c,d){if(!n||0===n.length)return;const u=a;let p=a;for(let g=0;g<n.length;g+=1){const f=n[g];switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const n=re(f.sourceBlock.style,o.styles),g=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0);d?.(f.sourceBlock.id,g);const m=g+se(n).top;Om(e,t,n,f.layout.lines,r,g,i),c&&(await Bm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await hm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:$m,layer:"behind"})),await Dm(e,t,f.sourceBlock,f.layout.lines,o,r,m,l,s,$m),c&&(await Bm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await hm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:$m,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Yn(f.sourceBlock,i),a=gr({floating:f.sourceBlock.style.floating,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,anchorTop:p,width:n,height:f.floatingTableHeight??1,pageIndex:t});a.y+=f.floatingTableOffsetY??0,await Nm(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,l,s,$m);break}await Nm(e,t,f,o,r,p,i,l,s,$m);break;default:Zo(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const l=n[g+1];if("paragraph"===l?.sourceBlock.type&&l.layout&&l.sourceBlock.id!==f.sourceBlock.id){const n=re(f.sourceBlock.style,o.styles),s=re(l.sourceBlock.style,o.styles);if(Be(n,s)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+se(n).top;let l=0;for(const e of f.layout.lines)l=Math.max(l,e.top+e.height);const s=o+l,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:tn(c),y1:tn(s),x2:tn(d),y2:tn(s),stroke:u.color,lineWidth:u.width,dashArray:fm(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function Hm(e,t,n,o,r,a,i){if(e.drawRect(t,{x:0,y:0,width:n,height:o,fill:r?.pageColor||"#ffffff"}),a){const r=a.distance??12,i="dashed"===a.style?[6,4]:"dotted"===a.style?[1,3]:void 0;if(e.drawRect(t,{x:r,y:r,width:n-2*r,height:o-2*r,fill:void 0,stroke:a.color,lineWidth:a.width,...i?{dashArray:i}:{}}),"double"===a.style){const i=r+2*a.width;e.drawRect(t,{x:i,y:i,width:n-2*i,height:o-2*i,stroke:a.color,lineWidth:a.width})}}const l=r?.watermark;if("text"===l?.kind&&l.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:l.text,fontSize:l.fontSize??48,color:l.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===l?.kind&&l.src&&i){const r={src:l.src,width:360,height:180},a=await xm(e,i,r);if(a){const i=l.scale??1,s=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-s)/2,y:(o-c)/2,width:s,height:c}),e.restoreGraphicsState(t)}}}var Wm=[{key:"helvetica:regular",family:"Helvetica",bold:!1,italic:!1,writerResourceName:"F1",pdfResource:{kind:"base14",resourceName:"F1",baseFont:"Helvetica"}},{key:"helvetica:bold",family:"Helvetica",bold:!0,italic:!1,writerResourceName:"F2",pdfResource:{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"}},{key:"helvetica:italic",family:"Helvetica",bold:!1,italic:!0,writerResourceName:"F3",pdfResource:{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"}},{key:"helvetica:bolditalic",family:"Helvetica",bold:!0,italic:!0,writerResourceName:"F4",pdfResource:{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}}];function Um(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function jm(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Vm=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Wm)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Um(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=Xt(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(Um(t,n,o))??this.faces.get(Um(this.fallbackFamily,n,o))??this.faces.get(Um(this.fallbackFamily,!1,!1))}getPdfFontResources(){const e=/* @__PURE__ */new Map;for(const t of this.faces.values())e.set(t.pdfResource.resourceName,t.pdfResource);return Array.from(e.values())}async loadBundledUnicodeFaces(e={}){const t=e.families?new Set(Array.from(e.families).map(Xt).map(e=>e.toLowerCase())):null,n=await this.registerOfficeCompatibleFaces(t);if(!t||t.has("roboto")||Array.from(t).some(e=>"helvetica"!==e&&!n.has(e)))for(const[o,r]of Object.entries(te)){const e=await Ot(r);if(!e)continue;const t="bold"===o||"bolditalic"===o,n="italic"===o||"bolditalic"===o,a=`Roboto${o[0].toUpperCase()}${o.slice(1)}`;this.registerFontFace({key:`roboto:${o}`,family:"Roboto",bold:t,italic:n,writerResourceName:a,pdfResource:{kind:"unicode",resourceName:a,family:"Roboto",fontData:e}}),this.fallbackFamily="Roboto"}}async loadRemoteWebFontFaces(e={}){if(!e.families)return;const t=await Eo(e.families);for(const n of t){const e=`Remote${jm(n.postscriptName||n.family)}`;this.registerFontFace({key:Um(n.family,n.bold,n.italic),family:n.family,bold:n.bold,italic:n.italic,writerResourceName:e,pdfResource:{kind:"unicode",resourceName:e,family:n.family,fontData:n.fontData,postscriptName:n.postscriptName}})}}async registerOfficeCompatibleFaces(e){const t=/* @__PURE__ */new Set;for(const n of Ht){const o=[n.family,...n.aliases].map(e=>e.toLowerCase());if(e&&!o.some(t=>e.has(t)))continue;for(const e of o)t.add(e);const r=[];for(const[e,t]of Object.entries(n.files)){const o=await Ot(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${jm(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,s={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:n.family,fontData:o}};this.registerFontFace(s),r.push(s)}for(const e of n.aliases)for(const t of r)this.registerFontFace({...t,key:`${e.toLowerCase()}:${t.key.split(":")[1]}`,family:e})}return t}},Km="%PDF-1.4\n% Oasis PDF\n",_m=[{kind:"base14",resourceName:"F1",baseFont:"Helvetica"},{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"},{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"},{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}];function Xm(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function Gm(e){return(new TextEncoder).encode(e).byteLength}function qm(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function Ym(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Zm(e,t){if(!e)return t;const n=or(Sn(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Jm(e,t,n){const[o,r,a]=Zm(e,n);return`${Xm(o)} ${Xm(r)} ${Xm(a)} ${t}`}function Qm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var eh=/* @__PURE__ */new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]);function th(e){return Array.from(e).map(e=>function(e){const t=e.codePointAt(0)??63;return t>=32&&t<=126||t>=160&&t<=255?t:eh.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function nh(e){const t=[];for(let n of e)n>65535?(n-=65536,t.push(n>>>10&1023|55296),t.push(1023&n|56320)):t.push(n);return t.map(Ym).join("")}function oh(e){return Ym(e)}function rh(e){return`% OasisText ${nh(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function ah(e){return e&&0!==e.length?`[${e.map(e=>Xm(e)).join(" ")}] 0 d`:null}var ih=class{page;fonts;images;shadings;constructor(e,t,n,o){this.page=e,this.fonts=t,this.images=n,this.shadings=o}registerAxialGradient(e){const t=this.shadings.register({x0:e.x0,y0:this.page.height-e.y0,x1:e.x1,y1:this.page.height-e.y1,stops:e.stops});return this.page.shadingResourceNames.add(t),t}drawRect(e){const t=this.page;if(e.width<=0||e.height<=0)return;const n=["q"];if(e.fill&&n.push(Jm(e.fill,"rg",[1,1,1])),e.stroke){n.push(Jm(e.stroke,"RG",[0,0,0])),n.push(`${Xm(e.lineWidth??1)} w`);const t=ah(e.dashArray);t&&n.push(t)}n.push([Xm(e.x),Xm(t.height-e.y-e.height),Xm(e.width),Xm(e.height),"re"].join(" ")),e.fill&&e.stroke?n.push("B"):e.fill?n.push("f"):e.stroke&&n.push("S"),n.push("Q"),t.commands.push(n.join("\n"))}drawLine(e){const t=this.page,n=ah(e.dashArray),o=["q",Jm(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${Xm(e.lineWidth??1)} w`,`${Xm(e.x1)} ${Xm(t.height-e.y1)} m`,`${Xm(e.x2)} ${Xm(t.height-e.y2)} l`,"S","Q"),t.commands.push(o.join("\n"))}drawPath(e){const t=this.page;if(0===e.segments.length)return;if(!e.fill&&!e.stroke)return;const n=e=>t.height-e,o=["q"];e.fill&&o.push(Jm(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(Jm(e.stroke,"RG",[0,0,0])),o.push(`${Xm(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${Xm(r.x)} ${Xm(n(r.y))} m`);break;case"line":o.push(`${Xm(r.x)} ${Xm(n(r.y))} l`);break;case"cubic":o.push(`${Xm(r.x1)} ${Xm(n(r.y1))} ${Xm(r.x2)} ${Xm(n(r.y2))} ${Xm(r.x)} ${Xm(n(r.y))} c`);break;case"close":o.push("h")}e.fill&&e.stroke?o.push("B"):e.fill?o.push("f"):o.push("S"),o.push("Q"),t.commands.push(o.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}setOpacity(e){const t=Math.max(0,Math.min(1,e)),n=`GSOpacity${Math.round(100*t)}`;(this.page.graphicsStateOpacities??=/* @__PURE__ */new Map).set(n,t),this.page.commands.push(`/${n} gs`)}rotateAbout(e,t,n){const o=this.page;if(!n)return;const r=o.height-t,a=-n*Math.PI/180,i=Math.cos(a),l=Math.sin(a),s=e-e*i+r*l,c=r-e*l-r*i;o.commands.push(`${Xm(i)} ${Xm(l)} ${Xm(-l)} ${Xm(i)} ${Xm(s)} ${Xm(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${Xm(e)} ${Xm(r.height-t-o)} ${Xm(n)} ${Xm(o)} re`,"W","n")}clipPath(e){const t=this.page;if(0===e.length)return;const n=e=>t.height-e,o=[];for(const r of e)switch(r.type){case"move":o.push(`${Xm(r.x)} ${Xm(n(r.y))} m`);break;case"line":o.push(`${Xm(r.x)} ${Xm(n(r.y))} l`);break;case"cubic":o.push(`${Xm(r.x1)} ${Xm(n(r.y1))} ${Xm(r.x2)} ${Xm(n(r.y2))} ${Xm(r.x)} ${Xm(n(r.y))} c`);break;case"close":o.push("h")}o.push("W","n"),t.commands.push(o.join("\n"))}drawText(e){if(0===e.text.length)return;const t=this.fonts.resolveAndMarkFontName(e),n=this.fonts.getUnicodeState(t),o=n?this.fonts.buildUnicodeShowCommand(n,e.text,e.fontFeatures):`<${th(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${Xm(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Xm(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Xm(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([rh(n.text),"BT",Jm(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Jm(n.strokeColor??n.color,"RG",[0,0,0]),`${Xm(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Xm(n.x)} ${Xm(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([rh(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Xm(n.x)} ${Xm(r.height-n.y)} Td`,t,"ET",`/${o} sh`,"Q"].join("\n"))}drawImage(e){const t=this.page;if(e.width<=0||e.height<=0||!this.images.has(e.resourceName))return;t.imageResourceNames.add(e.resourceName);const n=t.height-e.y-e.height,o=Number.isFinite(e.rotation)?e.rotation??0:0,r=e.crop,a=r?.left??0,i=r?.top??0,l=r?.right??0,s=r?.bottom??0;if(r&&(a>0||i>0||l>0||s>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:l,bottom:s});if(0===o)return void t.commands.push(["q",[Xm(e.width),"0","0",Xm(e.height),Xm(e.x),Xm(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const c=-o*Math.PI/180,d=Math.cos(c),u=Math.sin(c),p=e.width*d,g=e.width*u,f=-e.height*u,m=e.height*d,h=e.x+e.width/2-.5*p-.5*f,b=n+e.height/2-.5*g-.5*m;t.commands.push(["q",[Xm(p),Xm(g),Xm(f),Xm(m),Xm(h),Xm(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,l=a/Math.max(1e-4,1-o.left-o.right),s=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*l,d=-o.bottom*s,u=-n*Math.PI/180,p=Math.cos(u),g=Math.sin(u),f=a/2,m=i/2,h=p,b=g,y=-g,v=p,x=e.x+a/2-(h*f+y*m),w=t+i/2-(b*f+v*m);r.commands.push(["q",[Xm(h),Xm(b),Xm(y),Xm(v),Xm(x),Xm(w),"cm"].join(" "),`0 0 ${Xm(a)} ${Xm(i)} re W n`,[Xm(l),"0","0",Xm(s),Xm(c),Xm(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function lh(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function sh(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function ch(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function dh(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=/* @__PURE__ */new Map;for(let o=0;o<t;o+=1)n.set(e.u16(),o);return e=>n.get(e)??-1}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,startIndex:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.startIndex+(e-t.start);return-1}}return()=>-1}function uh(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=sh(e,n);return e=>{const r=e-t;return r>=0&&r<n?o[r]:0}}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,classValue:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.classValue;return 0}}return()=>0}function ph(e){e.seek(0),e.skip(2),e.skip(2);const t=e.u16(),n=e.u16(),o=e.u16(),r=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let r=0;r<n;r+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}return o.map(({tag:t,offset:n})=>(e.seek(n),e.skip(2),{tag:t,lookupIndices:sh(e,e.u16())}))}(e,n),a=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let c=0;c<n;c+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}if(0===o.length)return[];const r=o.find(e=>"latn"===e.tag)??o.find(e=>"DFLT"===e.tag)??o[0];e.seek(r.offset);const a=e.u16();if(0===a)return[];e.seek(r.offset+a),e.skip(2);const i=e.u16(),l=e.u16(),s=[];65535!==i&&s.push(i);for(let c=0;c<l;c+=1)s.push(e.u16());return s}(e,t),i=/* @__PURE__ */new Map;for(const l of a){const e=r[l];if(!e)continue;const t=i.get(e.tag)??[];for(const n of e.lookupIndices)t.includes(n)||t.push(n);i.set(e.tag,t)}return{featureToLookups:i,lookupListOffset:o}}function gh(e,t,n){return e.seek(t),ch(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=ch(e,e.u16(),t),a=[];for(const i of r)try{const t=n(e,i,o);t&&a.push(t)}catch{}return{lookupType:o,subtables:a}})}function fh(e,t){const n=/* @__PURE__ */new Set;for(const o of t)for(const t of e.get(o)??[])n.add(t);return Array.from(n).sort((e,t)=>e-t)}function mh(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=ch(e,o,t).map(t=>(e.seek(t),sh(e,e.u16())));return{coverage:dh(e,n),sets:r}}function hh(e,t){const n=new Array(t);for(let o=0;o<t;o+=1){const t=e.u16(),r=e.u16();n[o]={sequenceIndex:t,lookupListIndex:r}}return n}function bh(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function yh(e,t){e.seek(t);const n=e.u16();return ch(e,n,t).map(t=>(e.seek(t),{backtrack:sh(e,e.u16()),input:sh(e,Math.max(0,e.u16()-1)),lookahead:sh(e,e.u16()),records:hh(e,e.u16())}))}function vh(e,t,n,o,r){const a=(e,n)=>{const o=t[e];return o?r?"b"===n?r.backtrack(o.id):"l"===n?r.lookahead(o.id):r.input(o.id):o.id:null};for(const i of e){const e=i.input.length+1;if(n+e>t.length)continue;let r=!0;for(let t=0;t<i.input.length;t+=1)if(a(n+1+t,"i")!==i.input[t]){r=!1;break}if(r){for(let e=0;e<i.backtrack.length;e+=1)if(a(n-1-e,"b")!==i.backtrack[e]){r=!1;break}if(r){for(let t=0;t<i.lookahead.length;t+=1)if(a(n+e+t,"l")!==i.lookahead[t]){r=!1;break}if(r)return bh(t,n,i.records,o),e}}}return null}function xh(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=e.i16(),n=dh(e,o);return{apply(e,o){const r=e[o];return!r||n(r.id)<0?null:(r.id=r.id+t&65535,1)}}}if(2===n){const t=e.u16(),n=sh(e,t),r=dh(e,o);return{apply(e,o){const a=e[o];if(!a)return null;const i=r(a.id);return i<0||i>=t?null:(a.id=n[i],1)}}}return null}(e,t);case 2:return function(e,t){const n=mh(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];if(0===i.length)return null;const l=n.codePoints,s=i.map((e,t)=>({id:e,codePoints:0===t?l:[]}));return e.splice(t,1,...s),i.length}}}(e,t);case 3:return function(e,t){const n=mh(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];return 0===i.length?null:(n.id=i[0],1)}}}(e,t);case 4:return function(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=ch(e,o,t).map(t=>(e.seek(t),ch(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:sh(e,Math.max(0,o-1))}}))),a=dh(e,n);return{apply(e,t){const n=e[t];if(!n)return null;const o=a(n.id);if(o<0||o>=r.length)return null;for(const a of r[o]){const{components:n}=a;if(t+n.length>e.length-1)continue;let o=!0;for(let a=0;a<n.length;a+=1)if(e[t+1+a].id!==n[a]){o=!1;break}if(!o)continue;const r=n.length+1,i=[];for(let a=0;a<r;a+=1)i.push(...e[t+a].codePoints);return e.splice(t,r,{id:a.ligatureGlyph,codePoints:i}),1}return null}}}(e,t);case 6:return function(e,t){e.seek(t);const n=e.u16();if(3===n){const n=ch(e,e.u16(),t),o=ch(e,e.u16(),t),r=ch(e,e.u16(),t),a=hh(e,e.u16()),i=n.map(t=>dh(e,t)),l=o.map(t=>dh(e,t)),s=r.map(t=>dh(e,t));return{apply(e,t,n){if(0===l.length)return null;if(t+l.length>e.length)return null;for(let o=0;o<l.length;o+=1)if(l[o](e[t+o].id)<0)return null;for(let o=0;o<i.length;o+=1){const n=e[t-1-o];if(!n||i[o](n.id)<0)return null}for(let o=0;o<s.length;o+=1){const n=e[t+l.length+o];if(!n||s[o](n.id)<0)return null}return bh(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=ch(e,o,t),a=dh(e,n),i=r.map(t=>yh(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;const r=a(o.id);return r<0||r>=i.length?null:vh(i[r],e,t,n,null)}}}if(2===n){const n=t+e.u16(),o=t+e.u16(),r=t+e.u16(),a=t+e.u16(),i=e.u16(),l=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();l[g]=0===n?0:t+n}const s=dh(e,n),c=uh(e,o),d=uh(e,r),u=uh(e,a),p=l.map(t=>0===t?[]:yh(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(s(o.id)<0)return null;const r=d(o.id),a=p[r];return a?vh(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return lh(e,t,xh);default:return null}}var wh=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=ph(n),a=gh(n,r,xh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return fh(this.featureToLookups,e)}applyLookupIndexAt(e,t,n){const o=this.lookups[e];if(!o||n<0||n>=t.length)return null;for(const r of o.subtables){const e=r.apply(t,n,this);if(null!==e)return e}return null}shape(e,t){const n=this.collectLookupIndices(t);for(const o of n){let t=0;for(;t<e.length;){const n=this.applyLookupIndexAt(o,e,t);t+=n&&n>0?n:1}}}};function Sh(e,t){let n=0;return 1&t&&e.i16(),2&t&&e.i16(),4&t&&(n=e.i16()),8&t&&e.i16(),16&t&&e.u16(),32&t&&e.u16(),64&t&&e.u16(),128&t&&e.u16(),n}function Ch(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function Ih(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=Sh(e,e.u16()),n=dh(e,o);return 0===t?null:{apply:(e,o,r)=>n(e[r])<0?null:(o[r]+=t,1)}}if(2===n){const t=e.u16(),n=e.u16(),r=Ch(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=Sh(e,t);const l=dh(e,o);return{apply(e,t,o){const r=l(e[o]);if(r<0||r>=n)return null;const a=i[r];return 0===a?null:(t[o]+=a,1)}}}return null}(e,t);case 2:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16(),r=e.u16(),a=e.u16(),i=!!(4&a);if(1===n){const n=e.u16(),l=ch(e,n,t).map(t=>{e.seek(t);const n=e.u16(),o=/* @__PURE__ */new Map;for(let i=0;i<n;i+=1){const t=e.u16(),n=Sh(e,r),i=Sh(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=dh(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=s(e[n]);if(r<0||r>=l.length)return null;const a=l[r].get(o);return a?(t[n]+=a.value1XAdvance,t[n+1]+=a.value2XAdvance,i?2:1):null}}}if(2===n){const n=t+e.u16(),l=t+e.u16(),s=e.u16(),c=e.u16(),d=Ch(r),u=d+Ch(a),p=e.tell(),g=new Array(s*c),f=new Array(s*c);for(let t=0;t<s;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=Sh(e,r),e.seek(p+o+d),f[t*c+n]=Sh(e,a)}const m=dh(e,o),h=uh(e,n),b=uh(e,l);return{apply(e,t,n){const o=e[n],r=e[n+1];if(void 0===r)return null;if(m(o)<0)return null;const a=h(o),l=b(r);if(a>=s||l>=c)return null;const d=a*c+l,u=g[d],p=f[d];return 0===u&&0===p?null:(t[n]+=u,t[n+1]+=p,i?2:1)}}}return null}(e,t);case 9:return lh(e,t,Ih);default:return null}}var Th=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=ph(n),a=gh(n,r,Ih);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=fh(this.featureToLookups,n);for(const r of o){const n=this.lookups[r];if(!n)continue;let o=0;for(;o<e.length;){let r=null;for(const a of n.subtables)if(r=a.apply(e,t,o),null!==r)break;o+=r&&r>0?r:1}}}},kh=/* @__PURE__ */new Set(["kern"]),Ph=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?wh.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?Th.parse(n):null}get hasGsub(){return null!==this.gsub}get hasGpos(){return null!==this.gpos}get hasShaping(){return null!==this.gsub||null!==this.gpos}layout(e,t){const n=[];for(const c of e){const e=c.codePointAt(0)??65533,t=this.font.glyphForCodePoint(e);n.push({id:t,codePoints:0===t?[65533]:[e]})}const o=t?.filter(e=>!kh.has(e))??[],r=t?.filter(e=>kh.has(e))??[];this.gsub&&o.length>0&&this.gsub.shape(n,o);const a=n.map(e=>this.font.advanceWidthForGlyph(e.id));this.gpos&&r.length>0&&this.gpos.position(n.map(e=>e.id),a,r);const i=[],l=[];let s=0;for(let c=0;c<n.length;c+=1){const e=n[c],t=this.font.advanceWidthForGlyph(e.id),o=a[c];i.push({id:e.id,codePoints:e.codePoints,advanceWidth:t}),l.push({xAdvance:o}),s+=o}return{glyphs:i,positions:l,advanceWidth:s}}},Rh=class{font;constructor(e){this.font=e}layout(e){const t=[],n=[];let o=0;for(const r of e){const e=r.codePointAt(0)??65533,a=this.font.glyphForCodePoint(e),i=this.font.advanceWidthForGlyph(a);t.push({id:a,codePoints:0===a?[65533]:[e],advanceWidth:i}),n.push({xAdvance:i}),o+=i}return{glyphs:t,positions:n,advanceWidth:o}}};function Bh(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ah(e,t){return Bh(e).getUint16(t)}function Mh(e,t,n){Bh(e).setUint16(t,n,!1)}function Fh(e,t,n){Bh(e).setUint32(t,n,!1)}function Oh(e){return e+3&-4}function Dh(e){const t=e.reduce((e,t)=>e+Oh(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=Oh(r.byteLength);return n}function Eh(e,t){const n=[],o=Bh(e);if(0===t)for(let r=0;r+1<e.byteLength;r+=2)n.push(2*o.getUint16(r));else for(let r=0;r+3<e.byteLength;r+=4)n.push(o.getUint32(r));return n}function Lh(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function Nh(e,t){if(e.byteLength<10||function(e,t){return Bh(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=Ah(e,n),t(Ah(e,n+2)),n+=4,n+=1&o?4:2,8&o?n+=2:64&o?n+=4:128&o&&(n+=8)}while(32&o)}function $h(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>Fh(t,4*n,e)),t}function zh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)Mh(n,4*o,e.advanceWidthForGlyph(o)),Mh(n,4*o+2,0);return n}var Hh=class{createSubset(e,t){const n=/* @__PURE__ */new Map,o=[];for(const d of t)o.push(d.id),n.has(d.id)||n.set(d.id,d.codePoints);const r=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head");if(!n||!o||!r)return Array.from(/* @__PURE__ */new Set([0,...t])).sort((e,t)=>e-t);const a=Eh(o,Ah(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=Lh(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||Nh(n.slice(e.start,e.end),e=>{i.has(e)||(i.add(e),l.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head"),a=e.getRawTableData("hhea"),i=e.getRawTableData("maxp"),l=e.getRawTableData("cmap");if(!(n&&o&&r&&a&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...t),c=new Set(t),d=Eh(o,Ah(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=Lh(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=Oh(t.byteLength)}}u.push(g);const f=r.slice();Fh(f,8,0),Mh(f,50,1);const m=a.slice();Mh(m,34,s+1);const h=i.slice();Mh(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:zh(e,s),loca:$h(u),maxp:h,glyf:Dh(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=Se(65536,new Map(Object.entries(a).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,l=Math.max(0,...r),s=[],c=[];for(let d=0;d<=l;d+=1)s[d]=e.advanceWidthForGlyph(d)/e.unitsPerEm*1e3,c[d]=n.get(d)??[0];return{fontFile:i,widths:s,unicode:c,encodeGlyph:e=>e}}};var Wh=class{fontResources=/* @__PURE__ */new Map;unicodeFontStates=/* @__PURE__ */new Map;usedFontResourceNames=/* @__PURE__ */new Set;constructor(e){for(const t of e)this.registerFontResource(t)}registerFontResource(e){if(this.fontResources.set(e.resourceName,e),"unicode"===e.kind&&!this.unicodeFontStates.has(e.resourceName)){const t=function(e){const t=new Ph(e);return{program:e,layouter:t.hasShaping?t:new Rh(e),subsetter:new Hh}}(function(e){const t=G.decodeSync(e);return Mo.parse(t)}(e.fontData)),n=1e3/t.program.unitsPerEm,o={id:0,codePoints:[0],advanceWidth:t.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(e.resourceName,{resource:e,font:t,usedGlyphs:/* @__PURE__ */new Map([[0,o]]),scale:n,layoutCache:/* @__PURE__ */new Map})}}resolveAndMarkFontName(e){const t=function(e){return e.fontResourceName?e.fontResourceName:e.bold&&e.italic?"F4":e.bold?"F2":e.italic?"F3":"F1"}(e);return this.usedFontResourceNames.add(t),t}getUnicodeState(e){return this.unicodeFontStates.get(e)}buildUnicodeShowCommand(e,t,n){const o=this.layoutUnicodeText(e,t,n),r=this.encodeUnicodeGlyphRun(e,o);return 0===r.length?null:r.some(e=>Math.abs(e.nominalWidth-e.desiredAdvance)>.01)?`[${r.map(e=>{const t=e.nominalWidth-e.desiredAdvance;return 0===t?`<${oh(e.glyphId)}>`:`<${oh(e.glyphId)}> ${Xm(t)}`}).join(" ")}] TJ`:`<${r.map(e=>oh(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>"base14"===e.kind||this.usedFontResourceNames.has(e.resourceName)),n=t.map(t=>{if("unicode"===t.kind){const n=this.unicodeFontStates.get(t.resourceName);if(n)return this.addUnicodeFontObjects(n,e)}return e(function(e){switch(e.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${e.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))});return{resourceXml:t.map((e,t)=>`/${e.resourceName} ${n[t]} 0 R`).join(" ")}}layoutUnicodeText(e,t,n){const o=`${n?.join(",")??""}\0${t}`,r=e.layoutCache.get(o);if(r)return r;const a=e.font.layouter.layout(t,n);return e.layoutCache.set(o,a),a}encodeUnicodeGlyphRun(e,t){return t.glyphs.map((n,o)=>{e.usedGlyphs.has(n.id)||e.usedGlyphs.set(n.id,n);const r=t.positions[o],a=n.advanceWidth*e.scale,i=(r?.xAdvance??n.advanceWidth)*e.scale;return{glyphId:n.id,nominalWidth:a,desiredAdvance:i}})}addUnicodeFontObjects(e,t){const n=e.font.subsetter.createSubset(e.font.program,e.usedGlyphs.values()),o=t(function(e,t=""){const n=`${qm(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${Gm(n)} /Filter /ASCIIHexDecode${o} >>\nstream\n${n}\nendstream`}(n.fontFile)),r=e.font.program.metadata,a=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),a>=1&&a<=7&&(i|=2),10===a&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${Qm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Qm(r.postscriptName,e.resource.family)}`,s=r.bbox,c=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*e.scale,s.minY*e.scale,s.maxX*e.scale,s.maxY*e.scale].map(Xm).join(" ")}]`,`/ItalicAngle ${Xm(r.italicAngle)}`,`/Ascent ${Xm(r.ascent*e.scale)}`,`/Descent ${Xm(r.descent*e.scale)}`,`/CapHeight ${Xm(r.capHeight*e.scale)}`,`/XHeight ${Xm(r.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${o} 0 R`,">>"].join("\n")),d=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${c} 0 R`,`/W [0 [${n.widths.map(e=>Xm(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${Gm(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${nh(e)}>`).filter(e=>"<>"!==e);0===t.length&&t.push("<0000>");const n=[];for(let o=0;o<t.length;o+=256){const e=Math.min(o+256,t.length);n.push(`<${Ym(o)}> <${Ym(e-1)}> [${t.slice(o,e).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${n.length} beginbfrange`,n.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(n.unicode)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${d} 0 R]`,`/ToUnicode ${u} 0 R`,">>"].join("\n"))}},Uh=class{imageResources=/* @__PURE__ */new Map;registerImageResource(e){const t=e.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(t)||this.imageResources.set(t,{resourceName:t,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height)),data:e.data,filter:e.filter}),t}has(e){return this.imageResources.has(e)}buildImageObjects(e){const t=/* @__PURE__ */new Map;for(const n of this.imageResources.values())t.set(n.resourceName,this.addImageObject(n,e));return t}addImageObject(e,t){return t(function(e,t){const n=`${qm(e)}>`;return[`<< /Length ${Gm(n)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${t.join(" ")}`," >>","stream",n,"endstream"].join("\n")}(e.data,["/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},jh=class{shadings=[];register(e){const t=`Sh${this.shadings.length+1}`;return this.shadings.push({name:t,spec:e}),t}buildShadingObjects(e){const t=/* @__PURE__ */new Map;for(const{name:n,spec:o}of this.shadings)t.set(n,this.addShadingObject(o,e));return t}addShadingObject(e,t){const n=t(function(e){if(2===e.length)return Vh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Vh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>Xm(e.offset)),o=e.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${t.join(" ")}]`,`/Bounds [${n.join(" ")}]`,`/Encode [${o}]`,">>"].join("\n")}(function(e){const t=e.map(e=>({offset:Math.min(1,Math.max(0,e.offset)),rgb:Zm(e.color,[0,0,0])})).sort((e,t)=>e.offset-t.offset);if(0===t.length)return[{offset:0,rgb:[0,0,0]},{offset:1,rgb:[0,0,0]}];if(1===t.length)return[{offset:0,rgb:t[0].rgb},{offset:1,rgb:t[0].rgb}];t[0].offset=0,t[t.length-1].offset=1;for(let n=1;n<t.length-1;n+=1){const e=t[n-1].offset+1e-4;t[n].offset<=e&&(t[n].offset=Math.min(.9999,e))}return t}(e.stops)));return t(["<< /ShadingType 2","/ColorSpace /DeviceRGB",`/Coords [${[e.x0,e.y0,e.x1,e.y1].map(Xm).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Vh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Xm).join(" ")}]`,`/C1 [${t.map(Xm).join(" ")}]`,"/N 1",">>"].join("\n")}var Kh=new TextEncoder;function _h(e){return"string"==typeof e?Gm(e):e.length}function Xh(e){const t=e.reduce((e,t)=>e+_h(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Kh.encode(r):r;n.set(e,o),o+=e.length}return n}function Gh(e){const t=xr(Kh.encode(e));return Xh([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function qh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function Yh(e){return`<FEFF${nh(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Zh(e){const t=[];if(e.title&&t.push(`/Title ${Yh(e.title)}`),e.author&&t.push(`/Author ${Yh(e.author)}`),e.subject&&t.push(`/Subject ${Yh(e.subject)}`),e.keywords&&t.push(`/Keywords ${Yh(e.keywords)}`),e.producer&&t.push(`/Producer (${qh(e.producer)})`),e.creationDate&&t.push(`/CreationDate (${function(e){const t=(e,t=2)=>String(e).padStart(t,"0");return`D:${e.getUTCFullYear()}${t(e.getUTCMonth()+1)}${t(e.getUTCDate())}${t(e.getUTCHours())}${t(e.getUTCMinutes())}${t(e.getUTCSeconds())}+00'00'`}(e.creationDate)})`),0!==t.length)return`<< ${t.join(" ")} >>`}function Jh(e){return e.children.reduce((e,t)=>e+1+Jh(t),0)}function Qh(e,t,n,o,r=[],a=[],i){const l=[],s=e=>{const t=l.length+1;return l.push({id:t,body:e}),t},c=s(""),d=s(""),{resourceXml:u}=t.buildFontObjects(s),p=n.buildImageObjects(s),g=o.buildShadingObjects(s),f=/* @__PURE__ */new Map;for(const B of e)for(const[e,t]of B.graphicsStateOpacities??[])f.has(e)||f.set(e,s(`<< /Type /ExtGState /ca ${Xm(t)} /CA ${Xm(t)} >>`));const m=[];for(const B of e){const e=s(Gh(`${B.commands.join("\n")}\n`)),t=Array.from(B.imageResourceNames).map(e=>{const t=p.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),n=t?` /XObject << ${t} >>`:"",o=Array.from(B.shadingResourceNames).map(e=>{const t=g.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),r=o?` /Shading << ${o} >>`:"",a=Array.from(B.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${f.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",l=B.annotations.map(e=>{const t=e.x,n=e.x+e.width,o=B.height-e.y-e.height,r=B.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${qh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${qh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${Xm(t)} ${Xm(o)} ${Xm(n)} ${Xm(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=l.length>0?`\n/Annots [${l.map(e=>`${e} 0 R`).join(" ")}]`:"",h=s(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${Xm(B.width)} ${Xm(B.height)}]`,`/Resources << /Font << ${u} >>${n}${r}${i} >>`,`/Contents ${e} 0 R${c}`,">>"].join("\n"));m.push(h)}let h;const b=r.filter(e=>void 0!==m[e.pageIndex]).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0);let y;b.length>0&&(h=s(`<< /Dests ${s(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${qh(t.name)}) [${n} 0 R /XYZ ${Xm(t.x)} ${Xm(o)} null]`}).join(" ")}] >>`)} 0 R >>`));const v=new Set(b.map(e=>e.name)),x=function(e){const t=[],n=[];for(const o of e){const e={title:o.title,destName:o.destName,children:[]};for(;n.length>0&&n[n.length-1].level>=o.level;)n.pop();0===n.length?t.push(e):n[n.length-1].node.children.push(e),n.push({node:e,level:o.level})}return t}(a.filter(e=>v.has(e.destName)));if(x.length>0){y=s("");const e=t=>t.map(t=>{const n=s("");return t.id=n,t.childIds=e(t.children),n}),t=e(x),n=(e,t)=>{e.forEach((o,r)=>{const a=o,i=r>0?e[r-1]:void 0,s=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+Yh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${qh(o.destName)})`];a.childIds.length>0&&(c.push(`/First ${a.childIds[0]} 0 R`),c.push(`/Last ${a.childIds[a.childIds.length-1]} 0 R`),c.push(`/Count ${Jh(o)}`)),c.push(">>"),l[a.id-1].body=c.filter(Boolean).join("\n"),n(o.children,a.id)})};n(x,y);const o=a.filter(e=>v.has(e.destName)).length;l[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(l[c-1].body=["<< /Type /Catalog",`/Pages ${d} 0 R`,void 0!==h?`/Names ${h} 0 R`:"",void 0!==y?`/Outlines ${y} 0 R`:"",void 0!==y?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=Zh(i);e&&(w=s(e))}const S=[Km];let C=_h(Km);const I=[0],T=e=>{S.push(e),C+=_h(e)};for(const B of l)I[B.id]=C,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const k=C;let P=`xref\n0 ${l.length+1}\n`;P+="0000000000 65535 f \n";for(const B of l)P+=`${String(I[B.id]??0).padStart(10,"0")} 00000 n \n`;T(P);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${l.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(k),"%%EOF",""].join("\n")),Xh(S)}var eb=class{pages=[];streams=[];fonts;images=new Uh;shadings=new jh;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=_m){this.fonts=new Wh(e)}registerFontResource(e){this.fonts.registerFontResource(e)}addPage(e){const t={width:Math.max(1,e.width),height:Math.max(1,e.height),commands:[],imageResourceNames:/* @__PURE__ */new Set,shadingResourceNames:/* @__PURE__ */new Set,annotations:[],graphicsStateOpacities:/* @__PURE__ */new Map};return this.pages.push(t),this.streams.push(new ih(t,this.fonts,this.images,this.shadings)),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(e,t){this.streams[e]?.drawRect(t)}drawLine(e,t){this.streams[e]?.drawLine(t)}drawPath(e,t){this.streams[e]?.drawPath(t)}saveGraphicsState(e){this.streams[e]?.saveGraphicsState()}restoreGraphicsState(e){this.streams[e]?.restoreGraphicsState()}setOpacity(e,t){this.streams[e]?.setOpacity(t)}rotateAbout(e,t,n,o){this.streams[e]?.rotateAbout(t,n,o)}clipRect(e,t,n,o,r){this.streams[e]?.clipRect(t,n,o,r)}clipPath(e,t){this.streams[e]?.clipPath(t)}drawText(e,t){this.streams[e]?.drawText(t)}registerAxialGradient(e,t){return this.streams[e]?.registerAxialGradient(t)??null}registerImageResource(e){return this.images.registerImageResource(e)}drawImage(e,t){this.streams[e]?.drawImage(t)}addLinkAnnotation(e,t){this.pages[e]?.annotations.push(t)}addNamedDestination(e){this.namedDestinations.some(t=>t.name===e.name)||this.namedDestinations.push(e)}addOutlineItem(e){this.outlineItems.push(e)}setDocumentInfo(e){this.documentInfo=e}toArrayBuffer(){const e=this.toUint8Array();return Uint8Array.from(e).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){return 0===this.pages.length&&this.addPage({width:612,height:792}),Qh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function tb(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=tn(i),s=tn(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:s,y:l});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:s,y:l}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function nb(e){e=sn(e);const t=new Vm,n=pt(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new eb(t.getPdfFontResources());o.setDocumentInfo(function(e){const t=e.metadata??{},n=e=>"string"==typeof e&&""!==e.trim()?e:void 0;return{title:n(t.title),author:n(t.author),subject:n(t.subject),keywords:n(t.keywords),producer:"Oasis Editor",creationDate:/* @__PURE__ */new Date}}(e));const r=Tr(e),a=function(e){return mt(e)}(e),i=function(e){const t=/* @__PURE__ */new Map,n=e.bookmarks;if(!n)return t;for(const o of n.order){const e=n.items[o],r=e?.start?.paragraphId;if(!e||!r)continue;const a=t.get(r)??[];a.push(e.name),t.set(r,a)}return t}(e),l=new Map(Bn(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,tn(s.pageSettings.width)),r=Math.max(1,tn(s.pageSettings.height)),c=o.addPage({width:n,height:r});await Hm(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=ue(s.pageSettings);await zm(o,c,s.headerBlocks,e,d,s.headerTop??nn(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??ye(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=hr(s.pageSettings),r=/* @__PURE__ */new Map;for(const e of s.blocks){const t=e.columnIndex??0,n=r.get(t)??[];n.push(e),r.set(t,n)}for(const[d,u]of r){const r=n[d]??n[0];await zm(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,tb(o,c,r.left,i,l))}}else await zm(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,tb(o,c,d,i,l));await zm(o,c,s.footerBlocks,e,d,s.footerTop??s.bodyBottom??s.pageSettings.height,u,t,a,s.pageSettings),s.footnoteBlocks&&s.footnoteBlocks.length>0&&void 0!==s.footnoteTop&&(void 0!==s.footnoteSeparatorTop&&o.drawLine(c,{x1:tn(d),y1:tn(s.footnoteSeparatorTop+.5),x2:tn(d+Math.min(180,.35*u)),y2:tn(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:tn(1)}),await rb(o,c,s.footnoteBlocks,s.footnoteReferenceIds??[],e,d,s.footnoteTop,u,t,a))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await Hm(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function ob(e){const t=await nb(e);return new Blob([t],{type:"application/pdf"})}async function rb(e,t,n,o,r,a,i,l,s,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,Io(r,e)?.run.text??""]));for(const g of n){const n=o.find(e=>g.blockId.startsWith(`${e}:`));if(n&&!u.has(n)){const o=p.get(n);if(o){const n="paragraph"===g.sourceBlock.type?g.sourceBlock:void 0,i=Te(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:tn(a),y:tn(d+12),text:o,fontSize:qt(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await zm(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function ab(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function ib(e){return new Promise(t=>{const n=URL.createObjectURL(e),o=document.createElement("iframe");o.setAttribute("aria-hidden","true"),o.style.position="fixed",o.style.right="0",o.style.bottom="0",o.style.width="0",o.style.height="0",o.style.border="0";let r=!1;const a=()=>{r||(r=!0,o.remove(),URL.revokeObjectURL(n),t())},i=()=>{if(!r){if(!window.open(n,"_blank")){const e=document.createElement("a");e.href=n,e.download="oasis-editor.pdf",e.click()}a()}};o.addEventListener("load",()=>{try{const e=o.contentWindow;if(!e)return void i();e.addEventListener("afterprint",a),globalThis.setTimeout(a,6e4),e.focus(),e.print()}catch{i()}}),o.src=n,document.body.appendChild(o)})}async function lb(e){return"function"==typeof e.arrayBuffer?e.arrayBuffer():new Promise((t,n)=>{const o=new FileReader;o.onerror=()=>n(o.error??/* @__PURE__ */new Error("Failed to read file.")),o.onload=()=>{const e=o.result;e instanceof ArrayBuffer?t(e):n(/* @__PURE__ */new Error("Failed to read file as ArrayBuffer."))},o.readAsArrayBuffer(e)})}function sb(e){if(!e)return null;for(const t of Array.from(e.items??[])){if("file"!==t.kind)continue;const e=t.getAsFile();if(e&&e.type.startsWith("image/"))return e}for(const t of Array.from(e.files??[]))if(t.type.startsWith("image/"))return t;return null}function cb(e){return function(e){const t=T(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=re(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=Te(o.styles,i.style?.styleId,e.styles),l=t.fontFamily??"<null>";n.set(l,(n.get(l)??0)+1),null!==t.characterSpacing&&(r+=1),null!==t.characterScale&&(a+=1)}}return{paragraphCount:t.length,alignCounts:Array.from(o.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:r,characterScaleRuns:a,firstParagraphs:t.slice(0,30).map((t,n)=>{const o=re(t.style,e.styles),r=t.runs[0],a=Te(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:Lt(t).length,runCount:t.runs.length,rawParagraphStyle:t.style,align:o.align,indentFirstLine:o.indentFirstLine,lineGridPitch:o.lineGridPitch,lineGridType:o.lineGridType,fontFamily:a.fontFamily,fontSize:a.fontSize,characterSpacing:a.characterSpacing,characterScale:a.characterScale,firstRunStyle:r?.styles}})}}(e)}function db(e,t){const n=Wn(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=Kr(e)[n.startIndex];if(!o)return null;let r=0;for(let a=0;a<o.runs.length;a+=1){const e=o.runs[a],i=r;if(r+=e.text.length,t(e)&&1===e.text.length&&i===n.startParagraphOffset)return{paragraph:o,paragraphIndex:n.startIndex,run:e,runIndex:a,offset:i}}return null}function ub(e,t){if("inline"===t)return;const n={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(t){case"square":case"tight":case"through":case"topAndBottom":return{...n,wrap:t,behindDoc:!1};case"behind":return{...n,wrap:"none",behindDoc:!0};case"front":return{...n,wrap:"none",behindDoc:!1}}}function pb(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function gb(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function fb(e){return"page"===e?.positionV?.relativeFrom}function mb(e){return db(e,e=>"image"===e.kind)}function hb(e,t,n){return Tb(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function bb(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function yb(e,t){return Tb(e,e=>{const n={...e},o=function(e){if(!e)return;const t=bb(e.left),n=bb(e.top),o=bb(e.right),r=bb(e.bottom),a=Math.min(o,Math.max(0,.99-t)),i=Math.min(r,Math.max(0,.99-n));return 0!==t||0!==n||0!==a||0!==i?{left:t,top:n,right:a,bottom:i}:void 0}(t.crop);return o?n.crop=o:delete n.crop,void 0!==t.width&&(n.width=Math.max(24,Math.round(t.width))),void 0!==t.height&&(n.height=Math.max(24,Math.round(t.height))),n})}function vb(e,t){const n=mb(e),o=n&&qn(n.run);return o?yb(e,function(e,t){if("reset"===t)return{crop:null};const n=t,{width:o,height:r}=e;if(!Number.isFinite(n)||n<=0||o<=0||r<=0)return{crop:e.crop??null};const a=e.crop??{},i=bb(a.left),l=bb(a.top),s=bb(a.right),c=bb(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-s);return{crop:{...a,left:i+t/2,right:s+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-l-c);return{crop:{...a,top:l+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function xb(e){const t=e.intrinsicWidth??e.width,n=e.intrinsicHeight??e.height,o=t>0&&n>0?t/n:e.width/Math.max(1,e.height),r=e.width/Math.max(1,e.height);if(!Number.isFinite(o)||!Number.isFinite(r))return{};if(o>r){const e=r/o,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(o<r){const e=o/r,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}return{}}function wb(e){return Tb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function Sb(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function Cb(e,t,n=90){const o=mb(e);if(!o||!qn(o.run))return e;const r="right"===t?-n:n,a=Sb(function(e){const t=mb(e);return(t&&qn(t.run))?.rotation??0}(e)+r);return Tb(e,e=>({...e,rotation:a}))}function Ib(e,t){const n=function(e){const t=mb(e),n=t&&qn(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?Tb(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function Tb(e,t){const n=mb(e);if(!n||!qn(n.run))return e;const o=Kr(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function kb(e,t){return Tb(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function Pb(e,t){const n=mb(e);if(!n)return e;const o=Kr(e),{paragraphIndex:a,offset:i,run:l}=n,s=No(o,t.paragraphId);if(s<0)return e;const c=o[s],p=Bt(c,t),g=s===a&&p>i?p-1:p;if(s===a&&g===i)return e;const f=e=>Ut(e,[...Rt(e,0,i),...Rt(e,i+1,u(e))]),m=(e,t)=>d(e,Math.max(0,Math.min(t,u(e))),[co("",Y(e,t),qn(l))]),h=o.map((e,t)=>t===a&&t===s?m(f(e),g):t===a?f(e):t===s?m(e,g):r([e])[0]),b=h[s],y=Math.max(0,Math.min(g+1,u(b)));return Ie(e,h,oe(Z(b,y)))}function Rb(e,t,n,o=0){const r=ue(V(t));if(!n)return r;const a=Ho(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function Bb(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await lb(t),r=`data:${t.type};base64,${function(e){return btoa(new Uint8Array(e).reduce((e,t)=>e+String.fromCharCode(t),""))}(o)}`,a=new Image;a.src=r,await new Promise(e=>{a.onload=e,a.onerror=e});const i=a.naturalWidth||300,l=a.naturalHeight||300,s=e.state(),c=n?.paragraphId??s.selection.focus.paragraphId,u=Rb(e.surfaceRef(),s.document,c,s.activeSectionIndex??0),p=i>u?u/i:1,g=Math.max(24,Math.round(i*p)),f=Math.max(24,Math.round(l*p));e.logger.info(`image insert:decoded natural=${i}x${l} fitted=${g}x${f} maxWidth=${u}`),e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=co("",Y(o,a),t),l=d(o,a,[i]),s=Kr(n).map((e,t)=>t===r?l:pn(e));return Ie(n,s,oe(Z(l,a+1)))}(n?Aa(e,{anchor:n,focus:n}):e,{src:r,width:g,height:f,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:Ui})}}}var Ab={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"preparing-fonts":[78,90],"applying-editor-state":[90,94],"stabilizing-layout":[94,99],done:[100,100],error:[100,100]};function Mb(e){return function(e){const[t,n]=an(null),o=(e,t)=>{const[n,o]=Ab[e];return void 0!==t&&Number.isFinite(t)?Math.round(10*(n+(o-n)*Math.min(1,Math.max(0,t))))/10:o},r=(e,t)=>{n({phase:e,progress:o(e,t),subProgress:t})},a=()=>{globalThis.setTimeout(()=>{n(e=>"done"===e?.phase||"error"===e?.phase?null:e)},1200)},i=function(e){return{handleImportFile:async t=>{if(!t)return;const n=h(t);if(!n)return e.setImportPhase("error"),e.logger.error("import:unsupported-format",{name:t.name,type:t.type}),void e.clearImportProgressSoon();const o=e.now();e.logger.info("import:start",{format:n.id,name:t.name,size:t.size}),e.setImportPhase("reading-file");const r="docx"===n.id?e.requestLocalFontAccess().catch(()=>!1):Promise.resolve(!1);try{const a=e.now(),i=await lb(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:c(e.now()-a,2)});let l=null,s=-1,d=0;const u=await n.import(i,(t,n)=>{const o=e.now(),r=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==l;if(!(a||void 0!==r&&(s<0||r-s>=1)||o-d>=40))return;l=t,s=r??s,d=o,e.setImportPhase(t,n);const i={phase:t,subProgress:n};a||void 0===n||1===n?e.logger.info("import:phase",i):e.logger.debug("import:phase",i)});e.logger.debug("import:document-diagnostics",cb(u));const p=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(u),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:c(e.now()-p,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(wo(u));const g=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:c(e.now()-g,2)});const f=$e(u).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),m=Ke(u).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:f,paragraphs:m,durationMs:c(e.now()-o,2)}),e.focusInput()}catch(a){e.setImportPhase("error"),e.logger.error("import:error",a)}finally{e.clearImportProgressSoon()}}}}({applyState:e.applyState,stabilizeLayoutAfterImport:e.stabilizeLayoutAfterImport,resetEditorChromeState:e.resetEditorChromeState,focusInput:e.focusInput,requestLocalFontAccess:e.requestLocalFontAccess,prepareDocumentFonts:e.prepareDocumentFonts,setImportPhase:r,clearImportProgressSoon:a,now:()=>performance.now(),logger:e.logger}),l=Bb({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),s=function(e){const t=e.download??ab,n=e.print??ib;let o=!1;return{handleExportDocx:async()=>{const n=await gm(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await ob(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await ob(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>gm(e.document()),exportPdfBlob:()=>ob(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),d=async t=>{e.isReadOnly()||await i.handleImportFile(t)},u=async(e,t)=>{await l.insertImageFromFile(e,t)},p=async t=>{e.isReadOnly()||t&&(await u(t),e.focusInput())};return{importProgress:t,handleImportFile:d,handleExportDocx:async()=>s.handleExportDocx(),handleExportPdf:async()=>s.handleExportPdf(),handlePrint:async()=>s.handlePrint(),exportDocxBlob:s.exportDocxBlob,exportPdfBlob:s.exportPdfBlob,insertImageFromFile:u,handleInsertImage:p}}(e)}function Fb(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Ob(e){return" "===e||"\t"===e||"\n"===e}function Db(e,t,n){if(n.isCollapsed)return null;const o=t.get(e);return void 0===o||o<n.startIndex||o>n.endIndex?null:n.startIndex===n.endIndex?{start:n.startParagraphOffset,end:n.endParagraphOffset}:e===n.start.paragraphId?{start:n.startParagraphOffset,end:Number.POSITIVE_INFINITY}:e===n.end.paragraphId?{start:0,end:n.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function Eb(e,t){if(!e)return null;for(const n of e)if("table"===n.type){if(n.id===t)return n;for(const e of n.rows)for(const n of e.cells){const e=Eb(n.blocks,t);if(e)return e}}return null}function Lb(e,t){const n=Wn(t),o=[],r=e.surfaceRect,a=new Map(Kr(t).map((e,t)=>[e.id,t]));let i=null,l=null;if(!n.isCollapsed&&n.startIndex===n.endIndex&&n.endParagraphOffset-n.startParagraphOffset===1){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.inlineImages.find(t)??e.floatingImages.find(t);if(o&&(i={paragraphId:o.paragraphId,startOffset:o.startOffset,endOffset:o.endOffset,left:o.left-r.left,top:o.top-r.top,width:o.width,height:o.height,rotation:o.rotation??0}),!i){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.floatingTextBoxes.find(t),a=o?void 0:e.inlineTextBoxes.find(t),i=o??a;i&&(l={paragraphId:i.paragraphId,startOffset:i.startOffset,endOffset:i.endOffset,left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height,rotation:i.rotation??0,floating:Boolean(o)})}}const s=(e.paragraphsById.get(t.selection.anchor.paragraphId)??[]).find(e=>e.tableCell)?.tableCell,c=(e.paragraphsById.get(t.selection.focus.paragraphId)??[]).find(e=>e.tableCell)?.tableCell;let d=!1;if(s&&c&&s.tableId===c.tableId&&(s.rowIndex!==c.rowIndex||s.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of Fe(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Eb(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Eb(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=ln(n),a=t.find(e=>e.rowIndex===s.rowIndex&&e.cellIndex===s.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const l=Math.min(a.visualRowIndex,i.visualRowIndex),s=Math.max(a.visualRowIndex+a.rowSpan-1,i.visualRowIndex+i.rowSpan-1),c=Math.min(a.visualColumnIndex,i.visualColumnIndex),u=Math.max(a.visualColumnIndex+a.colSpan-1,i.visualColumnIndex+i.colSpan-1),p=/* @__PURE__ */new Set;for(const a of e.paragraphs)if(a.tableCell&&a.tableCell.tableId===n.id){const e=t.find(e=>e.rowIndex===a.tableCell.rowIndex&&e.cellIndex===a.tableCell.cellIndex);if(e){const t=e.visualRowIndex<=s&&e.visualRowIndex+e.rowSpan-1>=l,n=e.visualColumnIndex<=u&&e.visualColumnIndex+e.colSpan-1>=c;if(t&&n){const t=`${e.rowIndex}:${e.cellIndex}`;p.has(t)||(p.add(t),o.push({left:a.tableCell.left-r.left,top:a.tableCell.top-r.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(d||n.isCollapsed||i||l))for(const w of e.paragraphs){const e=Db(w.paragraphId,a,n);if(!e)continue;const t=Math.max(e.start,w.startOffset),i=Math.min(e.end,w.endOffset);if(!(t>=i))for(const n of w.lines){let e=Math.max(t,n.startOffset),a=Math.min(i,n.endOffset);for(;e<a&&Ob(Fb(w,e));)e+=1;for(;a>e&&Ob(Fb(w,a-1));)a-=1;if(e>=a)continue;const l=n.slots.find(t=>t.offset===e),s=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!l||!s)continue;const c=0===w.startOffset&&n.startOffset===w.startOffset&&n.top>w.top,d=c?w.top:n.top,u=c?n.top+n.height-w.top:n.height;o.push({left:l.left-r.left+1,top:d-r.top,width:Math.max(1,s.left-l.left+1-1),height:u})}}const u=t.selection.focus.paragraphId,p=e.paragraphsById.get(u)??[],g=p[0]?.paragraph,f=function(e,t){if(0===e.length)return null;const n=e.find(e=>t>=e.startOffset&&t<=e.endOffset)??e[e.length-1],o=n.lines.flatMap(e=>e.slots);if(0===o.length)return{left:n.left,top:n.top,height:Math.max(18,n.height)};let r=o[0],a=Math.abs(t-r.offset);for(const l of o){const e=Math.abs(t-l.offset);e<a&&(r=l,a=e)}const i=n.lines[0];return 0===n.startOffset&&void 0!==i&&t>=i.startOffset&&t<=i.endOffset&&r.top>n.top?{left:r.left,top:n.top,height:r.top+r.height-n.top}:{left:r.left,top:r.top,height:r.height}}(p,g?Bt(g,t.selection.focus):t.selection.focus.offset),m=(f?.left??r.left)-r.left,h=(f?.top??r.top)-r.top,b=Math.max(18,f?.height??28),y={left:m,top:h,height:b,visible:p.length>0&&!d&&!i&&!l};let v=null;const x=(e.paragraphsById.get(u)??[])[0]?.tableCell?.tableId??null;if(x){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of e.paragraphs){const e=r.tableCell;e&&e.tableId===x&&(t=Math.min(t,e.left),n=Math.min(n,e.top),o=Math.max(o,e.left+e.width),a=Math.max(a,e.top+e.height))}Number.isFinite(t)&&o>t&&a>n&&(v={tableId:x,left:t-r.left,top:n-r.top,width:o-t,height:a-n})}return{selectionBoxes:o,inputBox:{left:m,top:h,height:b},caretBox:y,selectedImageBox:i,selectedTextBoxBox:l,selectedTableBox:v}}var Nb={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments"};function $b(e,t){return e[Nb[t]]??!0}function zb(e,t){return"boolean"==typeof t.allAuthors?Ub(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=jb(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=jb(n);return Ub(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Kb(e)):t.section?function(e,t){const n=Nb[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function Hb(e,t){return e.markupAuthors?.includes(t)??!0}function Wb(e,t,n){return!("insert"===t&&!$b(e,"insertions"))&&(!("delete"===t&&!$b(e,"deletions"))&&Hb(e,n))}function Ub(e,t){return void 0===e.markupAuthors&&void 0===t||void 0!==e.markupAuthors&&void 0!==t&&e.markupAuthors.length===t.length&&e.markupAuthors.every((e,n)=>e===t[n])?e:{...e,markupAuthors:t}}function jb(e){return[...new Set(e)].sort()}function Vb(e,t){for(const n of e.runs){const e=n.revision?.author??n.revisionRangeMarker?.author;e&&t.add(e)}}function Kb(e){const t=/* @__PURE__ */new Set,n=e=>{if(e)for(const n of e)"paragraph"===n.type&&Vb(n,t)},o=T(e.document);for(const l of o)Vb(l,t);for(const l of Fe(e.document))for(const e of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])n(e);const r=e.document.footnotes?.items??{};for(const l of Object.values(r))n(l.blocks);const a=e.document.endnotes?.items??{};for(const l of Object.values(a))n(l.blocks);const i=e.document.comments?.items??{};for(const l of Object.values(i)){const e=l.author??l.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function _b(e,t){const n=[];let o=0;for(const r of e.runs){const e=o,a=o+r.text.length;o=a;const i=r.revision;if(i&&("insert"===i.type||"delete"===i.type)&&Wb(t,i.type,i.author)&&a>e){const t=n.at(-1);t&&t.revisionId===i.id&&t.type===i.type&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:i.id,type:i.type})}}return n}var Xb={composeMeasuredParagraphLines:e=>Fn.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>Fn.resolveRenderedLineHeightPx(e,t)};function Gb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function qb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>{const o=e?.[n];return o?.blockIndex===t.blockIndex&&o?.offset===t.offset})}function Yb(){let e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Map;return function(n){const o=/* @__PURE__ */new Map,r=t=>t?.map(t=>{const n=e.get(t.blockId),r=function(e,t){return Boolean(e&&e.blockId===t.blockId&&e.sourceBlock===t.sourceBlock&&e.estimatedHeight===t.estimatedHeight&&e.tableSegment?.startRowIndex===t.tableSegment?.startRowIndex&&e.tableSegment?.endRowIndex===t.tableSegment?.endRowIndex&&e.tableSegment?.repeatedHeaderRowCount===t.tableSegment?.repeatedHeaderRowCount&&Gb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&Gb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&qb(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&qb(e.tableSegment?.endRowCellBlockPositions,t.tableSegment?.endRowCellBlockPositions)&&function(e,t){return e===t||!(!e||!t)&&e.text===t.text&&e.startOffset===t.startOffset&&e.endOffset===t.endOffset&&e.lines.length===t.lines.length&&t.lines.every((t,n)=>{const o=e.lines[n];return void 0!==o&&o.startOffset===t.startOffset&&o.endOffset===t.endOffset&&o.top===t.top&&o.height===t.height})}(e.layout,t.layout))}(n,t)?n:t;return o.set(r.blockId,r),r}),a=n.pages.map(e=>{const n={...e,blocks:r(e.blocks)??[],headerBlocks:r(e.headerBlocks),footerBlocks:r(e.footerBlocks),footnoteBlocks:r(e.footnoteBlocks)},o=t.get(n.id);return function(e,t){const n=Boolean(e&&e.pageSettings.width===t.pageSettings.width&&e.pageSettings.height===t.pageSettings.height&&e.pageSettings.orientation===t.pageSettings.orientation&&e.pageSettings.margins.top===t.pageSettings.margins.top&&e.pageSettings.margins.right===t.pageSettings.margins.right&&e.pageSettings.margins.bottom===t.pageSettings.margins.bottom&&e.pageSettings.margins.left===t.pageSettings.margins.left&&e.pageSettings.margins.header===t.pageSettings.margins.header&&e.pageSettings.margins.footer===t.pageSettings.margins.footer&&e.pageSettings.margins.gutter===t.pageSettings.margins.gutter);if(!e||e.id!==t.id||e.index!==t.index||e.height!==t.height||e.maxHeight!==t.maxHeight||!n||e.bodyTop!==t.bodyTop||e.bodyBottom!==t.bodyBottom||e.headerTop!==t.headerTop||e.footerTop!==t.footerTop||e.footnoteTop!==t.footnoteTop||e.footnoteSeparatorTop!==t.footnoteSeparatorTop)return!1;const o=(e,t)=>(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t);return o(e.blocks,t.blocks)&&o(e.headerBlocks,t.headerBlocks)&&o(e.footerBlocks,t.footerBlocks)&&o(e.footnoteBlocks,t.footnoteBlocks)&&(r=e.footnoteReferenceIds,a=t.footnoteReferenceIds,(r?.length??0)===(a?.length??0)&&(a??[]).every((e,t)=>r?.[t]===e));var r,a}(o,n)?o:n});return e=o,t=new Map(a.map(e=>[e.id,e])),{pages:a}}}function Zb(e,t){if(0===t.length)return e;let n;for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&(n??={...e},delete n[o]);return n??e}function Jb(e){return function(e){const[t,n]=an({}),[r,a]=an({}),[i,l]=an({left:0,top:0,height:28}),[s,c]=an([]),[d,u]=an([]),[p,g]=an([]),[f,m]=an(null),[h,b]=an(null),[y,v]=an(null),[x,w]=an({left:0,top:0,height:28,visible:!1}),[S,C]=an(null),I=Yb(),T=vr(()=>{Jo();const t=e.state.reviewDisplayMode??"all";return"all"===t?e.state.document:Nr(e.state.document,t).document}),k=vr(()=>(Jo(),I(Tr(T(),void 0,t(),r(),{measurer:Xb})))),P=nt();let R=0;const B=(t="selection")=>{const n=e.surfaceRef();if(!n)return c([]),u([]),g([]),m(null),b(null),v(null),void w(e=>({...e,visible:!1}));const o=P.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:k(),zoomFactor:e.zoomFactor?.()});if(!o)return c([]),u([]),g([]),m(null),b(null),v(null),void w(e=>({...e,visible:!1}));if("all"!==(e.state.reviewDisplayMode??"all"))return c([]),m(null),b(null),v(null),w({left:0,top:0,height:28,visible:!1}),l({left:0,top:0,height:28}),u([]),void g([]);const r=Lb(o,e.state);c(r.selectionBoxes),g(!1===e.state.showRevisionMarkup?[]:function(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=_b(r.paragraph,t);if(0!==e.length)for(const t of r.lines)for(const r of e){const e=Math.max(r.start,t.startOffset),a=Math.min(r.end,t.endOffset);if(e>=a)continue;const i=t.slots.find(t=>t.offset===e),l=t.slots.find(e=>e.offset===a)??t.slots[t.slots.length-1];i&&l&&o.push({revisionId:r.revisionId,type:r.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,l.left-i.left),height:t.height})}}return o}(o,e.state)),u(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!$b(t,"comments"))return[];const o=e.surfaceRect,r=new Map(Kr(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const l=n.items[i];if(!l?.start||!l?.end||!Hb(t,l.author))continue;const s=r.get(l.start.paragraphId),c=r.get(l.end.paragraphId);if(void 0!==s&&void 0!==c)for(const t of e.paragraphs){const e=r.get(t.paragraphId);if(void 0===e||e<s||e>c)continue;const n=e===s?l.start.offset:0,d=e===c?l.end.offset:Number.POSITIVE_INFINITY,u=Math.max(n,t.startOffset),p=Math.min(d,t.endOffset);if(!(u>=p))for(const r of t.lines){const e=Math.max(u,r.startOffset),t=Math.min(p,r.endOffset);if(e>=t)continue;const n=r.slots.find(t=>t.offset===e),l=r.slots.find(e=>e.offset===t)??r.slots[r.slots.length-1];n&&l&&a.push({commentId:i,left:n.left-o.left,top:r.top-o.top,width:Math.max(1,l.left-n.left),height:r.height})}}}return a}(o,e.state)),m(r.selectedImageBox),b(r.selectedTextBoxBox),v(r.selectedTableBox),l(r.inputBox),w(r.caretBox)},A=(e="selection")=>{const t=++R;queueMicrotask(()=>{t===R&&B(e)})},M=(e="content-change")=>(A(e),!1),F=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(a(e=>Zb(e,t.paragraphIds??[])),Lr()),A(e),t.resolveWhenDone?Promise.resolve():null),O=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),a({}),Lr();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];a(t=>Zb(t,e)),Lr()}A("content-change")}},D=async()=>{n({}),a({}),Lr(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),A("import")};we(()=>{e.state.selection.anchor.paragraphId,e.state.selection.anchor.runId,e.state.selection.anchor.offset,e.state.selection.focus.paragraphId,e.state.selection.focus.runId,e.state.selection.focus.offset,A("selection")}),we(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||A("content-change")}),we(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.markupAuthors,A("content-change")}),we(()=>{e.state.reviewDisplayMode,A("content-change")}),we(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{A("scroll")},r=()=>{A("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",r),o(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",r)})});const E=()=>C(null),L=()=>{R+=1,P.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:r,documentLayout:k,canvasSnapshotProvider:P,inputBox:i,selectionBoxes:s,commentHighlights:d,revisionMarkupBoxes:p,selectedImageBox:f,selectedTextBoxBox:h,selectedTableBox:y,caretBox:x,preferredColumnX:S,setPreferredColumnX:C,clearPreferredColumn:E,requestInputBoxSync:A,scheduleDeferredLayoutMeasurement:F,stabilizeLayoutAfterImport:D,syncMeasuredLayoutMetrics:M,syncInputBox:B,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:a,applyInvalidation:O,onCleanupHook:L}}(e)}function Qb(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function ey(e){return function(e){const t=(e,t)=>{const n=$e(e.document),o=Math.max(0,Math.min(fo(e),n.length-1)),r=io(e),a=n[o];if(!a)return e;const i=[...n],l={...a},s=pr("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(s):e.push(s),l.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(s):e.push(s),l.footer=e}else{const e=[...a.blocks];t<0?e.unshift(s):e.push(s),l.blocks=e}return i[o]=l,{...e,document:{...e.document,sections:i}}},n=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:Qb(n.redoStack,o),lastTransactionMeta:null},nextState:n.undoStack[n.undoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},o=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.redoStack.length?null:{history:{undoStack:Qb(n.undoStack,o),redoStack:n.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:n.redoStack[n.redoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},r=n=>{const o=e.imageOps().getSelectedImageInfo(e.state());if(!o)return!1;const r=Kr(e.state()),a=r.findIndex(e=>e.id===o.paragraph.id);if(a<0)return!1;const i=a+n;if(i<0||i>=r.length){const o=e.state(),r=t(o,n),a=Kr(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=Z(i,n<0?u(i):0);return e.applyTransactionalState(()=>Pb(r,l),{mergeKey:Vi}),e.focusInput(),!0}const l=r[i],s=n<0?u(l):0;return e.applyTransactionalState(e=>Pb(e,Z(l,s)),{mergeKey:Vi}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(lr)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function ty(e={}){const t=e.dbName??"oasis-editor-db",n=e.storeName??"documents",o=e.key??"current-document";let r=null;async function a(){return r||(r=await function(e){return new Promise((t,n)=>{const o=indexedDB.open(e.name,e.version);o.onerror=()=>{n(/* @__PURE__ */new Error(`Failed to open IndexedDB: ${o.error?.message}`))},o.onsuccess=()=>{t(o.result)},o.onupgradeneeded=t=>{const n=o.result;e.onUpgrade(n,t.oldVersion,t.newVersion)}})}({name:t,version:1,onUpgrade:e=>{e.objectStoreNames.contains(n)||e.createObjectStore(n)}}),r)}return{async saveDocument(e){await function(e,t,n,o){return new Promise((r,a)=>{try{const i=e.transaction([t],"readwrite"),l=i.objectStore(t).put(o,n);l.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${l.error?.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{a(/* @__PURE__ */new Error(`Transaction failed putting item in ${t}: ${i.error?.message}`))}}catch(i){a(i)}})}(await a(),n,o,e)},loadDocument:async()=>function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readonly").objectStore(t).get(n);a.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to get item from ${t}: ${a.error?.message}`))},a.onsuccess=()=>{o(a.result??null)}}catch(a){r(a)}})}(await a(),n,o),async clearDocument(){await function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readwrite"),i=a.objectStore(t).delete(n);i.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to delete item from ${t}: ${i.error?.message}`))},a.oncomplete=()=>{o()},a.onabort=a.onerror=()=>{r(/* @__PURE__ */new Error(`Transaction failed deleting item from ${t}: ${a.error?.message}`))}}catch(a){r(a)}})}(await a(),n,o)},close(){r&&(r.close(),r=null)}}}function ny(e){return function(e){const[t,n]=an([]),[o,r]=an([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},l=t=>{e.commitState(e.cloneState(t))},s=(t,n)=>{const o=e.stateSnapshot(),r=yn("txn:produce",()=>t(o),0);if(r===o)return;a=function(e,t,n,o,r=Date.now()){return{undoStack:void 0!==o?.mergeKey&&e.lastTransactionMeta?.mergeKey===o.mergeKey&&r-e.lastTransactionMeta.timestamp<1e3?e.undoStack:Qb(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const l=yn("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>$e(e.document).map(e=>[...(e.header??[]).map(e=>e.id),...e.blocks.map(e=>e.id),...(e.footer??[]).map(e=>e.id)].join("|")).join("||");if(n(e)!==n(t))return{dirtyAll:!0,structureChanged:!0};const o=Kr(e),r=Kr(t),a=/* @__PURE__ */new Map;for(const l of o)a.set(l.id,l);const i=[];for(const l of r){const e=a.get(l.id);if(!e){i.push(l.id);continue}if(e===l)continue;if(e.runs.length!==l.runs.length){i.push(l.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=l.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=qn(o),i=qn(r);if(Boolean(a)!==Boolean(i)||(a?.width??-1)!==(i?.width??-1)||(a?.height??-1)!==(i?.height??-1)||(a?.floating?.wrap??"")!==(i?.floating?.wrap??"")||Boolean(a?.floating?.behindDoc)!==Boolean(i?.floating?.behindDoc)||(a?.wrapPolygon?.length??-1)!==(i?.wrapPolygon?.length??-1)){t=!0;break}}t&&i.push(l.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(l),yn("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:s,applyHistoryState:l,resetTransactionGrouping:()=>{var e;e=a,a={...e,lastTransactionMeta:null}},updateHistoryState:e=>{a=e(a),i()},getHistoryState:()=>a,clearHistory:()=>{a={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}(e)}function oy(e){let t=e.state.document,n=e.state.selection;we(()=>{const o=e.state.document,r=e.state.selection,a=o!==t,i=r!==n;var l;if(t=o,n=r,e.state.activeSectionIndex,e.state.activeZone,l=e.state,Ai&&(Oi={anchor:{paragraphId:l.selection.anchor.paragraphId,runId:l.selection.anchor.runId,offset:l.selection.anchor.offset},focus:{paragraphId:l.selection.focus.paragraphId,runId:l.selection.focus.runId,offset:l.selection.focus.offset},activeZone:l.activeZone??"main",activeSectionIndex:l.activeSectionIndex??0}),e.isImportInProgress())return;const s=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(s),a&&(e.emit("change",s),e.emit("documentChange",s.document)),i&&e.emit("selectionChange",s.selection)})}function ry(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:g,getImageOps:f}=e,m=Mb({state:()=>r,applyState:l,applyTransactionalState:(e,t)=>W(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await F()},resetEditorChromeState:()=>G(),focusInput:d,requestLocalFontAccess:wa,prepareDocumentFonts:async e=>{await Pe(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),h=()=>"done"!==m.importProgress()?.phase&&"error"!==m.importProgress()?.phase&&null!==m.importProgress(),{measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:C,revisionMarkupBoxes:I,selectedImageBox:T,selectedTextBoxBox:k,selectedTableBox:P,caretBox:R,preferredColumnX:B,setPreferredColumnX:A,clearPreferredColumn:M,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyInvalidation:E,onCleanupHook:L}=Jb({state:r,surfaceRef:u,viewportRef:p,isImporting:h,zoomFactor:g}),N=ty({key:t().persistenceKey}),{status:$}=function(e,t,n){const[o,r]=an("Initial"),[a,i]=an(!1),l=()=>n.enabled??!1,s=n.persistence,c=_r(async e=>{if(l()&&a()){r("Saving...");try{const t=JSON.parse(JSON.stringify(ze(e)));await s.saveDocument(t),r("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),r("Error")}}},1e3);return we(it(()=>e.document,e=>{l()&&a()&&c(e)},{defer:!0})),Zn(async()=>{if(!l())return i(!0),void r("Saved");try{const e=await s.loadDocument();e&&t(e)}catch(e){n.logger?.error("persistence:load failed",e)}finally{i(!0),r("Saved")}}),{status:o}}(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=wo(e);a(t),G()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??N,logger:n}),{undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_}=ny({stateSnapshot:i,commitState:a,cloneState:s,applyLayoutInvalidation:E}),X=ey({state:()=>r,stateSnapshot:i,applyHistoryState:U,applyTransactionalState:W,focusInput:d,clearPreferredColumn:M,imageOps:f,updateHistoryState:V,getHistoryState:K}),G=()=>{M(),O({}),D({}),Lr(),x.clear(),_()};return oy({state:r,isImportInProgress:h,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:m,isImportInProgress:h,measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:C,revisionMarkupBoxes:I,selectedImageBox:T,selectedTextBoxBox:k,selectedTableBox:P,caretBox:R,preferredColumnX:B,setPreferredColumnX:A,clearPreferredColumn:M,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyLayoutInvalidation:E,onCleanupHook:L,fallbackPersistence:N,persistenceStatus:$,undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_,historyActions:X,resetEditorChromeState:G}}(e)}function ay(e){return db(e,e=>"textBox"===e.kind)}function iy(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function ly(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Gn(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return Ie(e,a,$(a,Wn(e)))}function sy(e,t,n,o={}){const r=ay(e),a=r&&Er(r.run);if(!r||!a)return e;const i=o.handleDirection??"se",l=i.includes("n")||i.includes("s"),s=i.includes("w"),c=i.includes("n"),d=Math.max(24,Math.round(t)),u=Math.max(24,Math.round(n)),{paragraphIndex:p,run:g}=r,f=d-a.width,m=u-a.height,h=Kr(e).map((e,t)=>t!==p?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Gn(e);const t=e.textBox,n={...t,width:d,height:u};return l&&t.body?.autoFit&&(n.body={...t.body,autoFit:!1}),t.floating&&(n.floating=function(e,t,n,o,r){let a=e;if(o&&0!==t){const n=e.positionH;n?.align||(a={...a,positionH:{...n??{},offset:(n?.offset??0)-t*In}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*In}})}return a}(t.floating,f,m,s,c)),{...e,textBox:n}})});return Ie(e,h,$(h,Wn(e)))}var cy=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),dy=e=>e.rows.reduce((e,t)=>Math.max(e,cy(t)),0),uy=(e,t)=>{let n=0;for(const o of e.cells){const e=Math.max(1,o.colSpan??1);if(t>=n&&t<n+e)return o;n+=e}return null};function py(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}var gy=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=py(e);if(t)return t}return null};function fy(e,t){return e.some(e=>Po(e).some(e=>e.id===t))}var my=(e,t,n)=>{const o=Jr(e,t);if(!o)return null;const r=F(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!fy(o,n))continue;const e=i(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Jr(e,t);if(!n)return[];if("footnote"===n.zone){const t=n.footnoteId?e.footnotes?.items[n.footnoteId]:void 0;return t?[t.blocks]:[]}const o=Fe(e)[n.sectionIndex];return o?"main"===n.zone?[o.blocks]:"header"===n.zone?[o.header,o.firstPageHeader,o.evenPageHeader].filter(e=>Boolean(e)):[o.footer,o.firstPageFooter,o.evenPageFooter].filter(e=>Boolean(e)):[]}(e,t),r.tablePath,t);if(!a)return null;const l=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),s=l.findIndex(e=>function(e,t){return e.blocks.some(e=>Po(e).some(e=>e.id===t))}(e,t));if(-1===s)return null;const c=py(l[s+n]);return c?Z(c,0):null};function hy(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function by(e,t,n){if("main"===n)return"blocks";const o=e.selection.focus.paragraphId;return"header"===n?[["header",t.header],["firstPageHeader",t.firstPageHeader],["evenPageHeader",t.evenPageHeader]].find(([,e])=>hy(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>hy(e,o))?.[0]??"footer":"blocks"}function yy(e){const t=Jr(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function vy(e,t){if("footnote"===t){const t=yy(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=$e(e.document),o=fo(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=by(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var xy=(e,t,n="main")=>{if("footnote"===n){const n=yy(e),o=e.document.footnotes,r=n?o?.items[n]:void 0;return n&&o&&r?{...e,document:{...e.document,footnotes:{...o,items:{...o.items,[n]:{...r,blocks:t}}}}}:e}const o=fo(e),r=$e(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const l=by(e,i,n),s=[...r];return s[a]="blocks"===l?{...i,blocks:t}:{...i,[l]:t},{...e,document:{...e.document,sections:s}}};function wy(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Sy(e,t){const n=i(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:wy(t),targetBlocks:e}:null}function Cy(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];if(!a||"table"!==a.type)return null;const i=[...r];return i[o.tableBlockIndex]=To(a),Sy(i,n)}var Iy=(e,t,n)=>{const o=F(e.document,e.selection.focus.paragraphId,fo(e));if(!o||e.selection.anchor.paragraphId!==e.selection.focus.paragraphId)return n(e);const r=function(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];return a&&"table"===a.type?Sy(function(e,t){const n=[...e];let o=n;for(let r=0;r<t.length;r+=1){const e=t[r];if(!e)break;const n=o[e.tableBlockIndex];if(!n||"table"!==n.type)break;const a={...n,rows:[...n.rows]};o[e.tableBlockIndex]=a;const i=a.rows[e.rowIndex];if(!i)break;const l={...i,cells:[...i.cells]};a.rows[e.rowIndex]=l;const s=l.cells[e.cellIndex];if(!s)break;const c={...s,blocks:[...s.blocks]};l.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,o);if(!r)return n(e);const a=n({...e,document:eo(r.targetCell.blocks.map(e=>"paragraph"===e.type?pn(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),i=$e(a.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...i),{...xy(e,r.targetBlocks,o.zone),selection:a.selection}};function Ty(e,t){const n=F(e.document,e.selection.focus.paragraphId,fo(e));return n?Cy(e,t,n):null}function ky(e,t,n,o){const r=xy(e,t,n);return o?{...r,selection:{anchor:Z(o,0),focus:Z(o,0)}}:r}function Py(e,t,n,o){const r=t.getTargetBlocks(e,n),a=i(r,o);return a?.[a.length-1]?.table??null}function Ry(e,t){const n=F(e.document,e.selection.focus.paragraphId,fo(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Py(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function By(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Ry(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.colSpan??1)>1)},o=t=>{const n=e.resolveVerticalTableCellRange(t);if(!n)return!1;const o=Py(t,e,n.zone,n.tablePath);if(!o)return!1;for(let e=n.startRowIndex;e<=n.endRowIndex;e+=1){const t=o.rows[e]?.cells[n.cellIndex];if(!t||"continue"===t.vMerge||1!==t.blocks.length||"paragraph"!==t.blocks[0]?.type)return!1}return!0},r=e=>t(e)||o(e),a=t=>{const n=Ry(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.rowSpan??1)>1&&"restart"===o?.vMerge)},i=e=>n(e)||a(e),l=t=>null!==Ry(t,e),s=t=>{const n=Ry(t,e);return Boolean(n&&dy(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function Ay(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function My(e){return e.blocks.flatMap(Po)}function Fy(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Oy(e,t){return function(e,t){const n=e.selection,o=fo(e),r=F(e.document,n.anchor.paragraphId,o),a=F(e.document,n.focus.paragraphId,o);if(!r||!a||r.zone!==a.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(r.tablePath,a.tablePath))return null;const l=t.getTargetBlocks(e,r.zone),s=i(l,r.tablePath),c=i(l,a.tablePath),d=s?.[s.length-1],u=c?.[c.length-1];if(!d||!u||d.table!==u.table)return null;const p=Fy(r),g=Fy(a),f=d.table,m=ln(f),h=m.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex),b=m.find(e=>e.rowIndex===g.rowIndex&&e.cellIndex===g.cellIndex);return h&&b?{anchorLocation:p,focusLocation:g,anchorCell:h,focusCell:b,tableBlock:f,tableLayout:m}:null}(e,t)}function Dy(e){return function(e){const t=t=>{const n=t.selection,o=Oy(t,e);if(!o||o.anchorLocation.rowIndex===o.focusLocation.rowIndex&&o.anchorLocation.cellIndex===o.focusLocation.cellIndex)return e.logger?.debug(`resolveTableCellRangeSelection: no expansion (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId})`),null;const r=Math.min(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),a=Math.max(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),i=Math.min(o.anchorLocation.cellIndex,o.focusLocation.cellIndex),l=Math.max(o.anchorLocation.cellIndex,o.focusLocation.cellIndex);e.logger?.info(`resolveTableCellRangeSelection: expanding r${o.anchorLocation.rowIndex}:c${o.anchorLocation.cellIndex}->r${o.focusLocation.rowIndex}:c${o.focusLocation.cellIndex} (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId}) range=[rows ${r}..${a}, cells ${i}..${l}]`);const s=Ay(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Ay(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[s.rowIndex]?.cells[s.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?My(d)[0]:void 0,g=u?My(u):[],f=g[g.length-1];return p&&f?{anchor:Z(p,0),focus:Z(f,Lt(f).length)}:null},n=t=>{const n=Oy(t,e);if(!n)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex+n.anchorCell.rowSpan-1,n.focusCell.visualRowIndex+n.focusCell.rowSpan-1),a=Math.min(n.anchorCell.visualColumnIndex,n.focusCell.visualColumnIndex),i=Math.max(n.anchorCell.visualColumnIndex+n.anchorCell.colSpan-1,n.focusCell.visualColumnIndex+n.focusCell.colSpan-1),l=n.tableLayout.filter(e=>e.visualRowIndex<=r&&e.visualRowIndex+e.rowSpan-1>=o&&e.visualColumnIndex<=i&&e.visualColumnIndex+e.colSpan-1>=a);return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),cells:l,zone:n.anchorLocation.zone}},o=t=>{const n=Oy(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Ay(n.anchorCell,n.focusCell);if(0===o)return null;const r=o<=0?n.anchorLocation:n.focusLocation,a=o<=0?n.focusLocation:n.anchorLocation;return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:a.cellIndex,zone:n.anchorLocation.zone}},r=t=>{const n=Oy(t,e);if(!n||n.anchorLocation.cellIndex!==n.focusLocation.cellIndex)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex);return o===r?null:{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),startRowIndex:o,endRowIndex:r,cellIndex:n.anchorLocation.cellIndex,zone:n.anchorLocation.zone}};return{resolveTableCellRangeSelection:t,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:r}}(e)}function Ey(e){if(e)for(const t of e.blocks){const e=Po(t)[0];if(e)return e}}function Ly(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Cy(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Ny(e){return function(e){const t=e=>({...e,style:e.style?{...e.style}:void 0,conditionalStyle:e.conditionalStyle?{...e.conditionalStyle}:void 0,mergeRevisionState:void 0,blocks:e.blocks.map(e=>To(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Ly(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=a.rows[o.rowIndex];if(!l)return n;const s=l.cells.slice(o.startCellIndex,o.endCellIndex+1);if(s.length<2)return n;const c=n.trackChangesEnabled?us():void 0,d={...s[0],colSpan:s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:s.flatMap(e=>e.blocks.map(e=>To(e))),...c?{style:{...s[0].style??{},revision:{...c,type:"merge",previous:{colSpan:s[0].colSpan,rowSpan:s[0].rowSpan,vMerge:s[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"horizontal",currentCellCount:1,previousCells:s.map(t)}}:{}};l.cells.splice(o.startCellIndex,s.length,d);const u=Ey(d);return u?ky(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Ly(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=[];for(let e=o.startRowIndex;e<=o.endRowIndex;e+=1){const t=a.rows[e],r=t?.cells[o.cellIndex];if(!t||!r||"continue"===r.vMerge||1!==r.blocks.length||"paragraph"!==r.blocks[0]?.type)return n;l.push(r)}if(l.length<2)return n;const s=Math.max(1,l[0].colSpan??1);if(!l.every(e=>Math.max(1,e.colSpan??1)===s))return n;const c=n.trackChangesEnabled?us():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>To(e))),...c?{style:{...l[0].style??{},revision:{...c,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"vertical",currentCellCount:1,previousCells:l.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=Gr([pr("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Ey(d);return u?ky(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Ty(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex]?.cells[a.cellIndex],s=Math.max(1,l?.rowSpan??1);if(!l||s<=1||"restart"!==l.vMerge)return n;const c=t(l),d=n.trackChangesEnabled?us():void 0,u=Math.max(1,l.colSpan??1);l.rowSpan=void 0,l.vMerge=void 0,d&&(l.style={...l.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},l.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:s-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):Gr([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=Gr([pr("")],u);t.cells[a.cellIndex]=n}const p=Ey(l);return p?ky(n,i,a.zone,p):n},i=n=>{const o=Ty(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex],s=l?.cells[a.cellIndex],c=Math.max(1,s?.colSpan??1);if(!l||!s||c<=1)return n;const d=t(s),u=n.trackChangesEnabled?us():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>To(e)),...u?{style:{...s.style??{},revision:{...u,type:"merge",previous:{colSpan:d.colSpan,rowSpan:d.rowSpan,vMerge:d.vMerge}}},mergeRevisionState:{revisionId:u.id,orientation:"horizontal",currentCellCount:c,previousCells:[d]}}:{}},...Array.from({length:c-1},()=>Gr([pr("")]))];l.cells.splice(a.cellIndex,1,...p);const g=Ey(p[0]);return g?ky(n,i,a.zone,g):n},l=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:l}}(e)}function $y(e,t){e.style={...e.style??{},revision:{...us(),type:t}}}function zy(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}function Hy(e,t,n){const o=zy(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=zy(r);if(e)return e}return gy(e)}function Wy(e){return function(e){const t=(t,n)=>{const o=Ty(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex];if(!l)return t;const s=Math.max(0,Math.min(r.rows.length,a.rowIndex+(n>0?1:0)));let c;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge))){const e=ln(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),l=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=ma(l.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<s&&e.visualRowIndex+e.rowSpan>s);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=Gr([pr("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return Gr([pr("")],t.colSpan)})),t.trackChangesEnabled&&$y(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=Hy(r,uy(c,d),c);return ky(t,i,a.zone,u)}c=ma(l.cells.map(e=>Gr([pr("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&$y(c,"insert"),r.rows.splice(s,0,c);const d=Hy(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return ky(t,i,a.zone,d)},n=t=>{const n=Ty(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(o.rows.length<=1&&!t.trackChangesEnabled)return t;const i=o.rows[r.rowIndex];if(!i)return t;if(t.trackChangesEnabled)return $y(i,"delete"),ky(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const l=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),s=l?ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=ln(o);for(const t of e)t.visualRowIndex<r.rowIndex&&t.visualRowIndex+t.rowSpan>r.rowIndex&&(t.cell.rowSpan=Math.max(1,t.cell.rowSpan??1)-1,t.cell.rowSpan<=1?(t.cell.rowSpan=void 0,t.cell.vMerge=void 0):t.cell.vMerge="restart")}o.rows.splice(r.rowIndex,1);const c=o.rows[Math.min(r.rowIndex,o.rows.length-1)],d=Hy(o,c?uy(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,cy(c)-1))):null);return ky(t,a,r.zone,d)},o=(t,n)=>{const o=Ty(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=ln(r).find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=(e?.visualColumnIndex??a.cellIndex)+(n>0?Math.max(1,e?.colSpan??1):0);for(const n of r.rows){const e=[];let r=0,a=!1;for(const i of n.cells){const n=Math.max(1,i.colSpan??1);if(!a&&o<=r){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.push(n),a=!0}!a&&r<o&&o<r+n?(e.push({...i,colSpan:n+1,...t.trackChangesEnabled?{style:{...i.style??{},revision:{...us(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=Hy(r,l?uy(l,o):null);return ky(t,i,a.zone,s)}const l=Math.max(0,Math.min(r.rows[0]?.cells.length??0,a.cellIndex+(n>0?1:0)));for(const e of r.rows){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=Hy(r,s);return ky(t,i,a.zone,c)},r=t=>{const n=Ty(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(dy(o)<=1)return t;if(t.trackChangesEnabled){const e=ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=uy(t,e);n&&$y(n,"delete")}return ky(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=[];let o=0;for(const r of t.cells){const t=Math.max(1,r.colSpan??1);e>=o&&e<o+t?t>1&&n.push({...r,colSpan:t-1>1?t-1:void 0}):n.push(r),o+=t}t.cells=n}const n=o.rows[r.rowIndex],i=Hy(o,n&&uy(n,Math.min(e,Math.max(0,cy(n)-1))));return ky(t,a,r.zone,i)}if(o.rows[0]?.cells.length<=1)return t;for(const e of o.rows)e.cells.splice(r.cellIndex,1);const i=o.rows[r.rowIndex],l=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],s=Hy(o,l);return ky(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function Uy(e){return function(e){const t=t=>{const n=e.resolveTableCellRangeSelection(t);return n?e.applySelectionToStatePreservingStructure(t,n):t},n=(n,o)=>{e.applyTransactionalState(r=>{const a=e.resolveSelectedTableCells(r);if(!a||a.cells.length<=1){const a=t(r);return a!==r&&e.logger?.info(`${o}: expanded selection to ${a.selection.anchor.paragraphId}[${a.selection.anchor.offset}]..${a.selection.focus.paragraphId}[${a.selection.focus.offset}]`),n(a)}const{blockIndex:i,tablePath:l,cells:s,zone:c}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${l.length} (${s.length} cells) in zone ${c}`);const d=[],u=[];for(const e of s){const t=e.cell.blocks.flatMap(Po);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p=n({...r,document:eo(d,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Z(d[0],0),focus:Z(d[d.length-1],Lt(d[d.length-1]).length)}}),g=Kr(p),f=l[l.length-1];if(!f)return r;const m=Cy(r,e.getTargetBlocks,{blockIndex:i,rowIndex:f.rowIndex,cellIndex:f.cellIndex,paragraphIndex:0,tablePath:l,zone:c});if(!m)return r;let h=0;for(let e=0;e<s.length;e+=1){const t=s[e],n=u[e]??0,o=g.slice(h,h+n);h+=n;const r=m.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=st(r.blocks,o))}return xy(r,m.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function jy(e){return function(e){const t=vy,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Dy({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=By({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Ny({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:C}=Wy({getTargetBlocks:t}),I=(e,n)=>Iy(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P}=Uy({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,logger:e.logger}),R=(t,n)=>{e.logger?.info(`insertTableCommand: ${t}x${n}`),e.applyTransactionalState(e=>function(e,t,n){const o=100/Math.max(1,n)+"%",r=e.trackChangesEnabled?us():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...Gr([pr("")]),style:{width:o}});const t=ma(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...bn(a),style:{width:"100%"}},l=nr(e,e.selection.focus),s=Fe(e.document),c=fo(e),d=io(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&Po(e).some(e=>e.id===l.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=s[c];if(!p)return e;const g={...p};let f=!1;if("header"===d){const e=u(p.header??[]);g.header=e.nextBlocks,f=e.found}else if("footer"===d){const e=u(p.footer??[]);g.footer=e.nextBlocks,f=e.found}else{const e=u(p.blocks);g.blocks=e.nextBlocks,f=e.found}if(!f)return e;const m=[...s];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:oe(Z(h,0))}}(e,t,n),{mergeKey:ji}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:C,getRowVisualWidth:cy,getTableVisualWidth:dy,findCellAtVisualColumn:uy,findFirstNavigableParagraphInTable:gy,updateBlocksInCurrentSection:xy,resolveAdjacentTableCellPosition:my,applyTableAwareParagraphEdit:I,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P,insertTableCommand:R}}(e)}function Vy(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function Ky(e,t){let n=null;const o=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=Vy(),i=i=>{if(!a.owns(i))return;const l=n;if(!l)return;const s=t.zoomFactor?.()??1,c=(i.clientX-l.startClientX)/s,d=(i.clientY-l.startClientY)/s,u=e.getMaxWidth(t.state,l.paragraphId),{width:p,height:g}=Ia(l,c,d,i.shiftKey,u),f=o(t.state,l.paragraphId,l.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,l.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,l)},l=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Qb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),s(),t.focusInput()},s=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)};return{start:(s,c,d,u,p)=>{const g=o(p,s,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:s,paragraphOffset:c,handleDirection:d,startClientX:u.clientX,startClientY:u.clientY,startWidth:f.width,startHeight:f.height,aspectRatio:f.width/f.height,initialState:t.cloneState(p)},a.claim(u),window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l))},stop:s}}function _y(e,t){let n=null;const o=Vy(),r=r=>{if(!o.owns(r))return;const a=n;if(!a)return;let i=((180*Math.atan2(r.clientY-a.centerY,r.clientX-a.centerX)/Math.PI+90)%360+360)%360;r.shiftKey&&(i=15*Math.round(i/15)%360);const l=((e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);l?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,l),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Qb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),i(),t.focusInput()},i=()=>{n=null,o.release(),window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)};return{start:(e,i,l,s)=>{const c=l.currentTarget.closest(".oasis-editor-selection-overlay");if(!c)return;const d=c.getBoundingClientRect();n={paragraphId:e,paragraphOffset:i,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:t.cloneState(s)},o.claim(l),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function Xy(e,t){return Math.max(1e-4,1-e-t)}function Gy(e,t,n,o){const r=Math.max(.01,1-e-t),a=Math.max(0,Math.min(n,.99-t)),i=Math.max(0,Math.min(o,.99-a));return a+i>=.99?{near:Math.max(0,.99-r-t),far:t}:{near:a,far:i}}function qy(e){let t=null;const n=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=Vy(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const l=e.zoomFactor?.()??1,s=(a.clientX-i.startClientX)/l,c=(a.clientY-i.startClientY)/l,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=Xy(a,l)/o,d=Xy(i,s)/r,u=1-a-l,p=1-i-s,g=Math.max(0,Math.min(1-u,a-t*c)),f=Math.max(0,Math.min(1-p,i-n*d));return{crop:{left:g,right:Math.max(0,1-u-g),top:f,bottom:Math.max(0,1-p-f)},width:Math.round(o),height:Math.round(r)}}(i,s,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=Xy(a,l)/o,d=Xy(i,s)/r,u=Ae(e.handleDirection,"x"),p=Ae(e.handleDirection,"y");let g=a,f=l,m=o;if(0!==u)if(u<0){m=gt(o-t,24,o+a/c);const e=Gy(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=gt(o+t,24,o+l/c);const e=Gy(a,l,a,l-(m-o)*c);g=e.near,f=e.far}let h=i,b=s,y=r;if(0!==p)if(p<0){y=gt(r-n,24,r+i/d);const e=Gy(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=gt(r+n,24,r+s/d);const e=Gy(i,s,i,s-(y-r)*d);h=e.near,b=e.far}return{crop:{left:g,top:h,right:f,bottom:b},width:Math.round(m),height:Math.round(y)}}(i,s,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(yb(o(e.state,u),{crop:d.crop,width:d.width,height:d.height})):e.logger.warn("image crop:missing paragraph",i)},i=()=>{const n=t;n&&e.updateHistoryState(t=>({...t,undoStack:Qb(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),l(),e.focusInput()},l=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},s=(l,s,c,d,u,p)=>{const g=n(u,l,s);if(!g)return;const f=mb(o(u,g)),m=f&&qn(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:l,paragraphOffset:s,handleDirection:c,startClientX:d.clientX,startClientY:d.clientY,startWidth:m.width,startHeight:m.height,startCrop:h,initialState:e.cloneState(u),mode:p},r.claim(d),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)};return{start:(e,t,n,o,r)=>s(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>s(e,t,"se",n,o,"move"),stop:l}}function Yy(e){return function(e){const[t,n]=an(!1),[o,r]=an(!1),[a,i]=an(null);we(()=>{o()&&!m(e.state)&&r(!1)});const l=()=>{m(e.state)?r(e=>!e):r(!1)},[s,c]=an({x:0,y:0}),[d,u]=an(null);let p=null,g=null,f=null;const m=e=>{const t=Wn(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=Kr(e)[t.startIndex];if(!n)return null;let o=0;for(const r of n.runs){const a=o;if(o+=r.text.length,"image"===r.kind&&1===r.text.length&&a===t.startParagraphOffset)return{paragraph:n,run:r,startOffset:a,width:r.image.width,height:r.image.height,src:Ze(e.document,r.image.src)}}return null},h=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),b=()=>{f||(f=document.createElement("style"),f.setAttribute("data-oasis-image-drag-cursor",""),f.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(f))},y=()=>{f&&(f.remove(),f=null),document.body.style.cursor=""},v=Vy(),x=()=>{y(),g=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P)},w=()=>{x()},S=Ky({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>hb(e,t,n),getMaxWidth:(t,n)=>Rb(e.surfaceRef(),t.document,n,t.activeSectionIndex??0)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),C=_y({label:"image",applyRotate:(e,t)=>function(e,t){const n=Sb(t);return Tb(e,e=>({...e,rotation:n}))}(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),I=qy({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),k=t=>{if(!v.owns(t))return;let o=p;if(!o){const r=g;if(!r)return;if(Math.abs(t.clientX-r.startClientX)+Math.abs(t.clientY-r.startClientY)<4)return;o={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},p=o,g=null,n(!0),b(),e.logger.info(`image drag:start ${o.paragraphId}@${o.paragraphOffset} client=(${t.clientX},${t.clientY})`)}c({x:t.clientX,y:t.clientY}),i({...o}),u(h(t.clientX,t.clientY))},P=t=>{if(!v.owns(t))return;const n=p;if(n||g){if(n){const o=h(t.clientX,t.clientY);o?(e.logger.info(`image drag:done ${n.paragraphId} -> ${o.paragraphId}:${o.runId}[${o.offset}]`),e.applyTransactionalState(e=>Pb(e,o),{mergeKey:Vi})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},R=(t,o,r,a)=>{const l=r.currentTarget,s=a?{left:a.left,top:a.top,width:a.width,height:a.height}:l?.getBoundingClientRect();if(!s)return;const d=m(e.state);g={paragraphId:t,paragraphOffset:o,startClientX:r.clientX,startClientY:r.clientY,src:d?.src??"",width:d?.width??s.width,height:d?.height??s.height,offsetX:r.clientX-s.left,offsetY:r.clientY-s.top},p=null,c({x:r.clientX,y:r.clientY}),n(!1),i(null),u(null),v.claim(r),window.addEventListener("pointermove",k),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P)},B=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=T(e.state.document).find(e=>e.id===t);r&&e.applyState(Aa(e.state,{anchor:Z(r,n),focus:Z(r,n+1)})),R(t,n,o),e.focusInputAfterPointerSelection()},A=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,o,r,e.state)},M=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.start(t,n,o,e.state)},F=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),I.start(t,n,o,r,e.state)},O=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),I.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:l,draggedImageInfo:a,mousePos:s,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:R,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:C.stop,stopImageCrop:I.stop,handleImagePointerDown:B,handleImageResizeHandlePointerDown:A,handleImageRotateHandlePointerDown:M,handleImageCropHandlePointerDown:F,handleImageCropBodyPointerDown:O}}(e)}function Zy(e){return function(e){const t=e=>{const t=ay(e),n=t&&Er(t.run);return n?{width:n.width,height:un(n,e,0)}:null},n=Ky({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>sy(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=Rb(e.surfaceRef(),n.document,o,n.activeSectionIndex??0),a=t(n);return a?Math.max(r,a.width):r}},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),o=_y({label:"text box",applyRotate:(e,t)=>iy(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),r=(t,o,r,a)=>{a.preventDefault(),a.stopPropagation(),n.start(t,o,r,a,e.state)},a=(t,n,r)=>{r.preventDefault(),r.stopPropagation(),o.start(t,n,r,e.state)};return{handleTextBoxResizeHandlePointerDown:r,handleTextBoxRotateHandlePointerDown:a,stopTextBoxResize:n.stop,stopTextBoxRotate:o.stop}}(e)}function Jy(e){return function(e){const[t,n]=an(void 0),o=()=>{n(void 0)};we(()=>{zr(e.state().selection)||o()});const r=(e,t)=>{n(n=>{const o={...n??{}};return null==t||""===t?delete o[e]:o[e]=t,Object.keys(o).length>0?o:void 0})},a=(e,t)=>{n(n=>{const o={...n??{}};return o[e]=t,"superscript"===e&&t&&(o.subscript=!1),"subscript"===e&&t&&(o.superscript=!1),o})},i=()=>{const n=ie(e.state()),o=t();return zr(e.state().selection)&&o?{...n,bold:o.bold??n.bold,italic:o.italic??n.italic,underline:o.underline??n.underline,underlineStyle:void 0!==o.underlineStyle?String(o.underlineStyle??""):n.underlineStyle,strike:o.strike??n.strike,superscript:o.superscript??n.superscript,subscript:o.subscript??n.subscript,fontFamily:o.fontFamily??n.fontFamily,fontSize:void 0!==o.fontSize&&null!==o.fontSize?String(o.fontSize):n.fontSize,color:o.color??n.color,highlight:o.highlight??n.highlight,textShading:o.shading??n.textShading,link:o.link??n.link,characterStyleId:void 0!==o.styleId&&null!==o.styleId?String(o.styleId):n.characterStyleId}:n},l=(t,n)=>{if(zr(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),r(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},s=t=>{if(zr(e.state().selection)){const n=!i()[t];return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),a(t,n),void e.focusInput()}e.commandsController().applyBooleanStyleCommand(t)},c=t=>{if(zr(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),n(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:o,toolbarStyleState:i,applyToolbarValueStyleCommand:l,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:s}}(e)}function Qy(e,t,n={}){if(!t)return[];const o=[],r=T(e),{matchCase:a=!1,wholeWord:i=!1}=n,l=a?"g":"gi";let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const c=new RegExp(s,l);return r.forEach((e,t)=>{const n=Lt(e);let r;for(c.lastIndex=0;null!==(r=c.exec(n));){const n=r.index,a=r.index+r[0].length;o.push({anchor:Z(e,n),focus:Z(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function ev(e,t,n,o={}){const r=Qy(e.document,t,o);if(0===r.length)return e;let a=e;for(let i=r.length-1;i>=0;i-=1){const e=r[i];a=Aa(a,{anchor:e.anchor,focus:e.focus}),a=za(a,n)}return a}function tv(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*tt+(r<e?e-r:r>i?r-i:0)}function nv(e,t,n){if(0===e.slots.length)return{offset:e.startOffset,score:Number.POSITIVE_INFINITY};let o=e.slots[0].offset,r=Number.POSITIVE_INFINITY,a=e.slots[0].left,i=e.slots[0].top,l=e.slots[0].height;for(const s of e.slots){const e=n<s.top?s.top-n:n>s.top+s.height?n-(s.top+s.height):0,c=Math.abs(t-s.left),d=e*tt+c;d<r&&(r=d,o=s.offset,a=s.left,i=s.top,l=s.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:l}}function ov(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=nv(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function rv(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function av(e){const{snapshot:t,state:n}=e,o=e.pierce??!1,r=e.zoomFactor&&e.zoomFactor>0?e.zoomFactor:1,a=t.surfaceRect,i=a.left+(e.clientX-a.left)/r,l=a.top+(e.clientY-a.top)/r,s=function(e,t,n){if(0===e.length)return null;let o=e[0],r=Number.POSITIVE_INFINITY;for(const a of e){const e=tv(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,l);if(!s)return null;const c=function(e,t){const n=t-e.top;return n<e.bodyTop?"header":void 0!==e.footnoteSeparatorTop&&n>=e.footnoteSeparatorTop&&n<(e.footerTop??e.height)?"footnote":n>=e.bodyBottom?"footer":"main"}(s,l),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const l=e.floatingTextBoxes[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&o>=l.left&&o<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(t,s.index,c,i,l,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&d.startOffset>=e.startOffset&&d.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(d.startOffset,n.endOffset)),t=Z(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:d.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:d.left,top:d.top,height:d.height},textBox:{paragraphId:d.paragraphId,paragraphOffset:e,startOffset:d.startOffset,endOffset:d.endOffset,left:d.left,top:d.top,width:d.width,height:d.height}}}}const u=function(e,t,n,o,r,a){for(let i=e.floatingImages.length-1;i>=0;i-=1){const l=e.floatingImages[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&rv(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&rv(o,r,i))return i;return null}(t,s.index,c,i,l,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&u.startOffset>=e.startOffset&&u.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(u.startOffset,n.endOffset)),t=Z(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:u.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},image:{paragraphId:u.paragraphId,paragraphOffset:e,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const p=function(e,t,n){if(0===e.length)return null;let o=null;for(const i of e)for(const e of i.lines){const r=e.top-2,a=e.top+e.height+2;if(n<r||n>a)continue;const{offset:l,score:s,slotLeft:c,slotTop:d,slotHeight:u}=nv(e,t,n);(!o||s<o.score)&&(o={paragraph:i,offset:l,score:s,caretViewport:void 0!==c&&void 0!==d&&void 0!==u?{left:c,top:d,height:u}:void 0})}if(o)return{paragraph:o.paragraph,offset:o.offset,caretViewport:o.caretViewport};let r=null,a=Number.POSITIVE_INFINITY;for(const i of e){const e=tv(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),t,n);e<a&&(a=e,r=i)}return r?{paragraph:r,offset:ov(r,t,n),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(t.paragraphs.filter(e=>e.pageIndex===s.index&&e.zone===c),i,l);if(!p){const e=n.selection.focus.paragraphId,o=n.selection.focus.offset,r=function(e,t,n,o,r){return e.unsupportedRegions.find(e=>e.pageIndex===t&&e.zone===n&&o>=e.left&&o<=e.left+e.width&&r>=e.top&&r<=e.top+e.height)?.reason??null}(t,s.index,c,i,l);return{zone:c,paragraphId:e,paragraphOffset:o,position:{...n.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:r??"zone-without-paragraph"}}const g=p.paragraph,f=Math.max(0,Math.min(p.offset,g.textLength)),m=Z(g.paragraph,f);return{zone:c,footnoteId:g.footnoteId,paragraphId:g.paragraphId,paragraphOffset:f,position:m,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:g.tableCell?.anchorPosition,caretViewport:p.caretViewport}}function iv(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),l=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){Ai&&(Fi=e?function(e){return{surfaceRect:{left:e.surfaceRect.left,top:e.surfaceRect.top,width:e.surfaceRect.width,height:e.surfaceRect.height},pages:(t=e.pages,t.map(e=>({index:e.index,left:e.left,top:e.top,width:e.width,height:e.height,bodyTop:e.bodyTop,bodyBottom:e.bodyBottom}))),paragraphs:e.paragraphs.map(e=>{return{paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,textLength:e.textLength,left:e.left,top:e.top,width:e.width,height:e.height,lines:(t=e.lines,t.map(e=>{return{startOffset:e.startOffset,endOffset:e.endOffset,top:e.top,height:e.height,slots:(t=e.slots,t.map(e=>({offset:e.offset,left:e.left,top:e.top,height:e.height})))};var t})),tableCell:e.tableCell?{tableId:e.tableCell.tableId,rowIndex:e.tableCell.rowIndex,cellIndex:e.tableCell.cellIndex,left:e.tableCell.left,top:e.tableCell.top,width:e.tableCell.width,height:e.tableCell.height}:void 0,verticalMode:e.verticalMode};var t}),inlineImages:e.inlineImages.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height})),inlineTextBoxes:e.inlineTextBoxes.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height,rotation:e.rotation})),unsupportedRegions:e.unsupportedRegions.map(e=>({...e}))};var t}(e):null)}(l),!l)return Li(null),null;const s=av({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return Li(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var lv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],sv=/* @__PURE__ */new Map;function cv(){return lv.map(e=>({...e}))}var dv=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function uv(e,t,n){const[o,r]=e,[a,i]=t,[l,s]=n,c=l-a,d=s-i,u=c*c+d*d;return 0===u?Math.hypot(o-a,r-i):Math.abs(c*(i-r)-d*(a-o))/Math.sqrt(u)}function pv(e,t){if(e.length<3)return e.slice();let n=0,o=0;const r=e[0],a=e[e.length-1];for(let s=1;s<e.length-1;s+=1){const t=uv(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=pv(e.slice(0,o+1),t),l=pv(e.slice(o),t);return[...i.slice(0,-1),...l]}function gv(e,t,n){let o=0;for(let s=0;s<e.length;s+=1)1===e[s]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return cv();const r=function(e,t,n){const o=(o,r)=>o>=0&&o<t&&r>=0&&r<n&&1===e[r*t+o];let r=-1,a=-1;for(let u=0;u<n&&a<0;u+=1)for(let n=0;n<t;n+=1)if(1===e[u*t+n]){r=n,a=u;break}if(r<0)return[];const i=[];let l=r,s=a,c=6;const d=t*n*4;for(let u=0;u<d;u+=1){let e=!1;for(let t=1;t<=8;t+=1){const n=(c+t)%8,[r,a]=dv[n],d=l+r,u=s+a;if(o(d,u)){i.push([l,s]),c=(n+4)%8,l=d,s=u,e=!0;break}}if(!e){i.push([l,s]);break}if(l===r&&s===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return cv();const a=.012*Math.max(t,n);let i=pv(r,a),l=a;for(;i.length>40;)l*=1.6,i=pv(r,l);return i.length<3?cv():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function fv(e){const t=e.src,n=sv.get(t);if(n)return n.map(e=>({...e}));const o=function(e){const t=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(!t||!n)return null;const o=Math.min(1,256/Math.max(t,n)),r=Math.max(1,Math.round(t*o)),a=Math.max(1,Math.round(n*o)),i=document.createElement("canvas");i.width=r,i.height=a;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(e,0,0,r,a);try{s=l.getImageData(0,0,r,a).data}catch{return null}const c=new Uint8Array(r*a);let d=0;for(let u=0;u<c.length;u+=1)s[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return cv();const r=gv(o.mask,o.width,o.height);return sv.set(t,r),r.map(e=>({...e}))}function mv(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>mb(t())?"image":ay(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},l=(e,n)=>{const r=Ze(t().document,n),a=t=>{const n=fv(t);o(t=>function(e,t,n){const o=Kr(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...pn(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Gn(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:pn(e));return r?Ie(e,a,$(a,Wn(e))):e}(t,e,n),{mergeKey:tl})},i=Zt(r,()=>{i.naturalWidth>0&&a(i)});i.complete&&i.naturalWidth>0&&a(i)};return{target:a,preset:()=>{const e=a();return"image"===e?function(e){const t=mb(e),n=t&&qn(t.run);return n?pb(n.floating):null}(t()):"textBox"===e?function(e){const t=ay(e),n=t&&Er(t.run);return n?pb(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=mb(e),n=t&&qn(t.run);return fb(n?.floating)}(t()):"textBox"===e&&function(e){const t=ay(e),n=t&&Er(t.run);return fb(n?.floating)}(t())},setPreset:e=>{if(i(Vl,(t,n)=>"image"===n?function(e,t){return kb(e,e=>ub(e,t))}(t,e):function(e,t){return ly(e,e=>ub(e,t))}(t,e)),"tight"===e||"through"===e){const e=mb(t()),n=e&&qn(e.run);n&&!n.wrapPolygon&&l(e.run.id,n.src)}},setFixedPosition:e=>i(Kl,(t,n)=>"image"===n?function(e,t){return kb(e,e=>e?gb(e,t):e)}(t,e):function(e,t){return ly(e,e=>e?gb(e,t):e)}(t,e))}}function hv(e){return function(e){const t=t=>{const n=Ba(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Oa(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},n=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Ba(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Oa(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),e.focusInput()}},o=t=>{if(e.isReadOnly())return void t.preventDefault();const n=e.consumePasteMode?.();if(e.forcePlainTextPaste()||"text"===n){e.setForcePlainTextPaste(!1);const n=t.clipboardData?.getData("text/plain")??"";return 0===n.length?void t.preventDefault():(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e,n))),t.currentTarget.value="",void e.focusInput())}const o="merge"!==n?sb(t.clipboardData):null;if(o)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(o),t.currentTarget.value="",void e.focusInput();const r=ni(t.clipboardData?.getData("text/html")??""),a="merge"===n?ti(e.state(),r):r;if(a.length>0)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e,a))),t.currentTarget.value="",void e.focusInput();const i=t.clipboardData?.getData("text/plain")??"";0!==i.length&&(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e,i))),t.currentTarget.value="",e.focusInput())},r=t=>{if(e.isReadOnly())return void t.preventDefault();const n=sb(t.dataTransfer);if(!n)return;t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??e.state().selection.focus;e.insertImageFromFile(n,o),e.focusInput()};return{handleCopy:t,handleCut:n,handlePaste:o,handleDrop:r}}(e)}var bv=/* @__PURE__ */new WeakMap;function yv(e,t){return function(e){return $e(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function vv(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=bv.get(a);if(i)return i;const l=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(const d of a.paragraphs){const e=d.tableCell;if(!e)continue;const t=`${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,n=l.get(e.tableId)??/* @__PURE__ */new Map;let o=n.get(t);o||(o={tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,pageIndex:d.pageIndex,left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height,width:e.width,height:e.height,contentMinWidth:0,contentMinHeight:0},n.set(t,o),l.set(e.tableId,n));const r=d.lines.flatMap(e=>e.slots.map(e=>e.left)),a=d.lines.map(e=>e.top+e.height),i=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,u=d.lines.length>0?d.lines[0].top:d.top,p=a.length>0?Math.max(...a):d.top+d.height,g=`${e.tableId}:${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,f=s.get(g);f?(f.left=Math.min(f.left,i),f.top=Math.min(f.top,u),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):s.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of l.entries())for(const e of u.values()){const t=s.get(`${d}:${e.pageIndex}:${e.rowIndex}:${e.cellIndex}`);t&&(e.contentMinWidth=Math.max(0,t.right-t.left),e.contentMinHeight=Math.max(0,t.bottom-t.top))}const c=[];for(const[d,u]of l.entries()){const e=Array.from(u.values());if(0===e.length)continue;const t=Math.min(...e.map(e=>e.left)),n=Math.min(...e.map(e=>e.top)),o=Math.max(...e.map(e=>e.right)),r=Math.max(...e.map(e=>e.bottom));c.push({tableId:d,cells:e,bounds:{left:t,top:n,right:o,bottom:r,width:Math.max(1,o-t),height:Math.max(1,r-n)}})}return bv.set(a,c),c}function xv(e,t,n,o,r,a){const i=vv(t,n,o,r,a);if(0===i.length)return null;let l=null;for(const d of i)if(!(e.clientX<d.bounds.left-4||e.clientX>d.bounds.right+4||e.clientY<d.bounds.top-4||e.clientY>d.bounds.bottom+4))for(const t of d.cells){const n=e.clientY>=t.top-4&&e.clientY<=t.bottom+4,o=e.clientX>=t.left-4&&e.clientX<=t.right+4;if(n){const n=Math.abs(e.clientX-t.left);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"bottom",distance:o})}}if(!l)return null;const s=yv(n,l.geometry.tableId);if(!s)return null;const c=ln(s).find(e=>e.rowIndex===l.cell.rowIndex&&e.cellIndex===l.cell.cellIndex);return c?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:c,tableGeometry:l.geometry}:null}var wv=1/.75;function Sv(e){return.75*e}function Cv(e){return e*wv}var Iv=zs;function Tv(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Cv(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Cv(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Cv(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Cv(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Cv(e.style.borderRight.width)):1)}function kv(e,t,n){const o=Math.max(1,e.rows.length),r=n.bounds.height/o,a=Array(o).fill(r),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(let l=0;l<o;l+=1){const n=Iv(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Cv(n));continue}const o=t.find(e=>e.rowIndex===l&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[l]=Math.max(1,e.height))}}return a}function Pv(e,t,n){const o=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),r=o-1,a=Array(o).fill(n.bounds.width/o),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));if(e.gridCols&&e.gridCols.length>=o)for(let s=0;s<o;s+=1)a[s]=Math.max(1,Cv(e.gridCols[s]));else for(const s of t){if(1!==s.colSpan)continue;const e=i.get(`${s.rowIndex}:${s.cellIndex}`);e&&(a[s.visualColumnIndex]=Math.max(1,e.width))}const l={};for(let s=0;s<o;s+=1)l[s]=Math.max(10,Sv(a[s]));return{widthsPt:l,maxColumnIndex:r}}function Rv(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Cv(10),r=Math.max(Cv(10),t.minRowHeightPx??Cv(10)),a=Math.max(10,Sv(Math.max(r,o+n)));return function(e,t,n,o){return $s(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Bv(e){const t=e();if(!t)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const n=t.getBoundingClientRect();return{left:n.left,top:n.top,width:Math.max(0,n.width),height:Math.max(0,n.height)}}var Av=null;function Mv(e,t){Av=t,e?(document.body.classList.add("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")):(document.body.classList.add("oasis-editor-hover-row-resize"),document.body.classList.remove("oasis-editor-hover-col-resize"))}function Fv(e){e&&Av!==e||(Av=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Ov(e,t){Mv(e,t)}function Dv(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Ev(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Lv(e){const[t,n]=an(null);let o=null,r=null,a=null,i=null;const l={},s=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Fv();const i=xv(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Mv("left"===i.side||"right"===i.side,l):Fv()},c=Vy(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Dv(u)))},u=()=>{a=null;const o=i;i=null;const r=t();o&&r&&n({...r,currentPos:"column"===r.type?o.clientX:o.clientY,guideBounds:Bv(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Ev(o),o=null),null!==a&&(Ev(a),a=null),n(null),Fv(l),c.release(),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)},g=n=>{if(!c.owns(n))return;const o=t();if(!o)return;const r=e.zoomFactor?.()??1,a=(("column"===o.type?n.clientX:n.clientY)-o.initialPos)/r;Math.abs(a)>=2&&e.applyTransactionalState(e=>"row"===o.type?Rv(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=Sv(n),r=t.maxColumnIndex??t.index,a={...t.columnWidthsPt??{}};for(let m=0;m<=r;m+=1)void 0===a[m]&&(a[m]=10);const i=t.minColumnWidthsPx??{},l=a[t.index]??10,s=Math.max(10,Sv(i[t.index]??Cv(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(s,l-o),i=l-r;n+i<0&&(i=-n,r=l-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Hs(e,t.tableId,a,c,d)}let c=Math.max(s,l+o);const d=t.index===r;if(d)a[t.index]=c;else{const e=t.index+1,n=a[e]??10,o=Math.max(10,Sv(i[e]??Cv(10)));let r=n-(c-l);r<o&&(r=o,c=l+(n-o),c=Math.max(s,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=yv(e,t.tableId),g=Iv(p?.style?.width),f=d?u:null!==g?g:void 0;return Hs(e,t.tableId,a,f)}(e,o,a)),p()};return{resizing:t,handlePointerMove:e=>{c.owns(e)&&(t()||(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Dv(s))))},handlePointerDown:t=>{r=null,null!==o&&(Ev(o),o=null),Fv();const a=e.surfaceRef();if(!a)return!1;const i=xv(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=ln(i.tableNode);if("left"===i.side||"right"===i.side){const o="left"===i.side&&0===i.layoutEntry.visualColumnIndex,r=o?0:"left"===i.side?i.layoutEntry.visualColumnIndex-1:i.layoutEntry.visualColumnIndex+i.layoutEntry.colSpan-1;if(r<0)return!1;const a="left"===i.side?i.rect.left:i.rect.right,{widthsPt:p,maxColumnIndex:f}=Pv(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Cv(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const l of n){if(1!==l.colSpan)continue;if(!i.get(`${l.rowIndex}:${l.cellIndex}`))continue;const n=t.rows[l.rowIndex]?.cells[l.cellIndex];if(!n)continue;const o=l.visualColumnIndex,s=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,ca(n,e.document.styles)),1);a[o]=Math.max(s,c+Tv(n)+12,r)}return a}(s,i.tableNode,u,i.tableGeometry);return n({type:"column",tableId:i.tableId,index:r,initialPos:a,currentPos:a,columnWidthsPt:p,maxColumnIndex:f,minColumnWidthsPx:m,resizeFromLeftEdge:o,initialTableIndentLeftPt:Iv(i.tableNode.style?.indentLeft)??0,guideBounds:Bv(e.viewportRef)}),Ov(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=kv(i.tableNode,u,i.tableGeometry),f="top"===i.side?i.layoutEntry.visualRowIndex-1:i.layoutEntry.visualRowIndex+i.layoutEntry.rowSpan-1;if(f<0||f>=p.length)return!1;const m="top"===i.side?i.rect.top:i.rect.bottom,h=function(e,t,n,o){const r=e.rows[o];if(!r)return Cv(10);const a=Cv(10);let i=a;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===l);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===l);a&&(i=Math.max(i,a.contentMinHeight+4))}return Math.max(a,i)}(i.tableNode,u,i.tableGeometry,f);return n({type:"row",tableId:i.tableId,index:f,initialPos:m,currentPos:m,initialRowHeightPx:p[f],minRowHeightPx:h,guideBounds:Bv(e.viewportRef)}),Ov(!1,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var Nv=null;function $v(e){const t=(e.bounds.width+(e.currentClientX-e.startClientX))/e.bounds.width,n=(e.bounds.height+(e.currentClientY-e.startClientY))/e.bounds.height,o=Object.values(e.widthsPt),r=o.length>0?Math.min(...o):1,a=r>0?10/r:0,i=Cv(10),l=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,s=l>0?i/l:0;return{scaleX:Math.max(a,t),scaleY:Math.max(s,n)}}function zv(e){const[t,n]=an(null);let o=null,r=null;const a={},i=Vy(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Dv(s)))},s=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(Ev(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Nv===a&&(Nv=null,"nwse-resize"===document.body.style.cursor&&(document.body.style.cursor=""))},d=n=>{if(!i.owns(n))return;const o=t();if(o){const t=Math.abs(n.clientX-o.startClientX),r=Math.abs(n.clientY-o.startClientY);if(t>=2||r>=2){const t={...o,currentClientX:n.clientX,currentClientY:n.clientY},{scaleX:r,scaleY:a}=$v(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const s of Object.keys(t.widthsPt)){const e=Number(s);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=Hs(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,Sv(e*o))}),$s(i,t.tableId,l)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=$v(e);return{left:e.bounds.left,top:e.bounds.top,width:e.bounds.width*n,height:e.bounds.height*o}},handlePointerDown:(t,o)=>{const r=e.surfaceRef();if(!r)return;const s=vv(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=yv(e.state(),t);if(!s||!c)return;const u=ln(c),{widthsPt:p}=Pv(c,u,s),g=kv(c,u,s),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:s.bounds.left,top:s.bounds.top,width:Math.max(1,s.bounds.width),height:Math.max(1,s.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),Nv=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var Hv=null;function Wv(e,t,n,o){if(!e)return null;for(const r of e)if("table"===r.type){if(r.id===t)return{table:r,nested:n,movableTopLevelStory:o};for(const e of r.rows)for(const n of e.cells){const e=Wv(n.blocks,t,!0,!1);if(e)return e}}return null}function Uv(e,t){for(const n of Fe(e)){for(const e of[n.blocks,n.header,n.footer]){const n=Wv(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=Wv(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=Wv(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=Wv(n.blocks,t,!1,!1);if(e)return e}return null}function jv(e){return function(e){const[t,n]=an(!1),[o,r]=an(null),[a,i]=an(null),[l,s]=an(0),[c,d]=an(0),[u,p]=an({x:0,y:0});let g=null,f=null;const m={},h=(e,t)=>e===t||null!==e&&null!==t&&e.paragraphId===t.paragraphId&&e.runId===t.runId&&e.offset===t.offset,b=e=>{i(t=>h(t,e)?t:e)},y=Vy(),v=()=>{f=null,null!==g&&(Ev(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),Hv===m&&(Hv=null,"grabbing"===document.body.style.cursor&&(document.body.style.cursor=""))},x=()=>{g=null;const n=f;if(f=null,!n||!t())return;p({x:n.clientX,y:n.clientY});const r=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),a=o()?.tableId;r&&a&&function(e,t,n){const o=Uv(e,n);return Boolean(o?.table&&Po(o.table).some(e=>e.id===t))}(e.state().document,r.paragraphId,a)?b(null):b(r)},w=e=>{if(y.owns(e)){if(!t()){if(Math.abs(e.clientY-l())<=4)return;n(!0),Hv=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Dv(x))}},S=n=>{if(!y.owns(n))return;const r=o();if(t()){const t=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),o=r?.tableId;o&&e.applyTransactionalState(e=>{const r=Uv(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return Es(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*ar,y:(t.y??0)+(n.clientY-l())*ar,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?M(e,o,t):e})}v(),e.focusInput()};return{dragging:t,draggedTableInfo:o,mousePos:u,dropTargetPos:a,handlePointerDown:(e,t)=>{t.preventDefault(),t.stopPropagation();const o=t.currentTarget.getBoundingClientRect(),a=o;r({tableId:e,width:a.width,height:a.height,offsetX:t.clientX-o.left,offsetY:t.clientY-o.top}),s(t.clientY),d(t.clientX),p({x:t.clientX,y:t.clientY}),n(!1),i(null),y.claim(t),window.addEventListener("pointermove",w),window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)},stop:v}}(e)}var Vv=e=>"touch"===e.pointerType;function Kv(e,t){if(!e||0===e.length){const e=sa(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Po(n)[0]??null,blocks:e}}function _v(e,t,n){const o=T(e.document).filter(t=>{const o=Jr(e.document,t.id);return null!==o&&o.zone===n}),r=o.findIndex(e=>e.id===t.id),a=r>=0?o[r+1]:void 0;return{start:Z(t,0),end:a?Z(a,0):Z(t,Lt(t).length)}}function Xv(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,l=0,s=0,c=null,d=0,u=0,p=0,g=null,f=null;const m=e=>"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16),h=e=>{"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)},b=(t,n,o,r)=>{const a=n!==(t.activeZone??"main"),i="footnote"===n&&r?Jr(o.document,r.paragraphId)?.footnoteId:void 0,l="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!l)return void e.applyState(o);let s=o.document,c=t.activeSectionIndex??0;if(!s.sections||0===s.sections.length){const e=sa("header"),t=sa("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:Yt(s.pageSettings??jt),header:[e],footer:[t]}]},c=0}const d=s.sections,u=d[c];let p=u.header,g=u.footer,f=null;if("header"===n){const e=Kv(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=Kv(g,"footer");f=e.paragraph,g=e.blocks}if(p!==u.header||g!==u.footer){const e=[...d];e[c]={...u,header:p,footer:g},s={...s,sections:e}}const m=r||(f?Z(f,0):o.selection.anchor);e.applyState({...o,document:s,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:n,activeFootnoteId:"footnote"===n?i:void 0})},y=t=>{const n=e.state(),o=n.selection,r=fo(n),a=St(n.document,o.anchor.paragraphId,r),i=St(n.document,o.focus.paragraphId,r),l=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";e.logger.debug(`${t} ${o.anchor.paragraphId}[${o.anchor.offset}]→${o.focus.paragraphId}[${o.focus.offset}] [${l}→${s}]`)},v=()=>{f?.longPressHandle&&clearTimeout(f.longPressHandle),f=null},x=()=>{t=null,o=null,g=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",k)},w=e=>{g=e,window.addEventListener("pointermove",I),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",k)},S=()=>{if(n=null,!t)return;const r=o;if(o=null,!r)return;const a=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(Jr(i.document,t.paragraphId)?.sectionIndex!==Jr(i.document,a.paragraphId)?.sectionIndex)return;const l=Aa(i,{anchor:t,focus:a.position});b(i,a.zone,l,a.position),y("selection:drag")},C=()=>{o&&(null!==n&&(h(n),n=null),S())},I=e=>{null!==g&&e.pointerId!==g||(!f||f.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(S))):Math.hypot(e.clientX-f.clientX,e.clientY-f.clientY)>20&&x())},T=t=>{if(null===g||t.pointerId===g){if(f&&!f.longPressFired){const n=f,o=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return v(),x(),void(o&&(D(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}C(),y("selection:end"),x(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},k=e=>{null!==g&&e.pointerId!==g||x()},P=(n,o,r)=>{if(r<2)return t=null,x(),void e.focusInputAfterPointerSelection();t=null,o.resolvedFromParagraph?b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position):b(n,o.zone,n),x(),e.focusInputAfterPointerSelection()},R=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=Z(r,o.textBox.startOffset),i=Z(r,o.textBox.endOffset);b(n,o.zone,Aa(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},B=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=Z(a,o.image.startOffset),l=Z(a,o.image.endOffset);b(n,o.zone,Aa(n,{anchor:i,focus:l}),i),x(),Vv(r)||e.imageOps.startImageDrag(o.image.paragraphId,o.image.startOffset,r,{left:o.image.left,top:o.image.top,width:o.image.width,height:o.image.height}),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,Aa(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{t=null;const a=_v(n,r,o.zone);b(n,o.zone,Aa(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},F=(n,o,r)=>{t=null;let a=0;const i=r.runs.find(e=>{const t="math"===e.kind&&o.paragraphOffset>=a&&o.paragraphOffset<=a+e.text.length;return a+=e.text.length,t});if("math"===i?.kind){const t=Z(r,o.paragraphOffset);return b(n,o.zone,Aa(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const l=He(Lt(r),o.paragraphOffset),s=Z(r,l.start),c=Z(r,l.end);b(n,o.zone,Aa(n,{anchor:s,focus:c}),s),x(),e.focusInputAfterPointerSelection()},O=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!Vv(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,x(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?R(n,o):o.image?B(n,o,a):a.shiftKey&&o.resolvedFromParagraph?A(n,o,a.pointerId):r>=3&&i?M(n,o,i):2===r&&i?F(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),Vv(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,o,r)},D=(t,n,o)=>{O(e.state(),t,n,o),e.focusInputSync()},E=()=>{const n=f;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const o=n.hit;if(!o?.resolvedFromParagraph)return;const r=e.state(),a=e.getParagraphById(r.document,o.paragraphId);if(!a)return;const i=He(Lt(a),o.paragraphOffset),l=Z(a,i.start),s=Z(a,i.end);b(r,o.zone,Aa(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-l);r=n-a<=450&&o<=((e,t)=>Vv(e)?20:t)(t,6)&&t.button===s?r+1:1,a=n,i=t.clientX,l=t.clientY,s=t.button;const g=Math.max(t.detail,r),m=e.state();if(e.clearPendingCaretTextStyle(),e.tableResize.handlePointerDown(t))return void t.preventDefault();const h=e.resolveSurfaceHitAtPoint(t.clientX,t.clientY,{pierce:t.altKey});if(c=h,d=n,u=t.clientX,p=t.clientY,Vv(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(E,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),O(m,h,g,t)},N=n=>{if(n.detail<3)return;n.preventDefault();const o=e.state(),r=Math.hypot(n.clientX-u,n.clientY-p),a=Date.now()-d<=600&&r<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(o.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const l=_v(o,i,a.zone);b(o,a.zone,Aa(o,{anchor:l.start,focus:l.end}),l.start),x(),e.focusInputAfterPointerSelection()},$=(e,t)=>{0===t.button&&(Vv(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:$,stopDragging:x}}(e)}function Gv(e){return function(e){const[t,n]=an(!1);let o,r=0,a="",i=null;const l=()=>{r=0,a="",o=void 0},s=(t,n)=>{if(!n&&t===a)return;if(0===r&&0===t.length)return void(n&&l());const s=r,c=Yo(o);e.clearPreferredColumn(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>{const n=function(e,t){if(t<=0)return e;const{paragraph:n,index:o,offset:r}=Ne(e);if(r<t)return e;const a=Kr(e),i=r-t,l=Ut(n,[...Rt(n,0,i),...Rt(n,r,u(n))],Y(n,i)),s=a.map((e,t)=>t===o?l:e);return Ie(e,s,oe(Z(l,i)))}(e,s);return t.length>0?za(n,t,c):n}),{mergeKey:Wi}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(uo("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(n.currentTarget.value)}`),n.currentTarget.value="",void l();const o=n.currentTarget.value;if(0===o.length)return;if(t())return e.logger.debug(`input:composing buffer=${JSON.stringify(o)}`),void s(o,!1);if(null!==i){const t=o===i;if(i=null,t)return e.logger.debug(`input:suppressed text=${JSON.stringify(o)}`),void(n.currentTarget.value="")}const r=e.state(),a=r.selection,c=Kr(r).find(e=>e.id===a.anchor.paragraphId)?.runs.find(e=>e.id===a.anchor.runId),d=c?{bold:c.styles?.bold,italic:c.styles?.italic,underline:c.styles?.underline}:null;e.logger.info(`input:text ${JSON.stringify(o)} (len=${o.length}) at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const u=Yo(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>za(e,o,u)),{mergeKey:Hi}),n.currentTarget.value="",e.focusInput(),yo("input:text")},d=()=>{e.logger.debug("input:composition start"),l(),i=null,o=Yo(e.pendingCaretTextStyle()),n(!0)},p=t=>{e.isReadOnly()||s(t.data??"",!1)},g=t=>{if(n(!1),e.isReadOnly())return t.currentTarget.value="",void l();const o=t.data??t.currentTarget.value,r=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(o)} (len=${o.length}) at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}]`),s(o,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:c,handleCompositionStart:d,handleCompositionUpdate:p,handleCompositionEnd:g,composing:t}}(e)}var qv="url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='white' stroke-width='4'/%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M7.5 7.1 7.5 19.1 10.9 15.8 14.7 24.4' stroke='white' stroke-width='1.15' opacity='.95'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' fill='white' stroke='white' stroke-width='3'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' stroke='black' stroke-width='1.25' stroke-dasharray='2 2'/%3E%3C/g%3E%3C/svg%3E\") 6 4, auto";function Yv(e,t){const n=Wn(e);if(n.isCollapsed)return!1;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r];if(!a)return!1;const i=Bt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function Zv(e){return function(e){const[t,n]=an(!1),[o,r]=an(null),[a,i]=an(!1),[l,s]=an(null),[c,d]=an(null);let u=null,p=null,g=null;const f=()=>{p&&(p.remove(),p=null)},m=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${qv} !important; }`,document.head.appendChild(p))},h=Vy(),b=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,n(!1),r(null),i(!1),s(null),d(null),f(),h.release(),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)},y=o=>{if(!h.owns(o))return;if(!u)return;const a=o.ctrlKey||o.metaKey;if(i(a),!t()){const t=Math.abs(o.clientX-u.x),r=Math.abs(o.clientY-u.y);if(t+r<4)return;e.logger?.info("text-drag:activate",{start:u,at:{x:o.clientX,y:o.clientY},deltaX:t,deltaY:r}),n(!0),m()}s({x:o.clientX,y:o.clientY});const l=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY);if(!l?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=l.tableCellAnchorPosition??l.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${l.zone}|src=${l.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:l.zone,resolvedFromParagraph:l.resolvedFromParagraph,paragraphId:l.paragraphId,paragraphOffset:l.paragraphOffset,hitPosition:`${l.position.paragraphId}:${l.position.runId}[${l.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:l.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(l.caretViewport??null)},v=n=>{if(h.owns(n)){if(e.logger?.info("text-drag:mouseup",{x:n.clientX,y:n.clientY,dragging:t(),copyMode:a(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null}),t()&&o()){const t=o(),n=a();e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>$a(e,t,{copy:n})),{mergeKey:n?ul:pl}),e.logger?.info("text-drag:apply",{mode:n?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position;e.applyTransactionalState(e=>Yv(e,t)?Aa(e,{anchor:t,focus:t}):e,{mergeKey:gl}),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}b(),e.focusInputAfterPointerSelection()}},x=(t,o)=>e.isReadOnly()||!o?.resolvedFromParagraph?(e.logger?.debug("text-drag:skip-start",{reason:e.isReadOnly()?"readonly":"no-hit",x:t.clientX,y:t.clientY}),!1):Yv(e.state(),o.position)?(e.logger?.info("text-drag:start-pending",{x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`,zone:o.zone}),u={x:t.clientX,y:t.clientY,position:o.position},s({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),d(o.caretViewport??null),n(!1),h.claim(t),window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),!0):(e.logger?.debug("text-drag:skip-start",{reason:"outside-selection",x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`}),!1);return{dragging:t,dropTargetPos:o,copyMode:a,pointerPos:l,caretViewport:c,tryStartTextDrag:x,stopDrag:b}}(e)}function Jv(e){return e.blocks.flatMap(Po)}function Qv(e,t){if(!e)return;const n=Jv(e);return"start"===t?n[0]:n[n.length-1]}function ex(e){return function(e){const t=(t,n)=>{const o=e.state(),r=Kr(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:Lt(r).length,i=Z(r,a);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=Kr(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:Lt(a).length,l=Z(a,i);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const l=Lt(i),s=o.selection.focus.offset,c=l.length;if(!n&&!zr(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ma(o):Fa(o)),!0;let d=i,u=s;"left"===t?0===s&&a>0?(d=r[a-1],u=Lt(d).length):u=De(l,s):s===c&&a<r.length-1?(d=r[a+1],u=0):u=Bo(l,s);const p=Z(d,u);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const l=e.surfaceRef(),s=l?.getBoundingClientRect()??null,c=e.preferredColumnX(),d=null===c?e.caretBox().left+(s?.left??0):c,u=l?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:l,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let p=a+t;const g=F(o.document,o.selection.focus.paragraphId,fo(o)),f=g?.tablePath[g.tablePath.length-1];if(g&&f){const e=vy(o,g.zone),n=i(e,g.tablePath),a=n?.[n.length-1]?.table;if(a){const e=ln(a),n=e.find(e=>e.rowIndex===f.rowIndex&&e.cellIndex===f.cellIndex);if(n){const o=[];for(let e=n.visualRowIndex+t;e>=0&&e<a.rows.length;e+=t)o.push(e);for(const n of o){const o=e.filter(e=>e.visualRowIndex===n&&Jv(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=Qv(e.cell,"start")?.id,n=t?u?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??d,r=n?n.left+n.width:d;return{entry:e,distance:d<o?o-d:d>r?d-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=Qv(i.cell,t<0?"end":"start");p=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=Qv(a.rows[0]?.cells[0],"start");e&&(p=r.findIndex(t=>t.id===e.id)-1)}else{const e=a.rows[a.rows.length-1],t=e?.cells[e.cells.length-1],n=Qv(t,"end");n&&(p=r.findIndex(e=>e.id===n.id)+1)}}}if(p<0||p>=r.length)return!1;const m=r[p];let h=0;const b=u?lo(u,m.id):[],y=t<0?b[b.length-1]:b[0];if(y&&y.lines.length>0){const e=y.lines,n=t<0?e[e.length-1]:e[0];h=n.slots.length?n.slots.reduce((e,t)=>Math.abs(d-t.left)<Math.abs(d-e.left)?t:e,n.slots[0]).offset:0}else h=Math.min(Bt(m,o.selection.focus),Lt(m).length);return e.setPreferredColumnX(d),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Aa(e,{anchor:n?e.selection.anchor:Z(m,h),focus:Z(m,h)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function tx(e){return function(e){const[t,n]=an(null),o=(t,o)=>{const r=Kr(e.state());let a;for(const e of r){for(const n of e.runs)if(n.revision?.id===t){a=n.revision;break}if(a)break}const i=e=>{for(const n of e)if("paragraph"!==n.type){if(n.style?.revision?.id===t)return n.style.revision;if(n.gridRevision?.id===t)return n.gridRevision;for(const e of n.rows){if(e.style?.revision?.id===t)return e.style.revision;if(e.style?.propertyRevision?.id===t)return e.style.propertyRevision;for(const n of e.cells){if(n.style?.revision?.id===t)return n.style.revision;if(n.style?.propertyRevision?.id===t)return n.style.propertyRevision;const e=i(n.blocks);if(e)return e}}}};if(!a)for(const n of Fe(e.state().document)){for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter])if(e&&(a=i(e),a))break;if(a)break}if(!a)return;const l=o.currentTarget.getBoundingClientRect(),s=e.surfaceRef()?.getBoundingClientRect();if(!s)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(l.left-s.left)/c,top:(l.top-s.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function nx(e){const t=Kr(e);if(!t.length)return null;const n=Wn(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:Rt(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:u(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Yo(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(Te(r?r.styles:Y(o,n.startParagraphOffset),o.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===u(o));return{text:a,paragraph:i?Dr(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function ox(e,t){const n=Kr(e);if(!n.length)return e;const o=Wn(e,n);if(o.isCollapsed)return e;let r=!1;const a=n.map((e,n)=>{if(n<o.startIndex||n>o.endIndex)return e;const a=n===o.startIndex?o.startParagraphOffset:0,i=n===o.endIndex?o.endParagraphOffset:u(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===u(e))}(e,n,o),s=l?Dr(t.paragraph):e.style,c=l?t.list?{...t.list}:void 0:e.list,d=l&&(JSON.stringify(s)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),p=a<i&&Rt(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Yo(t.text)??{};void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision);const o=Object.keys(n).length?n:void 0;return!Cn(e.styles,o)});if(!d&&!p)return e;r=!0;let g=p?Ye(e,a,i,e=>{if("text"!==e.kind)return e;const n=Yo(t.text)??{};return void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(n).length?n:void 0}}):e;return l&&(g={...g,style:s,list:c}),g});return r?Ie(e,a,$(a,o)):e}function rx(e){const t=Kr(e);if(!t.length)return"";const n=Wn(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function ax(e){const[t,n]=an(null);let r=null,a=null,i="";const l=()=>{r=null,a=null,i="",n(null)};Jt()&&(we(()=>{t()&&(e.isReadOnly()||e.state().document!==a)&&l()}),o(l));const s=()=>!e.isReadOnly()&&Kr(e.state()).length>0,c=t=>{if(!s())return!1;const o=e.state(),l=nx(o);return!!l&&(r=l,a=o.document,i=rx(o),n(t),e.focusInput(),!0)};return{mode:t,canCapture:s,armOnce:()=>c("once"),armContinuous:()=>c("continuous"),cancel:l,applyToSelection:n=>{if(!r||!t())return!1;if(e.isReadOnly()||e.state().document!==a)return l(),!1;const o=e.state();if(rx(o)===i)return!1;const s=function(e,t){const n=Kr(e);if(0===n.length)return null;const o=Wn(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=He(Lt(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Z(r,a.start),focus:Z(r,a.end)}}}(o,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return _t(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>ox(e,r));return c=n.document!==t.document,n}),"once"===t()?l():c&&(a=e.state().document)}),c&&e.focusInput(),c}}}function ix(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:g,setForcePlainTextPaste:f,getCommandsController:m,applyTransactionalState:h,clearPreferredColumn:b,resetTransactionGrouping:y,updateHistoryState:v,caretBox:x,preferredColumnX:w,setPreferredColumnX:S,documentLayout:C,canvasSnapshotProvider:I}=e,T=()=>mb(t),k=()=>ay(t),P=mv({state:()=>t,resetTransactionGrouping:y,applyTransactionalState:h,focusInput:i}),R=iv({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:C,canvasSnapshotProvider:I,zoomFactor:u}).resolveSurfaceHitAtPoint,B=function(e){const[t,n]=an(""),[o,r]=an(""),[a,i]=an({matchCase:!1,wholeWord:!1}),[l,s]=an([]),[c,d]=an(-1),[u,p]=an(!1);we(it([()=>e.state.document,t,a],([e,t,n])=>{const o=Qy(e,t,n);s(o),0===o.length?d(-1):(c()>=o.length||-1===c())&&d(0)}));const g=t=>{const n=l()[t];n&&e.applyState(Aa(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:o,setReplaceTerm:r,findOptions:a,setFindOptions:i,matches:l,currentIndex:c,findNext:()=>{const e=l().length;if(0===e)return;const t=(c()+1)%e;d(t),g(t)},findPrevious:()=>{const e=l().length;if(0===e)return;const t=(c()-1+e)%e;d(t),g(t)},replace:()=>{if(0===l().length||-1===c())return;const t=l()[c()];e.applyTransactionalState(e=>za(Aa(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:il})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>ev(e,n,o(),a()),{mergeKey:ll}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:h,focusInput:i}),A=jy({applyTransactionalState:h,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:kn(e).document,selection:t}),focusInput:i,logger:n}),M=ax({state:()=>t,isReadOnly:o,applyTransactionalState:h,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i}),F=(e,t)=>R(e,t)?.position??null,O=Yy({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:F,applyState:r,applyTransactionalState:h,updateHistoryState:v,focusInput:i,focusInputAfterPointerSelection:l,cloneState:a,logger:n,zoomFactor:u}),D=Zy({state:t,surfaceRef:c,applyState:r,updateHistoryState:v,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),E=Jy({state:()=>t,commandsController:m,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i,logger:n}),L=function(e){const t=()=>e.state,n=Lv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=zv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=jv({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=tx({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=Zv({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),l=Xv({state:t,applyState:e.applyState,tableResize:n,imageOps:e.imageOps,clearPendingCaretTextStyle:e.styleController.clearPendingCaretTextStyle,onSelectionFinalized:()=>{e.formatPainter.applyToSelection("pointer")},clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,focusInputSync:e.focusInputSync,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,getParagraphById:Oo,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),s=Gv({state:t,isReadOnly:e.isReadOnly,logger:e.logger,clearPreferredColumn:e.clearPreferredColumn,pendingCaretTextStyle:e.styleController.pendingCaretTextStyle,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput}),c=ex({state:t,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,surfaceRef:()=>e.surfaceRef()??null,caretBox:e.caretBox,preferredColumnX:e.preferredColumnX,setPreferredColumnX:e.setPreferredColumnX,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),{handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}=hv({state:t,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,consumePasteMode:e.clipboardActions?.consumePasteMode,onNativeClipboardSuccess:e.clipboardActions?.dismiss,setForcePlainTextPaste:e.setForcePlainTextPaste,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,insertImageFromFile:e.insertImageFromFile,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint});return{tableResize:n,tableCornerResize:o,tableDrag:r,revisionController:a,textDrag:i,surfaceEvents:l,textInput:s,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,applyState:r,applyTransactionalState:h,isReadOnly:o,logger:n,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,clearPreferredColumn:b,resetTransactionGrouping:y,surfaceRef:c,viewportRef:d,caretBox:()=>x(),preferredColumnX:()=>w(),setPreferredColumnX:S,zoomFactor:u,documentLayout:C,canvasSnapshotProvider:I,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:F,tableOps:A,imageOps:O,styleController:E,formatPainter:M,getForcePlainTextPaste:g,setForcePlainTextPaste:f,clipboardActions:e.clipboardActions,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),N=e=>{0===e.button&&(E.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:T,selectedTextBoxRun:k,layoutOptionsOverlay:P,fr:B,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:F,tableOps:A,imageOps:O,textBoxOps:D,styleController:E,formatPainter:M,onEditorPointerDown:N,tableResize:L.tableResize,tableCornerResize:L.tableCornerResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}(e)}function lx(e){if("main"!==(e.activeZone??"main"))return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=Vn(),l=function(e){const n=e.footnotes,o=n?.settings?.numberFormat??"decimal";let r=(n?.settings?.startAt??1)-1;const a=/* @__PURE__ */new Set;for(const{run:i}of ir(e)){const e=t(i);e&&!e.customMark&&(a.has(e.footnoteId)||(a.add(e.footnoteId),r+=1))}return Tn(r+1,o)}(n.document),s=Mn(i.id,l),c=d(o,a,[s]),u=Kr(n).map((e,t)=>t===r?c:e),p=Z(c,a+l.length),g=Ie(n,u,En(p)),f=function(e){return e||{items:{}}}(g.document.footnotes),m={...g.document,footnotes:{...f,items:{...f.items,[i.id]:i}}},h=Mr(m),b=i.blocks.flatMap(Po).find(Boolean);return b?{...g,document:h,selection:En(Z(b,0)),activeZone:"footnote",activeFootnoteId:i.id}:{...g,document:h}}function sx(e,t,n){return e.flatMap(e=>{if("paragraph"===e.type)return[e];let o=e.style;if(o?.revision?.id===t)if(n){const{revision:e,...t}=o;o=t}else o={...o.revision.previous};let r=e.gridCols,a=e.gridRevision;a?.id===t&&(r=n?r:[...a.previous],a=void 0);const i=e.rows.map(e=>({...e,cells:[...e.cells]}));for(let s=0;s<i.length;s+=1){const e=i[s];for(let o=0;o<e.cells.length;o+=1){const r=e.cells[o],a=r.mergeRevisionState;if(a&&a.revisionId===t){if(n){const{mergeRevisionState:t,...n}=r;e.cells[o]=n;continue}"horizontal"===a.orientation?e.cells.splice(o,a.currentCellCount,...a.previousCells):a.previousCells.forEach((e,t)=>{const n=i[s+t];n&&(n.cells[o]=e)})}}}const l=i.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};if(o?.revision?.id===t){const{revision:e,...t}=o;o=t}const r=e.cells.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};let r={...e,style:o,blocks:sx(e.blocks,t,n)};if(o?.revision?.id===t&&e.mergeRevisionState?.revisionId!==t){const e=o.revision,{revision:t,...a}=o;r={...r,...n||"merge"!==e.type?{}:e.previous,style:a}}return[r]});return[{...e,isHeader:o&&"isHeader"in o?o.isHeader:e.isHeader,style:o,cells:r}]});return 0===l.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:l}]})}function cx(e,t,n){const o=Fe(e.document).map(e=>({...e,blocks:sx(e.blocks,t,n),header:e.header?sx(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?sx(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?sx(e.evenPageHeader,t,n):void 0,footer:e.footer?sx(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?sx(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?sx(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function dx(e,t){const n=Kr(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"delete"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"insert"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return cx(Ie(e,n,$(n,Wn(e))),t,!0)}function ux(e,t){const n=Kr(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"insert"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"delete"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return cx(Ie(e,n,$(n,Wn(e))),t,!1)}function px(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>px(e,t))))}function gx(e,t,n){for(const o of e)if("paragraph"!==o.type){px(o,t)&&(o.style?.revision&&n.add(o.style.revision.id),o.gridRevision&&n.add(o.gridRevision.id));for(const e of o.rows){const o=e.cells.filter(e=>e.blocks.some(e=>px(e,t)));o.length>0&&(e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id));for(const e of o)e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id),gx(e.blocks,t,n)}}}function fx(e){const t=Wn(e),n=Kr(e),o=/* @__PURE__ */new Set;for(let a=t.startIndex;a<=t.endIndex;a+=1){const e=n[a],r=a===t.startIndex?t.startParagraphOffset:0,i=a===t.endIndex?t.endParagraphOffset:u(e),l=Rt(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Fe(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&gx(e,r,o);return o}function mx(e){const t=/* @__PURE__ */new Set,n=e=>{for(const n of e)n.revision?.id&&t.add(n.revision.id),n.revisionRangeMarker?.id&&t.add(n.revisionRangeMarker.id)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){r.style?.revision&&t.add(r.style.revision.id),r.gridRevision&&t.add(r.gridRevision.id);for(const e of r.rows){e.style?.revision&&t.add(e.style.revision.id),e.style?.propertyRevision&&t.add(e.style.propertyRevision.id);for(const n of e.cells)n.style?.revision&&t.add(n.style.revision.id),n.style?.propertyRevision&&t.add(n.style.propertyRevision.id),n.mergeRevisionState?.revisionId&&t.add(n.mergeRevisionState.revisionId),o(n.blocks)}}else n(r.runs)};for(const i of Fe(e.document))i.propertyRevision&&t.add(i.propertyRevision.id),o(i.blocks),o(i.header),o(i.firstPageHeader),o(i.evenPageHeader),o(i.footer),o(i.firstPageFooter),o(i.evenPageFooter);const r=e.document.footnotes?.items??{};for(const i of Object.values(r))o(i.blocks);const a=e.document.endnotes?.items??{};for(const i of Object.values(a))o(i.blocks);return t}function hx(e){return mx(e).size>0}function bx(e,t){if(!hx(e))return e;const n=er(e.document,t);if(!n.changed)return e;const o=Kr({...e,document:n.document}),r=$(o,Wn(e));return{...e,document:n.document,selection:r}}function yx(e){const t=Wn(e),n=Kr(e);if(t.isCollapsed){const e=n[t.startIndex];return e?Et(e,t.startParagraphOffset)?.href??null:null}const o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:u(e);return Rt(e,r,a)}).filter(e=>e.text.length>0&&"image"!==e.kind);if(0===o.length)return null;const r=o[0]?.styles?.link;return r&&o.every(e=>e.styles?.link===r)?r:null}function vx(e){const t=Wn(e),n=Kr(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return pn(e);if(!e.list)return pn(e);const o=e.list.level??0;return o<=0?j(e):be(e,o-1)});return Ie(e,n,$(n,t))}function xx(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:i,applySelectionAwareTextCommand:l,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:c,focusInput:d,clearPreferredColumn:p,resetTransactionGrouping:g,toolbarStyleState:f,selectionCollapsed:m,selectedImageRun:h}=e,b=e=>{p(),g(),o(e),d()},y=e=>{p(),g(),l(e),d()},v=e=>{p(),g(),s(e),d()},x=(e,t)=>{p(),g(),i(e,t),d()},w=()=>{const e=Wn(t);return Kr(t).slice(e.startIndex,e.endIndex+1)},S=()=>w().some(e=>Boolean(e.list)),C=()=>{const e=t.selection.focus.paragraphId;return Kr(t).find(t=>t.id===e)??null},T=()=>{const e=C();return!!e?.list&&(p(),g(),m()&&0===Lt(e).length?s(e=>function(e){const t=Wn(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?pn(e):j(e));return Ie(e,n,$(n,t))}(e)):i(e=>c(e,e=>function(e){const t=zr(e.selection)?e:Me(e),{paragraph:n,index:o,offset:a}=Ne(t),i=Ut(n,Rt(n,0,a),Y(n,a)),l=Rt(n,a,u(n)),s=l.length>0?de(n,l.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=pr("");return e.style=n.style?{...n.style}:void 0,e.list=lt(n.list),e})(),c=Kr(t),d=[...r(c.slice(0,o)),i,s,...r(c.slice(o+1))];return Ie(t,d,oe(Z(s,0)))}(e)),{mergeKey:Ki}),d(),!0)},k=()=>{const e=t.selection,n=fo(t),o=St(t.document,e.anchor.paragraphId,n),r=St(t.document,e.focus.paragraphId,n);return o&&r&&o.blockIndex===r.blockIndex?` [table b${o.blockIndex} r${o.rowIndex}:c${o.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},P=e=>{if(m())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${k()}`),y(t=>Ka(t,e))},R=e=>{m()||y(t=>function(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e).map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:u(o);return Ye(o,a,i,n=>{let r=So(Va(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!Te(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return Ie(e,o,$(o,n))}(t,e))},B=(e,o)=>{if(m())return;const r=t.selection;n.info(`setStyle:${e}=${JSON.stringify(o)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${k()}`),y(t=>_a(t,e,o))},A=(e,t)=>{v(n=>Ve(n,e,t))},M=e=>{const t=!f()[e];A(e,"widowControl"===e?t:!!t||null)},F=()=>{x(e=>c(e,e=>Zr(e)))},O=()=>"main"===(t.activeZone??"main"),D=()=>{O()&&x(e=>lx(e))},E=e=>{const n=yx(t);m()&&!n||x(t=>function(e,t){const n=Wn(e);if(!n.isCollapsed)return _a(e,"link",t);const o=Kr(e)[n.startIndex];if(!o)return e;const r=Et(o,n.startParagraphOffset);if(!r)return e;const a=_a(Aa(e,{anchor:Z(o,r.startOffset),focus:Z(o,r.endOffset)}),"link",t),i=Kr(a)[n.startIndex];return i?{...a,selection:{anchor:Z(i,r.startOffset),focus:Z(i,r.endOffset)}}:a}(t,e),{mergeKey:_i})},L=()=>{const n=yx(t)??"";m()&&!n||e.openLinkDialog(n)},N=()=>e.openFontDialog(),z=()=>e.openParagraphDialog(),H=()=>{E(null)},W=()=>{const t=h();if(!t)return;const n=qn(t.run)?.alt??"";e.openImageAltDialog(n)},U=t=>{h()&&x(n=>function(e,t,n){const o=mb(e);if(!o||!qn(o.run))return e;const a=Kr(e),i=o.paragraphIndex+1,l=i<a.length&&wr(a[i])?en(a[i],t,n):Gt(t,n,1),s=i<a.length&&wr(a[i])?[...r(a.slice(0,i)),l,...r(a.slice(i+1))]:[...r(a.slice(0,i)),l,...r(a.slice(i))],c=he(s),d=c[i]??l;return Ie(e,c,oe(Z(d,q(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:Gi})},V=()=>{h()&&e.openImageCaptionDialog(function(e){const t=mb(e);if(!t||!qn(t.run))return null;const n=Kr(e);return Ce(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:P,applyToggleCharacterBorderCommand:()=>{m()||y(e=>function(e){const t=Wn(e);if(t.isCollapsed)return e;const n=Kr(e),o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:u(e);return Rt(e,r,a)}).filter(e=>e.text.length>0);if(0===o.length)return e;const r=!o.every(e=>Boolean(e.styles?.textBorder)),a=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,a=n===t.endIndex?t.endParagraphOffset:u(e);return Ye(e,o,a,e=>({...e,styles:qa(e.styles,r)}))});return Ie(e,a,$(a,t))}(e))},applyValueStyleCommand:B,applyUnderlineStyleCommand:R,applyChangeTextCaseCommand:e=>{m()||y(t=>Ja(t,e))},applyClearFormattingCommand:()=>{m()||y(e=>function(e){const t=Wn(e);if(t.isCollapsed)return e;const n=Kr(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,r=n===t.endIndex?t.endParagraphOffset:u(e);return Ye(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Ie(e,n,$(n,t))}(e))},applyParagraphStyleCommand:A,toggleParagraphFlagCommand:M,applyParagraphListCommand:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),l=i.length>0&&i.every(e=>e.list?.kind===t),s=o.map((e,n)=>{if(n<r||n>a)return pn(e);const o=pn(e);return l?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return Ie(e,s,$(s,n))}(t,e))},handleListFormatChange:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?pn(e):e.list?{...pn(e),list:{...e.list,format:t||void 0}}:pn(e));return Ie(e,o,$(o,n))}(t,e))},handleListStartAtChange:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?pn(e):e.list?{...pn(e),list:{...e.list,startAt:null!==t?t:void 0}}:pn(e));return Ie(e,o,$(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{b(wt(t,e))},applyInsertPageBreakCommand:F,canInsertFootnoteCommand:O,applyInsertFootnoteCommand:D,handleStyleChange:e=>{v(t=>I(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{b(a(t,e,n))},applyToggleTrackChangesCommand:()=>{b(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleRevisionMarkupCommand:()=>{b(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(t))},applySetReviewDisplayModeCommand:e=>{b(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(t,e))},applyShowMarkupCommand:e=>{b(zb(t,e))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),d()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),d()},applyAcceptRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of fx(e))t=dx(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of fx(e))t=ux(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{x(e=>function(e){return bx(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{x(e=>function(e){return bx(e,"reject")}(e))},applyLinkCommand:E,promptForLink:L,openFontDialog:N,openParagraphDialog:z,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:H,applyImageAltCommand:e=>{h()&&x(t=>function(e,t){return Tb(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:Xi})},promptForImageAlt:W,applyImageCaptionCommand:U,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=mb(e),o=n&&qn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Ar));return hb(e,r,r*(o.height/o.width))}(t,e),{mergeKey:qi})},applyImageHeightCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=mb(e),o=n&&qn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Ar));return hb(e,r*(o.width/o.height),r)}(t,e),{mergeKey:qi})},applyImageCropAspectCommand:e=>{if(!h())return;const t=function(e){const t=e.trim().toLowerCase();if("reset"===t||"fit"===t||"fill"===t)return"reset";const n=t.split(/[:/]/);if(2!==n.length)return null;const o=Number(n[0]),r=Number(n[1]);return!Number.isFinite(o)||!Number.isFinite(r)||o<=0||r<=0?null:o/r}(e);null!==t&&x(e=>"reset"===t?wb(e):vb(e,t),{mergeKey:Yi})},applyImageCropShapeCommand:e=>{h()&&x(t=>function(e,t){const n=t?.trim();return Tb(e,e=>{const t={...e};return n&&"rect"!==n?(t.cropShape={preset:n},t.cropFit||(t.cropFit="fill")):delete t.cropShape,t})}(t,e),{mergeKey:Yi})},applyImageCropFillCommand:()=>{h()&&x(e=>function(e){const t=mb(e),n=t&&qn(t.run);return n?Tb(yb(e,{crop:xb(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Yi})},applyImageCropFitCommand:()=>{h()&&x(e=>function(e){return Tb(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Yi})},resetImageCropCommand:()=>{h()&&x(e=>wb(e),{mergeKey:Yi})},applyImageBorderCommand:e=>{h()&&x(t=>function(e,t){return Tb(e,e=>{if(null===t.color){const{border:t,...n}=e;return n}const n={...e.border??{color:"#000000"}};return void 0!==t.color&&(n.color=t.color),void 0!==t.widthPt&&(n.widthPt=t.widthPt),void 0!==t.dash&&(n.dash=t.dash),{...e,border:n}})}(t,e))},flipImageCommand:e=>{h()&&x(t=>Ib(t,e),{mergeKey:Zi})},rotateImageCommand:e=>{h()&&x(t=>Cb(t,e),{mergeKey:Ji})},applyImageTransparencyCommand:e=>{h()&&x(t=>function(e,t){return null===mb(e)?e:Tb(e,e=>{if(!Number.isFinite(t)||t<=0){const{transparency:t,...n}=e;return n}const n=Math.min(1,t);return{...e,transparency:Math.round(1e3*n)/1e3}})}(t,e??0),{mergeKey:Qi})},resetImageCommand:()=>{h()&&x(e=>function(e){return null===mb(e)?e:Tb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,delete t.transparency,delete t.border,delete t.rotation,delete t.flipH,delete t.flipV,delete t.fillMode,t})}(e),{mergeKey:el})},handleListTab:e=>!St(t.document,t.selection.focus.paragraphId,fo(t))&&(!!S()&&(v(t=>"indent"===e?function(e){const t=Wn(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?pn(e):e.list?be(e,(e.list.level??0)+1):pn(e));return Ie(e,n,$(n,t))}(t):vx(t)),!0)),handleListEnter:T,handleListBoundaryBackspace:e=>{const n=C();return!(!n?.list||!m())&&(0===Bt(n,t.selection.focus)&&(p(),g(),s(e=>vx(e)),e.currentTarget.value="",d(),!0))}}}(e)}function wx(e){return{fontFamily:e.fontFamily??"",fontSize:xn(e.fontSize),color:e.color??"",colorMode:e.color?"custom":"automatic",highlight:e.highlight??"",shading:e.textShading??"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underlineStyle?e.underlineStyle:null,underlineColor:e.underlineColor??"",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden),characterScale:e.characterScale??"",characterSpacing:e.characterSpacing??"",baselineShift:e.baselineShift??"",kerningThreshold:e.kerningThreshold??"",ligatures:e.ligatures??"",numberSpacing:e.numberSpacing??"",numberForm:e.numberForm??"",stylisticSet:e.stylisticSet??"",contextualAlternates:Boolean(e.contextualAlternates)}}function Sx(e){return{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",mirrorIndents:e.mirrorIndents??!1,spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",lineRule:e.lineRule??"",contextualSpacing:e.contextualSpacing??!1,outlineLevel:e.outlineLevel??"",shading:e.shading??"",borderStyle:e.borderStyle??"",borderWidth:e.borderWidth??"",borderColor:e.borderColor??"",borderSideTop:e.borderSideTop??!1,borderSideRight:e.borderSideRight??!1,borderSideBottom:e.borderSideBottom??!1,borderSideLeft:e.borderSideLeft??!1,pageBreakBefore:e.pageBreakBefore??!1,keepWithNext:e.keepWithNext??!1,keepLinesTogether:e.keepLinesTogether??!1,widowControl:e.widowControl??!0,tabs:e.tabs??[]}}function Cx(e){return function(e){const t=xx({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,applySelectionAwareTextCommand:e.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:e.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,toolbarStyleState:e.toolbarStyleState,selectionCollapsed:()=>zr(e.state.selection),selectedImageRun:e.selectedImageRun,openLinkDialog:t=>e.setLinkDialog({isOpen:!0,initialHref:t}),openImageAltDialog:t=>e.setImageAltDialog({isOpen:!0,initialAlt:t}),openImageCaptionDialog:t=>e.setImageCaptionDialog({isOpen:!0,initialCaption:t}),openFontDialog:()=>{e.setFontDialog({isOpen:!0,initial:wx(e.toolbarStyleState())})},openParagraphDialog:()=>{e.setParagraphDialog({isOpen:!0,initial:Sx(e.toolbarStyleState())})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Ix(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Tx=class{bindings=/* @__PURE__ */new Map;register(e){this.bindings.set(e.id,e)}unregister(e){this.bindings.delete(e)}getBindings(){return Array.from(this.bindings.values())}execute(e,t,n){const o=e.ctrlKey||e.metaKey,r=e.key.toLowerCase();for(const a of this.bindings.values())if(a.key.toLowerCase()===r&&Boolean(a.ctrlOrMeta)===o&&Boolean(a.shift)===e.shiftKey&&Boolean(a.alt)===e.altKey){if(a.command&&n)return n.canExecuteCommand?.(a.command)??!0?(n.executeCommand(a.command),e.preventDefault(),!0):(e.preventDefault(),!0);if(!1!==a.execute(t,e))return e.preventDefault(),!0}return!1}},kx=[{id:"newDocument",command:"newDocument",key:"n",ctrlOrMeta:!0,execute:()=>!0},{id:"print",command:"print",key:"p",ctrlOrMeta:!0,execute:()=>!0},{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:e=>{const t=e.state(),n=Kr(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Aa(t,{anchor:Z(o,0),focus:Z(r,Lt(r).length)})),e.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:e=>!!e.selectedImageRun()&&(e.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:e=>(e.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:e=>(e.setForcePlainTextPaste(!0),e.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:e=>(e.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"repeatLastAction",command:"repeatLastAction",key:"F4",ctrlOrMeta:!1,execute:e=>(e.executeCommand?.("repeatLastAction"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:e=>(e.toggleFindReplace(!0),!0)},{id:"commandSearch",command:"openCommandSearch",key:"q",alt:!0,execute:e=>(e.toggleCommandSearch(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:e=>(e.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:e=>(e.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:e=>(e.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:e=>(e.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Zr(e))),e.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>za(e,"\n"))),e.focusInput(),!0)},{id:"columnBreak",command:"columnBreak",key:"Enter",ctrlOrMeta:!0,shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ha(e))),e.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:e=>(e.commandsController.handleListEnter()||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Fo(e))),e.focusInput()),!0)}];function Px(e){return function(e){const t=new Tx;kx.forEach(e=>t.register(e));const n=n=>{const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="ArrowLeft"===e||"ArrowRight"===e||"ArrowUp"===e||"ArrowDown"===e||"Home"===e||"End"===e||"PageUp"===e||"PageDown"===e,r="Shift"===e||"Control"===e||"Meta"===e||"Alt"===e,a=(n.ctrlKey||n.metaKey)&&("a"===t||"c"===t);return void(o||r||a||n.preventDefault())}if(n.isComposing||229===n.keyCode)return;const r=e.executeCommand?{executeCommand:(t,n)=>e.executeCommand?.(t,n),canExecuteCommand:(t,n)=>e.canExecuteCommand?.(t,n)}:void 0;if(!t.execute(n,e,r)){if((n.ctrlKey||n.metaKey)&&!n.altKey){if(("ArrowLeft"===n.key||"ArrowRight"===n.key)&&(n.preventDefault(),e.resetTransactionGrouping(),e.moveSelectionByWord("ArrowLeft"===n.key?"left":"right",n.shiftKey)))return void e.focusInput();if("Backspace"===n.key||"Delete"===n.key){if(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!zr(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),n.currentTarget.value="",void e.focusInput();const t=Kr(o),r=t[t.findIndex(e=>e.id===o.selection.focus.paragraphId)];if(!r)return n.currentTarget.value="",void e.focusInput();if("Backspace"===n.key&&r.list&&0===Bt(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>vx(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=Lt(r),l=He(i,a);return"Backspace"===n.key?0===a||l.start===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Aa(t,{anchor:Z(r,l.start),focus:Z(r,a)}),e=>Ua(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))):l.end>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Aa(t,{anchor:Z(r,a),focus:Z(r,l.end)}),e=>Ua(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))),n.currentTarget.value="",void e.focusInput()}}if("Home"===n.key||"End"===n.key){n.preventDefault(),e.resetTransactionGrouping();const t="Home"===n.key?"start":"end";return n.ctrlKey||n.metaKey?e.moveSelectionToDocumentBoundary(t,n.shiftKey):e.moveSelectionToParagraphBoundary(t,n.shiftKey),void e.focusInput()}if(!n.altKey||n.ctrlKey||n.metaKey||"ArrowUp"!==n.key&&"ArrowDown"!==n.key||(n.preventDefault(),e.resetTransactionGrouping(),e.clearPreferredColumn(),!e.moveSelectedImageByParagraph("ArrowUp"===n.key?-1:1)))switch(n.key){case"Backspace":return e.commandsController.handleListBoundaryBackspace(n)?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))),n.currentTarget.value="",void e.focusInput();case"Tab":{if(e.commandsController.handleListTab(n.shiftKey?"outdent":"indent"))return void n.preventDefault();const t=e.resolveAdjacentTableCellPosition(o.document,o.selection.focus.paragraphId,n.shiftKey?-1:1);if(t)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applySelectionPreservingStructure({anchor:t,focus:t}),void e.focusInput();break}case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(Pa(o,-1))):(e.clearPreferredColumn(),e.applyState(Ma(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return Pa(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Fa(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return Ra(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return ka(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return Ra(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return ka(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var Rx=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var Bx={oasis:{color:"#0f766e",heading:"#115e59",body:"#1f2937"},office:{color:"#4472c4",heading:"#2f5597",body:"#1f2937"},facet:{color:"#8064a2",heading:"#604a7b",body:"#262626"},integral:{color:"#70ad47",heading:"#548235",body:"#1f2937"},ion:{color:"#ed7d31",heading:"#c55a11",body:"#262626"},retrospect:{color:"#5b9bd5",heading:"#2f75b5",body:"#1f2937"}},Ax={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},Mx={aptos:["Aptos, sans-serif","Aptos Display, sans-serif"],calibri:["Calibri, sans-serif","Calibri Light, sans-serif"],georgia:["Georgia, serif","Georgia, serif"],garamond:["Garamond, serif","Garamond, serif"]};function Fx(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function Ox(e,t){return function(e,t){const n=Bx[t],o=e.document.styles??{},r=Object.fromEntries(Object.entries(o).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.body,...o?{fontFamily:"Aptos Display, sans-serif"}:{fontFamily:"Aptos, sans-serif"}}}]}));return{...e,document:{...e.document,design:{...e.document.design??{},themeId:t,colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading,dk2:n.body},fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:"Aptos Display"},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:"Aptos"}}}},styles:r}}}(e,t)}function Dx(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Ex(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function Lx(e){return null!=e&&""!==e?Number(e):null}function Nx({gate:e,style:t,selection:n,history:o,formatting:r,dialog:a,link:i,command:l,valueCommand:s,actionCommand:c}){const d=t.state;return{selectAll:l("selectAll",r.selectAll),selectWord:l("selectWord",r.selectWord),selectSentence:l("selectSentence",r.selectSentence),selectParagraph:l("selectParagraph",r.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:s("selectText",e=>{const t=e??{};return r.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:c("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:l("insertFootnote",r.insertFootnote),setNoteOptions:c("setNoteOptions",e=>{const t=e??{},n="endnote"===t.kind?"endnote":"footnote";r.setNoteOptions({kind:n,...void 0!==t.numberFormat?{numberFormat:t.numberFormat}:{},...void 0!==t.startAt?{startAt:Lx(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:l("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:l("updateTableOfContents",r.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&r.hasTableOfContents()})),insertText:c("insertText",e=>{const t="object"==typeof e&&null!==e&&"text"in e?e:{text:e};r.insertText(String(t.text??""),"string"==typeof t.fontFamily?t.fontFamily:null)}),insertEquation:c("insertEquation",e=>{r.insertEquation(e)}),updateEquation:c("updateEquation",e=>{const t=e;r.updateEquation(t.runId,t.expression)}),pastePlainText:l("pastePlainText",r.pastePlainText),formatPainter:l("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:l("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:l("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:l("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:l("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:l("underline",r.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:l("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:l("wordUnderline",r.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:l("strike",r.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:l("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:l("smallCaps",r.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:l("allCaps",r.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:l("hidden",r.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:l("noProof",r.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:l("webHidden",r.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:l("specVanish",r.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:l("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:l("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:l("shadow",r.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:l("emboss",r.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:l("engrave",r.engrave,()=>({isActive:Boolean(d().imprint)})),outline:l("outline",r.outline,()=>({isActive:Boolean(d().outline)})),superscript:l("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:l("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:l("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:l("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:l("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:l("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:l("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:l("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:l("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:l("find",r.find),replace:l("replace",r.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),setReviewDisplayMode:s("setReviewDisplayMode",e=>{const t="string"==typeof e?e:e?.mode;return("all"===t||"final"===t||"original"===t)&&r.setReviewDisplayMode(t)},()=>r.reviewDisplayMode()),toggleTrackChanges:l("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),toggleRevisionMarkup:l("toggleRevisionMarkup",r.toggleRevisionMarkup,()=>({isActive:r.areRevisionMarkupVisible()})),showMarkupOptions:s("showMarkupOptions",()=>!1,()=>r.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{r.applyShowMarkup(e??{})}),toggleOutlinePanel:l("toggleOutlinePanel",r.toggleOutlinePanel,()=>({isActive:r.areOutlineVisible()})),toggleRevisionsPanel:l("toggleRevisionsPanel",r.toggleRevisionsPanel,()=>({isActive:r.areRevisionsPanelVisible()})),acceptRevisions:l("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:l("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:l("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:l("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),requestAcceptAllRevisions:l("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&r.hasRevisionsInDocument()})),requestRejectAllRevisions:l("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:l("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:l("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:l("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:l("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:l("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:l("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:l("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:l("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:l("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:l("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:l("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:l("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:l("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:l("togglePreciseFonts",r.togglePreciseFonts,()=>(m(),{isActive:Ca()})),undo:l("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:l("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:l("pageBreak",r.pageBreak),lineBreak:l("lineBreak",r.lineBreak),columnBreak:l("columnBreak",r.columnBreak),splitBlock:l("splitBlock",r.splitBlock),insertNonBreakingSpace:l("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:l("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:l("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:l("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:l("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:l("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:l("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:l("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:s("setFontFamily",e=>r.setFontFamily(e||null),()=>d().fontFamily),setFontSize:s("setFontSize",e=>{const t=e&&"object"==typeof e&&"size"in e?e.size:e;if(null==t||""===t)return r.setFontSize(null);if("string"!=typeof t&&"number"!=typeof t)return!1;const n=kr(t);return null!==n&&r.setFontSize(n)},()=>xn(d().fontSize)),increaseFontSize:l("increaseFontSize",r.increaseFontSize),decreaseFontSize:l("decreaseFontSize",r.decreaseFontSize),growFont1:l("growFont1",r.growFont1),shrinkFont1:l("shrinkFont1",r.shrinkFont1),changeTextCase:c("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:l("clearFormatting",r.clearFormatting),setColor:s("setColor",e=>r.setColor(e??null),()=>d().color||null),setHighlight:s("setHighlight",e=>r.setHighlight(e??null),()=>d().highlight||null),setTextShading:s("setTextShading",e=>r.setTextShading(e??null),()=>d().textShading||null),setStyleId:s("setStyleId",e=>r.setStyleId(String(e)),()=>d().styleId||"normal"),setCharacterStyleId:s("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:s("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:s("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:s("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:s("setCharacterScale",e=>r.setCharacterScale(Lx(e)),()=>d().characterScale),setCharacterSpacing:s("setCharacterSpacing",e=>r.setCharacterSpacing(Lx(e)),()=>d().characterSpacing),setRunSnapToGrid:s("setRunSnapToGrid",e=>r.setRunSnapToGrid(Dx(e)),()=>d().snapToGrid),setFitText:s("setFitText",e=>r.setFitText(Lx(e)),()=>d().fitText),setBaselineShift:s("setBaselineShift",e=>r.setBaselineShift(Lx(e)),()=>d().baselineShift),setEmphasisMark:s("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:s("setTextEffect",e=>r.setTextEffect(e||null),()=>d().textEffect),setKerning:s("setKerning",e=>r.setKerning(Lx(e)),()=>d().kerningThreshold),setLigatures:s("setLigatures",e=>r.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:s("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:s("setNumberForm",e=>r.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:s("setStylisticSet",e=>r.setStylisticSet(Lx(e)),()=>d().stylisticSet)}}function $x({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const l=t.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:n.documentStyles()})),print:i("print",()=>n.printDocument(),()=>({isEnabled:!0})),paste:i("paste",()=>a.paste(),()=>({isEnabled:e.isCommandEnabled("paste")&&a.canPaste()})),pasteAsPlainText:i("pasteAsPlainText",()=>a.pasteAsPlainText(),()=>({isEnabled:e.isCommandEnabled("pasteAsPlainText")&&a.canPaste()})),cut:i("cut",()=>a.cut(),()=>({isEnabled:e.isCommandEnabled("cut")&&a.hasSelection()&&a.canCut()})),pasteMergeFormatting:i("pasteMergeFormatting",()=>a.pasteMergeFormatting(),()=>({isEnabled:e.isCommandEnabled("pasteMergeFormatting")&&a.canPaste()})),copy:i("copy",()=>a.copy(),()=>({isEnabled:e.isCommandEnabled("copy")&&a.hasSelection()})),newDocument:i("newDocument",()=>n.newDocument()),saveDocument:i("saveDocument",()=>n.saveDocument()),exportDocx:i("exportDocx",()=>n.exportDocx()),exportPdf:i("exportPdf",()=>n.exportPdf()),importDocument:i("importDocument",()=>n.importDocument()),insertHtml:i("insertHtml",e=>{if(!e||"object"!=typeof e||"string"!=typeof e.html)throw new TypeError("insertHtml requires a payload with a string html property.");n.insertHtml(e.html)}),insertImage:i("insertImage",()=>n.insertImage()),insertShape:i("insertShape",e=>n.insertShape(String(e))),setShapeFill:i("setShapeFill",e=>n.setShapeFill(null==e?null:String(e))),setShapeOutline:i("setShapeOutline",e=>n.setShapeOutline(null==e?null:String(e))),setShapeOutlineWidth:i("setShapeOutlineWidth",e=>n.setShapeOutlineWidth(Number(e))),alignFloatingObject:i("alignFloatingObject",e=>n.alignFloatingObject(e??"center")),reorderFloatingObject:i("reorderFloatingObject",e=>n.reorderFloatingObject(e??"front")),nudgeFloatingObject:i("nudgeFloatingObject",e=>{const t=e??{};n.nudgeFloatingObject(Number(t.dx)||0,Number(t.dy)||0)}),setFloatingFixedPosition:i("setFloatingFixedPosition",e=>n.setFloatingFixedPosition(Boolean(e))),setFloatingRotation:i("setFloatingRotation",e=>n.setFloatingRotation(Number(e))),setFloatingWrapPreset:i("setFloatingWrapPreset",e=>n.setFloatingWrapPreset(e??"square")),setFloatingWrapText:i("setFloatingWrapText",e=>n.setFloatingWrapText(e??"bothSides")),setFloatingPositionPreset:i("setFloatingPositionPreset",e=>n.setFloatingPositionPreset(e??"middleCenter")),setShapePreset:i("setShapePreset",e=>n.setShapePreset(null==e?"rect":String(e))),setTextBoxTextDirection:i("setTextBoxTextDirection",e=>n.setTextBoxTextDirection(e??"horz")),setTextBoxVerticalAlign:i("setTextBoxVerticalAlign",e=>n.setTextBoxVerticalAlign(e??"t")),editTextBoxAlt:i("editTextBoxAlt",e=>n.setTextBoxAlt(null==e?null:String(e))),rotateTextBox:i("rotateTextBox",e=>n.rotateTextBox(e??"left")),textBoxWidthCm:i("textBoxWidthCm",e=>n.setTextBoxWidthCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.width??null})),textBoxHeightCm:i("textBoxHeightCm",e=>n.setTextBoxHeightCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.height??null})),openSymbolDialog:i("openSymbolDialog",()=>n.openSymbolDialog()),openCommandSearch:i("openCommandSearch",()=>n.openCommandSearch()),repeatLastAction:i("repeatLastAction",()=>n.repeatLastAction()),openEquationDialog:i("openEquationDialog",()=>n.openEquationDialog()),tableProperties:i("tableProperties",e=>n.openTableProperties(e?.activeTab??"table"),()=>({isEnabled:n.hasActiveTable()})),unlink:i("unlink",()=>o.remove(),()=>({isEnabled:e.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),imageContext:i("imageContext",()=>{},()=>({isEnabled:r.isSelected(),isActive:r.isSelected(),value:null})),imageWidthCm:i("imageWidthCm",e=>r.setWidthCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.width??null})),imageHeightCm:i("imageHeightCm",e=>r.setHeightCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.height??null})),imageCrop:i("imageCrop",()=>r.toggleCrop(),()=>({isEnabled:r.isSelected(),isActive:r.isCropActive()})),imageCropAspect:i("imageCropAspect",e=>r.applyCropAspect(String(e)),()=>({isEnabled:r.isSelected()})),imageCropShape:i("imageCropShape",e=>r.applyCropShape(String(e)),()=>({isEnabled:r.isSelected(),value:r.getCropShape()})),imageCropFill:i("imageCropFill",()=>r.applyCropFill(),()=>({isEnabled:r.isSelected()})),imageCropFit:i("imageCropFit",()=>r.applyCropFit(),()=>({isEnabled:r.isSelected()})),imageCropReset:i("imageCropReset",()=>r.resetCrop(),()=>({isEnabled:r.isSelected()})),imageFlip:i("imageFlip",e=>r.flip(e??"horizontal"),()=>({isEnabled:r.isSelected()})),imageRotate:i("imageRotate",e=>r.rotate(e??"left"),()=>({isEnabled:r.isSelected()})),imageBorder:i("imageBorder",e=>r.setBorder(e),()=>({isEnabled:r.isSelected(),value:r.getBorder()})),imageTransparency:i("imageTransparency",e=>r.setTransparency("number"==typeof e?e:null==e?0:Number(e)),()=>({isEnabled:r.isSelected(),value:r.getTransparency()})),resetImage:i("resetImage",()=>r.reset(),()=>({isEnabled:r.canReset()}))}}function zx({style:e,paragraph:t,section:n,valueCommand:o,actionCommand:r}){const a=e.state;return{outdent:r("outdent",()=>t.outdent()),indent:r("indent",()=>t.indent()),moveParagraphsUp:r("moveParagraphsUp",()=>t.moveParagraphsUp(),()=>({isEnabled:t.canMoveParagraphsUp()})),moveParagraphsDown:r("moveParagraphsDown",()=>t.moveParagraphsDown(),()=>({isEnabled:t.canMoveParagraphsDown()})),togglePageBreakBefore:r("togglePageBreakBefore",()=>t.togglePageBreakBefore(),()=>({isActive:Boolean(a().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>t.toggleKeepWithNext(),()=>({isActive:Boolean(a().keepWithNext)})),toggleKeepLinesTogether:r("toggleKeepLinesTogether",()=>t.toggleKeepLinesTogether(),()=>({isActive:Boolean(a().keepLinesTogether)})),toggleWidowControl:r("toggleWidowControl",()=>t.toggleWidowControl(),()=>({isActive:Boolean(a().widowControl)})),toggleParagraphBidi:r("toggleParagraphBidi",()=>t.setBidi(!a().bidi||null),()=>({isActive:Boolean(a().bidi)})),setParagraphBidi:o("setParagraphBidi",e=>(t.setBidi(Dx(e)),!0),()=>a().bidi),setParagraphAlign:o("setParagraphAlign",e=>(t.setParagraphAlign(e),!0),()=>a().align),sortParagraphs:r("sortParagraphs",e=>t.sortParagraphs(!0===e||"true"===e||Boolean(e?.descending))),promote:r("promote",()=>t.promote()),demote:r("demote",()=>t.demote()),resetParagraphFormatting:r("resetParagraphFormatting",()=>t.resetParagraphFormatting()),setOutlineLevel:r("setOutlineLevel",e=>{const n=e??void 0,o=null==n||"body"===n||""===n?null:Number(n);t.setOutlineLevel(null===o||Number.isNaN(o)?null:o)},()=>({value:Number(e.state().outlineLevel)||null})),setParagraphTabStops:r("setParagraphTabStops",e=>{const n=e??{};t.setTabStops({...void 0!==n.tabs?{tabs:n.tabs}:{},...void 0!==n.set?{set:n.set}:{},...void 0!==n.clear?{clear:n.clear}:{},...void 0!==n.clearAll?{clearAll:n.clearAll}:{},...void 0!==n.default?{default:n.default}:{}})}),setSpacingAfter:o("setSpacingAfter",e=>(t.setSpacingAfter(Lx(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(Lx(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(Dx(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Ex(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Ex(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(Dx(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(Dx(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(Dx(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(Dx(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(Dx(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(Dx(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(Dx(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(Dx(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(Dx(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(Dx(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(Dx(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(Dx(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(Dx(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(Dx(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(Lx(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(Lx(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(Lx(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(Lx(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",Lx(n.value))},()=>{const e=Number(a().indentFirstLine),t=Number(a().indentHanging),n=Number.isFinite(t)&&t>0?"hanging":Number.isFinite(e)&&e>0?"firstLine":"none";return{isActive:"none"!==n,value:n}}),setParagraphShading:o("setParagraphShading",e=>(t.setShading(e??null),!0),()=>a().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>t.applyBorders()),applyHorizontalLine:r("applyHorizontalLine",()=>t.addHorizontalLine()),setDropCap:r("setDropCap",e=>{const n=e??{};t.setDropCap(n)},()=>({value:t.hasDropCap()})),setLineHeight:o("setLineHeight",e=>(t.setLineHeight(Lx(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(Lx(e))),setListLevel:r("setListLevel",e=>t.setListLevel(Lx(e)??0)),toggleOrientation:r("toggleOrientation",()=>n.toggleOrientation(),()=>({isActive:n.isLandscape()})),setOrientation:r("setOrientation",e=>n.setOrientation(e)),sectionBreakNextPage:r("sectionBreakNextPage",()=>n.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>n.breakContinuous()),sectionBreakEvenPage:r("sectionBreakEvenPage",()=>n.breakEvenPage()),sectionBreakOddPage:r("sectionBreakOddPage",()=>n.breakOddPage()),sectionBreakNextColumn:r("sectionBreakNextColumn",()=>n.breakNextColumn()),setPageMargins:r("setPageMargins",e=>{n.setPageMargins(e??{})},()=>({value:n.getMargins()})),setMarginsPreset:r("setMarginsPreset",e=>{"string"==typeof e&&e.length>0&&n.setMarginsPreset(e)}),setSectionPageNumbering:r("setSectionPageNumbering",e=>{const t=e??{};n.setPageNumbering({...void 0!==t.start?{start:Number(t.start)}:{},..."string"==typeof t.format?{format:t.format}:{}})},()=>({value:n.getPageNumbering()})),setPaperSize:r("setPaperSize",e=>{const t=e??{};void 0!==t.widthPt&&void 0!==t.heightPt&&n.setPaperSize({widthPt:Number(t.widthPt),heightPt:Number(t.heightPt)})},()=>({value:n.getPaperSize()})),setPaperSizePreset:r("setPaperSizePreset",e=>{"string"==typeof e&&e.length>0&&n.setPaperSizePreset(e)}),setColumns:r("setColumns",e=>{const t=e??{};void 0!==t.count&&n.setColumns({count:Number(t.count),...void 0!==t.space?{space:Number(t.space)}:{},...void 0!==t.separator?{separator:Boolean(t.separator)}:{}})}),setColumnsPreset:r("setColumnsPreset",e=>{if("string"==typeof e&&e.length>0){const t=go(e);if(!t)return;n.setColumns({count:t.count})}}),setSectionVerticalAlign:r("setSectionVerticalAlign",e=>{const t=e??void 0;void 0!==t&&"top"!==t&&"center"!==t&&"both"!==t&&"bottom"!==t||n.setVerticalAlign(t??"top")},()=>({value:n.getVerticalAlign()})),setSectionStart:r("setSectionStart",e=>{const t=e??void 0;void 0!==t&&"nextPage"!==t&&"continuous"!==t&&"evenPage"!==t&&"oddPage"!==t&&"nextColumn"!==t||n.setSectionStart(t??"nextPage")},()=>({value:n.getSectionStart()})),setSectionBidi:r("setSectionBidi",e=>{const t=e??void 0;n.setBidi(t??!0)},()=>({value:n.getBidi()})),setHyphenation:r("setHyphenation",e=>{const t=e??{};n.setHyphenation(t)},()=>({value:n.getHyphenation().value}))}}function Hx({gate:e,headerFooter:t,command:n,actionCommand:o}){return{editHeader:n("editHeader",()=>(t.editHeader(),!0)),editFooter:n("editFooter",()=>(t.editFooter(),!0)),editFirstPageHeader:n("editFirstPageHeader",()=>(t.editFirstPageHeader(),!0)),editEvenPageHeader:n("editEvenPageHeader",()=>(t.editEvenPageHeader(),!0)),editFirstPageFooter:n("editFirstPageFooter",()=>(t.editFirstPageFooter(),!0)),editEvenPageFooter:n("editEvenPageFooter",()=>(t.editEvenPageFooter(),!0)),insertPageNumber:n("insertPageNumber",()=>(t.insertPageNumber(),!0)),insertPageNumberXOfY:n("insertPageNumberXOfY",()=>(t.insertPageNumberXOfY(),!0)),placePageNumberTop:n("placePageNumberTop",()=>(t.placePageNumberTop(),!0)),placePageNumberBottom:n("placePageNumberBottom",()=>(t.placePageNumberBottom(),!0)),exitHeaderFooter:o("exitHeaderFooter",()=>t.exit(),()=>({isEnabled:e.isCommandEnabled("exitHeaderFooter")&&t.isInHeaderFooter()})),setDifferentFirstPage:o("setDifferentFirstPage",e=>{const n=e??void 0;t.setDifferentFirstPage(n??!0)},()=>({value:t.getDifferentFirstPage()})),setDifferentOddEven:o("setDifferentOddEven",e=>{const n=e??void 0;t.setDifferentOddEven(n??!0)},()=>({value:t.getDifferentOddEven()}))}}function Wx({bookmark:e,actionCommand:t}){return{insertBookmark:t("insertBookmark",t=>{e.insert("string"==typeof t&&t.trim().length>0?t:void 0)}),removeBookmark:t("removeBookmark",t=>{"string"==typeof t&&e.remove(t)})}}function Ux({fields:e,actionCommand:t}){return{insertDateField:t("insertDateField",()=>{e.insertDate()}),insertDateTime:t("insertDateTime",t=>{const n=t??{};e.insertDateTime(n.dateFormat)}),insertCrossReference:t("insertCrossReference",t=>{const n=t??{};if("string"!=typeof n.bookmark||0===n.bookmark.length)return;const o="PAGEREF"===n.type?"PAGEREF":"REF";e.insertCrossReference({type:o,bookmark:n.bookmark})})}}function jx({gate:e,table:t,actionCommand:n,valueCommand:o}){return{tableContext:n("tableContext",()=>{},()=>({isEnabled:t.insideTable(),isActive:t.insideTable(),value:t.selectionLabel()})),tableMerge:n("tableMerge",()=>t.merge(),()=>({isEnabled:e.isCommandEnabled("tableMerge")&&t.canMerge()})),tableSplit:n("tableSplit",()=>t.split(),()=>({isEnabled:e.isCommandEnabled("tableSplit")&&t.canSplit()})),tableToText:n("tableToText",()=>t.convertToText(),()=>({isEnabled:e.isCommandEnabled("tableToText")&&t.canConvertToText()})),textToTable:n("textToTable",()=>t.convertToTable(),()=>({isEnabled:e.isCommandEnabled("textToTable")&&t.canConvertToTable()})),tableSplitAtRow:n("tableSplitAtRow",()=>t.splitTableAtRow(),()=>({isEnabled:e.isCommandEnabled("tableSplitAtRow")&&t.canSplitTableAtRow()})),tableSortAscending:n("tableSortAscending",()=>t.sortTable("ascending"),()=>({isEnabled:e.isCommandEnabled("tableSortAscending")&&t.canSortTable()})),tableSortDescending:n("tableSortDescending",()=>t.sortTable("descending"),()=>({isEnabled:e.isCommandEnabled("tableSortDescending")&&t.canSortTable()})),tableDelete:n("tableDelete",()=>t.deleteTable(),()=>({isEnabled:e.isCommandEnabled("tableDelete")&&t.canDeleteTable()})),tableRepeatHeaderRows:n("tableRepeatHeaderRows",()=>t.toggleRepeatHeaderRows(),()=>({isEnabled:e.isCommandEnabled("tableRepeatHeaderRows")&&t.canToggleRepeatHeaderRows(),isActive:t.isRepeatHeaderRowsActive()})),tableInsertColumnBefore:n("tableInsertColumnBefore",()=>t.insertColumnBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnBefore")&&t.canEditColumn()})),tableInsertColumnAfter:n("tableInsertColumnAfter",()=>t.insertColumnAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnAfter")&&t.canEditColumn()})),tableDeleteColumn:n("tableDeleteColumn",()=>t.deleteColumn(),()=>({isEnabled:e.isCommandEnabled("tableDeleteColumn")&&t.canEditColumn()})),tableInsertRowBefore:n("tableInsertRowBefore",()=>t.insertRowBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowBefore")&&t.canEditRow()})),tableInsertRowAfter:n("tableInsertRowAfter",()=>t.insertRowAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowAfter")&&t.canEditRow()})),tableDeleteRow:n("tableDeleteRow",()=>t.deleteRow(),()=>({isEnabled:e.isCommandEnabled("tableDeleteRow")&&t.canEditRow()})),tableDeleteCells:n("tableDeleteCells",()=>t.deleteCell(),()=>({isEnabled:e.isCommandEnabled("tableDeleteCells")&&t.canDeleteCell()})),tableCellShading:n("tableCellShading",e=>t.cellShading(e??null)),tableCellBorders:n("tableCellBorders",()=>t.cellBorders()),tableCellNoBorders:n("tableCellNoBorders",()=>t.cellNoBorders()),tableApplyBorderPreset:n("tableApplyBorderPreset",e=>t.applyBorderPreset(e)),toggleTableDrawBorders:n("toggleTableDrawBorders",()=>t.toggleDrawingBorders(),()=>({isEnabled:t.insideTable(),isActive:t.isDrawingBorders()})),toggleTableGridlines:n("toggleTableGridlines",()=>t.toggleGridlines(),()=>({isEnabled:t.insideTable(),isActive:t.isShowingGridlines()})),tableWidth100:n("tableWidth100",()=>t.width100()),tableAlignLeft:n("tableAlignLeft",()=>t.alignLeft()),tableAlignCenter:n("tableAlignCenter",()=>t.alignCenter()),tableAlignRight:n("tableAlignRight",()=>t.alignRight()),tableSetCellAlignment:n("tableSetCellAlignment",e=>t.setCellAlignment(e),()=>({value:t.getCellAlignmentState()})),tableSetCellVerticalAlign:n("tableSetCellVerticalAlign",e=>t.setCellVerticalAlign(e)),tableSetCellTextDirection:n("tableSetCellTextDirection",e=>t.setCellTextDirection(e)),tableSetCellWidth:n("tableSetCellWidth",e=>t.setCellWidth(String(e))),tableSetCellNoWrap:n("tableSetCellNoWrap",e=>t.setCellNoWrap(Dx(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(Dx(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(Dx(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(Dx(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetHeaderRow")&&t.canSetActiveTableRowHeader()})),tableSetColumnWidth:o("tableSetColumnWidth",e=>(t.setActiveTableColumnWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetColumnWidth")&&t.canSetActiveTableColumnWidth()})),tableSetTableWidth:o("tableSetTableWidth",e=>(t.setActiveTableWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetTableWidth")&&t.canSetActiveTableWidth()})),tableSetCellMargins:n("tableSetCellMargins",e=>t.setCellMargins(e??{}),()=>({isEnabled:e.isCommandEnabled("tableSetCellMargins")&&t.canSetCellMargins()})),tableSetCellSpacing:n("tableSetCellSpacing",e=>t.setCellSpacing(Lx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(Lx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Ex(e)),()=>({isEnabled:e.isCommandEnabled("tableSetAlignment")&&t.canSetTableAlignment()})),tableFormula:n("tableFormula",e=>t.evaluateTableFormula(String(e)),()=>({isEnabled:e.isCommandEnabled("tableFormula")&&t.canEvaluateTableFormula()})),tableSelectCell:n("tableSelectCell",()=>t.selectTablePart("cell"),()=>({isEnabled:e.isCommandEnabled("tableSelectCell")&&t.canSelectTable()})),tableSelectRow:n("tableSelectRow",()=>t.selectTablePart("row"),()=>({isEnabled:e.isCommandEnabled("tableSelectRow")&&t.canSelectTable()})),tableSelectColumn:n("tableSelectColumn",()=>t.selectTablePart("column"),()=>({isEnabled:e.isCommandEnabled("tableSelectColumn")&&t.canSelectTable()})),tableSelectTable:n("tableSelectTable",()=>t.selectTablePart("table"),()=>({isEnabled:e.isCommandEnabled("tableSelectTable")&&t.canSelectTable()})),tableToggleHeaderRow:n("tableToggleHeaderRow",()=>t.toggleTblLook("firstRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstRow??!1})),tableToggleTotalRow:n("tableToggleTotalRow",()=>t.toggleTblLook("lastRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastRow??!1})),tableToggleBandedRows:n("tableToggleBandedRows",()=>t.toggleTblLook("bandedRows"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedRows??!1})),tableToggleFirstColumn:n("tableToggleFirstColumn",()=>t.toggleTblLook("firstCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstCol??!1})),tableToggleLastColumn:n("tableToggleLastColumn",()=>t.toggleTblLook("lastCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastCol??!1})),tableToggleBandedColumns:n("tableToggleBandedColumns",()=>t.toggleTblLook("bandedCols"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedCols??!1})),setTableStyle:n("setTableStyle",e=>t.setStyleId(String(e??"")),()=>({isEnabled:t.insideTable(),value:t.getStyleId()})),tableToggleAutoFit:n("tableToggleAutoFit",()=>t.toggleAutoFit(),()=>({isEnabled:t.insideTable(),isActive:"autofit"===t.getLayout()})),tableAutoFit:n("tableAutoFit",e=>t.setAutoFit(e??"contents"),()=>({isEnabled:t.canSetAutoFit()})),tableDistributeColumns:n("tableDistributeColumns",()=>t.distributeColumns(),()=>({isEnabled:e.isCommandEnabled("tableDistributeColumns")&&t.canEditColumn()})),tableDistributeRows:n("tableDistributeRows",()=>t.distributeRows(),()=>({isEnabled:e.isCommandEnabled("tableDistributeRows")&&t.canEditRow()})),insertTable:n("insertTable",e=>{const{rows:n,cols:o,columns:r}=e??{},a=o??r;n&&a&&t.insert(n,a)})}}function Vx({design:e,actionCommand:t}){return{applyDocumentTheme:t("applyDocumentTheme",t=>e.applyTheme(String(t)),()=>({value:e.getDesign()?.themeId})),setDocumentColorScheme:t("setDocumentColorScheme",t=>e.setColorScheme(String(t)),()=>({value:e.getDesign()?.colorSchemeId})),setDocumentFontScheme:t("setDocumentFontScheme",t=>e.setFontScheme(String(t)),()=>({value:e.getDesign()?.fontSchemeId})),setDocumentParagraphSpacing:t("setDocumentParagraphSpacing",t=>e.setParagraphSpacing(String(t)),()=>({value:e.getDesign()?.paragraphSpacingId})),setDocumentEffects:t("setDocumentEffects",t=>e.setEffects(String(t)),()=>({value:e.getDesign()?.effectsId})),setDocumentPageColor:t("setDocumentPageColor",t=>e.setPageColor(t??null),()=>({value:e.getDesign()?.pageColor})),setDocumentWatermark:t("setDocumentWatermark",t=>e.setWatermark(t??null),()=>({value:e.getDesign()?.watermark})),setDocumentPageBorder:t("setDocumentPageBorder",t=>e.setPageBorder(t??null),()=>({value:e.getPageBorder()})),setDocumentDesignDefault:t("setDocumentDesignDefault",()=>e.setDefault())}}function Kx({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",()=>{e.openParagraphDialog()})}}var _x=/* @__PURE__ */new Set(["copy","selectAll","selectWord","selectSentence","selectParagraph","selectCollapse","nextRevision","previousRevision","nextComment","previousComment","toggleCommentsPanel","find","replace","print","exportDocx","exportPdf","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","toggleRevisionMarkup","showMarkupOptions","applyShowMarkup","toggleRevisionsPanel","toggleOutlinePanel","setReviewDisplayMode","imageContext","tableContext","toggleTableGridlines","documentStyles"]),Xx=/* @__PURE__ */new Set(["bold","italic","underline","doubleUnderline","wordUnderline","strike","doubleStrike","smallCaps","allCaps","hidden","noProof","webHidden","specVanish","contextualAlternates","characterBorder","shadow","emboss","engrave","outline","superscript","subscript","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","growFont1","shrinkFont1","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setCharacterStyleId","setUnderlineStyle","applyUnderlineStyle","setUnderlineColor","setCharacterScale","setCharacterSpacing","setRunSnapToGrid","setFitText","setBaselineShift","setEmphasisMark","setTextEffect","setKerning","setLigatures","setNumberSpacing","setNumberForm","setStylisticSet"]),Gx=/* @__PURE__ */new WeakMap;function qx(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!Xx.has(t)||!function(e){const t=e.state?.();if(!t)return!1;const n=t.document,o=t.selection;if(!n||!o)return!1;let r=Gx.get(n);r||(r=/* @__PURE__ */new WeakMap,Gx.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==db(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((_x.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function Yx(e){return{state:()=>e.styleController.toolbarStyleState()}}function Zx(e){return{isCollapsed:()=>zr(e.state().selection)}}function Jx(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var Qx={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function ew(e){return/\p{L}|\p{N}/u.test(e)}function tw(e){return"."===e||"!"===e||"?"===e}function nw(e,t){return Z(e,t)}function ow(e,t,n,o){return e-n||t-o}function rw(e,t){const n=Kr(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:nw(o,t.startOffset),focus:nw(r,t.endOffset)}}:e}function aw(e,t,n){if(!t.length)return null;const o=Kr(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?Wn(e,o).end:Wn(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=Bt(l,a);return("next"===n?t.find(e=>ow(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>ow(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function iw(e){const t=Kr(e),n=[],o=/* @__PURE__ */new Set;return t.forEach((e,t)=>{let r=0;for(const a of e.runs){const e=a.revision?.id;e&&!o.has(e)&&(o.add(e),n.push({id:e,startIndex:t,startOffset:r,endIndex:t,endOffset:r+a.text.length})),r+=a.text.length}}),n}function lw(e,t){const n=aw(e,iw(e),t);return n?rw(e,n):e}function sw(e){const t=Kr(e),n=new Map(t.map((e,t)=>[e.id,t])),o=e.document.comments;if(!o)return[];const r=[];for(const a of o.order){const e=o.items[a];if(!e?.start||!e.end)continue;const i=n.get(e.start.paragraphId),l=n.get(e.end.paragraphId);if(void 0===i||void 0===l)continue;const s=t[i],c=t[l],d=Math.max(0,Math.min(e.start.offset,s.runs.reduce((e,t)=>e+t.text.length,0))),u=Math.max(0,Math.min(e.end.offset,c.runs.reduce((e,t)=>e+t.text.length,0)));ow(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>ow(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function cw(e,t){const n=aw(e,sw(e),t);return n?rw(e,n):e}function dw(e){const t=sw(e);if(!t.length)return null;const n=Wn(e),o=t.find(e=>0===ow(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===ow(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>ow(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&ow(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function uw(e,t){const n=iw(e).find(e=>e.id===t);return n?rw(e,n):e}var pw=e=>Math.round(e/zo*96);function gw(e,t=3){const n=[];for(const o of T(e.document)){const e=ga(o.style?.styleId);if(null===e||e>t)continue;const r=Lt(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function fw(e){const t=bo(e.text).id;return e.fieldChar?{id:t,text:e.text,kind:"fieldChar",fieldChar:e.fieldChar}:void 0!==e.fieldInstruction?{id:t,text:e.text,kind:"fieldInstruction",fieldInstruction:e.fieldInstruction}:{id:t,text:e.text,kind:"text"}}function mw(e,t){const n=pr("");return n.runs=e,t&&(n.style=t),n}function hw(e,t,n){const o=void 0!==t?String(t):"";return mw([fw({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:pw(40),indentLeft:pw(397*(e.level-1))})}function bw(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return c(o*ar,2)}function yw(e,t,n,o){const r=Fe(e.document),a=r[t];if(!a)return e;const i=[...r];return i[t]={...a,blocks:n},{...e,document:{...e.document,sections:i},selection:oe(Z(o,0))}}function vw(e,t=()=>{},n=3){if("main"!==io(e))return e;const o=fo(e),r=Fe(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>hw(e,t(e.id),n));return[mw([fw({text:"",fieldChar:{kind:"begin"}}),fw({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),fw({text:"",fieldChar:{kind:"separate"}})]),...o,mw([fw({text:"",fieldChar:{kind:"end"}})])]}(gw(e,n),t,bw(r)),i=nr(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&Po(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return yw(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function xw(e){let t=0,n="",o=-1,r=-1,a=!1;for(let i=0;i<e.length;i+=1){const l=e[i];if("paragraph"===l.type)for(const e of l.runs){const l=dn(e),s=rt(e);if("begin"===l?.kind)t+=1,1===t&&(r=i,n="",a=!1,o=-1);else if(1===t&&void 0!==s)n+=s,/\bTOC\b/i.test(n)&&(a=!0);else if("separate"===l?.kind)1===t&&(o=i);else if("end"===l?.kind){if(1===t&&a)return{startBlockIndex:o>=0?o:r,endBlockIndex:i};t=Math.max(0,t-1)}}}return null}function ww(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?xo(n):11,r="increase"===t?tr(o):Dn(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",Sr(r)),!0},n=e=>{const t=Tr(e.document),n=/* @__PURE__ */new Map;for(const o of t.pages)for(const e of o.blocks){const t=e.paragraphId;t&&!n.has(t)&&n.set(t,o.index+1)}return e=>n.get(e)};return{formatPainterOnce:e.formatPainter.armOnce,formatPainterContinuous:e.formatPainter.armContinuous,cancelFormatPainter:()=>(e.formatPainter.cancel(),!0),formatPainterMode:e.formatPainter.mode,canCaptureFormatPainter:e.formatPainter.canCapture,selectAll:()=>{const t=T(e.state().document);if(0===t.length)return!1;const n=t[0],o=t[t.length-1];return e.applyState({...e.state(),selection:{anchor:Z(n,0),focus:Z(o,Lt(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ne(e),o=Lt(t);let r=n,a=n;for(;r>0&&ew(o[r-1]);)r-=1;for(;a<o.length&&ew(o[a]);)a+=1;return Aa(e,{anchor:Z(t,r),focus:Z(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ne(e),o=Lt(t);let r=n;for(;r>0&&!tw(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!tw(o[a]);)a+=1;return a<o.length&&(a+=1),Aa(e,{anchor:Z(t,r),focus:Z(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=Kr(e),n=Wn(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Aa(e,{anchor:Z(o,0),focus:Z(r,u(r))}):e}(e.state())),e.focusInput(),!0),selectCollapse:(t=!1)=>!e.isReadOnly()&&(e.applyState(function(e,t=!1){const n=e.selection.anchor,o=e.selection.focus,r=Kr(e),a=Pr(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Aa(e,{anchor:i,focus:i})}(e.state(),t)),e.focusInput(),!0),selectText:(t,n=1)=>0!==t.length&&(e.applyState(function(e,t,n=1){const o=Qy(e.document,t)[Math.max(1,n)-1];return o?Aa(e,{anchor:o.anchor,focus:o.focus}):e}(e.state(),t,n)),e.focusInput(),!0),selectRange:(t,n)=>(e.applyState(function(e,t,n){return Aa(e,{anchor:t,focus:n})}(e.state(),t,n)),e.focusInput(),!0),insertFootnote:()=>(e.commandsController.applyInsertFootnoteCommand(),!0),setNoteOptions:t=>{e.applyTransactionalState(e=>function(e,t){const n=t.kind,o={...("endnote"===n?e.document.endnotes?.settings:e.document.footnotes?.settings)??{}};let r=!1;if(void 0!==t.numberFormat){const e=null===t.numberFormat?void 0:t.numberFormat;o.numberFormat!==e&&(o.numberFormat=e,r=!0)}if(void 0!==t.startAt){const e=null===t.startAt?void 0:Math.max(1,Math.round(t.startAt));o.startAt!==e&&(o.startAt=e,r=!0)}if(void 0!==t.restart){const e=null===t.restart?void 0:t.restart;o.restart!==e&&(o.restart=e,r=!0)}if(!r)return e;const a=Object.keys(o).length>0?{...o}:void 0;if("endnote"===n){const t=e.document.endnotes??{items:{}};return{...e,document:{...e.document,endnotes:{...t,settings:a}}}}const i=e.document.footnotes??{items:{}};return{...e,document:{...e.document,footnotes:{...i,settings:a}}}}(e,{kind:t.kind,...void 0!==t.numberFormat?{numberFormat:null===t.numberFormat?null:t.numberFormat}:{},...void 0!==t.startAt?{startAt:t.startAt}:{},...void 0!==t.restart?{restart:null===t.restart?null:t.restart}:{}})),e.focusInput()},getNoteOptions:t=>function(e,t){return"endnote"===t?{...e.document.endnotes?.settings??{}}:{...e.document.footnotes?.settings??{}}}(e.state(),t),insertText:(t,n)=>{if(0===t.length)return!1;const o=n?{fontFamily:n}:void 0;return e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>za(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=Y(o,a),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},s=d(o,a,[l]),c=Kr(n).map((e,t)=>t===r?s:e);return Ie(n,c,oe(Z(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=Kr(e).map(e=>{let r=!1;const a=e.runs.map(e=>e.id!==t||"math"!==e.kind?e:(o=!0,r=!0,{...e,math:n,text:""}));return r?{...e,runs:a}:e});return o?Ie(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=Fe(e.document)[fo(e)];return!!t&&null!==xw(t.blocks)}(e.state()),hasRevisionsInSelection:()=>fx(e.state()).size>0,hasRevisionsInDocument:()=>hx(e.state()),hasNavigableRevisions:()=>iw(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),sw(t).map(e=>e.id)).length>0;var t},canCreateComment:e.commentComposer.canCreate,canReplyToComment:e.commentComposer.canReply,newComment:e.commentComposer.openNew,replyComment:e.commentComposer.openReply,editComment:e.commentComposer.openEdit,toggleCommentsPanel:e.commentComposer.togglePanel,isCommentsPanelOpen:e.commentComposer.panelOpen,canEditComment:e.commentComposer.canEdit,navigateRevisionNext:()=>{const t=e.state(),n=lw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=lw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=cw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=cw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==dw(e.state()),isSelectedCommentResolved:()=>Boolean(dw(e.state())?.resolved),canManageSelectedComment:e.commentComposer.canResolveSelected,resolveSelectedComment:()=>e.commentComposer.resolveSelected(!0),reopenSelectedComment:()=>e.commentComposer.resolveSelected(!1),deleteSelectedComment:e.commentComposer.deleteSelected,canDeleteSelectedComment:e.commentComposer.canDeleteSelected,insertTableOfContents:()=>(e.applyTransactionalState(e=>vw(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=fo(e),r=Fe(e.document)[o];if(!r)return e;const a=xw(r.blocks);if(!a)return e;const i=gw(e,n).map(e=>hw(e,t(e.id),bw(r)));return yw(e,o,[...r.blocks.slice(0,a.startBlockIndex+1),...i,...r.blocks.slice(a.endBlockIndex)],i[0]??r.blocks[a.startBlockIndex])}(e,n(e))),e.focusInput(),!0),pastePlainText:()=>(e.forcePlainTextPaste.set(!0),e.focusInput(),!0),bold:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),doubleUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"double"===e.styleController.toolbarStyleState().underlineStyle?null:"double"),!0),wordUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"words"===e.styleController.toolbarStyleState().underlineStyle?null:"words"),!0),strike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),doubleStrike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("doubleStrike"),!0),smallCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("smallCaps"),!0),allCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("allCaps"),!0),hidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("hidden"),!0),noProof:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("noProof"),!0),webHidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("webHidden"),!0),specVanish:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("specVanish"),!0),contextualAlternates:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("contextualAlternates"),!0),toggleCharacterBorder:()=>(e.keyboardCommandsController.applyToggleCharacterBorderCommand(),!0),shadow:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("shadow"),!0),emboss:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("emboss"),!0),engrave:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("imprint"),!0),outline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("outline"),!0),superscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(e.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(e.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(e.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(e.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(e.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(e.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(e.findReplace.setIsOpen(!0),!0),replace:()=>(e.findReplace.setIsOpen(!0),!0),replaceAll:t=>(e.isReadOnly()||(e.applyTransactionalState(e=>ev(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:ll}),e.focusInput()),!0),isTrackChangesEnabled:()=>Boolean(e.state().trackChangesEnabled),areMarginsVisible:()=>Boolean(e.state().showMargins),areParagraphMarksVisible:()=>Boolean(e.state().showParagraphMarks),areRevisionMarkupVisible:()=>Boolean(e.state().showRevisionMarkup??!0),areOutlineVisible:()=>e.isOutlineVisible(),toggleRevisionsPanel:()=>(e.toggleRevisionsPanel(),!0),areRevisionsPanelVisible:()=>e.revisionsPanelVisible(),reviewDisplayMode:()=>e.state().reviewDisplayMode??"all",setReviewDisplayMode:t=>(e.commandsController.applySetReviewDisplayModeCommand(t),!0),showMarkupOptions:()=>function(e){const t=void 0===e.markupAuthors;return{insertions:$b(e,"insertions"),deletions:$b(e,"deletions"),comments:$b(e,"comments"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Kb(e)}}(e.state()),applyShowMarkup:t=>(e.commandsController.applyShowMarkupCommand(t),!0),toggleTrackChanges:()=>(e.commandsController.applyToggleTrackChangesCommand(),!0),toggleRevisionMarkup:()=>(e.commandsController.applyToggleRevisionMarkupCommand(),!0),toggleOutlinePanel:()=>(e.toggleOutlinePanel(),!0),acceptRevisions:()=>(e.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(e.commandsController.applyRejectRevisionsCommand(),!0),acceptAllRevisions:()=>(e.commandsController.applyAcceptAllRevisionsCommand(),!0),rejectAllRevisions:()=>(e.commandsController.applyRejectAllRevisionsCommand(),!0),toggleShowMargins:()=>(e.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(e.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(Q(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Zr(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>za(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Ha(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Fo(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return za(e,Qx[t])}(e,t))),e.focusInput(),!0),setFontFamily:t=>(e.styleController.applyToolbarValueStyleCommand("fontFamily",t),!0),setFontSize:t=>(e.styleController.applyToolbarValueStyleCommand("fontSize",t),!0),increaseFontSize:()=>t("increase"),decreaseFontSize:()=>t("decrease"),growFont1:()=>(e.applyTransactionalState(e=>Xa(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>Xa(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>zr(e.state().selection)?(e.styleController.clearPendingCaretTextStyle(),e.focusInput(),!0):(e.commandsController.applyClearFormattingCommand(),!0),setColor:t=>(e.styleController.applyToolbarValueStyleCommand("color",t),!0),setHighlight:t=>(e.styleController.applyToolbarValueStyleCommand("highlight",t),!0),setTextShading:t=>(e.styleController.applyToolbarValueStyleCommand("shading",t),!0),setStyleId:t=>(e.commandsController.handleStyleChange(t),!0),setCharacterStyleId:t=>(e.styleController.applyToolbarValueStyleCommand("styleId",t||null),!0),applyUnderlineStyle:e.styleController.applyToolbarUnderlineStyleCommand,setUnderlineStyle:t=>e.styleController.applyToolbarValueStyleCommand("underlineStyle",t),setUnderlineColor:t=>(e.styleController.applyToolbarValueStyleCommand("underlineColor",t),!0),setCharacterScale:t=>(e.styleController.applyToolbarValueStyleCommand("characterScale",t),!0),setCharacterSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("characterSpacing",t),!0),setRunSnapToGrid:t=>(e.styleController.applyToolbarValueStyleCommand("snapToGrid",t),!0),setFitText:t=>(e.styleController.applyToolbarValueStyleCommand("fitText",t),!0),setBaselineShift:t=>(e.styleController.applyToolbarValueStyleCommand("baselineShift",t),!0),setEmphasisMark:t=>(e.styleController.applyToolbarValueStyleCommand("emphasisMark",t),!0),setTextEffect:t=>(e.styleController.applyToolbarValueStyleCommand("textEffect",t),!0),setKerning:t=>(e.styleController.applyToolbarValueStyleCommand("kerningThreshold",t),!0),setLigatures:t=>(e.styleController.applyToolbarValueStyleCommand("ligatures",t||null),!0),setNumberSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("numberSpacing",t||null),!0),setNumberForm:t=>(e.styleController.applyToolbarValueStyleCommand("numberForm",t||null),!0),setStylisticSet:t=>(e.styleController.applyToolbarValueStyleCommand("stylisticSet",t),!0)}}function Sw(e,t){const n=ay(e),o=n&&Er(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,n)=>n!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function Cw(e,t){return{...e??{type:"floating",allowOverlap:!0,positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none"===e?.wrap?e.wrap:e?.wrap??"square",behindDoc:e?.behindDoc,positionH:{relativeFrom:"margin",align:t,offset:0}}}function Iw(e,t,n){const o={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"},r=o.positionH??{},a=o.positionV??{};return{...o,wrap:"none"===o.wrap?o.wrap:o.wrap??"square",positionH:{...r,offset:(r.offset??0)+Math.round(t*In),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*In)}}}function Tw(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function kw(e,t,n=90){return Pw(e,e=>{const o="right"===t?-n:n,r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}((e.rotation??0)+o);return{...e,rotation:r}})}function Pw(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Gn(e))});return Ie(e,a,$(a,Wn(e)))}function Rw(e,t){return Pw(e,e=>({...e,body:t(e.body??{})}))}function Bw(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of T(t)){e.style?.styleId&&o.add(e.style.styleId);for(const t of e.runs)t.styles?.styleId&&o.add(t.styles.styleId)}return Object.values(n).map(e=>{const t=va(e.id,n),r="table"===e.type?jo(e.id,n).tableStyle:void 0,a=r?.conditionalFormats?.wholeTable,i=r?.conditionalFormats?.firstRow,l=r?.conditionalFormats?.band1Horz,s=a?.borders?.borderBottom??r?.borders?.borderBottom;return{id:e.id,name:e.name,type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:t.fontFamily?.trim()||void 0,fontSize:"number"==typeof t.fontSize?t.fontSize:void 0,color:t.color??void 0,bold:t.bold??void 0,italic:t.italic??void 0,tablePreview:r?{wholeFill:a?.shading,headerFill:i?.shading,bandFill:l?.shading,borderColor:s?.color,headerColor:i?.textStyle?.color??void 0}:void 0}})},newDocument:()=>e.newDocument(),saveDocument:()=>e.saveDocument(),openSymbolDialog:()=>e.openSymbolDialog(),openCommandSearch:()=>e.openCommandSearch(),repeatLastAction:()=>e.repeatLastAction(),openEquationDialog:()=>e.openEquationDialog(),hasActiveTable:()=>fc(e.state()),openTableProperties:t=>e.openTablePropertiesDialog(t??"table"),exportDocx:()=>{e.docIO.handleExportDocx()},exportPdf:()=>{e.docIO.handleExportPdf()},printDocument:()=>{e.docIO.handlePrint()},importDocument:()=>e.importInputRef()?.click(),insertImage:()=>e.imageInputRef()?.click(),insertHtml:t=>e.applyTransactionalState(e=>function(e,t){if(!t.trim())return e;const n=K(t),o=$e(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return Da(e,o.map(e=>({runs:e.runs.map(e=>({text:e.text,styles:e.styles,..."image"===e.kind?{image:e.image}:{}})),style:e.style,list:e.list})));const r=zr(e.selection)?e:Me(e),{paragraph:a,offset:i}=Ne(r),l=Rt(a,0,i),s=Rt(a,i,u(a)),c=pr(""),d={...a,runs:l.length?l:pr("").runs},p={...a,id:c.id,runs:s.length?s:c.runs},g=[...i>0?[d]:[],...o,...s.length||"table"===o[o.length-1]?.type?[p]:[]];let f=!1;const m=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===a.id)return f=!0,t=!0,g;if("table"!==e.type)return[e];let n=!1;const o=e.rows.map(e=>{let t=!1;const o=e.cells.map(e=>{const n=m(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:o}):e});return n?(t=!0,[{...e,rows:o}]):[e]});return t?n:e},h=r.activeZone??"main";let b=r.document;if("footnote"===h&&r.activeFootnoteId&&r.document.footnotes?.items[r.activeFootnoteId]){const e=r.document.footnotes,t=e.items[r.activeFootnoteId],n=m(t.blocks);f&&(b={...r.document,footnotes:{...e,items:{...e.items,[r.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=$e(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const a="header"===h?"header":"footer"===h?"footer":"blocks",i=m(o[a]??[]);if(f){const e=[...t];e[n]={...o,[a]:i},b={...r.document,sections:e}}}if(!f)return e;const y=o[o.length-1],v="paragraph"!==y.type||s.length?Z(p,0):Z(y,u(y));return{...r,document:b,selection:oe(v)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=function(e){switch(e.document.design?.effectsId){case"flat":return{fill:"#e2e8f0",border:"#64748b"};case"intense":return{fill:"#0f766e",border:"#115e59"};case"moderate":return{fill:"#5b9bd5",border:"#2f75b5"};default:return{fill:"#4472C4",border:"#2F528F"}}}(n),l={width:150,height:100,blocks:[pr("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:ub(void 0,"front")},s=co("",Y(o,a),void 0,l),c=d(o,a,[s]),u=Kr(n).map((e,t)=>t===r?c:pn(e));return Ie(n,u,oe(Z(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:_l}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Sw(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Xl}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:Gl}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==r.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:Cw(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Cw(e.textBox.floating,t)}}:Gn(e))});return Ie(e,a,$(a,Wn(e)))}(e,t),{mergeKey:ql}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=e=>({...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none",behindDoc:"back"===t}),i=Kr(e).map((e,t)=>t!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==r.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:a(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:a(e.textBox.floating)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:Yl}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=Kr(e).map((e,o)=>o!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:Iw(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Iw(e.textBox.floating,t,n)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t,n),{mergeKey:Zl}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Gn(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?gb(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?gb(n,t):n}}}return Gn(e)})});return Ie(e,a,$(a,Wn(e)))}(e,t),{mergeKey:Jl}),setFloatingRotation:t=>e.applyTransactionalState(e=>Tw(e,t),{mergeKey:Ql}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>ub(e,t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Gn(e);if("image"===e.kind){const t=o(e.image.floating),n=t?{...e.image,floating:t}:(()=>{const{floating:t,...n}=e.image;return n})();return{...e,image:n}}if("textBox"===e.kind){const t=o(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return Gn(e)})});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:es}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:o(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:o(e.textBox.floating)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:ts}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:o,v:r}=function(e){return{h:e.endsWith("Left")?"left":e.endsWith("Right")?"right":"center",v:e.startsWith("top")?"top":e.startsWith("bottom")?"bottom":"ctr"}}(t),a={relativeFrom:"margin",align:o,offset:0},i={relativeFrom:"margin",align:r,offset:0},{paragraphIndex:l,run:s}=n,c=Kr(e).map((e,t)=>t!==l?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==s.id)return Gn(e);if("image"===e.kind){const t={...e.image.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.image.floating?.wrap?e.image.floating.wrap:e.image.floating?.wrap??"square",behindDoc:e.image.floating?.behindDoc,positionH:a,positionV:i};return{...e,image:{...e.image,floating:t}}}if("textBox"===e.kind){const t={...e.textBox.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.textBox.floating?.wrap?e.textBox.floating.wrap:e.textBox.floating?.wrap??"square",behindDoc:e.textBox.floating?.behindDoc,positionH:a,positionV:i};return{...e,textBox:{...e.textBox,floating:t}}}return Gn(e)})});return Ie(e,c,$(c,Wn(e)))}(e,t),{mergeKey:ns}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,preset:t}))}(e,t),{mergeKey:os}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Rw(e,e=>({...e,vert:n}))}(e,t),{mergeKey:rs}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Rw(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:as}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:is}),rotateTextBox:t=>e.applyTransactionalState(e=>kw(e,t),{mergeKey:ls}),getTextBoxSizeCm:()=>function(e){const t=ay(e),n=t&&Er(t.run);return n?{width:n.width/Ar,height:n.height/Ar}:null}(e.state()),isTextBoxSelected:()=>null!==ay(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,width:Math.max(24,Math.round(t*Ar))}))}(e,t),{mergeKey:ss}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,height:Math.max(24,Math.round(t*Ar))}))}(e,t),{mergeKey:cs})}}function Aw(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!zr(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function Mw(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=mb(e),n=t&&qn(t.run);return n?{width:n.width/Ar,height:n.height/Ar}:null}(e.state()),setWidthCm:t=>e.commandsController.applyImageWidthCmCommand(t),setHeightCm:t=>e.commandsController.applyImageHeightCmCommand(t),isCropActive:()=>e.imageCropMode.isActive(),toggleCrop:()=>e.imageCropMode.toggle(),applyCropAspect:t=>e.commandsController.applyImageCropAspectCommand(t),getCropShape:()=>function(e){const t=mb(e);return(t&&qn(t.run))?.cropShape??null}(e.state())?.preset??null,applyCropShape:t=>e.commandsController.applyImageCropShapeCommand(t),applyCropFill:()=>e.commandsController.applyImageCropFillCommand(),applyCropFit:()=>e.commandsController.applyImageCropFitCommand(),resetCrop:()=>e.commandsController.resetImageCropCommand(),getBorder:()=>function(e){const t=mb(e);return(t&&qn(t.run))?.border??null}(e.state()),setBorder:t=>e.commandsController.applyImageBorderCommand(t),flip:t=>e.commandsController.flipImageCommand(t),rotate:t=>e.commandsController.rotateImageCommand(t),getTransparency:()=>function(e){const t=mb(e),n=t&&qn(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==mb(e.state())}}function Fw(e){const t=e.clipboardActions??li({state:e.state,isReadOnly:e.isReadOnly,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput});return{canCut:()=>!0,canPaste:()=>!0,hasSelection:t.hasSelection,copy:()=>{t.copy()},cut:()=>{t.cut()},paste:()=>{t.paste("rich")},pasteAsPlainText:()=>{t.paste("text")},pasteMergeFormatting:()=>{t.paste("merge")}}}function Ow(e,t){const n=io(e),o=Fe(e.document);if("header"===n||"footer"===n){const r=fo(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=aa(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=fo(e),r=o[n];if(!r)return e;const a=[...o];return a[n]={...r,blocks:t},{...e,document:{...e.document,sections:a}}}return e}function Dw(e,t){return null!==Lw(e,t)}function Ew(e,t){const n=Lw(e,t);if(!n)return e;const{nextBlocks:o}=n,r=Ow(e,o),a=o.flatMap(Po);return{...r,selection:Nw(e.selection,a)}}function Lw(e,t){const n=io(e);if("footnote"===n)return null;const o=fn(e,n);if(0===o.length)return null;const r=Wn(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let l=n;l<=o;l+=1){const e=t[l];if(void 0===e)return null;r.add(e)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==e[l].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{Po(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:l}=a,s=o.slice(i,l+1);let c;if("up"===t){if(0===i)return null;const e=o[i-1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i-1),...s,e,...o.slice(l+1)]}else{if(l===o.length-1)return null;const e=o[l+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...s,...o.slice(l+2)]}return{nextBlocks:c}}function Nw(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return Z(r,Math.min(e.offset,u(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function $w(e,t){const n=function(e){const t=io(e);if("footnote"===t)return null;const n=fn(e,t);if(0===n.length)return null;const o=Wn(e),r=/* @__PURE__ */new Set;for(let l=o.startIndex;l<=o.endIndex;l+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=Po(n[o]).length;if(l<e+r){t=o;break}e+=r}if(t<0)return null;r.add(t)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==n[l].type)return null;return{blocks:n,lo:a,hi:i}}(e);if(!n)return e;if(n.hi-n.lo<1)return e;const{lo:o,hi:r,blocks:a}=n,i=a.slice(o,r+1).map((e,t)=>({block:e,index:t,key:zw(Lt(e))}));i.sort((e,n)=>{const o=function(e,t){const n=function(e,t){return void 0!==e&&void 0!==t?e===t?0:e<t?-1:1:void 0!==e?-1:void 0!==t?1:0}(e.num,t.num);return 0!==n?n:e.text.localeCompare(t.text,void 0,{sensitivity:"base"})}(e.key,n.key);return 0!==o?t?-o:o:e.index-n.index});const l=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],s=Ow(e,l),c=l.flatMap(Po);return{...s,selection:Hw(e.selection,c)}}function zw(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function Hw(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return Z(r,Math.min(e.offset,u(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Ww(e,t){const n=Wn(e),o=Kr(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=ga(o[l]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return pn(e);const i=ga(e.style?.styleId);if(e.list&&e.list.kind){const n=e.list.level??0,o=t?Math.max(0,n-1):Math.min(8,n+1);return o===n?pn(e):(a=!0,be(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return pn(e);a=!0;const o=pn(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return pn(e);a=!0;const l=pn(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?Ie(e,i,$(i,n)):e}var Uw=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function jw(e,t){return Math.abs(e-t)<1e-6}function Vw(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var Kw=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var _w=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var Xw={width:1.5,type:"solid",color:"#000000"};function Gw(e,t){const n=t.text??Lt(e).slice(0,1),o=Math.max(1,Math.min(10,Math.round(t.lines??3))),r=e.runs[0]?.styles,a=t.font;return{text:n,lines:o,type:"margin"===t.type?"margin":"drop",style:void 0!==a?{...r??{},fontFamily:a}:r}}function qw(e){return{togglePageBreakBefore:()=>e.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>e.commandsController.toggleParagraphFlagCommand("keepWithNext"),toggleKeepLinesTogether:()=>e.commandsController.toggleParagraphFlagCommand("keepLinesTogether"),toggleWidowControl:()=>e.commandsController.toggleParagraphFlagCommand("widowControl"),setSpacingAfter:t=>e.commandsController.applyParagraphStyleCommand("spacingAfter",t),setSpacingBefore:t=>e.commandsController.applyParagraphStyleCommand("spacingBefore",t),setLineRule:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.lineRule,i=(()=>{if(null!==t&&"auto"!==t)return Kw.has(t)?t:a})();if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.textDirection,i=null===t||"lrTb"===t?void 0:_w.has(t)?t:a;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressAutoHyphens,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressLineNumbers,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.kinsoku,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.overflowPunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.wordWrap,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDE,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDN,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.adjustRightInd,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.topLinePunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.pageBreakBefore,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepWithNext,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepLinesTogether,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.widowControl,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.contextualSpacing,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.mirrorIndents,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setIndentLeft:t=>e.commandsController.applyParagraphStyleCommand("indentLeft",t),setIndentRight:t=>e.commandsController.applyParagraphStyleCommand("indentRight",t),setIndentFirstLine:t=>e.commandsController.applyParagraphStyleCommand("indentFirstLine",t),setIndentHanging:t=>e.commandsController.applyParagraphStyleCommand("indentHanging",t),setSpecialIndent:(t,n)=>{const o=n??48;e.applyTransactionalState(e=>{let n=Ve(e,"indentFirstLine",null);return n=Ve(n,"indentHanging",null),"firstLine"===t?n=Ve(n,"indentFirstLine",o):"hanging"===t&&(n=Ve(n,"indentHanging",o)),n},{mergeKey:nl}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=Ve(e,"borderTop",t);return n=Ve(n,"borderRight",t),n=Ve(n,"borderBottom",t),n=Ve(n,"borderLeft",t),n},{mergeKey:ol}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>Ve(e,"borderBottom",Xw),{mergeKey:ol}),e.focusInput()},setLineHeight:t=>e.commandsController.applyParagraphStyleCommand("lineHeight",t),setListFormat:t=>e.commandsController.handleListFormatChange(t),setListStartAt:t=>e.commandsController.handleListStartAtChange(t),setListLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Math.min(8,Math.max(0,Math.round(t))),r=Kr(e);let a=!1;const i=r.map((e,t)=>t<n.startIndex||t>n.endIndex?e:e.list?(e.list.level??0)===o?e:(a=!0,be(e,o)):e);return a?Ie(e,i,$(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Dw(e.state(),"up")?(e.applyTransactionalState(e=>Ew(e,"up"),{mergeKey:rl}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Dw(e.state(),"down")?(e.applyTransactionalState(e=>Ew(e,"down"),{mergeKey:al}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Dw(e.state(),"up"),canMoveParagraphsDown:()=>Dw(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>Ww(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>Ww(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=Wn(e),n=Kr(e);let o=!1;const r=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const r=e.style;if(!r||Uw.every(e=>!(e in r)))return e;o=!0;const a=pn(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?Ie(e,r,$(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=e.document.styles,a=t.set??[],i=t.clear??[],l=Boolean(t.clearAll),s=void 0!==t.tabs||a.length>0||i.length>0||l;let c=!1;const d=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;if(!s)return e;const d=ct(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!jw(e.position,t));return d.some(e=>jw(e.position,t))&&n.push({position:t,type:"clear"}),n};let p=[...void 0!==t.tabs?(t.tabs??[]).map(e=>({...e})):(e.style?.tabs??[]).map(e=>({...e}))];if(l){p=[];for(const e of d)p=u(p,e.position)}for(const t of i)p=u(p,t);for(const t of a)p=p.filter(e=>!jw(e.position,t.position)),p.push(Vw(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=pn(e);return g.style={...e.style??{},tabs:p.length>0?p:null},c=!0,g});let u=c;const p=void 0!==t.default&&null!==t.default,g=e.document.settings?.defaultTabStop,f=p&&void 0!==t.default&&null!==t.default?Math.min(1584,Math.max(1,t.default)):void 0;if((p||null===t.default)&&(null===t.default?void 0!==g:void 0!==t.default&&g!==f)&&(u=!0),!u)return e;let m=Ie(e,d,$(d,n));if(p||null===t.default){const n={...e.document.settings??{}};null===t.default?delete n.defaultTabStop:void 0!==t.default&&(n.defaultTabStop=f),m={...m,document:{...m.document,settings:n}}}return m}(e,t),{mergeKey:cl}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=null==t?null:Math.min(8,Math.max(0,Math.round(t)));let a=!1;const i=o.map((e,t)=>{if(t<n.startIndex||t>n.endIndex)return e;if((e.style?.outlineLevel??null)===r)return e;a=!0;const o={...e.style??{}};null===r?delete o.outlineLevel:o.outlineLevel=r;const i=pn(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?Ie(e,i,$(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return Ve(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>$w(e,t)),hasDropCap:()=>function(e){const t=Wn(e);return Kr(e).slice(t.startIndex,t.endIndex+1).some(e=>void 0!==e.dropCap)}(e.state()),setDropCap:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,l=o.map((e,n)=>n<r||n>a?pn(e):i?{...pn(e),dropCap:void 0}:{...pn(e),dropCap:Gw(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Ie(e,l,$(l,n))}(e,t)),e.focusInput()}}}function Yw(e){const t=Fe(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(fo(e),t.length-1))}}function Zw(e,t){const{sections:n,sectionIndex:o}=Yw(e);if(0===n.length)return e;const r=t(n[o]);if(r===n[o])return e;const a=[...n];return a[o]=r,{...e,document:{...e.document,sections:a}}}function Jw(e,t,n="default"){const o=Rn(t,n);return Zw(e,e=>e[o]?e:{...e,[o]:[sa(t)]})}function Qw(e,t,n="default"){const o=Rn(t,n),r=Zw(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:io(r)===t?oS(r):r}function eS(e,t,n="default"){const o=Jw(e,t,n),{sections:r,sectionIndex:a}=Yw(o),i=(r[a][Rn(t,n)]??[]).flatMap(Po).find(Boolean);return i?{...o,selection:En(Z(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function tS(e){const{sections:t,sectionIndex:n}=Yw(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function nS(e){const{sections:t,sectionIndex:n}=Yw(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function oS(e){const{sections:t,sectionIndex:n}=Yw(e),o=(t[n]?.blocks??[]).flatMap(Po).find(Boolean);return o?{...e,selection:En(Z(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function rS(e){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Rt(o,0,i),s=Rt(o,i,u(o)),c={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Y(o,i)},d=Ut(o,[...l,c,...s]),p=Kr(n),g=[...r(p.slice(0,a)),d,...r(p.slice(a+1))];return Ie(n,g,oe(Z(d,i+c.text.length)))}(e,"PAGE")}function aS(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function iS(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},aS("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},aS("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[aS("PAGE",void 0,`run:page-field:${n}`,t)]}function lS(e,t="page",n){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Y(o,i),s=t.map((e,t)=>e.styles?e:{...e,styles:l,id:`${e.id}:${t}`}),c=Ut(o,[...Rt(o,0,i),...s,...Rt(o,i,u(o))]),d=Kr(n),p=[...r(d.slice(0,a)),c,...r(d.slice(a+1))],g=s.reduce((e,t)=>e+t.text.length,0);return Ie(n,p,oe(Z(c,i+g)))}(e,iS(t,n))}function sS(e){const t=Fe(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(fo(e),t.length-1))}}function cS(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return lS(e,o,r);const i="top"===t?"header":"footer",l=Rn(i,"default"),{sections:s,sectionIndex:c}=sS(e);if(0===s.length)return e;const d={id:no("paragraph"),type:"paragraph",runs:iS(o,r),style:{styleId:i,align:a}},u={...s[c],[l]:[d]},p=[...s];return p[c]=u,{...e,document:{...e.document,sections:p},selection:En(Z(d,0)),activeSectionIndex:c,activeZone:i}}function dS(e){const t={isLandscape:()=>{const t=fo(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;if(!o)return;const r=o.pageSettings?.orientation??"portrait";t.setOrientation("portrait"===r?"landscape":"portrait")},breakNextPage:()=>e.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>e.commandsController.applyInsertSectionBreakCommand("continuous"),breakEvenPage:()=>e.commandsController.applyInsertSectionBreakCommand("evenPage"),breakOddPage:()=>e.commandsController.applyInsertSectionBreakCommand("oddPage"),breakNextColumn:()=>e.commandsController.applyInsertSectionBreakCommand("nextColumn"),getMargins:()=>{const t=fo(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;o?.pageSettings&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,margins:{...o.pageSettings.margins,...t}}})},setMarginsPreset:t=>{e.applyTransactionalState(e=>Pn(e,t)),e.focusInput()},getPageNumbering:()=>{const t=fo(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=sS(e);if(0===n.length)return e;const r={...n[o].pageNumbering,...void 0!==t.start?{start:t.start}:{},...void 0!==t.format?{format:t.format}:{}};return a(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>Uo(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ra(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>ft(e,t)),e.focusInput()},getColumns:()=>sr(e.state()),setColumns:t=>{e.applyTransactionalState(e=>ua(e,t)),e.focusInput()},getVerticalAlign:()=>gn(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>b(e,t)),e.focusInput()},getSectionStart:()=>{const t=fo(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=fo(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>ao(e.state()),setBidi:t=>{e.applyTransactionalState(e=>Vr(e,t)),e.focusInput()},getHyphenation:()=>function(e){const t=e.document.settings;return{value:!0===t?.autoHyphenation,zone:t?.hyphenationZone,caps:t?.doNotHyphenateCaps,limit:t?.consecutiveHyphenLimit}}(e.state()),setHyphenation:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.settings,o={...n??{},...void 0!==t.value?{autoHyphenation:t.value}:void 0!==n?.autoHyphenation?{autoHyphenation:n.autoHyphenation}:{},...void 0!==t.zone?{hyphenationZone:t.zone}:void 0!==n?.hyphenationZone?{hyphenationZone:n.hyphenationZone}:{},...void 0!==t.caps?{doNotHyphenateCaps:t.caps}:void 0!==n?.doNotHyphenateCaps?{doNotHyphenateCaps:n.doNotHyphenateCaps}:{},...void 0!==t.limit?{consecutiveHyphenLimit:t.limit}:void 0!==n?.consecutiveHyphenLimit?{consecutiveHyphenLimit:n.consecutiveHyphenLimit}:{}};return{...e,document:{...e.document,settings:o}}}(e,t)),e.focusInput()}};return t}function uS(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>eS(e,"header")),editFooter:()=>t(e=>eS(e,"footer")),editFirstPageHeader:()=>t(e=>eS(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>eS(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>eS(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>eS(e,"footer","evenPage")),insertPageNumber:()=>t(e=>rS(e)),insertPageNumberXOfY:()=>t(e=>lS(e,"xOfY")),placePageNumberTop:()=>t(e=>cS(e,"top")),placePageNumberBottom:()=>t(e=>cS(e,"bottom")),exit:()=>t(e=>function(e){return oS(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>tS(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(tS(e)===t)return e;let n=e;return t?(n=Jw(n,"header","firstPage"),n=Jw(n,"footer","firstPage"),n):(n=Qw(n,"header","firstPage"),Qw(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>nS(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(nS(e)===t)return e;let n=e;return t?(n=Jw(n,"header","evenPage"),n=Jw(n,"footer","evenPage"),n):(n=Qw(n,"header","evenPage"),Qw(n,"footer","evenPage"))}(t,e))}}function pS(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function gS(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=Wn(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:Wr(),name:l,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[s.id]:s},order:[...i,s.id]},d={...e.document,bookmarks:c};return{...e,document:d}}(e,t)),e.focusInput()},remove:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.bookmarks;if(!n||!n.items[t])return e;const o={...n.items};delete o[t];const r={items:o,order:n.order.filter(e=>e!==t)};return{...e,document:{...e.document,bookmarks:r}}}(e,t)),e.focusInput()},list:()=>pS(e.state()).map(e=>({id:e.id,name:e.name}))}}var fS=["January","February","March","April","May","June","July","August","September","October","November","December"],mS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function hS(e,t){let n="";const o=e=>String(e).padStart(2,"0");let r=0;const a=t;for(;r<a.length;){const t=a[r];let i=t;for(;r+i.length<a.length&&a[r+i.length]===t;)i+=t;const l=e.getHours();switch(t){case"d":n+=i.length>=4?mS[e.getDay()]:3===i.length?mS[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?fS[e.getMonth()]:3===i.length?fS[e.getMonth()].slice(0,3):2===i.length?o(e.getMonth()+1):String(e.getMonth()+1);break;case"y":n+=i.length>=3?String(e.getFullYear()):String(e.getFullYear()).slice(-2);break;case"H":n+=o(l);break;case"h":n+=i.length>=2?o(l%12==0?12:l%12):String(l%12==0?12:l%12);break;case"m":n+=i.length>=2?o(e.getMinutes()):String(e.getMinutes());break;case"s":n+=i.length>=2?o(e.getSeconds()):String(e.getSeconds());break;default:if(a.slice(r).toLowerCase().startsWith("am/pm")){n+=l<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}function bS(e,t){const n=t.type??"REF";if(!function(e,t){return pS(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ne(o),s=Y(a,l),c={type:n,bookmark:t.bookmark},d={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:c,styles:s},p=Ut(a,[...Rt(a,0,l),d,...Rt(a,l,u(a))]),g=Kr(o),f=[...r(g.slice(0,i)),p,...r(g.slice(i+1))];return Ie(o,f,oe(Z(p,l+d.text.length)))}function yS(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,a=zr(e.selection)?e:Me(e),{paragraph:i,index:l,offset:s}=Ne(a),c=Y(i,s),d=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},p={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:hS(o,n),kind:"field",field:d,styles:c},g=Ut(i,[...Rt(i,0,s),p,...Rt(i,s,u(i))]),f=Kr(a),m=[...r(f.slice(0,l)),g,...r(f.slice(l+1))],h=p.text.length;return Ie(a,m,oe(Z(g,s+h)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=hS(n,t);return 0===o.length?e:za(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>bS(e,t)),e.focusInput()}}}function vS(e){let t=!1,n=!1;const o=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},r={firstRow:!1,lastRow:!1,firstCol:!1,lastCol:!1,noHBand:!1,noVBand:!1},a=e=>{const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t);if(!n)return null;const o=function(e,t,n){if("footnote"===n){const t=e.activeFootnoteId;return t?e.document.footnotes?.items[t]?.blocks??null:null}const o=Fe(e.document)[t];return o?"header"===n?o.header??[]:"footer"===n?o.footer??[]:o.blocks:null}(e,t,n.zone);if(!o)return null;const r=i(o,n.tablePath);return r?.[r.length-1]?.table??null},l=e=>{const t=a(e);if(!t)return null;const n=cr(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(F(e.state().document,e.state().selection.focus.paragraphId,fo(e.state()))),selectionLabel:()=>{const t=e.state();if(Wn(t).isCollapsed)return null;const n=fo(t),o=F(t.document,t.selection.anchor.paragraphId,n),r=F(t.document,t.selection.focus.paragraphId,n),a=o?.tablePath[o.tablePath.length-1],i=r?.tablePath[r.tablePath.length-1];if(!o||!r||!a||!i||o.zone!==r.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(o.tablePath,r.tablePath)||a.rowIndex===i.rowIndex&&a.cellIndex===i.cellIndex)return null;const l=e.selectionBoxes().length;return 0===l?null:`Table selection: ${l} cell${1===l?"":"s"}`},getTblLook:()=>{const t=l(e.state());return t?{firstRow:t.firstRow,lastRow:t.lastRow,firstCol:t.firstCol,lastCol:t.lastCol,bandedRows:!t.noHBand,bandedCols:!t.noVBand}:null},toggleTblLook:e=>o(t=>{const n=l(t);if(!n)return t;const o={...n};switch(e){case"firstRow":o.firstRow=!n.firstRow;break;case"lastRow":o.lastRow=!n.lastRow;break;case"firstCol":o.firstCol=!n.firstCol;break;case"lastCol":o.lastCol=!n.lastCol;break;case"bandedRows":o.noHBand=!n.noHBand;break;case"bandedCols":o.noVBand=!n.noVBand}return Ds(t,"tblLook",o)},Wl),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Ds(t,"styleId",e||null),Ul),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Ds(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),jl),canSetAutoFit:()=>null!==bs(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Rs(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...us(),type:"property",previous:{...r??{}}}});let a=ps(r,"layout",n);return"window"===t?a=ps(a,"width","100%"):"contents"===t&&(a=ps(a,"width",null)),{...o,style:a}})}(t,e),Ll),distributeColumns:()=>o(e=>Rs(e,e=>{const t=ln(e),n=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),o=(e.gridCols??[]).reduce((e,t)=>e+("number"==typeof t&&t>0?t:0),0),r=o>0?o:120*n,a=r/n,i=Array.from({length:n},()=>a),l=e.rows.map((e,n)=>({...e,cells:e.cells.map((e,o)=>{const r=t.find(e=>e.rowIndex===n&&e.cellIndex===o);return r?{...e,style:{...e.style??{},width:a*Math.max(1,r.colSpan)}}:e})}));return{...e,gridCols:i,rows:l,style:{...e.style??{},width:r}}}),jl),distributeRows:()=>o(e=>Rs(e,e=>{let t=0;for(const o of e.rows){const e=o.style?.height,n="number"==typeof e?e:"string"==typeof e?Number.parseFloat(e):0;Number.isFinite(n)&&n>t&&(t=n)}t<=0&&(t=24);const n=e.rows.map(e=>({...e,style:{...e.style??{},height:t,heightRule:"atLeast"}}));return{...e,rows:n}}),jl),canMerge:()=>e.tableOps.canMergeSelectedTable(e.state()),canSplit:()=>e.tableOps.canSplitSelectedTable(e.state()),canEditColumn:()=>e.tableOps.canEditSelectedTableColumn(e.state()),canEditRow:()=>e.tableOps.canEditSelectedTableRow(e.state()),canConvertToText:()=>null!==bs(e.state()),convertToText:()=>o(e=>Ws(e),Bl),canConvertToTable:()=>{return!bs(t=e.state())&&null!==Ts(t);var t},convertToTable:()=>o(e=>Us(e),Al),canSplitTableAtRow:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);if(!o)return!1;const r=t.loc.rowIndex;return r>0&&r<o.rows.length}(e.state()),splitTableAtRow:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex;if(r<=0||r>=o.rows.length)return e;const a=o.rows.slice(0,r),i=o.rows.slice(r),l={...o,rows:a},s=bn(i),c=Ps(e,[l,pr(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:oe(Z(d,0))}:e}(e),Ml),canSortTable:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return!!o&&function(e){let t=0;for(const n of e)n.isHeader||(t+=1);return t}(o.rows)>=2}(e.state()),sortTable:e=>o(t=>Vs(t,e),"ascending"===e?Fl:Ol),canDeleteTable:()=>null!==bs(e.state()),deleteTable:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=t.loc.tablePath[0]?.tableBlockIndex;if(void 0===o||"table"!==n[o]?.type)return e;if(1===n.length){const t=pr(""),n=Ps(e,[t]);return n===e?e:{...n,selection:oe(Z(t,0))}}const r=function(e,t){for(let n=t+1;n<e.length;n+=1){const t=e[n];if("paragraph"===t?.type)return t.id}for(let n=t-1;n>=0;n-=1){const t=e[n];if("paragraph"===t?.type)return t.id}return null}(n,o),a=Ps(e,[]);if(a===e)return e;if(r){const e=Kr(a).find(e=>e.id===r);if(e)return{...a,selection:oe(Z(e,0))}}return a}(e),Dl),canToggleRepeatHeaderRows:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&_s(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=_s(o.rows[0]);return Rs(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),Nl),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),fl),split:()=>o(t=>e.tableOps.splitSelectedTable(t),ml),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),hl),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),hl),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),bl),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),yl),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),yl),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),vl),canDeleteCell:()=>ic(e.state()),deleteCell:()=>o(e=>lc(e),El),cellShading:e=>o(t=>Fs(t,"shading",e||null),xl),cellBorders:()=>o(e=>Os(e,{width:1,type:"solid",color:"#64748b"}),wl),cellNoBorders:()=>o(e=>Os(e,{width:0,type:"none",color:"transparent"}),wl),applyBorderPreset:e=>o(t=>function(e,t,n=Bs){const o=Ms(e);if(!o)return e;const r=/* @__PURE__ */new Map,a=new Set(o.selectedEntries.map(e=>e.cell.id)),i=/* @__PURE__ */new Map;for(const m of o.entries)for(let e=m.visualRowIndex;e<m.visualRowIndex+m.rowSpan;e+=1)for(let t=m.visualColumnIndex;t<m.visualColumnIndex+m.colSpan;t+=1)i.set(`${e}:${t}`,m);const l=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},s=(e,t,o,r,a=n)=>{l(e,t,a),o&&o.cell.id!==e?.cell.id&&l(o,r,a)},c=(e,t=n)=>{if("top"===e||"bottom"===e){const n="top"===e?o.startRow:o.endRow,r=n+("top"===e?-1:1);for(let l=o.startCol;l<=o.endCol;l+=1){const o=i.get(`${n}:${l}`);o&&a.has(o.cell.id)&&s(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${l}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,l=r+("left"===e?-1:1);for(let n=o.startRow;n<=o.endRow;n+=1){const o=i.get(`${n}:${r}`);o&&a.has(o.cell.id)&&s(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${l}`),"left"===e?"borderRight":"borderLeft",t)}},d=()=>{for(let e=o.startRow+1;e<=o.endRow;e+=1)for(let t=o.startCol;t<=o.endCol;t+=1){const n=i.get(`${e-1}:${t}`),o=i.get(`${e}:${t}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderBottom",o,"borderTop")}},u=()=>{for(let e=o.startCol+1;e<=o.endCol;e+=1)for(let t=o.startRow;t<=o.endRow;t+=1){const n=i.get(`${t}:${e-1}`),o=i.get(`${t}:${e}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderRight",o,"borderLeft")}};switch(t){case"none":for(const e of o.selectedEntries)for(const t of["borderTop","borderRight","borderBottom","borderLeft","borderStart","borderEnd","borderTopLeftToBottomRight","borderTopRightToBottomLeft"])l(e,t,As);c("top",As),c("right",As),c("bottom",As),c("left",As);break;case"top":c("top");break;case"right":c("right");break;case"bottom":c("bottom");break;case"left":c("left");break;case"outside":c("top"),c("right"),c("bottom"),c("left");break;case"insideHorizontal":d();break;case"insideVertical":u();break;case"inside":d(),u();break;case"all":c("top"),c("right"),c("bottom"),c("left"),d(),u();break;case"diagonalDown":for(const e of o.selectedEntries)l(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)l(e,"borderTopRightToBottomLeft")}if(0===r.size)return e;const p=/* @__PURE__ */new Set;for(const m of o.entries)if(r.has(m.cell.id))for(const e of m.cell.blocks)for(const t of Po(e))p.add(t.id);const g=t=>{const n=r.get(t.id);if(!n)return t;let o=t.style;e.trackChangesEnabled&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...us(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=ps(o,e,r);return{...t,style:o}},f=Fe(e.document).map(e=>({...e,blocks:ya(e.blocks,p,g),header:e.header?ya(e.header,p,g):void 0,footer:e.footer?ya(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),wl),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Ds(e,"width","100%"),Sl),alignLeft:()=>o(e=>Fs(e,"horizontalAlign","left"),Cl),alignCenter:()=>o(e=>Fs(e,"horizontalAlign","center"),Cl),alignRight:()=>o(e=>Fs(e,"horizontalAlign","right"),Cl),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,Fs(Fs(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},Il),getCellAlignmentState:()=>function(e){const t=Ms(e);if(!t||0===t.selectedEntries.length)return null;const n=t.selectedEntries.map(({cell:e})=>e.style?.horizontalAlign??"left"),o=t.selectedEntries.map(({cell:e})=>e.style?.verticalAlign??"top"),r=(e,t)=>{const n=e[0];return n?e.some(e=>!t.includes(e))?null:e.some(e=>e!==n)?"mixed":n:null};return{horizontal:r(n,["left","center","right"]),vertical:r(o,["top","middle","bottom"])}}(e.state()),setCellVerticalAlign:e=>o(t=>Fs(t,"verticalAlign",e),Tl),setCellTextDirection:e=>o(t=>Fs(t,"textDirection",e),kl),setCellWidth:e=>o(t=>function(e,t){return Fs(e,"width",t)}(t,e),Pl),setCellNoWrap:e=>o(t=>function(e,t){return Fs(e,"noWrap",t)}(t,e),Pl),setCellFitText:e=>o(t=>function(e,t){return Fs(e,"fitText",t)}(t,e),Pl),canSetCellMargins:()=>null!==bs(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Fs(n,"paddingTop",t.top)),void 0!==t.right&&(n=Fs(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Fs(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Fs(n,"paddingLeft",t.left)),n}(t,e),$l),canSetCellSpacing:()=>Xs(e.state()),setCellSpacing:e=>o(t=>function(e,t){return Xs(e)?Ds(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),$l),canSetTableIndent:()=>Gs(e.state()),setTableIndent:e=>o(t=>function(e,t){return Gs(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Ds(e,"indentLeft",null):Ds(e,"indentLeft",Math.round(2*t)/2):e}(t,e),$l),canSetTableAlignment:()=>null!==bs(e.state()),setTableAlignment:e=>o(t=>Ys(t,e),$l),canEvaluateTableFormula:()=>null!==bs(e.state()),evaluateTableFormula:e=>o(t=>Qs(t,e),zl),canSelectTable:()=>null!==bs(e.state()),selectTablePart:t=>e.applyState(rc(e.state(),t)),canSetActiveTableRowHeight:()=>null!==bs(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=Ls(n,"height",t.height),void 0!==t.heightRule&&(n=Ls(n,"heightRule",t.heightRule)),n}(t,e),Hl),canSetActiveTableRowBreakAcrossPages:()=>Zs(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Zs(e)?Ls(e,"cantSplit",null===t?null:!t):e}(t,e),Hl),canSetActiveTableRowHeader:()=>null!==bs(e.state()),setActiveTableRowHeader:e=>o(t=>Ns(t,e),Nl),canSetActiveTableColumnWidth:()=>null!==bs(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Ss(ms(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=ln(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:Hs(e,a.id,{[l]:t})}(t,e),Rl),canSetActiveTableWidth:()=>null!==bs(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Ss(ms(e.document,o,r.zone),r.tablePath);return a?Es(e,a.id,"width",t):e}(t,e),Sl),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function xS(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>Ox(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Ax[t]??Ax.oasis,o=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.color}}]}));return{...e,document:{...e.document,styles:o,design:{...e.document.design??{},colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading}}}}}}(t,e)),setFontScheme:e=>t(t=>function(e,t){const[n,o]=Mx[t]??Mx.aptos,r=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,textStyle:{...t.textStyle??{},fontFamily:/^heading|title|quote/i.test(e)?o:n}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},fontSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:o.split(",")[0].trim()},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:n.split(",")[0].trim()}}}},styles:r}}}(t,e)),setParagraphSpacing:e=>t(t=>function(e,t){const n={compact:[0,4],tight:[0,6],open:[0,10],relaxed:[4,12]},[o,r]=n[t]??n.open,a=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,paragraphStyle:{...t.paragraphStyle??{},spacingBefore:o,spacingAfter:r}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},paragraphSpacingId:t},styles:a}}}(t,e)),setEffects:e=>t(t=>Fx(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return Fx(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return Fx(e,{watermark:t})}(t,e)),setPageBorder:e=>t(t=>function(e,t){const n=(e.document.sections??[]).map(e=>({...e,pageBorder:t}));return{...e,document:{...e.document,sections:n,design:{...e.document.design??{}}}}}(t,e)),setDefault:()=>{const t=e.state().document.design;t&&globalThis.localStorage?.setItem("oasis-design-default",JSON.stringify(t))},getDesign:()=>e.state().document.design,getPageBorder:()=>e.state().document.sections?.find(e=>e.pageBorder)?.pageBorder}}function wS(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,o)=>({execute:t,refresh:()=>{const t=o?.()??{};return{...t,isEnabled:n(e)&&(t.isEnabled??!0)}}}));var n;const o=function(e){return(t,n,o)=>({execute:n,refresh:()=>({isEnabled:e(t),value:o()})})}(e.gate.isCommandEnabled),r=function(e){return(t,n,o)=>({execute:e=>(n(e),!0),refresh:()=>{const n=o?.()??{};return{...n,isEnabled:e(t)&&(n.isEnabled??!0)}}})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...Nx({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,dialog:e.dialog,link:e.link,command:t,valueCommand:o,actionCommand:r}),...$x({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...zx({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...Kx({dialog:e.dialog,actionCommand:r}),...Hx({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...jx({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...Vx({design:e.design,actionCommand:r}),...Wx({bookmark:e.bookmark,actionCommand:r}),...Ux({fields:e.fields,actionCommand:r})}}}({gate:qx(e),style:Yx(e),selection:Zx(e),history:Jx(e),formatting:ww(e),document:Bw(e),link:Aw(e),image:Mw(e),browser:Fw(e),paragraph:qw(e),section:dS(e),headerFooter:uS(e),table:vS(e),design:xS(e),bookmark:gS(e),fields:yS(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var SS=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",command:"newDocument",icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.importDocx",shortcut:"Ctrl+O",command:"importDocument",icon:"upload"},{id:"file_save",path:"File/Save",labelKey:"generic.save",shortcut:"Ctrl+S",command:"saveDocument",icon:"save"},{id:"file_export",path:"File/Export",labelKey:"menu.file.export",icon:"download"},{id:"file_export_pdf",path:"File/Export/PDF",command:"exportPdf",icon:"file-down"},{id:"file_export_docx",path:"File/Export/DOCX",command:"exportDocx",icon:"file-text"},{id:"file_export_html",path:"File/Export/HTML",hidden:!0},{id:"file_export_md",path:"File/Export/MD",hidden:!0},{id:"file_print",path:"File/Print",labelKey:"menu.file.print",shortcut:"Ctrl+P",command:"print",icon:"printer"},{id:"edit_undo",path:"Edit/Undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z",command:"undo",icon:"undo-2"},{id:"edit_redo",path:"Edit/Redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y",command:"redo",icon:"redo-2"},{id:"edit_repeat",path:"Edit/Repeat",labelKey:"quickAccess.repeat",shortcut:"F4",command:"repeatLastAction",icon:"repeat"},{id:"edit_cut",path:"Edit/Cut",labelKey:"menu.edit.cut",shortcut:"Ctrl+X",command:"cut",icon:"scissors"},{id:"edit_copy",path:"Edit/Copy",labelKey:"menu.edit.copy",shortcut:"Ctrl+C",command:"copy",icon:"copy"},{id:"edit_paste",path:"Edit/Paste",labelKey:"menu.edit.paste",shortcut:"Ctrl+V",command:"paste",icon:"clipboard-paste"},{id:"edit_paste_merge",path:"Edit/Paste Merge Formatting",labelKey:"toolbar.pasteMergeFormatting",command:"pasteMergeFormatting",icon:"paintbrush"},{id:"edit_paste_plain",path:"Edit/Paste as Plain Text",labelKey:"toolbar.pastePlainText",command:"pasteAsPlainText",icon:"clipboard"},{id:"edit_format_painter",path:"Edit/Format Painter",labelKey:"toolbar.formatPainter",command:"formatPainter",icon:"paintbrush"},{id:"edit_format_painter_continuous",path:"Edit/Format Painter Continuous",labelKey:"toolbar.formatPainterContinuous",command:"formatPainterContinuous",icon:"paintbrush"},{id:"edit_cancel_format_painter",path:"Edit/Cancel Format Painter",labelKey:"toolbar.formatPainterCancel",command:"cancelFormatPainter",icon:"x"},{id:"edit_find",path:"Edit/Find & Replace",labelKey:"find.title",shortcut:"Ctrl+F",command:"find",icon:"search"},{id:"edit_selectAll",path:"Edit/Select All",labelKey:"menu.edit.selectAll",shortcut:"Ctrl+A",hidden:!0},{id:"review_previous_revision",path:"Review/Previous Change",labelKey:"toolbar.previousRevision",command:"previousRevision",icon:"chevron-up"},{id:"review_next_revision",path:"Review/Next Change",labelKey:"toolbar.nextRevision",command:"nextRevision",icon:"chevron-down"},{id:"review_revision_markup",path:"Review/Show Markup",labelKey:"toolbar.revisionMarkup",command:"toggleRevisionMarkup",icon:"highlighter"},{id:"review_accept_all_revisions",path:"Review/Accept All Changes",labelKey:"toolbar.acceptAll",command:"requestAcceptAllRevisions",icon:"check-check"},{id:"review_reject_all_revisions",path:"Review/Reject All Changes",labelKey:"toolbar.rejectAll",command:"requestRejectAllRevisions",icon:"undo-2"},{id:"review_comments_panel",path:"Review/Comments Panel",labelKey:"review.commentsPanel",command:"toggleCommentsPanel",icon:"list-filter"},{id:"review_revisions_panel",path:"Review/Reviewing Pane",labelKey:"review.reviewingPane",command:"toggleRevisionsPanel",icon:"list-checks"},{id:"review_new_comment",path:"Review/New Comment",labelKey:"toolbar.newComment",command:"newComment",icon:"message-square-plus"},{id:"review_reply_comment",path:"Review/Reply to Comment",labelKey:"toolbar.replyComment",command:"replyComment",icon:"reply"},{id:"review_edit_comment",path:"Review/Edit Comment",labelKey:"toolbar.editComment",command:"editComment",icon:"pencil"},{id:"review_previous_comment",path:"Review/Previous Comment",labelKey:"toolbar.previousComment",command:"previousComment",icon:"message-square"},{id:"review_next_comment",path:"Review/Next Comment",labelKey:"toolbar.nextComment",command:"nextComment",icon:"messages-square"},{id:"review_resolve_comment",path:"Review/Resolve Comment",labelKey:"toolbar.resolveComment",command:"resolveComment",icon:"message-square-check"},{id:"review_reopen_comment",path:"Review/Reopen Comment",labelKey:"toolbar.reopenComment",command:"reopenComment",icon:"message-square-more"},{id:"review_delete_comment",path:"Review/Delete Comment",labelKey:"toolbar.deleteComment",command:"deleteComment",icon:"message-square-x"},{id:"view_outline",path:"View/Show Outline",labelKey:"menu.view.outline",command:"toggleOutlinePanel",icon:"list"},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:e=>e.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:e=>e.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:e=>e.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_header",path:"Insert/Header",labelKey:"headerFooter.header",command:"editHeader",icon:"panel-top"},{id:"insert_footer",path:"Insert/Footer",labelKey:"headerFooter.footer",command:"editFooter",icon:"panel-bottom"},{id:"insert_page_number",path:"Insert/Page Number",labelKey:"headerFooter.pageNumber",icon:"hash"},{id:"insert_page_number_current",path:"Insert/Page Number/Current Position",labelKey:"headerFooter.pageNumberCurrent",command:"insertPageNumber"},{id:"insert_page_number_xofy",path:"Insert/Page Number/Page X of Y",labelKey:"headerFooter.pageNumberXOfY",command:"insertPageNumberXOfY"},{id:"insert_page_number_top",path:"Insert/Page Number/Top of Page",labelKey:"headerFooter.pageNumberTop",command:"placePageNumberTop"},{id:"insert_page_number_bottom",path:"Insert/Page Number/Bottom of Page",labelKey:"headerFooter.pageNumberBottom",command:"placePageNumberBottom"},{id:"insert_bookmark",path:"Insert/Bookmark",labelKey:"toolbar.bookmark",command:"insertBookmark",icon:"bookmark"},{id:"insert_date",path:"Insert/Date",labelKey:"toolbar.date",command:"insertDateField",icon:"calendar"},{id:"insert_specialChar",path:"Insert/Special Character",hidden:!0},{id:"insert_comment",path:"Insert/Comment",hidden:!0},{id:"format_text",path:"Format/Text",labelKey:"menu.format.text",icon:"type"},{id:"format_text_bold",path:"Format/Text/Bold",labelKey:"toolbar.bold",shortcut:"Ctrl+B",command:"bold",icon:"bold"},{id:"format_text_italic",path:"Format/Text/Italic",labelKey:"toolbar.italic",shortcut:"Ctrl+I",command:"italic",icon:"italic"},{id:"format_text_underline",path:"Format/Text/Underline",labelKey:"toolbar.underline",shortcut:"Ctrl+U",command:"underline",icon:"underline"},{id:"format_text_strike",path:"Format/Text/Strikethrough",labelKey:"toolbar.strike",command:"strike",icon:"strikethrough"},{id:"format_paragraphStyles",path:"Format/Paragraph styles",labelKey:"toolbar.style",hidden:!0},{id:"format_align",path:"Format/Align",labelKey:"menu.format.align",icon:"align-left"},{id:"format_align_left",path:"Format/Align/Left",labelKey:"toolbar.alignLeft",command:"alignLeft",icon:"align-left"},{id:"format_align_center",path:"Format/Align/Center",labelKey:"toolbar.alignCenter",command:"alignCenter",icon:"align-center"},{id:"format_align_right",path:"Format/Align/Right",labelKey:"toolbar.alignRight",command:"alignRight",icon:"align-right"},{id:"format_align_justify",path:"Format/Align/Justify",labelKey:"toolbar.justify",command:"alignJustify",icon:"align-justify"},{id:"format_lineSpacing",path:"Format/Line spacing",hidden:!0},{id:"format_lists",path:"Format/Lists",labelKey:"menu.format.lists",icon:"list"},{id:"format_lists_bullet",path:"Format/Lists/Bullet List",labelKey:"toolbar.bulletList",command:"bulletList",icon:"list"},{id:"format_lists_numbered",path:"Format/Lists/Numbered List",labelKey:"toolbar.numberedList",command:"orderedList",icon:"list-ordered"},{id:"format_clear",path:"Format/Clear formatting",hidden:!0},{id:"layout_orientation",path:"Layout/Orientation",labelKey:"section.orientation",icon:"layout"},{id:"layout_orientation_portrait",path:"Layout/Orientation/Portrait",labelKey:"section.portrait",command:{name:"setOrientation",payload:"portrait"},icon:e=>e.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:e=>e.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_command_search",path:"Tools/Command Search",labelKey:"menu.tools.commandSearch",command:"openCommandSearch",icon:"search",shortcut:"Ctrl+K"},{id:"tools_spelling",hidden:!0,path:"Tools/Spelling"},{id:"tools_preferences",path:"Tools/Preferences",hidden:!0},{id:"help_shortcuts",path:"Help/Keyboard shortcuts",labelKey:"menu.help.shortcuts",hidden:!0},{id:"help_about",path:"Help/About",labelKey:"menu.help.about",hidden:!0}];function CS(t){const n=wS(t.essentials),{runtimePlugins:r,toolbarRegistry:a,menuRegistry:i,dispose:l}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=Jn(),i=new e;for(const e of Or(t.t))a.register(e);for(const e of SS)i.register(e);for(const e of n){for(const t of e.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",groupLabel:t.groupLabel,row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,ribbonGroupLayout:t.ribbonGroupLayout,order:t.order};a.register(e),o.push(t.id)}for(const t of e.menubar??[])i.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),r.push(t.id)}return t.customizeToolbar?.(a),t.customizeMenubar?.(i),{runtimePlugins:n,toolbarRegistry:a,menuRegistry:i,dispose:()=>{for(const e of o)a.remove(e);for(const e of r)i.unregister(e)}}}({essentialsPlugin:n,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),s=function(e){const[t,n]=an(!1),[o,r]=an(new _e({doc:e.initialDocument}));let a=!1;const i=e=>{const t=yt(e),n=o().commands.get(t);if(!n)return{isEnabled:!1,isActive:!1,value:void 0};const r=n.refresh?.()??{isEnabled:!0};return{isEnabled:!1!==r.isEnabled,isActive:Boolean(r.isActive),value:r.value}};return{runtimeReady:t,runtimeEditor:o,commandStateOf:i,toolbarHost:()=>({commands:{execute:(e,t)=>{const n=w(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=w(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await _e.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(e.onExecuted&&(t.commands.onExecuted=e.onExecuted),a)return void(await t.destroy());const i=o();r(t),await i.destroy(),n(!0),requestAnimationFrame(()=>{e.onSettled?.(),e.onReady?.(t)})}catch(t){e.logger.error("runtime:init failed",t),e.onError?.(t),e.onSettled?.()}},dispose:async()=>{a=!0,await o().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:r,focusEditor:t.focusEditor,logger:t.logger,onExecuted:t.onExecuted,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return Zn(()=>{s.initialize()}),o(()=>{s.dispose(),l()}),{toolbarRegistry:a,menuRegistry:i,runtimeReady:s.runtimeReady,runtimeEditor:s.runtimeEditor,commandStateOf:s.commandStateOf,toolbarHost:s.toolbarHost}}var IS=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function TS(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!IS.has(e)})(e)&&(n={command:e,payload:t})},canExecute:()=>null!==n&&function(e){try{return e()}catch{return!1}}(()=>t(n.command,n.payload)),execute:()=>{n&&e(n.command,n.payload)}}}function kS(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Cx({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:e.focusInput,selectedImageRun:n.selectedImageRun,tableOps:n.tableOps,toolbarStyleState:n.styleController.toolbarStyleState,applyBooleanStyleCommand:e=>n.styleController.applyToolbarBooleanStyleCommand(e),locale:e.locale,setLinkDialog:e.setLinkDialog,setImageAltDialog:e.setImageAltDialog,setImageCaptionDialog:e.setImageCaptionDialog,setFontDialog:e.setFontDialog,setParagraphDialog:e.setParagraphDialog});let i;const l=TS((e,t)=>{if(!i)throw new Error("repeat tracking used before ready");return i().commands.execute(e,t)},(e,t)=>!!i&&i().commands.canExecute(e,t)),s=()=>{l.execute()},c=()=>l.canExecute(),{runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m}=CS({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:r,keyboardCommandsController:a,historyActions:t.historyActions,styleController:n.styleController,formatPainter:n.formatPainter,commentComposer:e.commentComposer,tableOps:n.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:n.selectedImageRun,imageCropMode:{isActive:n.imageOps.cropMode,toggle:n.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:n.fr.setIsOpen},newDocument:Ix({isDirty:()=>o.isDirty(),resetDocument:()=>o.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),saveDocument:()=>{o.save().catch(t=>e.logger.error("document:save failed",t))},openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openCommandSearch:()=>e.setCommandSearchOpen(!0),repeatLastAction:s,canRepeatLastAction:c,openTablePropertiesDialog:t=>{const n=mc(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=T(e.state.document).find(e=>e.id===t.paragraphId);if("paragraph"===n?.type){let o=0;for(const r of n.runs){if("math"===r.kind&&t.offset>=o&&t.offset<=o+r.text.length)return void e.setEquationDialog({isOpen:!0,initial:r.math,targetRunId:r.id});o+=r.text.length}}e.setEquationDialog({isOpen:!0})},openFontDialog:r.openFontDialog,openParagraphDialog:r.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:mx(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:mx(e.state).size})},toggleOutlinePanel:e.toggleOutline,isOutlineVisible:e.isOutlineVisible,toggleRevisionsPanel:e.toggleRevisionsPanel,revisionsPanelVisible:e.revisionsPanelVisible},externalPlugins:e.runtimeOptions().plugins,t:e.translator,customizeToolbar:e.runtimeOptions().customizeToolbar,customizeMenubar:e.runtimeOptions().customizeMenubar,initialDocument:e.getStateSnapshot().document,focusEditor:e.focusInput,logger:e.logger,onExecuted:(t,n)=>{l.record(t,n),e.onExecutedTap?.()},onReady:t=>{i=()=>t,o.resolveReady(t),e.runtimeOptions().onReady?.(o)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>o.rejectReady(e)});(function(e,t){const n=()=>t.cloneState(t.getStateSnapshot());e.connectHost({getRuntimeEditor:()=>t.runtimeReady()?t.runtimeEditor():null,getState:()=>n(),getDocument:()=>n().document,setDocument:e=>{t.applyState(wo(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=wn();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=Ox(e,n.themeId)),e=Fx(e,n)}}catch{}t.applyState(e),t.resetEditorChromeState(),t.focusInput()},saveDocument:async()=>{await t.getPersistence().saveDocument(n().document)},getSelection:()=>n().selection,setSelection:e=>{t.applyState({...t.getStateSnapshot(),selection:{anchor:{...e.anchor},focus:{...e.focus}}}),t.focusInput()},focus:()=>t.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.setFocused(!1)},clearHistory:()=>t.clearHistory(),importDocx:e=>t.docIO.handleImportFile(e),exportDocx:()=>Promise.resolve(t.docIO.handleExportDocx()),exportPdf:()=>Promise.resolve(t.docIO.handleExportPdf()),exportDocxBlob:()=>t.docIO.exportDocxBlob(),exportPdfBlob:()=>t.docIO.exportPdfBlob(),getUiState:t.getUiState,updateUiState:t.updateUiState,getZoom:t.getZoom,setZoom:t.setZoom,adjustZoom:t.adjustZoom,toolbarRegistry:t.toolbarRegistry,menuRegistry:t.menuRegistry})})(o,{runtimeReady:d,runtimeEditor:u,getStateSnapshot:e.getStateSnapshot,cloneState:e.cloneState,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,resetEditorChromeState:t.resetEditorChromeState,focusInput:e.focusInput,setFocused:e.setFocused,clearHistory:t.clearHistory,getPersistence:()=>e.documentOptions().persistence??t.fallbackPersistence,docIO:t.docIO,getUiState:e.getUiState,updateUiState:e.updateUiState,getZoom:e.zoom.zoomPercent,setZoom:e.zoom.setZoomPercent,adjustZoom:e.zoom.adjustZoom,toolbarRegistry:f,menuRegistry:m}),we(()=>{if(!d())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());u().dispatch(()=>t)});const{handleKeyDown:h}=function(e){const{state:t,isReadOnly:n,logger:o,focusInput:r,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:g,historyActions:f,styleController:m,findReplace:h,commandSearch:b,runtimeEditor:y}=e,{handleKeyDown:v}=Px({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:u,selectedImageRun:d,setForcePlainTextPaste:c,moveSelectionByWord:g.moveSelectionByWord,moveSelectionToDocumentBoundary:g.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:g.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:g.moveVerticalSelection,moveVerticalByBlock:g.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleCommandSearch:e=>{b.setIsOpen(e??!b.isOpen())},executeCommand:(e,t)=>y().commands.execute(e,t),canExecuteCommand:e=>y().commands.canExecute(e)});return{handleKeyDown:e=>{Rx.includes(e.key)&&m.clearPendingCaretTextStyle();const n=[e.ctrlKey?"Ctrl":null,e.metaKey?"Meta":null,e.altKey?"Alt":null,e.shiftKey?"Shift":null].filter(Boolean).join("+"),r=n?`${n}+${e.key}`:e.key,a=t().selection;o.debug(`key:down ${r} at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}]`),uo("input-to-layout"),v(e),yo("input-to-layout")}}}({state:()=>e.state,isReadOnly:e.isReadOnly,logger:e.logger,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,setForcePlainTextPaste:e.setForcePlainTextPaste,selectedImageRun:n.selectedImageRun,commandsController:a,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,commandSearch:e.commandSearch,runtimeEditor:u});return{commandsController:r,runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m,handleKeyDown:h}}(e)}function PS(e,t){const n=e.document.comments?.items;if(!n?.[t])return null;const o=/* @__PURE__ */new Set;let r=t;for(;n[r]?.parentId&&!o.has(r);){o.add(r);const e=n[r].parentId;if(!n[e])break;r=e}return r}function RS(e,t,n){if(t.document===e.document)return e;const o=e.document.comments?.items[n.commentId]??t.document.comments?.items[n.commentId];if(!o)return t;const r=PS(e,n.commentId)??PS(t,n.commentId)??n.commentId,a=e.document.comments?.order.length??0,i=t.document.comments?.order.length??0;return function(e,t){if(!(t.id.trim()&&t.commentId.trim()&&t.threadId.trim()&&t.actorName.trim()&&Number.isFinite(t.timestamp)))return e;const n=e.document.reviewActivity??[];return n.some(e=>e.id===t.id)?e:{...e,document:{...e.document,reviewActivity:[...n,{...t}]}}}(t,{id:n.id,kind:n.kind,commentId:n.commentId,threadId:r,...n.parentId?{parentId:n.parentId}:{},actorName:n.actorName,...n.actorId?{actorId:n.actorId}:{},targetAuthor:o.author,timestamp:n.timestamp,..."comment-deleted"===n.kind?{affectedCount:Math.max(1,a-i)}:{}})}function BS(e,t){if(!t)return!1;if(!e)return!0;if(e.canModerate)return!0;const n=e.identity?.id.trim();return Boolean(n&&t.authorId&&n===t.authorId)}function AS(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!BS(e,t.items[n]))return!1;const o=/* @__PURE__ */new Set([n]),r=[n],a=/* @__PURE__ */new Map;for(const i of Object.values(t.items)){if(!i.parentId)continue;const e=a.get(i.parentId)??[];e.push(i.id),a.set(i.parentId,e)}for(;r.length;){const n=r.pop();for(const i of a.get(n)??[])if(!o.has(i)){if(o.add(i),!BS(e,t.items[i]))return!1;r.push(i)}}return!0}function MS(e){const[t,n]=an(null),[o,r]=an(""),[a,i]=an(!1),s=()=>e.access?.(),c=()=>{const e=s()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},d=()=>!(e.isReadOnly()||s()&&null===c()),u=()=>d()&&null!==Xe(e.state()),p=t=>d()&&Boolean(e.state().document.comments?.items[t]),g=()=>d()&&null!==dw(e.state()),f=t=>!e.isReadOnly()&&BS(s(),e.state().document.comments?.items[t]),m=()=>{const t=dw(e.state());return null!==t&&f(t.id)},h=t=>!e.isReadOnly()&&AS(s(),e.state().document.comments,t),b=f,y=(e="Local editor")=>{const t=c();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},v=(e,t,n,o,r,a)=>RS(e,t,{id:no("review-activity"),kind:n,commentId:o,...y(r),timestamp:Date.now(),...a?{parentId:a}:{}}),x=t=>{if(!p(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"reply",snapshot:o,parentId:r.id,parentAuthor:r.author,parentText:r.text}),!0)},w=t=>{if(!f(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"edit",snapshot:o,commentId:t,commentAuthor:r.author,commentText:r.text}),!0)},S=()=>{n(null),e.focusInput()},C=t=>{if(!h(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!AS(s(),r.document.comments,t))return r;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const o=/* @__PURE__ */new Set([t]),r=[t],a=/* @__PURE__ */new Map;for(const l of Object.values(n.items)){if(!l.parentId)continue;const e=a.get(l.parentId)??[];e.push(l.id),a.set(l.parentId,e)}for(;r.length>0;){const e=r.pop();for(const t of a.get(e)??[])o.has(t)||(o.add(t),r.push(t))}const i=Object.fromEntries(Object.entries(n.items).filter(([e])=>!o.has(e)));return{...e,document:{...e.document,comments:{...n,items:i,order:n.order.filter(e=>!o.has(e))}}}}(r,t);return o=a.document!==r.document,o?v(r,a,"comment-deleted",t):a}),o},I=(t,n)=>{if(!b(t))return!1;const o=e.state();let r=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==o.document||!BS(s(),a.document.comments?.items[t]))return a;const i=function(e,t,n){const o=e.document.comments,r=o?.items[t];return o&&r&&Boolean(r.resolved)!==n?{...e,document:{...e.document,comments:{...o,items:{...o.items,[t]:{...r,resolved:n}}}}}:e}(a,t,n);return r=i.document!==a.document,r?v(a,i,n?"comment-resolved":"comment-reopened",t):i}),r};return{draft:t,lastAuthor:o,panelOpen:a,togglePanel:()=>(i(!a()),!0),closePanel:()=>{i(!1)},canCreate:u,canReply:g,canReplyId:p,canEdit:m,canEditId:f,canDeleteId:h,canDeleteSelected:()=>{const t=dw(e.state());return null!==t&&h(t.id)},deleteSelected:()=>{const t=dw(e.state());return!!t&&C(t.id)},deleteById:C,canResolveId:b,canResolveSelected:()=>{const t=dw(e.state());return null!==t&&b(t.id)},resolveSelected:t=>{const n=dw(e.state());return!!n&&I(n.id,t)},resolveById:I,authorName:()=>c()?.displayName??o(),authorLocked:()=>void 0!==s(),openNew:()=>!!u()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!g())return!1;const t=dw(e.state());return!!t&&x(t.id)},openReplyToId:x,openEdit:()=>{if(!m())return!1;const t=dw(e.state());return!!t&&w(t.id)},openEditToId:w,close:S,submit:(n,o)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!f(a.commentId))return!1;if("edit"!==a.mode&&!d())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":c()?.displayName??n.trim(),u=o.trim();if(!i||!u||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===u)return S(),!0;const p="edit"===a.mode?null:{id:no("comment"),author:i,...c()?{authorId:c().id}:{},text:u,date:Date.now()};let g=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!BS(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!d())return t;const n="edit"===a.mode?P(t,a.commentId,u):"reply"===a.mode?l(t,a.parentId,p):Do({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},p);return g=n.document!==t.document,g?v(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:p.id,i,"reply"===a.mode?a.parentId:void 0):n}),g&&("edit"!==a.mode&&r(i),S()),g}}}var FS=/*#__PURE__*/f("<div class=oasis-review-comments-filters role=group>"),OS=/*#__PURE__*/f("<div class=oasis-review-comments-list>"),DS=/*#__PURE__*/f("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),ES=/*#__PURE__*/f("<div role=region class=oasis-review-comments-panel data-testid=review-comments-panel><div class=oasis-review-comments-heading></div><div class=oasis-review-mode-switch role=group>"),LS=/*#__PURE__*/f("<div class=oasis-review-thread-replies>"),NS=/*#__PURE__*/f("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),$S=/*#__PURE__*/f("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),zS=/*#__PURE__*/f("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function HS(e){const t=R(),[n,o]=an("all"),[r,a]=an(!1),[i,l]=an(""),[s,c]=an(null),[d,u]=an(null),p=()=>e.state().document.comments,g=vr(()=>{const e=p();if(!e)return[];const t=i().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(o=>("open"!==n()||!o.resolved)&&(!("resolved"===n()&&!o.resolved)&&(!t||[o,...D(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),f=e=>D(p()?.items??{},e),m=vr(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),h=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",b=t=>{d()===t?e.composer.deleteById(t)&&(u(null),s()===t&&c(null)):u(t)};return y=ES(),v=y.firstChild,x=v.nextSibling,We(v,X(ia,{as:"strong",get children(){return t("review.commentsPanel")}}),null),We(v,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),We(x,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),We(x,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return r()},onClick:()=>{a(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),We(y,X(ia,{as:"p",get children(){return et(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${p()?.order.length??0}`}}),null),We(y,X(po,{get label(){return et(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),We(y,X(Ft,{get when(){return!r()},get children(){return[(a=FS(),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),fe(()=>le(a,"aria-label",t("review.filterComments"))),a),(r=OS(),We(r,X(Ft,{get when(){return 0===g().length},get children(){return X(ia,{as:"p",get children(){return t("review.noComments")}})}}),null),We(r,X(ee,{get each(){return g()},children:n=>{return o=NS(),r=o.firstChild,a=r.nextSibling,We(r,X(ia,{as:"strong",get children(){return n.author||"—"}}),null),We(r,X(ia,{as:"span",get children(){return et(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),We(o,X(ia,{as:"p",get children(){return n.text}}),a),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),We(a,X(Ft,{get when(){return e.composer.canEditId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canResolveId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return et(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canReplyId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[X(Qe,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-comment-delete",get children(){return et(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),X(Ft,{get when(){return d()===n.id},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),We(o,X(Ft,{get when(){return f(n.id).length>0},get children(){return X(Qe,{size:"sm",variant:"ghost",get"aria-expanded"(){return s()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{c(s()===n.id?null:n.id)},get children(){return et(()=>s()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${f(n.id).length})`}})}}),null),We(o,X(Ft,{get when(){return s()===n.id},get children(){var o=LS();return We(o,X(ee,{get each(){return f(n.id)},children:n=>{return o=$S(),r=o.firstChild,We(o,X(ia,{as:"strong",get children(){return n.author||"—"}}),r),We(o,X(ia,{as:"p",get children(){return n.text}}),r),We(r,X(Ft,{get when(){return e.composer.canEditId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),We(r,X(Ft,{get when(){return e.composer.canReplyId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),We(r,X(Ft,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[X(Qe,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-reply-delete",get children(){return et(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),X(Ft,{get when(){return d()===n.id},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),We(y,X(Ft,{get when(){return r()},get children(){var n=DS();return We(n,X(Ft,{get when(){return 0===m().length},get children(){return X(ia,{as:"p",get children(){return t("review.activity.empty")}})}}),null),We(n,X(ee,{get each(){return m()},children:n=>{return o=zS(),r=o.firstChild,We(r,X(ia,{as:"strong",get children(){return n.actorName}}),null),We(r,X(ia,{as:"span",get children(){return h(n.timestamp)}}),null),We(o,X(ia,{as:"p",get children(){return[et(()=>(e=>{switch(e){case"comment-created":return t("review.activity.created");case"comment-replied":return t("review.activity.replied");case"comment-edited":return t("review.activity.edited");case"comment-resolved":return t("review.activity.resolved");case"comment-reopened":return t("review.activity.reopened");case"comment-deleted":return t("review.activity.deleted")}})(n.kind))," — ",et(()=>n.targetAuthor),et(()=>et(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),We(o,X(Ft,{get when(){return Boolean(p()?.items[n.commentId])},get children(){return X(Qe,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),fe(()=>le(o,"data-activity-kind",n.kind)),o;var o,r}}),null),fe(()=>le(n,"aria-label",t("review.activity.title"))),n}}),null),fe(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&le(y,"aria-label",e.e=n),o!==e.t&&le(x,"aria-label",e.t=o),e},{e:void 0,t:void 0}),y;var y,v,x}var WS=/*#__PURE__*/f("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),US=/*#__PURE__*/f("<div class=oasis-review-revision-footer>"),jS=/*#__PURE__*/f('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),VS=/*#__PURE__*/f("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function KS(e,t){const n=Kr(e),o=[];for(const a of n)for(const e of a.runs)e.revision?.id===t&&o.push(e.text);const r=o.join("").trim();return r.length>96?`${r.slice(0,93)}…`:r}function _S(e){const t=R(),n=vr(()=>{const t=e.state(),n=Kr(t),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(const e of n)for(const t of e.runs){const e=t.revision;e&&(o.has(e.id)||o.set(e.id,e.author),r.has(e.id)||r.set(e.id,{date:e.date,type:e.type}))}return iw(t).map(e=>{const n=r.get(e.id);return{id:e.id,type:n?.type??"insert",author:o.get(e.id)??"—",date:n?.date,snippet:KS(t,e.id)}})}),o=vr(()=>{const t=e.state();return n().filter(e=>Wb(t,e.type,e.author))});return r=jS(),a=r.firstChild,We(a,X(ia,{as:"strong",get children(){return t("review.reviewingPane")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),We(r,X(ia,{as:"p",get children(){return[et(()=>t("review.revisionCount")),": ",et(()=>o().length)]}}),null),We(r,X(Ft,{get when(){return n().length-o().length>0},get children(){return X(ia,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),We(r,X(Ft,{get when(){return o().length>0},get fallback(){return X(ia,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=WS();return We(n,X(ee,{get each(){return o()},children:n=>{return o=VS(),r=o.firstChild,a=r.nextSibling,We(r,X(ia,{as:"span",get class(){return"oasis-review-revision-type "+("delete"===n.type?"review-revisions-icon-delete":"review-revisions-icon-insert")},get"data-revision-type"(){return n.type},get children(){return[X(Qr,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),X(ia,{as:"span",get children(){return e=n.type,t("insert"===e||"delete"===e?"insert"===e?"review.revisionInsert":"review.revisionDelete":"review.revisionProperty");var e}})]}}),null),We(r,X(ia,{as:"p",get children(){return n.snippet||"—"}}),null),We(r,X(ia,{as:"span",get children(){return n.author}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r,a}})),n}}),null),We(r,X(Ft,{get when(){return o().length>0},get children(){var n=US();return We(n,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),We(n,X(Qe,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),fe(()=>le(r,"aria-label",t("review.reviewingPane"))),r;var r,a}var XS=/*#__PURE__*/f('<div class="oasis-editor-shell oasis-editor-app">');function GS(e={}){const t=e.runtime?.client??Je(),[n,r]=an({}),a=()=>({...e.ui??{},...n(),toolbar:{...e.ui?.toolbar??{},...n().toolbar??{}}}),i=()=>({...e.document??{},...void 0===n().readOnly?{}:{readOnly:n().readOnly}}),l=()=>({...a(),readOnly:i().readOnly}),s=e=>(r(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...l(),...e}),c=()=>e.runtime??{};Ei();const d=Ge(()=>a().locale??"pt-BR"),u=k("app"),{state:p,commitState:f,getStateSnapshot:m}=function(e){const t=e.initialState?kn(e.initialState):e.initialDocument?wo(e.initialDocument):wn();let n=t;const[o,r]=an(t);return{state:new Proxy({},{get(e,t){const n=o();if(null!==n&&("object"==typeof n||"function"==typeof n))return Reflect.get(n,t)},has(e,t){const n=o();return null!==n&&("object"==typeof n||"function"==typeof n)&&Reflect.has(n,t)},ownKeys(e){const t=o();return null===t||"object"!=typeof t&&"function"!=typeof t?[]:Reflect.ownKeys(t)},getOwnPropertyDescriptor(e,t){const n=o();return null===n||"object"!=typeof n&&"function"!=typeof n?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(n,t),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:e=>{const t=pa(e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:i().initialDocument,initialState:i().initialState}),h=e=>{f(e)},b=kn;let y=!1;const{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:S,showOutline:I,toggleOutline:T,toolbarView:P,toolbarLayout:R,isReadOnly:B,useComposedShell:A,loadingOptions:M,loadingLabel:F,shellComponent:D}=function(e){const{ui:t,documentOptions:n,updateUiState:o,state:r}=e,a=()=>{const e=t().loading;return"object"==typeof e&&null!==e?e:void 0};return{showChrome:()=>t().showChrome??!0,showTitleBar:()=>t().showTitleBar??!0,showMenubar:()=>t().showMenubar??!0,showToolbar:()=>t().showToolbar??!0,showOutline:()=>t().showOutline??!0,toggleOutline:()=>{o({showOutline:!(t().showOutline??!0)})},toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>(n().readOnly??!1)||"all"!==(r().reviewDisplayMode??"all"),useComposedShell:()=>"docs"===t().uiVariant||"document"!==(t().shell??"document"),loadingOptions:a,loadingLabel:()=>a()?.label??"Loading oasis-editor...",shellComponent:()=>{const e=t().shell??"document";return"inline"===e?oa:"balloon"===e?C:Pt}}}({ui:a,documentOptions:i,updateUiState:s,state:()=>p}),L=function(){const[e,t]=an(!1);let n,o,r,a,i;return{focused:e,setFocused:t,focusInput:()=>{t(!0),queueMicrotask(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{t(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},focusInputSync:()=>{t(!0),r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)},get viewportRef(){return n},set viewportRef(e){n=e},get surfaceRef(){return o},set surfaceRef(e){o=e},get textareaRef(){return r},set textareaRef(e){r=e},get importInputRef(){return a},set importInputRef(e){a=e},get imageInputRef(){return i},set imageInputRef(e){i=e}}}(),N=L.focused,$=L.setFocused,z=L.focusInput,H=L.focusInputAfterPointerSelection,W=L.focusInputSync,[U,j]=an(!1!==a().loading),V=ce(),{linkDialog:K,setLinkDialog:_,imageAltDialog:G,setImageAltDialog:q,imageCaptionDialog:Y,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:se,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:pe,symbolDialog:ge,setSymbolDialog:me,equationDialog:he,setEquationDialog:be}=function(){const[e,t]=an({isOpen:!1}),[n,o]=an({isOpen:!1}),[r,a]=an({isOpen:!1}),[i,l]=an({isOpen:!1,initialHref:""}),[s,c]=an({isOpen:!1,initialAlt:""}),[d,u]=an({isOpen:!1,initialCaption:""}),[p,g]=an({isOpen:!1,x:0,y:0}),[f,m]=an({isOpen:!1,initial:{fontFamily:"",fontSize:"",color:"",colorMode:"automatic",highlight:"",shading:"",bold:!1,italic:!1,underline:!1,underlineStyle:null,underlineColor:"",strike:!1,doubleStrike:!1,superscript:!1,subscript:!1,smallCaps:!1,allCaps:!1,hidden:!1,characterScale:"",characterSpacing:"",baselineShift:"",kerningThreshold:"",ligatures:"",numberSpacing:"",numberForm:"",stylisticSet:"",contextualAlternates:!1}}),[h,b]=an({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",mirrorIndents:!1,spacingBefore:"",spacingAfter:"",lineHeight:"",lineRule:"",contextualSpacing:!1,outlineLevel:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1,pageBreakBefore:!1,keepWithNext:!1,keepLinesTogether:!1,widowControl:!0,tabs:[]}}),[y,v]=an({isOpen:!1,action:"accept",count:0}),[x,w]=an({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""}});return{newDocumentDialog:e,setNewDocumentDialog:t,symbolDialog:n,setSymbolDialog:o,equationDialog:r,setEquationDialog:a,linkDialog:i,setLinkDialog:l,imageAltDialog:s,setImageAltDialog:c,imageCaptionDialog:d,setImageCaptionDialog:u,contextMenu:p,setContextMenu:g,fontDialog:f,setFontDialog:m,paragraphDialog:h,setParagraphDialog:b,tablePropertiesDialog:x,setTablePropertiesDialog:w,revisionBulkDialog:y,setRevisionBulkDialog:v}}(),[ye,ve]=an(!1),xe=()=>L.viewportRef,we=()=>L.surfaceRef,Se=ry({documentOptions:i,logger:u,runtimeClient:t,state:p,commitState:f,getStateSnapshot:m,applyState:h,cloneState:b,isReadOnly:B,focusInput:z,surfaceRef:we,viewportRef:xe,zoomFactor:V.zoomFactor,getImageOps:()=>Xe.imageOps}),{docIO:Ce,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,canvasSnapshotProvider:Pe,inputBox:Be,selectionBoxes:Ae,commentHighlights:Me,revisionMarkupBoxes:Fe,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Ee,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,clearPreferredColumn:ze,onCleanupHook:He,persistenceStatus:Ue,applyTransactionalState:je,resetTransactionGrouping:Ve,updateHistoryState:Ke}=Se,_e=li({state:()=>p,isReadOnly:B,applyTransactionalState:je,applyTableAwareParagraphEdit:(e,t)=>Xe.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:ze,resetTransactionGrouping:Ve,focusInput:z}),Xe=ix({clipboardActions:_e,state:p,logger:u,isReadOnly:B,applyState:h,cloneState:b,focusInput:z,focusInputAfterPointerSelection:H,focusInputSync:W,surfaceRef:we,viewportRef:xe,zoomFactor:V.zoomFactor,insertImageFromFile:Ce.insertImageFromFile,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},getCommandsController:()=>Rt.commandsController,applyTransactionalState:je,clearPreferredColumn:ze,resetTransactionGrouping:Ve,updateHistoryState:Ke,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,canvasSnapshotProvider:Pe,openEquationDialog:(e,t)=>{be({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:qe,fr:Ye,tableOps:Ze,imageOps:Qe,textBoxOps:tt,styleController:nt,onEditorPointerDown:ot,tableResize:rt,tableCornerResize:at,tableDrag:it,revisionController:lt,textDrag:st,surfaceEventsWithTextDrag:ct,textInput:dt,handleCopy:pt,handleCut:gt,handlePaste:ft,handleDrop:mt}=Xe,[ht,bt]=an(!1),[yt,vt]=an(0),xt=function(){const[e,t]=an(!1);return{open:()=>e(),toggle:()=>(t(e=>!e),!0),close:()=>{t(!1)}}}(),wt=Ri(Bi),It=e=>{p.selection.anchor.offset;try{return!1!==Ot().commands.canExecute(e)}catch{return!1}},Tt=e=>{try{Ot().commands.execute(e)}catch(t){u.error("quick-access execute failed",t)}},kt=MS({state:()=>p,isReadOnly:B,applyTransactionalState:je,focusInput:z,access:()=>c().review}),Rt=kS({onExecutedTap:()=>{vt(e=>e+1)},commandSearch:{isOpen:ht,setIsOpen:e=>{bt(e)}},setCommandSearchOpen:bt,clipboardActions:_e,document:Se,interaction:Xe,commentComposer:kt,state:p,logger:u,isReadOnly:B,focusInput:z,applyState:h,getStateSnapshot:m,cloneState:b,setFocused:$,setInitialLoading:j,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},locale:()=>a().locale??"pt-BR",translator:d,runtimeClient:t,runtimeOptions:c,documentOptions:i,getUiState:l,updateUiState:s,zoom:V,importInputRef:()=>L.importInputRef,imageInputRef:()=>L.imageInputRef,setLinkDialog:_,setImageAltDialog:q,setImageCaptionDialog:J,setNewDocumentDialog:pe,setSymbolDialog:me,setEquationDialog:be,setTablePropertiesDialog:ie,setFontDialog:ne,setParagraphDialog:re,setRevisionBulkDialog:de,toggleOutline:T,isOutlineVisible:I,toggleRevisionsPanel:()=>{xt.toggle()},revisionsPanelVisible:xt.open}),{commandsController:Bt,runtimeReady:At,runtimeEditor:Ot,toolbarHost:Dt,toolbarRegistry:Et,menuRegistry:Lt,handleKeyDown:Nt}=Rt,$t=()=>function(e,t,n){const o=[],r=/* @__PURE__ */new Set;for(const a of e){if("hidden"in a&&!0===a.hidden)continue;const e=xi(a);if(!e)continue;const t=a.label;if("string"!=typeof t||!t.trim())continue;if(r.has(e.command))continue;r.add(e.command);const n={id:a.id,label:t,command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"ribbon"};o.push(n)}for(const a of t){if(!0===a.hidden)continue;const e=vi(a.command);if(!e)continue;if(r.has(e.command))continue;r.add(e.command);const t=a.labelKey?n(a.labelKey):a.id;o.push({id:a.id,label:String(t),command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"menubar",...a.shortcut?{shortcut:a.shortcut}:{}})}return o}(Et.getOrdered(),Lt.getItems(),d),zt=e=>{try{return!1!==Ot().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:Ht,computeFontSizeOptions:Wt,applyFontDialogValues:Ut,applyParagraphDialogValues:jt,setParagraphDialogDefault:Vt,applyTablePropertiesDialogValues:Kt,buildContextMenuItems:_t,handleEditorContextMenu:Xt,closeContextMenu:Gt}=vc({clipboardActions:_e,state:()=>p,selection:()=>p.selection,toolbarStyleState:nt.toolbarStyleState,isReadOnly:B,t:d,logger:u,setFontDialog:ne,setParagraphDialog:re,setTablePropertiesDialog:ie,setContextMenu:ee,clearPreferredColumn:ze,resetTransactionGrouping:Ve,applyTransactionalState:je,applyTableAwareParagraphEdit:Ze.applyTableAwareParagraphEdit,focusInput:z,promptForLink:Bt.promptForLink,tableOps:Ze}),{layout:qt,overlays:Yt,refs:Zt,surfaceHandlers:Jt,inputHandlers:en,fileHandlers:tn}=function(e){const{layout:t,overlays:n,refs:o,surface:r,input:a,files:i}=e;return{layout:{documentLayout:t.documentLayout,remoteWebFonts:t.remoteWebFonts,viewportHeight:t.viewportHeight,class:t.className,style:t.style,zoomPercent:t.zoomPercent,setZoomPercent:t.setZoomPercent,zoomFactor:t.zoomFactor},overlays:{selectionBoxes:n.selectionBoxes,commentHighlights:n.commentHighlights,revisionMarkupBoxes:n.revisionMarkupBoxes,onReplyToComment:n.onReplyToComment,onEditComment:n.onEditComment,canEditComment:n.canEditComment,canReplyComment:n.canReplyComment,selectedImageBox:n.selectedImageBox,selectedTextBoxBox:n.selectedTextBoxBox,selectedTableBox:n.selectedTableBox,layoutOptions:n.layoutOptions,caretBox:n.caretBox,inputBox:n.inputBox,hoveredRevision:n.hoveredRevision,focused:n.focused,showCaret:n.showCaret,importProgress:n.importProgress,imageCropMode:n.imageCropMode},refs:{onViewportRef:e=>{o.focusController.viewportRef=e},onSurfaceRef:e=>{o.focusController.surfaceRef=e},onTextareaRef:e=>{o.focusController.textareaRef=e},onImportInputRef:e=>{o.focusController.importInputRef=e},onImageInputRef:e=>{o.focusController.imageInputRef=e}},surfaceHandlers:{onDragOver:e=>e.preventDefault(),onDrop:r.handleDrop,onEditorPointerDown:r.onEditorPointerDown,onSurfacePointerDown:r.surfaceEvents.handleSurfacePointerDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfacePointerMove:r.tableResize.handlePointerMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphPointerDown:r.surfaceEvents.handleParagraphPointerDown,onImagePointerDown:r.handleImagePointerDown,onImageResizeHandlePointerDown:r.handleImageResizeHandlePointerDown,onTextBoxResizeHandlePointerDown:r.handleTextBoxResizeHandlePointerDown,onImageRotateHandlePointerDown:r.handleImageRotateHandlePointerDown,onImageCropHandlePointerDown:r.handleImageCropHandlePointerDown,onImageCropBodyPointerDown:r.handleImageCropBodyPointerDown,onTextBoxRotateHandlePointerDown:r.handleTextBoxRotateHandlePointerDown,onTableDragHandlePointerDown:r.tableDrag.handlePointerDown,onTableCornerResizeHandlePointerDown:r.tableCornerResize.handlePointerDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:e=>r.handleEditorContextMenu(e)},inputHandlers:{onInputBlur:()=>a.setFocused(!1),onInputFocus:()=>a.setFocused(!0),onCompositionEnd:a.textInput.handleCompositionEnd,onCompositionStart:a.textInput.handleCompositionStart,onCompositionUpdate:a.textInput.handleCompositionUpdate,onCopy:a.handleCopy,onCut:a.handleCut,onInput:a.textInput.handleTextInput,onKeyDown:a.handleKeyDown,onKeyUp:a.handleKeyUp,onPaste:a.handlePaste},fileHandlers:{onImportInputChange:e=>i.handleImportFile(e.currentTarget.files?.[0]??null),onImageInputChange:e=>i.handleInsertImage(e.currentTarget.files?.[0]??null)}}}({layout:{documentLayout:ke,remoteWebFonts:i().remoteWebFonts,viewportHeight:a().viewportHeight,className:a().class,style:a().style,zoomPercent:V.zoomPercent,setZoomPercent:V.setZoomPercent,zoomFactor:V.zoomFactor},overlays:{selectionBoxes:Ae,commentHighlights:Me,revisionMarkupBoxes:Fe,onReplyToComment:e=>{kt.openReplyToId(e)},onEditComment:e=>{kt.openEditToId(e)},canEditComment:kt.canEditId,canReplyComment:kt.canReplyId,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Ee,layoutOptions:qe,caretBox:Le,inputBox:Be,hoveredRevision:lt.hoveredRevision,focused:N,showCaret:()=>function(e,t){if(!t.visible||!zr(e.selection))return!1;const n=fo(e),o=St(e.document,e.selection.anchor.paragraphId,n),r=St(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(p,Le()),importProgress:Ce.importProgress,imageCropMode:Qe.cropMode},refs:{focusController:L},files:{handleImportFile:Ce.handleImportFile,handleInsertImage:Ce.handleInsertImage},surface:{surfaceEvents:ct,tableResize:rt,tableCornerResize:at,tableDrag:it,revisionController:lt,handleDrop:mt,onEditorPointerDown:ot,handleImagePointerDown:Qe.handleImagePointerDown,handleImageResizeHandlePointerDown:Qe.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:tt.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Qe.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Qe.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Qe.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:tt.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:Xt},input:{textInput:dt,setFocused:$,handleCopy:pt,handleCut:gt,handlePaste:ft,handleKeyDown:e=>{if("Escape"===e.key&&Xe.formatPainter.mode())return Xe.formatPainter.cancel(),void e.preventDefault();Nt(e)},handleKeyUp:e=>{Xe.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Xe.formatPainter.applyToSelection("keyboard")}}});return Zn(()=>{Ct(),ha(),Xo(),qr(()=>we()??null),ut(),!Mt()&&g()&&ve(!0)}),o(()=>{He(),ct.stopDragging(),st.stopDrag(),rt.stop(),at.stop(),it.stop(),Qe.stopImageDrag(),Qe.stopImageResize(),Qe.stopImageCrop(),tt.stopTextBoxResize(),O()}),X(E,{translator:d,get children(){var e=XS();return Re(e,"--oasis-editor-gutter-x","34px"),We(e,X(Ft,{get when(){return et(()=>!(A()||!v()))()&&S()},get children(){return X(Qt,{host:Dt,registry:Et,get view(){return P()},get layout(){return R()}})}}),null),We(e,X(di,{get notice(){return _e.notice},onDismiss:()=>{_e.dismiss(),z()}}),null),We(e,X(Ft,{get when(){return kt.panelOpen()},get children(){return X(HS,{state:()=>p,composer:kt,locale:()=>a().locale??"pt-BR",get onClose(){return kt.closePanel},onNavigate:e=>{const t=function(e,t){const n=e.document.comments?.items;if(!n?.[t])return e;let o=n[t];const r=/* @__PURE__ */new Set;for(;o&&!o.start&&o.parentId&&!r.has(o.id);)r.add(o.id),o=n[o.parentId];const a=o?.start,i=o?.end;if(!a||!i)return e;const l=Kr(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:Z(s,a.offset),focus:Z(c,i.offset)}}:e}(p,e);t!==p&&(h(t),z())}})}}),null),We(e,X(Ft,{get when(){return xt.open()},get children(){return X(_S,{state:()=>p,get onClose(){return xt.close},onNavigate:e=>{const t=uw(p,e);t!==p&&(h(t),z())},onAccept:e=>{const t=uw(p,e);t!==p&&(h(t),Bt.applyAcceptRevisionsCommand(),z())},onReject:e=>{const t=uw(p,e);t!==p&&(h(t),Bt.applyRejectRevisionsCommand(),z())},onAcceptAll:()=>Ot().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>Ot().commands.execute("requestRejectAllRevisions")})}}),null),We(e,X(yi,{get isOpen(){return ht()},get entries(){return $t()},isEnabled:zt,onExecute:e=>{Ot().commands.execute(e.command,e.payload),bt(!1),z()},onClose:()=>{bt(!1),z()}}),null),We(e,X(Qd,{commentComposer:kt,dialogs:{linkDialog:K,setLinkDialog:_,imageAltDialog:G,setImageAltDialog:q,imageCaptionDialog:Y,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:se,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:pe,symbolDialog:ge,setSymbolDialog:me,equationDialog:he,setEquationDialog:be},findReplace:Ye,fontFamilyOptions:Ht,fontSizeOptions:Wt,contextMenuItems:_t,focusInput:z,get applyLinkCommand(){return Bt.applyLinkCommand},get applyImageAltCommand(){return Bt.applyImageAltCommand},get applyImageCaptionCommand(){return Bt.applyImageCaptionCommand},applyFontDialogValues:Ut,applyParagraphDialogValues:jt,setParagraphDialogDefault:Vt,applyTablePropertiesDialogValues:Kt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{Ot().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),z()},insertSymbol:(e,t)=>{Ot().commands.execute("insertText",{text:e,fontFamily:t}),z()},applyEquation:(e,t)=>{t?Ot().commands.execute("updateEquation",{runId:t,expression:e}):Ot().commands.execute("insertEquation",e),z()},closeContextMenu:Gt}),null),We(e,X(Ft,{get when(){return S()},get children(){return X(Ti,{catalog:Bi,get visible(){return wt.visible},get onToggle(){return wt.toggle},onExecute:Tt,canExecute:It,tick:yt,onOpenCommandSearch:()=>{bt(!0)}})}}),null),We(e,X(tu,{useComposedShell:A,shellComponent:D,runtime:{state:()=>p,toolbarHost:Dt,runtimeEditor:Ot,persistenceStatus:Ue,toolbarRegistry:Et,menuRegistry:Lt},chrome:{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:S,showOutline:I,toolbarView:P,toolbarLayout:R},view:{isReadOnly:B,viewportHeight:()=>a().viewportHeight,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,layout:qt,overlays:Yt,refs:Zt,surfaceHandlers:Jt,inputHandlers:en,fileHandlers:tn}}),null),We(e,X(Tc,{state:p,get surfaceRef(){return we()},documentLayout:ke,snapshotProvider:Pe,get zoomFactor(){return V.zoomFactor},tableResize:rt,tableCornerResize:at,imageOps:Qe,tableDrag:it,textDrag:st}),null),We(e,X(Ft,{get when(){return U()||!At()},get children(){return X(ta,{get label(){return F()},get class(){return M()?.class},get style(){return M()?.style}})}}),null),We(e,X(ou,{get isOpen(){return et(()=>!(!ye()||U()))()&&At()},onClose:()=>ve(!1)}),null),fe(t=>{var n=a().theme??"light",o=!!A(),r=!!B(),i=!(null===Xe.formatPainter.mode());return n!==t.e&&le(e,"data-theme",t.e=n),o!==t.t&&e.classList.toggle("oasis-editor-docs",t.t=o),r!==t.a&&e.classList.toggle("oasis-editor-read-only",t.a=r),i!==t.o&&e.classList.toggle("oasis-editor-format-painter-active",t.o=i),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e}})}export{GS as OasisEditorApp};
|
|
1
|
+
import{$ as e,$a as t,$n as n,$o as o,$t as r,A as a,Aa as i,An as l,Ao as s,Ar as c,B as d,Ba as u,Bi as p,Bn as g,Bo as f,Br as m,Bt as h,C as b,Ca as y,Ci as v,Cn as x,Co as w,Cr as S,Ct as C,D as I,Da as T,Di as k,Dn as P,Do as R,Dr as B,Dt as A,E as M,Ea as F,Ei as O,En as D,Eo as E,Er as L,Et as N,F as $,Fa as z,Fn as H,Fr as W,Ft as U,G as j,Ga as V,Gi as K,Gn as _,Go as X,Gr as G,Gt as q,H as Y,Ha as Z,Hi as J,Hn as Q,Ho as ee,Hr as te,Ht as ne,I as oe,Ia as re,Ii as ae,In as ie,Io as le,Ir as se,It as ce,J as de,Ja as ue,Ji as pe,Jn as ge,Jo as fe,Jr as me,Jt as he,K as be,Ka as ye,Ki as ve,Kn as xe,Ko as we,Kr as Se,Kt as Ce,L as Ie,La as Te,Li as ke,Ln as Pe,Lo as Re,Lr as Be,Lt as Ae,M as Me,Ma as Fe,Mi as Oe,Mn as De,Mo as Ee,Mr as Le,N as Ne,Na as $e,Ni as ze,Nn as He,No as We,Nr as Ue,Nt as je,O as Ve,Oa as Ke,Oi as _e,On as Xe,Oo as Ge,Or as qe,P as Ye,Pa as Ze,Pi as Je,Pn as Qe,Po as et,Pr as tt,Pt as nt,Q as ot,Qa as rt,Qn as at,Qo as it,Qt as lt,R as st,Ra as ct,Ri as dt,Rn as ut,Rr as pt,Rt as gt,S as ft,Sa as mt,Si as ht,Sn as bt,So as yt,Sr as vt,St as xt,T as wt,Ta as St,Ti as Ct,Tn as It,To as Tt,Tr as kt,Tt as Pt,U as Rt,Ua as Bt,Ui as At,Un as Mt,Uo as Ft,Ur as Ot,Ut as Dt,V as Et,Va as Lt,Vi as Nt,Vn as $t,Vo as zt,Vr as Ht,Vt as Wt,W as Ut,Wa as jt,Wi as Vt,Wn as Kt,Wo as _t,Wr as Xt,Wt as Gt,X as qt,Xa as Yt,Xn as Zt,Xo as Jt,Xr as Qt,Xt as en,Y as tn,Ya as nn,Yi as on,Yn as rn,Yo as an,Yr as ln,Yt as sn,Z as cn,Za as dn,Zn as un,Zt as pn,_ as gn,_a as fn,_i as mn,_n as hn,_o as bn,_r as yn,_t as vn,a as xn,aa as wn,ai as Sn,an as Cn,ao as In,ar as Tn,at as kn,b as Pn,ba as Rn,bi as Bn,bn as An,bo as Mn,br as Fn,bt as On,c as Dn,ca as En,cn as Ln,co as Nn,cr as $n,ct as zn,d as Hn,da as Wn,di as Un,dn as jn,do as Vn,dr as Kn,dt as _n,ei as Xn,en as Gn,eo as qn,er as Yn,es as Zn,et as Jn,f as Qn,fa as eo,fn as to,fo as no,fr as oo,ft as ro,g as ao,ga as io,gi as lo,gn as so,go as co,gr as uo,gt as po,h as go,ha as fo,hi as mo,hn as ho,ho as bo,hr as yo,ht as vo,i as xo,ia as wo,in as So,io as Co,ir as Io,it as To,j as ko,ja as Po,ji as Ro,jn as Bo,jo as Ao,jr as Mo,k as Fo,ka as Oo,kn as Do,kr as Eo,l as Lo,la as No,ln as $o,lo as zo,lr as Ho,lt as Wo,m as Uo,ma as jo,mi as Vo,mn as Ko,mo as _o,mr as Xo,mt as Go,n as qo,nn as Yo,no as Zo,nr as Jo,ns as Qo,nt as er,o as tr,oa as nr,oi as or,on as rr,oo as ar,or as ir,ot as lr,p as sr,pa as cr,pi as dr,pn as ur,po as pr,pr as gr,pt as fr,q as mr,qa as hr,qi as br,qn as yr,qo as vr,qr as xr,qt as wr,r as Sr,rn as Cr,ro as Ir,rr as Tr,s as kr,sa as Pr,si as Rr,sn as Br,so as Ar,sr as Mr,st as Fr,t as Or,tn as Dr,to as Er,tr as Lr,tt as Nr,u as $r,ua as zr,un as Hr,uo as Wr,ur as Ur,ut as jr,v as Vr,va as Kr,vi as _r,vn as Xr,vo as Gr,vr as qr,vt as Yr,w as Zr,wa as Jr,wi as Qr,wn as ea,wo as ta,wr as na,wt as oa,x as ra,xa as aa,xi as ia,xn as la,xo as sa,xr as ca,xt as da,y as ua,ya as pa,yi as ga,yn as fa,yo as ma,yr as ha,yt as ba,z as ya,za as va,zi as xa,zn as wa,zo as Sa,zr as Ca,zt as Ia}from"./defaultToolbar-CSM7SoWl.js";function Ta(e,t){return{document:e.document,selection:t}}function ka(e,t){if(!zr(e.selection))return ko(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=Ne(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,oe(Z(i,Math.min(r,u(i)))))}function Pa(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=Ne(e),i=u(o);if(t<0&&a>0)return Ta(e,{anchor:e.selection.anchor,focus:Z(o,a-1)});if(t>0&&a<i)return Ta(e,{anchor:e.selection.anchor,focus:Z(o,a+1)});if(t<0&&r>0){const t=n[r-1];return Ta(e,{anchor:e.selection.anchor,focus:Z(t,u(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return Ta(e,{anchor:e.selection.anchor,focus:Z(t,0)})}return e}function Ra(e,t){const{paragraphs:n,index:o,offset:r}=Ne(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,{anchor:e.selection.anchor,focus:Z(i,Math.min(r,u(i)))})}function Ba(e){const t=Wn(e);if(t.isCollapsed)return"";const n=Kr(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return Lt(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(Lt(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(Lt(n[i]));return o.push(Lt(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Aa(e,t){return{...e,selection:{anchor:nr(e,t.anchor),focus:nr(e,t.focus)}}}function Ma(e){if(!zr(e.selection))return ko(e,"start");const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o>0)return{document:e.document,selection:oe(Z(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:oe(Z(a,u(a)))}}function Fa(e){if(!zr(e.selection))return ko(e,"end");const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o<u(t))return{document:e.document,selection:oe(Z(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:oe(Z(a,0))}}function Oa(e){const t=Wn(e);if(t.isCollapsed)return"";const n=Kr(e),o=[];let r=null;const a=()=>{r&&(o.push("bullet"===r?"</ul>":"</ol>"),r=null)};for(let i=t.startIndex;i<=t.endIndex;i+=1){const l=n[i];if(!l)continue;const s=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:u(l),d=Rt(l,s,c),p=ke(l.style),g=p.length>0?` style="${p}"`:"",f=ae(d,e.document);if(l.list?.kind){const e="bullet"===l.list.kind?"ul":"ol";r!==l.list.kind&&(a(),o.push(`<${e}>`),r=l.list.kind),o.push(`<li${g}>${f}</li>`);continue}a(),o.push(`<p${g}>${f}</p>`)}return a(),o.join("")}function Da(e,t){if(0===t.length)return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Kr(n),s=Rt(o,0,i),c=Rt(o,i,u(o)),d=t.map(e=>{const t=_o(e.runs.map(e=>({text:e.text,styles:Yo(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let p,g=oe(Z(o,i));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=Ut(o,[...s,...e.runs.map(Gn),...c],Y(o,i));n.style=o.style?{...o.style}:e.style?{...e.style}:void 0,n.list=o.list?{...o.list}:e.list?{...e.list}:void 0,p=[...r(l.slice(0,a)),n,...r(l.slice(a+1))],g=oe(Z(n,s.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=d[0],t=d[d.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),u=Ut(o,[...s,...e.runs.map(Gn)],Y(o,i));u.style=o.style?{...o.style}:e.style?{...e.style}:void 0,u.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(pn),m=Ut(t,[...t.runs.map(Gn),...c],void 0);m.list=t.list?{...t.list}:void 0,p=[...r(l.slice(0,a)),u,...f,m,...r(l.slice(a+1))],g=oe(Z(m,n))}return Ie(n,p,g)}function Ea(e){return e.map(Gn)}function La(e){return e.reduce((e,t)=>e+t.text.length,0)}function Na(e,t,n){if(0===n.length)return e;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=Bt(a,t),l=Ea(n[0].runs);if(1===n.length){const t=d(a,i,l),n=o.map((e,n)=>n===r?t:e),s=La(l),c=Z(t,i),u=Z(t,i+s);return Ie(e,n,{anchor:c,focus:u})}const s=Rt(a,0,i),c=Rt(a,i,u(a)),p=n[n.length-1],g=n.slice(1,-1),f=Ut(pn(n[0].paragraphTemplate),[...s,...l],Y(a,i)),m=g.map(e=>Ut(pn(e.paragraphTemplate),Ea(e.runs))),h=Ut(pn(p.paragraphTemplate),[...Ea(p.runs),...c],Y(a,i)),b=[...o.slice(0,r),f,...m,h,...o.slice(r+1)],y=Z(f,La(s)),v=Z(h,La(p.runs));return Ie(e,b,{anchor:y,focus:v})}function $a(e,t,n={}){if(Wn(e).isCollapsed)return e;if(function(e,t){const n=Wn(e);if(n.isCollapsed)return!1;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return!1;if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r],i=Bt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,t))return e;const o=function(e){const t=Wn(e);if(t.isCollapsed)return[];const n=Kr(e),o=[];for(let r=t.startIndex;r<=t.endIndex;r+=1){const e=n[r],a=r===t.startIndex?t.startParagraphOffset:0,i=r===t.endIndex?t.endParagraphOffset:u(e),l=Rt(e,a,i);o.push({paragraphTemplate:pn(e),runs:l})}return o}(e);if(0===o.length)return e;if(n.copy)return Na(e,t,o);const r=function(e,t){const n=Wn(e),o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=Bt(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return Z(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,t);return Na(Me(e),r,o)}function za(e,t,n){if(0===t.length)return e;const o=zr(e.selection)?e:Me(e),{paragraph:r,index:a,offset:i}=Ne(o),l=n?{...n}:Y(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:l,kind:"text"};o.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=d(r,i,[s]),u=Kr(o).map((e,t)=>t===a?c:e);return Ie(o,u,oe(Z(c,i+t.length)))}function Ha(e){return za(e,"\v")}function Wa(e,t,n){if(0===t.length)return e;const o=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!o.includes("\n"))return za(e,o,n);const r=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ne(r),s=o.split("\n"),c=n?{...n}:Y(a,l),d=Rt(a,0,l),p=Ut(a,[...d,co(s[0],c)],c),g=Rt(a,l,u(a)),f=s.slice(1,-1).map(e=>mr([{text:e,styles:c}])),m=mr([{text:s[s.length-1],styles:c},...g.map(e=>({text:e.text,styles:e.styles}))]),h=Kr(r),b=[...h.slice(0,i),p,...f,m,...h.slice(i+1)];return Ie(r,b,oe(Z(m,s[s.length-1].length)))}function Ua(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o>0){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<=t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o-1),...Rt(t,o,u(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o-1)))}const c=i.text[s-1],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...Rt(t,0,o-1),d,...Rt(t,o,u(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o-1)))}}const a=Ut(t,[...Rt(t,0,o-1),...Rt(t,o,u(t))],Y(t,o-1)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o-1)))}if(0===n)return e;const a=r[n-1],i=Ut(a,[...a.runs.map(Gn),...t.runs.map(Gn)]),l=[...r.slice(0,n-1),i,...r.slice(n+1)];return Ie(e,l,oe(Z(i,u(a))))}function ja(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ne(e),r=Kr(e);if(o<u(t)){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o),...Rt(t,o+1,u(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o)))}const c=i.text[s],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...Rt(t,0,o),d,...Rt(t,o+1,u(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o)))}}const a=Ut(t,[...Rt(t,0,o),...Rt(t,o+1,u(t))],Y(t,o)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o)))}if(n>=r.length-1)return e;const a=r[n+1],i=Ut(t,[...t.runs.map(Gn),...a.runs.map(Gn)]),l=[...r.slice(0,n),i,...r.slice(n+2)];return Ie(e,l,oe(Z(i,o)))}function Va(e,t,n,o,r){let a=Cr(n,o,r);const i=Te(a,t.style?.styleId,e.document.styles);return!r&&i[o]&&(a={...a,[o]:!1}),!r||"superscript"!==o&&"subscript"!==o||(a=Va(e,t,a,"superscript"===o?"subscript":"superscript",!1)),a}function Ka(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((t,o)=>{const r=n.startIndex+o,a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:u(t);return Rt(t,a,i).map(n=>({...n,styles:Te(n.styles,t.style?.styleId,e.document.styles)}))}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.[t])),i=o.map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const i=r===n.startIndex?n.startParagraphOffset:0,l=r===n.endIndex?n.endParagraphOffset:u(o);return Ye(o,i,l,n=>({...n,styles:Va(e,o,n.styles,t,a)}))});return Ie(e,i,$(i,n))}function _a(e,t,n){const o=Wn(e);if(o.isCollapsed)return e;const r=Kr(e).map((e,r)=>{if(r<o.startIndex||r>o.endIndex)return e;const a=r===o.startIndex?o.startParagraphOffset:0,i=r===o.endIndex?o.endParagraphOffset:u(e);return Ye(e,a,i,e=>({...e,styles:So(e.styles,t,n)}))});return Ie(e,r,$(r,o))}function Xa(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e),r=e.document.styles,a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:u(e);return Ye(e,a,i,n=>{const o=(Te(n.styles,e.style?.styleId,r).fontSize??14.6667)*ar,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:So(n.styles,"fontSize",a/ar)}})});return Ie(e,a,$(a,n))}var Ga={width:.5,type:"solid",color:"#000000"};function qa(e,t){const n={...e??{}};return t?n.textBorder=Ga:delete n.textBorder,Object.keys(n).length>0?n:void 0}function Ya(e){return/\p{L}/u.test(e)}function Za(e,t){switch(t){case"lower":return e.toLowerCase();case"upper":return e.toUpperCase();case"capitalize":return function(e){let t="",n=!1;for(const o of e){const e=Ya(o);t+=e&&!n?o.toUpperCase():o,n=e}return t}(e);case"toggle":return function(e){let t="";for(const n of e){const e=n.toUpperCase(),o=n.toLowerCase();t+=n===o&&n!==e?e:n===e&&n!==o?o:n}return t}(e);default:return function(e){let t="",n=!0;for(const o of e.toLowerCase())n&&Ya(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function Ja(e,t){return function(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e).map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:u(e),i=t(Rt(e,r,a).map(e=>e.text).join(""));let l=0;return Ye(e,r,a,e=>{const t=e.text.length,n=i.slice(l,l+t);return l+=t,{...e,text:n}})});return Ie(e,o,$(o,n))}(e,e=>Za(e,t))}var Qa=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function ei(e,t){const n=Yo(e)??{};delete n.link;for(const o of Qa)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function ti(e,t){if(0===t.length)return[];const n=Wn(e),o=Kr(e)[n.startIndex];if(!o)return t;const r=Y(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:ei(r,e.styles)})),style:Dr(o.style),list:o.list?{...o.list}:void 0}))}function ni(e){if("undefined"==typeof document||0===e.trim().length)return[];const t=document.createElement("template");t.innerHTML=e;const n=[],o=Array.from(t.content.childNodes),r=(e,t,o)=>{const r=t.length>0?t:[co("")];n.push({runs:r.map(e=>{const t=qn(e);return{text:e.text,styles:Yo(e.styles),image:t?{...t}:void 0}}),style:e?ve(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,br(n,void 0),{kind:t,level:0})};for(const i of o){if(i.nodeType===Node.TEXT_NODE){const e=i.textContent??"";e.trim().length>0&&r(null,[co(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=on(e.tagName);if(t){a(e,t);continue}if(pe(e.tagName)){r(e,br(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=br(e,void 0);n.length>0&&r(null,n)}return n}async function oi(e,t){if(e.isReadOnly())return!1;if("undefined"==typeof navigator||!Boolean(navigator.clipboard?.read||navigator.clipboard?.readText))return e.onIssue?.("access-denied"),!1;const n=e.state(),o={anchor:{...n.selection.anchor},focus:{...n.selection.focus}};let r;try{r=await async function(e){const t=navigator.clipboard;let n=/* @__PURE__ */new Error("Clipboard access unavailable"),o=!1,r=!1;const a="text"===e&&Boolean(t?.readText);if(a)try{const e=await t.readText();return e?{kind:"content",text:e,html:""}:{kind:"empty"}}catch(i){n=i}if(t?.read)try{const n=await t.read();let a="",i="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(a=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(i=await(await t.getType("text/plain")).text());if(a||i)return{kind:"content",html:a,text:i};o=!0,r=n.length>0}catch(i){n=i}if(!a&&t?.readText)try{const e=await t.readText();if(e)return{kind:"content",text:e,html:""};o=!0}catch(i){n=i}if(o)return{kind:r?"unsupported":"empty"};throw n}(t)}catch(s){return e.onError?.(s),e.onIssue?.("access-denied"),!1}if(e.isReadOnly())return!1;if(e.state().document!==n.document)return e.onIssue?.("document-changed"),!1;if("content"!==r.kind)return e.onIssue?.(r.kind),!1;const a="text"!==t?ni(r.html):[],i="merge"===t?ti({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return e.onIssue?.("unsupported"),!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let l=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},s=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Da(e,i):Wa(e,r.text));return l=s.document!==t.document,s}),l&&e.focusInput(),l}function ri(e){if("undefined"==typeof document||"function"!=typeof document.execCommand)return!1;const t=document.activeElement,n=document.createElement("textarea");n.value=e,n.readOnly=!0,n.setAttribute("aria-hidden","true"),n.style.cssText="position:fixed;opacity:0;left:-9999px;top:0",document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),document.execCommand("copy")}catch{return!1}finally{n.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}}function ai(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>ri(e))}catch{}return Promise.resolve(ri(e))}async function ii(e,t){const n=await function(e){const t=Ba(e);if(!t)return Promise.resolve(!1);const n="undefined"!=typeof navigator?navigator.clipboard:void 0;if(n?.write&&"undefined"!=typeof ClipboardItem)try{const o=Oa(e),r=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})});return n.write([r]).then(()=>!0,()=>ai(t))}catch{}return ai(t)}(e);return!n&&Ba(e)&&t?.("access-denied"),n}function li(e){return function(e){const[t,n]=an();let r,a=0;Jt()&&o(()=>{a++});const i=()=>{n(void 0),r=void 0},l=()=>{a++,i()},s=async(t,o="rich")=>{const l=++a;i();const s=e.state(),c=i=>{l===a&&(n({action:t,issue:i,..."paste"===t?{mode:o}:{}}),"access-denied"!==i&&"unsupported"!==i||("paste"!==t||"unsupported"===i&&"rich"!==o||(r={document:s.document,mode:o}),e.focusInput()),e.onIssue?.(i))};if("copy"===t)return ii(s,c);const d={...e,onIssue:c,isReadOnly:()=>l!==a||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.state();if(!Ba(t))return!1;if(!(await ii(t,e.onIssue))||e.isReadOnly())return!1;if(e.state().document!==t.document)return e.onIssue?.("document-changed"),!1;const n={anchor:{...t.selection.anchor},focus:{...t.selection.focus}};let o=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==t.document)return r;const a={...r,selection:n},i=e.applyTableAwareParagraphEdit(a,e=>Ua(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):oi(d,o)},c=()=>{const t=r;return l(),t?.document===e.state().document?t.mode:void 0};return{notice:t,dismiss:l,consumePasteMode:c,copy:()=>s("copy"),cut:()=>s("cut"),paste:(e="rich")=>s("paste",e),hasSelection:()=>Ba(e.state()).length>0}}(e)}var si=/*#__PURE__*/f("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),ci=/*#__PURE__*/f("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function di(e){const t=R();let n;const[r,a]=an(12);we(()=>{if(!e.notice())return;const t=n?.parentElement;if(!t)return;const r=()=>{const e=t.getBoundingClientRect(),o=t.querySelector(".oasis-editor-toolbar"),r=o?o.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),l=window.innerHeight-e.top-(n?.offsetHeight??0)-12;a(Math.max(i,Math.min(r,l)))};queueMicrotask(r);const i=new ResizeObserver(r);i.observe(t),n&&i.observe(n);const l=t.querySelector(".oasis-editor-toolbar");l&&i.observe(l),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),o(()=>{i.disconnect(),window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)})});return i=si(),"function"==typeof n?zt(n,i):n=i,We(i,X(Ft,{get when(){return e.notice()},children:n=>{return o=ci(),We(o,X(Qr,{name:"clipboard"}),null),We(o,X(ia,{get children(){return(e=>{const n=`${/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+"}${"copy"===e.action?"C":"cut"===e.action?"X":"V"}`,o="access-denied"===e.issue?`clipboard.${e.action}Denied`:"empty"===e.issue?"clipboard.empty":"document-changed"===e.issue?"clipboard.documentChanged":e.mode&&"rich"!==e.mode?"clipboard.unsupportedOption":"clipboard.unsupported";return t(o,[n])})(n())}}),null),We(o,X(A,{variant:"ghost",size:"sm",icon:"x",get label(){return t("generic.close")},get onClick(){return e.onDismiss},"data-testid":"editor-clipboard-feedback-close"}),null),o;var o}})),fe(e=>Re(i,"top",`${r()}px`)),i;var i}var ui=/[\s\-–—/_([{]/;function pi(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=t.toLowerCase();if(o===n)return 1e3;const r=o.indexOf(n);if(r>=0){let e=400;return 0===r?e+=400:!function(e,t){return 0===t||ui.test(e[t-1]??"")}(o,r)?e+=100:e+=200,e+=Math.round(n.length/o.length*50),e}let a=0,i=-1,l=-1,s=0;for(const d of n){const e=o.indexOf(d,a);if(-1===e)return null;-1===i&&(i=e),s+=e-a,a=e+1,l=e}const c=l-i+1;return Math.max(1,120-s-4*Math.abs(c-n.length))}function gi(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=pi(n,t.label),r=pi(n,t.command),a=Math.max(o??Number.NEGATIVE_INFINITY,(r??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var fi=/*#__PURE__*/f("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),mi=/*#__PURE__*/f("<div class=oasis-command-search-overlay role=presentation data-testid=editor-command-search-overlay><div class=oasis-command-search role=dialog aria-modal=true data-testid=editor-command-search>"),hi=/*#__PURE__*/f("<kbd class=oasis-command-search-shortcut>"),bi=/*#__PURE__*/f("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function yi(e){const t=R(),[n,o]=an(""),[r,a]=an(0);let i;we(()=>{e.isOpen&&(o(""),a(0),queueMicrotask(()=>{i?.focus()}))});const l=vr(()=>function(e,t,n=24){const o=e.trim().toLowerCase();if(0===o.length)return t.map(e=>({...e,score:0})).sort((e,t)=>e.label.localeCompare(t.label)).slice(0,n);const r=[];for(const a of t){const e=gi(o,a);null!==e&&r.push({...a,score:e})}return r.sort((e,t)=>t.score-e.score||e.label.length-t.label.length),r.slice(0,n)}(n(),e.entries,12));we(()=>{l(),a(e=>Math.min(e,Math.max(0,l().length-1)))});const c=t=>e.isEnabled(t.command,t.payload),d=t=>{c(t)&&e.onExecute(t)},u=e=>{const t=l().length;0!==t&&a(n=>(n+e+t)%t)},p=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),u(1);break;case"ArrowUp":t.preventDefault(),u(-1);break;case"Enter":{t.preventDefault();const e=l()[r()];e&&d(e);break}case"Escape":t.preventDefault(),e.onClose()}};return X(Ft,{get when(){return e.isOpen},get children(){var u=mi(),g=u.firstChild;return s(u,"click",e.onClose,!0),g.$$keydown=p,g.$$click=e=>e.stopPropagation(),We(g,X(po,{id:"editor-command-search-input",get placeholder(){return t("commandSearch.placeholder")},get value(){return n()},onChange:e=>{o(e)},ref(e){"function"==typeof i?i(e):i=e},role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":"editor-command-search-listbox",get"aria-activedescendant"(){return et(()=>!!l()[r()])()?`editor-command-search-option-${r()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),We(g,X(ia,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),We(g,X(Ft,{get when(){return l().length>0},get fallback(){return X(ia,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=fi();return We(e,X(ee,{get each(){return l()},children:(e,t)=>{const n=()=>t()===r(),o=()=>c(e);return(i=bi()).$$click=()=>d(e),i.addEventListener("mouseenter",()=>{a(t())}),We(i,X(ia,{as:"span",get children(){return e.label}}),null),We(i,X(Ft,{get when(){return e.shortcut},get children(){var t=hi();return We(t,()=>e.shortcut),t}}),null),fe(r=>{var a=`editor-command-search-option-${t()}`,l=n(),s=!o()||void 0,c=!!n(),d=!o(),u=e.command;return a!==r.e&&le(i,"id",r.e=a),l!==r.t&&le(i,"aria-selected",r.t=l),s!==r.a&&le(i,"aria-disabled",r.a=s),c!==r.o&&i.classList.toggle("oasis-command-search-option-active",r.o=c),d!==r.i&&i.classList.toggle("oasis-command-search-option-disabled",r.i=d),u!==r.n&&le(i,"data-command",r.n=u),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i;var i}})),e}}),null),We(g,X(ht,{size:"sm",variant:"ghost",class:"oasis-command-search-close",get onClick(){return e.onClose},"data-testid":"editor-command-search-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),fe(()=>le(g,"aria-label",t("commandSearch.title"))),u}})}function vi(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function xi(e){return vi(e.command)}Ee(["click","keydown"]);var wi=/*#__PURE__*/f("<div class=oasis-quick-access role=region data-testid=editor-quick-access>"),Si=/*#__PURE__*/f("<button type=button class=oasis-editor-line-spacing-item role=menuitemcheckbox><span class=oasis-editor-line-spacing-item-check aria-hidden=true></span><span class=oasis-editor-line-spacing-item-label>");function Ci(e){const t=R(),n=vr(()=>{e.tick();const t={};for(const n of e.catalog)t[n.command]=e.canExecute(n.command);return t});return o=wi(),We(o,X(ee,{get each(){return e.catalog.filter(t=>e.visible().includes(t.command))},children:o=>X(dr,{get icon(){return o.icon},get tooltip(){return t(o.labelKey)},get"aria-label"(){return t(o.labelKey)},get"data-testid"(){return`editor-qat-${o.command}`},get disabled(){return!n()[o.command]},onClick:()=>e.onExecute(o.command)})}),null),We(o,X(Un,{icon:"chevron-down",testId:"editor-qat-customize",get tooltip(){return t("quickAccess.customize")},hideChevron:!0,panelClass:"oasis-quick-access-menu",get children(){return X(ee,{get each(){return e.catalog},children:n=>{const o=()=>e.visible().includes(n.command);return r=Si(),a=r.firstChild,i=a.nextSibling,r.$$click=()=>e.onToggle(n.command),We(a,X(Ft,{get when(){return o()},get children(){return X(v,{size:14})}})),We(i,()=>t(n.labelKey)),fe(e=>{var a=!!o(),i=o(),l=t(n.labelKey),s=`editor-qat-toggle-${n.command}`;return a!==e.e&&r.classList.toggle("oasis-editor-line-spacing-item-active",e.e=a),i!==e.t&&le(r,"aria-checked",e.t=i),l!==e.a&&le(r,"aria-label",e.a=l),s!==e.o&&le(r,"data-testid",e.o=s),e},{e:void 0,t:void 0,a:void 0,o:void 0}),r;var r,a,i}})}}),null),fe(()=>le(o,"aria-label",t("quickAccess.title"))),o;var o}Ee(["click"]);var Ii=/*#__PURE__*/f("<div class=oasis-chrome-strip data-testid=editor-chrome-strip>");function Ti(e){const t=R();return n=Ii(),We(n,X(Ci,{get catalog(){return e.catalog},get visible(){return e.visible},get onToggle(){return e.onToggle},get onExecute(){return e.onExecute},get canExecute(){return e.canExecute},get tick(){return e.tick}}),null),We(n,X(ia,{as:"span",class:"oasis-chrome-strip-spacer","aria-hidden":"true"}),null),We(n,X(dr,{icon:"search",get label(){return t("toolbar.tellMe")},wide:!0,get tooltip(){return`${t("toolbar.tellMe")} (Alt+Q)`},"data-testid":"editor-toolbar-tell-me",get onClick(){return e.onOpenCommandSearch}}),null),n;var n}var ki="oasis-quick-access-v1",Pi=["saveDocument","undo","redo","repeatLastAction"];function Ri(e){const t=new Set(e.map(e=>e.command)),n=function(){try{const e=globalThis.localStorage?.getItem(ki);if(!e)return[...Pi];const t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e):[...Pi]}catch{return[...Pi]}}().filter(e=>t.has(e)),o=n.length>0?[...n,...Pi.filter(e=>t.has(e)&&!n.includes(e))]:[...Pi],[r,a]=an(o);return we(()=>{!function(e){try{globalThis.localStorage?.setItem(ki,JSON.stringify(e))}catch{}}(r())}),{catalog:e,visible:r,isShown:e=>r().includes(e),toggle:e=>{t.has(e)&&a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}}}var Bi=[{command:"saveDocument",icon:"save",labelKey:"generic.save"},{command:"undo",icon:"undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z"},{command:"redo",icon:"redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y"},{command:"repeatLastAction",icon:"repeat",labelKey:"quickAccess.repeat",shortcut:"F4"},{command:"find",icon:"search",labelKey:"find.title",shortcut:"Ctrl+F"},{command:"print",icon:"printer",labelKey:"menu.file.print",shortcut:"Ctrl+P"},{command:"exportDocx",icon:"file-text",labelKey:"toolbar.exportDocx"},{command:"exportPdf",icon:"file-down",labelKey:"toolbar.exportPdf"},{command:"toggleTrackChanges",icon:"file-check",labelKey:"toolbar.trackChanges"},{command:"toggleRevisionMarkup",icon:"highlighter",labelKey:"toolbar.revisionMarkup"},{command:"toggleCommentsPanel",icon:"list-filter",labelKey:"review.commentsPanel"},{command:"toggleRevisionsPanel",icon:"list-checks",labelKey:"toolbar.revisionsPanel"},{command:"toggleOutlinePanel",icon:"list",labelKey:"menu.view.outline"},{command:"togglePreciseFonts",icon:"type",labelKey:"menu.view.preciseFonts"},{command:"toggleShowParagraphMarks",icon:"pilcrow",labelKey:"menu.view.paragraphMarks"},{command:"toggleShowMargins",icon:"scan",labelKey:"menu.view.margins"}],Ai=!1,Mi=null,Fi=null,Oi=null,Di=[];function Ei(){"undefined"!=typeof window&&(!function(){const e={BASE_URL:"./",DEV:!1,MODE:"lib",PROD:!0,SSR:!1},t=globalThis.process?.env??{};return!0===e.DEV||"test"===e.MODE||"test"===t.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?Ai&&(delete window.__oasisCanvasDebug,Ai=!1):Ai||(window.__oasisCanvasDebug={getLastHit:()=>Mi?{...Mi}:null,getLayoutSnapshot:()=>Fi?{...Fi,surfaceRect:{...Fi.surfaceRect},pages:Fi.pages.map(e=>({...e})),paragraphs:Fi.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:Fi.inlineImages.map(e=>({...e})),inlineTextBoxes:Fi.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:Fi.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Oi?{anchor:{...Oi.anchor},focus:{...Oi.focus},activeZone:Oi.activeZone,activeSectionIndex:Oi.activeSectionIndex}:null,getMissEvents:()=>Di.map(e=>({...e})),clearMissEvents:()=>{Di=[]}},Ai=!0))}function Li(e){Ai&&e&&(Mi={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Ni=["Aptos, sans-serif","Aptos Display, sans-serif","Arial","Arial Black","Bahnschrift, sans-serif","Book Antiqua, serif","Calibri, sans-serif","Calibri Light, sans-serif","Cambria, serif","Candara, sans-serif","Century Gothic, sans-serif","Comic Sans MS","Consolas, monospace","Constantia, serif","Corbel, sans-serif","Courier New","Franklin Gothic Medium, sans-serif","Garamond, serif","Georgia","Gill Sans, sans-serif","Helvetica, sans-serif","Impact","Inter","Lucida Console, monospace","Lucida Sans Unicode, sans-serif","Open Sans, sans-serif","Palatino Linotype, serif","Segoe UI, sans-serif","Tahoma, sans-serif","Times New Roman","Trebuchet MS, sans-serif","Verdana, sans-serif","Wingdings"];function $i(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function zi(e){return function(e){const[t,n]=an([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))$i(r,o,i.textStyle?.fontFamily);$i(r,o,t.fontFamily);for(const i of n)$i(a,o,i);for(const i of Ni)$i(a,o,i);return[...r.sort((e,t)=>e.localeCompare(t)),...a.sort((e,t)=>e.localeCompare(t))]}(e.state().document,e.toolbarStyleState(),t()),r=()=>function(e,t){const n=new Set(qo);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(xo(e))}const o=xo(Number(t.fontSize));return Number.isFinite(o)&&o>0&&n.add(o),Array.from(n).sort((e,t)=>e-t)}(e.state().document,e.toolbarStyleState());return{computeFontFamilyOptions:o,computeFontSizeOptions:r,loadLocalFontFamilyOptions:async()=>{if(t().length>0)return;const e=await $t();e.length>0&&n(e)}}}(e)}var Hi="insertText",Wi="composition",Ui="insertImage",ji="insertTable",Vi="moveImage",Ki="splitListItem",_i="link",Xi="imageAlt",Gi="imageCaption",qi="imageResize",Yi="imageCrop",Zi="imageFlip",Ji="imageRotate",Qi="imageTransparency",el="imageReset",tl="layoutWrapPolygon",nl="specialIndent",ol="paraBorders",rl="paragraphMoveUp",al="paragraphMoveDown",il="findReplace",ll="findReplaceAll",sl="tableProperties",cl="paragraph-dialog",dl="font-dialog",ul="copyTextByDrag",pl="moveTextByDrag",gl="collapseSelectionByClick",fl="mergeTable",ml="splitTable",hl="insertTableColumn",bl="deleteTableColumn",yl="insertTableRow",vl="deleteTableRow",xl="tableShading",wl="tableBorders",Sl="tableWidth",Cl="tableAlign",Il="tableCellAlignment",Tl="tableCellVerticalAlign",kl="tableCellTextDirection",Pl="tableCellWidth",Rl="tableColumnWidth",Bl="tableToText",Al="textToTable",Ml="tableSplitAtRow",Fl="tableSortAscending",Ol="tableSortDescending",Dl="tableDelete",El="deleteTableCell",Ll="tableAutoFit",Nl="tableRepeatHeaderRows",$l="tableCellMargins",zl="tableFormula",Hl="tableRowHeight",Wl="tableStyleOptions",Ul="tableStyleGallery",jl="tableDistribute",Vl="layoutWrapPreset",Kl="layoutFixedPosition",_l="shapeFill",Xl="shapeOutline",Gl="shapeOutlineWidth",ql="floatingAlign",Yl="floatingReorder",Zl="floatingNudge",Jl="floatingFixedPosition",Ql="floatingRotation",es="floatingWrap",ts="floatingWrapText",ns="floatingPositionPreset",os="shapePreset",rs="textBoxTextDirection",as="textBoxVerticalAlign",is="textBoxAlt",ls="textBoxRotate",ss="textBoxWidthCm",cs="textBoxHeightCm";function ds(e,t){const n={...e},o=(e,t)=>{null==t?delete n[e]:n[e]=t};return o("align",t.align),o("indentLeft",t.indentLeft),o("indentRight",t.indentRight),o("indentFirstLine",t.indentFirstLine),o("indentHanging",t.indentHanging),n.mirrorIndents=t.mirrorIndents,o("spacingBefore",t.spacingBefore),o("spacingAfter",t.spacingAfter),o("lineHeight",t.lineHeight),o("lineRule",t.lineRule),n.contextualSpacing=t.contextualSpacing,o("outlineLevel",t.outlineLevel),o("shading",t.shading),o("borderTop",t.borders.top),o("borderRight",t.borders.right),o("borderBottom",t.borders.bottom),o("borderLeft",t.borders.left),n.pageBreakBefore=t.pageBreakBefore,n.keepWithNext=t.keepWithNext,n.keepLinesTogether=t.keepLinesTogether,n.widowControl=t.widowControl,o("tabs",t.tabs.length>0?t.tabs:null),n}function us(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function ps(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function gs(e,t){const n=Fe(e.document).map(e=>({...e,blocks:t(e.blocks),header:e.header?t(e.header):void 0,firstPageHeader:e.firstPageHeader?t(e.firstPageHeader):void 0,evenPageHeader:e.evenPageHeader?t(e.evenPageHeader):void 0,footer:e.footer?t(e.footer):void 0,firstPageFooter:e.firstPageFooter?t(e.firstPageFooter):void 0,evenPageFooter:e.evenPageFooter?t(e.evenPageFooter):void 0})),o=e.document.footnotes?{...e.document.footnotes,items:Object.fromEntries(Object.entries(e.document.footnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0,r=e.document.endnotes?{...e.document.endnotes,items:Object.fromEntries(Object.entries(e.document.endnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0;return{...e,document:{...e.document,sections:n,footnotes:o,endnotes:r}}}function fs(e,t){return e.map(e=>{if("paragraph"===e.type)return e;const n=t(e);return{...n,rows:n.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:fs(e.blocks,t)}))}))}})}function ms(e,t,n){const o=Fe(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function hs(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function bs(e){const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:hs(n)}:null}function ys(e,t,n){const o=t[0];if(!o)return e;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return e;if(1===t.length){const t=n(r);if(t===r)return e;const a=[...e];return a[o.tableBlockIndex]=t,a}const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return e;const l=ys(i.blocks,t.slice(1),n);if(l===i.blocks)return e;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function vs(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function xs(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?vs(e.firstPageHeader,n)?"firstPage":vs(e.evenPageHeader,n)?"evenPage":"default":vs(e.firstPageFooter,n)?"firstPage":vs(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[Rn(t,o)]??null}return null}function ws(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?vs(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:vs(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?vs(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:vs(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function Ss(e,t){const n=t[0];if(!n||!e)return null;const o=e[n.tableBlockIndex];if(!o||"table"!==o.type)return null;if(1===t.length)return o;const r=o.rows[n.rowIndex],a=r?.cells[n.cellIndex];return r&&a?Ss(a.blocks,t.slice(1)):null}function Cs(e,t,n){const o=t[0];if(!o)return null;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return null;if(1===t.length)return[...e.slice(0,o.tableBlockIndex),...n,...e.slice(o.tableBlockIndex+1)];const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return null;const l=Cs(i.blocks,t.slice(1),n);if(!l)return null;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function Is(e){const t=bs(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return ks(e,r);const a=Fe(e.document)[n];return a?xs(a,o.zone,r):null}function Ts(e){const t=e.selection.focus.paragraphId,n=io(e);if("footnote"===n)return ks(e,t);const o=fo(e),r=Fe(e.document)[o];return r?xs(r,n,t):null}function ks(e,t){const n=Jr(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function Ps(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>Cs(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Jr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Fe(e.document).map((e,t)=>t===o?ws(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function Rs(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>ys(e,r.tablePath,t);if("footnote"===r.zone){const t=Jr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Fe(e.document).map((e,t)=>t===o?ws(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var Bs={width:.5,type:"solid",color:"#000000"},As={width:0,type:"none",color:"transparent"};function Ms(e){const t=fo(e),n=F(e.document,e.selection.anchor.paragraphId,t),o=F(e.document,e.selection.focus.paragraphId,t);if(!n||!o||n.zone!==o.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(n.tablePath,o.tablePath))return null;const r=ms(e.document,t,n.zone);if(!r)return null;const a=i(r,n.tablePath),l=i(r,o.tablePath),s=a?.[a.length-1],c=l?.[l.length-1];if(!s||!c||s.table!==c.table)return null;const d=n.tablePath[n.tablePath.length-1],u=o.tablePath[o.tablePath.length-1];if(!d||!u)return null;const p=ln(s.table),g=p.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex),f=p.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex);if(!g||!f)return null;const m=Math.min(g.visualRowIndex,f.visualRowIndex),h=Math.max(g.visualRowIndex+g.rowSpan-1,f.visualRowIndex+f.rowSpan-1),b=Math.min(g.visualColumnIndex,f.visualColumnIndex),y=Math.max(g.visualColumnIndex+g.colSpan-1,f.visualColumnIndex+f.colSpan-1);return{entries:p,selectedEntries:p.filter(e=>e.visualRowIndex<=h&&e.visualRowIndex+e.rowSpan-1>=m&&e.visualColumnIndex<=y&&e.visualColumnIndex+e.colSpan-1>=b),startRow:m,endRow:h,startCol:b,endCol:y}}function Fs(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=Ms(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of Po(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=Wn(e),o=Kr(e);for(let r=n.startIndex;r<=n.endIndex;r+=1)t.add(o[r].id);return t}(e))o.add(i);const r=o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...us(),type:"property",previous:{...r??{}}}}),{...o,style:ps(r,t,n)}},a=Fe(e.document).map(e=>({...e,blocks:ya(e.blocks,o,r),header:e.header?ya(e.header,o,r):void 0,footer:e.footer?ya(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function Os(e,t){let n=Fs(e,"borderTop",t);return n=Fs(n,"borderRight",t),n=Fs(n,"borderBottom",t),n=Fs(n,"borderLeft",t),n}function Ds(e,t,n){const o=function(e){const t=Wn(e),n=Kr(e),o=/* @__PURE__ */new Set;for(let r=t.startIndex;r<=t.endIndex;r+=1)o.add(n[r].id);return o}(e),r=a=>a.map(a=>{if("paragraph"===a.type)return a;const i=a.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:r(e.blocks)}))})),l={...a,rows:i};return function(e,t){return e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>"paragraph"===e.type&&t.has(e.id))))}(a,o)?(o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&!r?.revision&&(r={...r??{},revision:{...us(),type:"property",previous:{...r??{}}}}),{...o,style:ps(r,t,n)}})(l):l});return gs(e,r)}function Es(e,t,n,o){const r=r=>{if(r.id!==t)return r;let a=r.style;return e.trackChangesEnabled&&"revision"!==n&&!a?.revision&&(a={...a??{},revision:{...us(),type:"property",previous:{...a??{}}}}),{...r,style:ps(a,n,o)}};return gs(e,e=>fs(e,r))}function Ls(e,t,n){const o=bs(e);if(!o)return e;return Rs(e,r=>{const a=r.rows.map((r,a)=>a===o.loc.rowIndex?(()=>{let o=r.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...us(),type:"property",previous:{...o??{}}}}),{...r,style:ps(o,t,n)}})():r);return{...r,rows:a}})}function Ns(e,t){const n=bs(e);if(!n)return e;return Rs(e,o=>({...o,rows:o.rows.map((o,r)=>{if(r!==n.loc.rowIndex)return o;let a=o.style;e.trackChangesEnabled&&!a?.propertyRevision&&(a={...a??{},propertyRevision:{...us(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:ps(a,"isHeader",i??null)}})}))}function $s(e,t,n){const o=o=>{if(o.id!==t)return o;const r=o.rows.map((t,o)=>{if(!Object.prototype.hasOwnProperty.call(n,o))return t;let r=t.style;return e.trackChangesEnabled&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...us(),type:"property",previous:{...r??{}}}}),{...t,style:ps(r,"height",n[o])}});return{...o,rows:r}};return gs(e,e=>fs(e,o))}function zs(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"!=typeof e)return null;const t=e.trim().toLowerCase();if(!t||t.includes("%"))return null;if(t.endsWith("pt")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}if(t.endsWith("px")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e*ar:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Hs(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=ln(a),l=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),s=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(s);let d=!1,u=!0;for(let e=0;e<s;e+=1){const t=zs(n[e]);if(null!==t){c[e]=Math.max(1,t),d=!0;continue}const o=a.gridCols?.[e];if(!("number"==typeof o&&Number.isFinite(o)&&o>0)){u=!1;break}c[e]=o}const p=a.rows.map((t,o)=>{const r=t.cells.map((t,r)=>{const a=l.get(`${o}:${r}`);if(!a)return t;const i=n[a.visualColumnIndex+a.colSpan-1];if(void 0!==i&&1===a.colSpan){const n=e.trackChangesEnabled&&!t.style?.propertyRevision?{...us(),type:"property",previous:{...t.style??{}}}:t.style?.propertyRevision;return{...t,style:{...t.style??{},width:i,...n?{propertyRevision:n}:{}}}}return t});return{...t,cells:r}}),g={...a.style??{}};return!e.trackChangesEnabled||g.revision||void 0===o&&void 0===r||(g.revision={...us(),type:"property",previous:{...a.style??{}}}),void 0!==o&&(g.width=o),void 0!==r&&(g.indentLeft="number"==typeof r?r:Number(r)),{...a,rows:p,gridCols:d&&u?c:a.gridCols,gridRevision:e.trackChangesEnabled&&d&&u&&!a.gridRevision?{...us(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return gs(e,e=>fs(e,a))}function Ws(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=function(e){const t=[];for(const n of e.rows)for(const e of n.cells)for(const n of e.blocks)"paragraph"===n.type&&t.push(pn(n));return t}(o);if(0===r.length)return e;const a=Ps(e,r);if(a===e)return e;const i=r[0];return{...a,selection:oe(Z(i,0))}}function Us(e){if(bs(e))return e;if(!Ts(e))return e;const t=Kr(e);if(0===t.length)return e;const n=Wn(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(js),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>ma(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:no("paragraph"),type:"paragraph",runs:o.length>0?o:[bo("")]};return Gr([r])})));return bn(o)}(o),a=o[0].id,i=o[o.length-1].id;let l=null,s=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=io(e),r=fo(e);if("footnote"===o){const o=Jr(e.document,n)?.footnoteId??e.activeFootnoteId,r=e.document.footnotes,a=o?r?.items[o]:void 0;return o&&r&&a?{...e,document:{...e.document,footnotes:{...r,items:{...r.items,[o]:{...a,blocks:t(a.blocks)}}}}}:e}const a=Fe(e.document).map((e,a)=>a===r?ws(e,o,n,t):e);return{...e,document:{...e.document,sections:a}}}(e,e=>{const{nextBlocks:t,cell:n}=function(e,t,n,o){let r=-1,a=-1;for(let l=0;l<e.length;l+=1){const o=e[l];"paragraph"===o.type&&(o.id===t&&(r=l),o.id===n&&(a=l))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let l=r;l<=a;l+=1)if("paragraph"!==e[l].type)return{nextBlocks:null,cell:null};const i=o.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return{nextBlocks:[...e.slice(0,r),o,...e.slice(a+1)],cell:i??null}}(e,a,i,r);return t&&n?(l=n,s=!0,t):e});return s&&l?{...c,selection:oe(Z(l,0))}:e}function js(e){const t=[];let n=[];const o=()=>{n.length>0&&t.push(n),n=[]};for(const r of e.runs){const e=r.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&o();const a=e[t];if(a.length>0){const e=Gn(r);e.id=`run:${Math.random().toString(36).slice(2,9)}`,e.text=a,n.push(e)}}}return n.length>0&&t.push(n),t}function Vs(e,t){const n=bs(e);if(!n)return e;const o=n.loc.cellIndex;return Rs(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const s of e.rows)s.isHeader?o.push(s):r.push(s);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=Ks(e.cells[t]),r=Ks(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),l=[...o,...i];return l.length===e.rows.length&&l.every((t,n)=>t===e.rows[n])?e.rows:l}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function Ks(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function _s(e){return!0===e.isHeader}function Xs(e){return null!==bs(e)}function Gs(e){return null!==bs(e)}var qs=/* @__PURE__ */new Set(["left","center","right"]);function Ys(e,t){const n=bs(e);if(!n)return e;if(null!==t&&!qs.has(t))return e;const o=function(e,t){const n=bs(e);if(!n)return null;const o=i(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,ms(e.document,n.activeSectionIndex,n.loc.zone)??[]);if(!o)return e;const r=o.style?.align,a=null===t?void 0:t;return r===a?e:Ds(e,"align",a)}function Zs(e){return null!==bs(e)}var Js=["SUM","AVERAGE","COUNT","MIN","MAX"];function Qs(e,t){const n=function(e){const t=/^\s*=\s*([A-Z]+)\s*\(\s*([A-Z]+)\s*\)\s*$/i.exec(e);if(!t)return null;const n=t[1].toUpperCase(),o=t[2].toUpperCase();return Js.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=bs(e);if(!o)return e;const r=Is(e);if(!r)return e;const a=Ss(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=ln(e),r=o.find(e=>e.rowIndex===n.rowIndex&&e.cellIndex===n.cellIndex);if(!r)return[];const a=[];for(const i of o){if(i.rowIndex===n.rowIndex&&i.cellIndex===n.cellIndex)continue;if(!tc(r,i,t))continue;if(!nc(r,i,t))continue;const e=oc(ec(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const l=function(e){if(Number.isInteger(e)||!Number.isFinite(e))return String(e);const t=Math.round(1e6*e)/1e6;return String(t)}(function(e,t){switch(e){case"SUM":return t.reduce((e,t)=>e+t,0);case"AVERAGE":return t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0;case"COUNT":return t.length;case"MIN":return t.length>0?Math.min(...t):0;case"MAX":return t.length>0?Math.max(...t):0}}(n.function,i)),s=o.loc.rowIndex,c=o.loc.cellIndex,d=Rs(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[pr(l)]})})}));if(d===e)return e;const u=pr(l);return{...d,selection:oe(Z(u,l.length))}}function ec(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function tc(e,t,n){if("LEFT"===n||"RIGHT"===n){const n=e.visualRowIndex+e.rowSpan,o=t.visualRowIndex+t.rowSpan;return e.visualRowIndex<o&&t.visualRowIndex<n}const o=e.visualColumnIndex+e.colSpan,r=t.visualColumnIndex+t.colSpan;return e.visualColumnIndex<r&&t.visualColumnIndex<o}function nc(e,t,n){switch(n){case"ABOVE":return t.visualRowIndex+t.rowSpan<=e.visualRowIndex;case"BELOW":return t.visualRowIndex>=e.visualRowIndex+e.rowSpan;case"LEFT":return t.visualColumnIndex+t.colSpan<=e.visualColumnIndex;case"RIGHT":return t.visualColumnIndex>=e.visualColumnIndex+e.colSpan}}function oc(e){const t=/\d+(?:[.,]\d+)?/.exec(e);if(!t)return null;const n=t[0].replace(",","."),o=Number(n);return Number.isFinite(o)?o:null}function rc(e,t){const n=function(e){const t=bs(e);if(!t)return null;const n=Is(e);if(!n)return null;const o=Ss(n,t.loc.tablePath);if(!o)return null;const r=ln(o),a=r.find(e=>e.rowIndex===t.loc.rowIndex&&e.cellIndex===t.loc.cellIndex);return a?{table:o,entries:r,active:a}:null}(e);if(!n)return e;const{table:o,entries:r,active:a}=n,i=function(e,t,n,o){switch(o){case"cell":return[n];case"row":{const e=n.visualRowIndex,o=n.visualRowIndex+n.rowSpan;return t.filter(t=>{const n=t.visualRowIndex,r=t.visualRowIndex+t.rowSpan;return n<o&&e<r})}case"column":{const e=n.visualColumnIndex,o=n.visualColumnIndex+n.colSpan;return t.filter(t=>{const n=t.visualColumnIndex,r=t.visualColumnIndex+t.colSpan;return n<o&&e<r})}case"table":return[...t]}}(0,r,a,t);if(0===i.length)return e;const l=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),s=l[0].cell,c=l[l.length-1].cell,d=ac(s),u=ac(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:Z(p,0),focus:Z(g,Lt(g).length)}}:e}function ac(e){return e.blocks.flatMap(Po)}function ic(e){const t=function(e){const t=bs(e);if(!t)return null;const n=Is(e);if(!n)return null;const o=Ss(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function lc(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex,a=t.loc.cellIndex,i=o.rows[r];if(!i||i.cells.length<=1||a>=i.cells.length)return e;const l=Rs(e,e=>{const t=e.rows.map((e,t)=>{if(t!==r)return e;const n=e.cells.filter((e,t)=>t!==a);return{...e,cells:n}});return{...e,rows:t}});if(l===e)return e;const s=i.cells[Math.min(a,i.cells.length-2)],c=s?s.blocks.flatMap(Po)[0]??null:null;return c?{...l,selection:oe(Z(c,0))}:l}var sc={activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""};function cc(e){const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=i(function(e,t){const n=Fe(e.document)[fo(e)];return n?"header"===t?n.header??[]:"footer"===t?n.footer??[]:n.blocks:[]}(e,n.zone),n.tablePath),a=r?.[r.length-1]?.table;if(!a)return null;const l=ln(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:l?.visualColumnIndex??o.cellIndex}}function dc(e){if("number"==typeof e&&Number.isFinite(e))return{value:String(e),unit:"points"};if("string"==typeof e){const t=e.trim();if(t.endsWith("%"))return{value:t.slice(0,-1),unit:"percent"};const n=t.match(/^([0-9.]+)(pt)?$/i);if(n?.[1])return{value:n[1],unit:"points"}}return{value:"",unit:"points"}}function uc(e){return!!e&&"none"!==e.type&&e.width>0}function pc(e,t="table"){const n=dc(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=dc(o?.style?.height),i=dc(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=dc(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(uc)[0],u=function(e){const t=e.style?.floating;return t&&0!==Object.keys(t).length?Object.entries(t).map(([e,t])=>`${e}=${t}`).join(", "):""}(e.table);return{...sc,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:dc(e.table.style?.indentLeft).value,tableWrapping:u?"around":"none",floatingSummary:u,floatingHorizontalAnchor:e.table.style?.floating?.horizontalAnchor??"margin",floatingVerticalAnchor:e.table.style?.floating?.verticalAnchor??"text",floatingX:null!=e.table.style?.floating?.x?String(e.table.style.floating.x):"0",floatingY:null!=e.table.style?.floating?.y?String(e.table.style.floating.y):"0",floatingXAlign:e.table.style?.floating?.xAlign??"",floatingYAlign:e.table.style?.floating?.yAlign??"",floatingDistanceTop:String(e.table.style?.floating?.distanceTop??0),floatingDistanceRight:String(e.table.style?.floating?.distanceRight??0),floatingDistanceBottom:String(e.table.style?.floating?.distanceBottom??0),floatingDistanceLeft:String(e.table.style?.floating?.distanceLeft??0),floatingOverlap:e.table.style?.tblOverlap??"overlap",rowHeight:a.value,rowHeightRule:o?.style?.heightRule??"",repeatHeader:Boolean(o?.isHeader),allowBreakAcrossPages:!0!==o?.style?.cantSplit,hiddenRow:!0===o?.style?.hidden,columnWidth:s.value,cellWidth:i.value,cellVerticalAlign:c.verticalAlign??"",cellTextDirection:c.textDirection??"",cellNoWrap:!0===c.noWrap,cellFitText:!0===c.fitText,cellHideMark:!0===c.hideMark,marginTop:null!=c.paddingTop?String(c.paddingTop):"",marginRight:null!=c.paddingRight?String(c.paddingRight):"",marginBottom:null!=c.paddingBottom?String(c.paddingBottom):"",marginLeft:null!=c.paddingLeft?String(c.paddingLeft):"",borderStyle:d?.type??"none",borderWidth:d?String(d.width):"",borderColor:d?.color??"",borderTop:uc(c.borderTop),borderRight:uc(c.borderRight),borderBottom:uc(c.borderBottom),borderLeft:uc(c.borderLeft),borderStart:uc(c.borderStart),borderEnd:uc(c.borderEnd),borderTopLeftToBottomRight:uc(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:uc(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function gc(e,t,n){return Fs(e,t,n)}function fc(e){return Boolean(cc(e))}function mc(e,t="table"){const n=cc(e);return n?pc(n,t):null}function hc(e){const t=()=>fc(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=mc(e.state(),t);n&&(e.setContextMenu({isOpen:!1,x:0,y:0}),e.setTablePropertiesDialog({isOpen:!0,initial:n}))},applyTablePropertiesDialogValues:n=>{e.isReadOnly()||t()&&(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>function(e,t){const n=cc(e);if(!n)return e;let o=e;return o=Es(o,n.tableId,"width",t.tableWidth),o=Es(o,n.tableId,"align",t.tableAlign),o=Es(o,n.tableId,"indentLeft",t.tableIndentLeft),o=Es(o,n.tableId,"floating",t.tableFloating),o=Es(o,n.tableId,"tblOverlap",t.tableOverlap),o=Es(o,n.tableId,"altTitle",t.altTitle),o=Es(o,n.tableId,"altDescription",t.altDescription),o=Ns(o,t.repeatHeader),o=Ls(o,"height",t.rowHeight),o=Ls(o,"heightRule",t.rowHeightRule),o=Ls(o,"cantSplit",t.cantSplit),o=Ls(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Hs(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=gc(o,"width",t.cellWidth),o=gc(o,"verticalAlign",t.cellVerticalAlign),o=gc(o,"textDirection",t.cellTextDirection),o=gc(o,"noWrap",t.cellNoWrap),o=gc(o,"fitText",t.cellFitText),o=gc(o,"hideMark",t.cellHideMark),o=gc(o,"paddingTop",t.margins.top),o=gc(o,"paddingRight",t.margins.right),o=gc(o,"paddingBottom",t.margins.bottom),o=gc(o,"paddingLeft",t.margins.left),o=gc(o,"borderTop",t.borders.top),o=gc(o,"borderRight",t.borders.right),o=gc(o,"borderBottom",t.borders.bottom),o=gc(o,"borderLeft",t.borders.left),o=gc(o,"borderStart",t.borders.start),o=gc(o,"borderEnd",t.borders.end),o=gc(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=gc(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=gc(o,"shading",t.shading),o}(e,n),{mergeKey:sl}),e.focusInput())}}}function bc(e){return function(e){const t=e.t,n=e.clipboardActions??li({...e,onIssue:t=>e.logger.warn("contextMenu:clipboard:not-completed",{issue:t})}),o=n.copy,r=n.cut,a=()=>n.paste("rich"),i=()=>{const n=!zr(e.state().selection),i=e.isReadOnly(),l=[{id:"cut",label:t("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!n,testId:"editor-context-menu-cut",onSelect:()=>{r()}},{id:"copy",label:t("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!n,testId:"editor-context-menu-copy",onSelect:()=>{o()}},{id:"paste",label:t("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{a()}},{id:"sep1",type:"separator"},{id:"link",label:t("contextmenu.link"),icon:"link",disabled:i||!n,testId:"editor-context-menu-link",onSelect:e.promptForLink},{id:"font",label:t("contextmenu.font"),icon:"type",disabled:i||!n,testId:"editor-context-menu-font",onSelect:e.openFontDialog},{id:"paragraph",label:t("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:e.openParagraphDialog}],s=e.table;return s?.isInsideTable()&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:t("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},l=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},s=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:i,closeContextMenu:s,handleEditorContextMenu:l,programmaticCopy:o,programmaticCut:r,programmaticPaste:a}}(e)}function yc(e){const{state:t,tableOps:n,applyTableContextCommand:o}=e;return{isInsideTable:e.isInsideTable,canMerge:()=>n.canMergeSelectedTable(t()),canSplit:()=>n.canSplitSelectedTable(t()),canEditColumn:()=>n.canEditSelectedTableColumn(t()),canEditRow:()=>n.canEditSelectedTableRow(t()),openProperties:()=>e.openTablePropertiesDialog("table"),openBordersAndShading:()=>e.openTablePropertiesDialog("cell"),merge:()=>o(e=>n.mergeSelectedTable(e),fl),split:()=>o(e=>n.splitSelectedTable(e),ml),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),hl),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),hl),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),bl),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),yl),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),yl),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),vl)}}function vc(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=zi({state:e.state,toolbarStyleState:e.toolbarStyleState}),r=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:xn(t.fontSize),color:t.color??"",colorMode:t.color?"custom":"automatic",highlight:t.highlight??"",shading:t.textShading??"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underlineStyle?t.underlineStyle:null,underlineColor:t.underlineColor??"",strike:Boolean(t.strike),doubleStrike:Boolean(t.doubleStrike),superscript:Boolean(t.superscript),subscript:Boolean(t.subscript),smallCaps:Boolean(t.smallCaps),allCaps:Boolean(t.allCaps),hidden:Boolean(t.hidden),characterScale:t.characterScale??"",characterSpacing:t.characterSpacing??"",baselineShift:t.baselineShift??"",kerningThreshold:t.kerningThreshold??"",ligatures:t.ligatures??"",numberSpacing:t.numberSpacing??"",numberForm:t.numberForm??"",stylisticSet:t.stylisticSet??"",contextualAlternates:Boolean(t.contextualAlternates)})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(t,n)=>{e.isReadOnly()||(zr(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=_a(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=_a(o,"fontSize",kr(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=_a(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=_a(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=_a(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=Ka(o,"bold")),t.italic!==Boolean(n.italic)&&(o=Ka(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=_a(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=_a(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=Ka(o,"underline")),t.strike!==Boolean(n.strike)&&(o=Ka(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=Ka(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=Ka(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=Ka(o,"subscript")),t.superscript&&t.subscript&&(o=Ka(o,"subscript")),t.strike&&t.doubleStrike&&(o=Ka(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=Ka(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=Ka(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=Ka(o,"hidden"));const l=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(l??null)&&(o=_a(o,"characterScale",t.characterScale));const s=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(s??null)&&(o=_a(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=_a(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=_a(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=_a(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=_a(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=_a(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=_a(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=Ka(o,"contextualAlternates")),o},{mergeKey:dl})),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,selection:e.selection,isReadOnly:e.isReadOnly,loadLocalFontFamilyOptions:o,setFontDialog:e.setFontDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),a=r.openFontDialog,i=function(e){return{openParagraphDialog:()=>{var t;e.setParagraphDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{align:t.align??"",indentLeft:t.indentLeft??"",indentRight:t.indentRight??"",indentFirstLine:t.indentFirstLine??"",indentHanging:t.indentHanging??"",mirrorIndents:t.mirrorIndents??!1,spacingBefore:t.spacingBefore??"",spacingAfter:t.spacingAfter??"",lineHeight:t.lineHeight??"",lineRule:t.lineRule??"",contextualSpacing:t.contextualSpacing??!1,outlineLevel:t.outlineLevel??"",shading:t.shading??"",borderStyle:t.borderStyle??"",borderWidth:t.borderWidth??"",borderColor:t.borderColor??"",borderSideTop:t.borderSideTop??!1,borderSideRight:t.borderSideRight??!1,borderSideBottom:t.borderSideBottom??!1,borderSideLeft:t.borderSideLeft??!1,pageBreakBefore:t.pageBreakBefore??!1,keepWithNext:t.keepWithNext??!1,keepLinesTogether:t.keepLinesTogether??!1,widowControl:t.widowControl??!0,tabs:t.tabs??[]})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(t,n)=>{if(e.isReadOnly())return;e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e=>{if(""===e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null};e.applyTransactionalState(e=>{let r=e;t.align!==(n.align||null)&&(r=Ve(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=Ve(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=Ve(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=Ve(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=Ve(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=Ve(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=Ve(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=Ve(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=Ve(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=Ve(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=Ve(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=Ve(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=Ve(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=Ve(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=Ve(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=Ve(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=Ve(r,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=Ve(r,"tabs",t.tabs.length>0?t.tabs:null));const l="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,s={borderTop:n.borderSideTop?l:null,borderRight:n.borderSideRight?l:null,borderBottom:n.borderSideBottom?l:null,borderLeft:n.borderSideLeft?l:null},c={borderTop:t.borders.top,borderRight:t.borders.right,borderBottom:t.borders.bottom,borderLeft:t.borders.left};for(const t of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(c[t])!==JSON.stringify(s[t])&&(r=Ve(r,t,c[t]));return r},{mergeKey:cl}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=z(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:ds(r.paragraphStyle??{},t)}}}}}),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,isReadOnly:e.isReadOnly,setParagraphDialog:e.setParagraphDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),l=i.openParagraphDialog,s=hc({state:e.state,isReadOnly:e.isReadOnly,setTablePropertiesDialog:e.setTablePropertiesDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),c=s.openTablePropertiesDialog,d=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},u=bc({clipboardActions:e.clipboardActions,state:e.state,isReadOnly:e.isReadOnly,t:e.t,logger:e.logger,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.applyTableAwareParagraphEdit,focusInput:e.focusInput,promptForLink:e.promptForLink,openFontDialog:a,openParagraphDialog:l,table:yc({state:e.state,tableOps:e.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function xc(e){const t=vr(()=>{const t=e.targetPos(),n=e.surfaceRef;if(!n)return null;const o=e.snapshotProvider.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});let r=0,a=0,i=28;if(o){const n=Kr(e.state).find(e=>e.id===t.paragraphId),r=n?Bt(n,t):0,a=mo(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=mn(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const l=e.caretViewport?.()??null;if(l)return r=l.left,a=l.top,i=Math.max(12,Math.min(36,l.height)),{viewportLeft:r,viewportTop:a,height:i};const s=e.pointerPos?.()??null;return s?(r=s.x,a=s.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return X(Ft,{get when(){return t()},children:e=>X(H,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var wc=/*#__PURE__*/f("<div class=oasis-editor-table-resize-guide>"),Sc=/*#__PURE__*/f("<div class=oasis-editor-table-resize-outline>"),Cc=/*#__PURE__*/f("<img class=oasis-editor-image-ghost>"),Ic=/*#__PURE__*/f("<div class=oasis-editor-table-ghost>");function Tc(e){return[X(Ft,{get when(){return e.tableResize.resizing()},children:e=>{return t=wc(),fe(n=>{var o=!("column"!==e().type),r=!("row"!==e().type),a={..."column"===e().type?{left:`${e().currentPos}px`,top:`${e().guideBounds.top}px`,width:"0px",height:`${e().guideBounds.height}px`}:{left:`${e().guideBounds.left}px`,top:`${e().currentPos}px`,width:`${e().guideBounds.width}px`,height:"0px"}};return o!==n.e&&t.classList.toggle("oasis-editor-table-resize-guide-column",n.e=o),r!==n.t&&t.classList.toggle("oasis-editor-table-resize-guide-row",n.t=r),n.a=Sa(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),X(Ft,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Sc(),fe(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&Re(t,"left",n.e=o),r!==n.t&&Re(t,"top",n.t=r),a!==n.a&&Re(t,"width",n.a=a),i!==n.o&&Re(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),X(Ft,{get when(){return et(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=Cc(),fe(o=>{var r=t().src,a=`${t().width}px`,i=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",s=e.imageOps.mousePos().y-t().offsetY+"px";return r!==o.e&&le(n,"src",o.e=r),a!==o.t&&Re(n,"width",o.t=a),i!==o.a&&Re(n,"height",o.a=i),l!==o.o&&Re(n,"left",o.o=l),s!==o.i&&Re(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),X(Ft,{get when(){return et(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=Ic(),fe(o=>{var r=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",l=e.tableDrag.mousePos().y-t().offsetY+"px";return r!==o.e&&Re(n,"width",o.e=r),a!==o.t&&Re(n,"height",o.t=a),i!==o.a&&Re(n,"left",o.a=i),l!==o.o&&Re(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),X(Ft,{get when(){return et(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),X(Ft,{get when(){return et(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),X(Ft,{get when(){return et(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>X(xc,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t,get pointerPos(){return e.textDrag.pointerPos},get caretViewport(){return e.textDrag.caretViewport}})})]}function kc(e){return[X(Qe,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),X(Qe,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Pc(e){const t=R(),[n,o]=an(e.initialValue);let r;we(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return X(xt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return X(kc,{get onCancel(){return e.onClose},onConfirm:a,get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return e.confirmLabel},get cancelTestId(){return e.testIds?.cancel},get confirmTestId(){return e.testIds?.confirm}})},get children(){return X(po,{ref(e){"function"==typeof r?r(e):r=e},get label(){return e.label},get value(){return n()},onChange:o,onKeyDown:e=>"Enter"===e.key&&a(),get placeholder(){return e.placeholder},get"data-testid"(){return e.testIds?.input}})}})}function Rc(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.link.title")},get label(){return t("dialog.link.label")},get placeholder(){return t("dialog.link.placeholder")},get initialValue(){return e.initialHref},get confirmLabel(){return t("generic.apply")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm},testIds:{input:"editor-link-dialog-input",cancel:"editor-link-dialog-cancel",confirm:"editor-link-dialog-apply"}})}function Bc(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageAlt.title")},get label(){return t("dialog.imageAlt.label")},get placeholder(){return t("dialog.imageAlt.placeholder")},get initialValue(){return e.initialAlt},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}function Ac(e){const t=R();return X(Pc,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageCaption.title")},get label(){return t("dialog.imageCaption.label")},get placeholder(){return t("dialog.imageCaption.placeholder")},get initialValue(){return e.initialCaption},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}var Mc=/*#__PURE__*/f("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Fc=/*#__PURE__*/f("<div class=oasis-editor-comment-composer>");function Oc(e){const t=R(),[n,o]=an(""),[r,a]=an("");let i;const l=e.composer.draft,s=()=>("edit"===l()?.mode||n().trim().length>0)&&r().trim().length>0,c=()=>{s()&&e.composer.submit(n(),r())};return we(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),X(xt,{get isOpen(){return null!==l()},get title(){return t("edit"===l()?.mode?"toolbar.editComment":"reply"===l()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[X(Qe,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",get disabled(){return!s()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var s=Fc();return We(s,X(Ft,{get when(){return"reply"===l()?.mode},get children(){var e=Mc();return We(e,X(ia,{as:"strong",get children(){return[et(()=>t("comment.replyTo"))," ",et(()=>l()?.parentAuthor)]}}),null),We(e,X(ia,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),We(s,X(po,{get label(){return t("comment.author")},get value(){return n()},onChange:o,maxLength:150,required:!0,get disabled(){return"edit"===l()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),We(s,X(vo,{ref(e){"function"==typeof i?i(e):i=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return r()},onChange:a,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),c())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),s}})}var Dc=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],Ec=[33,50,66,75,90,100,105,110,115,120,150,200];function Lc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Nc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function $c(e){return null==e||""===e?"":String(e)}function zc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Hc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function Wc(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Uc(e){switch(e){case"none":return"none";case"standard":return"common-ligatures";case"contextual":return"contextual";case"historical":return"historical-ligatures";case"standardContextual":return"common-ligatures contextual";default:return}}function jc(e,t){const n=[];return"proportional"===e&&n.push("proportional-nums"),"tabular"===e&&n.push("tabular-nums"),"lining"===t&&n.push("lining-nums"),"oldStyle"===t&&n.push("oldstyle-nums"),n.join(" ")||void 0}function Vc(e,t){const n=[],o=Wc(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Kc(e){return{familyFilter:"",fontFamily:e.fontFamily??"",fontSize:e.fontSize??"",colorMode:e.colorMode,color:e.color||"#111827",highlight:e.highlight||"",shading:e.shading||"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underline?e.underlineStyle??"single":"none",underlineColor:e.underlineColor||"#111827",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden)}}function _c(e){return{characterScale:$c(e.characterScale),spacingMode:zc(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Hc(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:$c(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:$c(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function Xc(e){const t=R(),[n,o]=an("font"),[r,a]=an(Kc(e.initial)),[i,l]=an(_c(e.initial));we(()=>{e.isOpen&&(o("font"),a(Kc(e.initial)),l(_c(e.initial)))});const s=vr(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=vr(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=vr(()=>{const t=new Set(Dc);for(const o of e.sizeOptions)t.add(o);const n=Number(r().fontSize);return Number.isFinite(n)&&n>0&&t.add(n),Array.from(t).sort((e,t)=>e-t)}),u=vr(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=vr(()=>{const e=i();return e.characterScale.trim()&&null===Lc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Nc(e.spacingAmount)||"normal"!==e.positionMode&&null===Nc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Nc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===Wc(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=vr(()=>function(e,t){const n=Number(e.fontSize),o=Lc(t.characterScale)??100,r="normal"===t.spacingMode?null:Nc(t.spacingAmount),a="normal"===t.positionMode?null:Nc(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,l=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,s=[];return e.underline&&"none"!==e.underlineStyle&&s.push("underline"),e.strike&&s.push("line-through"),e.doubleStrike&&s.push("line-through"),{"font-family":e.fontFamily||"inherit","font-size":Number.isFinite(n)&&n>0?`${n}pt`:void 0,"font-weight":e.bold?700:400,"font-style":e.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":l??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":Uc(t.ligatures),"font-variant-numeric":jc(t.numberSpacing,t.numberForm),"font-feature-settings":Vc(t.stylisticSet,t.contextualAlternates)}}(r(),i()));return{activeTab:n,setActiveTab:e=>o(e),fontTabValues:r,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{l(n=>({...n,[e]:t}))},selectedFontStyle:s,visibleFamilyOptions:c,effectiveSizeOptions:d,customSizeError:u,advancedValidationError:p,previewStyle:g,applyFontStylePreset:e=>{a(t=>({...t,bold:"bold"===e||"boldItalic"===e,italic:"italic"===e||"boldItalic"===e}))},handleApply:()=>{if(p())return;const t=function(e,t){const n=Number(e.fontSize),o=Number.isFinite(n)&&n>0,r="none"===e.underlineStyle?null:e.underlineStyle,a=null!==r,i=t.characterScale.trim()?Lc(t.characterScale):null,l="normal"===t.spacingMode?null:Nc(t.spacingAmount),s="normal"===t.positionMode?null:Nc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Nc(t.kerningThreshold):null,d=Wc(t.stylisticSet);return{fontFamily:e.fontFamily.trim()?e.fontFamily.trim():null,fontSize:o?n:null,colorMode:e.colorMode,color:"automatic"===e.colorMode?null:e.color||null,highlight:e.highlight||null,shading:e.shading||null,bold:e.bold,italic:e.italic,underline:a,underlineStyle:r,underlineColor:a&&e.underlineColor||null,strike:e.strike,doubleStrike:e.doubleStrike,superscript:e.superscript,subscript:e.subscript,smallCaps:e.smallCaps,allCaps:e.allCaps,hidden:e.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===t.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===t.positionMode?-s:s,kerningThreshold:c,ligatures:t.ligatures||null,numberSpacing:t.numberSpacing||null,numberForm:t.numberForm||null,stylisticSet:d,contextualAlternates:t.contextualAlternates}}(r(),i());e.onApply(t,e.initial),e.onClose()}}}var Gc=/*#__PURE__*/f("<div>");function qc(e){const t=R();return n=Gc(),We(n,()=>t("dialog.font.previewText")),fe(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&Ao(n,t.e=o),r!==t.t&&le(n,"data-testid",t.t=r),t.a=Sa(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Yc=/*#__PURE__*/f('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Zc(e){const t=R(),{ctrl:n}=e;return o=Yc(),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:12,get children(){return X(po,{get label(){return t("dialog.font.familyFilter")},get value(){return n.fontTabValues().familyFilter},onChange:e=>n.updateFontTab("familyFilter",e),"data-testid":"editor-font-dialog-family-filter"})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.family")},get value(){return n.fontTabValues().fontFamily},onChange:e=>n.updateFontTab("fontFamily",e),"data-testid":"editor-font-dialog-family",get options(){return[{value:"",label:"—"},...n.visibleFamilyOptions().map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.size")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-size",get options(){return[{value:"",label:"—"},...n.effectiveSizeOptions().map(e=>({value:String(e),label:String(e)}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return[X(po,{get label(){return t("dialog.font.customSize")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-custom-size"}),X(On,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.styleList")},get value(){return n.selectedFontStyle()},onChange:e=>n.applyFontStylePreset(e),"data-testid":"editor-font-dialog-style-list",get options(){return[{value:"regular",label:t("dialog.font.styleRegular")},{value:"italic",label:t("dialog.font.styleItalic")},{value:"bold",label:t("dialog.font.styleBold")},{value:"boldItalic",label:t("dialog.font.styleBoldItalic")}]}})}})]}}),null),We(o,X(Yr,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().colorMode},onChange:e=>n.updateFontTab("colorMode",e),"data-testid":"editor-font-dialog-color-mode",get options(){return[{value:"automatic",label:t("toolbar.colorAutomatic")},{value:"custom",label:t("dialog.font.customColor")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(Go,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().color},get disabled(){return"automatic"===n.fontTabValues().colorMode},onChange:e=>n.setFontTabValues(t=>({...t,color:e,colorMode:"custom"})),"data-testid":"editor-font-dialog-color"})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Go,{get label(){return t("dialog.font.highlight")},get value(){return n.fontTabValues().highlight||"#fef08a"},onChange:e=>n.updateFontTab("highlight",e),"data-testid":"editor-font-dialog-highlight"})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Go,{get label(){return t("dialog.font.shading")},get value(){return n.fontTabValues().shading||"#fef3c7"},onChange:e=>n.updateFontTab("shading",e),"data-testid":"editor-font-dialog-shading"})}})]}}),null),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.underlineStyle")},get value(){return n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineStyle:e,underline:"none"!==e})),"data-testid":"editor-font-dialog-underline-style",get options(){return[{value:"none",label:t("toolbar.underlineRemove")},...ot.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(Go,{get label(){return t("dialog.font.underlineColor")},get value(){return n.fontTabValues().underlineColor||"#111827"},get disabled(){return"none"===n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineColor:e,underline:"none"!==t.underlineStyle})),"data-testid":"editor-font-dialog-underline-color"})}})]}}),null),We(o,X(vn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return X(ee,{get each(){return[{testId:"editor-font-dialog-bold",label:t("dialog.font.bold"),labelStyle:{"font-weight":700},checked:()=>n.fontTabValues().bold,onChange:e=>n.updateFontTab("bold",e)},{testId:"editor-font-dialog-italic",label:t("dialog.font.italic"),labelStyle:{"font-style":"italic"},checked:()=>n.fontTabValues().italic,onChange:e=>n.updateFontTab("italic",e)},{testId:"editor-font-dialog-underline",label:t("dialog.font.underline"),labelStyle:{"text-decoration":"underline"},checked:()=>n.fontTabValues().underline,onChange:e=>n.setFontTabValues(t=>({...t,underline:e,underlineStyle:e?"none"===t.underlineStyle?"single":t.underlineStyle:"none"}))},{testId:"editor-font-dialog-strike",label:t("dialog.font.strike"),labelStyle:{"text-decoration":"line-through"},checked:()=>n.fontTabValues().strike,onChange:e=>n.setFontTabValues(t=>({...t,strike:e,doubleStrike:!e&&t.doubleStrike}))},{testId:"editor-font-dialog-double-strike",label:t("dialog.font.doubleStrike"),checked:()=>n.fontTabValues().doubleStrike,onChange:e=>n.setFontTabValues(t=>({...t,doubleStrike:e,strike:!e&&t.strike}))},{testId:"editor-font-dialog-superscript",label:t("toolbar.superscript"),checked:()=>n.fontTabValues().superscript,onChange:e=>n.setFontTabValues(t=>({...t,superscript:e,subscript:!e&&t.subscript}))},{testId:"editor-font-dialog-subscript",label:t("toolbar.subscript"),checked:()=>n.fontTabValues().subscript,onChange:e=>n.setFontTabValues(t=>({...t,subscript:e,superscript:!e&&t.superscript}))},{testId:"editor-font-dialog-small-caps",label:t("dialog.font.smallCaps"),checked:()=>n.fontTabValues().smallCaps,onChange:e=>n.updateFontTab("smallCaps",e)},{testId:"editor-font-dialog-all-caps",label:t("dialog.font.allCaps"),checked:()=>n.fontTabValues().allCaps,onChange:e=>n.updateFontTab("allCaps",e)},{testId:"editor-font-dialog-hidden",label:t("dialog.font.hidden"),checked:()=>n.fontTabValues().hidden,onChange:e=>n.updateFontTab("hidden",e)}]},children:e=>X(Fr,{get label(){return e.label},get labelStyle(){return e.labelStyle},get checked(){return e.checked()},get onChange(){return e.onChange},get"data-testid"(){return e.testId}})})}})}}),null),We(o,X(vn,{get label(){return t("dialog.font.preview")},get children(){return X(qc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var Jc=/*#__PURE__*/f("<div class=oasis-editor-font-dialog-kerning-line>"),Qc=/*#__PURE__*/f('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function ed(e){const t=R(),{ctrl:n}=e;return o=Qc(),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("dialog.font.advancedScale")},get value(){return n.advancedTabValues().characterScale||"100"},onChange:e=>n.updateAdvancedTab("characterScale",e),"data-testid":"editor-font-dialog-advanced-scale",get options(){return Ec.map(e=>({value:String(e),label:`${e}%`}))}})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.advancedSpacing")},get value(){return n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingMode",e),"data-testid":"editor-font-dialog-advanced-spacing-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"expanded",label:t("dialog.font.advancedExpanded")},{value:"condensed",label:t("dialog.font.advancedCondensed")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(po,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().spacingAmount},get disabled(){return"normal"===n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingAmount",e),"data-testid":"editor-font-dialog-advanced-spacing-amount"})}})]}})}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("dialog.font.advancedPosition")},get value(){return n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionMode",e),"data-testid":"editor-font-dialog-advanced-position-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"raised",label:t("dialog.font.advancedRaised")},{value:"lowered",label:t("dialog.font.advancedLowered")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(po,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().positionAmount},get disabled(){return"normal"===n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionAmount",e),"data-testid":"editor-font-dialog-advanced-position-amount"})}}),X(Yr,{size:12,get children(){var e=Jc();return We(e,X(fr,{class:"oasis-editor-font-dialog-kerning-toggle",get label(){return t("dialog.font.advancedKerning")},get checked(){return n.advancedTabValues().kerningEnabled},onChange:e=>n.setAdvancedTabValues(t=>({...t,kerningEnabled:e,kerningThreshold:e?t.kerningThreshold||"1":t.kerningThreshold})),"data-testid":"editor-font-dialog-advanced-kerning-enabled"}),null),We(e,X(po,{class:"oasis-editor-font-dialog-kerning-input",get value(){return n.advancedTabValues().kerningThreshold},get disabled(){return!n.advancedTabValues().kerningEnabled},onChange:e=>n.updateAdvancedTab("kerningThreshold",e),"data-testid":"editor-font-dialog-advanced-kerning"}),null),We(e,X(On,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedLigatures")},get value(){return n.advancedTabValues().ligatures},onChange:e=>n.updateAdvancedTab("ligatures",e),"data-testid":"editor-font-dialog-advanced-ligatures",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"none",label:t("dialog.font.advancedLigaturesNone")},{value:"standard",label:t("dialog.font.advancedLigaturesStandard")},{value:"contextual",label:t("dialog.font.advancedLigaturesContextual")},{value:"historical",label:t("dialog.font.advancedLigaturesHistorical")},{value:"standardContextual",label:t("dialog.font.advancedLigaturesStandardContextual")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedNumberSpacing")},get value(){return n.advancedTabValues().numberSpacing},onChange:e=>n.updateAdvancedTab("numberSpacing",e),"data-testid":"editor-font-dialog-advanced-number-spacing",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"proportional",label:t("dialog.font.advancedNumberSpacingProportional")},{value:"tabular",label:t("dialog.font.advancedNumberSpacingTabular")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedNumberForm")},get value(){return n.advancedTabValues().numberForm},onChange:e=>n.updateAdvancedTab("numberForm",e),"data-testid":"editor-font-dialog-advanced-number-form",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"lining",label:t("dialog.font.advancedNumberFormLining")},{value:"oldStyle",label:t("dialog.font.advancedNumberFormOldStyle")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("dialog.font.advancedStylisticSet")},get value(){return n.advancedTabValues().stylisticSet},onChange:e=>n.updateAdvancedTab("stylisticSet",e),"data-testid":"editor-font-dialog-advanced-stylistic-set",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},...Array.from({length:20},(e,t)=>t+1).map(e=>({value:String(e),label:String(e)}))]}})}})]}}),X(fr,{class:"oasis-editor-font-dialog-contextual-toggle",get label(){return t("dialog.font.advancedContextualAlternates")},get checked(){return n.advancedTabValues().contextualAlternates},onChange:e=>n.updateAdvancedTab("contextualAlternates",e),"data-testid":"editor-font-dialog-advanced-contextual-alternates"})]}}),null),We(o,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return X(qc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),We(o,X(On,{as:"p",class:"oasis-editor-dialog-help-text","data-testid":"editor-font-dialog-advanced-placeholder",get children(){return n.advancedValidationError()||t("dialog.font.advancedPlaceholder")}}),null),o;var o}function td(e){const t=R(),n=Xc(e);return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.font.title")},get onClose(){return e.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-font-dialog-cancel",confirmTestId:"editor-font-dialog-apply"})},get children(){return X(da,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return t("dialog.font.title")},get value(){return n.activeTab()},onChange:e=>n.setActiveTab(e),get items(){return[{id:"font",label:t("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:X(Zc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:X(ed,{ctrl:n})}]}})}})}var nd=/*#__PURE__*/f("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),od=/*#__PURE__*/f("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function rd(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function ad(e){const t=R(),[n,o]=an([]);we(()=>{e.isOpen&&o(e.initial.map(rd))});const r=(e,t)=>{o(n=>n.map((n,o)=>o===e?{...n,...t}:n))},a=()=>{o(e=>[...e,{position:null,type:"left",leader:"none"}])},i=()=>{const t=n().filter(e=>null!==e.position).map(e=>({position:e.position,type:e.type,..."none"!==e.leader?{leader:e.leader}:{}})).sort((e,t)=>e.position-t.position);e.onApply(t),e.onClose()};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=od(),r=n.firstChild,a=r.nextSibling,We(r,X(Qe,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),We(a,X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),We(a,X(Qe,{variant:"primary",onClick:i,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){var e=nd(),i=e.firstChild;return We(e,X(ee,{get each(){return n()},get fallback(){return X(On,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>X(Yr,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),X(Yr,{size:{xs:6,md:3},get children(){return X(ro,{get label(){return t("paragraph.tabsAlignment")},get value(){return e.type},onChange:e=>r(n(),{type:e}),get options(){return[{value:"left",label:t("paragraph.tabAlignLeft")},{value:"center",label:t("paragraph.tabAlignCenter")},{value:"right",label:t("paragraph.tabAlignRight")},{value:"decimal",label:t("paragraph.tabAlignDecimal")},{value:"bar",label:t("paragraph.tabAlignBar")}]}})}}),X(Yr,{size:{xs:6,md:3},get children(){return X(ro,{get label(){return t("paragraph.tabsLeader")},get value(){return e.leader},onChange:e=>r(n(),{leader:e}),get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:t("paragraph.tabLeaderDot")},{value:"hyphen",label:t("paragraph.tabLeaderHyphen")},{value:"underscore",label:t("paragraph.tabLeaderUnderscore")}]}})}}),X(Yr,{size:{xs:12,md:2},get children(){return X(Qe,{variant:"ghost",onClick:()=>(e=>{o(t=>t.filter((t,n)=>n!==e))})(n()),"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsRemove")}})}})]}})}),i),We(i,X(Qe,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var id=96/72;function ld(e){const[t,n]=an(""),[o,r]=an(""),[a,i]=an(null),[l,s]=an(null),[c,d]=an("none"),[u,p]=an(null),[g,f]=an(!1),[m,h]=an(null),[b,y]=an(null),[v,x]=an("multiple"),[w,S]=an(null),[C,I]=an(!1),[T,k]=an(""),[P,R]=an("none"),[B,A]=an(null),[M,F]=an(""),[O,D]=an(!1),[E,L]=an(!1),[N,$]=an(!1),[z,H]=an(!1),[W,U]=an(!1),[j,V]=an(!1),[K,_]=an(!1),[X,G]=an(!0),[q,Y]=an([]);we(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(cn(e.initial.indentLeft??"")),s(cn(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(cn(e.initial.spacingBefore??"")),y(cn(e.initial.spacingAfter??"")),I(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=cn(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/id):null}:null===o?{mode:"multiple",at:null}:1===o?{mode:"single",at:null}:1.5===o?{mode:"onePointFive",at:null}:2===o?{mode:"double",at:null}:{mode:"multiple",at:o});x(a),S(l);const c=e.initial.borderStyle;R("solid"===c||"dashed"===c||"dotted"===c?c:"none"),A(cn(e.initial.borderWidth??"")),F(e.initial.borderColor??""),D(e.initial.borderSideTop??!1),L(e.initial.borderSideRight??!1),$(e.initial.borderSideBottom??!1),H(e.initial.borderSideLeft??!1),U(e.initial.pageBreakBefore??!1),V(e.initial.keepWithNext??!1),_(e.initial.keepLinesTogether??!1),G(e.initial.widowControl??!0),Y(e.initial.tabs??[]);const u=cn(e.initial.indentFirstLine??""),g=cn(e.initial.indentHanging??"");null!==g&&g>0?(d("hanging"),p(g)):null!==u&&u>0?(d("firstLine"),p(u)):(d("none"),p(null))}var t,o});const Z=()=>{switch(v()){case"single":return{lineHeight:1,lineRule:null};case"onePointFive":return{lineHeight:1.5,lineRule:null};case"double":return{lineHeight:2,lineRule:null};case"multiple":return{lineHeight:w(),lineRule:null};case"atLeast":return{lineHeight:null!==w()?w()*id:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*id:null,lineRule:"exact"}}},J=vr(()=>{const e=a(),n=l(),o="firstLine"===c()?u():null,r="hanging"===c()?u():null,i=null!==o?o:null!==r?-r:null,s="none"!==P()?`${B()??.5}pt ${P()} ${M().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=Z(),g=null===d?void 0:"exact"===p||"atLeast"===p?`${d}px`:String(d);return{"text-align":t()||void 0,"line-height":g,"padding-left":null!==e?`${e+(r??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==i?`${i}pt`:void 0,"background-color":T().trim()||void 0,"border-top":s&&O()?s:void 0,"border-right":s&&E()?s:void 0,"border-bottom":s&&N()?s:void 0,"border-left":s&&z()?s:void 0}}),Q=()=>{const e=P();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=B(),n={type:e,width:null!==t&&t>0?t:.5,color:M().trim()||"#000000"};return{top:O()?n:null,right:E()?n:null,bottom:N()?n:null,left:z()?n:null}},ee=()=>{const e=u(),{lineHeight:n,lineRule:r}=Z(),i=o();return{align:t()||null,indentLeft:a(),indentRight:l(),indentFirstLine:"firstLine"===c()?e:null,indentHanging:"hanging"===c()?e:null,mirrorIndents:g(),spacingBefore:m(),spacingAfter:b(),lineHeight:n,lineRule:r,contextualSpacing:C(),outlineLevel:""===i?null:Number(i),shading:T().trim()||null,borders:Q(),pageBreakBefore:W(),keepWithNext:j(),keepLinesTogether:K(),widowControl:X(),tabs:q()}};return{align:t,setAlign:n,outlineLevel:o,setOutlineLevel:r,indentLeft:a,setIndentLeft:i,indentRight:l,setIndentRight:s,special:c,setSpecial:d,specialBy:u,setSpecialBy:p,mirrorIndents:g,setMirrorIndents:f,spacingBefore:m,setSpacingBefore:h,spacingAfter:b,setSpacingAfter:y,lineMode:v,setLineMode:x,lineAt:w,setLineAt:S,contextualSpacing:C,setContextualSpacing:I,shading:T,setShading:k,borderStyle:P,setBorderStyle:R,borderWidth:B,setBorderWidth:A,borderColor:M,setBorderColor:F,sideTop:O,setSideTop:D,sideRight:E,setSideRight:L,sideBottom:N,setSideBottom:$,sideLeft:z,setSideLeft:H,pageBreakBefore:W,setPageBreakBefore:U,keepWithNext:j,setKeepWithNext:V,keepLinesTogether:K,setKeepLinesTogether:_,widowControl:X,setWidowControl:G,tabs:q,setTabs:Y,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:J,handleApply:()=>{e.onApply(ee(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(ee()),e.onClose()}}}var sd=/*#__PURE__*/f("<div class=oasis-editor-paragraph-dialog-panel>"),cd=/*#__PURE__*/f("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),dd=/*#__PURE__*/f("<div>"),ud=/*#__PURE__*/f("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function pd(e){const t=R(),[n,o]=an(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:l,indentLeft:s,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:g,specialBy:f,setSpecialBy:m,mirrorIndents:h,setMirrorIndents:b,spacingBefore:y,setSpacingBefore:v,spacingAfter:x,setSpacingAfter:w,lineMode:S,setLineMode:C,lineAt:I,setLineAt:T,contextualSpacing:k,setContextualSpacing:P,shading:B,setShading:A,borderStyle:M,setBorderStyle:F,borderWidth:O,setBorderWidth:D,borderColor:E,setBorderColor:L,sideTop:N,setSideTop:$,sideRight:z,setSideRight:H,sideBottom:W,setSideBottom:U,sideLeft:j,setSideLeft:V,pageBreakBefore:K,setPageBreakBefore:_,keepWithNext:G,setKeepWithNext:q,keepLinesTogether:Y,setKeepLinesTogether:Z,widowControl:J,setWidowControl:Q,tabs:ee,setTabs:te,atEnabled:ne,previewStyle:oe,handleApply:re,handleSetDefault:ae}=ld(e),ie=X(ro,{get label(){return t("paragraph.alignLabel")},get value(){return r()},onChange:a,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:t("paragraph.alignLeft")},{value:"center",label:t("paragraph.alignCenter")},{value:"right",label:t("paragraph.alignRight")},{value:"justify",label:t("paragraph.alignJustify")}]}}),le=X(ro,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:l,"data-testid":"editor-paragraph-dialog-outline-level",get options(){return[{value:"",label:t("paragraph.outlineBodyText")},...Array.from({length:9},(e,n)=>({value:String(n),label:t("paragraph.outlineLevelN",[n+1])}))]}}),se=(ce=sd(),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},children:ie}),X(Yr,{size:{xs:12,md:6},children:le})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("paragraph.specialLabel")},get value(){return p()},onChange:e=>{const t=e;g(t),"none"===t&&m(null)},"data-testid":"editor-paragraph-dialog-special",get options(){return[{value:"none",label:t("paragraph.specialNone")},{value:"firstLine",label:t("paragraph.specialFirstLine")},{value:"hanging",label:t("paragraph.specialHanging")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(_n,{get label(){return t("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===p()},get value(){return f()??""},onChange:m,"data-testid":"editor-paragraph-dialog-special-by"})}}),X(Yr,{size:12,get children(){return X(fr,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:b,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return y()??""},onChange:v,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return x()??""},onChange:w,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),X(Yr,{size:{xs:12,md:4}}),X(Yr,{size:{xs:12,md:8},get children(){return X(ro,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return S()},onChange:e=>{C(e)},"data-testid":"editor-paragraph-dialog-line-mode",get options(){return[{value:"single",label:t("paragraph.lineSpacingSingle")},{value:"onePointFive",label:t("paragraph.lineSpacingOnePointFive")},{value:"double",label:t("paragraph.lineSpacingDouble")},{value:"atLeast",label:t("paragraph.lineSpacingAtLeast")},{value:"exact",label:t("paragraph.lineSpacingExact")},{value:"multiple",label:t("paragraph.lineSpacingMultiple")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(_n,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===S()?"0.05":"1"},get disabled(){return!ne()},get value(){return I()??""},onChange:T,"data-testid":"editor-paragraph-dialog-line-at"})}}),X(Yr,{size:12,get children(){return X(fr,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return k()},onChange:P,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),We(ce,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("paragraph.borderStyleLabel")},get value(){return M()},onChange:e=>{const t=e;F(t),"none"===t?($(!1),H(!1),U(!1),V(!1)):N()||z()||W()||j()||($(!0),H(!0),U(!0),V(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(_n,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===M()},get value(){return O()??""},onChange:D,"data-testid":"editor-paragraph-dialog-border-width"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===M()},get value(){return E()||"#000000"},onChange:L,"data-testid":"editor-paragraph-dialog-border-color"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:A,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),X(vn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===M()},get checked(){return N()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),X(fr,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===M()},get checked(){return z()},onChange:H,"data-testid":"editor-paragraph-dialog-border-side-right"}),X(fr,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===M()},get checked(){return W()},onChange:U,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),X(fr,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===M()},get checked(){return j()},onChange:V,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),ce);var ce;const de=(ue=sd(),We(ue,X(zn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return X(ba,{direction:"column",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.widowControlLabel")},get checked(){return J()},onChange:Q,"data-testid":"editor-paragraph-dialog-widow-control"}),X(fr,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return G()},onChange:q,"data-testid":"editor-paragraph-dialog-keep-with-next"}),X(fr,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Y()},onChange:Z,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),X(fr,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return K()},onChange:_,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ue);var ue,pe;return pe=dd(),We(pe,X(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",testId:"editor-paragraph-dialog",get footer(){return n=ud(),r=n.firstChild,a=r.nextSibling,We(r,X(Qe,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),We(r,X(Qe,{variant:"secondary",onClick:ae,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),We(a,X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),We(a,X(Qe,{variant:"primary",onClick:re,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[X(da,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:se,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:de,testId:"editor-paragraph-dialog-tab-breaks"}]}}),X(vn,{get label(){return t("paragraph.preview")},get children(){var e=cd();return We(e,()=>t("paragraph.previewText")),fe(t=>Sa(e,oe(),t)),e}})]}}),null),We(pe,X(ad,{get isOpen(){return n()},get initial(){return ee()},onClose:()=>{o(!1)},onApply:te}),null),pe}function gd(e,t){const n=cn(e);return null===n?null:"percent"===t?`${n}%`:n}function fd(e,t,n){if("none"===e)return null;const o=cn(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function md(e){const[t,n]=Ro({activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"",floatingY:"",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"",floatingDistanceRight:"",floatingDistanceBottom:"",floatingDistanceLeft:"",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTlBr:!1,borderTrBl:!1,shading:"",altTitle:"",altDescription:""});we(()=>{var t;e.isOpen&&n(Oe({activeTab:(t=e.initial).activeTab??"table",tableWidth:t.tableWidth,tableWidthUnit:t.tableWidthUnit,tableAlign:t.tableAlign,tableIndentLeft:t.tableIndentLeft,tableWrapping:t.tableWrapping,floatingHorizontalAnchor:t.floatingHorizontalAnchor,floatingVerticalAnchor:t.floatingVerticalAnchor,floatingX:t.floatingX,floatingY:t.floatingY,floatingXAlign:t.floatingXAlign,floatingYAlign:t.floatingYAlign,floatingDistanceTop:t.floatingDistanceTop,floatingDistanceRight:t.floatingDistanceRight,floatingDistanceBottom:t.floatingDistanceBottom,floatingDistanceLeft:t.floatingDistanceLeft,floatingOverlap:t.floatingOverlap,rowHeight:t.rowHeight,rowHeightRule:t.rowHeightRule,repeatHeader:t.repeatHeader,allowBreakAcrossPages:t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:t.columnWidth,cellWidth:t.cellWidth,cellVerticalAlign:t.cellVerticalAlign,cellTextDirection:t.cellTextDirection,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,marginTop:t.marginTop,marginRight:t.marginRight,marginBottom:t.marginBottom,marginLeft:t.marginLeft,borderStyle:t.borderStyle,borderWidth:t.borderWidth,borderColor:t.borderColor,borderTop:t.borderTop,borderRight:t.borderRight,borderBottom:t.borderBottom,borderLeft:t.borderLeft,borderStart:t.borderStart,borderEnd:t.borderEnd,borderTlBr:t.borderTopLeftToBottomRight,borderTrBl:t.borderTopRightToBottomLeft,shading:t.shading,altTitle:t.altTitle,altDescription:t.altDescription}))});return{form:t,set:n,handleApply:()=>{e.onApply(function(e){const t=fd(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:gd(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:gd(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:cn(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:cn(e.floatingY)??0},distanceTop:cn(e.floatingDistanceTop)??0,distanceRight:cn(e.floatingDistanceRight)??0,distanceBottom:cn(e.floatingDistanceBottom)??0,distanceLeft:cn(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:gd(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:gd(e.columnWidth,"points"),cellWidth:gd(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:cn(e.marginTop),right:cn(e.marginRight),bottom:cn(e.marginBottom),left:cn(e.marginLeft)},borders:{top:e.borderTop?t:null,right:e.borderRight?t:null,bottom:e.borderBottom?t:null,left:e.borderLeft?t:null,start:e.borderStart?t:null,end:e.borderEnd?t:null,topLeftToBottomRight:e.borderTlBr?t:null,topRightToBottomLeft:e.borderTrBl?t:null},shading:e.shading.trim()||null,altTitle:e.altTitle.trim()||null,altDescription:e.altDescription.trim()||null}}(t),e.initial),e.onClose()}}}function hd(e,t,n,o,r=!1,a=!1){return X(po,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:e,min:a?void 0:"0",step:"1",get value(){return t()},disabled:r,onChange:n,"data-testid":o})}var bd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function yd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=bd(),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.measureIn")},get value(){return n().tableWidthUnit},onChange:e=>o("tableWidthUnit",e),"data-testid":"editor-table-properties-table-width-unit",get options(){return[{value:"points",label:t("table.points")},{value:"percent",label:t("table.percent")}]}})}})]}})}}),null),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[X(jr,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return n().tableAlign},onChange:e=>o("tableAlign",e),get children(){return["left","center","right"].map(e=>X(Wo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),X(Yr,{container:!0,spacing:1.5,get children(){return X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),We(r,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),X(fr,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),X(Ft,{get when(){return"around"===n().tableWrapping},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.horizontalAnchor")},get value(){return n().floatingHorizontalAnchor},onChange:e=>o("floatingHorizontalAnchor",e),"data-testid":"editor-table-properties-floating-h-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.verticalAnchor")},get value(){return n().floatingVerticalAnchor},onChange:e=>o("floatingVerticalAnchor",e),"data-testid":"editor-table-properties-floating-v-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("table.horizontalAlignment")},get value(){return n().floatingXAlign},onChange:e=>o("floatingXAlign",e),"data-testid":"editor-table-properties-floating-x-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["left","center","right","inside","outside"].map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("table.verticalAlignment")},get value(){return n().floatingYAlign},onChange:e=>o("floatingYAlign",e),"data-testid":"editor-table-properties-floating-y-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["top","center","bottom","inside","outside"].map(e=>({value:e,label:e}))]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),X(fr,{get label(){return t("table.allowOverlap")},get checked(){return"overlap"===n().floatingOverlap},onChange:e=>o("floatingOverlap",e?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),r;var r}var vd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function xd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=vd(),We(r,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),X(Yr,{size:{xs:12,md:6},get children(){return X(ro,{get label(){return t("table.rowHeightRule")},get value(){return n().rowHeightRule},onChange:e=>o("rowHeightRule",e),"data-testid":"editor-table-properties-row-height-rule",get options(){return[{value:"",label:t("table.rowAuto")},{value:"atLeast",label:t("table.rowAtLeast")},{value:"exact",label:t("table.rowExactly")}]}})}})]}}),null),We(r,X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),X(fr,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),X(fr,{get label(){return t("table.hiddenRow")},get checked(){return n().hiddenRow},onChange:e=>o("hiddenRow",e),"data-testid":"editor-table-properties-hidden-row"})]}}),null),r;var r}var wd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Sd(e){const t=R(),n=e.ctrl.set;return o=wd(),We(o,X(Yr,{container:!0,spacing:1.5,get children(){return X(Yr,{size:{xs:12,md:6},get children(){return hd(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var Cd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),Id=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Td(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set,r=vr(()=>{const e=fd(n().borderStyle,n().borderWidth,n().borderColor),t=e?`${e.width}pt ${e.type} ${e.color}`:void 0;return{"background-color":n().shading.trim()||void 0,"border-top":t&&n().borderTop?t:"1px solid #dadce0","border-right":t&&n().borderRight?t:"1px solid #dadce0","border-bottom":t&&n().borderBottom?t:"1px solid #dadce0","border-left":t&&n().borderLeft?t:"1px solid #dadce0"}}),a=()=>"none"===n().borderStyle;return i=Id(),We(i,X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:4},get children(){return hd(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("table.verticalAlignment")},get value(){return n().cellVerticalAlign},onChange:e=>o("cellVerticalAlign",e),"data-testid":"editor-table-properties-cell-valign",get options(){return[{value:"",label:t("table.inherit")},{value:"top",label:t("table.valignTop")},{value:"middle",label:t("table.valignMiddle")},{value:"bottom",label:t("table.valignBottom")}]}})}}),X(Yr,{size:{xs:12,md:4},get children(){return X(ro,{get label(){return t("table.textDirection")},get value(){return n().cellTextDirection},onChange:e=>o("cellTextDirection",e),"data-testid":"editor-table-properties-cell-direction",get options(){return[{value:"",label:t("table.inherit")},{value:"lrTb",label:"lrTb"},{value:"tbRl",label:"tbRl"},{value:"btLr",label:"btLr"},{value:"lrTbV",label:"lrTbV"},{value:"tbRlV",label:"tbRlV"}]}})}})]}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),X(fr,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),X(fr,{get label(){return t("table.hideMark")},get checked(){return n().cellHideMark},onChange:e=>o("cellHideMark",e),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),We(i,X(zn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[X(Yr,{container:!0,spacing:1.5,get children(){return[X(Yr,{size:{xs:12,md:3},get children(){return X(ro,{get label(){return t("paragraph.borderStyleLabel")},get value(){return n().borderStyle},onChange:e=>{const t=e;o("borderStyle",t),"none"===t?(o("borderTop",!1),o("borderRight",!1),o("borderBottom",!1),o("borderLeft",!1),o("borderStart",!1),o("borderEnd",!1),o("borderTlBr",!1),o("borderTrBl",!1)):n().borderTop||n().borderRight||n().borderBottom||n().borderLeft||(o("borderTop",!0),o("borderRight",!0),o("borderBottom",!0),o("borderLeft",!0))},"data-testid":"editor-table-properties-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),X(Yr,{size:{xs:12,md:3},get children(){return hd(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.borderColorLabel")},get value(){return n().borderColor||"#000000"},get disabled(){return a()},onChange:e=>o("borderColor",e),"data-testid":"editor-table-properties-border-color"})}}),X(Yr,{size:{xs:12,md:3},get children(){return X(Go,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),X(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[X(fr,{get label(){return t("paragraph.borderSideTop")},get checked(){return n().borderTop},get disabled(){return a()},onChange:e=>o("borderTop",e),"data-testid":"editor-table-properties-border-top"}),X(fr,{get label(){return t("paragraph.borderSideRight")},get checked(){return n().borderRight},get disabled(){return a()},onChange:e=>o("borderRight",e),"data-testid":"editor-table-properties-border-right"}),X(fr,{get label(){return t("paragraph.borderSideBottom")},get checked(){return n().borderBottom},get disabled(){return a()},onChange:e=>o("borderBottom",e),"data-testid":"editor-table-properties-border-bottom"}),X(fr,{get label(){return t("paragraph.borderSideLeft")},get checked(){return n().borderLeft},get disabled(){return a()},onChange:e=>o("borderLeft",e),"data-testid":"editor-table-properties-border-left"}),X(fr,{get label(){return t("table.borderStart")},get checked(){return n().borderStart},get disabled(){return a()},onChange:e=>o("borderStart",e),"data-testid":"editor-table-properties-border-start"}),X(fr,{get label(){return t("table.borderEnd")},get checked(){return n().borderEnd},get disabled(){return a()},onChange:e=>o("borderEnd",e),"data-testid":"editor-table-properties-border-end"}),X(fr,{get label(){return t("table.borderTlBr")},get checked(){return n().borderTlBr},get disabled(){return a()},onChange:e=>o("borderTlBr",e),"data-testid":"editor-table-properties-border-tlbr"}),X(fr,{get label(){return t("table.borderTrBl")},get checked(){return n().borderTrBl},get disabled(){return a()},onChange:e=>o("borderTrBl",e),"data-testid":"editor-table-properties-border-trbl"})]}}),(e=Cd(),fe(t=>Sa(e,r(),t)),e)];var e}}),null),i;var i}var kd=/*#__PURE__*/f("<div class=oasis-editor-table-properties-panel>");function Pd(e){const t=R(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=kd(),We(r,X(po,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),We(r,X(vo,{class:"oasis-editor-dialog-input-group",get label(){return t("table.altDescription")},controlClass:"oasis-editor-table-properties-textarea",get value(){return n().altDescription},onChange:e=>o("altDescription",e),"data-testid":"editor-table-properties-alt-description"}),null),r;var r}function Rd(e){const t=R(),n=md(e);return X(xt,{get isOpen(){return e.isOpen},get title(){return t("table.propertiesTitle")},get onClose(){return e.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-table-properties-cancel",confirmTestId:"editor-table-properties-apply"})},get children(){return X(da,{get value(){return n.form.activeTab},onChange:e=>n.set("activeTab",e),get ariaLabel(){return t("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:t("table.tabTable"),testId:"editor-table-properties-tab-table",panel:X(yd,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:X(xd,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:X(Sd,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:X(Td,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:X(Pd,{ctrl:n})}]}})}})}var Bd=/*#__PURE__*/f("<p data-testid=editor-new-document-message>");function Ad(e){const t=R();return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("dialog.newDocument.discard")},cancelTestId:"editor-new-document-cancel",confirmTestId:"editor-new-document-discard"})},get children(){var e=Bd();return We(e,()=>t("dialog.newDocument.message")),e}})}function Md(e){const t=R(),n=()=>"accept"===e.action;return X(xt,{get isOpen(){return e.isOpen},get title(){return t(n()?"review.bulkAcceptTitle":"review.bulkRejectTitle")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",testId:"editor-revision-bulk-dialog",get footer(){return X(kc,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t(n()?"toolbar.acceptAll":"toolbar.rejectAll")},cancelTestId:"editor-revision-bulk-cancel",confirmTestId:"editor-revision-bulk-confirm"})},get children(){return X(ia,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Fd=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-controls><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-font></select></label><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-category><option value=all>"),Od=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),Dd=/*#__PURE__*/f("<div class=oasis-editor-symbol-dialog-layout><div class=oasis-editor-symbol-dialog-grid role=grid></div><aside class=oasis-editor-symbol-dialog-preview><span class=oasis-editor-symbol-dialog-preview-label></span><span class=oasis-editor-symbol-dialog-preview-character data-testid=editor-symbol-dialog-preview></span><label class=oasis-editor-symbol-dialog-field><span></span><input data-testid=editor-symbol-dialog-code></label><p class=oasis-editor-symbol-dialog-help>"),Ed=/*#__PURE__*/f("<option>"),Ld=/*#__PURE__*/f("<button type=button class=oasis-editor-symbol-dialog-tile>"),Nd=/*#__PURE__*/f("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),$d=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function zd(e){const t=R(),[n,o]=an("common"),[r,a]=an(Hn[0]),[i,l]=an($d[0]),[s,c]=an(Hn[0].codePoint),d=vr(()=>(e.isOpen,Lo())),u=vr(()=>"all"===n()?Qn.flatMap(e=>e.entries):Qn.find(e=>e.id===n())?.entries??Hn),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&($r(t),e.onInsert(t,i()),e.onClose())};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.symbol.title")},get onClose(){return e.onClose},class:"oasis-editor-symbol-dialog",bodyClass:"oasis-editor-symbol-dialog-body",size:"lg",closeOnOverlayClick:!1,get footer(){return[X(Qe,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(w=Fd(),S=w.firstChild,C=S.firstChild,I=C.nextSibling,T=S.nextSibling.firstChild,k=T.nextSibling,P=k.firstChild,We(C,()=>t("dialog.symbol.font")),I.addEventListener("change",e=>{l(e.currentTarget.value)}),We(I,X(ee,{each:$d,children:e=>{return(t=Ed()).value=e,We(t,e),t;var t}})),We(T,()=>t("dialog.symbol.subset")),k.addEventListener("change",e=>{o(e.currentTarget.value)}),We(P,()=>t("symbols.category.all")),We(k,X(ee,{each:Qn,children:e=>{return n=Ed(),We(n,()=>t(e.labelKey)),fe(()=>n.value=e.id),n;var n}}),null),fe(()=>I.value=i()),fe(()=>k.value=n()),w),(e=Dd(),f=e.firstChild,m=f.nextSibling.firstChild,h=m.nextSibling,b=h.nextSibling,y=b.firstChild,v=y.nextSibling,x=b.nextSibling,We(f,X(Ft,{get when(){return d().length>0},get children(){var e=Od(),n=e.firstChild,o=n.nextSibling;return We(n,()=>t("dialog.symbol.recent")),We(o,X(ee,{get each(){return d()},children:e=>{return(t=Ld()).$$click=()=>p(e),We(t,()=>e.character),fe(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&le(t,"title",n.e=o),r!==n.t&&le(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),We(f,X(ee,{get each(){return u()},children:e=>{return(t=Nd()).$$dblclick=g,t.$$click=()=>p(e),We(t,()=>e.character),fe(n=>{var o=!(r().character!==e.character),a=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,l=`editor-symbol-dialog-${e.codePoint.replace(/[^A-Z0-9]/g,"-")}`;return o!==n.e&&t.classList.toggle("oasis-editor-symbol-dialog-tile-active",n.e=o),a!==n.t&&le(t,"title",n.t=a),i!==n.a&&le(t,"aria-label",n.a=i),l!==n.o&&le(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),We(m,()=>t("dialog.symbol.preview")),We(h,()=>r().character),We(y,()=>t("dialog.symbol.code")),v.$$input=e=>(e=>{c(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||a({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),le(v,"spellcheck",!1),We(x,()=>t("dialog.symbol.doubleClickHelp")),fe(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&le(f,"aria-label",e.e=n),o!==e.t&&Re(h,"font-family",e.t=o),e},{e:void 0,t:void 0}),fe(()=>v.value=s()),e)];var e,f,m,h,b,y,v,x,w,S,C,I,T,k,P}})}Ee(["input","click","dblclick"]);var Hd=/*#__PURE__*/f("<div class=oasis-editor-equation-editor><div class=oasis-editor-equation-palette></div><label class=oasis-editor-equation-linear><span></span><textarea data-testid=editor-equation-linear></textarea></label><div class=oasis-editor-equation-preview aria-live=polite data-testid=editor-equation-preview>"),Wd=/*#__PURE__*/f("<button type=button data-testid=editor-equation-template>"),Ud=[["\\frac{□}{□}","\\frac{a}{b}"],["\\sqrt{□}","\\sqrt{x}"],["x^□","x^{2}"],["x_□","x_{i}"],["∑","\\sum_{i=1}^{n} i"],["∫","∫ f(x) dx"],["[ ]","(a+b)"],["[a b]","\\matrix{a & b \\ c & d}"]];function jd(e){const t=R(),[n,o]=an(""),[r,a]=an(Ir);we(()=>{if(!e.isOpen)return;const t=e.initial??Ir;a(t),o(L(t))});const i=e=>{o(e),a(kt(e))};return X(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.equation.title")},get onClose(){return e.onClose},size:"lg",closeOnOverlayClick:!1,class:"oasis-editor-equation-dialog",get footer(){return[X(Qe,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),X(Qe,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Hd(),o=e.firstChild,a=o.nextSibling,l=a.firstChild,s=l.nextSibling,c=a.nextSibling;return We(o,X(ee,{each:Ud,children:([e,t])=>{return(n=Wd()).$$click=()=>i(t),We(n,e),n;var n}})),We(l,()=>t("dialog.equation.linear")),s.$$input=e=>i(e.currentTarget.value),le(s,"spellcheck",!1),We(c,()=>L(r())||t("dialog.equation.empty")),fe(()=>le(o,"aria-label",t("dialog.equation.structures"))),fe(()=>s.value=n()),e}})}Ee(["input","click"]);var Vd=/*#__PURE__*/f("<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper></div></div><div class=oasis-editor-fr-input-group>");function Kd(e){const t=R(),{fr:n}=e,r=e=>{n.isOpen()&&"Escape"===e.key&&n.setIsOpen(!1)},a=e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext())};return Zn(()=>{window.addEventListener("keydown",r,!0)}),o(()=>{window.removeEventListener("keydown",r,!0)}),X(Ft,{get when(){return n.isOpen()},get children(){var e=Vd(),o=e.firstChild,r=o.nextSibling,i=r.firstChild,l=i.firstChild,s=i.nextSibling;return e.$$keydown=a,We(o,X(ia,{get children(){return t("find.title")}}),null),We(o,X(ht,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),We(l,X(po,{type:"text",get placeholder(){return t("find.placeholder")},get value(){return n.searchTerm()},onChange:e=>n.setSearchTerm(e),autofocus:!0,controlClass:"oasis-editor-fr-input"}),null),We(l,X(On,{class:"oasis-editor-fr-counter",get children(){return et(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),We(i,X(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[X(ht,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),X(ht,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),We(s,X(po,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),We(s,X(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[X(ht,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),X(ht,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replaceAll},get disabled(){return 0===n.matches().length},get children(){return t("replace.allBtn")}})]}}),null),We(r,X(ba,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[X(fr,{class:"oasis-editor-fr-checkbox",get label(){return t("find.matchCase")},get checked(){return n.findOptions().matchCase},onChange:e=>n.setFindOptions({...n.findOptions(),matchCase:e})}),X(fr,{class:"oasis-editor-fr-checkbox",get label(){return t("find.wholeWord")},get checked(){return n.findOptions().wholeWord},onChange:e=>n.setFindOptions({...n.findOptions(),wholeWord:e})})]}}),null),e}})}Ee(["keydown"]);var _d=/*#__PURE__*/f("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),Xd=/*#__PURE__*/f("<i>"),Gd=/*#__PURE__*/f("<span class=oasis-editor-context-menu-shortcut>"),qd=/*#__PURE__*/f("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),Yd=/*#__PURE__*/f("<div class=oasis-editor-context-menu-separator>"),Zd=/*#__PURE__*/f("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function Jd(e){let t;const n=t=>{e.isOpen&&"Escape"===t.key&&(t.preventDefault(),e.onClose())},r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},a=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},i=()=>{e.isOpen&&e.onClose()};return Zn(()=>{window.addEventListener("keydown",n,!0),window.addEventListener("mousedown",r,!0),window.addEventListener("contextmenu",a,!0),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i,!0)}),o(()=>{window.removeEventListener("keydown",n,!0),window.removeEventListener("mousedown",r,!0),window.removeEventListener("contextmenu",a,!0),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i,!0)}),we(()=>{if(!e.isOpen||!t)return;const n=t.getBoundingClientRect(),o=Math.max(4,window.innerWidth-n.width-4),r=Math.max(4,window.innerHeight-n.height-4),a=Math.min(e.x,o),i=Math.min(e.y,r);t.style.left=`${a}px`,t.style.top=`${i}px`}),X(Ft,{get when(){return e.isOpen},get children(){var n=_d();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?zt(t,n):t=n,We(n,X(ee,{get each(){return e.items},children:t=>X(Ft,{get when(){return"separator"!==t.type},get fallback(){return Yd()},get children(){var n=qd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},We(n,X(Ft,{get when(){return t.icon},get fallback(){return e=Zd(),We(e,X(v,{size:16})),e;var e},get children(){var e=Xd();return fe(()=>le(e,"data-lucide",t.icon)),e}}),o),We(o,()=>t.label),We(n,X(Ft,{get when(){return t.shortcut},get children(){var e=Gd();return We(e,()=>t.shortcut),e}}),null),fe(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&le(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),fe(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&Re(n,"left",t.e=o),r!==t.t&&Re(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function Qd(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:c,paragraphDialog:d,setParagraphDialog:u,tablePropertiesDialog:p,setTablePropertiesDialog:g,newDocumentDialog:f,setNewDocumentDialog:m,revisionBulkDialog:h,setRevisionBulkDialog:b,symbolDialog:y,setSymbolDialog:v,equationDialog:x,setEquationDialog:w}=e.dialogs;return[X(Ad,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),X(Md,{get isOpen(){return h().isOpen},get action(){return h().action},get count(){return h().count},onClose:()=>{b({...h(),isOpen:!1}),e.focusInput()},onConfirm:()=>{const t=h().action;b({...h(),isOpen:!1}),e.applyBulkRevisions(t)}}),X(zd,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),X(jd,{get isOpen(){return x().isOpen},get initial(){return x().initial},onClose:()=>{w({isOpen:!1}),e.focusInput()},onApply:t=>{w({isOpen:!1}),e.applyEquation(t,x().targetRunId)}}),X(Rc,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),X(Bc,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),X(Ac,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),X(Oc,{get composer(){return e.commentComposer}}),X(Kd,{get fr(){return e.findReplace}}),X(td,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...s(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),X(pd,{get isOpen(){return d().isOpen},get initial(){return d().initial},onClose:()=>{u({...d(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyParagraphDialogValues},get onSetDefault(){return e.setParagraphDialogDefault}}),X(Rd,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),X(Jd,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}Ee(["contextmenu","click"]);var eu=/*#__PURE__*/f("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function tu(e){let t,n;const o=nt(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=je({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[X(Ft,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return X(t,{get state(){return n.state()},get toolbarHost(){return n.toolbarHost},get runtimeEditor(){return n.runtimeEditor},get persistenceStatus(){return n.persistenceStatus},get toolbarRegistry(){return n.toolbarRegistry},get menuRegistry(){return n.menuRegistry},get showChrome(){return o.showChrome()},get showTitleBar(){return o.showTitleBar()},get showMenubar(){return o.showMenubar()},get showToolbar(){return o.showToolbar()},get showOutline(){return o.showOutline},get toolbarView(){return o.toolbarView()},get toolbarLayout(){return o.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get documentLayout(){return r.documentLayout},get viewportHeight(){return r.viewportHeight},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),X(Ft,{get when(){return!e.useComposedShell()},get children(){return X(N,{get editor(){return e.runtime.runtimeEditor},get children(){var l=eu(),s=l.firstChild;return We(l,X(Ft,{get when(){return e.chrome.showOutline()},get children(){return X(Vo,{get state(){return e.runtime.state()},onNavigate:i,surfaceRef:()=>t,viewportRef:()=>n,get documentLayout(){return e.view.documentLayout},get zoomFactor(){return e.view.layout.zoomFactor},snapshotProvider:o})}}),s),We(s,X(U,{get state(){return e.runtime.state},get layout(){return{...e.view.layout,documentLayout:e.view.documentLayout,measuredBlockHeights:e.view.measuredBlockHeights,measuredParagraphLayouts:e.view.measuredParagraphLayouts,readOnly:e.view.isReadOnly()}},get overlays(){return{...e.view.overlays,toolbarHost:e.runtime.toolbarHost,persistenceStatus:e.runtime.persistenceStatus}},get refs(){return{...e.view.refs,onSurfaceRef:r,onViewportRef:a}},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),l}})}})]}var nu=/*#__PURE__*/f("<div class=oasis-editor-welcome-overlay role=dialog aria-modal=true aria-labelledby=oasis-editor-welcome-title><div class=oasis-editor-welcome-card><h2 id=oasis-editor-welcome-title class=oasis-editor-welcome-title></h2><p class=oasis-editor-welcome-body></p><p class=oasis-editor-welcome-note></p><div class=oasis-editor-welcome-actions>");function ou(e){const t=R(),n=()=>{wa(),_(),e.onClose()},o=()=>{Kt(!1),_(),e.onClose()};return X(Ft,{get when(){return e.isOpen},get children(){var e=nu(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return We(r,X(Tt,{height:72,class:"oasis-editor-welcome-mark"}),a),We(a,()=>t("welcome.title")),We(i,()=>t("welcome.body")),We(l,()=>t("welcome.note")),We(s,X(Qe,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),We(s,X(Qe,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var ru=/* @__PURE__ */Qo(It(),1),au=ea(),iu="word/comments.xml";function lu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function su(e){return e.localName??e.tagName}function cu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function du(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function uu(e){let t="";for(const n of lu(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===su(n)){t+=n.textContent??"";continue}if("tab"===su(n)){t+="\t";continue}if("br"===su(n)||"cr"===su(n)){t+="\n";continue}}t+=uu(n)}return t}function pu(e){return lu(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===su(e))}function gu(e){return pu(e).map(uu).join("\n").trim()}function fu(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===su(t)?t:void 0}function mu(e,t){const n=cu(pu(t)[0]??t,"paraId");for(;t.firstChild;)t.removeChild(t.firstChild);for(let r=0;r<e.childNodes.length;r+=1){const n=e.childNodes[r];n&&t.appendChild(n.cloneNode(!0))}const o=pu(t)[0];n&&o&&o.setAttributeNS(to,"w14:paraId",n)}function hu(e,t){const n=pu(e),o=pu(t);n[0]&&o[0]&&jn(n[0],o[0]);const r=new Set(lu(t).filter(e=>e.namespaceURI!==ur).map(e=>`${e.namespaceURI??""}\0${su(e)}`));for(const a of lu(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${su(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function bu(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/comments")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(iu);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=fu(e),o=fu(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of lu(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==su(i))continue;const e=cu(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of lu(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==su(i))continue;const e=cu(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new au.XMLSerializer).serializeToString(t);du(i,t),gu(i)===gu(t)?mu(i,t):hu(i,t),(new au.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(iu,a),!0)}var yu="http://schemas.microsoft.com/office/word/2012/wordml",vu="word/commentsExtended.xml";function xu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function wu(e){return e.localName??e.tagName}function Su(e){return`${e.namespaceURI??""}\0${wu(e)}`}function Cu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Iu(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function Tu(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function ku(e){const t=/* @__PURE__ */new Map,n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(ur,"comment"))){const e=Cu(o,"id"),n=o.getElementsByTagNameNS(ur,"p").item(0),r=n?Cu(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function Pu(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===yu&&"commentsEx"===wu(t)?t:void 0}function Ru(e,t,n){for(let r=0;r<e.attributes.length;r+=1){const o=e.attributes.item(r);if(!o)continue;const a=o.localName??o.name;"paraId"!==a&&((o.namespaceURI?t.hasAttributeNS(o.namespaceURI,a):t.hasAttribute(o.name))||Iu(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(xu(t).map(Su));for(const r of xu(e))o.has(Su(r))||t.appendChild(r.cloneNode(!0))}function Bu(e,t,n,o){const r=Pu(t),a=Pu(o);if(!r||!a)return o;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||Iu(t,o,o.value)}}(r,a);const i=ku(e),l=ku(n),s=/* @__PURE__ */new Map;for(const[p,g]of i){const e=l.get(p);e&&s.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of xu(e)){if(n.namespaceURI!==yu||"commentEx"!==wu(n))continue;const e=Cu(n,"paraId");e&&t.set(e,n)}return t}(a),d=xu(r),u=new Set(xu(a).filter(e=>!(e.namespaceURI===yu&&"commentEx"===wu(e))).map(Su));for(const p of d){if(p.namespaceURI===yu&&"commentEx"===wu(p)){const e=Cu(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&Ru(p,n,s);continue}u.has(Su(p))||(a.appendChild(p.cloneNode(!0)),u.add(Su(p)))}return(new au.XMLSerializer).serializeToString(a.ownerDocument)}var Au="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Mu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Fu(e){return e.localName??e.tagName}function Ou(e){return`${e.namespaceURI??""}\0${Fu(e)}`}function Du(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Eu(e,t){return Mu(e).find(e=>e.namespaceURI===Au&&Fu(e)===t)}function Lu(e,t){return e.filter(e=>e.namespaceURI===Au&&t.has(Fu(e)))}function Nu(e){if(e.namespaceURI!==Au)return;const t=Fu(e);if("p"===t){const t=Du(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Eu(e,"sdtPr"),n=t?Eu(t,"id"):void 0,o=n?Du(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function $u(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=(new au.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==Au||i.namespaceURI!==Au||Fu(a)!==n||Fu(i)!==n)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(a,i);const l=Mu(a),s=Mu(i),c=new Set(s.map(Ou));return l.forEach((e,t)=>{if(e.namespaceURI===Au||c.has(Ou(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>Ou(t)===Ou(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new au.XMLSerializer).serializeToString(r)}function zu(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=$u(e,t,n),a=(new au.DOMParser).parseFromString(e,"application/xml"),i=(new au.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==Au||s.namespaceURI!==Au||Fu(l)!==n||Fu(s)!==n)return r;const c=Mu(l),d=Mu(s),u=function(e,t,n){const o=Lu(e,n),r=Lu(t,n);return o.length===r.length&&o.every((e,t)=>Fu(e)===Fu(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Au||o.has(Fu(e)))return;const n=Ou(e),r=p.get(n)??0;if(p.set(n,r+1),Mu(s).filter(e=>Ou(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===Au&&o.has(Fu(e)));if(!a)return;const i=Nu(a);if(i){const e=Lu(n,o).find(e=>Nu(e)===i);if(e)return e}if(!r)return;const l=Lu(e,o),s=Lu(n,o),c=l.indexOf(a);return c>=0?s[c]:void 0}(c,t,d,o,u);(a||u)&&s.insertBefore(e.cloneNode(!0),a??null)}),(new au.XMLSerializer).serializeToString(i)}var Hu="word/document.xml",Wu=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Uu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function ju(e){return e.localName??e.tagName}function Vu(e){return`${e.namespaceURI??""}\0${ju(e)}`}function Ku(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function _u(e,t){return Uu(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ju(e)===t)}function Xu(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Wu.has(ju(e))}function Gu(e){return e.filter(Xu)}function qu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=ju(e);if("p"===t){const t=Ku(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=_u(e,"sdtPr"),n=t?Ku(_u(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Yu(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml"),o=(new au.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==r.namespaceURI||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==a.namespaceURI||"document"!==ju(r)||"document"!==ju(a))return t;!function(e,t){const n=Uu(e),o=_u(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===ju(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=Uu(t).find(t=>!i.has(t)&&Vu(t)===Vu(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=_u(r,"body"),l=_u(a,"body");if(!i||!l)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(i,l);const s=Uu(i),c=Uu(l),d=function(e,t){const n=Gu(e),o=Gu(t);return n.length===o.length&&n.every((e,t)=>ju(e)===ju(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if(Xu(e))return;const n=Vu(e),o=u.get(n)??0;if(u.set(n,o+1),Uu(l).filter(e=>Vu(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(Xu);if(!o)return;const r=qu(o);return r?Gu(n).find(e=>qu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=Gu(e),r=Gu(n),a=e.slice(t+1).find(Xu);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(s,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&l.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===ju(e))}(c)??null)}),(new au.XMLSerializer).serializeToString(o)}async function Zu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(Hu);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Yu(e,$u(e,t,"document"))}(n.data,r);return a!==r&&(t.file(Hu,a),!0)}var Ju="word/document.xml",Qu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ep(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function tp(e){const t=(new au.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Qu,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function np(e){const t=[];return tp(e).forEach((e,n)=>{const o=/* @__PURE__ */new Map;for(const r of function(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}(e)){const e=r.namespaceURI===Qu&&"headerReference"===r.localName?"header":r.namespaceURI===Qu&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=ep(r,"id");if(!a)continue;const i=ep(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),t.push({key:`${n}:${e}:${i}:${s}`,kind:e,relationshipId:a})}}),t}function op(e){return new Map(e.map(e=>[e.id,e]))}async function rp(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(Ju)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=tp(n.data),a=tp(o);if(r.length!==a.length)return!1;const i=np(n.data),l=np(o),s=new Map(i.map(e=>[e.key,e])),c=op(n.relationships??[]),d=op(await async function(e){const t=await(e.file(function(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}(Ju))?.async("string"));return An(Ju,fa(t))}(t));let u=!1;for(const p of l){const n=s.get(p.key);if(!n||n.kind!==p.kind)continue;const o=c.get(n.relationshipId),r=d.get(p.relationshipId);if("External"===o?.targetMode||"External"===r?.targetMode||!o?.resolvedTarget||!r?.resolvedTarget)continue;const a=e.parts[o.resolvedTarget];if("xml"!==a?.kind)continue;const i=r.resolvedTarget,l=await(t.file(i)?.async("string"));if(!l)continue;const g="header"===p.kind?"hdr":"ftr",f=zu(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var ap="word/document.xml",ip={"/styles":"word/styles.xml","/numbering":"word/numbering.xml","/settings":"word/settings.xml","/fontTable":"word/fontTable.xml","/theme":"word/theme/theme1.xml","/footnotes":"word/footnotes.xml","/endnotes":"word/endnotes.xml","/comments":"word/comments.xml","/commentsExtended":"word/commentsExtended.xml"},lp=["/officeDocument",...Object.keys(ip)];function sp(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function cp(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function dp(e){for(const[t,n]of Object.entries(ip))if(e.type.endsWith(t))return n}function up(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=so(e);return void 0===n?t.get(e)??e:null===n?e:cp(t.get(n)??n)}function pp(e,t){for(const[n,o]of t)if(o===e)return n;return e}function gp(e,t){if(null===e)return t;const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function fp(e,t){const n=e.parts[t];return"xml"===n?.kind?fa(n.data):[]}function mp(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:fp(e,ho):e.parts[t]?.relationships??fp(e,cp(t));return An(t,n)}function hp(e,t,n){return mp(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function bp(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,lp.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=An(n,[e])[0]?.resolvedTarget,c=l?.resolvedTarget??(s?r.get(s)??s:void 0);return c?{...e,...l?{id:l.id,type:l.type}:{},target:gp(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function yp(e,t,n){const o=[...t],r=new Map(t.map(e=>[e.id,e]));for(const a of e){const e=r.get(a.id);if(e){if(sp(e)===sp(a))continue;throw new Error(`Cannot safely preserve ${n}: relationship id ${a.id} is used by both the source package and rebuilt document for different targets.`)}o.push(a)}return o}function vp(e,t,n){const o=t.parts[n];o&&("base64"===o.encoding?e.file(n,o.data,{base64:!0}):e.file(n,o.data))}function xp(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===Wt(o))}async function wp(e,t){const n=e.sourcePackage;if(!n)return t;const o=await ru.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>hn(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(ap,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=dp(o);e&&t.set(e,o.resolvedTarget)}return t}(n),i=function(e,t,n){const o=/* @__PURE__ */new Set;for(const[r,a]of t)r!==ap&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new ru.default;for(const c of Object.keys(n.parts))vp(l,n,c);for(const c of i)l.remove(c),l.remove(cp(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=so(a);if(null==i)continue;const l=mp(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=pp(i,n);o.has(cp(c))||(0===s.length?e.remove(a):e.file(a,bt(s)))}}(l,n,a,r,i);let s=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=hn(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=up(e,a),o=so(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=hp(n,r,i),c=yp(s,bp(fa(await d.async("string")),s,e,r,a),t);l.file(t,bt(c));continue}const r=await d.async("uint8array");xp(n,e,t,r)||l.file(t,r)}return s&&l.file(Ko,function(e,t,n,o){const r=Xr(t),a={};for(const[l,s]of Object.entries(r.overrides))a[n.get(l)??l]=s;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return la({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,s,a,i)),l.generateAsync({type:"arraybuffer"})}var Sp="word/document.xml",Cp=["first","even","default"];function Ip(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function Tp(e,t){const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function kp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Pp(e,t){const n=[],o=e=>{for(const r of kp(e))r.localName===t&&n.push(r),o(r)};return o(e),n}function Rp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Bp(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return r.value!==n&&(e.setAttribute(r.name,n),!0)}return!1}function Ap(e){const t=(new au.DOMParser).parseFromString(e,"application/xml"),n=[],o=Pp(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of kp(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Rp(r,"id");if(!a)continue;const i=Rp(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),n.push({key:`${t}:${e}:${i}:${s}`,sectionIndex:t,kind:e,type:i,occurrence:s,relationshipId:a})}}),{references:n,sectionCount:o.length}}function Mp(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function Fp(e,t){const n=e.parts[t]?.relationships??fa(Mp(e,Ip(t)));return An(t,n)}function Op(e,t){const n=new Map(t.map(e=>[e.id,e]));return e.flatMap(e=>{const t=n.get(e.relationshipId);if(!t||"External"===t.targetMode||!t.resolvedTarget)return[];const o="header"===e.kind?"/header":"/footer";return t.type.endsWith(o)?[{...e,relationship:t,partPath:t.resolvedTarget}]:[]})}async function Dp(e,t){const n=Mp(e,e.mainDocumentPart),o=await(t.file(Sp)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=Ap(n),a=Ap(o),i=Op(r.references,Fp(e,e.mainDocumentPart));!function(e){const t=[...e].sort((e,t)=>{if(e.sectionIndex!==t.sectionIndex)return e.sectionIndex-t.sectionIndex;if(e.kind!==t.kind)return"header"===e.kind?-1:1;const n=Cp.indexOf(e.type),o=Cp.indexOf(t.type),r=n<0?99:n,a=o<0?99:o;return r!==a?r-a:e.type!==t.type?e.type.localeCompare(t.type):e.occurrence-t.occurrence});let n=1,o=1;for(const r of t)"header"===r.kind?(r.baselinePath=`word/header${n}.xml`,n+=1):(r.baselinePath=`word/footer${o}.xml`,o+=1)}(i);const l=Op(a.references,await async function(e,t){const n=await(e.file(Ip(t))?.async("string"));return An(t,fa(n))}(t,Sp)),s=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of l){const e=s.get(p.key);e&&(c.push({current:p,source:e}),d.add(e.partPath),u.set(p.relationshipId,e.relationship))}return{matches:c,deletedSourcePartPaths:r.sectionCount===a.sectionCount?new Set(i.map(e=>e.partPath).filter(e=>!d.has(e))):/* @__PURE__ */new Set,sourceRelationshipByCurrentId:u}}function Ep(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function Lp(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===Wt(await a.async("uint8array")):void 0===r}async function Np(e,t,n,o){for(const r of n)if(!(await Lp(e,t,o?Ip(r.current.partPath):r.current.partPath,r.source.baselinePath?o?Ip(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function $p(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?Ip(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?Wt(a):"<missing>")}if(o.size>1)throw new Error(`Cannot safely preserve shared header/footer part ${t[0].source.partPath}: its section projections diverged after editing.`)}async function zp(e,t,n){const o=await(e.file(Sp)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[Sp],a=Wt((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of Pp(n,r)){const n=Rp(e,"id"),r=n?t.get(n):void 0;r&&(o=Bp(e,"id",r.id)||o)}return o?(new au.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(Sp,t)}}const r=Ip(Sp),a=fa(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:Tp(Sp,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,bt(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(Ep(e)===Ep(r))continue;throw new Error(`Cannot safely preserve ${t}: relationship id ${r.id} is used for different targets.`)}o.set(r.id,r),n.push(r)}return n}(a,r)))}async function Hp(e,t,n){const o=n[0],r=o.source.partPath;if(!(await Np(e,t,n,!1))){await $p(e,n,!1);const t=await(e.file(o.current.partPath)?.async("uint8array"));if(!t)throw new Error(`Cannot preserve ${r}: rebuilt header/footer part is missing.`);e.file(r,t)}for(const c of n)c.current.partPath!==r&&e.remove(c.current.partPath);const a=Ip(r);if(!(await Np(e,t,n,!0))){await $p(e,n,!0);const t=Ip(o.current.partPath),c=await(e.file(t)?.async("string"));c&&e.file(a,bt((i=fa(c),l=o.current.partPath,s=r,i.map(e=>{if("External"===e.targetMode)return e;const t=An(l,[e])[0]?.resolvedTarget;return t?{...e,target:Tp(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=Ip(c.current.partPath);t!==a&&e.remove(t)}}async function Wp(e,t,n){for(const o of function(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=t.get(n.source.partPath)??[];e.push(n),t.set(n.source.partPath,e)}return t}(n.matches).values())await Hp(e,t,o)}async function Up(e,t){const n=e.sourcePackage;if(!n)return t;const o=await ru.default.loadAsync(t),r=await Dp(n,o);r.matches.length>0&&(await zp(o,n,r),await Wp(o,n,r),await async function(e,t){const n=await(e.file(Ko)?.async("string"));if(!n)return;const o=Xr(n);for(const r of t.matches){const e=o.overrides[r.current.partPath];e&&(o.overrides[r.source.partPath]=e),r.current.partPath!==r.source.partPath&&delete o.overrides[r.current.partPath]}e.file(Ko,la(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return wp(function(e,t){const n=e.sourcePackage;if(!n||0===t.size)return e;const o={defaults:{...n.contentTypes.defaults},overrides:Object.fromEntries(Object.entries(n.contentTypes.overrides).filter(([e])=>!t.has(e)))},r={...n.parts};for(const d of t)delete r[d],delete r[Ip(d)];const a=r[n.mainDocumentPart],i=Fp(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=Ip(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:bt(i)});const c=r[Ko];return c&&(r[Ko]={...c,data:la(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var jp=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],Vp=/* @__PURE__ */new Set(["p","tbl"]),Kp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function _p(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Xp(e){return e.localName??e.tagName}function Gp(e){return`${e.namespaceURI??""}\0${Xp(e)}`}function qp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Yp(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function Zp(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Xp(n)===t?n:void 0}function Jp(e){const t=qp(e,"type");if(t&&Kp.has(t))return`type:${t}`;const n=qp(e,"id");return n?`id:${n}`:void 0}function Qp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Vp.has(Xp(e))}function eg(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Xp(e))return;const t=qp(e,"paraId");return t?`p:${t}`:void 0}function tg(e,t){!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(e,t);const n=_p(e),o=_p(t),r=function(e,t){const n=e.filter(Qp),o=t.filter(Qp);return n.length===o.length&&n.every((e,t)=>Xp(e)===Xp(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Qp(e))return;const l=Gp(e),s=a.get(l)??0;if(a.set(l,s+1),_p(t).filter(e=>Gp(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Qp);if(!r)return;const a=eg(r);if(a){const e=n.filter(Qp).find(e=>eg(e)===a);if(e)return e}if(!o)return;const i=e.filter(Qp),l=n.filter(Qp),s=i.indexOf(r);return s>=0?l[s]:void 0}(n,i,o,r);("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||c||r)&&t.insertBefore(e.cloneNode(!0),c??null)})}function ng(e,t,n,o){const r=Zp(t,o.rootName),a=Zp(n,o.rootName);if(!r||!a)return n;const i=_p(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xp(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of _p(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Xp(c)!==o.entryName)continue;const e=Jp(c);e&&l.set(e,c)}const s=function(e,t){const n="footnote"===t?e.footnotes?.items:e.endnotes?.items,o=/* @__PURE__ */new Set;for(const r of Object.values(n??{}))void 0!==r.docxId&&Number.isSafeInteger(r.docxId)&&r.docxId>=1&&o.add(String(r.docxId));return o}(e,o.kind);for(const c of i){const e=Jp(c);if(!e)continue;const t=l.get(e),n=qp(c,"type");if(t){n&&Kp.has(n)?a.replaceChild(c.cloneNode(!0),t):tg(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=qp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new au.XMLSerializer).serializeToString(a.ownerDocument)}var og="http://schemas.openxmlformats.org/wordprocessingml/2006/main",rg="word/numbering.xml";function ag(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function ig(e){return e.localName??e.tagName}function lg(e){return`${e.namespaceURI??""}\0${ig(e)}`}function sg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function cg(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return void e.setAttribute(r.name,n)}e.setAttributeNS(og,`w:${t}`,n)}function dg(e,t){return ag(e).find(e=>e.namespaceURI===og&&ig(e)===t)}function ug(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function pg(e,t){const n=new Set(ag(t).map(lg));for(const o of ag(e))o.namespaceURI===og||n.has(lg(o))||t.appendChild(o.cloneNode(!0))}function gg(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}var fg=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function mg(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[lg(e),e]));n.forEach((e,r)=>{const a=lg(e),i=o.get(a),l=ig(e);if(i)return ug(e,i),void(e.namespaceURI===og&&"rPr"===l?function(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[lg(e),e]));n.forEach((e,r)=>{const a=lg(e),i=o.get(a);if(i)return ug(e,i),void pg(e,i);e.namespaceURI===og&&"rFonts"===ig(e)||gg(n,r,e,t,e=>o.get(lg(e)))})}(e,i):pg(e,i));if(e.namespaceURI!==og||!fg.has(l)){if(e.namespaceURI===og&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of ag(e))o.namespaceURI===og&&"rFonts"===ig(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}gg(n,r,e,t,e=>o.get(lg(e)))}})}function hg(e){return function(e){return e.namespaceURI===og&&"lvl"===ig(e)?`${lg(e)}\0${sg(e,"ilvl")??"0"}`:lg(e)}(e)}function bg(e,t,n){const o=dg(t,"abstractNumId"),r=o?sg(o,"val"):void 0;if(!r)return;const a=ag(e).find(e=>e.namespaceURI===og&&"abstractNum"===ig(e)&&sg(e,"abstractNumId")===r);return a?ag(a).find(e=>e.namespaceURI===og&&"lvl"===ig(e)&&(sg(e,"ilvl")??"0")===n):void 0}function yg(e,t){const n=t.cloneNode(!0);mg(e,n);const o=dg(e,"pPr"),r=dg(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function vg(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=sg(dg(t,"start")??t,"val")??"1";for(const r of ag(e)){const e=ig(r);if(r.namespaceURI===og&&"startOverride"===e){const e=r.cloneNode(!0);cg(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==og||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(yg(r,t))}return n}function xg(e){if(e.namespaceURI!==og)return lg(e);const t=ig(e);return"abstractNum"===t?`${lg(e)}\0${sg(e,"abstractNumId")??""}`:"num"===t?`${lg(e)}\0${sg(e,"numId")??""}`:lg(e)}function wg(e,t){const n=function(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new au.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===og&&o.namespaceURI===og&&"numbering"===ig(n)&&"numbering"===ig(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;ug(o,r);const a=ag(o),i=new Map(ag(r).map(e=>[xg(e),e]));return a.forEach((e,t)=>{const n=xg(e),o=i.get(n),l=ig(e);if(o)return ug(e,o),void(e.namespaceURI===og&&"abstractNum"===l?function(e,t){ug(e,t);const n=ag(e),o=new Map(ag(t).map(e=>[hg(e),e]));n.forEach((e,r)=>{const a=hg(e),i=o.get(a);if(i)return ug(e,i),void(e.namespaceURI===og&&"lvl"===ig(e)?mg(e,i):pg(e,i));gg(n,r,e,t,e=>o.get(hg(e)))})}(e,o):e.namespaceURI===og&&"num"===l?function(e,t,n){ug(e,t);const o=dg(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of ag(t))a.namespaceURI===og&&"lvlOverride"===ig(a)&&r.set(sg(a,"ilvl")??"0",a);for(const a of ag(e)){const e=ig(a);if(a.namespaceURI!==og||"abstractNumId"!==e){if(a.namespaceURI===og&&"lvlOverride"===e){const e=sg(a,"ilvl")??"0",o=vg(a,bg(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===og||ag(t).some(e=>lg(e)===lg(a))||t.appendChild(a.cloneNode(!0))}else o&&(ug(a,o),pg(a,o))}}(e,o,r):pg(e,o));gg(a,t,e,r,e=>i.get(xg(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}async function Sg(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/numbering")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(rg);if(!n||!o)return!1;const r=await o.async("string"),a=wg(n,r);return a!==r&&(t.file(rg,a),!0)}var Cg=[{relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootLocalName:"footnotes"},{relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootLocalName:"endnotes"},{relationshipSuffix:"/comments",rebuiltPath:"word/comments.xml",rootLocalName:"comments"}];function Ig(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var Tg="http://schemas.openxmlformats.org/wordprocessingml/2006/main",kg=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function Pg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Rg(e){return e.localName??e.tagName}function Bg(e){return`${e.namespaceURI??""}\0${Rg(e)}`}function Ag(e){const t=[],n=e=>{for(const o of Pg(e))o.namespaceURI===Tg&&"sectPr"===Rg(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function Mg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function Fg(e){return e.namespaceURI===Tg&&kg.has(Rg(e))}function Og(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml"),o=(new au.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=Ag(n),l=Ag(o);return 0===i.length||i.length!==l.length?t:(Mg(r,a),i.forEach((e,t)=>{!function(e,t){Mg(e,t);const n=Pg(e),o=Pg(t),r=/* @__PURE__ */new Map;for(const i of o){const e=Bg(i),t=r.get(e);t?t.push(i):r.set(e,[i])}const a=/* @__PURE__ */new Map;for(let i=0;i<n.length;i+=1){const e=n[i],o=Bg(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){Mg(e,s);continue}if(Fg(e))continue;const c=n.slice(i+1).map(e=>r.get(Bg(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new au.XMLSerializer).serializeToString(o))}var Dg="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Eg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Lg(e){return e.localName??e.tagName}function Ng(e,t){const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Dg&&Lg(n)===t?n:void 0}function $g(e){return Eg(e).length>0?(new au.XMLSerializer).serializeToString(e.ownerDocument):void 0}var zg=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),Hg=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Wg(e){const t=Ng(e,"settings");if(!t)return e;for(const n of[...Eg(t)]){if(n.namespaceURI!==Dg)continue;const e=Lg(n);if(zg.has(e)){t.removeChild(n);continue}const o=Hg.get(e);if(o){for(const e of[...Eg(n)])e.namespaceURI===Dg&&o.has(Lg(e))&&n.removeChild(e);0===Eg(n).length&&t.removeChild(n)}}return $g(t)}function Ug(e){const t=Ng(e,"styles");if(!t)return e;for(const n of[...Eg(t)])n.namespaceURI===Dg&&"style"===Lg(n)&&t.removeChild(n);return $g(t)}function jg(e){const t=Ng(e,"fonts");if(!t)return e;for(const n of[...Eg(t)])n.namespaceURI===Dg&&"font"===Lg(n)&&t.removeChild(n);return $g(t)}async function Vg(e,t,n){const o=e.file(t);if(!o)return!1;const r=await o.async("string"),a=n(r);return a!==r&&(void 0===a?e.remove(t):e.file(t,a),!0)}var Kg="word/styles.xml";function _g(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Xg(e){return e.localName??e.tagName}function Gg(e){return`${e.namespaceURI??""}\0${Xg(e)}`}function qg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Yg(e,t){return _g(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xg(e)===t)}function Zg(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Xg(e)?`${Gg(e)}\0${qg(e,"type")??""}`:Gg(e)}function Jg(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Xg(t)?t:void 0}function Qg(e,t){const n=Yg(e,"pPr");if(!n)return!1;const o=Yg(t,"pPr"),r=new au.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=rr(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Xg(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=_g(e),a=r.indexOf(n),i=_g(t),l=new Map(i.map(e=>[Zg(e),e])),s=r.slice(a+1).map(e=>l.get(Zg(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function ef(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(Kg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Jg(e),o=Jg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of _g(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xg(i))continue;const e=qg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of _g(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xg(i))continue;const e=qg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Qg(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Kg,a),!0)}function tf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function nf(e){return e.localName??e.tagName}function of(e){for(let t=0;t<e.attributes.length;t+=1){const n=e.attributes[t];if(n&&"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==n.namespaceURI&&"http://www.w3.org/2000/xmlns/"!==n.namespaceURI&&"xmlns"!==n.prefix&&"xmlns"!==n.name)return!0}return!1}function rf(e,t){const n=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===nf(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${ur}" xmlns:w14="${to}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};x(r,`<w:r xmlns:w="${ur}" xmlns:w14="${to}">${e}<w:t/></w:r>`);const a=function(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===nf(t)?t:void 0}(Br(r,o));if(!a)return t;let i=tf(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===nf(e));return!i&&of(n)&&(i=a.ownerDocument.createElementNS(ur,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(jn(n,i),0!==tf(i).length||of(i)?(new au.XMLSerializer).serializeToString(i):""):""}var af="word/styles.xml";function lf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function sf(e){return e.localName??e.tagName}function cf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function df(e,t){return lf(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&sf(e)===t)}function uf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===sf(t)?t:void 0}function pf(e,t){const n=df(e,"rPr");if(!n)return!1;const o=df(t,"rPr"),r=new au.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=rf(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===sf(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=lf(e),a=r.indexOf(n),i=lf(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&sf(t)===sf(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function gf(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(af);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=uf(e),o=uf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of lf(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==sf(i))continue;const e=cf(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of lf(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==sf(i))continue;const e=cf(i,"styleId"),t=e?r.get(e):void 0;t&&(a=pf(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(af,a),!0)}var ff="word/styles.xml",mf=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function hf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function bf(e){return e.localName??e.tagName}function yf(e){return`${e.namespaceURI??""}\0${bf(e)}`}function vf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function xf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function wf(e,t){return hf(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&bf(e)===t)}function Sf(e){return e?(new au.XMLSerializer).serializeToString(e):""}function Cf(e,t){if(!e)return;const n=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&bf(n)===t?n:void 0}function If(e,t,n){switch(e){case"pPr":return rr(t,n);case"rPr":return rf(t,n);case"tblPr":return $o(t,n);case"trPr":return Hr(t,n);case"tcPr":return Ln(t,n);default:return n}}function Tf(e,t,n,o){const r=hf(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&mf.has(bf(e)));return i?wf(t,bf(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===bf(e)&&mf.has(o)?hf(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===bf(e))??null:null}function kf(e,t,n){const o=wf(e,n);if(!o)return!1;const r=wf(t,n),a=Sf(r),i=If(n,Sf(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=Cf(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,Tf(e,t,o,n)),!0)}function Pf(e,t){xf(e,t);let n=!1;for(const r of mf)n=kf(e,t,r)||n;const o=new Set(hf(t).map(yf));for(const r of hf(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&mf.has(bf(r))||o.has(yf(r))||(t.appendChild(r.cloneNode(!0)),o.add(yf(r)),n=!0);return n}function Rf(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(ur,"w:tblStylePr");xf(e,n);let o=!1;for(const r of hf(e)){const e=bf(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&mf.has(e)){const t=Cf(If(e,Sf(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function Bf(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==bf(e))return;const t=vf(e,"type");return t?`tblStylePr:${t}`:void 0}function Af(e,t){let n=!1;n=kf(e,t,"tblPr")||n;const o=hf(e).filter(e=>void 0!==Bf(e)),r=/* @__PURE__ */new Map;for(const a of hf(t)){const e=Bf(a);e&&r.set(e,a)}for(const a of o){const o=Bf(a),i=r.get(o);if(i){n=Pf(a,i)||n;continue}const l=Rf(a);if(!l)continue;const s=hf(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==Bf(e)),u=d?r.get(Bf(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function Mf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===bf(t)?t:void 0}async function Ff(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(ff);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Mf(e),o=Mf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of hf(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===bf(i)){const e=vf(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of hf(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==bf(i))continue;if("table"!==vf(i,"type"))continue;const e=vf(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Af(i,t)||a)}return a?(new au.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(ff,a),!0)}var Of="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Df(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Ef(e){return e.localName??e.tagName}function Lf(e){return`${e.namespaceURI??""}\0${Ef(e)}`}function Nf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function $f(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function zf(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=(new au.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===Of&&i.namespaceURI===Of&&Ef(a)===n&&Ef(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Hf(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}function Wf(e,t){const n=new Set(Df(t).map(Lf));for(const o of Df(e))o.namespaceURI===Of||n.has(Lf(o))||t.appendChild(o.cloneNode(!0))}var Uf=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var jf=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Vf(e){return e.namespaceURI===Of&&"tblStylePr"===Ef(e)?`${Lf(e)}\0${Nf(e,"type")??""}`:Lf(e)}function Kf(e){return e.namespaceURI===Of&&"style"===Ef(e)?`${Lf(e)}\0${Nf(e,"styleId")??""}`:Lf(e)}var _f=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function Xf(e){return e.namespaceURI===Of&&"font"===Ef(e)?`${Lf(e)}\0${Nf(e,"name")??""}`:Lf(e)}var Gf=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=zf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]),i=Df(o),l=new Map(Df(r).map(e=>[Lf(e),e]));return i.forEach((e,t)=>{const n=Lf(e),o=l.get(n),s=Ef(e),c=e.namespaceURI===Of?a.get(s):void 0;if(o)return $f(e,o),void(c?function(e,t,n){$f(e,t);const o=Df(t),r=new Map(o.map(e=>[Lf(e),e])),a=Df(e);a.forEach((e,o)=>{const i=Lf(e),l=r.get(i);if(l)return $f(e,l),void Wf(e,l);e.namespaceURI===Of&&n.has(Ef(e))||Hf(a,o,e,t,e=>r.get(Lf(e)))})}(e,o,c):Wf(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Df(e))r.namespaceURI===Of&&t.has(Ef(r))||(n.appendChild(r.cloneNode(!0)),o=!0);return o?n:void 0}(e,c);if(n){const e=i.slice(t+1).map(e=>l.get(Lf(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===Of&&Uf.has(s)||Hf(i,t,e,r,e=>l.get(Lf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=zf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=Df(o),i=new Map(Df(r).map(e=>[Kf(e),e]));return a.forEach((e,t)=>{const n=Kf(e),o=i.get(n);if(o)return $f(e,o),void(e.namespaceURI===Of&&"style"===Ef(e)?function(e,t){$f(e,t);const n=Df(e),o=new Map(Df(t).map(e=>[Vf(e),e]));n.forEach((e,r)=>{const a=Vf(e),i=o.get(a);if(i)return $f(e,i),void Wf(e,i);e.namespaceURI===Of&&jf.has(Ef(e))||Hf(n,r,e,t,e=>o.get(Vf(e)))})}(e,o):Wf(e,o));Hf(a,t,e,r,e=>i.get(Kf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=zf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;$f(o,r);const a=Df(o),i=new Map(Df(r).map(e=>[Xf(e),e]));return a.forEach((e,t)=>{const n=Xf(e),o=i.get(n);if(o)return $f(e,o),void(e.namespaceURI===Of&&"font"===Ef(e)&&function(e,t){$f(e,t);const n=Df(e),o=new Map(Df(t).map(e=>[Lf(e),e]));n.forEach((e,r)=>{const a=Lf(e),i=o.get(a);i?$f(e,i):e.namespaceURI===Of&&_f.has(Ef(e))||Hf(n,r,e,t,e=>o.get(Lf(e)))})}(e,o));Hf(a,t,e,r,e=>i.get(Xf(e)))}),(new au.XMLSerializer).serializeToString(r.ownerDocument)}}];function qf(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var Yf="word/document.xml";function Zf(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS("*","sectPr");let n=0;for(let o=0;o<t.length;o+=1){const e=t.item(o),r=e?.parentNode;e&&"sectPrChange"!==r?.localName&&(n+=1)}return n}async function Jf(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return wp(e,t);const r=await ru.default.loadAsync(t),a=Boolean(r.file("word/numbering.xml")),i={settings:Boolean(r.file("word/settings.xml")),styles:Boolean(r.file("word/styles.xml")),fontTable:Boolean(r.file("word/fontTable.xml"))};let l=await async function(e,t){let n=!1;for(const o of Gf){const r=qf(e,o.relationshipSuffix);if(!r)continue;const a=t.file(o.rebuiltPath);if(!a){t.file(o.rebuiltPath,r),n=!0;continue}if(!o.merge)continue;const i=await a.async("string"),l=o.merge(r,i);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r);a&&(l=await Sg(n,r)||l),i.styles&&(l=await ef(n,r)||l,l=await gf(n,r)||l,l=await Ff(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await Vg(e,"word/settings.xml",Wg)||n),t.styles||(n=await Vg(e,"word/styles.xml",Ug)||n),t.fontTable||(n=await Vg(e,"word/fontTable.xml",jg)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of Cg){const r=Ig(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=$u(r,i,o.rootLocalName);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r)||l,l=await async function(e,t,n){let o=!1;for(const r of jp){const a=Yp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=ng(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await bu(n,r)||l,l=await async function(e,t){const n=Tu(e,"/comments"),o=Tu(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(vu);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=Bu(n,o,i,l);return s!==l&&(t.file(vu,s),!0)}(n,r)||l,l=await rp(n,r)||l,l=await Zu(n,r)||l;const s=await(r.file(Yf)?.async("string"));if(!s||Zf(o.data)!==Zf(s)){return wp(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=Og(o.data,s);c!==s&&(r.file(Yf,c),l=!0);return Up(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function Qf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function em(e){const t=(new au.DOMParser).parseFromString(e,"application/xml").documentElement;return t&&(t.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/customXml","itemID")??t.getAttribute("ds:itemID")??t.getAttribute("itemID"))?.trim()||null}function tm(e){const t=/^(([^:[]+):)?([^[]+?)(?:\[(\d+)\])?$/.exec(e);if(!t)return null;const n=t[4]?Number.parseInt(t[4],10):1;return!Number.isFinite(n)||n<1?null:{...t[2]?{prefix:t[2]}:{},localName:t[3],index:n}}function nm(e,t,n,o){if(e.localName!==n)return!1;if(!t)return!e.namespaceURI;const r=o.get(t);return void 0!==r&&e.namespaceURI===r}function om(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function rm(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=Qf(t);for(const o of Object.values(e.parts)){if("xml"!==o.kind||!/^customXml\/item\d+\.xml$/i.test(o.path))continue;const t=(o.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/customXmlProps")&&e.resolvedTarget))?.resolvedTarget;if(!t)continue;const r=e.parts[t];if(!r||"xml"!==r.kind)continue;const a=em(r.data);if(a&&Qf(a)===n)return{storeItemId:a,itemPartPath:o.path,itemPropsPartPath:t,xml:o.data}}return null}(e,t.storeItemID);if(!o)return!1;const r=function(e,t,n){const o=(new au.DOMParser).parseFromString(e,"application/xml"),r=o.documentElement;if(!r)return null;const a=t.trim().replace(/\/text\(\)$/,"");if(!a.startsWith("/")||a.startsWith("//"))return null;const i=a.split("/").filter(Boolean);if(0===i.length)return null;const l=i.at(-1)?.startsWith("@")?i.pop():null,s=tm(i[0]);if(!s||1!==s.index)return null;if(!nm(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=tm(i[m]);if(!e)return null;const t=om(c).filter(t=>nm(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!l)return{document:o,element:c};const d=l.slice(1),u=d.indexOf(":");if(u<0)return{document:o,element:c,attribute:{localName:d,qualifiedName:d}};const p=d.slice(0,u),g=d.slice(u+1),f=n.get(p);return f?{document:o,element:c,attribute:{namespaceUri:f,localName:g,qualifiedName:`${p}:${g}`}}:null}(o.xml,t.xpath,function(e){const t=/* @__PURE__ */new Map;if(!e)return t;for(const n of e.matchAll(/xmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])(.*?)\2/g))t.set(n[1],n[3]);return t}(t.prefixMappings));if(!r)return!1;if(r.attribute)r.attribute.namespaceUri?r.element.setAttributeNS(r.attribute.namespaceUri,r.attribute.qualifiedName,n):r.element.setAttribute(r.attribute.localName,n);else{if(om(r.element).length>0)return!1;for(;r.element.firstChild;)r.element.removeChild(r.element.firstChild);r.element.appendChild(r.document.createTextNode(n))}const a=e.parts[o.itemPartPath];return!!a&&(a.data=(new au.XMLSerializer).serializeToString(r.document),!0)}function am(e,t,n,o){if(!t.sdtPr.dataBinding)return;const r=e.get(t.groupId);r?r.value+=`${o}${n}`:e.set(t.groupId,{wrapper:t,value:n})}function im(e){return e.blocks.map(sm).filter(Boolean).join("\n")}function lm(e){return e.cells.map(im).filter(Boolean).join("\t")}function sm(e){return"paragraph"===e.type?Lt(e):e.rows.map(lm).filter(Boolean).join("\n")}function cm(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])am(t,e,n.text,"");"textBox"===n.kind&&um(n.textBox.blocks,t)}}function dm(e,t){for(const n of e.rows){const e=lm(n);for(const o of n.sdtWrappers??[])am(t,o,e,"\n");for(const o of n.cells){const e=im(o);for(const n of o.sdtWrappers??[])am(t,n,e,"\n");um(o.blocks,t)}}}function um(e,t){if(e)for(const n of e){const e=sm(n);for(const o of n.sdtWrappers??[])am(t,o,e,"\n");"paragraph"===n.type?cm(n,t):dm(n,t)}}async function pm(e){if(!e.sourcePackage)return ne(e);const t={...e,sourcePackage:(n=e.sourcePackage,{...n,contentTypes:{defaults:{...n.contentTypes.defaults},overrides:{...n.contentTypes.overrides}},rootRelationships:n.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(n.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...n.diagnostics?{diagnostics:n.diagnostics.map(e=>({...e}))}:{},...n.rebuiltPartHashes?{rebuiltPartHashes:{...n.rebuiltPartHashes}}:{}})};var n;!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of $e(e))um(o.blocks,t),um(o.header,t),um(o.firstPageHeader,t),um(o.evenPageHeader,t),um(o.footer,t),um(o.firstPageFooter,t),um(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&rm(e.sourcePackage,t,r)&&(n+=1)}}(t);return Jf(t,await ne(t))}async function gm(e){if(!e.sourcePackage)return Dt(e);const t=await pm(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function fm(e){switch(e){case"dashed":return[tn(5),tn(3)];case"dotted":return[tn(1),tn(3)];default:return}}async function mm(e,t,n,o,r,a,i,l){const s=t.rotation;s&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,tn(o+a/2),tn(r+i/2),s)),function(e,t,n,o,r,a,i){const l=at(n.shape?.preset,tn(o),tn(r),tn(a),tn(i)),s=n.shape?.fill,c=n.shape?.borderColor,d=n.shape?.borderWidthPt??(c?.75:0);e.drawPath(t,{segments:l,fill:s,stroke:c&&d>0?c:void 0,lineWidth:d})}(e,n.pageIndex,t,o,r,a,i),await async function(e,t,n,o,r,a,i,l){if(0===t.blocks.length)return;const s=function(e){return{left:e.body?.paddingLeft??0,top:e.body?.paddingTop??0,right:e.body?.paddingRight??0,bottom:e.body?.paddingBottom??0}}(t),c=o+s.left,d=r+s.top,u=Math.max(1,a-s.left-s.right),p=Math.max(1,i-s.top-s.bottom),g=$n({blocks:t.blocks,pageSettings:{width:u,height:p,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:p,styles:n.document.styles,pageOffset:n.pageIndex})[0]?.blocks??[];if(0===g.length)return;const f=mt(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,tn(c),tn(d),tn(u),tn(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await l.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,l);break;case"table":await l.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,l);break;default:Zo(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,o,r,a,i,l),s&&e.restoreGraphicsState(n.pageIndex)}async function hm(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const p of a){const a=new Map(p.slots.map(e=>[e.offset,e]));for(const g of p.fragments){const f=g.textBox;if(!f?.floating)continue;const m=Boolean(f.floating.behindDoc);if(e.layer&&"behind"===e.layer!==m)continue;const h=l+(a.get(g.startOffset)?.left??0),b=d+p.top,y=oo({object:Kn(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await mm(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var bm=/* @__PURE__ */new WeakMap;function ym(e){const t=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(e);if(!t)return null;const n=t[1].toLowerCase(),o=Boolean(t[2]),r=t[3]??"";if(!o)return{mediaType:n,data:(new TextEncoder).encode(decodeURIComponent(r))};const a="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:n,data:Uint8Array.from(a,e=>e.charCodeAt(0))}}async function vm(e,t,n){let o=e;o.startsWith("data:")||(o=await async function(e){if("function"!=typeof fetch)return null;const t=await fetch(e);if(!t.ok)return null;const n=await t.blob(),o=new Uint8Array(await n.arrayBuffer()),r=Array.from(o,e=>String.fromCharCode(e)).join(""),a="function"==typeof btoa?btoa(r):Buffer.from(o).toString("base64");return`data:${n.type||"application/octet-stream"};base64,${a}`}(o)??o);let r=ym(o);if(!r)return null;const a="undefined"!=typeof Image?await async function(e){return"undefined"==typeof Image?null:await new Promise(t=>{const n=new Image;n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}(o):null,i=null!=a&&a.naturalWidth>0&&a.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const e=function(e){if("undefined"==typeof document)return null;const t=document.createElement("canvas");t.width=e.naturalWidth,t.height=e.naturalHeight;const n=t.getContext("2d");return n?(n.fillStyle="#ffffff",n.fillRect(0,0,t.width,t.height),n.drawImage(e,0,0),t.toDataURL("image/jpeg",.92)):null}(a);if(r=e?ym(e):null,!r)return null}const l=i?a.naturalWidth:t,s=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function xm(e,t,n){const o=Ze(t,n.src);if(!o)return null;let r=bm.get(e);r||(r=/* @__PURE__ */new Map,bm.set(e,r));const a=r.get(o);if(a)return a;const i=vm(o,n.width,n.height).then(t=>t?e.registerImageResource({width:t.width,height:t.height,data:t.data,filter:"DCTDecode"}):null);return r.set(o,i),i}async function wm(e,t,n,o,r,a,i,l){const s=await xm(e,n,o);if(!s)return;const c=o.intrinsicWidth??o.width,d=o.intrinsicHeight??o.height,u=c/Math.max(1,d),p=i/Math.max(1,l);let g=r,f=a,m=i,h=l;"fit"===o.cropFit&&u>0&&(u>p?(h=i/u,f+=(l-h)/2):(m=l*u,g+=(i-m)/2));const b="fill"!==o.cropFit||o.crop?o.crop:(()=>{if(u>p){const e=p/u,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(u<p){const e=u/p,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),y=o.cropShape?.preset,v=y?function(e,t,n,o,r,a){if(!a)return e;const i=t+o/2,l=n+r/2,s=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(s)-(t-l)*Math.sin(s),y:l+(e-i)*Math.sin(s)+(t-l)*Math.cos(s)});return e.map(e=>{if("close"===e.type)return e;if("cubic"===e.type){const t=c(e.x1,e.y1),n=c(e.x2,e.y2),o=c(e.x,e.y);return{type:"cubic",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:o.x,y:o.y}}const t=c(e.x,e.y);return{type:e.type,x:t.x,y:t.y}})}(at(y,r,a,i,l),r,a,i,l,o.rotation??0):null,x=o.transparency??0,w="fit"===o.cropFit&&Boolean(o.rotation);v&&(e.saveGraphicsState(t),e.clipPath(t,v)),w&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,o.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:s,x:g,y:f,width:m,height:h,rotation:w?void 0:o.rotation,crop:b}),x>0&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t),v&&e.restoreGraphicsState(t);const S=o.border;if(!S)return;const C=o.rotation;C&&!v&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,C));const I=Xn(S.dash);v?e.drawPath(t,{segments:v,stroke:S.color,lineWidth:S.widthPt??1}):e.drawRect(t,{x:r,y:a,width:i,height:l,stroke:S.color,lineWidth:S.widthPt??1,...I.length>0?{dashArray:I}:{}}),C&&!v&&e.restoreGraphicsState(t)}function Sm(e,t){const n=new Map(e.slots.map(e=>[e.offset,e])),o=[];for(const r of t.chars){if("\n"===r.char||"\t"===r.char)continue;const e=n.get(r.paragraphOffset);e&&o.push({char:r.char,left:e.left,offset:r.paragraphOffset})}return o}function Cm(e,t,n){const o=Sm(e,t);if(0===o.length)return null;const r=new Map(e.slots.map(e=>[e.offset,e])),a=o[0],i=o[o.length-1],l=r.get(i.offset+1);return{left:a.left,right:l?.left??i.left+.55*n}}function Im(e,t,n,o,r,a,i){const l=Cm(e,t,n.fontSize??14.6667);return l?{x:tn(o+l.left),y:tn(r+e.top+a),width:tn(Math.max(0,l.right-l.left)),height:tn(Math.max(2,e.height-i))}:null}function Tm(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=Cm(n,o,i.fontSize??14.6667);if(!s)return;const c=r+s.left,d=r+s.right,u=a+n.top,p=a+n.top+n.height,g=rn(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:tn(g.x0),y0:tn(g.y0),x1:tn(g.x1),y1:tn(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function km(e,t,n,o,r,a,i){const l=Vt(i),s=(r,i)=>{e.drawLine(t,{x1:tn(n),y1:tn(r),x2:tn(o),y2:tn(r),stroke:a,lineWidth:tn(l),dashArray:i})};if(p(i))return s(r-yr),void s(r+yr);Nt(i)?function(e,t,n,o,r,a,i){let l=n,s=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*xa;e.drawLine(t,{x1:tn(l),y1:tn(s),x2:tn(c),y2:tn(o),stroke:a,lineWidth:tn(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,At(i))}function Pm(e,t){const n=or(Sn(e));if(!n)return e;const o=Math.max(0,Math.min(1,t));return Rr(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function Rm(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=tn(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:tn(t)+u*e,y:tn(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*tn(e.radiusPt*Nn),l=Pm(e.color,.4*(e.alpha??.5)),s=[[i,0],[-i,0],[0,i],[0,-i],[.7*i,.7*i],[.7*-i,.7*i],[.7*i,.7*-i],[.7*-i,.7*-i]];for(const[c,u]of s)o.drawText(r,{...d,x:tn(t)+c,y:tn(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=tn(e.distPt*Nn);o.drawText(r,{...d,x:tn(t)+Math.cos(i)*l,y:tn(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:tn(t)+u,y:tn(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=Pm(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:tn(t),y:tn(a)+tn(e.distPt*Nn)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:tn(t),y:tn(a),text:n,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function Bm(e){for(const t of e.lines){const n=new Map(t.slots.map(e=>[e.offset,e]));for(const o of t.fragments){const r=o.image;if(!r?.floating)continue;const a=Boolean(r.floating.behindDoc);if("behind"===e.layer!==a)continue;const i=n.get(o.startOffset),l=oo({object:Ur(r),pageSettings:e.pageSettings,contentLeft:e.contentLeft,contentTop:e.contentTop,contentWidth:e.contentWidth,paragraphTop:e.paragraphTop,lineTop:e.paragraphTop+t.top,anchorLeft:e.contentLeft+(i?.left??0)});await wm(e.writer,e.pageIndex,e.document,r,tn(l.x),tn(l.y),tn(l.width),tn(l.height))}}}function Am(e,t,n,o,r,a,i,l){const s=Cm(n,o,i.fontSize??14.6667);if(!s)return;const c=a+ge(l,n.top,n.height),d=r+s.left,u=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(e.drawLine(t,{x1:tn(d),y1:tn(c-xe),x2:tn(u),y2:tn(c-xe),stroke:p,lineWidth:tn(1)}),void e.drawLine(t,{x1:tn(d),y1:tn(c+xe),x2:tn(u),y2:tn(c+xe),stroke:p,lineWidth:tn(1)})):void km(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:tn(d),y1:tn(c),x2:tn(u),y2:tn(c),stroke:p,lineWidth:tn(1)})}async function Mm(e,t,n,o,r,a,i,l,s,c){if(r.image){if(r.image.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await wm(e,t,a,r.image,tn(i+n.left),tn(l+o.top+o.height-r.image.height),tn(r.image.width),tn(r.image.height)))}if(r.textBox){if(r.textBox.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await mm(e,r.textBox,{document:a,fontRegistry:s,pageIndex:t},i+n.left,l+o.top+o.height-r.textBox.height,r.textBox.width,r.textBox.height,c))}if(r.math){const c=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!c)return;const d=Te(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:tn(i+c.left),y:tn(l+o.top+o.height*Ue),text:na(r.math),fontSize:qt(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=Te(r.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=s.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=qt(d),g=(d.baselineShift??0)*Nn,f=re(n.style,a.styles),m=W(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*Ue-g+m,b=Sm(o,r),y=b.map(e=>qe(e.char,d)).join("");if(!b[0]||0===y.length)return;!function(e,t,n,o,r,a,i){if(!i.link)return;const l=Cm(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:tn(r+l.left),y:tn(a+n.top),width:tn(l.right-l.left),height:tn(n.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.shading)return;const l=Im(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.shading})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.highlight)return;const l=Im(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.highlight})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=Im(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:tn(Math.max(.5,l.width*Nn))})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i,l,s){const c=new Map(o.slots.map(e=>[e.offset,e])),d=re(n.style,a.styles).tabs??[];for(const u of r.chars){if("\t"!==u.char)continue;const n=c.get(u.paragraphOffset),r=c.get(u.paragraphOffset+1);if(!n||!r)continue;const a=o.slots[0]?.left??0,p=n.left-a,g=d.filter(e=>"clear"!==e.type).map(e=>({...e,positionPx:e.position*Nn})).filter(e=>e.positionPx>p+.01).sort((e,t)=>e.positionPx-t.positionPx)[0],f=g?.leader&&"none"!==g.leader?g.leader:void 0;if(!f)continue;const m="underscore"===f?l+2:l;e.drawLine(t,{x1:tn(i+n.left),y1:tn(m),x2:tn(i+r.left),y2:tn(m),stroke:s,lineWidth:tn("heavy"===f?1.5:1),dashArray:"dot"===f||"middleDot"===f?[1,3]:"hyphen"===f?[5,3]:void 0})}}(e,t,n,o,r,a,i,h,d.color??"#000000");const v=re(n.style,a.styles).align??"left",x=J(d,qt(d)),w={fontSize:p,bold:d.bold,italic:d.italic,fontResourceName:u.writerResourceName,characterSpacing:d.characterSpacing??0,horizontalScale:d.characterScale??100,fontFeatures:x};!function(e,t,n,o,r,a,i){const l="justify"===i?function(e){const t=[];let n=[];for(const o of e)" "!==o.char?n.push(o):n.length>0&&(t.push(n),n=[]);return n.length>0&&t.push(n),t}(t):function(e){const t=[];let n=[];for(const o of e){const e=n[n.length-1];e&&o.offset>e.offset+1&&(t.push(n),n=[]),n.push(o)}return n.length>0&&t.push(n),t}(t);for(const s of l){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>qe(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;Rm({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&B(e.char));t.length>0&&n!==r&&a(),r=n,t.push(e)}a()}if(r.trailingHyphen&&a.endOffset>=r.endOffset){const t=r.slots.find(e=>e.offset===r.endOffset)??r.slots[r.slots.length-1];t&&Rm(e,n+t.left,"-")}}({writer:e,pageIndex:t,baselineY:h,fontSizePt:p,mainColor:"solid"===d.textFill?.type?d.textFill.color:"gradient"===d.textFill?.type&&d.textFill.stops[0]?d.textFill.stops[0].color:d.color??"#000000",gradientShadingName:Tm(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&Am(e,t,o,r,i,l,d,"underline"),d.strike&&Am(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&Am(e,t,o,r,i,l,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,o,r,a,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=dt[l];if(!s)return;const c=Sm(n,o),d="underDot"===l,u=Math.max(4,.35*n.height),p=d?a+n.top+n.height+u:a+n.top+u;for(let g=0;g<c.length;g+=1){const o=c[g];if(" "===o.char||"\t"===o.char||"\n"===o.char)continue;const a=c[g+1],l=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:tn(r+l-.25*u),y:tn(p),text:s,fontSize:tn(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function Fm(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=y(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=Te(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=S(n,r.styles),f=qt(u),m=c.length*f*.62*Nn,h=vt(n,r.styles,d.left,m);e.drawText(t,{x:tn(a+Math.max(0,h||g)),y:tn(i+o.top+o.height*Ue),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Om(e,t,n,o,r,a,i){const l=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],s=l.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!s)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=se(n),u=d.top+c+d.bottom,p=r+(n.indentLeft??0),g=r+i-(n.indentRight??0),f=a+u;n.shading&&e.drawRect(t,{x:tn(p),y:tn(a),width:tn(Math.max(0,g-p)),height:tn(u),fill:n.shading});for(const[h,b]of l){if(!h||"none"===h.type||h.width<=0)continue;const[n,o,r,i]="top"===b?[p,a,g,a]:"bottom"===b?[p,f,g,f]:"left"===b?[p,a,p,f]:[g,a,g,f];e.drawLine(t,{x1:tn(n),y1:tn(o),x2:tn(r),y2:tn(i),stroke:h.color,lineWidth:h.width,dashArray:fm(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:tn(p),y1:tn(a),x2:tn(p),y2:tn(f),stroke:m.color,lineWidth:m.width,dashArray:fm(m.type)})}async function Dm(e,t,n,o,r,a,i,l,s,c){for(const d of o){Fm(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await Mm(e,t,n,d,o,r,a,i,l,c)}}function Em(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:tn(o),y1:tn(r),x2:tn(a),y2:tn(i),stroke:n.color,lineWidth:tn(n.width),dashArray:fm(n.type)})}function Lm(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;Em(e,t,n.borders.top,a,i,l,i),Em(e,t,n.borders.right,l,i,l,s),Em(e,t,n.borders.bottom,a,s,l,s),Em(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&Em(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&Em(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function Nm(e,t,o,r,a,i,l,s,c,d){if("table"!==o.sourceBlock.type)return;const u=o.sourceBlock,p=o.tableSegment?me(u,o.tableSegment):u;if(0===p.rows.length)return;const g=n({table:p,state:{document:r},pageIndex:0,originX:0,originY:0,contentWidth:l,estimatedHeight:o.estimatedHeight});for(const n of g.cells)n.shading&&e.drawRect(t,{x:tn(a+n.left),y:tn(i+n.top),width:tn(n.width),height:tn(n.height),fill:n.shading});for(const n of g.cells)if(Lm(e,t,n,a,i),n.revision){const o="insert"===n.revision.type?"#059669":"delete"===n.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:tn(a+n.left+1),y:tn(i+n.top+1),width:tn(Math.max(0,n.width-2)),height:tn(Math.max(0,n.height-2)),stroke:o,lineWidth:tn(2)})}for(const n of g.cells)for(const o of n.paragraphs)await Dm(e,t,o.paragraph,o.lines,r,a+o.originX,i+o.originY,s,c,d)}var $m={drawParagraph:Dm,drawTableBlock:Nm};async function zm(e,t,n,o,r,a,i,l,s,c,d){if(!n||0===n.length)return;const u=a;let p=a;for(let g=0;g<n.length;g+=1){const f=n[g];switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const n=re(f.sourceBlock.style,o.styles),g=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0);d?.(f.sourceBlock.id,g);const m=g+se(n).top;Om(e,t,n,f.layout.lines,r,g,i),c&&(await Bm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await hm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:$m,layer:"behind"})),await Dm(e,t,f.sourceBlock,f.layout.lines,o,r,m,l,s,$m),c&&(await Bm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await hm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:$m,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Yn(f.sourceBlock,i),a=gr({floating:f.sourceBlock.style.floating,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,anchorTop:p,width:n,height:f.floatingTableHeight??1,pageIndex:t});a.y+=f.floatingTableOffsetY??0,await Nm(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,l,s,$m);break}await Nm(e,t,f,o,r,p,i,l,s,$m);break;default:Zo(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const l=n[g+1];if("paragraph"===l?.sourceBlock.type&&l.layout&&l.sourceBlock.id!==f.sourceBlock.id){const n=re(f.sourceBlock.style,o.styles),s=re(l.sourceBlock.style,o.styles);if(Be(n,s)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+se(n).top;let l=0;for(const e of f.layout.lines)l=Math.max(l,e.top+e.height);const s=o+l,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:tn(c),y1:tn(s),x2:tn(d),y2:tn(s),stroke:u.color,lineWidth:u.width,dashArray:fm(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function Hm(e,t,n,o,r,a,i){if(e.drawRect(t,{x:0,y:0,width:n,height:o,fill:r?.pageColor||"#ffffff"}),a){const r=a.distance??12,i="dashed"===a.style?[6,4]:"dotted"===a.style?[1,3]:void 0;if(e.drawRect(t,{x:r,y:r,width:n-2*r,height:o-2*r,fill:void 0,stroke:a.color,lineWidth:a.width,...i?{dashArray:i}:{}}),"double"===a.style){const i=r+2*a.width;e.drawRect(t,{x:i,y:i,width:n-2*i,height:o-2*i,stroke:a.color,lineWidth:a.width})}}const l=r?.watermark;if("text"===l?.kind&&l.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:l.text,fontSize:l.fontSize??48,color:l.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===l?.kind&&l.src&&i){const r={src:l.src,width:360,height:180},a=await xm(e,i,r);if(a){const i=l.scale??1,s=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-s)/2,y:(o-c)/2,width:s,height:c}),e.restoreGraphicsState(t)}}}var Wm=[{key:"helvetica:regular",family:"Helvetica",bold:!1,italic:!1,writerResourceName:"F1",pdfResource:{kind:"base14",resourceName:"F1",baseFont:"Helvetica"}},{key:"helvetica:bold",family:"Helvetica",bold:!0,italic:!1,writerResourceName:"F2",pdfResource:{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"}},{key:"helvetica:italic",family:"Helvetica",bold:!1,italic:!0,writerResourceName:"F3",pdfResource:{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"}},{key:"helvetica:bolditalic",family:"Helvetica",bold:!0,italic:!0,writerResourceName:"F4",pdfResource:{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}}];function Um(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function jm(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Vm=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Wm)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Um(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=Xt(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(Um(t,n,o))??this.faces.get(Um(this.fallbackFamily,n,o))??this.faces.get(Um(this.fallbackFamily,!1,!1))}getPdfFontResources(){const e=/* @__PURE__ */new Map;for(const t of this.faces.values())e.set(t.pdfResource.resourceName,t.pdfResource);return Array.from(e.values())}async loadBundledUnicodeFaces(e={}){const t=e.families?new Set(Array.from(e.families).map(Xt).map(e=>e.toLowerCase())):null,n=await this.registerOfficeCompatibleFaces(t);if(!t||t.has("roboto")||Array.from(t).some(e=>"helvetica"!==e&&!n.has(e)))for(const[o,r]of Object.entries(te)){const e=await Ot(r);if(!e)continue;const t="bold"===o||"bolditalic"===o,n="italic"===o||"bolditalic"===o,a=`Roboto${o[0].toUpperCase()}${o.slice(1)}`;this.registerFontFace({key:`roboto:${o}`,family:"Roboto",bold:t,italic:n,writerResourceName:a,pdfResource:{kind:"unicode",resourceName:a,family:"Roboto",fontData:e}}),this.fallbackFamily="Roboto"}}async loadRemoteWebFontFaces(e={}){if(!e.families)return;const t=await Eo(e.families);for(const n of t){const e=`Remote${jm(n.postscriptName||n.family)}`;this.registerFontFace({key:Um(n.family,n.bold,n.italic),family:n.family,bold:n.bold,italic:n.italic,writerResourceName:e,pdfResource:{kind:"unicode",resourceName:e,family:n.family,fontData:n.fontData,postscriptName:n.postscriptName}})}}async registerOfficeCompatibleFaces(e){const t=/* @__PURE__ */new Set;for(const n of Ht){const o=[n.family,...n.aliases].map(e=>e.toLowerCase());if(e&&!o.some(t=>e.has(t)))continue;for(const e of o)t.add(e);const r=[];for(const[e,t]of Object.entries(n.files)){const o=await Ot(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${jm(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,s={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:n.family,fontData:o}};this.registerFontFace(s),r.push(s)}for(const e of n.aliases)for(const t of r)this.registerFontFace({...t,key:`${e.toLowerCase()}:${t.key.split(":")[1]}`,family:e})}return t}},Km="%PDF-1.4\n% Oasis PDF\n",_m=[{kind:"base14",resourceName:"F1",baseFont:"Helvetica"},{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"},{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"},{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}];function Xm(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function Gm(e){return(new TextEncoder).encode(e).byteLength}function qm(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function Ym(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Zm(e,t){if(!e)return t;const n=or(Sn(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Jm(e,t,n){const[o,r,a]=Zm(e,n);return`${Xm(o)} ${Xm(r)} ${Xm(a)} ${t}`}function Qm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var eh=/* @__PURE__ */new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]);function th(e){return Array.from(e).map(e=>function(e){const t=e.codePointAt(0)??63;return t>=32&&t<=126||t>=160&&t<=255?t:eh.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function nh(e){const t=[];for(let n of e)n>65535?(n-=65536,t.push(n>>>10&1023|55296),t.push(1023&n|56320)):t.push(n);return t.map(Ym).join("")}function oh(e){return Ym(e)}function rh(e){return`% OasisText ${nh(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function ah(e){return e&&0!==e.length?`[${e.map(e=>Xm(e)).join(" ")}] 0 d`:null}var ih=class{page;fonts;images;shadings;constructor(e,t,n,o){this.page=e,this.fonts=t,this.images=n,this.shadings=o}registerAxialGradient(e){const t=this.shadings.register({x0:e.x0,y0:this.page.height-e.y0,x1:e.x1,y1:this.page.height-e.y1,stops:e.stops});return this.page.shadingResourceNames.add(t),t}drawRect(e){const t=this.page;if(e.width<=0||e.height<=0)return;const n=["q"];if(e.fill&&n.push(Jm(e.fill,"rg",[1,1,1])),e.stroke){n.push(Jm(e.stroke,"RG",[0,0,0])),n.push(`${Xm(e.lineWidth??1)} w`);const t=ah(e.dashArray);t&&n.push(t)}n.push([Xm(e.x),Xm(t.height-e.y-e.height),Xm(e.width),Xm(e.height),"re"].join(" ")),e.fill&&e.stroke?n.push("B"):e.fill?n.push("f"):e.stroke&&n.push("S"),n.push("Q"),t.commands.push(n.join("\n"))}drawLine(e){const t=this.page,n=ah(e.dashArray),o=["q",Jm(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${Xm(e.lineWidth??1)} w`,`${Xm(e.x1)} ${Xm(t.height-e.y1)} m`,`${Xm(e.x2)} ${Xm(t.height-e.y2)} l`,"S","Q"),t.commands.push(o.join("\n"))}drawPath(e){const t=this.page;if(0===e.segments.length)return;if(!e.fill&&!e.stroke)return;const n=e=>t.height-e,o=["q"];e.fill&&o.push(Jm(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(Jm(e.stroke,"RG",[0,0,0])),o.push(`${Xm(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${Xm(r.x)} ${Xm(n(r.y))} m`);break;case"line":o.push(`${Xm(r.x)} ${Xm(n(r.y))} l`);break;case"cubic":o.push(`${Xm(r.x1)} ${Xm(n(r.y1))} ${Xm(r.x2)} ${Xm(n(r.y2))} ${Xm(r.x)} ${Xm(n(r.y))} c`);break;case"close":o.push("h")}e.fill&&e.stroke?o.push("B"):e.fill?o.push("f"):o.push("S"),o.push("Q"),t.commands.push(o.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}setOpacity(e){const t=Math.max(0,Math.min(1,e)),n=`GSOpacity${Math.round(100*t)}`;(this.page.graphicsStateOpacities??=/* @__PURE__ */new Map).set(n,t),this.page.commands.push(`/${n} gs`)}rotateAbout(e,t,n){const o=this.page;if(!n)return;const r=o.height-t,a=-n*Math.PI/180,i=Math.cos(a),l=Math.sin(a),s=e-e*i+r*l,c=r-e*l-r*i;o.commands.push(`${Xm(i)} ${Xm(l)} ${Xm(-l)} ${Xm(i)} ${Xm(s)} ${Xm(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${Xm(e)} ${Xm(r.height-t-o)} ${Xm(n)} ${Xm(o)} re`,"W","n")}clipPath(e){const t=this.page;if(0===e.length)return;const n=e=>t.height-e,o=[];for(const r of e)switch(r.type){case"move":o.push(`${Xm(r.x)} ${Xm(n(r.y))} m`);break;case"line":o.push(`${Xm(r.x)} ${Xm(n(r.y))} l`);break;case"cubic":o.push(`${Xm(r.x1)} ${Xm(n(r.y1))} ${Xm(r.x2)} ${Xm(n(r.y2))} ${Xm(r.x)} ${Xm(n(r.y))} c`);break;case"close":o.push("h")}o.push("W","n"),t.commands.push(o.join("\n"))}drawText(e){if(0===e.text.length)return;const t=this.fonts.resolveAndMarkFontName(e),n=this.fonts.getUnicodeState(t),o=n?this.fonts.buildUnicodeShowCommand(n,e.text,e.fontFeatures):`<${th(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${Xm(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Xm(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Xm(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([rh(n.text),"BT",Jm(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Jm(n.strokeColor??n.color,"RG",[0,0,0]),`${Xm(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Xm(n.x)} ${Xm(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([rh(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Xm(n.x)} ${Xm(r.height-n.y)} Td`,t,"ET",`/${o} sh`,"Q"].join("\n"))}drawImage(e){const t=this.page;if(e.width<=0||e.height<=0||!this.images.has(e.resourceName))return;t.imageResourceNames.add(e.resourceName);const n=t.height-e.y-e.height,o=Number.isFinite(e.rotation)?e.rotation??0:0,r=e.crop,a=r?.left??0,i=r?.top??0,l=r?.right??0,s=r?.bottom??0;if(r&&(a>0||i>0||l>0||s>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:l,bottom:s});if(0===o)return void t.commands.push(["q",[Xm(e.width),"0","0",Xm(e.height),Xm(e.x),Xm(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const c=-o*Math.PI/180,d=Math.cos(c),u=Math.sin(c),p=e.width*d,g=e.width*u,f=-e.height*u,m=e.height*d,h=e.x+e.width/2-.5*p-.5*f,b=n+e.height/2-.5*g-.5*m;t.commands.push(["q",[Xm(p),Xm(g),Xm(f),Xm(m),Xm(h),Xm(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,l=a/Math.max(1e-4,1-o.left-o.right),s=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*l,d=-o.bottom*s,u=-n*Math.PI/180,p=Math.cos(u),g=Math.sin(u),f=a/2,m=i/2,h=p,b=g,y=-g,v=p,x=e.x+a/2-(h*f+y*m),w=t+i/2-(b*f+v*m);r.commands.push(["q",[Xm(h),Xm(b),Xm(y),Xm(v),Xm(x),Xm(w),"cm"].join(" "),`0 0 ${Xm(a)} ${Xm(i)} re W n`,[Xm(l),"0","0",Xm(s),Xm(c),Xm(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function lh(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function sh(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function ch(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function dh(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=/* @__PURE__ */new Map;for(let o=0;o<t;o+=1)n.set(e.u16(),o);return e=>n.get(e)??-1}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,startIndex:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.startIndex+(e-t.start);return-1}}return()=>-1}function uh(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=sh(e,n);return e=>{const r=e-t;return r>=0&&r<n?o[r]:0}}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,classValue:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.classValue;return 0}}return()=>0}function ph(e){e.seek(0),e.skip(2),e.skip(2);const t=e.u16(),n=e.u16(),o=e.u16(),r=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let r=0;r<n;r+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}return o.map(({tag:t,offset:n})=>(e.seek(n),e.skip(2),{tag:t,lookupIndices:sh(e,e.u16())}))}(e,n),a=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let c=0;c<n;c+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}if(0===o.length)return[];const r=o.find(e=>"latn"===e.tag)??o.find(e=>"DFLT"===e.tag)??o[0];e.seek(r.offset);const a=e.u16();if(0===a)return[];e.seek(r.offset+a),e.skip(2);const i=e.u16(),l=e.u16(),s=[];65535!==i&&s.push(i);for(let c=0;c<l;c+=1)s.push(e.u16());return s}(e,t),i=/* @__PURE__ */new Map;for(const l of a){const e=r[l];if(!e)continue;const t=i.get(e.tag)??[];for(const n of e.lookupIndices)t.includes(n)||t.push(n);i.set(e.tag,t)}return{featureToLookups:i,lookupListOffset:o}}function gh(e,t,n){return e.seek(t),ch(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=ch(e,e.u16(),t),a=[];for(const i of r)try{const t=n(e,i,o);t&&a.push(t)}catch{}return{lookupType:o,subtables:a}})}function fh(e,t){const n=/* @__PURE__ */new Set;for(const o of t)for(const t of e.get(o)??[])n.add(t);return Array.from(n).sort((e,t)=>e-t)}function mh(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=ch(e,o,t).map(t=>(e.seek(t),sh(e,e.u16())));return{coverage:dh(e,n),sets:r}}function hh(e,t){const n=new Array(t);for(let o=0;o<t;o+=1){const t=e.u16(),r=e.u16();n[o]={sequenceIndex:t,lookupListIndex:r}}return n}function bh(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function yh(e,t){e.seek(t);const n=e.u16();return ch(e,n,t).map(t=>(e.seek(t),{backtrack:sh(e,e.u16()),input:sh(e,Math.max(0,e.u16()-1)),lookahead:sh(e,e.u16()),records:hh(e,e.u16())}))}function vh(e,t,n,o,r){const a=(e,n)=>{const o=t[e];return o?r?"b"===n?r.backtrack(o.id):"l"===n?r.lookahead(o.id):r.input(o.id):o.id:null};for(const i of e){const e=i.input.length+1;if(n+e>t.length)continue;let r=!0;for(let t=0;t<i.input.length;t+=1)if(a(n+1+t,"i")!==i.input[t]){r=!1;break}if(r){for(let e=0;e<i.backtrack.length;e+=1)if(a(n-1-e,"b")!==i.backtrack[e]){r=!1;break}if(r){for(let t=0;t<i.lookahead.length;t+=1)if(a(n+e+t,"l")!==i.lookahead[t]){r=!1;break}if(r)return bh(t,n,i.records,o),e}}}return null}function xh(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=e.i16(),n=dh(e,o);return{apply(e,o){const r=e[o];return!r||n(r.id)<0?null:(r.id=r.id+t&65535,1)}}}if(2===n){const t=e.u16(),n=sh(e,t),r=dh(e,o);return{apply(e,o){const a=e[o];if(!a)return null;const i=r(a.id);return i<0||i>=t?null:(a.id=n[i],1)}}}return null}(e,t);case 2:return function(e,t){const n=mh(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];if(0===i.length)return null;const l=n.codePoints,s=i.map((e,t)=>({id:e,codePoints:0===t?l:[]}));return e.splice(t,1,...s),i.length}}}(e,t);case 3:return function(e,t){const n=mh(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];return 0===i.length?null:(n.id=i[0],1)}}}(e,t);case 4:return function(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=ch(e,o,t).map(t=>(e.seek(t),ch(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:sh(e,Math.max(0,o-1))}}))),a=dh(e,n);return{apply(e,t){const n=e[t];if(!n)return null;const o=a(n.id);if(o<0||o>=r.length)return null;for(const a of r[o]){const{components:n}=a;if(t+n.length>e.length-1)continue;let o=!0;for(let a=0;a<n.length;a+=1)if(e[t+1+a].id!==n[a]){o=!1;break}if(!o)continue;const r=n.length+1,i=[];for(let a=0;a<r;a+=1)i.push(...e[t+a].codePoints);return e.splice(t,r,{id:a.ligatureGlyph,codePoints:i}),1}return null}}}(e,t);case 6:return function(e,t){e.seek(t);const n=e.u16();if(3===n){const n=ch(e,e.u16(),t),o=ch(e,e.u16(),t),r=ch(e,e.u16(),t),a=hh(e,e.u16()),i=n.map(t=>dh(e,t)),l=o.map(t=>dh(e,t)),s=r.map(t=>dh(e,t));return{apply(e,t,n){if(0===l.length)return null;if(t+l.length>e.length)return null;for(let o=0;o<l.length;o+=1)if(l[o](e[t+o].id)<0)return null;for(let o=0;o<i.length;o+=1){const n=e[t-1-o];if(!n||i[o](n.id)<0)return null}for(let o=0;o<s.length;o+=1){const n=e[t+l.length+o];if(!n||s[o](n.id)<0)return null}return bh(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=ch(e,o,t),a=dh(e,n),i=r.map(t=>yh(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;const r=a(o.id);return r<0||r>=i.length?null:vh(i[r],e,t,n,null)}}}if(2===n){const n=t+e.u16(),o=t+e.u16(),r=t+e.u16(),a=t+e.u16(),i=e.u16(),l=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();l[g]=0===n?0:t+n}const s=dh(e,n),c=uh(e,o),d=uh(e,r),u=uh(e,a),p=l.map(t=>0===t?[]:yh(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(s(o.id)<0)return null;const r=d(o.id),a=p[r];return a?vh(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return lh(e,t,xh);default:return null}}var wh=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=ph(n),a=gh(n,r,xh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return fh(this.featureToLookups,e)}applyLookupIndexAt(e,t,n){const o=this.lookups[e];if(!o||n<0||n>=t.length)return null;for(const r of o.subtables){const e=r.apply(t,n,this);if(null!==e)return e}return null}shape(e,t){const n=this.collectLookupIndices(t);for(const o of n){let t=0;for(;t<e.length;){const n=this.applyLookupIndexAt(o,e,t);t+=n&&n>0?n:1}}}};function Sh(e,t){let n=0;return 1&t&&e.i16(),2&t&&e.i16(),4&t&&(n=e.i16()),8&t&&e.i16(),16&t&&e.u16(),32&t&&e.u16(),64&t&&e.u16(),128&t&&e.u16(),n}function Ch(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function Ih(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=Sh(e,e.u16()),n=dh(e,o);return 0===t?null:{apply:(e,o,r)=>n(e[r])<0?null:(o[r]+=t,1)}}if(2===n){const t=e.u16(),n=e.u16(),r=Ch(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=Sh(e,t);const l=dh(e,o);return{apply(e,t,o){const r=l(e[o]);if(r<0||r>=n)return null;const a=i[r];return 0===a?null:(t[o]+=a,1)}}}return null}(e,t);case 2:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16(),r=e.u16(),a=e.u16(),i=!!(4&a);if(1===n){const n=e.u16(),l=ch(e,n,t).map(t=>{e.seek(t);const n=e.u16(),o=/* @__PURE__ */new Map;for(let i=0;i<n;i+=1){const t=e.u16(),n=Sh(e,r),i=Sh(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=dh(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=s(e[n]);if(r<0||r>=l.length)return null;const a=l[r].get(o);return a?(t[n]+=a.value1XAdvance,t[n+1]+=a.value2XAdvance,i?2:1):null}}}if(2===n){const n=t+e.u16(),l=t+e.u16(),s=e.u16(),c=e.u16(),d=Ch(r),u=d+Ch(a),p=e.tell(),g=new Array(s*c),f=new Array(s*c);for(let t=0;t<s;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=Sh(e,r),e.seek(p+o+d),f[t*c+n]=Sh(e,a)}const m=dh(e,o),h=uh(e,n),b=uh(e,l);return{apply(e,t,n){const o=e[n],r=e[n+1];if(void 0===r)return null;if(m(o)<0)return null;const a=h(o),l=b(r);if(a>=s||l>=c)return null;const d=a*c+l,u=g[d],p=f[d];return 0===u&&0===p?null:(t[n]+=u,t[n+1]+=p,i?2:1)}}}return null}(e,t);case 9:return lh(e,t,Ih);default:return null}}var Th=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=ph(n),a=gh(n,r,Ih);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=fh(this.featureToLookups,n);for(const r of o){const n=this.lookups[r];if(!n)continue;let o=0;for(;o<e.length;){let r=null;for(const a of n.subtables)if(r=a.apply(e,t,o),null!==r)break;o+=r&&r>0?r:1}}}},kh=/* @__PURE__ */new Set(["kern"]),Ph=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?wh.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?Th.parse(n):null}get hasGsub(){return null!==this.gsub}get hasGpos(){return null!==this.gpos}get hasShaping(){return null!==this.gsub||null!==this.gpos}layout(e,t){const n=[];for(const c of e){const e=c.codePointAt(0)??65533,t=this.font.glyphForCodePoint(e);n.push({id:t,codePoints:0===t?[65533]:[e]})}const o=t?.filter(e=>!kh.has(e))??[],r=t?.filter(e=>kh.has(e))??[];this.gsub&&o.length>0&&this.gsub.shape(n,o);const a=n.map(e=>this.font.advanceWidthForGlyph(e.id));this.gpos&&r.length>0&&this.gpos.position(n.map(e=>e.id),a,r);const i=[],l=[];let s=0;for(let c=0;c<n.length;c+=1){const e=n[c],t=this.font.advanceWidthForGlyph(e.id),o=a[c];i.push({id:e.id,codePoints:e.codePoints,advanceWidth:t}),l.push({xAdvance:o}),s+=o}return{glyphs:i,positions:l,advanceWidth:s}}},Rh=class{font;constructor(e){this.font=e}layout(e){const t=[],n=[];let o=0;for(const r of e){const e=r.codePointAt(0)??65533,a=this.font.glyphForCodePoint(e),i=this.font.advanceWidthForGlyph(a);t.push({id:a,codePoints:0===a?[65533]:[e],advanceWidth:i}),n.push({xAdvance:i}),o+=i}return{glyphs:t,positions:n,advanceWidth:o}}};function Bh(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ah(e,t){return Bh(e).getUint16(t)}function Mh(e,t,n){Bh(e).setUint16(t,n,!1)}function Fh(e,t,n){Bh(e).setUint32(t,n,!1)}function Oh(e){return e+3&-4}function Dh(e){const t=e.reduce((e,t)=>e+Oh(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=Oh(r.byteLength);return n}function Eh(e,t){const n=[],o=Bh(e);if(0===t)for(let r=0;r+1<e.byteLength;r+=2)n.push(2*o.getUint16(r));else for(let r=0;r+3<e.byteLength;r+=4)n.push(o.getUint32(r));return n}function Lh(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function Nh(e,t){if(e.byteLength<10||function(e,t){return Bh(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=Ah(e,n),t(Ah(e,n+2)),n+=4,n+=1&o?4:2,8&o?n+=2:64&o?n+=4:128&o&&(n+=8)}while(32&o)}function $h(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>Fh(t,4*n,e)),t}function zh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)Mh(n,4*o,e.advanceWidthForGlyph(o)),Mh(n,4*o+2,0);return n}var Hh=class{createSubset(e,t){const n=/* @__PURE__ */new Map,o=[];for(const d of t)o.push(d.id),n.has(d.id)||n.set(d.id,d.codePoints);const r=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head");if(!n||!o||!r)return Array.from(/* @__PURE__ */new Set([0,...t])).sort((e,t)=>e-t);const a=Eh(o,Ah(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=Lh(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||Nh(n.slice(e.start,e.end),e=>{i.has(e)||(i.add(e),l.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head"),a=e.getRawTableData("hhea"),i=e.getRawTableData("maxp"),l=e.getRawTableData("cmap");if(!(n&&o&&r&&a&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...t),c=new Set(t),d=Eh(o,Ah(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=Lh(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=Oh(t.byteLength)}}u.push(g);const f=r.slice();Fh(f,8,0),Mh(f,50,1);const m=a.slice();Mh(m,34,s+1);const h=i.slice();Mh(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:zh(e,s),loca:$h(u),maxp:h,glyf:Dh(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=Se(65536,new Map(Object.entries(a).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,l=Math.max(0,...r),s=[],c=[];for(let d=0;d<=l;d+=1)s[d]=e.advanceWidthForGlyph(d)/e.unitsPerEm*1e3,c[d]=n.get(d)??[0];return{fontFile:i,widths:s,unicode:c,encodeGlyph:e=>e}}};var Wh=class{fontResources=/* @__PURE__ */new Map;unicodeFontStates=/* @__PURE__ */new Map;usedFontResourceNames=/* @__PURE__ */new Set;constructor(e){for(const t of e)this.registerFontResource(t)}registerFontResource(e){if(this.fontResources.set(e.resourceName,e),"unicode"===e.kind&&!this.unicodeFontStates.has(e.resourceName)){const t=function(e){const t=new Ph(e);return{program:e,layouter:t.hasShaping?t:new Rh(e),subsetter:new Hh}}(function(e){const t=G.decodeSync(e);return Mo.parse(t)}(e.fontData)),n=1e3/t.program.unitsPerEm,o={id:0,codePoints:[0],advanceWidth:t.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(e.resourceName,{resource:e,font:t,usedGlyphs:/* @__PURE__ */new Map([[0,o]]),scale:n,layoutCache:/* @__PURE__ */new Map})}}resolveAndMarkFontName(e){const t=function(e){return e.fontResourceName?e.fontResourceName:e.bold&&e.italic?"F4":e.bold?"F2":e.italic?"F3":"F1"}(e);return this.usedFontResourceNames.add(t),t}getUnicodeState(e){return this.unicodeFontStates.get(e)}buildUnicodeShowCommand(e,t,n){const o=this.layoutUnicodeText(e,t,n),r=this.encodeUnicodeGlyphRun(e,o);return 0===r.length?null:r.some(e=>Math.abs(e.nominalWidth-e.desiredAdvance)>.01)?`[${r.map(e=>{const t=e.nominalWidth-e.desiredAdvance;return 0===t?`<${oh(e.glyphId)}>`:`<${oh(e.glyphId)}> ${Xm(t)}`}).join(" ")}] TJ`:`<${r.map(e=>oh(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>"base14"===e.kind||this.usedFontResourceNames.has(e.resourceName)),n=t.map(t=>{if("unicode"===t.kind){const n=this.unicodeFontStates.get(t.resourceName);if(n)return this.addUnicodeFontObjects(n,e)}return e(function(e){switch(e.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${e.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))});return{resourceXml:t.map((e,t)=>`/${e.resourceName} ${n[t]} 0 R`).join(" ")}}layoutUnicodeText(e,t,n){const o=`${n?.join(",")??""}\0${t}`,r=e.layoutCache.get(o);if(r)return r;const a=e.font.layouter.layout(t,n);return e.layoutCache.set(o,a),a}encodeUnicodeGlyphRun(e,t){return t.glyphs.map((n,o)=>{e.usedGlyphs.has(n.id)||e.usedGlyphs.set(n.id,n);const r=t.positions[o],a=n.advanceWidth*e.scale,i=(r?.xAdvance??n.advanceWidth)*e.scale;return{glyphId:n.id,nominalWidth:a,desiredAdvance:i}})}addUnicodeFontObjects(e,t){const n=e.font.subsetter.createSubset(e.font.program,e.usedGlyphs.values()),o=t(function(e,t=""){const n=`${qm(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${Gm(n)} /Filter /ASCIIHexDecode${o} >>\nstream\n${n}\nendstream`}(n.fontFile)),r=e.font.program.metadata,a=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),a>=1&&a<=7&&(i|=2),10===a&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${Qm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Qm(r.postscriptName,e.resource.family)}`,s=r.bbox,c=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*e.scale,s.minY*e.scale,s.maxX*e.scale,s.maxY*e.scale].map(Xm).join(" ")}]`,`/ItalicAngle ${Xm(r.italicAngle)}`,`/Ascent ${Xm(r.ascent*e.scale)}`,`/Descent ${Xm(r.descent*e.scale)}`,`/CapHeight ${Xm(r.capHeight*e.scale)}`,`/XHeight ${Xm(r.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${o} 0 R`,">>"].join("\n")),d=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${c} 0 R`,`/W [0 [${n.widths.map(e=>Xm(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${Gm(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${nh(e)}>`).filter(e=>"<>"!==e);0===t.length&&t.push("<0000>");const n=[];for(let o=0;o<t.length;o+=256){const e=Math.min(o+256,t.length);n.push(`<${Ym(o)}> <${Ym(e-1)}> [${t.slice(o,e).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${n.length} beginbfrange`,n.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(n.unicode)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${d} 0 R]`,`/ToUnicode ${u} 0 R`,">>"].join("\n"))}},Uh=class{imageResources=/* @__PURE__ */new Map;registerImageResource(e){const t=e.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(t)||this.imageResources.set(t,{resourceName:t,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height)),data:e.data,filter:e.filter}),t}has(e){return this.imageResources.has(e)}buildImageObjects(e){const t=/* @__PURE__ */new Map;for(const n of this.imageResources.values())t.set(n.resourceName,this.addImageObject(n,e));return t}addImageObject(e,t){return t(function(e,t){const n=`${qm(e)}>`;return[`<< /Length ${Gm(n)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${t.join(" ")}`," >>","stream",n,"endstream"].join("\n")}(e.data,["/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},jh=class{shadings=[];register(e){const t=`Sh${this.shadings.length+1}`;return this.shadings.push({name:t,spec:e}),t}buildShadingObjects(e){const t=/* @__PURE__ */new Map;for(const{name:n,spec:o}of this.shadings)t.set(n,this.addShadingObject(o,e));return t}addShadingObject(e,t){const n=t(function(e){if(2===e.length)return Vh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Vh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>Xm(e.offset)),o=e.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${t.join(" ")}]`,`/Bounds [${n.join(" ")}]`,`/Encode [${o}]`,">>"].join("\n")}(function(e){const t=e.map(e=>({offset:Math.min(1,Math.max(0,e.offset)),rgb:Zm(e.color,[0,0,0])})).sort((e,t)=>e.offset-t.offset);if(0===t.length)return[{offset:0,rgb:[0,0,0]},{offset:1,rgb:[0,0,0]}];if(1===t.length)return[{offset:0,rgb:t[0].rgb},{offset:1,rgb:t[0].rgb}];t[0].offset=0,t[t.length-1].offset=1;for(let n=1;n<t.length-1;n+=1){const e=t[n-1].offset+1e-4;t[n].offset<=e&&(t[n].offset=Math.min(.9999,e))}return t}(e.stops)));return t(["<< /ShadingType 2","/ColorSpace /DeviceRGB",`/Coords [${[e.x0,e.y0,e.x1,e.y1].map(Xm).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Vh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Xm).join(" ")}]`,`/C1 [${t.map(Xm).join(" ")}]`,"/N 1",">>"].join("\n")}var Kh=new TextEncoder;function _h(e){return"string"==typeof e?Gm(e):e.length}function Xh(e){const t=e.reduce((e,t)=>e+_h(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Kh.encode(r):r;n.set(e,o),o+=e.length}return n}function Gh(e){const t=xr(Kh.encode(e));return Xh([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function qh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function Yh(e){return`<FEFF${nh(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Zh(e){const t=[];if(e.title&&t.push(`/Title ${Yh(e.title)}`),e.author&&t.push(`/Author ${Yh(e.author)}`),e.subject&&t.push(`/Subject ${Yh(e.subject)}`),e.keywords&&t.push(`/Keywords ${Yh(e.keywords)}`),e.producer&&t.push(`/Producer (${qh(e.producer)})`),e.creationDate&&t.push(`/CreationDate (${function(e){const t=(e,t=2)=>String(e).padStart(t,"0");return`D:${e.getUTCFullYear()}${t(e.getUTCMonth()+1)}${t(e.getUTCDate())}${t(e.getUTCHours())}${t(e.getUTCMinutes())}${t(e.getUTCSeconds())}+00'00'`}(e.creationDate)})`),0!==t.length)return`<< ${t.join(" ")} >>`}function Jh(e){return e.children.reduce((e,t)=>e+1+Jh(t),0)}function Qh(e,t,n,o,r=[],a=[],i){const l=[],s=e=>{const t=l.length+1;return l.push({id:t,body:e}),t},c=s(""),d=s(""),{resourceXml:u}=t.buildFontObjects(s),p=n.buildImageObjects(s),g=o.buildShadingObjects(s),f=/* @__PURE__ */new Map;for(const B of e)for(const[e,t]of B.graphicsStateOpacities??[])f.has(e)||f.set(e,s(`<< /Type /ExtGState /ca ${Xm(t)} /CA ${Xm(t)} >>`));const m=[];for(const B of e){const e=s(Gh(`${B.commands.join("\n")}\n`)),t=Array.from(B.imageResourceNames).map(e=>{const t=p.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),n=t?` /XObject << ${t} >>`:"",o=Array.from(B.shadingResourceNames).map(e=>{const t=g.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),r=o?` /Shading << ${o} >>`:"",a=Array.from(B.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${f.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",l=B.annotations.map(e=>{const t=e.x,n=e.x+e.width,o=B.height-e.y-e.height,r=B.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${qh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${qh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${Xm(t)} ${Xm(o)} ${Xm(n)} ${Xm(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=l.length>0?`\n/Annots [${l.map(e=>`${e} 0 R`).join(" ")}]`:"",h=s(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${Xm(B.width)} ${Xm(B.height)}]`,`/Resources << /Font << ${u} >>${n}${r}${i} >>`,`/Contents ${e} 0 R${c}`,">>"].join("\n"));m.push(h)}let h;const b=r.filter(e=>void 0!==m[e.pageIndex]).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0);let y;b.length>0&&(h=s(`<< /Dests ${s(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${qh(t.name)}) [${n} 0 R /XYZ ${Xm(t.x)} ${Xm(o)} null]`}).join(" ")}] >>`)} 0 R >>`));const v=new Set(b.map(e=>e.name)),x=function(e){const t=[],n=[];for(const o of e){const e={title:o.title,destName:o.destName,children:[]};for(;n.length>0&&n[n.length-1].level>=o.level;)n.pop();0===n.length?t.push(e):n[n.length-1].node.children.push(e),n.push({node:e,level:o.level})}return t}(a.filter(e=>v.has(e.destName)));if(x.length>0){y=s("");const e=t=>t.map(t=>{const n=s("");return t.id=n,t.childIds=e(t.children),n}),t=e(x),n=(e,t)=>{e.forEach((o,r)=>{const a=o,i=r>0?e[r-1]:void 0,s=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+Yh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${qh(o.destName)})`];a.childIds.length>0&&(c.push(`/First ${a.childIds[0]} 0 R`),c.push(`/Last ${a.childIds[a.childIds.length-1]} 0 R`),c.push(`/Count ${Jh(o)}`)),c.push(">>"),l[a.id-1].body=c.filter(Boolean).join("\n"),n(o.children,a.id)})};n(x,y);const o=a.filter(e=>v.has(e.destName)).length;l[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(l[c-1].body=["<< /Type /Catalog",`/Pages ${d} 0 R`,void 0!==h?`/Names ${h} 0 R`:"",void 0!==y?`/Outlines ${y} 0 R`:"",void 0!==y?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=Zh(i);e&&(w=s(e))}const S=[Km];let C=_h(Km);const I=[0],T=e=>{S.push(e),C+=_h(e)};for(const B of l)I[B.id]=C,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const k=C;let P=`xref\n0 ${l.length+1}\n`;P+="0000000000 65535 f \n";for(const B of l)P+=`${String(I[B.id]??0).padStart(10,"0")} 00000 n \n`;T(P);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${l.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(k),"%%EOF",""].join("\n")),Xh(S)}var eb=class{pages=[];streams=[];fonts;images=new Uh;shadings=new jh;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=_m){this.fonts=new Wh(e)}registerFontResource(e){this.fonts.registerFontResource(e)}addPage(e){const t={width:Math.max(1,e.width),height:Math.max(1,e.height),commands:[],imageResourceNames:/* @__PURE__ */new Set,shadingResourceNames:/* @__PURE__ */new Set,annotations:[],graphicsStateOpacities:/* @__PURE__ */new Map};return this.pages.push(t),this.streams.push(new ih(t,this.fonts,this.images,this.shadings)),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(e,t){this.streams[e]?.drawRect(t)}drawLine(e,t){this.streams[e]?.drawLine(t)}drawPath(e,t){this.streams[e]?.drawPath(t)}saveGraphicsState(e){this.streams[e]?.saveGraphicsState()}restoreGraphicsState(e){this.streams[e]?.restoreGraphicsState()}setOpacity(e,t){this.streams[e]?.setOpacity(t)}rotateAbout(e,t,n,o){this.streams[e]?.rotateAbout(t,n,o)}clipRect(e,t,n,o,r){this.streams[e]?.clipRect(t,n,o,r)}clipPath(e,t){this.streams[e]?.clipPath(t)}drawText(e,t){this.streams[e]?.drawText(t)}registerAxialGradient(e,t){return this.streams[e]?.registerAxialGradient(t)??null}registerImageResource(e){return this.images.registerImageResource(e)}drawImage(e,t){this.streams[e]?.drawImage(t)}addLinkAnnotation(e,t){this.pages[e]?.annotations.push(t)}addNamedDestination(e){this.namedDestinations.some(t=>t.name===e.name)||this.namedDestinations.push(e)}addOutlineItem(e){this.outlineItems.push(e)}setDocumentInfo(e){this.documentInfo=e}toArrayBuffer(){const e=this.toUint8Array();return Uint8Array.from(e).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){return 0===this.pages.length&&this.addPage({width:612,height:792}),Qh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function tb(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=tn(i),s=tn(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:s,y:l});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:s,y:l}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function nb(e){e=sn(e);const t=new Vm,n=pt(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new eb(t.getPdfFontResources());o.setDocumentInfo(function(e){const t=e.metadata??{},n=e=>"string"==typeof e&&""!==e.trim()?e:void 0;return{title:n(t.title),author:n(t.author),subject:n(t.subject),keywords:n(t.keywords),producer:"Oasis Editor",creationDate:/* @__PURE__ */new Date}}(e));const r=Tr(e),a=function(e){return mt(e)}(e),i=function(e){const t=/* @__PURE__ */new Map,n=e.bookmarks;if(!n)return t;for(const o of n.order){const e=n.items[o],r=e?.start?.paragraphId;if(!e||!r)continue;const a=t.get(r)??[];a.push(e.name),t.set(r,a)}return t}(e),l=new Map(Bn(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,tn(s.pageSettings.width)),r=Math.max(1,tn(s.pageSettings.height)),c=o.addPage({width:n,height:r});await Hm(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=ue(s.pageSettings);await zm(o,c,s.headerBlocks,e,d,s.headerTop??nn(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??ye(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=hr(s.pageSettings),r=/* @__PURE__ */new Map;for(const e of s.blocks){const t=e.columnIndex??0,n=r.get(t)??[];n.push(e),r.set(t,n)}for(const[d,u]of r){const r=n[d]??n[0];await zm(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,tb(o,c,r.left,i,l))}}else await zm(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,tb(o,c,d,i,l));await zm(o,c,s.footerBlocks,e,d,s.footerTop??s.bodyBottom??s.pageSettings.height,u,t,a,s.pageSettings),s.footnoteBlocks&&s.footnoteBlocks.length>0&&void 0!==s.footnoteTop&&(void 0!==s.footnoteSeparatorTop&&o.drawLine(c,{x1:tn(d),y1:tn(s.footnoteSeparatorTop+.5),x2:tn(d+Math.min(180,.35*u)),y2:tn(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:tn(1)}),await rb(o,c,s.footnoteBlocks,s.footnoteReferenceIds??[],e,d,s.footnoteTop,u,t,a))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await Hm(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function ob(e){const t=await nb(e);return new Blob([t],{type:"application/pdf"})}async function rb(e,t,n,o,r,a,i,l,s,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,Io(r,e)?.run.text??""]));for(const g of n){const n=o.find(e=>g.blockId.startsWith(`${e}:`));if(n&&!u.has(n)){const o=p.get(n);if(o){const n="paragraph"===g.sourceBlock.type?g.sourceBlock:void 0,i=Te(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:tn(a),y:tn(d+12),text:o,fontSize:qt(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await zm(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function ab(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function ib(e){return new Promise(t=>{const n=URL.createObjectURL(e),o=document.createElement("iframe");o.setAttribute("aria-hidden","true"),o.style.position="fixed",o.style.right="0",o.style.bottom="0",o.style.width="0",o.style.height="0",o.style.border="0";let r=!1;const a=()=>{r||(r=!0,o.remove(),URL.revokeObjectURL(n),t())},i=()=>{if(!r){if(!window.open(n,"_blank")){const e=document.createElement("a");e.href=n,e.download="oasis-editor.pdf",e.click()}a()}};o.addEventListener("load",()=>{try{const e=o.contentWindow;if(!e)return void i();e.addEventListener("afterprint",a),globalThis.setTimeout(a,6e4),e.focus(),e.print()}catch{i()}}),o.src=n,document.body.appendChild(o)})}async function lb(e){return"function"==typeof e.arrayBuffer?e.arrayBuffer():new Promise((t,n)=>{const o=new FileReader;o.onerror=()=>n(o.error??/* @__PURE__ */new Error("Failed to read file.")),o.onload=()=>{const e=o.result;e instanceof ArrayBuffer?t(e):n(/* @__PURE__ */new Error("Failed to read file as ArrayBuffer."))},o.readAsArrayBuffer(e)})}function sb(e){if(!e)return null;for(const t of Array.from(e.items??[])){if("file"!==t.kind)continue;const e=t.getAsFile();if(e&&e.type.startsWith("image/"))return e}for(const t of Array.from(e.files??[]))if(t.type.startsWith("image/"))return t;return null}function cb(e){return function(e){const t=T(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=re(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=Te(o.styles,i.style?.styleId,e.styles),l=t.fontFamily??"<null>";n.set(l,(n.get(l)??0)+1),null!==t.characterSpacing&&(r+=1),null!==t.characterScale&&(a+=1)}}return{paragraphCount:t.length,alignCounts:Array.from(o.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:r,characterScaleRuns:a,firstParagraphs:t.slice(0,30).map((t,n)=>{const o=re(t.style,e.styles),r=t.runs[0],a=Te(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:Lt(t).length,runCount:t.runs.length,rawParagraphStyle:t.style,align:o.align,indentFirstLine:o.indentFirstLine,lineGridPitch:o.lineGridPitch,lineGridType:o.lineGridType,fontFamily:a.fontFamily,fontSize:a.fontSize,characterSpacing:a.characterSpacing,characterScale:a.characterScale,firstRunStyle:r?.styles}})}}(e)}function db(e,t){const n=Wn(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=Kr(e)[n.startIndex];if(!o)return null;let r=0;for(let a=0;a<o.runs.length;a+=1){const e=o.runs[a],i=r;if(r+=e.text.length,t(e)&&1===e.text.length&&i===n.startParagraphOffset)return{paragraph:o,paragraphIndex:n.startIndex,run:e,runIndex:a,offset:i}}return null}function ub(e,t){if("inline"===t)return;const n={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(t){case"square":case"tight":case"through":case"topAndBottom":return{...n,wrap:t,behindDoc:!1};case"behind":return{...n,wrap:"none",behindDoc:!0};case"front":return{...n,wrap:"none",behindDoc:!1}}}function pb(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function gb(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function fb(e){return"page"===e?.positionV?.relativeFrom}function mb(e){return db(e,e=>"image"===e.kind)}function hb(e,t,n){return Tb(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function bb(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function yb(e,t){return Tb(e,e=>{const n={...e},o=function(e){if(!e)return;const t=bb(e.left),n=bb(e.top),o=bb(e.right),r=bb(e.bottom),a=Math.min(o,Math.max(0,.99-t)),i=Math.min(r,Math.max(0,.99-n));return 0!==t||0!==n||0!==a||0!==i?{left:t,top:n,right:a,bottom:i}:void 0}(t.crop);return o?n.crop=o:delete n.crop,void 0!==t.width&&(n.width=Math.max(24,Math.round(t.width))),void 0!==t.height&&(n.height=Math.max(24,Math.round(t.height))),n})}function vb(e,t){const n=mb(e),o=n&&qn(n.run);return o?yb(e,function(e,t){if("reset"===t)return{crop:null};const n=t,{width:o,height:r}=e;if(!Number.isFinite(n)||n<=0||o<=0||r<=0)return{crop:e.crop??null};const a=e.crop??{},i=bb(a.left),l=bb(a.top),s=bb(a.right),c=bb(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-s);return{crop:{...a,left:i+t/2,right:s+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-l-c);return{crop:{...a,top:l+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function xb(e){const t=e.intrinsicWidth??e.width,n=e.intrinsicHeight??e.height,o=t>0&&n>0?t/n:e.width/Math.max(1,e.height),r=e.width/Math.max(1,e.height);if(!Number.isFinite(o)||!Number.isFinite(r))return{};if(o>r){const e=r/o,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(o<r){const e=o/r,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}return{}}function wb(e){return Tb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function Sb(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function Cb(e,t,n=90){const o=mb(e);if(!o||!qn(o.run))return e;const r="right"===t?-n:n,a=Sb(function(e){const t=mb(e);return(t&&qn(t.run))?.rotation??0}(e)+r);return Tb(e,e=>({...e,rotation:a}))}function Ib(e,t){const n=function(e){const t=mb(e),n=t&&qn(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?Tb(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function Tb(e,t){const n=mb(e);if(!n||!qn(n.run))return e;const o=Kr(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function kb(e,t){return Tb(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function Pb(e,t){const n=mb(e);if(!n)return e;const o=Kr(e),{paragraphIndex:a,offset:i,run:l}=n,s=No(o,t.paragraphId);if(s<0)return e;const c=o[s],p=Bt(c,t),g=s===a&&p>i?p-1:p;if(s===a&&g===i)return e;const f=e=>Ut(e,[...Rt(e,0,i),...Rt(e,i+1,u(e))]),m=(e,t)=>d(e,Math.max(0,Math.min(t,u(e))),[co("",Y(e,t),qn(l))]),h=o.map((e,t)=>t===a&&t===s?m(f(e),g):t===a?f(e):t===s?m(e,g):r([e])[0]),b=h[s],y=Math.max(0,Math.min(g+1,u(b)));return Ie(e,h,oe(Z(b,y)))}function Rb(e,t,n,o=0){const r=ue(V(t));if(!n)return r;const a=Ho(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function Bb(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await lb(t),r=`data:${t.type};base64,${function(e){return btoa(new Uint8Array(e).reduce((e,t)=>e+String.fromCharCode(t),""))}(o)}`,a=new Image;a.src=r,await new Promise(e=>{a.onload=e,a.onerror=e});const i=a.naturalWidth||300,l=a.naturalHeight||300,s=e.state(),c=n?.paragraphId??s.selection.focus.paragraphId,u=Rb(e.surfaceRef(),s.document,c,s.activeSectionIndex??0),p=i>u?u/i:1,g=Math.max(24,Math.round(i*p)),f=Math.max(24,Math.round(l*p));e.logger.info(`image insert:decoded natural=${i}x${l} fitted=${g}x${f} maxWidth=${u}`),e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=co("",Y(o,a),t),l=d(o,a,[i]),s=Kr(n).map((e,t)=>t===r?l:pn(e));return Ie(n,s,oe(Z(l,a+1)))}(n?Aa(e,{anchor:n,focus:n}):e,{src:r,width:g,height:f,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:Ui})}}}var Ab={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"preparing-fonts":[78,90],"applying-editor-state":[90,94],"stabilizing-layout":[94,99],done:[100,100],error:[100,100]};function Mb(e){return function(e){const[t,n]=an(null),o=(e,t)=>{const[n,o]=Ab[e];return void 0!==t&&Number.isFinite(t)?Math.round(10*(n+(o-n)*Math.min(1,Math.max(0,t))))/10:o},r=(e,t)=>{n({phase:e,progress:o(e,t),subProgress:t})},a=()=>{globalThis.setTimeout(()=>{n(e=>"done"===e?.phase||"error"===e?.phase?null:e)},1200)},i=function(e){return{handleImportFile:async t=>{if(!t)return;const n=h(t);if(!n)return e.setImportPhase("error"),e.logger.error("import:unsupported-format",{name:t.name,type:t.type}),void e.clearImportProgressSoon();const o=e.now();e.logger.info("import:start",{format:n.id,name:t.name,size:t.size}),e.setImportPhase("reading-file");const r="docx"===n.id?e.requestLocalFontAccess().catch(()=>!1):Promise.resolve(!1);try{const a=e.now(),i=await lb(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:c(e.now()-a,2)});let l=null,s=-1,d=0;const u=await n.import(i,(t,n)=>{const o=e.now(),r=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==l;if(!(a||void 0!==r&&(s<0||r-s>=1)||o-d>=40))return;l=t,s=r??s,d=o,e.setImportPhase(t,n);const i={phase:t,subProgress:n};a||void 0===n||1===n?e.logger.info("import:phase",i):e.logger.debug("import:phase",i)});e.logger.debug("import:document-diagnostics",cb(u));const p=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(u),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:c(e.now()-p,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(wo(u));const g=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:c(e.now()-g,2)});const f=$e(u).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),m=Ke(u).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:f,paragraphs:m,durationMs:c(e.now()-o,2)}),e.focusInput()}catch(a){e.setImportPhase("error"),e.logger.error("import:error",a)}finally{e.clearImportProgressSoon()}}}}({applyState:e.applyState,stabilizeLayoutAfterImport:e.stabilizeLayoutAfterImport,resetEditorChromeState:e.resetEditorChromeState,focusInput:e.focusInput,requestLocalFontAccess:e.requestLocalFontAccess,prepareDocumentFonts:e.prepareDocumentFonts,setImportPhase:r,clearImportProgressSoon:a,now:()=>performance.now(),logger:e.logger}),l=Bb({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),s=function(e){const t=e.download??ab,n=e.print??ib;let o=!1;return{handleExportDocx:async()=>{const n=await gm(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await ob(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await ob(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>gm(e.document()),exportPdfBlob:()=>ob(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),d=async t=>{e.isReadOnly()||await i.handleImportFile(t)},u=async(e,t)=>{await l.insertImageFromFile(e,t)},p=async t=>{e.isReadOnly()||t&&(await u(t),e.focusInput())};return{importProgress:t,handleImportFile:d,handleExportDocx:async()=>s.handleExportDocx(),handleExportPdf:async()=>s.handleExportPdf(),handlePrint:async()=>s.handlePrint(),exportDocxBlob:s.exportDocxBlob,exportPdfBlob:s.exportPdfBlob,insertImageFromFile:u,handleInsertImage:p}}(e)}function Fb(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Ob(e){return" "===e||"\t"===e||"\n"===e}function Db(e,t,n){if(n.isCollapsed)return null;const o=t.get(e);return void 0===o||o<n.startIndex||o>n.endIndex?null:n.startIndex===n.endIndex?{start:n.startParagraphOffset,end:n.endParagraphOffset}:e===n.start.paragraphId?{start:n.startParagraphOffset,end:Number.POSITIVE_INFINITY}:e===n.end.paragraphId?{start:0,end:n.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function Eb(e,t){if(!e)return null;for(const n of e)if("table"===n.type){if(n.id===t)return n;for(const e of n.rows)for(const n of e.cells){const e=Eb(n.blocks,t);if(e)return e}}return null}function Lb(e,t){const n=Wn(t),o=[],r=e.surfaceRect,a=new Map(Kr(t).map((e,t)=>[e.id,t]));let i=null,l=null;if(!n.isCollapsed&&n.startIndex===n.endIndex&&n.endParagraphOffset-n.startParagraphOffset===1){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.inlineImages.find(t)??e.floatingImages.find(t);if(o&&(i={paragraphId:o.paragraphId,startOffset:o.startOffset,endOffset:o.endOffset,left:o.left-r.left,top:o.top-r.top,width:o.width,height:o.height,rotation:o.rotation??0}),!i){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.floatingTextBoxes.find(t),a=o?void 0:e.inlineTextBoxes.find(t),i=o??a;i&&(l={paragraphId:i.paragraphId,startOffset:i.startOffset,endOffset:i.endOffset,left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height,rotation:i.rotation??0,floating:Boolean(o)})}}const s=(e.paragraphsById.get(t.selection.anchor.paragraphId)??[]).find(e=>e.tableCell)?.tableCell,c=(e.paragraphsById.get(t.selection.focus.paragraphId)??[]).find(e=>e.tableCell)?.tableCell;let d=!1;if(s&&c&&s.tableId===c.tableId&&(s.rowIndex!==c.rowIndex||s.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of Fe(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Eb(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Eb(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=ln(n),a=t.find(e=>e.rowIndex===s.rowIndex&&e.cellIndex===s.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const l=Math.min(a.visualRowIndex,i.visualRowIndex),s=Math.max(a.visualRowIndex+a.rowSpan-1,i.visualRowIndex+i.rowSpan-1),c=Math.min(a.visualColumnIndex,i.visualColumnIndex),u=Math.max(a.visualColumnIndex+a.colSpan-1,i.visualColumnIndex+i.colSpan-1),p=/* @__PURE__ */new Set;for(const a of e.paragraphs)if(a.tableCell&&a.tableCell.tableId===n.id){const e=t.find(e=>e.rowIndex===a.tableCell.rowIndex&&e.cellIndex===a.tableCell.cellIndex);if(e){const t=e.visualRowIndex<=s&&e.visualRowIndex+e.rowSpan-1>=l,n=e.visualColumnIndex<=u&&e.visualColumnIndex+e.colSpan-1>=c;if(t&&n){const t=`${e.rowIndex}:${e.cellIndex}`;p.has(t)||(p.add(t),o.push({left:a.tableCell.left-r.left,top:a.tableCell.top-r.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(d||n.isCollapsed||i||l))for(const w of e.paragraphs){const e=Db(w.paragraphId,a,n);if(!e)continue;const t=Math.max(e.start,w.startOffset),i=Math.min(e.end,w.endOffset);if(!(t>=i))for(const n of w.lines){let e=Math.max(t,n.startOffset),a=Math.min(i,n.endOffset);for(;e<a&&Ob(Fb(w,e));)e+=1;for(;a>e&&Ob(Fb(w,a-1));)a-=1;if(e>=a)continue;const l=n.slots.find(t=>t.offset===e),s=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!l||!s)continue;const c=0===w.startOffset&&n.startOffset===w.startOffset&&n.top>w.top,d=c?w.top:n.top,u=c?n.top+n.height-w.top:n.height;o.push({left:l.left-r.left+1,top:d-r.top,width:Math.max(1,s.left-l.left+1-1),height:u})}}const u=t.selection.focus.paragraphId,p=e.paragraphsById.get(u)??[],g=p[0]?.paragraph,f=function(e,t){if(0===e.length)return null;const n=e.find(e=>t>=e.startOffset&&t<=e.endOffset)??e[e.length-1],o=n.lines.flatMap(e=>e.slots);if(0===o.length)return{left:n.left,top:n.top,height:Math.max(18,n.height)};let r=o[0],a=Math.abs(t-r.offset);for(const l of o){const e=Math.abs(t-l.offset);e<a&&(r=l,a=e)}const i=n.lines[0];return 0===n.startOffset&&void 0!==i&&t>=i.startOffset&&t<=i.endOffset&&r.top>n.top?{left:r.left,top:n.top,height:r.top+r.height-n.top}:{left:r.left,top:r.top,height:r.height}}(p,g?Bt(g,t.selection.focus):t.selection.focus.offset),m=(f?.left??r.left)-r.left,h=(f?.top??r.top)-r.top,b=Math.max(18,f?.height??28),y={left:m,top:h,height:b,visible:p.length>0&&!d&&!i&&!l};let v=null;const x=(e.paragraphsById.get(u)??[])[0]?.tableCell?.tableId??null;if(x){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of e.paragraphs){const e=r.tableCell;e&&e.tableId===x&&(t=Math.min(t,e.left),n=Math.min(n,e.top),o=Math.max(o,e.left+e.width),a=Math.max(a,e.top+e.height))}Number.isFinite(t)&&o>t&&a>n&&(v={tableId:x,left:t-r.left,top:n-r.top,width:o-t,height:a-n})}return{selectionBoxes:o,inputBox:{left:m,top:h,height:b},caretBox:y,selectedImageBox:i,selectedTextBoxBox:l,selectedTableBox:v}}var Nb={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments"};function $b(e,t){return e[Nb[t]]??!0}function zb(e,t){return"boolean"==typeof t.allAuthors?Ub(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=jb(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=jb(n);return Ub(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Kb(e)):t.section?function(e,t){const n=Nb[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function Hb(e,t){return e.markupAuthors?.includes(t)??!0}function Wb(e,t,n){return!("insert"===t&&!$b(e,"insertions"))&&(!("delete"===t&&!$b(e,"deletions"))&&Hb(e,n))}function Ub(e,t){return void 0===e.markupAuthors&&void 0===t||void 0!==e.markupAuthors&&void 0!==t&&e.markupAuthors.length===t.length&&e.markupAuthors.every((e,n)=>e===t[n])?e:{...e,markupAuthors:t}}function jb(e){return[...new Set(e)].sort()}function Vb(e,t){for(const n of e.runs){const e=n.revision?.author??n.revisionRangeMarker?.author;e&&t.add(e)}}function Kb(e){const t=/* @__PURE__ */new Set,n=e=>{if(e)for(const n of e)"paragraph"===n.type&&Vb(n,t)},o=T(e.document);for(const l of o)Vb(l,t);for(const l of Fe(e.document))for(const e of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])n(e);const r=e.document.footnotes?.items??{};for(const l of Object.values(r))n(l.blocks);const a=e.document.endnotes?.items??{};for(const l of Object.values(a))n(l.blocks);const i=e.document.comments?.items??{};for(const l of Object.values(i)){const e=l.author??l.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function _b(e,t){const n=[];let o=0;for(const r of e.runs){const e=o,a=o+r.text.length;o=a;const i=r.revision;if(i&&("insert"===i.type||"delete"===i.type)&&Wb(t,i.type,i.author)&&a>e){const t=n.at(-1);t&&t.revisionId===i.id&&t.type===i.type&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:i.id,type:i.type})}}return n}var Xb={composeMeasuredParagraphLines:e=>Fn.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>Fn.resolveRenderedLineHeightPx(e,t)};function Gb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function qb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>{const o=e?.[n];return o?.blockIndex===t.blockIndex&&o?.offset===t.offset})}function Yb(){let e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Map;return function(n){const o=/* @__PURE__ */new Map,r=t=>t?.map(t=>{const n=e.get(t.blockId),r=function(e,t){return Boolean(e&&e.blockId===t.blockId&&e.sourceBlock===t.sourceBlock&&e.estimatedHeight===t.estimatedHeight&&e.tableSegment?.startRowIndex===t.tableSegment?.startRowIndex&&e.tableSegment?.endRowIndex===t.tableSegment?.endRowIndex&&e.tableSegment?.repeatedHeaderRowCount===t.tableSegment?.repeatedHeaderRowCount&&Gb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&Gb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&qb(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&qb(e.tableSegment?.endRowCellBlockPositions,t.tableSegment?.endRowCellBlockPositions)&&function(e,t){return e===t||!(!e||!t)&&e.text===t.text&&e.startOffset===t.startOffset&&e.endOffset===t.endOffset&&e.lines.length===t.lines.length&&t.lines.every((t,n)=>{const o=e.lines[n];return void 0!==o&&o.startOffset===t.startOffset&&o.endOffset===t.endOffset&&o.top===t.top&&o.height===t.height})}(e.layout,t.layout))}(n,t)?n:t;return o.set(r.blockId,r),r}),a=n.pages.map(e=>{const n={...e,blocks:r(e.blocks)??[],headerBlocks:r(e.headerBlocks),footerBlocks:r(e.footerBlocks),footnoteBlocks:r(e.footnoteBlocks)},o=t.get(n.id);return function(e,t){const n=Boolean(e&&e.pageSettings.width===t.pageSettings.width&&e.pageSettings.height===t.pageSettings.height&&e.pageSettings.orientation===t.pageSettings.orientation&&e.pageSettings.margins.top===t.pageSettings.margins.top&&e.pageSettings.margins.right===t.pageSettings.margins.right&&e.pageSettings.margins.bottom===t.pageSettings.margins.bottom&&e.pageSettings.margins.left===t.pageSettings.margins.left&&e.pageSettings.margins.header===t.pageSettings.margins.header&&e.pageSettings.margins.footer===t.pageSettings.margins.footer&&e.pageSettings.margins.gutter===t.pageSettings.margins.gutter);if(!e||e.id!==t.id||e.index!==t.index||e.height!==t.height||e.maxHeight!==t.maxHeight||!n||e.bodyTop!==t.bodyTop||e.bodyBottom!==t.bodyBottom||e.headerTop!==t.headerTop||e.footerTop!==t.footerTop||e.footnoteTop!==t.footnoteTop||e.footnoteSeparatorTop!==t.footnoteSeparatorTop)return!1;const o=(e,t)=>(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t);return o(e.blocks,t.blocks)&&o(e.headerBlocks,t.headerBlocks)&&o(e.footerBlocks,t.footerBlocks)&&o(e.footnoteBlocks,t.footnoteBlocks)&&(r=e.footnoteReferenceIds,a=t.footnoteReferenceIds,(r?.length??0)===(a?.length??0)&&(a??[]).every((e,t)=>r?.[t]===e));var r,a}(o,n)?o:n});return e=o,t=new Map(a.map(e=>[e.id,e])),{pages:a}}}function Zb(e,t){if(0===t.length)return e;let n;for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&(n??={...e},delete n[o]);return n??e}function Jb(e){return function(e){const[t,n]=an({}),[r,a]=an({}),[i,l]=an({left:0,top:0,height:28}),[s,c]=an([]),[d,u]=an([]),[p,g]=an([]),[f,m]=an(null),[h,b]=an(null),[y,v]=an(null),[x,w]=an({left:0,top:0,height:28,visible:!1}),[S,C]=an(null),I=Yb(),T=vr(()=>{Jo();const t=e.state.reviewDisplayMode??"all";return"all"===t?e.state.document:Nr(e.state.document,t).document}),k=vr(()=>(Jo(),I(Tr(T(),void 0,t(),r(),{measurer:Xb})))),P=nt();let R=0;const B=(t="selection")=>{const n=e.surfaceRef();if(!n)return c([]),u([]),g([]),m(null),b(null),v(null),void w(e=>({...e,visible:!1}));const o=P.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:k(),zoomFactor:e.zoomFactor?.()});if(!o)return c([]),u([]),g([]),m(null),b(null),v(null),void w(e=>({...e,visible:!1}));if("all"!==(e.state.reviewDisplayMode??"all"))return c([]),m(null),b(null),v(null),w({left:0,top:0,height:28,visible:!1}),l({left:0,top:0,height:28}),u([]),void g([]);const r=Lb(o,e.state);c(r.selectionBoxes),g(!1===e.state.showRevisionMarkup?[]:function(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=_b(r.paragraph,t);if(0!==e.length)for(const t of r.lines)for(const r of e){const e=Math.max(r.start,t.startOffset),a=Math.min(r.end,t.endOffset);if(e>=a)continue;const i=t.slots.find(t=>t.offset===e),l=t.slots.find(e=>e.offset===a)??t.slots[t.slots.length-1];i&&l&&o.push({revisionId:r.revisionId,type:r.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,l.left-i.left),height:t.height})}}return o}(o,e.state)),u(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!$b(t,"comments"))return[];const o=e.surfaceRect,r=new Map(Kr(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const l=n.items[i];if(!l?.start||!l?.end||!Hb(t,l.author))continue;const s=r.get(l.start.paragraphId),c=r.get(l.end.paragraphId);if(void 0!==s&&void 0!==c)for(const t of e.paragraphs){const e=r.get(t.paragraphId);if(void 0===e||e<s||e>c)continue;const n=e===s?l.start.offset:0,d=e===c?l.end.offset:Number.POSITIVE_INFINITY,u=Math.max(n,t.startOffset),p=Math.min(d,t.endOffset);if(!(u>=p))for(const r of t.lines){const e=Math.max(u,r.startOffset),t=Math.min(p,r.endOffset);if(e>=t)continue;const n=r.slots.find(t=>t.offset===e),l=r.slots.find(e=>e.offset===t)??r.slots[r.slots.length-1];n&&l&&a.push({commentId:i,left:n.left-o.left,top:r.top-o.top,width:Math.max(1,l.left-n.left),height:r.height})}}}return a}(o,e.state)),m(r.selectedImageBox),b(r.selectedTextBoxBox),v(r.selectedTableBox),l(r.inputBox),w(r.caretBox)},A=(e="selection")=>{const t=++R;queueMicrotask(()=>{t===R&&B(e)})},M=(e="content-change")=>(A(e),!1),F=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(a(e=>Zb(e,t.paragraphIds??[])),Lr()),A(e),t.resolveWhenDone?Promise.resolve():null),O=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),a({}),Lr();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];a(t=>Zb(t,e)),Lr()}A("content-change")}},D=async()=>{n({}),a({}),Lr(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),A("import")};we(()=>{e.state.selection.anchor.paragraphId,e.state.selection.anchor.runId,e.state.selection.anchor.offset,e.state.selection.focus.paragraphId,e.state.selection.focus.runId,e.state.selection.focus.offset,A("selection")}),we(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||A("content-change")}),we(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.markupAuthors,A("content-change")}),we(()=>{e.state.reviewDisplayMode,A("content-change")}),we(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{A("scroll")},r=()=>{A("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",r),o(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",r)})});const E=()=>C(null),L=()=>{R+=1,P.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:r,documentLayout:k,canvasSnapshotProvider:P,inputBox:i,selectionBoxes:s,commentHighlights:d,revisionMarkupBoxes:p,selectedImageBox:f,selectedTextBoxBox:h,selectedTableBox:y,caretBox:x,preferredColumnX:S,setPreferredColumnX:C,clearPreferredColumn:E,requestInputBoxSync:A,scheduleDeferredLayoutMeasurement:F,stabilizeLayoutAfterImport:D,syncMeasuredLayoutMetrics:M,syncInputBox:B,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:a,applyInvalidation:O,onCleanupHook:L}}(e)}function Qb(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function ey(e){return function(e){const t=(e,t)=>{const n=$e(e.document),o=Math.max(0,Math.min(fo(e),n.length-1)),r=io(e),a=n[o];if(!a)return e;const i=[...n],l={...a},s=pr("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(s):e.push(s),l.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(s):e.push(s),l.footer=e}else{const e=[...a.blocks];t<0?e.unshift(s):e.push(s),l.blocks=e}return i[o]=l,{...e,document:{...e.document,sections:i}}},n=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:Qb(n.redoStack,o),lastTransactionMeta:null},nextState:n.undoStack[n.undoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},o=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.redoStack.length?null:{history:{undoStack:Qb(n.undoStack,o),redoStack:n.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:n.redoStack[n.redoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},r=n=>{const o=e.imageOps().getSelectedImageInfo(e.state());if(!o)return!1;const r=Kr(e.state()),a=r.findIndex(e=>e.id===o.paragraph.id);if(a<0)return!1;const i=a+n;if(i<0||i>=r.length){const o=e.state(),r=t(o,n),a=Kr(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=Z(i,n<0?u(i):0);return e.applyTransactionalState(()=>Pb(r,l),{mergeKey:Vi}),e.focusInput(),!0}const l=r[i],s=n<0?u(l):0;return e.applyTransactionalState(e=>Pb(e,Z(l,s)),{mergeKey:Vi}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(lr)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function ty(e={}){const t=e.dbName??"oasis-editor-db",n=e.storeName??"documents",o=e.key??"current-document";let r=null;async function a(){return r||(r=await function(e){return new Promise((t,n)=>{const o=indexedDB.open(e.name,e.version);o.onerror=()=>{n(/* @__PURE__ */new Error(`Failed to open IndexedDB: ${o.error?.message}`))},o.onsuccess=()=>{t(o.result)},o.onupgradeneeded=t=>{const n=o.result;e.onUpgrade(n,t.oldVersion,t.newVersion)}})}({name:t,version:1,onUpgrade:e=>{e.objectStoreNames.contains(n)||e.createObjectStore(n)}}),r)}return{async saveDocument(e){await function(e,t,n,o){return new Promise((r,a)=>{try{const i=e.transaction([t],"readwrite"),l=i.objectStore(t).put(o,n);l.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${l.error?.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{a(/* @__PURE__ */new Error(`Transaction failed putting item in ${t}: ${i.error?.message}`))}}catch(i){a(i)}})}(await a(),n,o,e)},loadDocument:async()=>function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readonly").objectStore(t).get(n);a.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to get item from ${t}: ${a.error?.message}`))},a.onsuccess=()=>{o(a.result??null)}}catch(a){r(a)}})}(await a(),n,o),async clearDocument(){await function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readwrite"),i=a.objectStore(t).delete(n);i.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to delete item from ${t}: ${i.error?.message}`))},a.oncomplete=()=>{o()},a.onabort=a.onerror=()=>{r(/* @__PURE__ */new Error(`Transaction failed deleting item from ${t}: ${a.error?.message}`))}}catch(a){r(a)}})}(await a(),n,o)},close(){r&&(r.close(),r=null)}}}function ny(e){return function(e){const[t,n]=an([]),[o,r]=an([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},l=t=>{e.commitState(e.cloneState(t))},s=(t,n)=>{const o=e.stateSnapshot(),r=yn("txn:produce",()=>t(o),0);if(r===o)return;a=function(e,t,n,o,r=Date.now()){return{undoStack:void 0!==o?.mergeKey&&e.lastTransactionMeta?.mergeKey===o.mergeKey&&r-e.lastTransactionMeta.timestamp<1e3?e.undoStack:Qb(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const l=yn("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>$e(e.document).map(e=>[...(e.header??[]).map(e=>e.id),...e.blocks.map(e=>e.id),...(e.footer??[]).map(e=>e.id)].join("|")).join("||");if(n(e)!==n(t))return{dirtyAll:!0,structureChanged:!0};const o=Kr(e),r=Kr(t),a=/* @__PURE__ */new Map;for(const l of o)a.set(l.id,l);const i=[];for(const l of r){const e=a.get(l.id);if(!e){i.push(l.id);continue}if(e===l)continue;if(e.runs.length!==l.runs.length){i.push(l.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=l.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=qn(o),i=qn(r);if(Boolean(a)!==Boolean(i)||(a?.width??-1)!==(i?.width??-1)||(a?.height??-1)!==(i?.height??-1)||(a?.floating?.wrap??"")!==(i?.floating?.wrap??"")||Boolean(a?.floating?.behindDoc)!==Boolean(i?.floating?.behindDoc)||(a?.wrapPolygon?.length??-1)!==(i?.wrapPolygon?.length??-1)){t=!0;break}}t&&i.push(l.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(l),yn("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:s,applyHistoryState:l,resetTransactionGrouping:()=>{var e;e=a,a={...e,lastTransactionMeta:null}},updateHistoryState:e=>{a=e(a),i()},getHistoryState:()=>a,clearHistory:()=>{a={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}(e)}function oy(e){let t=e.state.document,n=e.state.selection;we(()=>{const o=e.state.document,r=e.state.selection,a=o!==t,i=r!==n;var l;if(t=o,n=r,e.state.activeSectionIndex,e.state.activeZone,l=e.state,Ai&&(Oi={anchor:{paragraphId:l.selection.anchor.paragraphId,runId:l.selection.anchor.runId,offset:l.selection.anchor.offset},focus:{paragraphId:l.selection.focus.paragraphId,runId:l.selection.focus.runId,offset:l.selection.focus.offset},activeZone:l.activeZone??"main",activeSectionIndex:l.activeSectionIndex??0}),e.isImportInProgress())return;const s=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(s),a&&(e.emit("change",s),e.emit("documentChange",s.document)),i&&e.emit("selectionChange",s.selection)})}function ry(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:g,getImageOps:f}=e,m=Mb({state:()=>r,applyState:l,applyTransactionalState:(e,t)=>W(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await F()},resetEditorChromeState:()=>G(),focusInput:d,requestLocalFontAccess:wa,prepareDocumentFonts:async e=>{await Pe(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),h=()=>"done"!==m.importProgress()?.phase&&"error"!==m.importProgress()?.phase&&null!==m.importProgress(),{measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:C,revisionMarkupBoxes:I,selectedImageBox:T,selectedTextBoxBox:k,selectedTableBox:P,caretBox:R,preferredColumnX:B,setPreferredColumnX:A,clearPreferredColumn:M,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyInvalidation:E,onCleanupHook:L}=Jb({state:r,surfaceRef:u,viewportRef:p,isImporting:h,zoomFactor:g}),N=ty({key:t().persistenceKey}),{status:$}=function(e,t,n){const[o,r]=an("Initial"),[a,i]=an(!1),l=()=>n.enabled??!1,s=n.persistence,c=_r(async e=>{if(l()&&a()){r("Saving...");try{const t=JSON.parse(JSON.stringify(ze(e)));await s.saveDocument(t),r("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),r("Error")}}},1e3);return we(it(()=>e.document,e=>{l()&&a()&&c(e)},{defer:!0})),Zn(async()=>{if(!l())return i(!0),void r("Saved");try{const e=await s.loadDocument();e&&t(e)}catch(e){n.logger?.error("persistence:load failed",e)}finally{i(!0),r("Saved")}}),{status:o}}(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=wo(e);a(t),G()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??N,logger:n}),{undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_}=ny({stateSnapshot:i,commitState:a,cloneState:s,applyLayoutInvalidation:E}),X=ey({state:()=>r,stateSnapshot:i,applyHistoryState:U,applyTransactionalState:W,focusInput:d,clearPreferredColumn:M,imageOps:f,updateHistoryState:V,getHistoryState:K}),G=()=>{M(),O({}),D({}),Lr(),x.clear(),_()};return oy({state:r,isImportInProgress:h,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:m,isImportInProgress:h,measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:C,revisionMarkupBoxes:I,selectedImageBox:T,selectedTextBoxBox:k,selectedTableBox:P,caretBox:R,preferredColumnX:B,setPreferredColumnX:A,clearPreferredColumn:M,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyLayoutInvalidation:E,onCleanupHook:L,fallbackPersistence:N,persistenceStatus:$,undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_,historyActions:X,resetEditorChromeState:G}}(e)}function ay(e){return db(e,e=>"textBox"===e.kind)}function iy(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function ly(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Gn(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return Ie(e,a,$(a,Wn(e)))}function sy(e,t,n,o={}){const r=ay(e),a=r&&Er(r.run);if(!r||!a)return e;const i=o.handleDirection??"se",l=i.includes("n")||i.includes("s"),s=i.includes("w"),c=i.includes("n"),d=Math.max(24,Math.round(t)),u=Math.max(24,Math.round(n)),{paragraphIndex:p,run:g}=r,f=d-a.width,m=u-a.height,h=Kr(e).map((e,t)=>t!==p?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Gn(e);const t=e.textBox,n={...t,width:d,height:u};return l&&t.body?.autoFit&&(n.body={...t.body,autoFit:!1}),t.floating&&(n.floating=function(e,t,n,o,r){let a=e;if(o&&0!==t){const n=e.positionH;n?.align||(a={...a,positionH:{...n??{},offset:(n?.offset??0)-t*In}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*In}})}return a}(t.floating,f,m,s,c)),{...e,textBox:n}})});return Ie(e,h,$(h,Wn(e)))}var cy=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),dy=e=>e.rows.reduce((e,t)=>Math.max(e,cy(t)),0),uy=(e,t)=>{let n=0;for(const o of e.cells){const e=Math.max(1,o.colSpan??1);if(t>=n&&t<n+e)return o;n+=e}return null};function py(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}var gy=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=py(e);if(t)return t}return null};function fy(e,t){return e.some(e=>Po(e).some(e=>e.id===t))}var my=(e,t,n)=>{const o=Jr(e,t);if(!o)return null;const r=F(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!fy(o,n))continue;const e=i(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Jr(e,t);if(!n)return[];if("footnote"===n.zone){const t=n.footnoteId?e.footnotes?.items[n.footnoteId]:void 0;return t?[t.blocks]:[]}const o=Fe(e)[n.sectionIndex];return o?"main"===n.zone?[o.blocks]:"header"===n.zone?[o.header,o.firstPageHeader,o.evenPageHeader].filter(e=>Boolean(e)):[o.footer,o.firstPageFooter,o.evenPageFooter].filter(e=>Boolean(e)):[]}(e,t),r.tablePath,t);if(!a)return null;const l=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),s=l.findIndex(e=>function(e,t){return e.blocks.some(e=>Po(e).some(e=>e.id===t))}(e,t));if(-1===s)return null;const c=py(l[s+n]);return c?Z(c,0):null};function hy(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function by(e,t,n){if("main"===n)return"blocks";const o=e.selection.focus.paragraphId;return"header"===n?[["header",t.header],["firstPageHeader",t.firstPageHeader],["evenPageHeader",t.evenPageHeader]].find(([,e])=>hy(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>hy(e,o))?.[0]??"footer":"blocks"}function yy(e){const t=Jr(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function vy(e,t){if("footnote"===t){const t=yy(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=$e(e.document),o=fo(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=by(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var xy=(e,t,n="main")=>{if("footnote"===n){const n=yy(e),o=e.document.footnotes,r=n?o?.items[n]:void 0;return n&&o&&r?{...e,document:{...e.document,footnotes:{...o,items:{...o.items,[n]:{...r,blocks:t}}}}}:e}const o=fo(e),r=$e(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const l=by(e,i,n),s=[...r];return s[a]="blocks"===l?{...i,blocks:t}:{...i,[l]:t},{...e,document:{...e.document,sections:s}}};function wy(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Sy(e,t){const n=i(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:wy(t),targetBlocks:e}:null}function Cy(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];if(!a||"table"!==a.type)return null;const i=[...r];return i[o.tableBlockIndex]=To(a),Sy(i,n)}var Iy=(e,t,n)=>{const o=F(e.document,e.selection.focus.paragraphId,fo(e));if(!o||e.selection.anchor.paragraphId!==e.selection.focus.paragraphId)return n(e);const r=function(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];return a&&"table"===a.type?Sy(function(e,t){const n=[...e];let o=n;for(let r=0;r<t.length;r+=1){const e=t[r];if(!e)break;const n=o[e.tableBlockIndex];if(!n||"table"!==n.type)break;const a={...n,rows:[...n.rows]};o[e.tableBlockIndex]=a;const i=a.rows[e.rowIndex];if(!i)break;const l={...i,cells:[...i.cells]};a.rows[e.rowIndex]=l;const s=l.cells[e.cellIndex];if(!s)break;const c={...s,blocks:[...s.blocks]};l.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,o);if(!r)return n(e);const a=n({...e,document:eo(r.targetCell.blocks.map(e=>"paragraph"===e.type?pn(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),i=$e(a.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...i),{...xy(e,r.targetBlocks,o.zone),selection:a.selection}};function Ty(e,t){const n=F(e.document,e.selection.focus.paragraphId,fo(e));return n?Cy(e,t,n):null}function ky(e,t,n,o){const r=xy(e,t,n);return o?{...r,selection:{anchor:Z(o,0),focus:Z(o,0)}}:r}function Py(e,t,n,o){const r=t.getTargetBlocks(e,n),a=i(r,o);return a?.[a.length-1]?.table??null}function Ry(e,t){const n=F(e.document,e.selection.focus.paragraphId,fo(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Py(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function By(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Ry(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.colSpan??1)>1)},o=t=>{const n=e.resolveVerticalTableCellRange(t);if(!n)return!1;const o=Py(t,e,n.zone,n.tablePath);if(!o)return!1;for(let e=n.startRowIndex;e<=n.endRowIndex;e+=1){const t=o.rows[e]?.cells[n.cellIndex];if(!t||"continue"===t.vMerge||1!==t.blocks.length||"paragraph"!==t.blocks[0]?.type)return!1}return!0},r=e=>t(e)||o(e),a=t=>{const n=Ry(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.rowSpan??1)>1&&"restart"===o?.vMerge)},i=e=>n(e)||a(e),l=t=>null!==Ry(t,e),s=t=>{const n=Ry(t,e);return Boolean(n&&dy(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function Ay(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function My(e){return e.blocks.flatMap(Po)}function Fy(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Oy(e,t){return function(e,t){const n=e.selection,o=fo(e),r=F(e.document,n.anchor.paragraphId,o),a=F(e.document,n.focus.paragraphId,o);if(!r||!a||r.zone!==a.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(r.tablePath,a.tablePath))return null;const l=t.getTargetBlocks(e,r.zone),s=i(l,r.tablePath),c=i(l,a.tablePath),d=s?.[s.length-1],u=c?.[c.length-1];if(!d||!u||d.table!==u.table)return null;const p=Fy(r),g=Fy(a),f=d.table,m=ln(f),h=m.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex),b=m.find(e=>e.rowIndex===g.rowIndex&&e.cellIndex===g.cellIndex);return h&&b?{anchorLocation:p,focusLocation:g,anchorCell:h,focusCell:b,tableBlock:f,tableLayout:m}:null}(e,t)}function Dy(e){return function(e){const t=t=>{const n=t.selection,o=Oy(t,e);if(!o||o.anchorLocation.rowIndex===o.focusLocation.rowIndex&&o.anchorLocation.cellIndex===o.focusLocation.cellIndex)return e.logger?.debug(`resolveTableCellRangeSelection: no expansion (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId})`),null;const r=Math.min(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),a=Math.max(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),i=Math.min(o.anchorLocation.cellIndex,o.focusLocation.cellIndex),l=Math.max(o.anchorLocation.cellIndex,o.focusLocation.cellIndex);e.logger?.info(`resolveTableCellRangeSelection: expanding r${o.anchorLocation.rowIndex}:c${o.anchorLocation.cellIndex}->r${o.focusLocation.rowIndex}:c${o.focusLocation.cellIndex} (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId}) range=[rows ${r}..${a}, cells ${i}..${l}]`);const s=Ay(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Ay(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[s.rowIndex]?.cells[s.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?My(d)[0]:void 0,g=u?My(u):[],f=g[g.length-1];return p&&f?{anchor:Z(p,0),focus:Z(f,Lt(f).length)}:null},n=t=>{const n=Oy(t,e);if(!n)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex+n.anchorCell.rowSpan-1,n.focusCell.visualRowIndex+n.focusCell.rowSpan-1),a=Math.min(n.anchorCell.visualColumnIndex,n.focusCell.visualColumnIndex),i=Math.max(n.anchorCell.visualColumnIndex+n.anchorCell.colSpan-1,n.focusCell.visualColumnIndex+n.focusCell.colSpan-1),l=n.tableLayout.filter(e=>e.visualRowIndex<=r&&e.visualRowIndex+e.rowSpan-1>=o&&e.visualColumnIndex<=i&&e.visualColumnIndex+e.colSpan-1>=a);return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),cells:l,zone:n.anchorLocation.zone}},o=t=>{const n=Oy(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Ay(n.anchorCell,n.focusCell);if(0===o)return null;const r=o<=0?n.anchorLocation:n.focusLocation,a=o<=0?n.focusLocation:n.anchorLocation;return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:a.cellIndex,zone:n.anchorLocation.zone}},r=t=>{const n=Oy(t,e);if(!n||n.anchorLocation.cellIndex!==n.focusLocation.cellIndex)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex);return o===r?null:{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),startRowIndex:o,endRowIndex:r,cellIndex:n.anchorLocation.cellIndex,zone:n.anchorLocation.zone}};return{resolveTableCellRangeSelection:t,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:r}}(e)}function Ey(e){if(e)for(const t of e.blocks){const e=Po(t)[0];if(e)return e}}function Ly(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Cy(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Ny(e){return function(e){const t=e=>({...e,style:e.style?{...e.style}:void 0,conditionalStyle:e.conditionalStyle?{...e.conditionalStyle}:void 0,mergeRevisionState:void 0,blocks:e.blocks.map(e=>To(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Ly(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=a.rows[o.rowIndex];if(!l)return n;const s=l.cells.slice(o.startCellIndex,o.endCellIndex+1);if(s.length<2)return n;const c=n.trackChangesEnabled?us():void 0,d={...s[0],colSpan:s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:s.flatMap(e=>e.blocks.map(e=>To(e))),...c?{style:{...s[0].style??{},revision:{...c,type:"merge",previous:{colSpan:s[0].colSpan,rowSpan:s[0].rowSpan,vMerge:s[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"horizontal",currentCellCount:1,previousCells:s.map(t)}}:{}};l.cells.splice(o.startCellIndex,s.length,d);const u=Ey(d);return u?ky(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Ly(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=[];for(let e=o.startRowIndex;e<=o.endRowIndex;e+=1){const t=a.rows[e],r=t?.cells[o.cellIndex];if(!t||!r||"continue"===r.vMerge||1!==r.blocks.length||"paragraph"!==r.blocks[0]?.type)return n;l.push(r)}if(l.length<2)return n;const s=Math.max(1,l[0].colSpan??1);if(!l.every(e=>Math.max(1,e.colSpan??1)===s))return n;const c=n.trackChangesEnabled?us():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>To(e))),...c?{style:{...l[0].style??{},revision:{...c,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"vertical",currentCellCount:1,previousCells:l.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=Gr([pr("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Ey(d);return u?ky(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Ty(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex]?.cells[a.cellIndex],s=Math.max(1,l?.rowSpan??1);if(!l||s<=1||"restart"!==l.vMerge)return n;const c=t(l),d=n.trackChangesEnabled?us():void 0,u=Math.max(1,l.colSpan??1);l.rowSpan=void 0,l.vMerge=void 0,d&&(l.style={...l.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},l.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:s-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):Gr([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=Gr([pr("")],u);t.cells[a.cellIndex]=n}const p=Ey(l);return p?ky(n,i,a.zone,p):n},i=n=>{const o=Ty(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex],s=l?.cells[a.cellIndex],c=Math.max(1,s?.colSpan??1);if(!l||!s||c<=1)return n;const d=t(s),u=n.trackChangesEnabled?us():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>To(e)),...u?{style:{...s.style??{},revision:{...u,type:"merge",previous:{colSpan:d.colSpan,rowSpan:d.rowSpan,vMerge:d.vMerge}}},mergeRevisionState:{revisionId:u.id,orientation:"horizontal",currentCellCount:c,previousCells:[d]}}:{}},...Array.from({length:c-1},()=>Gr([pr("")]))];l.cells.splice(a.cellIndex,1,...p);const g=Ey(p[0]);return g?ky(n,i,a.zone,g):n},l=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:l}}(e)}function $y(e,t){e.style={...e.style??{},revision:{...us(),type:t}}}function zy(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}function Hy(e,t,n){const o=zy(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=zy(r);if(e)return e}return gy(e)}function Wy(e){return function(e){const t=(t,n)=>{const o=Ty(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex];if(!l)return t;const s=Math.max(0,Math.min(r.rows.length,a.rowIndex+(n>0?1:0)));let c;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge))){const e=ln(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),l=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=ma(l.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<s&&e.visualRowIndex+e.rowSpan>s);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=Gr([pr("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return Gr([pr("")],t.colSpan)})),t.trackChangesEnabled&&$y(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=Hy(r,uy(c,d),c);return ky(t,i,a.zone,u)}c=ma(l.cells.map(e=>Gr([pr("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&$y(c,"insert"),r.rows.splice(s,0,c);const d=Hy(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return ky(t,i,a.zone,d)},n=t=>{const n=Ty(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(o.rows.length<=1&&!t.trackChangesEnabled)return t;const i=o.rows[r.rowIndex];if(!i)return t;if(t.trackChangesEnabled)return $y(i,"delete"),ky(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const l=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),s=l?ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=ln(o);for(const t of e)t.visualRowIndex<r.rowIndex&&t.visualRowIndex+t.rowSpan>r.rowIndex&&(t.cell.rowSpan=Math.max(1,t.cell.rowSpan??1)-1,t.cell.rowSpan<=1?(t.cell.rowSpan=void 0,t.cell.vMerge=void 0):t.cell.vMerge="restart")}o.rows.splice(r.rowIndex,1);const c=o.rows[Math.min(r.rowIndex,o.rows.length-1)],d=Hy(o,c?uy(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,cy(c)-1))):null);return ky(t,a,r.zone,d)},o=(t,n)=>{const o=Ty(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=ln(r).find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=(e?.visualColumnIndex??a.cellIndex)+(n>0?Math.max(1,e?.colSpan??1):0);for(const n of r.rows){const e=[];let r=0,a=!1;for(const i of n.cells){const n=Math.max(1,i.colSpan??1);if(!a&&o<=r){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.push(n),a=!0}!a&&r<o&&o<r+n?(e.push({...i,colSpan:n+1,...t.trackChangesEnabled?{style:{...i.style??{},revision:{...us(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=Hy(r,l?uy(l,o):null);return ky(t,i,a.zone,s)}const l=Math.max(0,Math.min(r.rows[0]?.cells.length??0,a.cellIndex+(n>0?1:0)));for(const e of r.rows){const n=Gr([pr("")]);t.trackChangesEnabled&&$y(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=Hy(r,s);return ky(t,i,a.zone,c)},r=t=>{const n=Ty(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(dy(o)<=1)return t;if(t.trackChangesEnabled){const e=ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=uy(t,e);n&&$y(n,"delete")}return ky(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=[];let o=0;for(const r of t.cells){const t=Math.max(1,r.colSpan??1);e>=o&&e<o+t?t>1&&n.push({...r,colSpan:t-1>1?t-1:void 0}):n.push(r),o+=t}t.cells=n}const n=o.rows[r.rowIndex],i=Hy(o,n&&uy(n,Math.min(e,Math.max(0,cy(n)-1))));return ky(t,a,r.zone,i)}if(o.rows[0]?.cells.length<=1)return t;for(const e of o.rows)e.cells.splice(r.cellIndex,1);const i=o.rows[r.rowIndex],l=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],s=Hy(o,l);return ky(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function Uy(e){return function(e){const t=t=>{const n=e.resolveTableCellRangeSelection(t);return n?e.applySelectionToStatePreservingStructure(t,n):t},n=(n,o)=>{e.applyTransactionalState(r=>{const a=e.resolveSelectedTableCells(r);if(!a||a.cells.length<=1){const a=t(r);return a!==r&&e.logger?.info(`${o}: expanded selection to ${a.selection.anchor.paragraphId}[${a.selection.anchor.offset}]..${a.selection.focus.paragraphId}[${a.selection.focus.offset}]`),n(a)}const{blockIndex:i,tablePath:l,cells:s,zone:c}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${l.length} (${s.length} cells) in zone ${c}`);const d=[],u=[];for(const e of s){const t=e.cell.blocks.flatMap(Po);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p=n({...r,document:eo(d,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Z(d[0],0),focus:Z(d[d.length-1],Lt(d[d.length-1]).length)}}),g=Kr(p),f=l[l.length-1];if(!f)return r;const m=Cy(r,e.getTargetBlocks,{blockIndex:i,rowIndex:f.rowIndex,cellIndex:f.cellIndex,paragraphIndex:0,tablePath:l,zone:c});if(!m)return r;let h=0;for(let e=0;e<s.length;e+=1){const t=s[e],n=u[e]??0,o=g.slice(h,h+n);h+=n;const r=m.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=st(r.blocks,o))}return xy(r,m.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function jy(e){return function(e){const t=vy,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Dy({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=By({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Ny({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:C}=Wy({getTargetBlocks:t}),I=(e,n)=>Iy(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P}=Uy({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,logger:e.logger}),R=(t,n)=>{e.logger?.info(`insertTableCommand: ${t}x${n}`),e.applyTransactionalState(e=>function(e,t,n){const o=100/Math.max(1,n)+"%",r=e.trackChangesEnabled?us():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...Gr([pr("")]),style:{width:o}});const t=ma(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...bn(a),style:{width:"100%"}},l=nr(e,e.selection.focus),s=Fe(e.document),c=fo(e),d=io(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&Po(e).some(e=>e.id===l.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=s[c];if(!p)return e;const g={...p};let f=!1;if("header"===d){const e=u(p.header??[]);g.header=e.nextBlocks,f=e.found}else if("footer"===d){const e=u(p.footer??[]);g.footer=e.nextBlocks,f=e.found}else{const e=u(p.blocks);g.blocks=e.nextBlocks,f=e.found}if(!f)return e;const m=[...s];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:oe(Z(h,0))}}(e,t,n),{mergeKey:ji}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:C,getRowVisualWidth:cy,getTableVisualWidth:dy,findCellAtVisualColumn:uy,findFirstNavigableParagraphInTable:gy,updateBlocksInCurrentSection:xy,resolveAdjacentTableCellPosition:my,applyTableAwareParagraphEdit:I,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P,insertTableCommand:R}}(e)}function Vy(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function Ky(e,t){let n=null;const o=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=Vy(),i=i=>{if(!a.owns(i))return;const l=n;if(!l)return;const s=t.zoomFactor?.()??1,c=(i.clientX-l.startClientX)/s,d=(i.clientY-l.startClientY)/s,u=e.getMaxWidth(t.state,l.paragraphId),{width:p,height:g}=Ia(l,c,d,i.shiftKey,u),f=o(t.state,l.paragraphId,l.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,l.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,l)},l=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Qb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),s(),t.focusInput()},s=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)};return{start:(s,c,d,u,p)=>{const g=o(p,s,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:s,paragraphOffset:c,handleDirection:d,startClientX:u.clientX,startClientY:u.clientY,startWidth:f.width,startHeight:f.height,aspectRatio:f.width/f.height,initialState:t.cloneState(p)},a.claim(u),window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l))},stop:s}}function _y(e,t){let n=null;const o=Vy(),r=r=>{if(!o.owns(r))return;const a=n;if(!a)return;let i=((180*Math.atan2(r.clientY-a.centerY,r.clientX-a.centerX)/Math.PI+90)%360+360)%360;r.shiftKey&&(i=15*Math.round(i/15)%360);const l=((e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);l?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,l),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Qb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),i(),t.focusInput()},i=()=>{n=null,o.release(),window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)};return{start:(e,i,l,s)=>{const c=l.currentTarget.closest(".oasis-editor-selection-overlay");if(!c)return;const d=c.getBoundingClientRect();n={paragraphId:e,paragraphOffset:i,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:t.cloneState(s)},o.claim(l),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function Xy(e,t){return Math.max(1e-4,1-e-t)}function Gy(e,t,n,o){const r=Math.max(.01,1-e-t),a=Math.max(0,Math.min(n,.99-t)),i=Math.max(0,Math.min(o,.99-a));return a+i>=.99?{near:Math.max(0,.99-r-t),far:t}:{near:a,far:i}}function qy(e){let t=null;const n=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=Vy(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const l=e.zoomFactor?.()??1,s=(a.clientX-i.startClientX)/l,c=(a.clientY-i.startClientY)/l,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=Xy(a,l)/o,d=Xy(i,s)/r,u=1-a-l,p=1-i-s,g=Math.max(0,Math.min(1-u,a-t*c)),f=Math.max(0,Math.min(1-p,i-n*d));return{crop:{left:g,right:Math.max(0,1-u-g),top:f,bottom:Math.max(0,1-p-f)},width:Math.round(o),height:Math.round(r)}}(i,s,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=Xy(a,l)/o,d=Xy(i,s)/r,u=Ae(e.handleDirection,"x"),p=Ae(e.handleDirection,"y");let g=a,f=l,m=o;if(0!==u)if(u<0){m=gt(o-t,24,o+a/c);const e=Gy(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=gt(o+t,24,o+l/c);const e=Gy(a,l,a,l-(m-o)*c);g=e.near,f=e.far}let h=i,b=s,y=r;if(0!==p)if(p<0){y=gt(r-n,24,r+i/d);const e=Gy(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=gt(r+n,24,r+s/d);const e=Gy(i,s,i,s-(y-r)*d);h=e.near,b=e.far}return{crop:{left:g,top:h,right:f,bottom:b},width:Math.round(m),height:Math.round(y)}}(i,s,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(yb(o(e.state,u),{crop:d.crop,width:d.width,height:d.height})):e.logger.warn("image crop:missing paragraph",i)},i=()=>{const n=t;n&&e.updateHistoryState(t=>({...t,undoStack:Qb(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),l(),e.focusInput()},l=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},s=(l,s,c,d,u,p)=>{const g=n(u,l,s);if(!g)return;const f=mb(o(u,g)),m=f&&qn(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:l,paragraphOffset:s,handleDirection:c,startClientX:d.clientX,startClientY:d.clientY,startWidth:m.width,startHeight:m.height,startCrop:h,initialState:e.cloneState(u),mode:p},r.claim(d),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)};return{start:(e,t,n,o,r)=>s(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>s(e,t,"se",n,o,"move"),stop:l}}function Yy(e){return function(e){const[t,n]=an(!1),[o,r]=an(!1),[a,i]=an(null);we(()=>{o()&&!m(e.state)&&r(!1)});const l=()=>{m(e.state)?r(e=>!e):r(!1)},[s,c]=an({x:0,y:0}),[d,u]=an(null);let p=null,g=null,f=null;const m=e=>{const t=Wn(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=Kr(e)[t.startIndex];if(!n)return null;let o=0;for(const r of n.runs){const a=o;if(o+=r.text.length,"image"===r.kind&&1===r.text.length&&a===t.startParagraphOffset)return{paragraph:n,run:r,startOffset:a,width:r.image.width,height:r.image.height,src:Ze(e.document,r.image.src)}}return null},h=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),b=()=>{f||(f=document.createElement("style"),f.setAttribute("data-oasis-image-drag-cursor",""),f.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(f))},y=()=>{f&&(f.remove(),f=null),document.body.style.cursor=""},v=Vy(),x=()=>{y(),g=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P)},w=()=>{x()},S=Ky({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>hb(e,t,n),getMaxWidth:(t,n)=>Rb(e.surfaceRef(),t.document,n,t.activeSectionIndex??0)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),C=_y({label:"image",applyRotate:(e,t)=>function(e,t){const n=Sb(t);return Tb(e,e=>({...e,rotation:n}))}(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),I=qy({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),k=t=>{if(!v.owns(t))return;let o=p;if(!o){const r=g;if(!r)return;if(Math.abs(t.clientX-r.startClientX)+Math.abs(t.clientY-r.startClientY)<4)return;o={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},p=o,g=null,n(!0),b(),e.logger.info(`image drag:start ${o.paragraphId}@${o.paragraphOffset} client=(${t.clientX},${t.clientY})`)}c({x:t.clientX,y:t.clientY}),i({...o}),u(h(t.clientX,t.clientY))},P=t=>{if(!v.owns(t))return;const n=p;if(n||g){if(n){const o=h(t.clientX,t.clientY);o?(e.logger.info(`image drag:done ${n.paragraphId} -> ${o.paragraphId}:${o.runId}[${o.offset}]`),e.applyTransactionalState(e=>Pb(e,o),{mergeKey:Vi})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},R=(t,o,r,a)=>{const l=r.currentTarget,s=a?{left:a.left,top:a.top,width:a.width,height:a.height}:l?.getBoundingClientRect();if(!s)return;const d=m(e.state);g={paragraphId:t,paragraphOffset:o,startClientX:r.clientX,startClientY:r.clientY,src:d?.src??"",width:d?.width??s.width,height:d?.height??s.height,offsetX:r.clientX-s.left,offsetY:r.clientY-s.top},p=null,c({x:r.clientX,y:r.clientY}),n(!1),i(null),u(null),v.claim(r),window.addEventListener("pointermove",k),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P)},B=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=T(e.state.document).find(e=>e.id===t);r&&e.applyState(Aa(e.state,{anchor:Z(r,n),focus:Z(r,n+1)})),R(t,n,o),e.focusInputAfterPointerSelection()},A=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,o,r,e.state)},M=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.start(t,n,o,e.state)},F=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),I.start(t,n,o,r,e.state)},O=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),I.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:l,draggedImageInfo:a,mousePos:s,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:R,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:C.stop,stopImageCrop:I.stop,handleImagePointerDown:B,handleImageResizeHandlePointerDown:A,handleImageRotateHandlePointerDown:M,handleImageCropHandlePointerDown:F,handleImageCropBodyPointerDown:O}}(e)}function Zy(e){return function(e){const t=e=>{const t=ay(e),n=t&&Er(t.run);return n?{width:n.width,height:un(n,e,0)}:null},n=Ky({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>sy(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=Rb(e.surfaceRef(),n.document,o,n.activeSectionIndex??0),a=t(n);return a?Math.max(r,a.width):r}},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),o=_y({label:"text box",applyRotate:(e,t)=>iy(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),r=(t,o,r,a)=>{a.preventDefault(),a.stopPropagation(),n.start(t,o,r,a,e.state)},a=(t,n,r)=>{r.preventDefault(),r.stopPropagation(),o.start(t,n,r,e.state)};return{handleTextBoxResizeHandlePointerDown:r,handleTextBoxRotateHandlePointerDown:a,stopTextBoxResize:n.stop,stopTextBoxRotate:o.stop}}(e)}function Jy(e){return function(e){const[t,n]=an(void 0),o=()=>{n(void 0)};we(()=>{zr(e.state().selection)||o()});const r=(e,t)=>{n(n=>{const o={...n??{}};return null==t||""===t?delete o[e]:o[e]=t,Object.keys(o).length>0?o:void 0})},a=(e,t)=>{n(n=>{const o={...n??{}};return o[e]=t,"superscript"===e&&t&&(o.subscript=!1),"subscript"===e&&t&&(o.superscript=!1),o})},i=()=>{const n=ie(e.state()),o=t();return zr(e.state().selection)&&o?{...n,bold:o.bold??n.bold,italic:o.italic??n.italic,underline:o.underline??n.underline,underlineStyle:void 0!==o.underlineStyle?String(o.underlineStyle??""):n.underlineStyle,strike:o.strike??n.strike,superscript:o.superscript??n.superscript,subscript:o.subscript??n.subscript,fontFamily:o.fontFamily??n.fontFamily,fontSize:void 0!==o.fontSize&&null!==o.fontSize?String(o.fontSize):n.fontSize,color:o.color??n.color,highlight:o.highlight??n.highlight,textShading:o.shading??n.textShading,link:o.link??n.link,characterStyleId:void 0!==o.styleId&&null!==o.styleId?String(o.styleId):n.characterStyleId}:n},l=(t,n)=>{if(zr(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),r(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},s=t=>{if(zr(e.state().selection)){const n=!i()[t];return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),a(t,n),void e.focusInput()}e.commandsController().applyBooleanStyleCommand(t)},c=t=>{if(zr(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),n(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:o,toolbarStyleState:i,applyToolbarValueStyleCommand:l,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:s}}(e)}function Qy(e,t,n={}){if(!t)return[];const o=[],r=T(e),{matchCase:a=!1,wholeWord:i=!1}=n,l=a?"g":"gi";let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const c=new RegExp(s,l);return r.forEach((e,t)=>{const n=Lt(e);let r;for(c.lastIndex=0;null!==(r=c.exec(n));){const n=r.index,a=r.index+r[0].length;o.push({anchor:Z(e,n),focus:Z(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function ev(e,t,n,o={}){const r=Qy(e.document,t,o);if(0===r.length)return e;let a=e;for(let i=r.length-1;i>=0;i-=1){const e=r[i];a=Aa(a,{anchor:e.anchor,focus:e.focus}),a=za(a,n)}return a}function tv(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*tt+(r<e?e-r:r>i?r-i:0)}function nv(e,t,n){if(0===e.slots.length)return{offset:e.startOffset,score:Number.POSITIVE_INFINITY};let o=e.slots[0].offset,r=Number.POSITIVE_INFINITY,a=e.slots[0].left,i=e.slots[0].top,l=e.slots[0].height;for(const s of e.slots){const e=n<s.top?s.top-n:n>s.top+s.height?n-(s.top+s.height):0,c=Math.abs(t-s.left),d=e*tt+c;d<r&&(r=d,o=s.offset,a=s.left,i=s.top,l=s.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:l}}function ov(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=nv(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function rv(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function av(e){const{snapshot:t,state:n}=e,o=e.pierce??!1,r=e.zoomFactor&&e.zoomFactor>0?e.zoomFactor:1,a=t.surfaceRect,i=a.left+(e.clientX-a.left)/r,l=a.top+(e.clientY-a.top)/r,s=function(e,t,n){if(0===e.length)return null;let o=e[0],r=Number.POSITIVE_INFINITY;for(const a of e){const e=tv(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,l);if(!s)return null;const c=function(e,t){const n=t-e.top;return n<e.bodyTop?"header":void 0!==e.footnoteSeparatorTop&&n>=e.footnoteSeparatorTop&&n<(e.footerTop??e.height)?"footnote":n>=e.bodyBottom?"footer":"main"}(s,l),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const l=e.floatingTextBoxes[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&o>=l.left&&o<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(t,s.index,c,i,l,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&d.startOffset>=e.startOffset&&d.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(d.startOffset,n.endOffset)),t=Z(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:d.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:d.left,top:d.top,height:d.height},textBox:{paragraphId:d.paragraphId,paragraphOffset:e,startOffset:d.startOffset,endOffset:d.endOffset,left:d.left,top:d.top,width:d.width,height:d.height}}}}const u=function(e,t,n,o,r,a){for(let i=e.floatingImages.length-1;i>=0;i-=1){const l=e.floatingImages[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&rv(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&rv(o,r,i))return i;return null}(t,s.index,c,i,l,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&u.startOffset>=e.startOffset&&u.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(u.startOffset,n.endOffset)),t=Z(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:u.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},image:{paragraphId:u.paragraphId,paragraphOffset:e,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const p=function(e,t,n){if(0===e.length)return null;let o=null;for(const i of e)for(const e of i.lines){const r=e.top-2,a=e.top+e.height+2;if(n<r||n>a)continue;const{offset:l,score:s,slotLeft:c,slotTop:d,slotHeight:u}=nv(e,t,n);(!o||s<o.score)&&(o={paragraph:i,offset:l,score:s,caretViewport:void 0!==c&&void 0!==d&&void 0!==u?{left:c,top:d,height:u}:void 0})}if(o)return{paragraph:o.paragraph,offset:o.offset,caretViewport:o.caretViewport};let r=null,a=Number.POSITIVE_INFINITY;for(const i of e){const e=tv(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),t,n);e<a&&(a=e,r=i)}return r?{paragraph:r,offset:ov(r,t,n),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(t.paragraphs.filter(e=>e.pageIndex===s.index&&e.zone===c),i,l);if(!p){const e=n.selection.focus.paragraphId,o=n.selection.focus.offset,r=function(e,t,n,o,r){return e.unsupportedRegions.find(e=>e.pageIndex===t&&e.zone===n&&o>=e.left&&o<=e.left+e.width&&r>=e.top&&r<=e.top+e.height)?.reason??null}(t,s.index,c,i,l);return{zone:c,paragraphId:e,paragraphOffset:o,position:{...n.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:r??"zone-without-paragraph"}}const g=p.paragraph,f=Math.max(0,Math.min(p.offset,g.textLength)),m=Z(g.paragraph,f);return{zone:c,footnoteId:g.footnoteId,paragraphId:g.paragraphId,paragraphOffset:f,position:m,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:g.tableCell?.anchorPosition,caretViewport:p.caretViewport}}function iv(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),l=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){Ai&&(Fi=e?function(e){return{surfaceRect:{left:e.surfaceRect.left,top:e.surfaceRect.top,width:e.surfaceRect.width,height:e.surfaceRect.height},pages:(t=e.pages,t.map(e=>({index:e.index,left:e.left,top:e.top,width:e.width,height:e.height,bodyTop:e.bodyTop,bodyBottom:e.bodyBottom}))),paragraphs:e.paragraphs.map(e=>{return{paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,textLength:e.textLength,left:e.left,top:e.top,width:e.width,height:e.height,lines:(t=e.lines,t.map(e=>{return{startOffset:e.startOffset,endOffset:e.endOffset,top:e.top,height:e.height,slots:(t=e.slots,t.map(e=>({offset:e.offset,left:e.left,top:e.top,height:e.height})))};var t})),tableCell:e.tableCell?{tableId:e.tableCell.tableId,rowIndex:e.tableCell.rowIndex,cellIndex:e.tableCell.cellIndex,left:e.tableCell.left,top:e.tableCell.top,width:e.tableCell.width,height:e.tableCell.height}:void 0,verticalMode:e.verticalMode};var t}),inlineImages:e.inlineImages.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height})),inlineTextBoxes:e.inlineTextBoxes.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height,rotation:e.rotation})),unsupportedRegions:e.unsupportedRegions.map(e=>({...e}))};var t}(e):null)}(l),!l)return Li(null),null;const s=av({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return Li(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var lv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],sv=/* @__PURE__ */new Map;function cv(){return lv.map(e=>({...e}))}var dv=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function uv(e,t,n){const[o,r]=e,[a,i]=t,[l,s]=n,c=l-a,d=s-i,u=c*c+d*d;return 0===u?Math.hypot(o-a,r-i):Math.abs(c*(i-r)-d*(a-o))/Math.sqrt(u)}function pv(e,t){if(e.length<3)return e.slice();let n=0,o=0;const r=e[0],a=e[e.length-1];for(let s=1;s<e.length-1;s+=1){const t=uv(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=pv(e.slice(0,o+1),t),l=pv(e.slice(o),t);return[...i.slice(0,-1),...l]}function gv(e,t,n){let o=0;for(let s=0;s<e.length;s+=1)1===e[s]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return cv();const r=function(e,t,n){const o=(o,r)=>o>=0&&o<t&&r>=0&&r<n&&1===e[r*t+o];let r=-1,a=-1;for(let u=0;u<n&&a<0;u+=1)for(let n=0;n<t;n+=1)if(1===e[u*t+n]){r=n,a=u;break}if(r<0)return[];const i=[];let l=r,s=a,c=6;const d=t*n*4;for(let u=0;u<d;u+=1){let e=!1;for(let t=1;t<=8;t+=1){const n=(c+t)%8,[r,a]=dv[n],d=l+r,u=s+a;if(o(d,u)){i.push([l,s]),c=(n+4)%8,l=d,s=u,e=!0;break}}if(!e){i.push([l,s]);break}if(l===r&&s===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return cv();const a=.012*Math.max(t,n);let i=pv(r,a),l=a;for(;i.length>40;)l*=1.6,i=pv(r,l);return i.length<3?cv():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function fv(e){const t=e.src,n=sv.get(t);if(n)return n.map(e=>({...e}));const o=function(e){const t=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(!t||!n)return null;const o=Math.min(1,256/Math.max(t,n)),r=Math.max(1,Math.round(t*o)),a=Math.max(1,Math.round(n*o)),i=document.createElement("canvas");i.width=r,i.height=a;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(e,0,0,r,a);try{s=l.getImageData(0,0,r,a).data}catch{return null}const c=new Uint8Array(r*a);let d=0;for(let u=0;u<c.length;u+=1)s[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return cv();const r=gv(o.mask,o.width,o.height);return sv.set(t,r),r.map(e=>({...e}))}function mv(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>mb(t())?"image":ay(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},l=(e,n)=>{const r=Ze(t().document,n),a=t=>{const n=fv(t);o(t=>function(e,t,n){const o=Kr(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...pn(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Gn(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:pn(e));return r?Ie(e,a,$(a,Wn(e))):e}(t,e,n),{mergeKey:tl})},i=Zt(r,()=>{i.naturalWidth>0&&a(i)});i.complete&&i.naturalWidth>0&&a(i)};return{target:a,preset:()=>{const e=a();return"image"===e?function(e){const t=mb(e),n=t&&qn(t.run);return n?pb(n.floating):null}(t()):"textBox"===e?function(e){const t=ay(e),n=t&&Er(t.run);return n?pb(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=mb(e),n=t&&qn(t.run);return fb(n?.floating)}(t()):"textBox"===e&&function(e){const t=ay(e),n=t&&Er(t.run);return fb(n?.floating)}(t())},setPreset:e=>{if(i(Vl,(t,n)=>"image"===n?function(e,t){return kb(e,e=>ub(e,t))}(t,e):function(e,t){return ly(e,e=>ub(e,t))}(t,e)),"tight"===e||"through"===e){const e=mb(t()),n=e&&qn(e.run);n&&!n.wrapPolygon&&l(e.run.id,n.src)}},setFixedPosition:e=>i(Kl,(t,n)=>"image"===n?function(e,t){return kb(e,e=>e?gb(e,t):e)}(t,e):function(e,t){return ly(e,e=>e?gb(e,t):e)}(t,e))}}function hv(e){return function(e){const t=t=>{const n=Ba(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Oa(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},n=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Ba(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Oa(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),e.focusInput()}},o=t=>{if(e.isReadOnly())return void t.preventDefault();const n=e.consumePasteMode?.();if(e.forcePlainTextPaste()||"text"===n){e.setForcePlainTextPaste(!1);const n=t.clipboardData?.getData("text/plain")??"";return 0===n.length?void t.preventDefault():(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e,n))),t.currentTarget.value="",void e.focusInput())}const o="merge"!==n?sb(t.clipboardData):null;if(o)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(o),t.currentTarget.value="",void e.focusInput();const r=ni(t.clipboardData?.getData("text/html")??""),a="merge"===n?ti(e.state(),r):r;if(a.length>0)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e,a))),t.currentTarget.value="",void e.focusInput();const i=t.clipboardData?.getData("text/plain")??"";0!==i.length&&(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e,i))),t.currentTarget.value="",e.focusInput())},r=t=>{if(e.isReadOnly())return void t.preventDefault();const n=sb(t.dataTransfer);if(!n)return;t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??e.state().selection.focus;e.insertImageFromFile(n,o),e.focusInput()};return{handleCopy:t,handleCut:n,handlePaste:o,handleDrop:r}}(e)}var bv=/* @__PURE__ */new WeakMap;function yv(e,t){return function(e){return $e(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function vv(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=bv.get(a);if(i)return i;const l=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(const d of a.paragraphs){const e=d.tableCell;if(!e)continue;const t=`${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,n=l.get(e.tableId)??/* @__PURE__ */new Map;let o=n.get(t);o||(o={tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,pageIndex:d.pageIndex,left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height,width:e.width,height:e.height,contentMinWidth:0,contentMinHeight:0},n.set(t,o),l.set(e.tableId,n));const r=d.lines.flatMap(e=>e.slots.map(e=>e.left)),a=d.lines.map(e=>e.top+e.height),i=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,u=d.lines.length>0?d.lines[0].top:d.top,p=a.length>0?Math.max(...a):d.top+d.height,g=`${e.tableId}:${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,f=s.get(g);f?(f.left=Math.min(f.left,i),f.top=Math.min(f.top,u),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):s.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of l.entries())for(const e of u.values()){const t=s.get(`${d}:${e.pageIndex}:${e.rowIndex}:${e.cellIndex}`);t&&(e.contentMinWidth=Math.max(0,t.right-t.left),e.contentMinHeight=Math.max(0,t.bottom-t.top))}const c=[];for(const[d,u]of l.entries()){const e=Array.from(u.values());if(0===e.length)continue;const t=Math.min(...e.map(e=>e.left)),n=Math.min(...e.map(e=>e.top)),o=Math.max(...e.map(e=>e.right)),r=Math.max(...e.map(e=>e.bottom));c.push({tableId:d,cells:e,bounds:{left:t,top:n,right:o,bottom:r,width:Math.max(1,o-t),height:Math.max(1,r-n)}})}return bv.set(a,c),c}function xv(e,t,n,o,r,a){const i=vv(t,n,o,r,a);if(0===i.length)return null;let l=null;for(const d of i)if(!(e.clientX<d.bounds.left-4||e.clientX>d.bounds.right+4||e.clientY<d.bounds.top-4||e.clientY>d.bounds.bottom+4))for(const t of d.cells){const n=e.clientY>=t.top-4&&e.clientY<=t.bottom+4,o=e.clientX>=t.left-4&&e.clientX<=t.right+4;if(n){const n=Math.abs(e.clientX-t.left);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"bottom",distance:o})}}if(!l)return null;const s=yv(n,l.geometry.tableId);if(!s)return null;const c=ln(s).find(e=>e.rowIndex===l.cell.rowIndex&&e.cellIndex===l.cell.cellIndex);return c?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:c,tableGeometry:l.geometry}:null}var wv=1/.75;function Sv(e){return.75*e}function Cv(e){return e*wv}var Iv=zs;function Tv(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Cv(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Cv(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Cv(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Cv(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Cv(e.style.borderRight.width)):1)}function kv(e,t,n){const o=Math.max(1,e.rows.length),r=n.bounds.height/o,a=Array(o).fill(r),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(let l=0;l<o;l+=1){const n=Iv(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Cv(n));continue}const o=t.find(e=>e.rowIndex===l&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[l]=Math.max(1,e.height))}}return a}function Pv(e,t,n){const o=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),r=o-1,a=Array(o).fill(n.bounds.width/o),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));if(e.gridCols&&e.gridCols.length>=o)for(let s=0;s<o;s+=1)a[s]=Math.max(1,Cv(e.gridCols[s]));else for(const s of t){if(1!==s.colSpan)continue;const e=i.get(`${s.rowIndex}:${s.cellIndex}`);e&&(a[s.visualColumnIndex]=Math.max(1,e.width))}const l={};for(let s=0;s<o;s+=1)l[s]=Math.max(10,Sv(a[s]));return{widthsPt:l,maxColumnIndex:r}}function Rv(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Cv(10),r=Math.max(Cv(10),t.minRowHeightPx??Cv(10)),a=Math.max(10,Sv(Math.max(r,o+n)));return function(e,t,n,o){return $s(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Bv(e){const t=e();if(!t)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const n=t.getBoundingClientRect();return{left:n.left,top:n.top,width:Math.max(0,n.width),height:Math.max(0,n.height)}}var Av=null;function Mv(e,t){Av=t,e?(document.body.classList.add("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")):(document.body.classList.add("oasis-editor-hover-row-resize"),document.body.classList.remove("oasis-editor-hover-col-resize"))}function Fv(e){e&&Av!==e||(Av=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Ov(e,t){Mv(e,t)}function Dv(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Ev(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Lv(e){const[t,n]=an(null);let o=null,r=null,a=null,i=null;const l={},s=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Fv();const i=xv(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Mv("left"===i.side||"right"===i.side,l):Fv()},c=Vy(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Dv(u)))},u=()=>{a=null;const o=i;i=null;const r=t();o&&r&&n({...r,currentPos:"column"===r.type?o.clientX:o.clientY,guideBounds:Bv(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Ev(o),o=null),null!==a&&(Ev(a),a=null),n(null),Fv(l),c.release(),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)},g=n=>{if(!c.owns(n))return;const o=t();if(!o)return;const r=e.zoomFactor?.()??1,a=(("column"===o.type?n.clientX:n.clientY)-o.initialPos)/r;Math.abs(a)>=2&&e.applyTransactionalState(e=>"row"===o.type?Rv(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=Sv(n),r=t.maxColumnIndex??t.index,a={...t.columnWidthsPt??{}};for(let m=0;m<=r;m+=1)void 0===a[m]&&(a[m]=10);const i=t.minColumnWidthsPx??{},l=a[t.index]??10,s=Math.max(10,Sv(i[t.index]??Cv(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(s,l-o),i=l-r;n+i<0&&(i=-n,r=l-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Hs(e,t.tableId,a,c,d)}let c=Math.max(s,l+o);const d=t.index===r;if(d)a[t.index]=c;else{const e=t.index+1,n=a[e]??10,o=Math.max(10,Sv(i[e]??Cv(10)));let r=n-(c-l);r<o&&(r=o,c=l+(n-o),c=Math.max(s,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=yv(e,t.tableId),g=Iv(p?.style?.width),f=d?u:null!==g?g:void 0;return Hs(e,t.tableId,a,f)}(e,o,a)),p()};return{resizing:t,handlePointerMove:e=>{c.owns(e)&&(t()||(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Dv(s))))},handlePointerDown:t=>{r=null,null!==o&&(Ev(o),o=null),Fv();const a=e.surfaceRef();if(!a)return!1;const i=xv(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=ln(i.tableNode);if("left"===i.side||"right"===i.side){const o="left"===i.side&&0===i.layoutEntry.visualColumnIndex,r=o?0:"left"===i.side?i.layoutEntry.visualColumnIndex-1:i.layoutEntry.visualColumnIndex+i.layoutEntry.colSpan-1;if(r<0)return!1;const a="left"===i.side?i.rect.left:i.rect.right,{widthsPt:p,maxColumnIndex:f}=Pv(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Cv(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const l of n){if(1!==l.colSpan)continue;if(!i.get(`${l.rowIndex}:${l.cellIndex}`))continue;const n=t.rows[l.rowIndex]?.cells[l.cellIndex];if(!n)continue;const o=l.visualColumnIndex,s=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,ca(n,e.document.styles)),1);a[o]=Math.max(s,c+Tv(n)+12,r)}return a}(s,i.tableNode,u,i.tableGeometry);return n({type:"column",tableId:i.tableId,index:r,initialPos:a,currentPos:a,columnWidthsPt:p,maxColumnIndex:f,minColumnWidthsPx:m,resizeFromLeftEdge:o,initialTableIndentLeftPt:Iv(i.tableNode.style?.indentLeft)??0,guideBounds:Bv(e.viewportRef)}),Ov(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=kv(i.tableNode,u,i.tableGeometry),f="top"===i.side?i.layoutEntry.visualRowIndex-1:i.layoutEntry.visualRowIndex+i.layoutEntry.rowSpan-1;if(f<0||f>=p.length)return!1;const m="top"===i.side?i.rect.top:i.rect.bottom,h=function(e,t,n,o){const r=e.rows[o];if(!r)return Cv(10);const a=Cv(10);let i=a;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===l);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===l);a&&(i=Math.max(i,a.contentMinHeight+4))}return Math.max(a,i)}(i.tableNode,u,i.tableGeometry,f);return n({type:"row",tableId:i.tableId,index:f,initialPos:m,currentPos:m,initialRowHeightPx:p[f],minRowHeightPx:h,guideBounds:Bv(e.viewportRef)}),Ov(!1,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var Nv=null;function $v(e){const t=(e.bounds.width+(e.currentClientX-e.startClientX))/e.bounds.width,n=(e.bounds.height+(e.currentClientY-e.startClientY))/e.bounds.height,o=Object.values(e.widthsPt),r=o.length>0?Math.min(...o):1,a=r>0?10/r:0,i=Cv(10),l=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,s=l>0?i/l:0;return{scaleX:Math.max(a,t),scaleY:Math.max(s,n)}}function zv(e){const[t,n]=an(null);let o=null,r=null;const a={},i=Vy(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Dv(s)))},s=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(Ev(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Nv===a&&(Nv=null,"nwse-resize"===document.body.style.cursor&&(document.body.style.cursor=""))},d=n=>{if(!i.owns(n))return;const o=t();if(o){const t=Math.abs(n.clientX-o.startClientX),r=Math.abs(n.clientY-o.startClientY);if(t>=2||r>=2){const t={...o,currentClientX:n.clientX,currentClientY:n.clientY},{scaleX:r,scaleY:a}=$v(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const s of Object.keys(t.widthsPt)){const e=Number(s);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=Hs(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,Sv(e*o))}),$s(i,t.tableId,l)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=$v(e);return{left:e.bounds.left,top:e.bounds.top,width:e.bounds.width*n,height:e.bounds.height*o}},handlePointerDown:(t,o)=>{const r=e.surfaceRef();if(!r)return;const s=vv(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=yv(e.state(),t);if(!s||!c)return;const u=ln(c),{widthsPt:p}=Pv(c,u,s),g=kv(c,u,s),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:s.bounds.left,top:s.bounds.top,width:Math.max(1,s.bounds.width),height:Math.max(1,s.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),Nv=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var Hv=null;function Wv(e,t,n,o){if(!e)return null;for(const r of e)if("table"===r.type){if(r.id===t)return{table:r,nested:n,movableTopLevelStory:o};for(const e of r.rows)for(const n of e.cells){const e=Wv(n.blocks,t,!0,!1);if(e)return e}}return null}function Uv(e,t){for(const n of Fe(e)){for(const e of[n.blocks,n.header,n.footer]){const n=Wv(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=Wv(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=Wv(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=Wv(n.blocks,t,!1,!1);if(e)return e}return null}function jv(e){return function(e){const[t,n]=an(!1),[o,r]=an(null),[a,i]=an(null),[l,s]=an(0),[c,d]=an(0),[u,p]=an({x:0,y:0});let g=null,f=null;const m={},h=(e,t)=>e===t||null!==e&&null!==t&&e.paragraphId===t.paragraphId&&e.runId===t.runId&&e.offset===t.offset,b=e=>{i(t=>h(t,e)?t:e)},y=Vy(),v=()=>{f=null,null!==g&&(Ev(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),Hv===m&&(Hv=null,"grabbing"===document.body.style.cursor&&(document.body.style.cursor=""))},x=()=>{g=null;const n=f;if(f=null,!n||!t())return;p({x:n.clientX,y:n.clientY});const r=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),a=o()?.tableId;r&&a&&function(e,t,n){const o=Uv(e,n);return Boolean(o?.table&&Po(o.table).some(e=>e.id===t))}(e.state().document,r.paragraphId,a)?b(null):b(r)},w=e=>{if(y.owns(e)){if(!t()){if(Math.abs(e.clientY-l())<=4)return;n(!0),Hv=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Dv(x))}},S=n=>{if(!y.owns(n))return;const r=o();if(t()){const t=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),o=r?.tableId;o&&e.applyTransactionalState(e=>{const r=Uv(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return Es(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*ar,y:(t.y??0)+(n.clientY-l())*ar,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?M(e,o,t):e})}v(),e.focusInput()};return{dragging:t,draggedTableInfo:o,mousePos:u,dropTargetPos:a,handlePointerDown:(e,t)=>{t.preventDefault(),t.stopPropagation();const o=t.currentTarget.getBoundingClientRect(),a=o;r({tableId:e,width:a.width,height:a.height,offsetX:t.clientX-o.left,offsetY:t.clientY-o.top}),s(t.clientY),d(t.clientX),p({x:t.clientX,y:t.clientY}),n(!1),i(null),y.claim(t),window.addEventListener("pointermove",w),window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)},stop:v}}(e)}var Vv=e=>"touch"===e.pointerType;function Kv(e,t){if(!e||0===e.length){const e=sa(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Po(n)[0]??null,blocks:e}}function _v(e,t,n){const o=T(e.document).filter(t=>{const o=Jr(e.document,t.id);return null!==o&&o.zone===n}),r=o.findIndex(e=>e.id===t.id),a=r>=0?o[r+1]:void 0;return{start:Z(t,0),end:a?Z(a,0):Z(t,Lt(t).length)}}function Xv(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,l=0,s=0,c=null,d=0,u=0,p=0,g=null,f=null;const m=e=>"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16),h=e=>{"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)},b=(t,n,o,r)=>{const a=n!==(t.activeZone??"main"),i="footnote"===n&&r?Jr(o.document,r.paragraphId)?.footnoteId:void 0,l="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!l)return void e.applyState(o);let s=o.document,c=t.activeSectionIndex??0;if(!s.sections||0===s.sections.length){const e=sa("header"),t=sa("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:Yt(s.pageSettings??jt),header:[e],footer:[t]}]},c=0}const d=s.sections,u=d[c];let p=u.header,g=u.footer,f=null;if("header"===n){const e=Kv(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=Kv(g,"footer");f=e.paragraph,g=e.blocks}if(p!==u.header||g!==u.footer){const e=[...d];e[c]={...u,header:p,footer:g},s={...s,sections:e}}const m=r||(f?Z(f,0):o.selection.anchor);e.applyState({...o,document:s,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:n,activeFootnoteId:"footnote"===n?i:void 0})},y=t=>{const n=e.state(),o=n.selection,r=fo(n),a=St(n.document,o.anchor.paragraphId,r),i=St(n.document,o.focus.paragraphId,r),l=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";e.logger.debug(`${t} ${o.anchor.paragraphId}[${o.anchor.offset}]→${o.focus.paragraphId}[${o.focus.offset}] [${l}→${s}]`)},v=()=>{f?.longPressHandle&&clearTimeout(f.longPressHandle),f=null},x=()=>{t=null,o=null,g=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",k)},w=e=>{g=e,window.addEventListener("pointermove",I),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",k)},S=()=>{if(n=null,!t)return;const r=o;if(o=null,!r)return;const a=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(Jr(i.document,t.paragraphId)?.sectionIndex!==Jr(i.document,a.paragraphId)?.sectionIndex)return;const l=Aa(i,{anchor:t,focus:a.position});b(i,a.zone,l,a.position),y("selection:drag")},C=()=>{o&&(null!==n&&(h(n),n=null),S())},I=e=>{null!==g&&e.pointerId!==g||(!f||f.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(S))):Math.hypot(e.clientX-f.clientX,e.clientY-f.clientY)>20&&x())},T=t=>{if(null===g||t.pointerId===g){if(f&&!f.longPressFired){const n=f,o=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return v(),x(),void(o&&(D(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}C(),y("selection:end"),x(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},k=e=>{null!==g&&e.pointerId!==g||x()},P=(n,o,r)=>{if(r<2)return t=null,x(),void e.focusInputAfterPointerSelection();t=null,o.resolvedFromParagraph?b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position):b(n,o.zone,n),x(),e.focusInputAfterPointerSelection()},R=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=Z(r,o.textBox.startOffset),i=Z(r,o.textBox.endOffset);b(n,o.zone,Aa(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},B=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=Z(a,o.image.startOffset),l=Z(a,o.image.endOffset);b(n,o.zone,Aa(n,{anchor:i,focus:l}),i),x(),Vv(r)||e.imageOps.startImageDrag(o.image.paragraphId,o.image.startOffset,r,{left:o.image.left,top:o.image.top,width:o.image.width,height:o.image.height}),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,Aa(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{t=null;const a=_v(n,r,o.zone);b(n,o.zone,Aa(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},F=(n,o,r)=>{t=null;let a=0;const i=r.runs.find(e=>{const t="math"===e.kind&&o.paragraphOffset>=a&&o.paragraphOffset<=a+e.text.length;return a+=e.text.length,t});if("math"===i?.kind){const t=Z(r,o.paragraphOffset);return b(n,o.zone,Aa(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const l=He(Lt(r),o.paragraphOffset),s=Z(r,l.start),c=Z(r,l.end);b(n,o.zone,Aa(n,{anchor:s,focus:c}),s),x(),e.focusInputAfterPointerSelection()},O=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!Vv(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,x(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?R(n,o):o.image?B(n,o,a):a.shiftKey&&o.resolvedFromParagraph?A(n,o,a.pointerId):r>=3&&i?M(n,o,i):2===r&&i?F(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),Vv(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,o,r)},D=(t,n,o)=>{O(e.state(),t,n,o),e.focusInputSync()},E=()=>{const n=f;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const o=n.hit;if(!o?.resolvedFromParagraph)return;const r=e.state(),a=e.getParagraphById(r.document,o.paragraphId);if(!a)return;const i=He(Lt(a),o.paragraphOffset),l=Z(a,i.start),s=Z(a,i.end);b(r,o.zone,Aa(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-l);r=n-a<=450&&o<=((e,t)=>Vv(e)?20:t)(t,6)&&t.button===s?r+1:1,a=n,i=t.clientX,l=t.clientY,s=t.button;const g=Math.max(t.detail,r),m=e.state();if(e.clearPendingCaretTextStyle(),e.tableResize.handlePointerDown(t))return void t.preventDefault();const h=e.resolveSurfaceHitAtPoint(t.clientX,t.clientY,{pierce:t.altKey});if(c=h,d=n,u=t.clientX,p=t.clientY,Vv(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(E,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),O(m,h,g,t)},N=n=>{if(n.detail<3)return;n.preventDefault();const o=e.state(),r=Math.hypot(n.clientX-u,n.clientY-p),a=Date.now()-d<=600&&r<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(o.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const l=_v(o,i,a.zone);b(o,a.zone,Aa(o,{anchor:l.start,focus:l.end}),l.start),x(),e.focusInputAfterPointerSelection()},$=(e,t)=>{0===t.button&&(Vv(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:$,stopDragging:x}}(e)}function Gv(e){return function(e){const[t,n]=an(!1);let o,r=0,a="",i=null;const l=()=>{r=0,a="",o=void 0},s=(t,n)=>{if(!n&&t===a)return;if(0===r&&0===t.length)return void(n&&l());const s=r,c=Yo(o);e.clearPreferredColumn(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>{const n=function(e,t){if(t<=0)return e;const{paragraph:n,index:o,offset:r}=Ne(e);if(r<t)return e;const a=Kr(e),i=r-t,l=Ut(n,[...Rt(n,0,i),...Rt(n,r,u(n))],Y(n,i)),s=a.map((e,t)=>t===o?l:e);return Ie(e,s,oe(Z(l,i)))}(e,s);return t.length>0?za(n,t,c):n}),{mergeKey:Wi}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(uo("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(n.currentTarget.value)}`),n.currentTarget.value="",void l();const o=n.currentTarget.value;if(0===o.length)return;if(t())return e.logger.debug(`input:composing buffer=${JSON.stringify(o)}`),void s(o,!1);if(null!==i){const t=o===i;if(i=null,t)return e.logger.debug(`input:suppressed text=${JSON.stringify(o)}`),void(n.currentTarget.value="")}const r=e.state(),a=r.selection,c=Kr(r).find(e=>e.id===a.anchor.paragraphId)?.runs.find(e=>e.id===a.anchor.runId),d=c?{bold:c.styles?.bold,italic:c.styles?.italic,underline:c.styles?.underline}:null;e.logger.info(`input:text ${JSON.stringify(o)} (len=${o.length}) at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const u=Yo(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>za(e,o,u)),{mergeKey:Hi}),n.currentTarget.value="",e.focusInput(),yo("input:text")},d=()=>{e.logger.debug("input:composition start"),l(),i=null,o=Yo(e.pendingCaretTextStyle()),n(!0)},p=t=>{e.isReadOnly()||s(t.data??"",!1)},g=t=>{if(n(!1),e.isReadOnly())return t.currentTarget.value="",void l();const o=t.data??t.currentTarget.value,r=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(o)} (len=${o.length}) at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}]`),s(o,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:c,handleCompositionStart:d,handleCompositionUpdate:p,handleCompositionEnd:g,composing:t}}(e)}var qv="url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='white' stroke-width='4'/%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M7.5 7.1 7.5 19.1 10.9 15.8 14.7 24.4' stroke='white' stroke-width='1.15' opacity='.95'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' fill='white' stroke='white' stroke-width='3'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' stroke='black' stroke-width='1.25' stroke-dasharray='2 2'/%3E%3C/g%3E%3C/svg%3E\") 6 4, auto";function Yv(e,t){const n=Wn(e);if(n.isCollapsed)return!1;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r];if(!a)return!1;const i=Bt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function Zv(e){return function(e){const[t,n]=an(!1),[o,r]=an(null),[a,i]=an(!1),[l,s]=an(null),[c,d]=an(null);let u=null,p=null,g=null;const f=()=>{p&&(p.remove(),p=null)},m=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${qv} !important; }`,document.head.appendChild(p))},h=Vy(),b=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,n(!1),r(null),i(!1),s(null),d(null),f(),h.release(),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)},y=o=>{if(!h.owns(o))return;if(!u)return;const a=o.ctrlKey||o.metaKey;if(i(a),!t()){const t=Math.abs(o.clientX-u.x),r=Math.abs(o.clientY-u.y);if(t+r<4)return;e.logger?.info("text-drag:activate",{start:u,at:{x:o.clientX,y:o.clientY},deltaX:t,deltaY:r}),n(!0),m()}s({x:o.clientX,y:o.clientY});const l=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY);if(!l?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=l.tableCellAnchorPosition??l.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${l.zone}|src=${l.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:l.zone,resolvedFromParagraph:l.resolvedFromParagraph,paragraphId:l.paragraphId,paragraphOffset:l.paragraphOffset,hitPosition:`${l.position.paragraphId}:${l.position.runId}[${l.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:l.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(l.caretViewport??null)},v=n=>{if(h.owns(n)){if(e.logger?.info("text-drag:mouseup",{x:n.clientX,y:n.clientY,dragging:t(),copyMode:a(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null}),t()&&o()){const t=o(),n=a();e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>$a(e,t,{copy:n})),{mergeKey:n?ul:pl}),e.logger?.info("text-drag:apply",{mode:n?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position;e.applyTransactionalState(e=>Yv(e,t)?Aa(e,{anchor:t,focus:t}):e,{mergeKey:gl}),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}b(),e.focusInputAfterPointerSelection()}},x=(t,o)=>e.isReadOnly()||!o?.resolvedFromParagraph?(e.logger?.debug("text-drag:skip-start",{reason:e.isReadOnly()?"readonly":"no-hit",x:t.clientX,y:t.clientY}),!1):Yv(e.state(),o.position)?(e.logger?.info("text-drag:start-pending",{x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`,zone:o.zone}),u={x:t.clientX,y:t.clientY,position:o.position},s({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),d(o.caretViewport??null),n(!1),h.claim(t),window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),!0):(e.logger?.debug("text-drag:skip-start",{reason:"outside-selection",x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`}),!1);return{dragging:t,dropTargetPos:o,copyMode:a,pointerPos:l,caretViewport:c,tryStartTextDrag:x,stopDrag:b}}(e)}function Jv(e){return e.blocks.flatMap(Po)}function Qv(e,t){if(!e)return;const n=Jv(e);return"start"===t?n[0]:n[n.length-1]}function ex(e){return function(e){const t=(t,n)=>{const o=e.state(),r=Kr(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:Lt(r).length,i=Z(r,a);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=Kr(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:Lt(a).length,l=Z(a,i);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const l=Lt(i),s=o.selection.focus.offset,c=l.length;if(!n&&!zr(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ma(o):Fa(o)),!0;let d=i,u=s;"left"===t?0===s&&a>0?(d=r[a-1],u=Lt(d).length):u=De(l,s):s===c&&a<r.length-1?(d=r[a+1],u=0):u=Bo(l,s);const p=Z(d,u);return e.clearPreferredColumn(),e.applyState(Aa(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const l=e.surfaceRef(),s=l?.getBoundingClientRect()??null,c=e.preferredColumnX(),d=null===c?e.caretBox().left+(s?.left??0):c,u=l?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:l,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let p=a+t;const g=F(o.document,o.selection.focus.paragraphId,fo(o)),f=g?.tablePath[g.tablePath.length-1];if(g&&f){const e=vy(o,g.zone),n=i(e,g.tablePath),a=n?.[n.length-1]?.table;if(a){const e=ln(a),n=e.find(e=>e.rowIndex===f.rowIndex&&e.cellIndex===f.cellIndex);if(n){const o=[];for(let e=n.visualRowIndex+t;e>=0&&e<a.rows.length;e+=t)o.push(e);for(const n of o){const o=e.filter(e=>e.visualRowIndex===n&&Jv(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=Qv(e.cell,"start")?.id,n=t?u?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??d,r=n?n.left+n.width:d;return{entry:e,distance:d<o?o-d:d>r?d-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=Qv(i.cell,t<0?"end":"start");p=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=Qv(a.rows[0]?.cells[0],"start");e&&(p=r.findIndex(t=>t.id===e.id)-1)}else{const e=a.rows[a.rows.length-1],t=e?.cells[e.cells.length-1],n=Qv(t,"end");n&&(p=r.findIndex(e=>e.id===n.id)+1)}}}if(p<0||p>=r.length)return!1;const m=r[p];let h=0;const b=u?lo(u,m.id):[],y=t<0?b[b.length-1]:b[0];if(y&&y.lines.length>0){const e=y.lines,n=t<0?e[e.length-1]:e[0];h=n.slots.length?n.slots.reduce((e,t)=>Math.abs(d-t.left)<Math.abs(d-e.left)?t:e,n.slots[0]).offset:0}else h=Math.min(Bt(m,o.selection.focus),Lt(m).length);return e.setPreferredColumnX(d),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Aa(e,{anchor:n?e.selection.anchor:Z(m,h),focus:Z(m,h)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function tx(e){return function(e){const[t,n]=an(null),o=(t,o)=>{const r=Kr(e.state());let a;for(const e of r){for(const n of e.runs)if(n.revision?.id===t){a=n.revision;break}if(a)break}const i=e=>{for(const n of e)if("paragraph"!==n.type){if(n.style?.revision?.id===t)return n.style.revision;if(n.gridRevision?.id===t)return n.gridRevision;for(const e of n.rows){if(e.style?.revision?.id===t)return e.style.revision;if(e.style?.propertyRevision?.id===t)return e.style.propertyRevision;for(const n of e.cells){if(n.style?.revision?.id===t)return n.style.revision;if(n.style?.propertyRevision?.id===t)return n.style.propertyRevision;const e=i(n.blocks);if(e)return e}}}};if(!a)for(const n of Fe(e.state().document)){for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter])if(e&&(a=i(e),a))break;if(a)break}if(!a)return;const l=o.currentTarget.getBoundingClientRect(),s=e.surfaceRef()?.getBoundingClientRect();if(!s)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(l.left-s.left)/c,top:(l.top-s.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function nx(e){const t=Kr(e);if(!t.length)return null;const n=Wn(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:Rt(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:u(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Yo(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(Te(r?r.styles:Y(o,n.startParagraphOffset),o.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===u(o));return{text:a,paragraph:i?Dr(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function ox(e,t){const n=Kr(e);if(!n.length)return e;const o=Wn(e,n);if(o.isCollapsed)return e;let r=!1;const a=n.map((e,n)=>{if(n<o.startIndex||n>o.endIndex)return e;const a=n===o.startIndex?o.startParagraphOffset:0,i=n===o.endIndex?o.endParagraphOffset:u(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===u(e))}(e,n,o),s=l?Dr(t.paragraph):e.style,c=l?t.list?{...t.list}:void 0:e.list,d=l&&(JSON.stringify(s)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),p=a<i&&Rt(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Yo(t.text)??{};void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision);const o=Object.keys(n).length?n:void 0;return!Cn(e.styles,o)});if(!d&&!p)return e;r=!0;let g=p?Ye(e,a,i,e=>{if("text"!==e.kind)return e;const n=Yo(t.text)??{};return void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(n).length?n:void 0}}):e;return l&&(g={...g,style:s,list:c}),g});return r?Ie(e,a,$(a,o)):e}function rx(e){const t=Kr(e);if(!t.length)return"";const n=Wn(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function ax(e){const[t,n]=an(null);let r=null,a=null,i="";const l=()=>{r=null,a=null,i="",n(null)};Jt()&&(we(()=>{t()&&(e.isReadOnly()||e.state().document!==a)&&l()}),o(l));const s=()=>!e.isReadOnly()&&Kr(e.state()).length>0,c=t=>{if(!s())return!1;const o=e.state(),l=nx(o);return!!l&&(r=l,a=o.document,i=rx(o),n(t),e.focusInput(),!0)};return{mode:t,canCapture:s,armOnce:()=>c("once"),armContinuous:()=>c("continuous"),cancel:l,applyToSelection:n=>{if(!r||!t())return!1;if(e.isReadOnly()||e.state().document!==a)return l(),!1;const o=e.state();if(rx(o)===i)return!1;const s=function(e,t){const n=Kr(e);if(0===n.length)return null;const o=Wn(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=He(Lt(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Z(r,a.start),focus:Z(r,a.end)}}}(o,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return _t(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>ox(e,r));return c=n.document!==t.document,n}),"once"===t()?l():c&&(a=e.state().document)}),c&&e.focusInput(),c}}}function ix(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:g,setForcePlainTextPaste:f,getCommandsController:m,applyTransactionalState:h,clearPreferredColumn:b,resetTransactionGrouping:y,updateHistoryState:v,caretBox:x,preferredColumnX:w,setPreferredColumnX:S,documentLayout:C,canvasSnapshotProvider:I}=e,T=()=>mb(t),k=()=>ay(t),P=mv({state:()=>t,resetTransactionGrouping:y,applyTransactionalState:h,focusInput:i}),R=iv({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:C,canvasSnapshotProvider:I,zoomFactor:u}).resolveSurfaceHitAtPoint,B=function(e){const[t,n]=an(""),[o,r]=an(""),[a,i]=an({matchCase:!1,wholeWord:!1}),[l,s]=an([]),[c,d]=an(-1),[u,p]=an(!1);we(it([()=>e.state.document,t,a],([e,t,n])=>{const o=Qy(e,t,n);s(o),0===o.length?d(-1):(c()>=o.length||-1===c())&&d(0)}));const g=t=>{const n=l()[t];n&&e.applyState(Aa(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:o,setReplaceTerm:r,findOptions:a,setFindOptions:i,matches:l,currentIndex:c,findNext:()=>{const e=l().length;if(0===e)return;const t=(c()+1)%e;d(t),g(t)},findPrevious:()=>{const e=l().length;if(0===e)return;const t=(c()-1+e)%e;d(t),g(t)},replace:()=>{if(0===l().length||-1===c())return;const t=l()[c()];e.applyTransactionalState(e=>za(Aa(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:il})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>ev(e,n,o(),a()),{mergeKey:ll}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:h,focusInput:i}),A=jy({applyTransactionalState:h,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:kn(e).document,selection:t}),focusInput:i,logger:n}),M=ax({state:()=>t,isReadOnly:o,applyTransactionalState:h,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i}),F=(e,t)=>R(e,t)?.position??null,O=Yy({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:F,applyState:r,applyTransactionalState:h,updateHistoryState:v,focusInput:i,focusInputAfterPointerSelection:l,cloneState:a,logger:n,zoomFactor:u}),D=Zy({state:t,surfaceRef:c,applyState:r,updateHistoryState:v,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),E=Jy({state:()=>t,commandsController:m,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i,logger:n}),L=function(e){const t=()=>e.state,n=Lv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=zv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=jv({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=tx({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=Zv({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),l=Xv({state:t,applyState:e.applyState,tableResize:n,imageOps:e.imageOps,clearPendingCaretTextStyle:e.styleController.clearPendingCaretTextStyle,onSelectionFinalized:()=>{e.formatPainter.applyToSelection("pointer")},clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,focusInputSync:e.focusInputSync,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,getParagraphById:Oo,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),s=Gv({state:t,isReadOnly:e.isReadOnly,logger:e.logger,clearPreferredColumn:e.clearPreferredColumn,pendingCaretTextStyle:e.styleController.pendingCaretTextStyle,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput}),c=ex({state:t,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,surfaceRef:()=>e.surfaceRef()??null,caretBox:e.caretBox,preferredColumnX:e.preferredColumnX,setPreferredColumnX:e.setPreferredColumnX,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),{handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}=hv({state:t,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,consumePasteMode:e.clipboardActions?.consumePasteMode,onNativeClipboardSuccess:e.clipboardActions?.dismiss,setForcePlainTextPaste:e.setForcePlainTextPaste,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,insertImageFromFile:e.insertImageFromFile,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint});return{tableResize:n,tableCornerResize:o,tableDrag:r,revisionController:a,textDrag:i,surfaceEvents:l,textInput:s,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,applyState:r,applyTransactionalState:h,isReadOnly:o,logger:n,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,clearPreferredColumn:b,resetTransactionGrouping:y,surfaceRef:c,viewportRef:d,caretBox:()=>x(),preferredColumnX:()=>w(),setPreferredColumnX:S,zoomFactor:u,documentLayout:C,canvasSnapshotProvider:I,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:F,tableOps:A,imageOps:O,styleController:E,formatPainter:M,getForcePlainTextPaste:g,setForcePlainTextPaste:f,clipboardActions:e.clipboardActions,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),N=e=>{0===e.button&&(E.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:T,selectedTextBoxRun:k,layoutOptionsOverlay:P,fr:B,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:F,tableOps:A,imageOps:O,textBoxOps:D,styleController:E,formatPainter:M,onEditorPointerDown:N,tableResize:L.tableResize,tableCornerResize:L.tableCornerResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}(e)}function lx(e){if("main"!==(e.activeZone??"main"))return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=Vn(),l=function(e){const n=e.footnotes,o=n?.settings?.numberFormat??"decimal";let r=(n?.settings?.startAt??1)-1;const a=/* @__PURE__ */new Set;for(const{run:i}of ir(e)){const e=t(i);e&&!e.customMark&&(a.has(e.footnoteId)||(a.add(e.footnoteId),r+=1))}return Tn(r+1,o)}(n.document),s=Mn(i.id,l),c=d(o,a,[s]),u=Kr(n).map((e,t)=>t===r?c:e),p=Z(c,a+l.length),g=Ie(n,u,En(p)),f=function(e){return e||{items:{}}}(g.document.footnotes),m={...g.document,footnotes:{...f,items:{...f.items,[i.id]:i}}},h=Mr(m),b=i.blocks.flatMap(Po).find(Boolean);return b?{...g,document:h,selection:En(Z(b,0)),activeZone:"footnote",activeFootnoteId:i.id}:{...g,document:h}}function sx(e,t,n){return e.flatMap(e=>{if("paragraph"===e.type)return[e];let o=e.style;if(o?.revision?.id===t)if(n){const{revision:e,...t}=o;o=t}else o={...o.revision.previous};let r=e.gridCols,a=e.gridRevision;a?.id===t&&(r=n?r:[...a.previous],a=void 0);const i=e.rows.map(e=>({...e,cells:[...e.cells]}));for(let s=0;s<i.length;s+=1){const e=i[s];for(let o=0;o<e.cells.length;o+=1){const r=e.cells[o],a=r.mergeRevisionState;if(a&&a.revisionId===t){if(n){const{mergeRevisionState:t,...n}=r;e.cells[o]=n;continue}"horizontal"===a.orientation?e.cells.splice(o,a.currentCellCount,...a.previousCells):a.previousCells.forEach((e,t)=>{const n=i[s+t];n&&(n.cells[o]=e)})}}}const l=i.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};if(o?.revision?.id===t){const{revision:e,...t}=o;o=t}const r=e.cells.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};let r={...e,style:o,blocks:sx(e.blocks,t,n)};if(o?.revision?.id===t&&e.mergeRevisionState?.revisionId!==t){const e=o.revision,{revision:t,...a}=o;r={...r,...n||"merge"!==e.type?{}:e.previous,style:a}}return[r]});return[{...e,isHeader:o&&"isHeader"in o?o.isHeader:e.isHeader,style:o,cells:r}]});return 0===l.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:l}]})}function cx(e,t,n){const o=Fe(e.document).map(e=>({...e,blocks:sx(e.blocks,t,n),header:e.header?sx(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?sx(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?sx(e.evenPageHeader,t,n):void 0,footer:e.footer?sx(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?sx(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?sx(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function dx(e,t){const n=Kr(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"delete"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"insert"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return cx(Ie(e,n,$(n,Wn(e))),t,!0)}function ux(e,t){const n=Kr(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"insert"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"delete"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return cx(Ie(e,n,$(n,Wn(e))),t,!1)}function px(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>px(e,t))))}function gx(e,t,n){for(const o of e)if("paragraph"!==o.type){px(o,t)&&(o.style?.revision&&n.add(o.style.revision.id),o.gridRevision&&n.add(o.gridRevision.id));for(const e of o.rows){const o=e.cells.filter(e=>e.blocks.some(e=>px(e,t)));o.length>0&&(e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id));for(const e of o)e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id),gx(e.blocks,t,n)}}}function fx(e){const t=Wn(e),n=Kr(e),o=/* @__PURE__ */new Set;for(let a=t.startIndex;a<=t.endIndex;a+=1){const e=n[a],r=a===t.startIndex?t.startParagraphOffset:0,i=a===t.endIndex?t.endParagraphOffset:u(e),l=Rt(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Fe(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&gx(e,r,o);return o}function mx(e){const t=/* @__PURE__ */new Set,n=e=>{for(const n of e)n.revision?.id&&t.add(n.revision.id),n.revisionRangeMarker?.id&&t.add(n.revisionRangeMarker.id)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){r.style?.revision&&t.add(r.style.revision.id),r.gridRevision&&t.add(r.gridRevision.id);for(const e of r.rows){e.style?.revision&&t.add(e.style.revision.id),e.style?.propertyRevision&&t.add(e.style.propertyRevision.id);for(const n of e.cells)n.style?.revision&&t.add(n.style.revision.id),n.style?.propertyRevision&&t.add(n.style.propertyRevision.id),n.mergeRevisionState?.revisionId&&t.add(n.mergeRevisionState.revisionId),o(n.blocks)}}else n(r.runs)};for(const i of Fe(e.document))i.propertyRevision&&t.add(i.propertyRevision.id),o(i.blocks),o(i.header),o(i.firstPageHeader),o(i.evenPageHeader),o(i.footer),o(i.firstPageFooter),o(i.evenPageFooter);const r=e.document.footnotes?.items??{};for(const i of Object.values(r))o(i.blocks);const a=e.document.endnotes?.items??{};for(const i of Object.values(a))o(i.blocks);return t}function hx(e){return mx(e).size>0}function bx(e,t){if(!hx(e))return e;const n=er(e.document,t);if(!n.changed)return e;const o=Kr({...e,document:n.document}),r=$(o,Wn(e));return{...e,document:n.document,selection:r}}function yx(e){const t=Wn(e),n=Kr(e);if(t.isCollapsed){const e=n[t.startIndex];return e?Et(e,t.startParagraphOffset)?.href??null:null}const o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:u(e);return Rt(e,r,a)}).filter(e=>e.text.length>0&&"image"!==e.kind);if(0===o.length)return null;const r=o[0]?.styles?.link;return r&&o.every(e=>e.styles?.link===r)?r:null}function vx(e){const t=Wn(e),n=Kr(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return pn(e);if(!e.list)return pn(e);const o=e.list.level??0;return o<=0?j(e):be(e,o-1)});return Ie(e,n,$(n,t))}function xx(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:i,applySelectionAwareTextCommand:l,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:c,focusInput:d,clearPreferredColumn:p,resetTransactionGrouping:g,toolbarStyleState:f,selectionCollapsed:m,selectedImageRun:h}=e,b=e=>{p(),g(),o(e),d()},y=e=>{p(),g(),l(e),d()},v=e=>{p(),g(),s(e),d()},x=(e,t)=>{p(),g(),i(e,t),d()},w=()=>{const e=Wn(t);return Kr(t).slice(e.startIndex,e.endIndex+1)},S=()=>w().some(e=>Boolean(e.list)),C=()=>{const e=t.selection.focus.paragraphId;return Kr(t).find(t=>t.id===e)??null},T=()=>{const e=C();return!!e?.list&&(p(),g(),m()&&0===Lt(e).length?s(e=>function(e){const t=Wn(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?pn(e):j(e));return Ie(e,n,$(n,t))}(e)):i(e=>c(e,e=>function(e){const t=zr(e.selection)?e:Me(e),{paragraph:n,index:o,offset:a}=Ne(t),i=Ut(n,Rt(n,0,a),Y(n,a)),l=Rt(n,a,u(n)),s=l.length>0?de(n,l.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=pr("");return e.style=n.style?{...n.style}:void 0,e.list=lt(n.list),e})(),c=Kr(t),d=[...r(c.slice(0,o)),i,s,...r(c.slice(o+1))];return Ie(t,d,oe(Z(s,0)))}(e)),{mergeKey:Ki}),d(),!0)},k=()=>{const e=t.selection,n=fo(t),o=St(t.document,e.anchor.paragraphId,n),r=St(t.document,e.focus.paragraphId,n);return o&&r&&o.blockIndex===r.blockIndex?` [table b${o.blockIndex} r${o.rowIndex}:c${o.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},P=e=>{if(m())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${k()}`),y(t=>Ka(t,e))},R=e=>{m()||y(t=>function(e,t){const n=Wn(e);if(n.isCollapsed)return e;const o=Kr(e).map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:u(o);return Ye(o,a,i,n=>{let r=So(Va(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!Te(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return Ie(e,o,$(o,n))}(t,e))},B=(e,o)=>{if(m())return;const r=t.selection;n.info(`setStyle:${e}=${JSON.stringify(o)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${k()}`),y(t=>_a(t,e,o))},A=(e,t)=>{v(n=>Ve(n,e,t))},M=e=>{const t=!f()[e];A(e,"widowControl"===e?t:!!t||null)},F=()=>{x(e=>c(e,e=>Zr(e)))},O=()=>"main"===(t.activeZone??"main"),D=()=>{O()&&x(e=>lx(e))},E=e=>{const n=yx(t);m()&&!n||x(t=>function(e,t){const n=Wn(e);if(!n.isCollapsed)return _a(e,"link",t);const o=Kr(e)[n.startIndex];if(!o)return e;const r=Et(o,n.startParagraphOffset);if(!r)return e;const a=_a(Aa(e,{anchor:Z(o,r.startOffset),focus:Z(o,r.endOffset)}),"link",t),i=Kr(a)[n.startIndex];return i?{...a,selection:{anchor:Z(i,r.startOffset),focus:Z(i,r.endOffset)}}:a}(t,e),{mergeKey:_i})},L=()=>{const n=yx(t)??"";m()&&!n||e.openLinkDialog(n)},N=()=>e.openFontDialog(),z=()=>e.openParagraphDialog(),H=()=>{E(null)},W=()=>{const t=h();if(!t)return;const n=qn(t.run)?.alt??"";e.openImageAltDialog(n)},U=t=>{h()&&x(n=>function(e,t,n){const o=mb(e);if(!o||!qn(o.run))return e;const a=Kr(e),i=o.paragraphIndex+1,l=i<a.length&&wr(a[i])?en(a[i],t,n):Gt(t,n,1),s=i<a.length&&wr(a[i])?[...r(a.slice(0,i)),l,...r(a.slice(i+1))]:[...r(a.slice(0,i)),l,...r(a.slice(i))],c=he(s),d=c[i]??l;return Ie(e,c,oe(Z(d,q(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:Gi})},V=()=>{h()&&e.openImageCaptionDialog(function(e){const t=mb(e);if(!t||!qn(t.run))return null;const n=Kr(e);return Ce(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:P,applyToggleCharacterBorderCommand:()=>{m()||y(e=>function(e){const t=Wn(e);if(t.isCollapsed)return e;const n=Kr(e),o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:u(e);return Rt(e,r,a)}).filter(e=>e.text.length>0);if(0===o.length)return e;const r=!o.every(e=>Boolean(e.styles?.textBorder)),a=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,a=n===t.endIndex?t.endParagraphOffset:u(e);return Ye(e,o,a,e=>({...e,styles:qa(e.styles,r)}))});return Ie(e,a,$(a,t))}(e))},applyValueStyleCommand:B,applyUnderlineStyleCommand:R,applyChangeTextCaseCommand:e=>{m()||y(t=>Ja(t,e))},applyClearFormattingCommand:()=>{m()||y(e=>function(e){const t=Wn(e);if(t.isCollapsed)return e;const n=Kr(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,r=n===t.endIndex?t.endParagraphOffset:u(e);return Ye(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Ie(e,n,$(n,t))}(e))},applyParagraphStyleCommand:A,toggleParagraphFlagCommand:M,applyParagraphListCommand:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),l=i.length>0&&i.every(e=>e.list?.kind===t),s=o.map((e,n)=>{if(n<r||n>a)return pn(e);const o=pn(e);return l?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return Ie(e,s,$(s,n))}(t,e))},handleListFormatChange:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?pn(e):e.list?{...pn(e),list:{...e.list,format:t||void 0}}:pn(e));return Ie(e,o,$(o,n))}(t,e))},handleListStartAtChange:e=>{v(t=>function(e,t){const n=Wn(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?pn(e):e.list?{...pn(e),list:{...e.list,startAt:null!==t?t:void 0}}:pn(e));return Ie(e,o,$(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{b(wt(t,e))},applyInsertPageBreakCommand:F,canInsertFootnoteCommand:O,applyInsertFootnoteCommand:D,handleStyleChange:e=>{v(t=>I(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{b(a(t,e,n))},applyToggleTrackChangesCommand:()=>{b(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleRevisionMarkupCommand:()=>{b(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(t))},applySetReviewDisplayModeCommand:e=>{b(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(t,e))},applyShowMarkupCommand:e=>{b(zb(t,e))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),d()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),d()},applyAcceptRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of fx(e))t=dx(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of fx(e))t=ux(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{x(e=>function(e){return bx(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{x(e=>function(e){return bx(e,"reject")}(e))},applyLinkCommand:E,promptForLink:L,openFontDialog:N,openParagraphDialog:z,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:H,applyImageAltCommand:e=>{h()&&x(t=>function(e,t){return Tb(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:Xi})},promptForImageAlt:W,applyImageCaptionCommand:U,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=mb(e),o=n&&qn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Ar));return hb(e,r,r*(o.height/o.width))}(t,e),{mergeKey:qi})},applyImageHeightCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=mb(e),o=n&&qn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Ar));return hb(e,r*(o.width/o.height),r)}(t,e),{mergeKey:qi})},applyImageCropAspectCommand:e=>{if(!h())return;const t=function(e){const t=e.trim().toLowerCase();if("reset"===t||"fit"===t||"fill"===t)return"reset";const n=t.split(/[:/]/);if(2!==n.length)return null;const o=Number(n[0]),r=Number(n[1]);return!Number.isFinite(o)||!Number.isFinite(r)||o<=0||r<=0?null:o/r}(e);null!==t&&x(e=>"reset"===t?wb(e):vb(e,t),{mergeKey:Yi})},applyImageCropShapeCommand:e=>{h()&&x(t=>function(e,t){const n=t?.trim();return Tb(e,e=>{const t={...e};return n&&"rect"!==n?(t.cropShape={preset:n},t.cropFit||(t.cropFit="fill")):delete t.cropShape,t})}(t,e),{mergeKey:Yi})},applyImageCropFillCommand:()=>{h()&&x(e=>function(e){const t=mb(e),n=t&&qn(t.run);return n?Tb(yb(e,{crop:xb(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Yi})},applyImageCropFitCommand:()=>{h()&&x(e=>function(e){return Tb(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Yi})},resetImageCropCommand:()=>{h()&&x(e=>wb(e),{mergeKey:Yi})},applyImageBorderCommand:e=>{h()&&x(t=>function(e,t){return Tb(e,e=>{if(null===t.color){const{border:t,...n}=e;return n}const n={...e.border??{color:"#000000"}};return void 0!==t.color&&(n.color=t.color),void 0!==t.widthPt&&(n.widthPt=t.widthPt),void 0!==t.dash&&(n.dash=t.dash),{...e,border:n}})}(t,e))},flipImageCommand:e=>{h()&&x(t=>Ib(t,e),{mergeKey:Zi})},rotateImageCommand:e=>{h()&&x(t=>Cb(t,e),{mergeKey:Ji})},applyImageTransparencyCommand:e=>{h()&&x(t=>function(e,t){return null===mb(e)?e:Tb(e,e=>{if(!Number.isFinite(t)||t<=0){const{transparency:t,...n}=e;return n}const n=Math.min(1,t);return{...e,transparency:Math.round(1e3*n)/1e3}})}(t,e??0),{mergeKey:Qi})},resetImageCommand:()=>{h()&&x(e=>function(e){return null===mb(e)?e:Tb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,delete t.transparency,delete t.border,delete t.rotation,delete t.flipH,delete t.flipV,delete t.fillMode,t})}(e),{mergeKey:el})},handleListTab:e=>!St(t.document,t.selection.focus.paragraphId,fo(t))&&(!!S()&&(v(t=>"indent"===e?function(e){const t=Wn(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?pn(e):e.list?be(e,(e.list.level??0)+1):pn(e));return Ie(e,n,$(n,t))}(t):vx(t)),!0)),handleListEnter:T,handleListBoundaryBackspace:e=>{const n=C();return!(!n?.list||!m())&&(0===Bt(n,t.selection.focus)&&(p(),g(),s(e=>vx(e)),e.currentTarget.value="",d(),!0))}}}(e)}function wx(e){return{fontFamily:e.fontFamily??"",fontSize:xn(e.fontSize),color:e.color??"",colorMode:e.color?"custom":"automatic",highlight:e.highlight??"",shading:e.textShading??"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underlineStyle?e.underlineStyle:null,underlineColor:e.underlineColor??"",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden),characterScale:e.characterScale??"",characterSpacing:e.characterSpacing??"",baselineShift:e.baselineShift??"",kerningThreshold:e.kerningThreshold??"",ligatures:e.ligatures??"",numberSpacing:e.numberSpacing??"",numberForm:e.numberForm??"",stylisticSet:e.stylisticSet??"",contextualAlternates:Boolean(e.contextualAlternates)}}function Sx(e){return{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",mirrorIndents:e.mirrorIndents??!1,spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",lineRule:e.lineRule??"",contextualSpacing:e.contextualSpacing??!1,outlineLevel:e.outlineLevel??"",shading:e.shading??"",borderStyle:e.borderStyle??"",borderWidth:e.borderWidth??"",borderColor:e.borderColor??"",borderSideTop:e.borderSideTop??!1,borderSideRight:e.borderSideRight??!1,borderSideBottom:e.borderSideBottom??!1,borderSideLeft:e.borderSideLeft??!1,pageBreakBefore:e.pageBreakBefore??!1,keepWithNext:e.keepWithNext??!1,keepLinesTogether:e.keepLinesTogether??!1,widowControl:e.widowControl??!0,tabs:e.tabs??[]}}function Cx(e){return function(e){const t=xx({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,applySelectionAwareTextCommand:e.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:e.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,toolbarStyleState:e.toolbarStyleState,selectionCollapsed:()=>zr(e.state.selection),selectedImageRun:e.selectedImageRun,openLinkDialog:t=>e.setLinkDialog({isOpen:!0,initialHref:t}),openImageAltDialog:t=>e.setImageAltDialog({isOpen:!0,initialAlt:t}),openImageCaptionDialog:t=>e.setImageCaptionDialog({isOpen:!0,initialCaption:t}),openFontDialog:()=>{e.setFontDialog({isOpen:!0,initial:wx(e.toolbarStyleState())})},openParagraphDialog:()=>{e.setParagraphDialog({isOpen:!0,initial:Sx(e.toolbarStyleState())})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Ix(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Tx=class{bindings=/* @__PURE__ */new Map;register(e){this.bindings.set(e.id,e)}unregister(e){this.bindings.delete(e)}getBindings(){return Array.from(this.bindings.values())}execute(e,t,n){const o=e.ctrlKey||e.metaKey,r=e.key.toLowerCase();for(const a of this.bindings.values())if(a.key.toLowerCase()===r&&Boolean(a.ctrlOrMeta)===o&&Boolean(a.shift)===e.shiftKey&&Boolean(a.alt)===e.altKey){if(a.command&&n)return n.canExecuteCommand?.(a.command)??!0?(n.executeCommand(a.command),e.preventDefault(),!0):(e.preventDefault(),!0);if(!1!==a.execute(t,e))return e.preventDefault(),!0}return!1}},kx=[{id:"newDocument",command:"newDocument",key:"n",ctrlOrMeta:!0,execute:()=>!0},{id:"print",command:"print",key:"p",ctrlOrMeta:!0,execute:()=>!0},{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:e=>{const t=e.state(),n=Kr(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Aa(t,{anchor:Z(o,0),focus:Z(r,Lt(r).length)})),e.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:e=>!!e.selectedImageRun()&&(e.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:e=>(e.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:e=>(e.setForcePlainTextPaste(!0),e.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:e=>(e.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"repeatLastAction",command:"repeatLastAction",key:"F4",ctrlOrMeta:!1,execute:e=>(e.executeCommand?.("repeatLastAction"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:e=>(e.toggleFindReplace(!0),!0)},{id:"commandSearch",command:"openCommandSearch",key:"q",alt:!0,execute:e=>(e.toggleCommandSearch(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:e=>(e.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:e=>(e.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:e=>(e.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:e=>(e.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Zr(e))),e.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>za(e,"\n"))),e.focusInput(),!0)},{id:"columnBreak",command:"columnBreak",key:"Enter",ctrlOrMeta:!0,shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ha(e))),e.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:e=>(e.commandsController.handleListEnter()||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Fo(e))),e.focusInput()),!0)}];function Px(e){return function(e){const t=new Tx;kx.forEach(e=>t.register(e));const n=n=>{const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="ArrowLeft"===e||"ArrowRight"===e||"ArrowUp"===e||"ArrowDown"===e||"Home"===e||"End"===e||"PageUp"===e||"PageDown"===e,r="Shift"===e||"Control"===e||"Meta"===e||"Alt"===e,a=(n.ctrlKey||n.metaKey)&&("a"===t||"c"===t);return void(o||r||a||n.preventDefault())}if(n.isComposing||229===n.keyCode)return;const r=e.executeCommand?{executeCommand:(t,n)=>e.executeCommand?.(t,n),canExecuteCommand:(t,n)=>e.canExecuteCommand?.(t,n)}:void 0;if(!t.execute(n,e,r)){if((n.ctrlKey||n.metaKey)&&!n.altKey){if(("ArrowLeft"===n.key||"ArrowRight"===n.key)&&(n.preventDefault(),e.resetTransactionGrouping(),e.moveSelectionByWord("ArrowLeft"===n.key?"left":"right",n.shiftKey)))return void e.focusInput();if("Backspace"===n.key||"Delete"===n.key){if(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!zr(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),n.currentTarget.value="",void e.focusInput();const t=Kr(o),r=t[t.findIndex(e=>e.id===o.selection.focus.paragraphId)];if(!r)return n.currentTarget.value="",void e.focusInput();if("Backspace"===n.key&&r.list&&0===Bt(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>vx(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=Lt(r),l=He(i,a);return"Backspace"===n.key?0===a||l.start===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Aa(t,{anchor:Z(r,l.start),focus:Z(r,a)}),e=>Ua(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))):l.end>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Aa(t,{anchor:Z(r,a),focus:Z(r,l.end)}),e=>Ua(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))),n.currentTarget.value="",void e.focusInput()}}if("Home"===n.key||"End"===n.key){n.preventDefault(),e.resetTransactionGrouping();const t="Home"===n.key?"start":"end";return n.ctrlKey||n.metaKey?e.moveSelectionToDocumentBoundary(t,n.shiftKey):e.moveSelectionToParagraphBoundary(t,n.shiftKey),void e.focusInput()}if(!n.altKey||n.ctrlKey||n.metaKey||"ArrowUp"!==n.key&&"ArrowDown"!==n.key||(n.preventDefault(),e.resetTransactionGrouping(),e.clearPreferredColumn(),!e.moveSelectedImageByParagraph("ArrowUp"===n.key?-1:1)))switch(n.key){case"Backspace":return e.commandsController.handleListBoundaryBackspace(n)?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ja(e))),n.currentTarget.value="",void e.focusInput();case"Tab":{if(e.commandsController.handleListTab(n.shiftKey?"outdent":"indent"))return void n.preventDefault();const t=e.resolveAdjacentTableCellPosition(o.document,o.selection.focus.paragraphId,n.shiftKey?-1:1);if(t)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applySelectionPreservingStructure({anchor:t,focus:t}),void e.focusInput();break}case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(Pa(o,-1))):(e.clearPreferredColumn(),e.applyState(Ma(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return Pa(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Fa(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return Ra(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return ka(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return Ra(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return ka(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var Rx=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var Bx={oasis:{color:"#0f766e",heading:"#115e59",body:"#1f2937"},office:{color:"#4472c4",heading:"#2f5597",body:"#1f2937"},facet:{color:"#8064a2",heading:"#604a7b",body:"#262626"},integral:{color:"#70ad47",heading:"#548235",body:"#1f2937"},ion:{color:"#ed7d31",heading:"#c55a11",body:"#262626"},retrospect:{color:"#5b9bd5",heading:"#2f75b5",body:"#1f2937"}},Ax={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},Mx={aptos:["Aptos, sans-serif","Aptos Display, sans-serif"],calibri:["Calibri, sans-serif","Calibri Light, sans-serif"],georgia:["Georgia, serif","Georgia, serif"],garamond:["Garamond, serif","Garamond, serif"]};function Fx(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function Ox(e,t){return function(e,t){const n=Bx[t],o=e.document.styles??{},r=Object.fromEntries(Object.entries(o).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.body,...o?{fontFamily:"Aptos Display, sans-serif"}:{fontFamily:"Aptos, sans-serif"}}}]}));return{...e,document:{...e.document,design:{...e.document.design??{},themeId:t,colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading,dk2:n.body},fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:"Aptos Display"},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:"Aptos"}}}},styles:r}}}(e,t)}function Dx(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Ex(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function Lx(e){return null!=e&&""!==e?Number(e):null}function Nx({gate:e,style:t,selection:n,history:o,formatting:r,dialog:a,link:i,command:l,valueCommand:s,actionCommand:c}){const d=t.state;return{selectAll:l("selectAll",r.selectAll),selectWord:l("selectWord",r.selectWord),selectSentence:l("selectSentence",r.selectSentence),selectParagraph:l("selectParagraph",r.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:s("selectText",e=>{const t=e??{};return r.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:c("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:l("insertFootnote",r.insertFootnote),setNoteOptions:c("setNoteOptions",e=>{const t=e??{},n="endnote"===t.kind?"endnote":"footnote";r.setNoteOptions({kind:n,...void 0!==t.numberFormat?{numberFormat:t.numberFormat}:{},...void 0!==t.startAt?{startAt:Lx(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:l("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:l("updateTableOfContents",r.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&r.hasTableOfContents()})),insertText:c("insertText",e=>{const t="object"==typeof e&&null!==e&&"text"in e?e:{text:e};r.insertText(String(t.text??""),"string"==typeof t.fontFamily?t.fontFamily:null)}),insertEquation:c("insertEquation",e=>{r.insertEquation(e)}),updateEquation:c("updateEquation",e=>{const t=e;r.updateEquation(t.runId,t.expression)}),pastePlainText:l("pastePlainText",r.pastePlainText),formatPainter:l("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:l("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:l("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:l("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:l("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:l("underline",r.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:l("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:l("wordUnderline",r.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:l("strike",r.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:l("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:l("smallCaps",r.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:l("allCaps",r.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:l("hidden",r.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:l("noProof",r.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:l("webHidden",r.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:l("specVanish",r.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:l("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:l("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:l("shadow",r.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:l("emboss",r.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:l("engrave",r.engrave,()=>({isActive:Boolean(d().imprint)})),outline:l("outline",r.outline,()=>({isActive:Boolean(d().outline)})),superscript:l("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:l("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:l("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:l("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:l("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:l("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:l("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:l("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:l("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:l("find",r.find),replace:l("replace",r.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),setReviewDisplayMode:s("setReviewDisplayMode",e=>{const t="string"==typeof e?e:e?.mode;return("all"===t||"final"===t||"original"===t)&&r.setReviewDisplayMode(t)},()=>r.reviewDisplayMode()),toggleTrackChanges:l("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),toggleRevisionMarkup:l("toggleRevisionMarkup",r.toggleRevisionMarkup,()=>({isActive:r.areRevisionMarkupVisible()})),showMarkupOptions:s("showMarkupOptions",()=>!1,()=>r.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{r.applyShowMarkup(e??{})}),toggleOutlinePanel:l("toggleOutlinePanel",r.toggleOutlinePanel,()=>({isActive:r.areOutlineVisible()})),toggleRevisionsPanel:l("toggleRevisionsPanel",r.toggleRevisionsPanel,()=>({isActive:r.areRevisionsPanelVisible()})),acceptRevisions:l("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:l("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:l("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:l("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),requestAcceptAllRevisions:l("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&r.hasRevisionsInDocument()})),requestRejectAllRevisions:l("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:l("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:l("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:l("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:l("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:l("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:l("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:l("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:l("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:l("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:l("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:l("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:l("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:l("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:l("togglePreciseFonts",r.togglePreciseFonts,()=>(m(),{isActive:Ca()})),undo:l("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:l("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:l("pageBreak",r.pageBreak),lineBreak:l("lineBreak",r.lineBreak),columnBreak:l("columnBreak",r.columnBreak),splitBlock:l("splitBlock",r.splitBlock),insertNonBreakingSpace:l("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:l("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:l("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:l("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:l("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:l("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:l("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:l("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:s("setFontFamily",e=>r.setFontFamily(e||null),()=>d().fontFamily),setFontSize:s("setFontSize",e=>{const t=e&&"object"==typeof e&&"size"in e?e.size:e;if(null==t||""===t)return r.setFontSize(null);if("string"!=typeof t&&"number"!=typeof t)return!1;const n=kr(t);return null!==n&&r.setFontSize(n)},()=>xn(d().fontSize)),increaseFontSize:l("increaseFontSize",r.increaseFontSize),decreaseFontSize:l("decreaseFontSize",r.decreaseFontSize),growFont1:l("growFont1",r.growFont1),shrinkFont1:l("shrinkFont1",r.shrinkFont1),changeTextCase:c("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:l("clearFormatting",r.clearFormatting),setColor:s("setColor",e=>r.setColor(e??null),()=>d().color||null),setHighlight:s("setHighlight",e=>r.setHighlight(e??null),()=>d().highlight||null),setTextShading:s("setTextShading",e=>r.setTextShading(e??null),()=>d().textShading||null),setStyleId:s("setStyleId",e=>r.setStyleId(String(e)),()=>d().styleId||"normal"),setCharacterStyleId:s("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:s("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:s("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:s("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:s("setCharacterScale",e=>r.setCharacterScale(Lx(e)),()=>d().characterScale),setCharacterSpacing:s("setCharacterSpacing",e=>r.setCharacterSpacing(Lx(e)),()=>d().characterSpacing),setRunSnapToGrid:s("setRunSnapToGrid",e=>r.setRunSnapToGrid(Dx(e)),()=>d().snapToGrid),setFitText:s("setFitText",e=>r.setFitText(Lx(e)),()=>d().fitText),setBaselineShift:s("setBaselineShift",e=>r.setBaselineShift(Lx(e)),()=>d().baselineShift),setEmphasisMark:s("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:s("setTextEffect",e=>r.setTextEffect(e||null),()=>d().textEffect),setKerning:s("setKerning",e=>r.setKerning(Lx(e)),()=>d().kerningThreshold),setLigatures:s("setLigatures",e=>r.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:s("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:s("setNumberForm",e=>r.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:s("setStylisticSet",e=>r.setStylisticSet(Lx(e)),()=>d().stylisticSet)}}function $x({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const l=t.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:n.documentStyles()})),print:i("print",()=>n.printDocument(),()=>({isEnabled:!0})),paste:i("paste",()=>a.paste(),()=>({isEnabled:e.isCommandEnabled("paste")&&a.canPaste()})),pasteAsPlainText:i("pasteAsPlainText",()=>a.pasteAsPlainText(),()=>({isEnabled:e.isCommandEnabled("pasteAsPlainText")&&a.canPaste()})),cut:i("cut",()=>a.cut(),()=>({isEnabled:e.isCommandEnabled("cut")&&a.hasSelection()&&a.canCut()})),pasteMergeFormatting:i("pasteMergeFormatting",()=>a.pasteMergeFormatting(),()=>({isEnabled:e.isCommandEnabled("pasteMergeFormatting")&&a.canPaste()})),copy:i("copy",()=>a.copy(),()=>({isEnabled:e.isCommandEnabled("copy")&&a.hasSelection()})),newDocument:i("newDocument",()=>n.newDocument()),saveDocument:i("saveDocument",()=>n.saveDocument()),exportDocx:i("exportDocx",()=>n.exportDocx()),exportPdf:i("exportPdf",()=>n.exportPdf()),importDocument:i("importDocument",()=>n.importDocument()),insertHtml:i("insertHtml",e=>{if(!e||"object"!=typeof e||"string"!=typeof e.html)throw new TypeError("insertHtml requires a payload with a string html property.");n.insertHtml(e.html)}),insertImage:i("insertImage",()=>n.insertImage()),insertShape:i("insertShape",e=>n.insertShape(String(e))),setShapeFill:i("setShapeFill",e=>n.setShapeFill(null==e?null:String(e))),setShapeOutline:i("setShapeOutline",e=>n.setShapeOutline(null==e?null:String(e))),setShapeOutlineWidth:i("setShapeOutlineWidth",e=>n.setShapeOutlineWidth(Number(e))),alignFloatingObject:i("alignFloatingObject",e=>n.alignFloatingObject(e??"center")),reorderFloatingObject:i("reorderFloatingObject",e=>n.reorderFloatingObject(e??"front")),nudgeFloatingObject:i("nudgeFloatingObject",e=>{const t=e??{};n.nudgeFloatingObject(Number(t.dx)||0,Number(t.dy)||0)}),setFloatingFixedPosition:i("setFloatingFixedPosition",e=>n.setFloatingFixedPosition(Boolean(e))),setFloatingRotation:i("setFloatingRotation",e=>n.setFloatingRotation(Number(e))),setFloatingWrapPreset:i("setFloatingWrapPreset",e=>n.setFloatingWrapPreset(e??"square")),setFloatingWrapText:i("setFloatingWrapText",e=>n.setFloatingWrapText(e??"bothSides")),setFloatingPositionPreset:i("setFloatingPositionPreset",e=>n.setFloatingPositionPreset(e??"middleCenter")),setShapePreset:i("setShapePreset",e=>n.setShapePreset(null==e?"rect":String(e))),setTextBoxTextDirection:i("setTextBoxTextDirection",e=>n.setTextBoxTextDirection(e??"horz")),setTextBoxVerticalAlign:i("setTextBoxVerticalAlign",e=>n.setTextBoxVerticalAlign(e??"t")),editTextBoxAlt:i("editTextBoxAlt",e=>n.setTextBoxAlt(null==e?null:String(e))),rotateTextBox:i("rotateTextBox",e=>n.rotateTextBox(e??"left")),textBoxWidthCm:i("textBoxWidthCm",e=>n.setTextBoxWidthCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.width??null})),textBoxHeightCm:i("textBoxHeightCm",e=>n.setTextBoxHeightCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.height??null})),openSymbolDialog:i("openSymbolDialog",()=>n.openSymbolDialog()),openCommandSearch:i("openCommandSearch",()=>n.openCommandSearch()),repeatLastAction:i("repeatLastAction",()=>n.repeatLastAction()),openEquationDialog:i("openEquationDialog",()=>n.openEquationDialog()),tableProperties:i("tableProperties",e=>n.openTableProperties(e?.activeTab??"table"),()=>({isEnabled:n.hasActiveTable()})),unlink:i("unlink",()=>o.remove(),()=>({isEnabled:e.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),imageContext:i("imageContext",()=>{},()=>({isEnabled:r.isSelected(),isActive:r.isSelected(),value:null})),imageWidthCm:i("imageWidthCm",e=>r.setWidthCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.width??null})),imageHeightCm:i("imageHeightCm",e=>r.setHeightCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.height??null})),imageCrop:i("imageCrop",()=>r.toggleCrop(),()=>({isEnabled:r.isSelected(),isActive:r.isCropActive()})),imageCropAspect:i("imageCropAspect",e=>r.applyCropAspect(String(e)),()=>({isEnabled:r.isSelected()})),imageCropShape:i("imageCropShape",e=>r.applyCropShape(String(e)),()=>({isEnabled:r.isSelected(),value:r.getCropShape()})),imageCropFill:i("imageCropFill",()=>r.applyCropFill(),()=>({isEnabled:r.isSelected()})),imageCropFit:i("imageCropFit",()=>r.applyCropFit(),()=>({isEnabled:r.isSelected()})),imageCropReset:i("imageCropReset",()=>r.resetCrop(),()=>({isEnabled:r.isSelected()})),imageFlip:i("imageFlip",e=>r.flip(e??"horizontal"),()=>({isEnabled:r.isSelected()})),imageRotate:i("imageRotate",e=>r.rotate(e??"left"),()=>({isEnabled:r.isSelected()})),imageBorder:i("imageBorder",e=>r.setBorder(e),()=>({isEnabled:r.isSelected(),value:r.getBorder()})),imageTransparency:i("imageTransparency",e=>r.setTransparency("number"==typeof e?e:null==e?0:Number(e)),()=>({isEnabled:r.isSelected(),value:r.getTransparency()})),resetImage:i("resetImage",()=>r.reset(),()=>({isEnabled:r.canReset()}))}}function zx({style:e,paragraph:t,section:n,valueCommand:o,actionCommand:r}){const a=e.state;return{outdent:r("outdent",()=>t.outdent()),indent:r("indent",()=>t.indent()),moveParagraphsUp:r("moveParagraphsUp",()=>t.moveParagraphsUp(),()=>({isEnabled:t.canMoveParagraphsUp()})),moveParagraphsDown:r("moveParagraphsDown",()=>t.moveParagraphsDown(),()=>({isEnabled:t.canMoveParagraphsDown()})),togglePageBreakBefore:r("togglePageBreakBefore",()=>t.togglePageBreakBefore(),()=>({isActive:Boolean(a().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>t.toggleKeepWithNext(),()=>({isActive:Boolean(a().keepWithNext)})),toggleKeepLinesTogether:r("toggleKeepLinesTogether",()=>t.toggleKeepLinesTogether(),()=>({isActive:Boolean(a().keepLinesTogether)})),toggleWidowControl:r("toggleWidowControl",()=>t.toggleWidowControl(),()=>({isActive:Boolean(a().widowControl)})),toggleParagraphBidi:r("toggleParagraphBidi",()=>t.setBidi(!a().bidi||null),()=>({isActive:Boolean(a().bidi)})),setParagraphBidi:o("setParagraphBidi",e=>(t.setBidi(Dx(e)),!0),()=>a().bidi),setParagraphAlign:o("setParagraphAlign",e=>(t.setParagraphAlign(e),!0),()=>a().align),sortParagraphs:r("sortParagraphs",e=>t.sortParagraphs(!0===e||"true"===e||Boolean(e?.descending))),promote:r("promote",()=>t.promote()),demote:r("demote",()=>t.demote()),resetParagraphFormatting:r("resetParagraphFormatting",()=>t.resetParagraphFormatting()),setOutlineLevel:r("setOutlineLevel",e=>{const n=e??void 0,o=null==n||"body"===n||""===n?null:Number(n);t.setOutlineLevel(null===o||Number.isNaN(o)?null:o)},()=>({value:Number(e.state().outlineLevel)||null})),setParagraphTabStops:r("setParagraphTabStops",e=>{const n=e??{};t.setTabStops({...void 0!==n.tabs?{tabs:n.tabs}:{},...void 0!==n.set?{set:n.set}:{},...void 0!==n.clear?{clear:n.clear}:{},...void 0!==n.clearAll?{clearAll:n.clearAll}:{},...void 0!==n.default?{default:n.default}:{}})}),setSpacingAfter:o("setSpacingAfter",e=>(t.setSpacingAfter(Lx(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(Lx(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(Dx(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Ex(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Ex(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(Dx(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(Dx(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(Dx(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(Dx(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(Dx(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(Dx(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(Dx(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(Dx(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(Dx(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(Dx(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(Dx(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(Dx(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(Dx(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(Dx(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(Lx(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(Lx(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(Lx(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(Lx(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",Lx(n.value))},()=>{const e=Number(a().indentFirstLine),t=Number(a().indentHanging),n=Number.isFinite(t)&&t>0?"hanging":Number.isFinite(e)&&e>0?"firstLine":"none";return{isActive:"none"!==n,value:n}}),setParagraphShading:o("setParagraphShading",e=>(t.setShading(e??null),!0),()=>a().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>t.applyBorders()),applyHorizontalLine:r("applyHorizontalLine",()=>t.addHorizontalLine()),setDropCap:r("setDropCap",e=>{const n=e??{};t.setDropCap(n)},()=>({value:t.hasDropCap()})),setLineHeight:o("setLineHeight",e=>(t.setLineHeight(Lx(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(Lx(e))),setListLevel:r("setListLevel",e=>t.setListLevel(Lx(e)??0)),toggleOrientation:r("toggleOrientation",()=>n.toggleOrientation(),()=>({isActive:n.isLandscape()})),setOrientation:r("setOrientation",e=>n.setOrientation(e)),sectionBreakNextPage:r("sectionBreakNextPage",()=>n.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>n.breakContinuous()),sectionBreakEvenPage:r("sectionBreakEvenPage",()=>n.breakEvenPage()),sectionBreakOddPage:r("sectionBreakOddPage",()=>n.breakOddPage()),sectionBreakNextColumn:r("sectionBreakNextColumn",()=>n.breakNextColumn()),setPageMargins:r("setPageMargins",e=>{n.setPageMargins(e??{})},()=>({value:n.getMargins()})),setMarginsPreset:r("setMarginsPreset",e=>{"string"==typeof e&&e.length>0&&n.setMarginsPreset(e)}),setSectionPageNumbering:r("setSectionPageNumbering",e=>{const t=e??{};n.setPageNumbering({...void 0!==t.start?{start:Number(t.start)}:{},..."string"==typeof t.format?{format:t.format}:{}})},()=>({value:n.getPageNumbering()})),setPaperSize:r("setPaperSize",e=>{const t=e??{};void 0!==t.widthPt&&void 0!==t.heightPt&&n.setPaperSize({widthPt:Number(t.widthPt),heightPt:Number(t.heightPt)})},()=>({value:n.getPaperSize()})),setPaperSizePreset:r("setPaperSizePreset",e=>{"string"==typeof e&&e.length>0&&n.setPaperSizePreset(e)}),setColumns:r("setColumns",e=>{const t=e??{};void 0!==t.count&&n.setColumns({count:Number(t.count),...void 0!==t.space?{space:Number(t.space)}:{},...void 0!==t.separator?{separator:Boolean(t.separator)}:{}})}),setColumnsPreset:r("setColumnsPreset",e=>{if("string"==typeof e&&e.length>0){const t=go(e);if(!t)return;n.setColumns({count:t.count})}}),setSectionVerticalAlign:r("setSectionVerticalAlign",e=>{const t=e??void 0;void 0!==t&&"top"!==t&&"center"!==t&&"both"!==t&&"bottom"!==t||n.setVerticalAlign(t??"top")},()=>({value:n.getVerticalAlign()})),setSectionStart:r("setSectionStart",e=>{const t=e??void 0;void 0!==t&&"nextPage"!==t&&"continuous"!==t&&"evenPage"!==t&&"oddPage"!==t&&"nextColumn"!==t||n.setSectionStart(t??"nextPage")},()=>({value:n.getSectionStart()})),setSectionBidi:r("setSectionBidi",e=>{const t=e??void 0;n.setBidi(t??!0)},()=>({value:n.getBidi()})),setHyphenation:r("setHyphenation",e=>{const t=e??{};n.setHyphenation(t)},()=>({value:n.getHyphenation().value}))}}function Hx({gate:e,headerFooter:t,command:n,actionCommand:o}){return{editHeader:n("editHeader",()=>(t.editHeader(),!0)),editFooter:n("editFooter",()=>(t.editFooter(),!0)),editFirstPageHeader:n("editFirstPageHeader",()=>(t.editFirstPageHeader(),!0)),editEvenPageHeader:n("editEvenPageHeader",()=>(t.editEvenPageHeader(),!0)),editFirstPageFooter:n("editFirstPageFooter",()=>(t.editFirstPageFooter(),!0)),editEvenPageFooter:n("editEvenPageFooter",()=>(t.editEvenPageFooter(),!0)),insertPageNumber:n("insertPageNumber",()=>(t.insertPageNumber(),!0)),insertPageNumberXOfY:n("insertPageNumberXOfY",()=>(t.insertPageNumberXOfY(),!0)),placePageNumberTop:n("placePageNumberTop",()=>(t.placePageNumberTop(),!0)),placePageNumberBottom:n("placePageNumberBottom",()=>(t.placePageNumberBottom(),!0)),exitHeaderFooter:o("exitHeaderFooter",()=>t.exit(),()=>({isEnabled:e.isCommandEnabled("exitHeaderFooter")&&t.isInHeaderFooter()})),setDifferentFirstPage:o("setDifferentFirstPage",e=>{const n=e??void 0;t.setDifferentFirstPage(n??!0)},()=>({value:t.getDifferentFirstPage()})),setDifferentOddEven:o("setDifferentOddEven",e=>{const n=e??void 0;t.setDifferentOddEven(n??!0)},()=>({value:t.getDifferentOddEven()}))}}function Wx({bookmark:e,actionCommand:t}){return{insertBookmark:t("insertBookmark",t=>{e.insert("string"==typeof t&&t.trim().length>0?t:void 0)}),removeBookmark:t("removeBookmark",t=>{"string"==typeof t&&e.remove(t)})}}function Ux({fields:e,actionCommand:t}){return{insertDateField:t("insertDateField",()=>{e.insertDate()}),insertDateTime:t("insertDateTime",t=>{const n=t??{};e.insertDateTime(n.dateFormat)}),insertCrossReference:t("insertCrossReference",t=>{const n=t??{};if("string"!=typeof n.bookmark||0===n.bookmark.length)return;const o="PAGEREF"===n.type?"PAGEREF":"REF";e.insertCrossReference({type:o,bookmark:n.bookmark})})}}function jx({gate:e,table:t,actionCommand:n,valueCommand:o}){return{tableContext:n("tableContext",()=>{},()=>({isEnabled:t.insideTable(),isActive:t.insideTable(),value:t.selectionLabel()})),tableMerge:n("tableMerge",()=>t.merge(),()=>({isEnabled:e.isCommandEnabled("tableMerge")&&t.canMerge()})),tableSplit:n("tableSplit",()=>t.split(),()=>({isEnabled:e.isCommandEnabled("tableSplit")&&t.canSplit()})),tableToText:n("tableToText",()=>t.convertToText(),()=>({isEnabled:e.isCommandEnabled("tableToText")&&t.canConvertToText()})),textToTable:n("textToTable",()=>t.convertToTable(),()=>({isEnabled:e.isCommandEnabled("textToTable")&&t.canConvertToTable()})),tableSplitAtRow:n("tableSplitAtRow",()=>t.splitTableAtRow(),()=>({isEnabled:e.isCommandEnabled("tableSplitAtRow")&&t.canSplitTableAtRow()})),tableSortAscending:n("tableSortAscending",()=>t.sortTable("ascending"),()=>({isEnabled:e.isCommandEnabled("tableSortAscending")&&t.canSortTable()})),tableSortDescending:n("tableSortDescending",()=>t.sortTable("descending"),()=>({isEnabled:e.isCommandEnabled("tableSortDescending")&&t.canSortTable()})),tableDelete:n("tableDelete",()=>t.deleteTable(),()=>({isEnabled:e.isCommandEnabled("tableDelete")&&t.canDeleteTable()})),tableRepeatHeaderRows:n("tableRepeatHeaderRows",()=>t.toggleRepeatHeaderRows(),()=>({isEnabled:e.isCommandEnabled("tableRepeatHeaderRows")&&t.canToggleRepeatHeaderRows(),isActive:t.isRepeatHeaderRowsActive()})),tableInsertColumnBefore:n("tableInsertColumnBefore",()=>t.insertColumnBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnBefore")&&t.canEditColumn()})),tableInsertColumnAfter:n("tableInsertColumnAfter",()=>t.insertColumnAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnAfter")&&t.canEditColumn()})),tableDeleteColumn:n("tableDeleteColumn",()=>t.deleteColumn(),()=>({isEnabled:e.isCommandEnabled("tableDeleteColumn")&&t.canEditColumn()})),tableInsertRowBefore:n("tableInsertRowBefore",()=>t.insertRowBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowBefore")&&t.canEditRow()})),tableInsertRowAfter:n("tableInsertRowAfter",()=>t.insertRowAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowAfter")&&t.canEditRow()})),tableDeleteRow:n("tableDeleteRow",()=>t.deleteRow(),()=>({isEnabled:e.isCommandEnabled("tableDeleteRow")&&t.canEditRow()})),tableDeleteCells:n("tableDeleteCells",()=>t.deleteCell(),()=>({isEnabled:e.isCommandEnabled("tableDeleteCells")&&t.canDeleteCell()})),tableCellShading:n("tableCellShading",e=>t.cellShading(e??null)),tableCellBorders:n("tableCellBorders",()=>t.cellBorders()),tableCellNoBorders:n("tableCellNoBorders",()=>t.cellNoBorders()),tableApplyBorderPreset:n("tableApplyBorderPreset",e=>t.applyBorderPreset(e)),toggleTableDrawBorders:n("toggleTableDrawBorders",()=>t.toggleDrawingBorders(),()=>({isEnabled:t.insideTable(),isActive:t.isDrawingBorders()})),toggleTableGridlines:n("toggleTableGridlines",()=>t.toggleGridlines(),()=>({isEnabled:t.insideTable(),isActive:t.isShowingGridlines()})),tableWidth100:n("tableWidth100",()=>t.width100()),tableAlignLeft:n("tableAlignLeft",()=>t.alignLeft()),tableAlignCenter:n("tableAlignCenter",()=>t.alignCenter()),tableAlignRight:n("tableAlignRight",()=>t.alignRight()),tableSetCellAlignment:n("tableSetCellAlignment",e=>t.setCellAlignment(e),()=>({value:t.getCellAlignmentState()})),tableSetCellVerticalAlign:n("tableSetCellVerticalAlign",e=>t.setCellVerticalAlign(e)),tableSetCellTextDirection:n("tableSetCellTextDirection",e=>t.setCellTextDirection(e)),tableSetCellWidth:n("tableSetCellWidth",e=>t.setCellWidth(String(e))),tableSetCellNoWrap:n("tableSetCellNoWrap",e=>t.setCellNoWrap(Dx(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(Dx(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(Dx(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(Dx(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetHeaderRow")&&t.canSetActiveTableRowHeader()})),tableSetColumnWidth:o("tableSetColumnWidth",e=>(t.setActiveTableColumnWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetColumnWidth")&&t.canSetActiveTableColumnWidth()})),tableSetTableWidth:o("tableSetTableWidth",e=>(t.setActiveTableWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetTableWidth")&&t.canSetActiveTableWidth()})),tableSetCellMargins:n("tableSetCellMargins",e=>t.setCellMargins(e??{}),()=>({isEnabled:e.isCommandEnabled("tableSetCellMargins")&&t.canSetCellMargins()})),tableSetCellSpacing:n("tableSetCellSpacing",e=>t.setCellSpacing(Lx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(Lx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Ex(e)),()=>({isEnabled:e.isCommandEnabled("tableSetAlignment")&&t.canSetTableAlignment()})),tableFormula:n("tableFormula",e=>t.evaluateTableFormula(String(e)),()=>({isEnabled:e.isCommandEnabled("tableFormula")&&t.canEvaluateTableFormula()})),tableSelectCell:n("tableSelectCell",()=>t.selectTablePart("cell"),()=>({isEnabled:e.isCommandEnabled("tableSelectCell")&&t.canSelectTable()})),tableSelectRow:n("tableSelectRow",()=>t.selectTablePart("row"),()=>({isEnabled:e.isCommandEnabled("tableSelectRow")&&t.canSelectTable()})),tableSelectColumn:n("tableSelectColumn",()=>t.selectTablePart("column"),()=>({isEnabled:e.isCommandEnabled("tableSelectColumn")&&t.canSelectTable()})),tableSelectTable:n("tableSelectTable",()=>t.selectTablePart("table"),()=>({isEnabled:e.isCommandEnabled("tableSelectTable")&&t.canSelectTable()})),tableToggleHeaderRow:n("tableToggleHeaderRow",()=>t.toggleTblLook("firstRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstRow??!1})),tableToggleTotalRow:n("tableToggleTotalRow",()=>t.toggleTblLook("lastRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastRow??!1})),tableToggleBandedRows:n("tableToggleBandedRows",()=>t.toggleTblLook("bandedRows"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedRows??!1})),tableToggleFirstColumn:n("tableToggleFirstColumn",()=>t.toggleTblLook("firstCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstCol??!1})),tableToggleLastColumn:n("tableToggleLastColumn",()=>t.toggleTblLook("lastCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastCol??!1})),tableToggleBandedColumns:n("tableToggleBandedColumns",()=>t.toggleTblLook("bandedCols"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedCols??!1})),setTableStyle:n("setTableStyle",e=>t.setStyleId(String(e??"")),()=>({isEnabled:t.insideTable(),value:t.getStyleId()})),tableToggleAutoFit:n("tableToggleAutoFit",()=>t.toggleAutoFit(),()=>({isEnabled:t.insideTable(),isActive:"autofit"===t.getLayout()})),tableAutoFit:n("tableAutoFit",e=>t.setAutoFit(e??"contents"),()=>({isEnabled:t.canSetAutoFit()})),tableDistributeColumns:n("tableDistributeColumns",()=>t.distributeColumns(),()=>({isEnabled:e.isCommandEnabled("tableDistributeColumns")&&t.canEditColumn()})),tableDistributeRows:n("tableDistributeRows",()=>t.distributeRows(),()=>({isEnabled:e.isCommandEnabled("tableDistributeRows")&&t.canEditRow()})),insertTable:n("insertTable",e=>{const{rows:n,cols:o,columns:r}=e??{},a=o??r;n&&a&&t.insert(n,a)})}}function Vx({design:e,actionCommand:t}){return{applyDocumentTheme:t("applyDocumentTheme",t=>e.applyTheme(String(t)),()=>({value:e.getDesign()?.themeId})),setDocumentColorScheme:t("setDocumentColorScheme",t=>e.setColorScheme(String(t)),()=>({value:e.getDesign()?.colorSchemeId})),setDocumentFontScheme:t("setDocumentFontScheme",t=>e.setFontScheme(String(t)),()=>({value:e.getDesign()?.fontSchemeId})),setDocumentParagraphSpacing:t("setDocumentParagraphSpacing",t=>e.setParagraphSpacing(String(t)),()=>({value:e.getDesign()?.paragraphSpacingId})),setDocumentEffects:t("setDocumentEffects",t=>e.setEffects(String(t)),()=>({value:e.getDesign()?.effectsId})),setDocumentPageColor:t("setDocumentPageColor",t=>e.setPageColor(t??null),()=>({value:e.getDesign()?.pageColor})),setDocumentWatermark:t("setDocumentWatermark",t=>e.setWatermark(t??null),()=>({value:e.getDesign()?.watermark})),setDocumentPageBorder:t("setDocumentPageBorder",t=>e.setPageBorder(t??null),()=>({value:e.getPageBorder()})),setDocumentDesignDefault:t("setDocumentDesignDefault",()=>e.setDefault())}}function Kx({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",()=>{e.openParagraphDialog()})}}var _x=/* @__PURE__ */new Set(["copy","selectAll","selectWord","selectSentence","selectParagraph","selectCollapse","nextRevision","previousRevision","nextComment","previousComment","toggleCommentsPanel","find","replace","print","exportDocx","exportPdf","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","toggleRevisionMarkup","showMarkupOptions","applyShowMarkup","toggleRevisionsPanel","toggleOutlinePanel","setReviewDisplayMode","imageContext","tableContext","toggleTableGridlines","documentStyles"]),Xx=/* @__PURE__ */new Set(["bold","italic","underline","doubleUnderline","wordUnderline","strike","doubleStrike","smallCaps","allCaps","hidden","noProof","webHidden","specVanish","contextualAlternates","characterBorder","shadow","emboss","engrave","outline","superscript","subscript","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","growFont1","shrinkFont1","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setCharacterStyleId","setUnderlineStyle","applyUnderlineStyle","setUnderlineColor","setCharacterScale","setCharacterSpacing","setRunSnapToGrid","setFitText","setBaselineShift","setEmphasisMark","setTextEffect","setKerning","setLigatures","setNumberSpacing","setNumberForm","setStylisticSet"]),Gx=/* @__PURE__ */new WeakMap;function qx(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!Xx.has(t)||!function(e){const t=e.state?.();if(!t)return!1;const n=t.document,o=t.selection;if(!n||!o)return!1;let r=Gx.get(n);r||(r=/* @__PURE__ */new WeakMap,Gx.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==db(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((_x.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function Yx(e){return{state:()=>e.styleController.toolbarStyleState()}}function Zx(e){return{isCollapsed:()=>zr(e.state().selection)}}function Jx(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var Qx={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function ew(e){return/\p{L}|\p{N}/u.test(e)}function tw(e){return"."===e||"!"===e||"?"===e}function nw(e,t){return Z(e,t)}function ow(e,t,n,o){return e-n||t-o}function rw(e,t){const n=Kr(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:nw(o,t.startOffset),focus:nw(r,t.endOffset)}}:e}function aw(e,t,n){if(!t.length)return null;const o=Kr(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?Wn(e,o).end:Wn(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=Bt(l,a);return("next"===n?t.find(e=>ow(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>ow(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function iw(e){const t=Kr(e),n=[],o=/* @__PURE__ */new Set;return t.forEach((e,t)=>{let r=0;for(const a of e.runs){const e=a.revision?.id;e&&!o.has(e)&&(o.add(e),n.push({id:e,startIndex:t,startOffset:r,endIndex:t,endOffset:r+a.text.length})),r+=a.text.length}}),n}function lw(e,t){const n=aw(e,iw(e),t);return n?rw(e,n):e}function sw(e){const t=Kr(e),n=new Map(t.map((e,t)=>[e.id,t])),o=e.document.comments;if(!o)return[];const r=[];for(const a of o.order){const e=o.items[a];if(!e?.start||!e.end)continue;const i=n.get(e.start.paragraphId),l=n.get(e.end.paragraphId);if(void 0===i||void 0===l)continue;const s=t[i],c=t[l],d=Math.max(0,Math.min(e.start.offset,s.runs.reduce((e,t)=>e+t.text.length,0))),u=Math.max(0,Math.min(e.end.offset,c.runs.reduce((e,t)=>e+t.text.length,0)));ow(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>ow(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function cw(e,t){const n=aw(e,sw(e),t);return n?rw(e,n):e}function dw(e){const t=sw(e);if(!t.length)return null;const n=Wn(e),o=t.find(e=>0===ow(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===ow(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>ow(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&ow(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function uw(e,t){const n=iw(e).find(e=>e.id===t);return n?rw(e,n):e}var pw=e=>Math.round(e/zo*96);function gw(e,t=3){const n=[];for(const o of T(e.document)){const e=ga(o.style?.styleId);if(null===e||e>t)continue;const r=Lt(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function fw(e){const t=bo(e.text).id;return e.fieldChar?{id:t,text:e.text,kind:"fieldChar",fieldChar:e.fieldChar}:void 0!==e.fieldInstruction?{id:t,text:e.text,kind:"fieldInstruction",fieldInstruction:e.fieldInstruction}:{id:t,text:e.text,kind:"text"}}function mw(e,t){const n=pr("");return n.runs=e,t&&(n.style=t),n}function hw(e,t,n){const o=void 0!==t?String(t):"";return mw([fw({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:pw(40),indentLeft:pw(397*(e.level-1))})}function bw(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return c(o*ar,2)}function yw(e,t,n,o){const r=Fe(e.document),a=r[t];if(!a)return e;const i=[...r];return i[t]={...a,blocks:n},{...e,document:{...e.document,sections:i},selection:oe(Z(o,0))}}function vw(e,t=()=>{},n=3){if("main"!==io(e))return e;const o=fo(e),r=Fe(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>hw(e,t(e.id),n));return[mw([fw({text:"",fieldChar:{kind:"begin"}}),fw({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),fw({text:"",fieldChar:{kind:"separate"}})]),...o,mw([fw({text:"",fieldChar:{kind:"end"}})])]}(gw(e,n),t,bw(r)),i=nr(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&Po(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return yw(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function xw(e){let t=0,n="",o=-1,r=-1,a=!1;for(let i=0;i<e.length;i+=1){const l=e[i];if("paragraph"===l.type)for(const e of l.runs){const l=dn(e),s=rt(e);if("begin"===l?.kind)t+=1,1===t&&(r=i,n="",a=!1,o=-1);else if(1===t&&void 0!==s)n+=s,/\bTOC\b/i.test(n)&&(a=!0);else if("separate"===l?.kind)1===t&&(o=i);else if("end"===l?.kind){if(1===t&&a)return{startBlockIndex:o>=0?o:r,endBlockIndex:i};t=Math.max(0,t-1)}}}return null}function ww(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?xo(n):11,r="increase"===t?tr(o):Dn(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",Sr(r)),!0},n=e=>{const t=Tr(e.document),n=/* @__PURE__ */new Map;for(const o of t.pages)for(const e of o.blocks){const t=e.paragraphId;t&&!n.has(t)&&n.set(t,o.index+1)}return e=>n.get(e)};return{formatPainterOnce:e.formatPainter.armOnce,formatPainterContinuous:e.formatPainter.armContinuous,cancelFormatPainter:()=>(e.formatPainter.cancel(),!0),formatPainterMode:e.formatPainter.mode,canCaptureFormatPainter:e.formatPainter.canCapture,selectAll:()=>{const t=T(e.state().document);if(0===t.length)return!1;const n=t[0],o=t[t.length-1];return e.applyState({...e.state(),selection:{anchor:Z(n,0),focus:Z(o,Lt(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ne(e),o=Lt(t);let r=n,a=n;for(;r>0&&ew(o[r-1]);)r-=1;for(;a<o.length&&ew(o[a]);)a+=1;return Aa(e,{anchor:Z(t,r),focus:Z(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ne(e),o=Lt(t);let r=n;for(;r>0&&!tw(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!tw(o[a]);)a+=1;return a<o.length&&(a+=1),Aa(e,{anchor:Z(t,r),focus:Z(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=Kr(e),n=Wn(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Aa(e,{anchor:Z(o,0),focus:Z(r,u(r))}):e}(e.state())),e.focusInput(),!0),selectCollapse:(t=!1)=>!e.isReadOnly()&&(e.applyState(function(e,t=!1){const n=e.selection.anchor,o=e.selection.focus,r=Kr(e),a=Pr(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Aa(e,{anchor:i,focus:i})}(e.state(),t)),e.focusInput(),!0),selectText:(t,n=1)=>0!==t.length&&(e.applyState(function(e,t,n=1){const o=Qy(e.document,t)[Math.max(1,n)-1];return o?Aa(e,{anchor:o.anchor,focus:o.focus}):e}(e.state(),t,n)),e.focusInput(),!0),selectRange:(t,n)=>(e.applyState(function(e,t,n){return Aa(e,{anchor:t,focus:n})}(e.state(),t,n)),e.focusInput(),!0),insertFootnote:()=>(e.commandsController.applyInsertFootnoteCommand(),!0),setNoteOptions:t=>{e.applyTransactionalState(e=>function(e,t){const n=t.kind,o={...("endnote"===n?e.document.endnotes?.settings:e.document.footnotes?.settings)??{}};let r=!1;if(void 0!==t.numberFormat){const e=null===t.numberFormat?void 0:t.numberFormat;o.numberFormat!==e&&(o.numberFormat=e,r=!0)}if(void 0!==t.startAt){const e=null===t.startAt?void 0:Math.max(1,Math.round(t.startAt));o.startAt!==e&&(o.startAt=e,r=!0)}if(void 0!==t.restart){const e=null===t.restart?void 0:t.restart;o.restart!==e&&(o.restart=e,r=!0)}if(!r)return e;const a=Object.keys(o).length>0?{...o}:void 0;if("endnote"===n){const t=e.document.endnotes??{items:{}};return{...e,document:{...e.document,endnotes:{...t,settings:a}}}}const i=e.document.footnotes??{items:{}};return{...e,document:{...e.document,footnotes:{...i,settings:a}}}}(e,{kind:t.kind,...void 0!==t.numberFormat?{numberFormat:null===t.numberFormat?null:t.numberFormat}:{},...void 0!==t.startAt?{startAt:t.startAt}:{},...void 0!==t.restart?{restart:null===t.restart?null:t.restart}:{}})),e.focusInput()},getNoteOptions:t=>function(e,t){return"endnote"===t?{...e.document.endnotes?.settings??{}}:{...e.document.footnotes?.settings??{}}}(e.state(),t),insertText:(t,n)=>{if(0===t.length)return!1;const o=n?{fontFamily:n}:void 0;return e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>za(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=Y(o,a),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},s=d(o,a,[l]),c=Kr(n).map((e,t)=>t===r?s:e);return Ie(n,c,oe(Z(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=Kr(e).map(e=>{let r=!1;const a=e.runs.map(e=>e.id!==t||"math"!==e.kind?e:(o=!0,r=!0,{...e,math:n,text:""}));return r?{...e,runs:a}:e});return o?Ie(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=Fe(e.document)[fo(e)];return!!t&&null!==xw(t.blocks)}(e.state()),hasRevisionsInSelection:()=>fx(e.state()).size>0,hasRevisionsInDocument:()=>hx(e.state()),hasNavigableRevisions:()=>iw(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),sw(t).map(e=>e.id)).length>0;var t},canCreateComment:e.commentComposer.canCreate,canReplyToComment:e.commentComposer.canReply,newComment:e.commentComposer.openNew,replyComment:e.commentComposer.openReply,editComment:e.commentComposer.openEdit,toggleCommentsPanel:e.commentComposer.togglePanel,isCommentsPanelOpen:e.commentComposer.panelOpen,canEditComment:e.commentComposer.canEdit,navigateRevisionNext:()=>{const t=e.state(),n=lw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=lw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=cw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=cw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==dw(e.state()),isSelectedCommentResolved:()=>Boolean(dw(e.state())?.resolved),canManageSelectedComment:e.commentComposer.canResolveSelected,resolveSelectedComment:()=>e.commentComposer.resolveSelected(!0),reopenSelectedComment:()=>e.commentComposer.resolveSelected(!1),deleteSelectedComment:e.commentComposer.deleteSelected,canDeleteSelectedComment:e.commentComposer.canDeleteSelected,insertTableOfContents:()=>(e.applyTransactionalState(e=>vw(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=fo(e),r=Fe(e.document)[o];if(!r)return e;const a=xw(r.blocks);if(!a)return e;const i=gw(e,n).map(e=>hw(e,t(e.id),bw(r)));return yw(e,o,[...r.blocks.slice(0,a.startBlockIndex+1),...i,...r.blocks.slice(a.endBlockIndex)],i[0]??r.blocks[a.startBlockIndex])}(e,n(e))),e.focusInput(),!0),pastePlainText:()=>(e.forcePlainTextPaste.set(!0),e.focusInput(),!0),bold:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),doubleUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"double"===e.styleController.toolbarStyleState().underlineStyle?null:"double"),!0),wordUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"words"===e.styleController.toolbarStyleState().underlineStyle?null:"words"),!0),strike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),doubleStrike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("doubleStrike"),!0),smallCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("smallCaps"),!0),allCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("allCaps"),!0),hidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("hidden"),!0),noProof:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("noProof"),!0),webHidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("webHidden"),!0),specVanish:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("specVanish"),!0),contextualAlternates:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("contextualAlternates"),!0),toggleCharacterBorder:()=>(e.keyboardCommandsController.applyToggleCharacterBorderCommand(),!0),shadow:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("shadow"),!0),emboss:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("emboss"),!0),engrave:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("imprint"),!0),outline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("outline"),!0),superscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(e.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(e.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(e.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(e.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(e.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(e.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(e.findReplace.setIsOpen(!0),!0),replace:()=>(e.findReplace.setIsOpen(!0),!0),replaceAll:t=>(e.isReadOnly()||(e.applyTransactionalState(e=>ev(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:ll}),e.focusInput()),!0),isTrackChangesEnabled:()=>Boolean(e.state().trackChangesEnabled),areMarginsVisible:()=>Boolean(e.state().showMargins),areParagraphMarksVisible:()=>Boolean(e.state().showParagraphMarks),areRevisionMarkupVisible:()=>Boolean(e.state().showRevisionMarkup??!0),areOutlineVisible:()=>e.isOutlineVisible(),toggleRevisionsPanel:()=>(e.toggleRevisionsPanel(),!0),areRevisionsPanelVisible:()=>e.revisionsPanelVisible(),reviewDisplayMode:()=>e.state().reviewDisplayMode??"all",setReviewDisplayMode:t=>(e.commandsController.applySetReviewDisplayModeCommand(t),!0),showMarkupOptions:()=>function(e){const t=void 0===e.markupAuthors;return{insertions:$b(e,"insertions"),deletions:$b(e,"deletions"),comments:$b(e,"comments"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Kb(e)}}(e.state()),applyShowMarkup:t=>(e.commandsController.applyShowMarkupCommand(t),!0),toggleTrackChanges:()=>(e.commandsController.applyToggleTrackChangesCommand(),!0),toggleRevisionMarkup:()=>(e.commandsController.applyToggleRevisionMarkupCommand(),!0),toggleOutlinePanel:()=>(e.toggleOutlinePanel(),!0),acceptRevisions:()=>(e.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(e.commandsController.applyRejectRevisionsCommand(),!0),acceptAllRevisions:()=>(e.commandsController.applyAcceptAllRevisionsCommand(),!0),rejectAllRevisions:()=>(e.commandsController.applyRejectAllRevisionsCommand(),!0),toggleShowMargins:()=>(e.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(e.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(Q(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Zr(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>za(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Ha(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Fo(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return za(e,Qx[t])}(e,t))),e.focusInput(),!0),setFontFamily:t=>(e.styleController.applyToolbarValueStyleCommand("fontFamily",t),!0),setFontSize:t=>(e.styleController.applyToolbarValueStyleCommand("fontSize",t),!0),increaseFontSize:()=>t("increase"),decreaseFontSize:()=>t("decrease"),growFont1:()=>(e.applyTransactionalState(e=>Xa(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>Xa(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>zr(e.state().selection)?(e.styleController.clearPendingCaretTextStyle(),e.focusInput(),!0):(e.commandsController.applyClearFormattingCommand(),!0),setColor:t=>(e.styleController.applyToolbarValueStyleCommand("color",t),!0),setHighlight:t=>(e.styleController.applyToolbarValueStyleCommand("highlight",t),!0),setTextShading:t=>(e.styleController.applyToolbarValueStyleCommand("shading",t),!0),setStyleId:t=>(e.commandsController.handleStyleChange(t),!0),setCharacterStyleId:t=>(e.styleController.applyToolbarValueStyleCommand("styleId",t||null),!0),applyUnderlineStyle:e.styleController.applyToolbarUnderlineStyleCommand,setUnderlineStyle:t=>e.styleController.applyToolbarValueStyleCommand("underlineStyle",t),setUnderlineColor:t=>(e.styleController.applyToolbarValueStyleCommand("underlineColor",t),!0),setCharacterScale:t=>(e.styleController.applyToolbarValueStyleCommand("characterScale",t),!0),setCharacterSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("characterSpacing",t),!0),setRunSnapToGrid:t=>(e.styleController.applyToolbarValueStyleCommand("snapToGrid",t),!0),setFitText:t=>(e.styleController.applyToolbarValueStyleCommand("fitText",t),!0),setBaselineShift:t=>(e.styleController.applyToolbarValueStyleCommand("baselineShift",t),!0),setEmphasisMark:t=>(e.styleController.applyToolbarValueStyleCommand("emphasisMark",t),!0),setTextEffect:t=>(e.styleController.applyToolbarValueStyleCommand("textEffect",t),!0),setKerning:t=>(e.styleController.applyToolbarValueStyleCommand("kerningThreshold",t),!0),setLigatures:t=>(e.styleController.applyToolbarValueStyleCommand("ligatures",t||null),!0),setNumberSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("numberSpacing",t||null),!0),setNumberForm:t=>(e.styleController.applyToolbarValueStyleCommand("numberForm",t||null),!0),setStylisticSet:t=>(e.styleController.applyToolbarValueStyleCommand("stylisticSet",t),!0)}}function Sw(e,t){const n=ay(e),o=n&&Er(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,n)=>n!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function Cw(e,t){return{...e??{type:"floating",allowOverlap:!0,positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none"===e?.wrap?e.wrap:e?.wrap??"square",behindDoc:e?.behindDoc,positionH:{relativeFrom:"margin",align:t,offset:0}}}function Iw(e,t,n){const o={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"},r=o.positionH??{},a=o.positionV??{};return{...o,wrap:"none"===o.wrap?o.wrap:o.wrap??"square",positionH:{...r,offset:(r.offset??0)+Math.round(t*In),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*In)}}}function Tw(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}function kw(e,t,n=90){return Pw(e,e=>{const o="right"===t?-n:n,r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}((e.rotation??0)+o);return{...e,rotation:r}})}function Pw(e,t){const n=ay(e);if(!n||!Er(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Gn(e))});return Ie(e,a,$(a,Wn(e)))}function Rw(e,t){return Pw(e,e=>({...e,body:t(e.body??{})}))}function Bw(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of T(t)){e.style?.styleId&&o.add(e.style.styleId);for(const t of e.runs)t.styles?.styleId&&o.add(t.styles.styleId)}return Object.values(n).map(e=>{const t=va(e.id,n),r="table"===e.type?jo(e.id,n).tableStyle:void 0,a=r?.conditionalFormats?.wholeTable,i=r?.conditionalFormats?.firstRow,l=r?.conditionalFormats?.band1Horz,s=a?.borders?.borderBottom??r?.borders?.borderBottom;return{id:e.id,name:e.name,type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:t.fontFamily?.trim()||void 0,fontSize:"number"==typeof t.fontSize?t.fontSize:void 0,color:t.color??void 0,bold:t.bold??void 0,italic:t.italic??void 0,tablePreview:r?{wholeFill:a?.shading,headerFill:i?.shading,bandFill:l?.shading,borderColor:s?.color,headerColor:i?.textStyle?.color??void 0}:void 0}})},newDocument:()=>e.newDocument(),saveDocument:()=>e.saveDocument(),openSymbolDialog:()=>e.openSymbolDialog(),openCommandSearch:()=>e.openCommandSearch(),repeatLastAction:()=>e.repeatLastAction(),openEquationDialog:()=>e.openEquationDialog(),hasActiveTable:()=>fc(e.state()),openTableProperties:t=>e.openTablePropertiesDialog(t??"table"),exportDocx:()=>{e.docIO.handleExportDocx()},exportPdf:()=>{e.docIO.handleExportPdf()},printDocument:()=>{e.docIO.handlePrint()},importDocument:()=>e.importInputRef()?.click(),insertImage:()=>e.imageInputRef()?.click(),insertHtml:t=>e.applyTransactionalState(e=>function(e,t){if(!t.trim())return e;const n=K(t),o=$e(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return Da(e,o.map(e=>({runs:e.runs.map(e=>({text:e.text,styles:e.styles,..."image"===e.kind?{image:e.image}:{}})),style:e.style,list:e.list})));const r=zr(e.selection)?e:Me(e),{paragraph:a,offset:i}=Ne(r),l=Rt(a,0,i),s=Rt(a,i,u(a)),c=pr(""),d={...a,runs:l.length?l:pr("").runs},p={...a,id:c.id,runs:s.length?s:c.runs},g=[...i>0?[d]:[],...o,...s.length||"table"===o[o.length-1]?.type?[p]:[]];let f=!1;const m=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===a.id)return f=!0,t=!0,g;if("table"!==e.type)return[e];let n=!1;const o=e.rows.map(e=>{let t=!1;const o=e.cells.map(e=>{const n=m(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:o}):e});return n?(t=!0,[{...e,rows:o}]):[e]});return t?n:e},h=r.activeZone??"main";let b=r.document;if("footnote"===h&&r.activeFootnoteId&&r.document.footnotes?.items[r.activeFootnoteId]){const e=r.document.footnotes,t=e.items[r.activeFootnoteId],n=m(t.blocks);f&&(b={...r.document,footnotes:{...e,items:{...e.items,[r.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=$e(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const a="header"===h?"header":"footer"===h?"footer":"blocks",i=m(o[a]??[]);if(f){const e=[...t];e[n]={...o,[a]:i},b={...r.document,sections:e}}}if(!f)return e;const y=o[o.length-1],v="paragraph"!==y.type||s.length?Z(p,0):Z(y,u(y));return{...r,document:b,selection:oe(v)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ne(n),i=function(e){switch(e.document.design?.effectsId){case"flat":return{fill:"#e2e8f0",border:"#64748b"};case"intense":return{fill:"#0f766e",border:"#115e59"};case"moderate":return{fill:"#5b9bd5",border:"#2f75b5"};default:return{fill:"#4472C4",border:"#2F528F"}}}(n),l={width:150,height:100,blocks:[pr("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:ub(void 0,"front")},s=co("",Y(o,a),void 0,l),c=d(o,a,[s]),u=Kr(n).map((e,t)=>t===r?c:pn(e));return Ie(n,u,oe(Z(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:_l}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Sw(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Xl}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:Gl}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==r.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:Cw(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Cw(e.textBox.floating,t)}}:Gn(e))});return Ie(e,a,$(a,Wn(e)))}(e,t),{mergeKey:ql}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=e=>({...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none",behindDoc:"back"===t}),i=Kr(e).map((e,t)=>t!==o?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==r.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:a(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:a(e.textBox.floating)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:Yl}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=Kr(e).map((e,o)=>o!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:Iw(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Iw(e.textBox.floating,t,n)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t,n),{mergeKey:Zl}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Gn(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?gb(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?gb(n,t):n}}}return Gn(e)})});return Ie(e,a,$(a,Wn(e)))}(e,t),{mergeKey:Jl}),setFloatingRotation:t=>e.applyTransactionalState(e=>Tw(e,t),{mergeKey:Ql}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>ub(e,t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Gn(e);if("image"===e.kind){const t=o(e.image.floating),n=t?{...e.image,floating:t}:(()=>{const{floating:t,...n}=e.image;return n})();return{...e,image:n}}if("textBox"===e.kind){const t=o(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return Gn(e)})});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:es}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?pn(e):{...pn(e),runs:e.runs.map(e=>e.id!==a.id?Gn(e):"image"===e.kind?{...e,image:{...e.image,floating:o(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:o(e.textBox.floating)}}:Gn(e))});return Ie(e,i,$(i,Wn(e)))}(e,t),{mergeKey:ts}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=db(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:o,v:r}=function(e){return{h:e.endsWith("Left")?"left":e.endsWith("Right")?"right":"center",v:e.startsWith("top")?"top":e.startsWith("bottom")?"bottom":"ctr"}}(t),a={relativeFrom:"margin",align:o,offset:0},i={relativeFrom:"margin",align:r,offset:0},{paragraphIndex:l,run:s}=n,c=Kr(e).map((e,t)=>t!==l?pn(e):{...pn(e),runs:e.runs.map(e=>{if(e.id!==s.id)return Gn(e);if("image"===e.kind){const t={...e.image.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.image.floating?.wrap?e.image.floating.wrap:e.image.floating?.wrap??"square",behindDoc:e.image.floating?.behindDoc,positionH:a,positionV:i};return{...e,image:{...e.image,floating:t}}}if("textBox"===e.kind){const t={...e.textBox.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.textBox.floating?.wrap?e.textBox.floating.wrap:e.textBox.floating?.wrap??"square",behindDoc:e.textBox.floating?.behindDoc,positionH:a,positionV:i};return{...e,textBox:{...e.textBox,floating:t}}}return Gn(e)})});return Ie(e,c,$(c,Wn(e)))}(e,t),{mergeKey:ns}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Sw(e,e=>({...e,preset:t}))}(e,t),{mergeKey:os}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Rw(e,e=>({...e,vert:n}))}(e,t),{mergeKey:rs}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Rw(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:as}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:is}),rotateTextBox:t=>e.applyTransactionalState(e=>kw(e,t),{mergeKey:ls}),getTextBoxSizeCm:()=>function(e){const t=ay(e),n=t&&Er(t.run);return n?{width:n.width/Ar,height:n.height/Ar}:null}(e.state()),isTextBoxSelected:()=>null!==ay(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,width:Math.max(24,Math.round(t*Ar))}))}(e,t),{mergeKey:ss}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return Pw(e,e=>({...e,height:Math.max(24,Math.round(t*Ar))}))}(e,t),{mergeKey:cs})}}function Aw(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!zr(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function Mw(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=mb(e),n=t&&qn(t.run);return n?{width:n.width/Ar,height:n.height/Ar}:null}(e.state()),setWidthCm:t=>e.commandsController.applyImageWidthCmCommand(t),setHeightCm:t=>e.commandsController.applyImageHeightCmCommand(t),isCropActive:()=>e.imageCropMode.isActive(),toggleCrop:()=>e.imageCropMode.toggle(),applyCropAspect:t=>e.commandsController.applyImageCropAspectCommand(t),getCropShape:()=>function(e){const t=mb(e);return(t&&qn(t.run))?.cropShape??null}(e.state())?.preset??null,applyCropShape:t=>e.commandsController.applyImageCropShapeCommand(t),applyCropFill:()=>e.commandsController.applyImageCropFillCommand(),applyCropFit:()=>e.commandsController.applyImageCropFitCommand(),resetCrop:()=>e.commandsController.resetImageCropCommand(),getBorder:()=>function(e){const t=mb(e);return(t&&qn(t.run))?.border??null}(e.state()),setBorder:t=>e.commandsController.applyImageBorderCommand(t),flip:t=>e.commandsController.flipImageCommand(t),rotate:t=>e.commandsController.rotateImageCommand(t),getTransparency:()=>function(e){const t=mb(e),n=t&&qn(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==mb(e.state())}}function Fw(e){const t=e.clipboardActions??li({state:e.state,isReadOnly:e.isReadOnly,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput});return{canCut:()=>!0,canPaste:()=>!0,hasSelection:t.hasSelection,copy:()=>{t.copy()},cut:()=>{t.cut()},paste:()=>{t.paste("rich")},pasteAsPlainText:()=>{t.paste("text")},pasteMergeFormatting:()=>{t.paste("merge")}}}function Ow(e,t){const n=io(e),o=Fe(e.document);if("header"===n||"footer"===n){const r=fo(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=aa(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=fo(e),r=o[n];if(!r)return e;const a=[...o];return a[n]={...r,blocks:t},{...e,document:{...e.document,sections:a}}}return e}function Dw(e,t){return null!==Lw(e,t)}function Ew(e,t){const n=Lw(e,t);if(!n)return e;const{nextBlocks:o}=n,r=Ow(e,o),a=o.flatMap(Po);return{...r,selection:Nw(e.selection,a)}}function Lw(e,t){const n=io(e);if("footnote"===n)return null;const o=fn(e,n);if(0===o.length)return null;const r=Wn(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let l=n;l<=o;l+=1){const e=t[l];if(void 0===e)return null;r.add(e)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==e[l].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{Po(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:l}=a,s=o.slice(i,l+1);let c;if("up"===t){if(0===i)return null;const e=o[i-1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i-1),...s,e,...o.slice(l+1)]}else{if(l===o.length-1)return null;const e=o[l+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...s,...o.slice(l+2)]}return{nextBlocks:c}}function Nw(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return Z(r,Math.min(e.offset,u(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function $w(e,t){const n=function(e){const t=io(e);if("footnote"===t)return null;const n=fn(e,t);if(0===n.length)return null;const o=Wn(e),r=/* @__PURE__ */new Set;for(let l=o.startIndex;l<=o.endIndex;l+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=Po(n[o]).length;if(l<e+r){t=o;break}e+=r}if(t<0)return null;r.add(t)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==n[l].type)return null;return{blocks:n,lo:a,hi:i}}(e);if(!n)return e;if(n.hi-n.lo<1)return e;const{lo:o,hi:r,blocks:a}=n,i=a.slice(o,r+1).map((e,t)=>({block:e,index:t,key:zw(Lt(e))}));i.sort((e,n)=>{const o=function(e,t){const n=function(e,t){return void 0!==e&&void 0!==t?e===t?0:e<t?-1:1:void 0!==e?-1:void 0!==t?1:0}(e.num,t.num);return 0!==n?n:e.text.localeCompare(t.text,void 0,{sensitivity:"base"})}(e.key,n.key);return 0!==o?t?-o:o:e.index-n.index});const l=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],s=Ow(e,l),c=l.flatMap(Po);return{...s,selection:Hw(e.selection,c)}}function zw(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function Hw(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return Z(r,Math.min(e.offset,u(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Ww(e,t){const n=Wn(e),o=Kr(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=ga(o[l]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return pn(e);const i=ga(e.style?.styleId);if(e.list&&e.list.kind){const n=e.list.level??0,o=t?Math.max(0,n-1):Math.min(8,n+1);return o===n?pn(e):(a=!0,be(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return pn(e);a=!0;const o=pn(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return pn(e);a=!0;const l=pn(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?Ie(e,i,$(i,n)):e}var Uw=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function jw(e,t){return Math.abs(e-t)<1e-6}function Vw(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var Kw=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var _w=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var Xw={width:1.5,type:"solid",color:"#000000"};function Gw(e,t){const n=t.text??Lt(e).slice(0,1),o=Math.max(1,Math.min(10,Math.round(t.lines??3))),r=e.runs[0]?.styles,a=t.font;return{text:n,lines:o,type:"margin"===t.type?"margin":"drop",style:void 0!==a?{...r??{},fontFamily:a}:r}}function qw(e){return{togglePageBreakBefore:()=>e.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>e.commandsController.toggleParagraphFlagCommand("keepWithNext"),toggleKeepLinesTogether:()=>e.commandsController.toggleParagraphFlagCommand("keepLinesTogether"),toggleWidowControl:()=>e.commandsController.toggleParagraphFlagCommand("widowControl"),setSpacingAfter:t=>e.commandsController.applyParagraphStyleCommand("spacingAfter",t),setSpacingBefore:t=>e.commandsController.applyParagraphStyleCommand("spacingBefore",t),setLineRule:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.lineRule,i=(()=>{if(null!==t&&"auto"!==t)return Kw.has(t)?t:a})();if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.textDirection,i=null===t||"lrTb"===t?void 0:_w.has(t)?t:a;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressAutoHyphens,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressLineNumbers,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.kinsoku,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.overflowPunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.wordWrap,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDE,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDN,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.adjustRightInd,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.topLinePunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.pageBreakBefore,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepWithNext,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepLinesTogether,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.widowControl,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.contextualSpacing,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.mirrorIndents,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...pn(e),style:l}});return r?Ie(e,a,$(a,n)):e}(e,t)),setIndentLeft:t=>e.commandsController.applyParagraphStyleCommand("indentLeft",t),setIndentRight:t=>e.commandsController.applyParagraphStyleCommand("indentRight",t),setIndentFirstLine:t=>e.commandsController.applyParagraphStyleCommand("indentFirstLine",t),setIndentHanging:t=>e.commandsController.applyParagraphStyleCommand("indentHanging",t),setSpecialIndent:(t,n)=>{const o=n??48;e.applyTransactionalState(e=>{let n=Ve(e,"indentFirstLine",null);return n=Ve(n,"indentHanging",null),"firstLine"===t?n=Ve(n,"indentFirstLine",o):"hanging"===t&&(n=Ve(n,"indentHanging",o)),n},{mergeKey:nl}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=Ve(e,"borderTop",t);return n=Ve(n,"borderRight",t),n=Ve(n,"borderBottom",t),n=Ve(n,"borderLeft",t),n},{mergeKey:ol}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>Ve(e,"borderBottom",Xw),{mergeKey:ol}),e.focusInput()},setLineHeight:t=>e.commandsController.applyParagraphStyleCommand("lineHeight",t),setListFormat:t=>e.commandsController.handleListFormatChange(t),setListStartAt:t=>e.commandsController.handleListStartAtChange(t),setListLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Math.min(8,Math.max(0,Math.round(t))),r=Kr(e);let a=!1;const i=r.map((e,t)=>t<n.startIndex||t>n.endIndex?e:e.list?(e.list.level??0)===o?e:(a=!0,be(e,o)):e);return a?Ie(e,i,$(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Dw(e.state(),"up")?(e.applyTransactionalState(e=>Ew(e,"up"),{mergeKey:rl}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Dw(e.state(),"down")?(e.applyTransactionalState(e=>Ew(e,"down"),{mergeKey:al}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Dw(e.state(),"up"),canMoveParagraphsDown:()=>Dw(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>Ww(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>Ww(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=Wn(e),n=Kr(e);let o=!1;const r=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const r=e.style;if(!r||Uw.every(e=>!(e in r)))return e;o=!0;const a=pn(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?Ie(e,r,$(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=e.document.styles,a=t.set??[],i=t.clear??[],l=Boolean(t.clearAll),s=void 0!==t.tabs||a.length>0||i.length>0||l;let c=!1;const d=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;if(!s)return e;const d=ct(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!jw(e.position,t));return d.some(e=>jw(e.position,t))&&n.push({position:t,type:"clear"}),n};let p=[...void 0!==t.tabs?(t.tabs??[]).map(e=>({...e})):(e.style?.tabs??[]).map(e=>({...e}))];if(l){p=[];for(const e of d)p=u(p,e.position)}for(const t of i)p=u(p,t);for(const t of a)p=p.filter(e=>!jw(e.position,t.position)),p.push(Vw(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=pn(e);return g.style={...e.style??{},tabs:p.length>0?p:null},c=!0,g});let u=c;const p=void 0!==t.default&&null!==t.default,g=e.document.settings?.defaultTabStop,f=p&&void 0!==t.default&&null!==t.default?Math.min(1584,Math.max(1,t.default)):void 0;if((p||null===t.default)&&(null===t.default?void 0!==g:void 0!==t.default&&g!==f)&&(u=!0),!u)return e;let m=Ie(e,d,$(d,n));if(p||null===t.default){const n={...e.document.settings??{}};null===t.default?delete n.defaultTabStop:void 0!==t.default&&(n.defaultTabStop=f),m={...m,document:{...m.document,settings:n}}}return m}(e,t),{mergeKey:cl}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=null==t?null:Math.min(8,Math.max(0,Math.round(t)));let a=!1;const i=o.map((e,t)=>{if(t<n.startIndex||t>n.endIndex)return e;if((e.style?.outlineLevel??null)===r)return e;a=!0;const o={...e.style??{}};null===r?delete o.outlineLevel:o.outlineLevel=r;const i=pn(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?Ie(e,i,$(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return Ve(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>$w(e,t)),hasDropCap:()=>function(e){const t=Wn(e);return Kr(e).slice(t.startIndex,t.endIndex+1).some(e=>void 0!==e.dropCap)}(e.state()),setDropCap:t=>{e.applyTransactionalState(e=>function(e,t){const n=Wn(e),o=Kr(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,l=o.map((e,n)=>n<r||n>a?pn(e):i?{...pn(e),dropCap:void 0}:{...pn(e),dropCap:Gw(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Ie(e,l,$(l,n))}(e,t)),e.focusInput()}}}function Yw(e){const t=Fe(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(fo(e),t.length-1))}}function Zw(e,t){const{sections:n,sectionIndex:o}=Yw(e);if(0===n.length)return e;const r=t(n[o]);if(r===n[o])return e;const a=[...n];return a[o]=r,{...e,document:{...e.document,sections:a}}}function Jw(e,t,n="default"){const o=Rn(t,n);return Zw(e,e=>e[o]?e:{...e,[o]:[sa(t)]})}function Qw(e,t,n="default"){const o=Rn(t,n),r=Zw(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:io(r)===t?oS(r):r}function eS(e,t,n="default"){const o=Jw(e,t,n),{sections:r,sectionIndex:a}=Yw(o),i=(r[a][Rn(t,n)]??[]).flatMap(Po).find(Boolean);return i?{...o,selection:En(Z(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function tS(e){const{sections:t,sectionIndex:n}=Yw(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function nS(e){const{sections:t,sectionIndex:n}=Yw(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function oS(e){const{sections:t,sectionIndex:n}=Yw(e),o=(t[n]?.blocks??[]).flatMap(Po).find(Boolean);return o?{...e,selection:En(Z(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function rS(e){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Rt(o,0,i),s=Rt(o,i,u(o)),c={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Y(o,i)},d=Ut(o,[...l,c,...s]),p=Kr(n),g=[...r(p.slice(0,a)),d,...r(p.slice(a+1))];return Ie(n,g,oe(Z(d,i+c.text.length)))}(e,"PAGE")}function aS(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function iS(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},aS("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},aS("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[aS("PAGE",void 0,`run:page-field:${n}`,t)]}function lS(e,t="page",n){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ne(n),l=Y(o,i),s=t.map((e,t)=>e.styles?e:{...e,styles:l,id:`${e.id}:${t}`}),c=Ut(o,[...Rt(o,0,i),...s,...Rt(o,i,u(o))]),d=Kr(n),p=[...r(d.slice(0,a)),c,...r(d.slice(a+1))],g=s.reduce((e,t)=>e+t.text.length,0);return Ie(n,p,oe(Z(c,i+g)))}(e,iS(t,n))}function sS(e){const t=Fe(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(fo(e),t.length-1))}}function cS(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return lS(e,o,r);const i="top"===t?"header":"footer",l=Rn(i,"default"),{sections:s,sectionIndex:c}=sS(e);if(0===s.length)return e;const d={id:no("paragraph"),type:"paragraph",runs:iS(o,r),style:{styleId:i,align:a}},u={...s[c],[l]:[d]},p=[...s];return p[c]=u,{...e,document:{...e.document,sections:p},selection:En(Z(d,0)),activeSectionIndex:c,activeZone:i}}function dS(e){const t={isLandscape:()=>{const t=fo(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;if(!o)return;const r=o.pageSettings?.orientation??"portrait";t.setOrientation("portrait"===r?"landscape":"portrait")},breakNextPage:()=>e.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>e.commandsController.applyInsertSectionBreakCommand("continuous"),breakEvenPage:()=>e.commandsController.applyInsertSectionBreakCommand("evenPage"),breakOddPage:()=>e.commandsController.applyInsertSectionBreakCommand("oddPage"),breakNextColumn:()=>e.commandsController.applyInsertSectionBreakCommand("nextColumn"),getMargins:()=>{const t=fo(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=fo(e.state()),o=e.state().document.sections?.[n]??e.state().document;o?.pageSettings&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,margins:{...o.pageSettings.margins,...t}}})},setMarginsPreset:t=>{e.applyTransactionalState(e=>Pn(e,t)),e.focusInput()},getPageNumbering:()=>{const t=fo(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=sS(e);if(0===n.length)return e;const r={...n[o].pageNumbering,...void 0!==t.start?{start:t.start}:{},...void 0!==t.format?{format:t.format}:{}};return a(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>Uo(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ra(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>ft(e,t)),e.focusInput()},getColumns:()=>sr(e.state()),setColumns:t=>{e.applyTransactionalState(e=>ua(e,t)),e.focusInput()},getVerticalAlign:()=>gn(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>b(e,t)),e.focusInput()},getSectionStart:()=>{const t=fo(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=fo(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>ao(e.state()),setBidi:t=>{e.applyTransactionalState(e=>Vr(e,t)),e.focusInput()},getHyphenation:()=>function(e){const t=e.document.settings;return{value:!0===t?.autoHyphenation,zone:t?.hyphenationZone,caps:t?.doNotHyphenateCaps,limit:t?.consecutiveHyphenLimit}}(e.state()),setHyphenation:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.settings,o={...n??{},...void 0!==t.value?{autoHyphenation:t.value}:void 0!==n?.autoHyphenation?{autoHyphenation:n.autoHyphenation}:{},...void 0!==t.zone?{hyphenationZone:t.zone}:void 0!==n?.hyphenationZone?{hyphenationZone:n.hyphenationZone}:{},...void 0!==t.caps?{doNotHyphenateCaps:t.caps}:void 0!==n?.doNotHyphenateCaps?{doNotHyphenateCaps:n.doNotHyphenateCaps}:{},...void 0!==t.limit?{consecutiveHyphenLimit:t.limit}:void 0!==n?.consecutiveHyphenLimit?{consecutiveHyphenLimit:n.consecutiveHyphenLimit}:{}};return{...e,document:{...e.document,settings:o}}}(e,t)),e.focusInput()}};return t}function uS(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>eS(e,"header")),editFooter:()=>t(e=>eS(e,"footer")),editFirstPageHeader:()=>t(e=>eS(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>eS(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>eS(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>eS(e,"footer","evenPage")),insertPageNumber:()=>t(e=>rS(e)),insertPageNumberXOfY:()=>t(e=>lS(e,"xOfY")),placePageNumberTop:()=>t(e=>cS(e,"top")),placePageNumberBottom:()=>t(e=>cS(e,"bottom")),exit:()=>t(e=>function(e){return oS(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>tS(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(tS(e)===t)return e;let n=e;return t?(n=Jw(n,"header","firstPage"),n=Jw(n,"footer","firstPage"),n):(n=Qw(n,"header","firstPage"),Qw(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>nS(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(nS(e)===t)return e;let n=e;return t?(n=Jw(n,"header","evenPage"),n=Jw(n,"footer","evenPage"),n):(n=Qw(n,"header","evenPage"),Qw(n,"footer","evenPage"))}(t,e))}}function pS(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function gS(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=Wn(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:Wr(),name:l,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[s.id]:s},order:[...i,s.id]},d={...e.document,bookmarks:c};return{...e,document:d}}(e,t)),e.focusInput()},remove:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.bookmarks;if(!n||!n.items[t])return e;const o={...n.items};delete o[t];const r={items:o,order:n.order.filter(e=>e!==t)};return{...e,document:{...e.document,bookmarks:r}}}(e,t)),e.focusInput()},list:()=>pS(e.state()).map(e=>({id:e.id,name:e.name}))}}var fS=["January","February","March","April","May","June","July","August","September","October","November","December"],mS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function hS(e,t){let n="";const o=e=>String(e).padStart(2,"0");let r=0;const a=t;for(;r<a.length;){const t=a[r];let i=t;for(;r+i.length<a.length&&a[r+i.length]===t;)i+=t;const l=e.getHours();switch(t){case"d":n+=i.length>=4?mS[e.getDay()]:3===i.length?mS[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?fS[e.getMonth()]:3===i.length?fS[e.getMonth()].slice(0,3):2===i.length?o(e.getMonth()+1):String(e.getMonth()+1);break;case"y":n+=i.length>=3?String(e.getFullYear()):String(e.getFullYear()).slice(-2);break;case"H":n+=o(l);break;case"h":n+=i.length>=2?o(l%12==0?12:l%12):String(l%12==0?12:l%12);break;case"m":n+=i.length>=2?o(e.getMinutes()):String(e.getMinutes());break;case"s":n+=i.length>=2?o(e.getSeconds()):String(e.getSeconds());break;default:if(a.slice(r).toLowerCase().startsWith("am/pm")){n+=l<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}function bS(e,t){const n=t.type??"REF";if(!function(e,t){return pS(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ne(o),s=Y(a,l),c={type:n,bookmark:t.bookmark},d={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:c,styles:s},p=Ut(a,[...Rt(a,0,l),d,...Rt(a,l,u(a))]),g=Kr(o),f=[...r(g.slice(0,i)),p,...r(g.slice(i+1))];return Ie(o,f,oe(Z(p,l+d.text.length)))}function yS(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,a=zr(e.selection)?e:Me(e),{paragraph:i,index:l,offset:s}=Ne(a),c=Y(i,s),d=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},p={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:hS(o,n),kind:"field",field:d,styles:c},g=Ut(i,[...Rt(i,0,s),p,...Rt(i,s,u(i))]),f=Kr(a),m=[...r(f.slice(0,l)),g,...r(f.slice(l+1))],h=p.text.length;return Ie(a,m,oe(Z(g,s+h)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=hS(n,t);return 0===o.length?e:za(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>bS(e,t)),e.focusInput()}}}function vS(e){let t=!1,n=!1;const o=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},r={firstRow:!1,lastRow:!1,firstCol:!1,lastCol:!1,noHBand:!1,noVBand:!1},a=e=>{const t=fo(e),n=F(e.document,e.selection.focus.paragraphId,t);if(!n)return null;const o=function(e,t,n){if("footnote"===n){const t=e.activeFootnoteId;return t?e.document.footnotes?.items[t]?.blocks??null:null}const o=Fe(e.document)[t];return o?"header"===n?o.header??[]:"footer"===n?o.footer??[]:o.blocks:null}(e,t,n.zone);if(!o)return null;const r=i(o,n.tablePath);return r?.[r.length-1]?.table??null},l=e=>{const t=a(e);if(!t)return null;const n=cr(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(F(e.state().document,e.state().selection.focus.paragraphId,fo(e.state()))),selectionLabel:()=>{const t=e.state();if(Wn(t).isCollapsed)return null;const n=fo(t),o=F(t.document,t.selection.anchor.paragraphId,n),r=F(t.document,t.selection.focus.paragraphId,n),a=o?.tablePath[o.tablePath.length-1],i=r?.tablePath[r.tablePath.length-1];if(!o||!r||!a||!i||o.zone!==r.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(o.tablePath,r.tablePath)||a.rowIndex===i.rowIndex&&a.cellIndex===i.cellIndex)return null;const l=e.selectionBoxes().length;return 0===l?null:`Table selection: ${l} cell${1===l?"":"s"}`},getTblLook:()=>{const t=l(e.state());return t?{firstRow:t.firstRow,lastRow:t.lastRow,firstCol:t.firstCol,lastCol:t.lastCol,bandedRows:!t.noHBand,bandedCols:!t.noVBand}:null},toggleTblLook:e=>o(t=>{const n=l(t);if(!n)return t;const o={...n};switch(e){case"firstRow":o.firstRow=!n.firstRow;break;case"lastRow":o.lastRow=!n.lastRow;break;case"firstCol":o.firstCol=!n.firstCol;break;case"lastCol":o.lastCol=!n.lastCol;break;case"bandedRows":o.noHBand=!n.noHBand;break;case"bandedCols":o.noVBand=!n.noVBand}return Ds(t,"tblLook",o)},Wl),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Ds(t,"styleId",e||null),Ul),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Ds(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),jl),canSetAutoFit:()=>null!==bs(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Rs(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...us(),type:"property",previous:{...r??{}}}});let a=ps(r,"layout",n);return"window"===t?a=ps(a,"width","100%"):"contents"===t&&(a=ps(a,"width",null)),{...o,style:a}})}(t,e),Ll),distributeColumns:()=>o(e=>Rs(e,e=>{const t=ln(e),n=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),o=(e.gridCols??[]).reduce((e,t)=>e+("number"==typeof t&&t>0?t:0),0),r=o>0?o:120*n,a=r/n,i=Array.from({length:n},()=>a),l=e.rows.map((e,n)=>({...e,cells:e.cells.map((e,o)=>{const r=t.find(e=>e.rowIndex===n&&e.cellIndex===o);return r?{...e,style:{...e.style??{},width:a*Math.max(1,r.colSpan)}}:e})}));return{...e,gridCols:i,rows:l,style:{...e.style??{},width:r}}}),jl),distributeRows:()=>o(e=>Rs(e,e=>{let t=0;for(const o of e.rows){const e=o.style?.height,n="number"==typeof e?e:"string"==typeof e?Number.parseFloat(e):0;Number.isFinite(n)&&n>t&&(t=n)}t<=0&&(t=24);const n=e.rows.map(e=>({...e,style:{...e.style??{},height:t,heightRule:"atLeast"}}));return{...e,rows:n}}),jl),canMerge:()=>e.tableOps.canMergeSelectedTable(e.state()),canSplit:()=>e.tableOps.canSplitSelectedTable(e.state()),canEditColumn:()=>e.tableOps.canEditSelectedTableColumn(e.state()),canEditRow:()=>e.tableOps.canEditSelectedTableRow(e.state()),canConvertToText:()=>null!==bs(e.state()),convertToText:()=>o(e=>Ws(e),Bl),canConvertToTable:()=>{return!bs(t=e.state())&&null!==Ts(t);var t},convertToTable:()=>o(e=>Us(e),Al),canSplitTableAtRow:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);if(!o)return!1;const r=t.loc.rowIndex;return r>0&&r<o.rows.length}(e.state()),splitTableAtRow:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex;if(r<=0||r>=o.rows.length)return e;const a=o.rows.slice(0,r),i=o.rows.slice(r),l={...o,rows:a},s=bn(i),c=Ps(e,[l,pr(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:oe(Z(d,0))}:e}(e),Ml),canSortTable:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return!!o&&function(e){let t=0;for(const n of e)n.isHeader||(t+=1);return t}(o.rows)>=2}(e.state()),sortTable:e=>o(t=>Vs(t,e),"ascending"===e?Fl:Ol),canDeleteTable:()=>null!==bs(e.state()),deleteTable:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=t.loc.tablePath[0]?.tableBlockIndex;if(void 0===o||"table"!==n[o]?.type)return e;if(1===n.length){const t=pr(""),n=Ps(e,[t]);return n===e?e:{...n,selection:oe(Z(t,0))}}const r=function(e,t){for(let n=t+1;n<e.length;n+=1){const t=e[n];if("paragraph"===t?.type)return t.id}for(let n=t-1;n>=0;n-=1){const t=e[n];if("paragraph"===t?.type)return t.id}return null}(n,o),a=Ps(e,[]);if(a===e)return e;if(r){const e=Kr(a).find(e=>e.id===r);if(e)return{...a,selection:oe(Z(e,0))}}return a}(e),Dl),canToggleRepeatHeaderRows:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=bs(e);if(!t)return!1;const n=Is(e);if(!n)return!1;const o=Ss(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&_s(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=bs(e);if(!t)return e;const n=Is(e);if(!n)return e;const o=Ss(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=_s(o.rows[0]);return Rs(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),Nl),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),fl),split:()=>o(t=>e.tableOps.splitSelectedTable(t),ml),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),hl),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),hl),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),bl),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),yl),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),yl),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),vl),canDeleteCell:()=>ic(e.state()),deleteCell:()=>o(e=>lc(e),El),cellShading:e=>o(t=>Fs(t,"shading",e||null),xl),cellBorders:()=>o(e=>Os(e,{width:1,type:"solid",color:"#64748b"}),wl),cellNoBorders:()=>o(e=>Os(e,{width:0,type:"none",color:"transparent"}),wl),applyBorderPreset:e=>o(t=>function(e,t,n=Bs){const o=Ms(e);if(!o)return e;const r=/* @__PURE__ */new Map,a=new Set(o.selectedEntries.map(e=>e.cell.id)),i=/* @__PURE__ */new Map;for(const m of o.entries)for(let e=m.visualRowIndex;e<m.visualRowIndex+m.rowSpan;e+=1)for(let t=m.visualColumnIndex;t<m.visualColumnIndex+m.colSpan;t+=1)i.set(`${e}:${t}`,m);const l=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},s=(e,t,o,r,a=n)=>{l(e,t,a),o&&o.cell.id!==e?.cell.id&&l(o,r,a)},c=(e,t=n)=>{if("top"===e||"bottom"===e){const n="top"===e?o.startRow:o.endRow,r=n+("top"===e?-1:1);for(let l=o.startCol;l<=o.endCol;l+=1){const o=i.get(`${n}:${l}`);o&&a.has(o.cell.id)&&s(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${l}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,l=r+("left"===e?-1:1);for(let n=o.startRow;n<=o.endRow;n+=1){const o=i.get(`${n}:${r}`);o&&a.has(o.cell.id)&&s(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${l}`),"left"===e?"borderRight":"borderLeft",t)}},d=()=>{for(let e=o.startRow+1;e<=o.endRow;e+=1)for(let t=o.startCol;t<=o.endCol;t+=1){const n=i.get(`${e-1}:${t}`),o=i.get(`${e}:${t}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderBottom",o,"borderTop")}},u=()=>{for(let e=o.startCol+1;e<=o.endCol;e+=1)for(let t=o.startRow;t<=o.endRow;t+=1){const n=i.get(`${t}:${e-1}`),o=i.get(`${t}:${e}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderRight",o,"borderLeft")}};switch(t){case"none":for(const e of o.selectedEntries)for(const t of["borderTop","borderRight","borderBottom","borderLeft","borderStart","borderEnd","borderTopLeftToBottomRight","borderTopRightToBottomLeft"])l(e,t,As);c("top",As),c("right",As),c("bottom",As),c("left",As);break;case"top":c("top");break;case"right":c("right");break;case"bottom":c("bottom");break;case"left":c("left");break;case"outside":c("top"),c("right"),c("bottom"),c("left");break;case"insideHorizontal":d();break;case"insideVertical":u();break;case"inside":d(),u();break;case"all":c("top"),c("right"),c("bottom"),c("left"),d(),u();break;case"diagonalDown":for(const e of o.selectedEntries)l(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)l(e,"borderTopRightToBottomLeft")}if(0===r.size)return e;const p=/* @__PURE__ */new Set;for(const m of o.entries)if(r.has(m.cell.id))for(const e of m.cell.blocks)for(const t of Po(e))p.add(t.id);const g=t=>{const n=r.get(t.id);if(!n)return t;let o=t.style;e.trackChangesEnabled&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...us(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=ps(o,e,r);return{...t,style:o}},f=Fe(e.document).map(e=>({...e,blocks:ya(e.blocks,p,g),header:e.header?ya(e.header,p,g):void 0,footer:e.footer?ya(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),wl),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Ds(e,"width","100%"),Sl),alignLeft:()=>o(e=>Fs(e,"horizontalAlign","left"),Cl),alignCenter:()=>o(e=>Fs(e,"horizontalAlign","center"),Cl),alignRight:()=>o(e=>Fs(e,"horizontalAlign","right"),Cl),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,Fs(Fs(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},Il),getCellAlignmentState:()=>function(e){const t=Ms(e);if(!t||0===t.selectedEntries.length)return null;const n=t.selectedEntries.map(({cell:e})=>e.style?.horizontalAlign??"left"),o=t.selectedEntries.map(({cell:e})=>e.style?.verticalAlign??"top"),r=(e,t)=>{const n=e[0];return n?e.some(e=>!t.includes(e))?null:e.some(e=>e!==n)?"mixed":n:null};return{horizontal:r(n,["left","center","right"]),vertical:r(o,["top","middle","bottom"])}}(e.state()),setCellVerticalAlign:e=>o(t=>Fs(t,"verticalAlign",e),Tl),setCellTextDirection:e=>o(t=>Fs(t,"textDirection",e),kl),setCellWidth:e=>o(t=>function(e,t){return Fs(e,"width",t)}(t,e),Pl),setCellNoWrap:e=>o(t=>function(e,t){return Fs(e,"noWrap",t)}(t,e),Pl),setCellFitText:e=>o(t=>function(e,t){return Fs(e,"fitText",t)}(t,e),Pl),canSetCellMargins:()=>null!==bs(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Fs(n,"paddingTop",t.top)),void 0!==t.right&&(n=Fs(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Fs(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Fs(n,"paddingLeft",t.left)),n}(t,e),$l),canSetCellSpacing:()=>Xs(e.state()),setCellSpacing:e=>o(t=>function(e,t){return Xs(e)?Ds(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),$l),canSetTableIndent:()=>Gs(e.state()),setTableIndent:e=>o(t=>function(e,t){return Gs(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Ds(e,"indentLeft",null):Ds(e,"indentLeft",Math.round(2*t)/2):e}(t,e),$l),canSetTableAlignment:()=>null!==bs(e.state()),setTableAlignment:e=>o(t=>Ys(t,e),$l),canEvaluateTableFormula:()=>null!==bs(e.state()),evaluateTableFormula:e=>o(t=>Qs(t,e),zl),canSelectTable:()=>null!==bs(e.state()),selectTablePart:t=>e.applyState(rc(e.state(),t)),canSetActiveTableRowHeight:()=>null!==bs(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=Ls(n,"height",t.height),void 0!==t.heightRule&&(n=Ls(n,"heightRule",t.heightRule)),n}(t,e),Hl),canSetActiveTableRowBreakAcrossPages:()=>Zs(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Zs(e)?Ls(e,"cantSplit",null===t?null:!t):e}(t,e),Hl),canSetActiveTableRowHeader:()=>null!==bs(e.state()),setActiveTableRowHeader:e=>o(t=>Ns(t,e),Nl),canSetActiveTableColumnWidth:()=>null!==bs(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Ss(ms(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=ln(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:Hs(e,a.id,{[l]:t})}(t,e),Rl),canSetActiveTableWidth:()=>null!==bs(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=bs(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Ss(ms(e.document,o,r.zone),r.tablePath);return a?Es(e,a.id,"width",t):e}(t,e),Sl),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function xS(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>Ox(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Ax[t]??Ax.oasis,o=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.color}}]}));return{...e,document:{...e.document,styles:o,design:{...e.document.design??{},colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading}}}}}}(t,e)),setFontScheme:e=>t(t=>function(e,t){const[n,o]=Mx[t]??Mx.aptos,r=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,textStyle:{...t.textStyle??{},fontFamily:/^heading|title|quote/i.test(e)?o:n}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},fontSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:o.split(",")[0].trim()},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:n.split(",")[0].trim()}}}},styles:r}}}(t,e)),setParagraphSpacing:e=>t(t=>function(e,t){const n={compact:[0,4],tight:[0,6],open:[0,10],relaxed:[4,12]},[o,r]=n[t]??n.open,a=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,paragraphStyle:{...t.paragraphStyle??{},spacingBefore:o,spacingAfter:r}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},paragraphSpacingId:t},styles:a}}}(t,e)),setEffects:e=>t(t=>Fx(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return Fx(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return Fx(e,{watermark:t})}(t,e)),setPageBorder:e=>t(t=>function(e,t){const n=(e.document.sections??[]).map(e=>({...e,pageBorder:t}));return{...e,document:{...e.document,sections:n,design:{...e.document.design??{}}}}}(t,e)),setDefault:()=>{const t=e.state().document.design;t&&globalThis.localStorage?.setItem("oasis-design-default",JSON.stringify(t))},getDesign:()=>e.state().document.design,getPageBorder:()=>e.state().document.sections?.find(e=>e.pageBorder)?.pageBorder}}function wS(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,o)=>({execute:t,refresh:()=>{const t=o?.()??{};return{...t,isEnabled:n(e)&&(t.isEnabled??!0)}}}));var n;const o=function(e){return(t,n,o)=>({execute:n,refresh:()=>({isEnabled:e(t),value:o()})})}(e.gate.isCommandEnabled),r=function(e){return(t,n,o)=>({execute:e=>(n(e),!0),refresh:()=>{const n=o?.()??{};return{...n,isEnabled:e(t)&&(n.isEnabled??!0)}}})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...Nx({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,dialog:e.dialog,link:e.link,command:t,valueCommand:o,actionCommand:r}),...$x({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...zx({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...Kx({dialog:e.dialog,actionCommand:r}),...Hx({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...jx({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...Vx({design:e.design,actionCommand:r}),...Wx({bookmark:e.bookmark,actionCommand:r}),...Ux({fields:e.fields,actionCommand:r})}}}({gate:qx(e),style:Yx(e),selection:Zx(e),history:Jx(e),formatting:ww(e),document:Bw(e),link:Aw(e),image:Mw(e),browser:Fw(e),paragraph:qw(e),section:dS(e),headerFooter:uS(e),table:vS(e),design:xS(e),bookmark:gS(e),fields:yS(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var SS=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",command:"newDocument",icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.importDocx",shortcut:"Ctrl+O",command:"importDocument",icon:"upload"},{id:"file_save",path:"File/Save",labelKey:"generic.save",shortcut:"Ctrl+S",command:"saveDocument",icon:"save"},{id:"file_export",path:"File/Export",labelKey:"menu.file.export",icon:"download"},{id:"file_export_pdf",path:"File/Export/PDF",command:"exportPdf",icon:"file-down"},{id:"file_export_docx",path:"File/Export/DOCX",command:"exportDocx",icon:"file-text"},{id:"file_export_html",path:"File/Export/HTML",hidden:!0},{id:"file_export_md",path:"File/Export/MD",hidden:!0},{id:"file_print",path:"File/Print",labelKey:"menu.file.print",shortcut:"Ctrl+P",command:"print",icon:"printer"},{id:"edit_undo",path:"Edit/Undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z",command:"undo",icon:"undo-2"},{id:"edit_redo",path:"Edit/Redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y",command:"redo",icon:"redo-2"},{id:"edit_repeat",path:"Edit/Repeat",labelKey:"quickAccess.repeat",shortcut:"F4",command:"repeatLastAction",icon:"repeat"},{id:"edit_cut",path:"Edit/Cut",labelKey:"menu.edit.cut",shortcut:"Ctrl+X",command:"cut",icon:"scissors"},{id:"edit_copy",path:"Edit/Copy",labelKey:"menu.edit.copy",shortcut:"Ctrl+C",command:"copy",icon:"copy"},{id:"edit_paste",path:"Edit/Paste",labelKey:"menu.edit.paste",shortcut:"Ctrl+V",command:"paste",icon:"clipboard-paste"},{id:"edit_paste_merge",path:"Edit/Paste Merge Formatting",labelKey:"toolbar.pasteMergeFormatting",command:"pasteMergeFormatting",icon:"paintbrush"},{id:"edit_paste_plain",path:"Edit/Paste as Plain Text",labelKey:"toolbar.pastePlainText",command:"pasteAsPlainText",icon:"clipboard"},{id:"edit_format_painter",path:"Edit/Format Painter",labelKey:"toolbar.formatPainter",command:"formatPainter",icon:"paintbrush"},{id:"edit_format_painter_continuous",path:"Edit/Format Painter Continuous",labelKey:"toolbar.formatPainterContinuous",command:"formatPainterContinuous",icon:"paintbrush"},{id:"edit_cancel_format_painter",path:"Edit/Cancel Format Painter",labelKey:"toolbar.formatPainterCancel",command:"cancelFormatPainter",icon:"x"},{id:"edit_find",path:"Edit/Find & Replace",labelKey:"find.title",shortcut:"Ctrl+F",command:"find",icon:"search"},{id:"edit_selectAll",path:"Edit/Select All",labelKey:"menu.edit.selectAll",shortcut:"Ctrl+A",hidden:!0},{id:"review_previous_revision",path:"Review/Previous Change",labelKey:"toolbar.previousRevision",command:"previousRevision",icon:"chevron-up"},{id:"review_next_revision",path:"Review/Next Change",labelKey:"toolbar.nextRevision",command:"nextRevision",icon:"chevron-down"},{id:"review_revision_markup",path:"Review/Show Markup",labelKey:"toolbar.revisionMarkup",command:"toggleRevisionMarkup",icon:"highlighter"},{id:"review_accept_all_revisions",path:"Review/Accept All Changes",labelKey:"toolbar.acceptAll",command:"requestAcceptAllRevisions",icon:"check-check"},{id:"review_reject_all_revisions",path:"Review/Reject All Changes",labelKey:"toolbar.rejectAll",command:"requestRejectAllRevisions",icon:"undo-2"},{id:"review_comments_panel",path:"Review/Comments Panel",labelKey:"review.commentsPanel",command:"toggleCommentsPanel",icon:"list-filter"},{id:"review_revisions_panel",path:"Review/Reviewing Pane",labelKey:"review.reviewingPane",command:"toggleRevisionsPanel",icon:"list-checks"},{id:"review_new_comment",path:"Review/New Comment",labelKey:"toolbar.newComment",command:"newComment",icon:"message-square-plus"},{id:"review_reply_comment",path:"Review/Reply to Comment",labelKey:"toolbar.replyComment",command:"replyComment",icon:"reply"},{id:"review_edit_comment",path:"Review/Edit Comment",labelKey:"toolbar.editComment",command:"editComment",icon:"pencil"},{id:"review_previous_comment",path:"Review/Previous Comment",labelKey:"toolbar.previousComment",command:"previousComment",icon:"message-square"},{id:"review_next_comment",path:"Review/Next Comment",labelKey:"toolbar.nextComment",command:"nextComment",icon:"messages-square"},{id:"review_resolve_comment",path:"Review/Resolve Comment",labelKey:"toolbar.resolveComment",command:"resolveComment",icon:"message-square-check"},{id:"review_reopen_comment",path:"Review/Reopen Comment",labelKey:"toolbar.reopenComment",command:"reopenComment",icon:"message-square-more"},{id:"review_delete_comment",path:"Review/Delete Comment",labelKey:"toolbar.deleteComment",command:"deleteComment",icon:"message-square-x"},{id:"view_outline",path:"View/Show Outline",labelKey:"menu.view.outline",command:"toggleOutlinePanel",icon:"list"},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:e=>e.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:e=>e.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:e=>e.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_header",path:"Insert/Header",labelKey:"headerFooter.header",command:"editHeader",icon:"panel-top"},{id:"insert_footer",path:"Insert/Footer",labelKey:"headerFooter.footer",command:"editFooter",icon:"panel-bottom"},{id:"insert_page_number",path:"Insert/Page Number",labelKey:"headerFooter.pageNumber",icon:"hash"},{id:"insert_page_number_current",path:"Insert/Page Number/Current Position",labelKey:"headerFooter.pageNumberCurrent",command:"insertPageNumber"},{id:"insert_page_number_xofy",path:"Insert/Page Number/Page X of Y",labelKey:"headerFooter.pageNumberXOfY",command:"insertPageNumberXOfY"},{id:"insert_page_number_top",path:"Insert/Page Number/Top of Page",labelKey:"headerFooter.pageNumberTop",command:"placePageNumberTop"},{id:"insert_page_number_bottom",path:"Insert/Page Number/Bottom of Page",labelKey:"headerFooter.pageNumberBottom",command:"placePageNumberBottom"},{id:"insert_bookmark",path:"Insert/Bookmark",labelKey:"toolbar.bookmark",command:"insertBookmark",icon:"bookmark"},{id:"insert_date",path:"Insert/Date",labelKey:"toolbar.date",command:"insertDateField",icon:"calendar"},{id:"insert_specialChar",path:"Insert/Special Character",hidden:!0},{id:"insert_comment",path:"Insert/Comment",hidden:!0},{id:"format_text",path:"Format/Text",labelKey:"menu.format.text",icon:"type"},{id:"format_text_bold",path:"Format/Text/Bold",labelKey:"toolbar.bold",shortcut:"Ctrl+B",command:"bold",icon:"bold"},{id:"format_text_italic",path:"Format/Text/Italic",labelKey:"toolbar.italic",shortcut:"Ctrl+I",command:"italic",icon:"italic"},{id:"format_text_underline",path:"Format/Text/Underline",labelKey:"toolbar.underline",shortcut:"Ctrl+U",command:"underline",icon:"underline"},{id:"format_text_strike",path:"Format/Text/Strikethrough",labelKey:"toolbar.strike",command:"strike",icon:"strikethrough"},{id:"format_paragraphStyles",path:"Format/Paragraph styles",labelKey:"toolbar.style",hidden:!0},{id:"format_align",path:"Format/Align",labelKey:"menu.format.align",icon:"align-left"},{id:"format_align_left",path:"Format/Align/Left",labelKey:"toolbar.alignLeft",command:"alignLeft",icon:"align-left"},{id:"format_align_center",path:"Format/Align/Center",labelKey:"toolbar.alignCenter",command:"alignCenter",icon:"align-center"},{id:"format_align_right",path:"Format/Align/Right",labelKey:"toolbar.alignRight",command:"alignRight",icon:"align-right"},{id:"format_align_justify",path:"Format/Align/Justify",labelKey:"toolbar.justify",command:"alignJustify",icon:"align-justify"},{id:"format_lineSpacing",path:"Format/Line spacing",hidden:!0},{id:"format_lists",path:"Format/Lists",labelKey:"menu.format.lists",icon:"list"},{id:"format_lists_bullet",path:"Format/Lists/Bullet List",labelKey:"toolbar.bulletList",command:"bulletList",icon:"list"},{id:"format_lists_numbered",path:"Format/Lists/Numbered List",labelKey:"toolbar.numberedList",command:"orderedList",icon:"list-ordered"},{id:"format_clear",path:"Format/Clear formatting",hidden:!0},{id:"layout_orientation",path:"Layout/Orientation",labelKey:"section.orientation",icon:"layout"},{id:"layout_orientation_portrait",path:"Layout/Orientation/Portrait",labelKey:"section.portrait",command:{name:"setOrientation",payload:"portrait"},icon:e=>e.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:e=>e.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_command_search",path:"Tools/Command Search",labelKey:"menu.tools.commandSearch",command:"openCommandSearch",icon:"search",shortcut:"Ctrl+K"},{id:"tools_spelling",hidden:!0,path:"Tools/Spelling"},{id:"tools_preferences",path:"Tools/Preferences",hidden:!0},{id:"help_shortcuts",path:"Help/Keyboard shortcuts",labelKey:"menu.help.shortcuts",hidden:!0},{id:"help_about",path:"Help/About",labelKey:"menu.help.about",hidden:!0}];function CS(t){const n=wS(t.essentials),{runtimePlugins:r,toolbarRegistry:a,menuRegistry:i,dispose:l}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=Jn(),i=new e;for(const e of Or(t.t))a.register(e);for(const e of SS)i.register(e);for(const e of n){for(const t of e.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",groupLabel:t.groupLabel,row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,ribbonGroupLayout:t.ribbonGroupLayout,order:t.order};a.register(e),o.push(t.id)}for(const t of e.menubar??[])i.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),r.push(t.id)}return t.customizeToolbar?.(a),t.customizeMenubar?.(i),{runtimePlugins:n,toolbarRegistry:a,menuRegistry:i,dispose:()=>{for(const e of o)a.remove(e);for(const e of r)i.unregister(e)}}}({essentialsPlugin:n,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),s=function(e){const[t,n]=an(!1),[o,r]=an(new _e({doc:e.initialDocument}));let a=!1;const i=e=>{const t=yt(e),n=o().commands.get(t);if(!n)return{isEnabled:!1,isActive:!1,value:void 0};const r=n.refresh?.()??{isEnabled:!0};return{isEnabled:!1!==r.isEnabled,isActive:Boolean(r.isActive),value:r.value}};return{runtimeReady:t,runtimeEditor:o,commandStateOf:i,toolbarHost:()=>({commands:{execute:(e,t)=>{const n=w(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=w(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await _e.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(e.onExecuted&&(t.commands.onExecuted=e.onExecuted),a)return void(await t.destroy());const i=o();r(t),await i.destroy(),n(!0),requestAnimationFrame(()=>{e.onSettled?.(),e.onReady?.(t)})}catch(t){e.logger.error("runtime:init failed",t),e.onError?.(t),e.onSettled?.()}},dispose:async()=>{a=!0,await o().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:r,focusEditor:t.focusEditor,logger:t.logger,onExecuted:t.onExecuted,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return Zn(()=>{s.initialize()}),o(()=>{s.dispose(),l()}),{toolbarRegistry:a,menuRegistry:i,runtimeReady:s.runtimeReady,runtimeEditor:s.runtimeEditor,commandStateOf:s.commandStateOf,toolbarHost:s.toolbarHost}}var IS=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function TS(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!IS.has(e)})(e)&&(n={command:e,payload:t})},canExecute:()=>null!==n&&function(e){try{return e()}catch{return!1}}(()=>t(n.command,n.payload)),execute:()=>{n&&e(n.command,n.payload)}}}function kS(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Cx({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:e.focusInput,selectedImageRun:n.selectedImageRun,tableOps:n.tableOps,toolbarStyleState:n.styleController.toolbarStyleState,applyBooleanStyleCommand:e=>n.styleController.applyToolbarBooleanStyleCommand(e),locale:e.locale,setLinkDialog:e.setLinkDialog,setImageAltDialog:e.setImageAltDialog,setImageCaptionDialog:e.setImageCaptionDialog,setFontDialog:e.setFontDialog,setParagraphDialog:e.setParagraphDialog});let i;const l=TS((e,t)=>{if(!i)throw new Error("repeat tracking used before ready");return i().commands.execute(e,t)},(e,t)=>!!i&&i().commands.canExecute(e,t)),s=()=>{l.execute()},c=()=>l.canExecute(),{runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m}=CS({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:r,keyboardCommandsController:a,historyActions:t.historyActions,styleController:n.styleController,formatPainter:n.formatPainter,commentComposer:e.commentComposer,tableOps:n.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:n.selectedImageRun,imageCropMode:{isActive:n.imageOps.cropMode,toggle:n.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:n.fr.setIsOpen},newDocument:Ix({isDirty:()=>o.isDirty(),resetDocument:()=>o.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),saveDocument:()=>{o.save().catch(t=>e.logger.error("document:save failed",t))},openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openCommandSearch:()=>e.setCommandSearchOpen(!0),repeatLastAction:s,canRepeatLastAction:c,openTablePropertiesDialog:t=>{const n=mc(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=T(e.state.document).find(e=>e.id===t.paragraphId);if("paragraph"===n?.type){let o=0;for(const r of n.runs){if("math"===r.kind&&t.offset>=o&&t.offset<=o+r.text.length)return void e.setEquationDialog({isOpen:!0,initial:r.math,targetRunId:r.id});o+=r.text.length}}e.setEquationDialog({isOpen:!0})},openFontDialog:r.openFontDialog,openParagraphDialog:r.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:mx(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:mx(e.state).size})},toggleOutlinePanel:e.toggleOutline,isOutlineVisible:e.isOutlineVisible,toggleRevisionsPanel:e.toggleRevisionsPanel,revisionsPanelVisible:e.revisionsPanelVisible},externalPlugins:e.runtimeOptions().plugins,t:e.translator,customizeToolbar:e.runtimeOptions().customizeToolbar,customizeMenubar:e.runtimeOptions().customizeMenubar,initialDocument:e.getStateSnapshot().document,focusEditor:e.focusInput,logger:e.logger,onExecuted:(t,n)=>{l.record(t,n),e.onExecutedTap?.()},onReady:t=>{i=()=>t,o.resolveReady(t),e.runtimeOptions().onReady?.(o)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>o.rejectReady(e)});(function(e,t){const n=()=>t.cloneState(t.getStateSnapshot());e.connectHost({getRuntimeEditor:()=>t.runtimeReady()?t.runtimeEditor():null,getState:()=>n(),getDocument:()=>n().document,setDocument:e=>{t.applyState(wo(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=wn();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=Ox(e,n.themeId)),e=Fx(e,n)}}catch{}t.applyState(e),t.resetEditorChromeState(),t.focusInput()},saveDocument:async()=>{await t.getPersistence().saveDocument(n().document)},getSelection:()=>n().selection,setSelection:e=>{t.applyState({...t.getStateSnapshot(),selection:{anchor:{...e.anchor},focus:{...e.focus}}}),t.focusInput()},focus:()=>t.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.setFocused(!1)},clearHistory:()=>t.clearHistory(),importDocx:e=>t.docIO.handleImportFile(e),exportDocx:()=>Promise.resolve(t.docIO.handleExportDocx()),exportPdf:()=>Promise.resolve(t.docIO.handleExportPdf()),exportDocxBlob:()=>t.docIO.exportDocxBlob(),exportPdfBlob:()=>t.docIO.exportPdfBlob(),getUiState:t.getUiState,updateUiState:t.updateUiState,getZoom:t.getZoom,setZoom:t.setZoom,adjustZoom:t.adjustZoom,toolbarRegistry:t.toolbarRegistry,menuRegistry:t.menuRegistry})})(o,{runtimeReady:d,runtimeEditor:u,getStateSnapshot:e.getStateSnapshot,cloneState:e.cloneState,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,resetEditorChromeState:t.resetEditorChromeState,focusInput:e.focusInput,setFocused:e.setFocused,clearHistory:t.clearHistory,getPersistence:()=>e.documentOptions().persistence??t.fallbackPersistence,docIO:t.docIO,getUiState:e.getUiState,updateUiState:e.updateUiState,getZoom:e.zoom.zoomPercent,setZoom:e.zoom.setZoomPercent,adjustZoom:e.zoom.adjustZoom,toolbarRegistry:f,menuRegistry:m}),we(()=>{if(!d())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());u().dispatch(()=>t)});const{handleKeyDown:h}=function(e){const{state:t,isReadOnly:n,logger:o,focusInput:r,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:g,historyActions:f,styleController:m,findReplace:h,commandSearch:b,runtimeEditor:y}=e,{handleKeyDown:v}=Px({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:u,selectedImageRun:d,setForcePlainTextPaste:c,moveSelectionByWord:g.moveSelectionByWord,moveSelectionToDocumentBoundary:g.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:g.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:g.moveVerticalSelection,moveVerticalByBlock:g.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleCommandSearch:e=>{b.setIsOpen(e??!b.isOpen())},executeCommand:(e,t)=>y().commands.execute(e,t),canExecuteCommand:e=>y().commands.canExecute(e)});return{handleKeyDown:e=>{Rx.includes(e.key)&&m.clearPendingCaretTextStyle();const n=[e.ctrlKey?"Ctrl":null,e.metaKey?"Meta":null,e.altKey?"Alt":null,e.shiftKey?"Shift":null].filter(Boolean).join("+"),r=n?`${n}+${e.key}`:e.key,a=t().selection;o.debug(`key:down ${r} at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}]`),uo("input-to-layout"),v(e),yo("input-to-layout")}}}({state:()=>e.state,isReadOnly:e.isReadOnly,logger:e.logger,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,setForcePlainTextPaste:e.setForcePlainTextPaste,selectedImageRun:n.selectedImageRun,commandsController:a,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,commandSearch:e.commandSearch,runtimeEditor:u});return{commandsController:r,runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m,handleKeyDown:h}}(e)}function PS(e,t){const n=e.document.comments?.items;if(!n?.[t])return null;const o=/* @__PURE__ */new Set;let r=t;for(;n[r]?.parentId&&!o.has(r);){o.add(r);const e=n[r].parentId;if(!n[e])break;r=e}return r}function RS(e,t,n){if(t.document===e.document)return e;const o=e.document.comments?.items[n.commentId]??t.document.comments?.items[n.commentId];if(!o)return t;const r=PS(e,n.commentId)??PS(t,n.commentId)??n.commentId,a=e.document.comments?.order.length??0,i=t.document.comments?.order.length??0;return function(e,t){if(!(t.id.trim()&&t.commentId.trim()&&t.threadId.trim()&&t.actorName.trim()&&Number.isFinite(t.timestamp)))return e;const n=e.document.reviewActivity??[];return n.some(e=>e.id===t.id)?e:{...e,document:{...e.document,reviewActivity:[...n,{...t}]}}}(t,{id:n.id,kind:n.kind,commentId:n.commentId,threadId:r,...n.parentId?{parentId:n.parentId}:{},actorName:n.actorName,...n.actorId?{actorId:n.actorId}:{},targetAuthor:o.author,timestamp:n.timestamp,..."comment-deleted"===n.kind?{affectedCount:Math.max(1,a-i)}:{}})}function BS(e,t){if(!t)return!1;if(!e)return!0;if(e.canModerate)return!0;const n=e.identity?.id.trim();return Boolean(n&&t.authorId&&n===t.authorId)}function AS(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!BS(e,t.items[n]))return!1;const o=/* @__PURE__ */new Set([n]),r=[n],a=/* @__PURE__ */new Map;for(const i of Object.values(t.items)){if(!i.parentId)continue;const e=a.get(i.parentId)??[];e.push(i.id),a.set(i.parentId,e)}for(;r.length;){const n=r.pop();for(const i of a.get(n)??[])if(!o.has(i)){if(o.add(i),!BS(e,t.items[i]))return!1;r.push(i)}}return!0}function MS(e){const[t,n]=an(null),[o,r]=an(""),[a,i]=an(!1),s=()=>e.access?.(),c=()=>{const e=s()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},d=()=>!(e.isReadOnly()||s()&&null===c()),u=()=>d()&&null!==Xe(e.state()),p=t=>d()&&Boolean(e.state().document.comments?.items[t]),g=()=>d()&&null!==dw(e.state()),f=t=>!e.isReadOnly()&&BS(s(),e.state().document.comments?.items[t]),m=()=>{const t=dw(e.state());return null!==t&&f(t.id)},h=t=>!e.isReadOnly()&&AS(s(),e.state().document.comments,t),b=f,y=(e="Local editor")=>{const t=c();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},v=(e,t,n,o,r,a)=>RS(e,t,{id:no("review-activity"),kind:n,commentId:o,...y(r),timestamp:Date.now(),...a?{parentId:a}:{}}),x=t=>{if(!p(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"reply",snapshot:o,parentId:r.id,parentAuthor:r.author,parentText:r.text}),!0)},w=t=>{if(!f(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"edit",snapshot:o,commentId:t,commentAuthor:r.author,commentText:r.text}),!0)},S=()=>{n(null),e.focusInput()},C=t=>{if(!h(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!AS(s(),r.document.comments,t))return r;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const o=/* @__PURE__ */new Set([t]),r=[t],a=/* @__PURE__ */new Map;for(const l of Object.values(n.items)){if(!l.parentId)continue;const e=a.get(l.parentId)??[];e.push(l.id),a.set(l.parentId,e)}for(;r.length>0;){const e=r.pop();for(const t of a.get(e)??[])o.has(t)||(o.add(t),r.push(t))}const i=Object.fromEntries(Object.entries(n.items).filter(([e])=>!o.has(e)));return{...e,document:{...e.document,comments:{...n,items:i,order:n.order.filter(e=>!o.has(e))}}}}(r,t);return o=a.document!==r.document,o?v(r,a,"comment-deleted",t):a}),o},I=(t,n)=>{if(!b(t))return!1;const o=e.state();let r=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==o.document||!BS(s(),a.document.comments?.items[t]))return a;const i=function(e,t,n){const o=e.document.comments,r=o?.items[t];return o&&r&&Boolean(r.resolved)!==n?{...e,document:{...e.document,comments:{...o,items:{...o.items,[t]:{...r,resolved:n}}}}}:e}(a,t,n);return r=i.document!==a.document,r?v(a,i,n?"comment-resolved":"comment-reopened",t):i}),r};return{draft:t,lastAuthor:o,panelOpen:a,togglePanel:()=>(i(!a()),!0),closePanel:()=>{i(!1)},canCreate:u,canReply:g,canReplyId:p,canEdit:m,canEditId:f,canDeleteId:h,canDeleteSelected:()=>{const t=dw(e.state());return null!==t&&h(t.id)},deleteSelected:()=>{const t=dw(e.state());return!!t&&C(t.id)},deleteById:C,canResolveId:b,canResolveSelected:()=>{const t=dw(e.state());return null!==t&&b(t.id)},resolveSelected:t=>{const n=dw(e.state());return!!n&&I(n.id,t)},resolveById:I,authorName:()=>c()?.displayName??o(),authorLocked:()=>void 0!==s(),openNew:()=>!!u()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!g())return!1;const t=dw(e.state());return!!t&&x(t.id)},openReplyToId:x,openEdit:()=>{if(!m())return!1;const t=dw(e.state());return!!t&&w(t.id)},openEditToId:w,close:S,submit:(n,o)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!f(a.commentId))return!1;if("edit"!==a.mode&&!d())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":c()?.displayName??n.trim(),u=o.trim();if(!i||!u||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===u)return S(),!0;const p="edit"===a.mode?null:{id:no("comment"),author:i,...c()?{authorId:c().id}:{},text:u,date:Date.now()};let g=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!BS(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!d())return t;const n="edit"===a.mode?P(t,a.commentId,u):"reply"===a.mode?l(t,a.parentId,p):Do({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},p);return g=n.document!==t.document,g?v(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:p.id,i,"reply"===a.mode?a.parentId:void 0):n}),g&&("edit"!==a.mode&&r(i),S()),g}}}var FS=/*#__PURE__*/f("<div class=oasis-review-comments-filters role=group>"),OS=/*#__PURE__*/f("<div class=oasis-review-comments-list>"),DS=/*#__PURE__*/f("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),ES=/*#__PURE__*/f("<div role=region class=oasis-review-comments-panel data-testid=review-comments-panel><div class=oasis-review-comments-heading></div><div class=oasis-review-mode-switch role=group>"),LS=/*#__PURE__*/f("<div class=oasis-review-thread-replies>"),NS=/*#__PURE__*/f("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),$S=/*#__PURE__*/f("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),zS=/*#__PURE__*/f("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function HS(e){const t=R(),[n,o]=an("all"),[r,a]=an(!1),[i,l]=an(""),[s,c]=an(null),[d,u]=an(null),p=()=>e.state().document.comments,g=vr(()=>{const e=p();if(!e)return[];const t=i().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(o=>("open"!==n()||!o.resolved)&&(!("resolved"===n()&&!o.resolved)&&(!t||[o,...D(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),f=e=>D(p()?.items??{},e),m=vr(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),h=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",b=t=>{d()===t?e.composer.deleteById(t)&&(u(null),s()===t&&c(null)):u(t)};return y=ES(),v=y.firstChild,x=v.nextSibling,We(v,X(ia,{as:"strong",get children(){return t("review.commentsPanel")}}),null),We(v,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),We(x,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),We(x,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return r()},onClick:()=>{a(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),We(y,X(ia,{as:"p",get children(){return et(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${p()?.order.length??0}`}}),null),We(y,X(po,{get label(){return et(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),We(y,X(Ft,{get when(){return!r()},get children(){return[(a=FS(),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),fe(()=>le(a,"aria-label",t("review.filterComments"))),a),(r=OS(),We(r,X(Ft,{get when(){return 0===g().length},get children(){return X(ia,{as:"p",get children(){return t("review.noComments")}})}}),null),We(r,X(ee,{get each(){return g()},children:n=>{return o=NS(),r=o.firstChild,a=r.nextSibling,We(r,X(ia,{as:"strong",get children(){return n.author||"—"}}),null),We(r,X(ia,{as:"span",get children(){return et(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),We(o,X(ia,{as:"p",get children(){return n.text}}),a),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),We(a,X(Ft,{get when(){return e.composer.canEditId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canResolveId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return et(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canReplyId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),We(a,X(Ft,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[X(Qe,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-comment-delete",get children(){return et(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),X(Ft,{get when(){return d()===n.id},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),We(o,X(Ft,{get when(){return f(n.id).length>0},get children(){return X(Qe,{size:"sm",variant:"ghost",get"aria-expanded"(){return s()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{c(s()===n.id?null:n.id)},get children(){return et(()=>s()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${f(n.id).length})`}})}}),null),We(o,X(Ft,{get when(){return s()===n.id},get children(){var o=LS();return We(o,X(ee,{get each(){return f(n.id)},children:n=>{return o=$S(),r=o.firstChild,We(o,X(ia,{as:"strong",get children(){return n.author||"—"}}),r),We(o,X(ia,{as:"p",get children(){return n.text}}),r),We(r,X(Ft,{get when(){return e.composer.canEditId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),We(r,X(Ft,{get when(){return e.composer.canReplyId(n.id)},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),We(r,X(Ft,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[X(Qe,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-reply-delete",get children(){return et(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),X(Ft,{get when(){return d()===n.id},get children(){return X(Qe,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),We(y,X(Ft,{get when(){return r()},get children(){var n=DS();return We(n,X(Ft,{get when(){return 0===m().length},get children(){return X(ia,{as:"p",get children(){return t("review.activity.empty")}})}}),null),We(n,X(ee,{get each(){return m()},children:n=>{return o=zS(),r=o.firstChild,We(r,X(ia,{as:"strong",get children(){return n.actorName}}),null),We(r,X(ia,{as:"span",get children(){return h(n.timestamp)}}),null),We(o,X(ia,{as:"p",get children(){return[et(()=>(e=>{switch(e){case"comment-created":return t("review.activity.created");case"comment-replied":return t("review.activity.replied");case"comment-edited":return t("review.activity.edited");case"comment-resolved":return t("review.activity.resolved");case"comment-reopened":return t("review.activity.reopened");case"comment-deleted":return t("review.activity.deleted")}})(n.kind))," — ",et(()=>n.targetAuthor),et(()=>et(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),We(o,X(Ft,{get when(){return Boolean(p()?.items[n.commentId])},get children(){return X(Qe,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),fe(()=>le(o,"data-activity-kind",n.kind)),o;var o,r}}),null),fe(()=>le(n,"aria-label",t("review.activity.title"))),n}}),null),fe(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&le(y,"aria-label",e.e=n),o!==e.t&&le(x,"aria-label",e.t=o),e},{e:void 0,t:void 0}),y;var y,v,x}var WS=/*#__PURE__*/f("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),US=/*#__PURE__*/f("<div class=oasis-review-revision-footer>"),jS=/*#__PURE__*/f('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),VS=/*#__PURE__*/f("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function KS(e,t){const n=Kr(e),o=[];for(const a of n)for(const e of a.runs)e.revision?.id===t&&o.push(e.text);const r=o.join("").trim();return r.length>96?`${r.slice(0,93)}…`:r}function _S(e){const t=R(),n=vr(()=>{const t=e.state(),n=Kr(t),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(const e of n)for(const t of e.runs){const e=t.revision;e&&(o.has(e.id)||o.set(e.id,e.author),r.has(e.id)||r.set(e.id,{date:e.date,type:e.type}))}return iw(t).map(e=>{const n=r.get(e.id);return{id:e.id,type:n?.type??"insert",author:o.get(e.id)??"—",date:n?.date,snippet:KS(t,e.id)}})}),o=vr(()=>{const t=e.state();return n().filter(e=>Wb(t,e.type,e.author))});return r=jS(),a=r.firstChild,We(a,X(ia,{as:"strong",get children(){return t("review.reviewingPane")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),We(r,X(ia,{as:"p",get children(){return[et(()=>t("review.revisionCount")),": ",et(()=>o().length)]}}),null),We(r,X(Ft,{get when(){return n().length-o().length>0},get children(){return X(ia,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),We(r,X(Ft,{get when(){return o().length>0},get fallback(){return X(ia,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=WS();return We(n,X(ee,{get each(){return o()},children:n=>{return o=VS(),r=o.firstChild,a=r.nextSibling,We(r,X(ia,{as:"span",get class(){return"oasis-review-revision-type "+("delete"===n.type?"review-revisions-icon-delete":"review-revisions-icon-insert")},get"data-revision-type"(){return n.type},get children(){return[X(Qr,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),X(ia,{as:"span",get children(){return e=n.type,t("insert"===e||"delete"===e?"insert"===e?"review.revisionInsert":"review.revisionDelete":"review.revisionProperty");var e}})]}}),null),We(r,X(ia,{as:"p",get children(){return n.snippet||"—"}}),null),We(r,X(ia,{as:"span",get children(){return n.author}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),We(a,X(Qe,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),fe(()=>le(o,"data-comment-id",n.id)),o;var o,r,a}})),n}}),null),We(r,X(Ft,{get when(){return o().length>0},get children(){var n=US();return We(n,X(Qe,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),We(n,X(Qe,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),fe(()=>le(r,"aria-label",t("review.reviewingPane"))),r;var r,a}var XS=/*#__PURE__*/f('<div class="oasis-editor-shell oasis-editor-app">');function GS(e={}){const t=e.runtime?.client??Je(),[n,r]=an({}),a=()=>({...e.ui??{},...n(),toolbar:{...e.ui?.toolbar??{},...n().toolbar??{}}}),i=()=>({...e.document??{},...void 0===n().readOnly?{}:{readOnly:n().readOnly}}),l=()=>({...a(),readOnly:i().readOnly}),s=e=>(r(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...l(),...e}),c=()=>e.runtime??{};Ei();const d=Ge(()=>a().locale??"pt-BR"),u=k("app"),{state:p,commitState:f,getStateSnapshot:m}=function(e){const t=e.initialState?kn(e.initialState):e.initialDocument?wo(e.initialDocument):wn();let n=t;const[o,r]=an(t);return{state:new Proxy({},{get(e,t){const n=o();if(null!==n&&("object"==typeof n||"function"==typeof n))return Reflect.get(n,t)},has(e,t){const n=o();return null!==n&&("object"==typeof n||"function"==typeof n)&&Reflect.has(n,t)},ownKeys(e){const t=o();return null===t||"object"!=typeof t&&"function"!=typeof t?[]:Reflect.ownKeys(t)},getOwnPropertyDescriptor(e,t){const n=o();return null===n||"object"!=typeof n&&"function"!=typeof n?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(n,t),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:e=>{const t=pa(e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:i().initialDocument,initialState:i().initialState}),h=e=>{f(e)},b=kn;let y=!1;const{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:S,showOutline:I,toggleOutline:T,toolbarView:P,toolbarLayout:R,isReadOnly:B,useComposedShell:A,loadingOptions:M,loadingLabel:F,shellComponent:D}=function(e){const{ui:t,documentOptions:n,updateUiState:o,state:r}=e,a=()=>{const e=t().loading;return"object"==typeof e&&null!==e?e:void 0};return{showChrome:()=>t().showChrome??!0,showTitleBar:()=>t().showTitleBar??!0,showMenubar:()=>t().showMenubar??!0,showToolbar:()=>t().showToolbar??!0,showOutline:()=>t().showOutline??!0,toggleOutline:()=>{o({showOutline:!(t().showOutline??!0)})},toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>(n().readOnly??!1)||"all"!==(r().reviewDisplayMode??"all"),useComposedShell:()=>"docs"===t().uiVariant||"document"!==(t().shell??"document"),loadingOptions:a,loadingLabel:()=>a()?.label??"Loading oasis-editor...",shellComponent:()=>{const e=t().shell??"document";return"inline"===e?oa:"balloon"===e?C:Pt}}}({ui:a,documentOptions:i,updateUiState:s,state:()=>p}),L=function(){const[e,t]=an(!1);let n,o,r,a,i;return{focused:e,setFocused:t,focusInput:()=>{t(!0),queueMicrotask(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{t(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},focusInputSync:()=>{t(!0),r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)},get viewportRef(){return n},set viewportRef(e){n=e},get surfaceRef(){return o},set surfaceRef(e){o=e},get textareaRef(){return r},set textareaRef(e){r=e},get importInputRef(){return a},set importInputRef(e){a=e},get imageInputRef(){return i},set imageInputRef(e){i=e}}}(),N=L.focused,$=L.setFocused,z=L.focusInput,H=L.focusInputAfterPointerSelection,W=L.focusInputSync,[U,j]=an(!1!==a().loading),V=ce(),{linkDialog:K,setLinkDialog:_,imageAltDialog:G,setImageAltDialog:q,imageCaptionDialog:Y,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:se,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:pe,symbolDialog:ge,setSymbolDialog:me,equationDialog:he,setEquationDialog:be}=function(){const[e,t]=an({isOpen:!1}),[n,o]=an({isOpen:!1}),[r,a]=an({isOpen:!1}),[i,l]=an({isOpen:!1,initialHref:""}),[s,c]=an({isOpen:!1,initialAlt:""}),[d,u]=an({isOpen:!1,initialCaption:""}),[p,g]=an({isOpen:!1,x:0,y:0}),[f,m]=an({isOpen:!1,initial:{fontFamily:"",fontSize:"",color:"",colorMode:"automatic",highlight:"",shading:"",bold:!1,italic:!1,underline:!1,underlineStyle:null,underlineColor:"",strike:!1,doubleStrike:!1,superscript:!1,subscript:!1,smallCaps:!1,allCaps:!1,hidden:!1,characterScale:"",characterSpacing:"",baselineShift:"",kerningThreshold:"",ligatures:"",numberSpacing:"",numberForm:"",stylisticSet:"",contextualAlternates:!1}}),[h,b]=an({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",mirrorIndents:!1,spacingBefore:"",spacingAfter:"",lineHeight:"",lineRule:"",contextualSpacing:!1,outlineLevel:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1,pageBreakBefore:!1,keepWithNext:!1,keepLinesTogether:!1,widowControl:!0,tabs:[]}}),[y,v]=an({isOpen:!1,action:"accept",count:0}),[x,w]=an({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""}});return{newDocumentDialog:e,setNewDocumentDialog:t,symbolDialog:n,setSymbolDialog:o,equationDialog:r,setEquationDialog:a,linkDialog:i,setLinkDialog:l,imageAltDialog:s,setImageAltDialog:c,imageCaptionDialog:d,setImageCaptionDialog:u,contextMenu:p,setContextMenu:g,fontDialog:f,setFontDialog:m,paragraphDialog:h,setParagraphDialog:b,tablePropertiesDialog:x,setTablePropertiesDialog:w,revisionBulkDialog:y,setRevisionBulkDialog:v}}(),[ye,ve]=an(!1),xe=()=>L.viewportRef,we=()=>L.surfaceRef,Se=ry({documentOptions:i,logger:u,runtimeClient:t,state:p,commitState:f,getStateSnapshot:m,applyState:h,cloneState:b,isReadOnly:B,focusInput:z,surfaceRef:we,viewportRef:xe,zoomFactor:V.zoomFactor,getImageOps:()=>Xe.imageOps}),{docIO:Ce,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,canvasSnapshotProvider:Pe,inputBox:Be,selectionBoxes:Ae,commentHighlights:Me,revisionMarkupBoxes:Fe,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Ee,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,clearPreferredColumn:ze,onCleanupHook:He,persistenceStatus:Ue,applyTransactionalState:je,resetTransactionGrouping:Ve,updateHistoryState:Ke}=Se,_e=li({state:()=>p,isReadOnly:B,applyTransactionalState:je,applyTableAwareParagraphEdit:(e,t)=>Xe.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:ze,resetTransactionGrouping:Ve,focusInput:z}),Xe=ix({clipboardActions:_e,state:p,logger:u,isReadOnly:B,applyState:h,cloneState:b,focusInput:z,focusInputAfterPointerSelection:H,focusInputSync:W,surfaceRef:we,viewportRef:xe,zoomFactor:V.zoomFactor,insertImageFromFile:Ce.insertImageFromFile,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},getCommandsController:()=>Rt.commandsController,applyTransactionalState:je,clearPreferredColumn:ze,resetTransactionGrouping:Ve,updateHistoryState:Ke,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,canvasSnapshotProvider:Pe,openEquationDialog:(e,t)=>{be({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:qe,fr:Ye,tableOps:Ze,imageOps:Qe,textBoxOps:tt,styleController:nt,onEditorPointerDown:ot,tableResize:rt,tableCornerResize:at,tableDrag:it,revisionController:lt,textDrag:st,surfaceEventsWithTextDrag:ct,textInput:dt,handleCopy:pt,handleCut:gt,handlePaste:ft,handleDrop:mt}=Xe,[ht,bt]=an(!1),[yt,vt]=an(0),xt=function(){const[e,t]=an(!1);return{open:()=>e(),toggle:()=>(t(e=>!e),!0),close:()=>{t(!1)}}}(),wt=Ri(Bi),It=e=>{p.selection.anchor.offset;try{return!1!==Ot().commands.canExecute(e)}catch{return!1}},Tt=e=>{try{Ot().commands.execute(e)}catch(t){u.error("quick-access execute failed",t)}},kt=MS({state:()=>p,isReadOnly:B,applyTransactionalState:je,focusInput:z,access:()=>c().review}),Rt=kS({onExecutedTap:()=>{vt(e=>e+1)},commandSearch:{isOpen:ht,setIsOpen:e=>{bt(e)}},setCommandSearchOpen:bt,clipboardActions:_e,document:Se,interaction:Xe,commentComposer:kt,state:p,logger:u,isReadOnly:B,focusInput:z,applyState:h,getStateSnapshot:m,cloneState:b,setFocused:$,setInitialLoading:j,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},locale:()=>a().locale??"pt-BR",translator:d,runtimeClient:t,runtimeOptions:c,documentOptions:i,getUiState:l,updateUiState:s,zoom:V,importInputRef:()=>L.importInputRef,imageInputRef:()=>L.imageInputRef,setLinkDialog:_,setImageAltDialog:q,setImageCaptionDialog:J,setNewDocumentDialog:pe,setSymbolDialog:me,setEquationDialog:be,setTablePropertiesDialog:ie,setFontDialog:ne,setParagraphDialog:re,setRevisionBulkDialog:de,toggleOutline:T,isOutlineVisible:I,toggleRevisionsPanel:()=>{xt.toggle()},revisionsPanelVisible:xt.open}),{commandsController:Bt,runtimeReady:At,runtimeEditor:Ot,toolbarHost:Dt,toolbarRegistry:Et,menuRegistry:Lt,handleKeyDown:Nt}=Rt,$t=()=>function(e,t,n){const o=[],r=/* @__PURE__ */new Set;for(const a of e){if("hidden"in a&&!0===a.hidden)continue;const e=xi(a);if(!e)continue;const t=a.label;if("string"!=typeof t||!t.trim())continue;if(r.has(e.command))continue;r.add(e.command);const n={id:a.id,label:t,command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"ribbon"};o.push(n)}for(const a of t){if(!0===a.hidden)continue;const e=vi(a.command);if(!e)continue;if(r.has(e.command))continue;r.add(e.command);const t=a.labelKey?n(a.labelKey):a.id;o.push({id:a.id,label:String(t),command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"menubar",...a.shortcut?{shortcut:a.shortcut}:{}})}return o}(Et.getOrdered(),Lt.getItems(),d),zt=e=>{try{return!1!==Ot().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:Ht,computeFontSizeOptions:Wt,applyFontDialogValues:Ut,applyParagraphDialogValues:jt,setParagraphDialogDefault:Vt,applyTablePropertiesDialogValues:Kt,buildContextMenuItems:_t,handleEditorContextMenu:Xt,closeContextMenu:Gt}=vc({clipboardActions:_e,state:()=>p,selection:()=>p.selection,toolbarStyleState:nt.toolbarStyleState,isReadOnly:B,t:d,logger:u,setFontDialog:ne,setParagraphDialog:re,setTablePropertiesDialog:ie,setContextMenu:ee,clearPreferredColumn:ze,resetTransactionGrouping:Ve,applyTransactionalState:je,applyTableAwareParagraphEdit:Ze.applyTableAwareParagraphEdit,focusInput:z,promptForLink:Bt.promptForLink,tableOps:Ze}),{layout:qt,overlays:Yt,refs:Zt,surfaceHandlers:Jt,inputHandlers:en,fileHandlers:tn}=function(e){const{layout:t,overlays:n,refs:o,surface:r,input:a,files:i}=e;return{layout:{documentLayout:t.documentLayout,remoteWebFonts:t.remoteWebFonts,viewportHeight:t.viewportHeight,class:t.className,style:t.style,zoomPercent:t.zoomPercent,setZoomPercent:t.setZoomPercent,zoomFactor:t.zoomFactor},overlays:{selectionBoxes:n.selectionBoxes,commentHighlights:n.commentHighlights,revisionMarkupBoxes:n.revisionMarkupBoxes,onReplyToComment:n.onReplyToComment,onEditComment:n.onEditComment,canEditComment:n.canEditComment,canReplyComment:n.canReplyComment,selectedImageBox:n.selectedImageBox,selectedTextBoxBox:n.selectedTextBoxBox,selectedTableBox:n.selectedTableBox,layoutOptions:n.layoutOptions,caretBox:n.caretBox,inputBox:n.inputBox,hoveredRevision:n.hoveredRevision,focused:n.focused,showCaret:n.showCaret,importProgress:n.importProgress,imageCropMode:n.imageCropMode},refs:{onViewportRef:e=>{o.focusController.viewportRef=e},onSurfaceRef:e=>{o.focusController.surfaceRef=e},onTextareaRef:e=>{o.focusController.textareaRef=e},onImportInputRef:e=>{o.focusController.importInputRef=e},onImageInputRef:e=>{o.focusController.imageInputRef=e}},surfaceHandlers:{onDragOver:e=>e.preventDefault(),onDrop:r.handleDrop,onEditorPointerDown:r.onEditorPointerDown,onSurfacePointerDown:r.surfaceEvents.handleSurfacePointerDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfacePointerMove:r.tableResize.handlePointerMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphPointerDown:r.surfaceEvents.handleParagraphPointerDown,onImagePointerDown:r.handleImagePointerDown,onImageResizeHandlePointerDown:r.handleImageResizeHandlePointerDown,onTextBoxResizeHandlePointerDown:r.handleTextBoxResizeHandlePointerDown,onImageRotateHandlePointerDown:r.handleImageRotateHandlePointerDown,onImageCropHandlePointerDown:r.handleImageCropHandlePointerDown,onImageCropBodyPointerDown:r.handleImageCropBodyPointerDown,onTextBoxRotateHandlePointerDown:r.handleTextBoxRotateHandlePointerDown,onTableDragHandlePointerDown:r.tableDrag.handlePointerDown,onTableCornerResizeHandlePointerDown:r.tableCornerResize.handlePointerDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:e=>r.handleEditorContextMenu(e)},inputHandlers:{onInputBlur:()=>a.setFocused(!1),onInputFocus:()=>a.setFocused(!0),onCompositionEnd:a.textInput.handleCompositionEnd,onCompositionStart:a.textInput.handleCompositionStart,onCompositionUpdate:a.textInput.handleCompositionUpdate,onCopy:a.handleCopy,onCut:a.handleCut,onInput:a.textInput.handleTextInput,onKeyDown:a.handleKeyDown,onKeyUp:a.handleKeyUp,onPaste:a.handlePaste},fileHandlers:{onImportInputChange:e=>i.handleImportFile(e.currentTarget.files?.[0]??null),onImageInputChange:e=>i.handleInsertImage(e.currentTarget.files?.[0]??null)}}}({layout:{documentLayout:ke,remoteWebFonts:i().remoteWebFonts,viewportHeight:a().viewportHeight,className:a().class,style:a().style,zoomPercent:V.zoomPercent,setZoomPercent:V.setZoomPercent,zoomFactor:V.zoomFactor},overlays:{selectionBoxes:Ae,commentHighlights:Me,revisionMarkupBoxes:Fe,onReplyToComment:e=>{kt.openReplyToId(e)},onEditComment:e=>{kt.openEditToId(e)},canEditComment:kt.canEditId,canReplyComment:kt.canReplyId,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Ee,layoutOptions:qe,caretBox:Le,inputBox:Be,hoveredRevision:lt.hoveredRevision,focused:N,showCaret:()=>function(e,t){if(!t.visible||!zr(e.selection))return!1;const n=fo(e),o=St(e.document,e.selection.anchor.paragraphId,n),r=St(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(p,Le()),importProgress:Ce.importProgress,imageCropMode:Qe.cropMode},refs:{focusController:L},files:{handleImportFile:Ce.handleImportFile,handleInsertImage:Ce.handleInsertImage},surface:{surfaceEvents:ct,tableResize:rt,tableCornerResize:at,tableDrag:it,revisionController:lt,handleDrop:mt,onEditorPointerDown:ot,handleImagePointerDown:Qe.handleImagePointerDown,handleImageResizeHandlePointerDown:Qe.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:tt.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Qe.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Qe.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Qe.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:tt.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:Xt},input:{textInput:dt,setFocused:$,handleCopy:pt,handleCut:gt,handlePaste:ft,handleKeyDown:e=>{if("Escape"===e.key&&Xe.formatPainter.mode())return Xe.formatPainter.cancel(),void e.preventDefault();Nt(e)},handleKeyUp:e=>{Xe.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Xe.formatPainter.applyToSelection("keyboard")}}});return Zn(()=>{Ct(),ha(),Xo(),qr(()=>we()??null),ut(),!Mt()&&g()&&ve(!0)}),o(()=>{He(),ct.stopDragging(),st.stopDrag(),rt.stop(),at.stop(),it.stop(),Qe.stopImageDrag(),Qe.stopImageResize(),Qe.stopImageCrop(),tt.stopTextBoxResize(),O()}),X(E,{translator:d,get children(){var e=XS();return Re(e,"--oasis-editor-gutter-x","34px"),We(e,X(Ft,{get when(){return et(()=>!(A()||!v()))()&&S()},get children(){return X(Qt,{host:Dt,registry:Et,get view(){return P()},get layout(){return R()}})}}),null),We(e,X(di,{get notice(){return _e.notice},onDismiss:()=>{_e.dismiss(),z()}}),null),We(e,X(Ft,{get when(){return kt.panelOpen()},get children(){return X(HS,{state:()=>p,composer:kt,locale:()=>a().locale??"pt-BR",get onClose(){return kt.closePanel},onNavigate:e=>{const t=function(e,t){const n=e.document.comments?.items;if(!n?.[t])return e;let o=n[t];const r=/* @__PURE__ */new Set;for(;o&&!o.start&&o.parentId&&!r.has(o.id);)r.add(o.id),o=n[o.parentId];const a=o?.start,i=o?.end;if(!a||!i)return e;const l=Kr(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:Z(s,a.offset),focus:Z(c,i.offset)}}:e}(p,e);t!==p&&(h(t),z())}})}}),null),We(e,X(Ft,{get when(){return xt.open()},get children(){return X(_S,{state:()=>p,get onClose(){return xt.close},onNavigate:e=>{const t=uw(p,e);t!==p&&(h(t),z())},onAccept:e=>{const t=uw(p,e);t!==p&&(h(t),Bt.applyAcceptRevisionsCommand(),z())},onReject:e=>{const t=uw(p,e);t!==p&&(h(t),Bt.applyRejectRevisionsCommand(),z())},onAcceptAll:()=>Ot().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>Ot().commands.execute("requestRejectAllRevisions")})}}),null),We(e,X(yi,{get isOpen(){return ht()},get entries(){return $t()},isEnabled:zt,onExecute:e=>{Ot().commands.execute(e.command,e.payload),bt(!1),z()},onClose:()=>{bt(!1),z()}}),null),We(e,X(Qd,{commentComposer:kt,dialogs:{linkDialog:K,setLinkDialog:_,imageAltDialog:G,setImageAltDialog:q,imageCaptionDialog:Y,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:se,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:pe,symbolDialog:ge,setSymbolDialog:me,equationDialog:he,setEquationDialog:be},findReplace:Ye,fontFamilyOptions:Ht,fontSizeOptions:Wt,contextMenuItems:_t,focusInput:z,get applyLinkCommand(){return Bt.applyLinkCommand},get applyImageAltCommand(){return Bt.applyImageAltCommand},get applyImageCaptionCommand(){return Bt.applyImageCaptionCommand},applyFontDialogValues:Ut,applyParagraphDialogValues:jt,setParagraphDialogDefault:Vt,applyTablePropertiesDialogValues:Kt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{Ot().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),z()},insertSymbol:(e,t)=>{Ot().commands.execute("insertText",{text:e,fontFamily:t}),z()},applyEquation:(e,t)=>{t?Ot().commands.execute("updateEquation",{runId:t,expression:e}):Ot().commands.execute("insertEquation",e),z()},closeContextMenu:Gt}),null),We(e,X(Ft,{get when(){return S()},get children(){return X(Ti,{catalog:Bi,get visible(){return wt.visible},get onToggle(){return wt.toggle},onExecute:Tt,canExecute:It,tick:yt,onOpenCommandSearch:()=>{bt(!0)}})}}),null),We(e,X(tu,{useComposedShell:A,shellComponent:D,runtime:{state:()=>p,toolbarHost:Dt,runtimeEditor:Ot,persistenceStatus:Ue,toolbarRegistry:Et,menuRegistry:Lt},chrome:{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:S,showOutline:I,toolbarView:P,toolbarLayout:R},view:{isReadOnly:B,viewportHeight:()=>a().viewportHeight,measuredBlockHeights:Ie,measuredParagraphLayouts:Te,documentLayout:ke,layout:qt,overlays:Yt,refs:Zt,surfaceHandlers:Jt,inputHandlers:en,fileHandlers:tn}}),null),We(e,X(Tc,{state:p,get surfaceRef(){return we()},documentLayout:ke,snapshotProvider:Pe,get zoomFactor(){return V.zoomFactor},tableResize:rt,tableCornerResize:at,imageOps:Qe,tableDrag:it,textDrag:st}),null),We(e,X(Ft,{get when(){return U()||!At()},get children(){return X(ta,{get label(){return F()},get class(){return M()?.class},get style(){return M()?.style}})}}),null),We(e,X(ou,{get isOpen(){return et(()=>!(!ye()||U()))()&&At()},onClose:()=>ve(!1)}),null),fe(t=>{var n=a().theme??"light",o=!!A(),r=!!B(),i=!(null===Xe.formatPainter.mode());return n!==t.e&&le(e,"data-theme",t.e=n),o!==t.t&&e.classList.toggle("oasis-editor-docs",t.t=o),r!==t.a&&e.classList.toggle("oasis-editor-read-only",t.a=r),i!==t.o&&e.classList.toggle("oasis-editor-format-painter-active",t.o=i),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e}})}export{GS as OasisEditorApp};
|