oasis-editor 0.0.339 → 0.0.340
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-DYRgjg6k.js +1 -0
- package/dist/defaultToolbar-DPGP5xau.js +1 -0
- package/dist/i18n/locales/en.d.ts +18 -0
- package/dist/i18n/locales/pt-BR.d.ts +18 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/ui/components/Toolbar/DesignGallery.d.ts +1 -4
- package/dist/ui/components/Toolbar/WatermarkGallery.d.ts +6 -0
- package/package.json +1 -1
- package/dist/OasisEditorApp-CFbYoJq4.js +0 -1
- package/dist/defaultToolbar-CA8oi_M8.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,$a as t,$n as n,$r 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,Br as f,Bt as m,C as h,Ca as b,Ci as y,Cn as v,Co as x,Cr as w,Ct as S,D as I,Da as C,Di as T,Dn as k,Do as P,Dr as R,Dt as B,E as M,Ea as A,Ei as F,En as O,Eo as D,Er as E,Et as L,F as N,Fa as $,Fi as z,Fn as H,Fo as W,Fr as U,Ft as j,G as V,Ga as K,Gi as _,Gn as G,Go as X,Gr as Y,Gt as q,H as Z,Ha as J,Hi as Q,Hn as ee,Ho as te,Hr as ne,Ht as oe,I as re,Ia 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 Ie,L as Ce,La as Te,Li as ke,Ln as Pe,Lr as Re,Lt as Be,M as Me,Ma as Ae,Mi as Fe,Mn as Oe,Mo as De,Mr as Ee,N as Le,Na as Ne,Ni as $e,Nn as ze,No as He,Nr as We,Nt as Ue,O as je,Oa as Ve,Oi as Ke,On as _e,Oo as Ge,Or as Xe,P as Ye,Pa as qe,Pi as Ze,Pn as Je,Po as Qe,Pr as et,Pt as tt,Q as nt,Qa as ot,Qn as rt,Qo as at,Qt as it,R as lt,Ra as st,Ri as ct,Rn as dt,Ro 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 It,Tn as Ct,To as Tt,Tr as kt,Tt as Pt,U as Rt,Ua as Bt,Ui as Mt,Un as At,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 Gt,Wt as Xt,X as Yt,Xa as qt,Xi as Zt,Xn as Jt,Xo as Qt,Xr as en,Xt as tn,Y as nn,Ya as on,Yi as rn,Yn as an,Yo as ln,Yr as sn,Yt as cn,Z as dn,Za as un,Zn as pn,Zo as gn,Zr as fn,Zt as mn,_ as hn,_a as bn,_i as yn,_n as vn,_o as xn,_r as wn,_t as Sn,a as In,aa as Cn,ai as Tn,an as kn,ao as Pn,ar as Rn,at as Bn,b as Mn,ba as An,bi as Fn,bn as On,bo as Dn,br as En,bt as Ln,c as Nn,ca as $n,cn as zn,co as Hn,cr as Wn,ct as Un,d as jn,da as Vn,dn as Kn,do as _n,dr as Gn,dt as Xn,en as Yn,eo as qn,er as Zn,es as Jn,et as Qn,f as eo,fa as to,fn as no,fo as oo,fr as ro,ft as ao,g as io,ga as lo,gi as so,gn as co,go as uo,gr as po,gt as go,h as fo,ha as mo,hi as ho,hn as bo,ho as yo,hr as vo,ht as xo,i as wo,ii as So,in as Io,io as Co,ir as To,is as ko,it as Po,j as Ro,ja as Bo,jn as Mo,jr as Ao,k as Fo,ka as Oo,ki as Do,kn as Eo,ko as Lo,kr as No,l as $o,la as zo,ln as Ho,lo as Wo,lr as Uo,lt as jo,m as Vo,ma as Ko,mn as _o,mo as Go,mr as Xo,mt as Yo,n as qo,nn as Zo,no as Jo,nr as Qo,ns as er,nt as tr,o as nr,oa as or,oi as rr,on as ar,oo as ir,or as lr,ot as sr,p as cr,pa 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 Ir,ro as Cr,rr as Tr,s as kr,sa as Pr,sn as Rr,so as Br,sr as Mr,st as Ar,t as Fr,tn as Or,to as Dr,tr as Er,ts 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 Gr,vo as Xr,vr as Yr,vt as qr,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 Ia,zt as Ca}from"./defaultToolbar-CA8oi_M8.js";function Ta(e,t){return{document:e.document,selection:t}}function ka(e,t){if(!Vn(e.selection))return Ro(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=Le(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,re(Bt(i,Math.min(r,Lt(i)))))}function Pa(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=Le(e),i=Lt(o);if(t<0&&a>0)return Ta(e,{anchor:e.selection.anchor,focus:Bt(o,a-1)});if(t>0&&a<i)return Ta(e,{anchor:e.selection.anchor,focus:Bt(o,a+1)});if(t<0&&r>0){const t=n[r-1];return Ta(e,{anchor:e.selection.anchor,focus:Bt(t,Lt(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return Ta(e,{anchor:e.selection.anchor,focus:Bt(t,0)})}return e}function Ra(e,t){const{paragraphs:n,index:o,offset:r}=Le(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ta(e,{anchor:e.selection.anchor,focus:Bt(i,Math.min(r,Lt(i)))})}function Ba(e){const t=to(e);if(t.isCollapsed)return"";const n=pa(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return J(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(J(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(J(n[i]));return o.push(J(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Ma(e,t){return{...e,selection:{anchor:Pr(e,t.anchor),focus:Pr(e,t.focus)}}}function Aa(e){if(!Vn(e.selection))return Ro(e,"start");const{paragraph:t,index:n,offset:o}=Le(e),r=pa(e);if(o>0)return{document:e.document,selection:re(Bt(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:re(Bt(a,Lt(a)))}}function Fa(e){if(!Vn(e.selection))return Ro(e,"end");const{paragraph:t,index:n,offset:o}=Le(e),r=pa(e);if(o<Lt(t))return{document:e.document,selection:re(Bt(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:re(Bt(a,0))}}function Oa(e){const t=to(e);if(t.isCollapsed)return"";const n=pa(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:Lt(l),d=Rt(l,s,c),u=ct(l.style),p=u.length>0?` style="${u}"`:"",g=ke(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${p}>${g}</li>`);continue}a(),o.push(`<p${p}>${g}</p>`)}return a(),o.join("")}function Da(e,t){if(0===t.length)return e;const n=Vn(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Le(n),l=pa(n),s=Rt(o,0,i),c=Rt(o,i,Lt(o)),d=t.map(e=>{const t=uo(e.runs.map(e=>({text:e.text,styles:Zo(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 u,p=re(Bt(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(Yn),...c],Z(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,u=[...r(l.slice(0,a)),n,...r(l.slice(a+1))],p=re(Bt(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),g=Ut(o,[...s,...e.runs.map(Yn)],Z(o,i));g.style=o.style?{...o.style}:e.style?{...e.style}:void 0,g.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(mn),m=Ut(t,[...t.runs.map(Yn),...c],void 0);m.list=t.list?{...t.list}:void 0,u=[...r(l.slice(0,a)),g,...f,m,...r(l.slice(a+1))],p=re(Bt(m,n))}return Ce(n,u,p)}function Ea(e){return e.map(Yn)}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=pa(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=jt(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=Bt(t,i),u=Bt(t,i+s);return Ce(e,n,{anchor:c,focus:u})}const s=Rt(a,0,i),c=Rt(a,i,Lt(a)),u=n[n.length-1],p=n.slice(1,-1),g=Ut(mn(n[0].paragraphTemplate),[...s,...l],Z(a,i)),f=p.map(e=>Ut(mn(e.paragraphTemplate),Ea(e.runs))),m=Ut(mn(u.paragraphTemplate),[...Ea(u.runs),...c],Z(a,i)),h=[...o.slice(0,r),g,...f,m,...o.slice(r+1)],b=Bt(g,La(s)),y=Bt(m,La(u.runs));return Ce(e,h,{anchor:b,focus:y})}function $a(e,t,n={}){if(to(e).isCollapsed)return e;if(function(e,t){const n=to(e);if(n.isCollapsed)return!1;const o=pa(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=jt(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=to(e);if(t.isCollapsed)return[];const n=pa(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:Lt(e),l=Rt(e,a,i);o.push({paragraphTemplate:mn(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=to(e),o=pa(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=jt(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return Bt(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=Vn(e.selection)?e:Me(e),{paragraph:r,index:a,offset:i}=Le(o),l=n?{...n}:Z(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=pa(o).map((e,t)=>t===a?c:e);return Ce(o,u,re(Bt(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=Vn(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Le(r),s=o.split("\n"),c=n?{...n}:Z(a,l),d=Rt(a,0,l),u=Ut(a,[...d,Xr(s[0],c)],c),p=Rt(a,l,Lt(a)),g=s.slice(1,-1).map(e=>mr([{text:e,styles:c}])),f=mr([{text:s[s.length-1],styles:c},...p.map(e=>({text:e.text,styles:e.styles}))]),m=pa(r),h=[...m.slice(0,i),u,...g,f,...m.slice(i+1)];return Ce(r,h,re(Bt(f,s[s.length-1].length)))}function Ua(e){if(!Vn(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Le(e),r=pa(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,Lt(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ce(e,l,re(Bt(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()}},u=[...Rt(t,0,o-1),d,...Rt(t,o,Lt(t))],p=Ut(t,u),g=r.map((e,t)=>t===n?p:e);return Ce(e,g,re(Bt(p,o-1)))}}const a=Ut(t,[...Rt(t,0,o-1),...Rt(t,o,Lt(t))],Z(t,o-1)),i=r.map((e,t)=>t===n?a:e);return Ce(e,i,re(Bt(a,o-1)))}if(0===n)return e;const a=r[n-1],i=Ut(a,[...a.runs.map(Yn),...t.runs.map(Yn)]),l=[...r.slice(0,n-1),i,...r.slice(n+1)];return Ce(e,l,re(Bt(i,Lt(a))))}function ja(e){if(!Vn(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Le(e),r=pa(e);if(o<Lt(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,Lt(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ce(e,l,re(Bt(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()}},u=[...Rt(t,0,o),d,...Rt(t,o+1,Lt(t))],p=Ut(t,u),g=r.map((e,t)=>t===n?p:e);return Ce(e,g,re(Bt(p,o)))}}const a=Ut(t,[...Rt(t,0,o),...Rt(t,o+1,Lt(t))],Z(t,o)),i=r.map((e,t)=>t===n?a:e);return Ce(e,i,re(Bt(a,o)))}if(n>=r.length-1)return e;const a=r[n+1],i=Ut(t,[...t.runs.map(Yn),...a.runs.map(Yn)]),l=[...r.slice(0,n),i,...r.slice(n+2)];return Ce(e,l,re(Bt(i,o)))}function Va(e,t,n,o,r){let a=Ir(n,o,r);const i=st(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=to(e);if(n.isCollapsed)return e;const o=pa(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:Lt(t);return Rt(t,a,i).map(n=>({...n,styles:st(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:Lt(o);return Ye(o,i,l,n=>({...n,styles:Va(e,o,n.styles,t,a)}))});return Ce(e,i,N(i,n))}function _a(e,t,n){const o=to(e);if(o.isCollapsed)return e;const r=pa(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:Lt(e);return Ye(e,a,i,e=>({...e,styles:Io(e.styles,t,n)}))});return Ce(e,r,N(r,o))}function Ga(e,t){const n=to(e);if(n.isCollapsed)return e;const o=pa(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:Lt(e);return Ye(e,a,i,n=>{const o=(st(n.styles,e.style?.styleId,r).fontSize??14.6667)*Hn,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:Io(n.styles,"fontSize",a/Hn)}})});return Ce(e,a,N(a,n))}var Xa={width:.5,type:"solid",color:"#000000"};function Ya(e,t){const n={...e??{}};return t?n.textBorder=Xa:delete n.textBorder,Object.keys(n).length>0?n:void 0}function qa(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=qa(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&&qa(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=to(e);if(n.isCollapsed)return e;const o=pa(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:Lt(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 Ce(e,o,N(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=Zo(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=to(e),o=pa(e)[n.startIndex];if(!o)return t;const r=Z(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:ei(r,e.styles)})),style:Or(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:[Xr("")];n.push({runs:r.map(e=>{const t=Dr(e);return{text:e.text,styles:Zo(e.styles),image:t?{...t}:void 0}}),style:e?br(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,pe(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,[Xr(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=Zt(e.tagName);if(t){a(e,t);continue}if(rn(e.tagName)){r(e,pe(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=pe(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]=gn();let o,r=0;at()&&Lr(()=>{r++});const a=()=>{n(void 0),o=void 0},i=()=>{r++,a()},l=async(t,i="rich")=>{const l=++r;a();const s=e.state(),c=a=>{l===r&&(n({action:t,issue:a,..."paste"===t?{mode:i}:{}}),"access-denied"!==a&&"unsupported"!==a||("paste"!==t||"unsupported"===a&&"rich"!==i||(o={document:s.document,mode:i}),e.focusInput()),e.onIssue?.(a))};if("copy"===t)return ii(s,c);const d={...e,onIssue:c,isReadOnly:()=>l!==r||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,i)},s=()=>{const t=o;return i(),t?.document===e.state().document?t.mode:void 0};return{notice:t,dismiss:i,consumePasteMode:s,copy:()=>l("copy"),cut:()=>l("cut"),paste:(e="rich")=>l("paste",e),hasSelection:()=>Ba(e.state()).length>0}}(e)}var si=/*#__PURE__*/te("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),ci=/*#__PURE__*/te("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function di(e){const t=Lo();let n;const[o,r]=gn(12);fe(()=>{if(!e.notice())return;const t=n?.parentElement;if(!t)return;const o=()=>{const e=t.getBoundingClientRect(),o=t.querySelector(".oasis-editor-toolbar"),a=o?o.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),l=window.innerHeight-e.top-(n?.offsetHeight??0)-12;r(Math.max(i,Math.min(a,l)))};queueMicrotask(o);const a=new ResizeObserver(o);a.observe(t),n&&a.observe(n);const i=t.querySelector(".oasis-editor-toolbar");i&&a.observe(i),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),Lr(()=>{a.disconnect(),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)})});return a=si(),"function"==typeof n?Ft(n,a):n=a,W(a,vr(X,{get when(){return e.notice()},children:n=>{return o=ci(),W(o,vr(It,{name:"clipboard"}),null),W(o,vr(ht,{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),W(o,vr(B,{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}})),Qt(e=>Sa(a,"top",`${o()}px`)),a;var a}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__*/te("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),mi=/*#__PURE__*/te("<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__*/te("<kbd class=oasis-command-search-shortcut>"),bi=/*#__PURE__*/te("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function yi(e){const t=Lo(),[n,o]=gn(""),[r,a]=gn(0);let i;fe(()=>{e.isOpen&&(o(""),a(0),queueMicrotask(()=>{i?.focus()}))});const l=ln(()=>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));fe(()=>{l(),a(e=>Math.min(e,Math.max(0,l().length-1)))});const s=t=>e.isEnabled(t.command,t.payload),c=t=>{s(t)&&e.onExecute(t)},d=e=>{const t=l().length;0!==t&&a(n=>(n+e+t)%t)},u=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),d(1);break;case"ArrowUp":t.preventDefault(),d(-1);break;case"Enter":{t.preventDefault();const e=l()[r()];e&&c(e);break}case"Escape":t.preventDefault(),e.onClose()}};return vr(X,{get when(){return e.isOpen},get children(){var d=mi(),p=d.firstChild;return De(d,"click",e.onClose,!0),p.$$keydown=u,p.$$click=e=>e.stopPropagation(),W(p,vr(go,{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 le(()=>!!l()[r()])()?`editor-command-search-option-${r()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),W(p,vr(ht,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),W(p,vr(X,{get when(){return l().length>0},get fallback(){return vr(ht,{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 W(e,vr(_t,{get each(){return l()},children:(e,t)=>{const n=()=>t()===r(),o=()=>s(e);return(i=bi()).$$click=()=>c(e),i.addEventListener("mouseenter",()=>{a(t())}),W(i,vr(ht,{as:"span",get children(){return e.label}}),null),W(i,vr(X,{get when(){return e.shortcut},get children(){var t=hi();return W(t,()=>e.shortcut),t}}),null),Qt(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&&ut(i,"id",r.e=a),l!==r.t&&ut(i,"aria-selected",r.t=l),s!==r.a&&ut(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&&ut(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),W(p,vr(y,{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),Qt(()=>ut(p,"aria-label",t("commandSearch.title"))),d}})}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)}Qe(["click","keydown"]);var wi=!1,Si=null,Ii=null,Ci=null,Ti=[];function ki(){"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}()?wi&&(delete window.__oasisCanvasDebug,wi=!1):wi||(window.__oasisCanvasDebug={getLastHit:()=>Si?{...Si}:null,getLayoutSnapshot:()=>Ii?{...Ii,surfaceRect:{...Ii.surfaceRect},pages:Ii.pages.map(e=>({...e})),paragraphs:Ii.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:Ii.inlineImages.map(e=>({...e})),inlineTextBoxes:Ii.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:Ii.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Ci?{anchor:{...Ci.anchor},focus:{...Ci.focus},activeZone:Ci.activeZone,activeSectionIndex:Ci.activeSectionIndex}:null,getMissEvents:()=>Ti.map(e=>({...e})),clearMissEvents:()=>{Ti=[]}},wi=!0))}function Pi(e){wi&&e&&(Si={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Ri=["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 Bi(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function Mi(e){return function(e){const[t,n]=gn([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))Bi(r,o,i.textStyle?.fontFamily);Bi(r,o,t.fontFamily);for(const i of n)Bi(a,o,i);for(const i of Ri)Bi(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(wo(e))}const o=wo(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 ee();e.length>0&&n(e)}}}(e)}var Ai="insertText",Fi="composition",Oi="insertImage",Di="insertTable",Ei="moveImage",Li="splitListItem",Ni="link",$i="imageAlt",zi="imageCaption",Hi="imageResize",Wi="imageCrop",Ui="imageFlip",ji="imageRotate",Vi="imageTransparency",Ki="imageReset",_i="layoutWrapPolygon",Gi="specialIndent",Xi="paraBorders",Yi="paragraphMoveUp",qi="paragraphMoveDown",Zi="findReplace",Ji="findReplaceAll",Qi="tableProperties",el="paragraph-dialog",tl="font-dialog",nl="copyTextByDrag",ol="moveTextByDrag",rl="collapseSelectionByClick",al="mergeTable",il="splitTable",ll="insertTableColumn",sl="deleteTableColumn",cl="insertTableRow",dl="deleteTableRow",ul="tableShading",pl="tableBorders",gl="tableWidth",fl="tableAlign",ml="tableCellAlignment",hl="tableCellVerticalAlign",bl="tableCellTextDirection",yl="tableCellWidth",vl="tableColumnWidth",xl="tableToText",wl="textToTable",Sl="tableSplitAtRow",Il="tableSortAscending",Cl="tableSortDescending",Tl="tableDelete",kl="deleteTableCell",Pl="tableAutoFit",Rl="tableRepeatHeaderRows",Bl="tableCellMargins",Ml="tableFormula",Al="tableRowHeight",Fl="tableStyleOptions",Ol="tableStyleGallery",Dl="tableDistribute",El="layoutWrapPreset",Ll="layoutFixedPosition",Nl="shapeFill",$l="shapeOutline",zl="shapeOutlineWidth",Hl="floatingAlign",Wl="floatingReorder",Ul="floatingNudge",jl="floatingFixedPosition",Vl="floatingRotation",Kl="floatingWrap",_l="floatingWrapText",Gl="floatingPositionPreset",Xl="shapePreset",Yl="textBoxTextDirection",ql="textBoxVerticalAlign",Zl="textBoxAlt",Jl="textBoxRotate",Ql="textBoxWidthCm",es="textBoxHeightCm";function ts(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 ns(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function os(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function rs(e,t){const n=Ne(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 as(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:as(e.blocks,t)}))}))}})}function is(e,t,n){const o=Ne(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function ls(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function ss(e){const t=lo(e),n=C(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:ls(n)}:null}function cs(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=cs(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 ds(e,t){return Boolean(e?.some(e=>Ae(e).some(e=>e.id===t)))}function us(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?ds(e.firstPageHeader,n)?"firstPage":ds(e.evenPageHeader,n)?"evenPage":"default":ds(e.firstPageFooter,n)?"firstPage":ds(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[aa(t,o)]??null}return null}function ps(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?ds(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:ds(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?ds(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:ds(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function gs(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?gs(a.blocks,t.slice(1)):null}function fs(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=fs(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 ms(e){const t=ss(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return bs(e,r);const a=Ne(e.document)[n];return a?us(a,o.zone,r):null}function hs(e){const t=e.selection.focus.paragraphId,n=bn(e);if("footnote"===n)return bs(e,t);const o=lo(e),r=Ne(e.document)[o];return r?us(r,n,t):null}function bs(e,t){const n=St(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function ys(e,t){const n=ss(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>fs(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=St(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=Ne(e.document).map((e,t)=>t===o?ps(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function vs(e,t){const n=ss(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>cs(e,r.tablePath,t);if("footnote"===r.zone){const t=St(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=Ne(e.document).map((e,t)=>t===o?ps(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var xs={width:.5,type:"solid",color:"#000000"},ws={width:0,type:"none",color:"transparent"};function Ss(e){const t=lo(e),n=C(e.document,e.selection.anchor.paragraphId,t),o=C(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=is(e.document,t,n.zone);if(!r)return null;const a=Bo(r,n.tablePath),i=Bo(r,o.tablePath),l=a?.[a.length-1],s=i?.[i.length-1];if(!l||!s||l.table!==s.table)return null;const c=n.tablePath[n.tablePath.length-1],d=o.tablePath[o.tablePath.length-1];if(!c||!d)return null;const u=en(l.table),p=u.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex),g=u.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex);if(!p||!g)return null;const f=Math.min(p.visualRowIndex,g.visualRowIndex),m=Math.max(p.visualRowIndex+p.rowSpan-1,g.visualRowIndex+g.rowSpan-1),h=Math.min(p.visualColumnIndex,g.visualColumnIndex),b=Math.max(p.visualColumnIndex+p.colSpan-1,g.visualColumnIndex+g.colSpan-1);return{entries:u,selectedEntries:u.filter(e=>e.visualRowIndex<=m&&e.visualRowIndex+e.rowSpan-1>=f&&e.visualColumnIndex<=b&&e.visualColumnIndex+e.colSpan-1>=h),startRow:f,endRow:m,startCol:h,endCol:b}}function Is(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=Ss(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of Ae(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=to(e),o=pa(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:{...ns(),type:"property",previous:{...r??{}}}}),{...o,style:os(r,t,n)}},a=Ne(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 Cs(e,t){let n=Is(e,"borderTop",t);return n=Is(n,"borderRight",t),n=Is(n,"borderBottom",t),n=Is(n,"borderLeft",t),n}function Ts(e,t,n){const o=function(e){const t=to(e),n=pa(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:{...ns(),type:"property",previous:{...r??{}}}}),{...o,style:os(r,t,n)}})(l):l});return rs(e,r)}function ks(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:{...ns(),type:"property",previous:{...a??{}}}}),{...r,style:os(a,n,o)}};return rs(e,e=>as(e,r))}function Ps(e,t,n){const o=ss(e);if(!o)return e;return vs(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:{...ns(),type:"property",previous:{...o??{}}}}),{...r,style:os(o,t,n)}})():r);return{...r,rows:a}})}function Rs(e,t){const n=ss(e);if(!n)return e;return vs(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:{...ns(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:os(a,"isHeader",i??null)}})}))}function Bs(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:{...ns(),type:"property",previous:{...r??{}}}}),{...t,style:os(r,"height",n[o])}});return{...o,rows:r}};return rs(e,e=>as(e,o))}function Ms(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*Hn:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function As(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=en(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=Ms(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?{...ns(),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={...ns(),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?{...ns(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return rs(e,e=>as(e,a))}function Fs(e){const t=ss(e);if(!t)return e;const n=ms(e);if(!n)return e;const o=gs(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(mn(n));return t}(o);if(0===r.length)return e;const a=ys(e,r);if(a===e)return e;const i=r[0];return{...a,selection:re(Bt(i,0))}}function Os(e){if(ss(e))return e;if(!hs(e))return e;const t=pa(e);if(0===t.length)return e;const n=to(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(Ds),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>sa(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:Go("paragraph"),type:"paragraph",runs:o.length>0?o:[xn("")]};return Dn([r])})));return ma(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=bn(e),r=lo(e);if("footnote"===o){const o=St(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=Ne(e.document).map((e,a)=>a===r?ps(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:re(Bt(l,0))}:e}function Ds(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=Yn(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 Es(e,t){const n=ss(e);if(!n)return e;const o=n.loc.cellIndex;return vs(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=Ls(e.cells[t]),r=Ls(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 Ls(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Ae(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Ns(e){return!0===e.isHeader}function $s(e){return null!==ss(e)}function zs(e){return null!==ss(e)}var Hs=/* @__PURE__ */new Set(["left","center","right"]);function Ws(e,t){const n=ss(e);if(!n)return e;if(null!==t&&!Hs.has(t))return e;const o=function(e,t){const n=ss(e);if(!n)return null;const o=Bo(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,is(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:Ts(e,"align",a)}function Us(e){return null!==ss(e)}var js=["SUM","AVERAGE","COUNT","MIN","MAX"];function Vs(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=ss(e);if(!o)return e;const r=ms(e);if(!r)return e;const a=gs(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=en(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(!_s(r,i,t))continue;if(!Gs(r,i,t))continue;const e=Xs(Ks(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=vs(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[yo(l)]})})}));if(d===e)return e;const u=yo(l);return{...d,selection:re(Bt(u,l.length))}}function Ks(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Ae(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function _s(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 Gs(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 Xs(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 Ys(e,t){const n=function(e){const t=ss(e);if(!t)return null;const n=ms(e);if(!n)return null;const o=gs(n,t.loc.tablePath);if(!o)return null;const r=en(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=qs(s),u=qs(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:Bt(p,0),focus:Bt(g,J(g).length)}}:e}function qs(e){return e.blocks.flatMap(Ae)}function Zs(e){const t=function(e){const t=ss(e);if(!t)return null;const n=ms(e);if(!n)return null;const o=gs(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function Js(e){const t=ss(e);if(!t)return e;const n=ms(e);if(!n)return e;const o=gs(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=vs(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(Ae)[0]??null:null;return c?{...l,selection:re(Bt(c,0))}:l}var Qs={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 ec(e){const t=lo(e),n=C(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Bo(function(e,t){const n=Ne(e.document)[lo(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 i=en(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:i?.visualColumnIndex??o.cellIndex}}function tc(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 nc(e){return!!e&&"none"!==e.type&&e.width>0}function oc(e,t="table"){const n=tc(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=tc(o?.style?.height),i=tc(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=tc(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(nc)[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{...Qs,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:tc(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:nc(c.borderTop),borderRight:nc(c.borderRight),borderBottom:nc(c.borderBottom),borderLeft:nc(c.borderLeft),borderStart:nc(c.borderStart),borderEnd:nc(c.borderEnd),borderTopLeftToBottomRight:nc(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:nc(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function rc(e,t,n){return Is(e,t,n)}function ac(e){return Boolean(ec(e))}function ic(e,t="table"){const n=ec(e);return n?oc(n,t):null}function lc(e){const t=()=>ac(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=ic(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=ec(e);if(!n)return e;let o=e;return o=ks(o,n.tableId,"width",t.tableWidth),o=ks(o,n.tableId,"align",t.tableAlign),o=ks(o,n.tableId,"indentLeft",t.tableIndentLeft),o=ks(o,n.tableId,"floating",t.tableFloating),o=ks(o,n.tableId,"tblOverlap",t.tableOverlap),o=ks(o,n.tableId,"altTitle",t.altTitle),o=ks(o,n.tableId,"altDescription",t.altDescription),o=Rs(o,t.repeatHeader),o=Ps(o,"height",t.rowHeight),o=Ps(o,"heightRule",t.rowHeightRule),o=Ps(o,"cantSplit",t.cantSplit),o=Ps(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=As(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=rc(o,"width",t.cellWidth),o=rc(o,"verticalAlign",t.cellVerticalAlign),o=rc(o,"textDirection",t.cellTextDirection),o=rc(o,"noWrap",t.cellNoWrap),o=rc(o,"fitText",t.cellFitText),o=rc(o,"hideMark",t.cellHideMark),o=rc(o,"paddingTop",t.margins.top),o=rc(o,"paddingRight",t.margins.right),o=rc(o,"paddingBottom",t.margins.bottom),o=rc(o,"paddingLeft",t.margins.left),o=rc(o,"borderTop",t.borders.top),o=rc(o,"borderRight",t.borders.right),o=rc(o,"borderBottom",t.borders.bottom),o=rc(o,"borderLeft",t.borders.left),o=rc(o,"borderStart",t.borders.start),o=rc(o,"borderEnd",t.borders.end),o=rc(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=rc(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=rc(o,"shading",t.shading),o}(e,n),{mergeKey:Qi}),e.focusInput())}}}function sc(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=!Vn(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 cc(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),al),split:()=>o(e=>n.splitSelectedTable(e),il),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),ll),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),ll),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),sl),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),cl),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),cl),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),dl)}}function dc(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=Mi({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:In(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()||(Vn(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:tl})),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=je(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=je(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=je(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=je(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=je(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=je(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=je(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=je(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=je(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=je(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=je(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=je(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=je(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=je(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=je(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=je(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=je(r,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=je(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=je(r,t,c[t]));return r},{mergeKey:el}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=ae(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:ts(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=lc({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=sc({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:cc({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 uc(e){const t=ln(()=>{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=pa(e.state).find(e=>e.id===t.paragraphId),r=n?jt(n,t):0,a=so(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=_r(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 vr(X,{get when(){return t()},children:e=>vr(ie,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var pc=/*#__PURE__*/te("<div class=oasis-editor-table-resize-guide>"),gc=/*#__PURE__*/te("<div class=oasis-editor-table-resize-outline>"),fc=/*#__PURE__*/te("<img class=oasis-editor-image-ghost>"),mc=/*#__PURE__*/te("<div class=oasis-editor-table-ghost>");function hc(e){return[vr(X,{get when(){return e.tableResize.resizing()},children:e=>{return t=pc(),Qt(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=zt(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),vr(X,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=gc(),Qt(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&Sa(t,"left",n.e=o),r!==n.t&&Sa(t,"top",n.t=r),a!==n.a&&Sa(t,"width",n.a=a),i!==n.o&&Sa(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),vr(X,{get when(){return le(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=fc(),Qt(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&&ut(n,"src",o.e=r),a!==o.t&&Sa(n,"width",o.t=a),i!==o.a&&Sa(n,"height",o.a=i),l!==o.o&&Sa(n,"left",o.o=l),s!==o.i&&Sa(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),vr(X,{get when(){return le(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=mc(),Qt(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&&Sa(n,"width",o.e=r),a!==o.t&&Sa(n,"height",o.t=a),i!==o.a&&Sa(n,"left",o.a=i),l!==o.o&&Sa(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),vr(X,{get when(){return le(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>vr(uc,{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})}),vr(X,{get when(){return le(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>vr(uc,{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})}),vr(X,{get when(){return le(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>vr(uc,{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 bc(e){return[vr(H,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),vr(H,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function yc(e){const t=Lo(),[n,o]=gn(e.initialValue);let r;fe(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return vr(xt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return vr(bc,{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 vr(go,{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 vc(e){const t=Lo();return vr(yc,{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 xc(e){const t=Lo();return vr(yc,{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 wc(e){const t=Lo();return vr(yc,{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 Sc=/*#__PURE__*/te("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Ic=/*#__PURE__*/te("<div class=oasis-editor-comment-composer>");function Cc(e){const t=Lo(),[n,o]=gn(""),[r,a]=gn("");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 fe(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),vr(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[vr(H,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),vr(H,{variant:"primary",get disabled(){return!s()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var s=Ic();return W(s,vr(X,{get when(){return"reply"===l()?.mode},get children(){var e=Sc();return W(e,vr(ht,{as:"strong",get children(){return[le(()=>t("comment.replyTo"))," ",le(()=>l()?.parentAuthor)]}}),null),W(e,vr(ht,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),W(s,vr(go,{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),W(s,vr(xo,{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 Tc=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],kc=[33,50,66,75,90,100,105,110,115,120,150,200];function Pc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Rc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function Bc(e){return null==e||""===e?"":String(e)}function Mc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Ac(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function Fc(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Oc(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 Dc(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 Ec(e,t){const n=[],o=Fc(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Lc(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 Nc(e){return{characterScale:Bc(e.characterScale),spacingMode:Mc(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Ac(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:Bc(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:Bc(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function $c(e){const t=Lo(),[n,o]=gn("font"),[r,a]=gn(Lc(e.initial)),[i,l]=gn(Nc(e.initial));fe(()=>{e.isOpen&&(o("font"),a(Lc(e.initial)),l(Nc(e.initial)))});const s=ln(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=ln(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=ln(()=>{const t=new Set(Tc);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=ln(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=ln(()=>{const e=i();return e.characterScale.trim()&&null===Pc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Rc(e.spacingAmount)||"normal"!==e.positionMode&&null===Rc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Rc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===Fc(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=ln(()=>function(e,t){const n=Number(e.fontSize),o=Pc(t.characterScale)??100,r="normal"===t.spacingMode?null:Rc(t.spacingAmount),a="normal"===t.positionMode?null:Rc(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":Oc(t.ligatures),"font-variant-numeric":Dc(t.numberSpacing,t.numberForm),"font-feature-settings":Ec(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()?Pc(t.characterScale):null,l="normal"===t.spacingMode?null:Rc(t.spacingAmount),s="normal"===t.positionMode?null:Rc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Rc(t.kerningThreshold):null,d=Fc(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 zc=/*#__PURE__*/te("<div>");function Hc(e){const t=Lo();return n=zc(),W(n,()=>t("dialog.font.previewText")),Qt(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&He(n,t.e=o),r!==t.t&&ut(n,"data-testid",t.t=r),t.a=zt(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Wc=/*#__PURE__*/te('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Uc(e){const t=Lo(),{ctrl:n}=e;return o=Wc(),W(o,vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:12,get children(){return vr(go,{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"})}}),vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{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}))]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(ao,{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)}))]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return[vr(go,{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"}),vr(Ln,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{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),W(o,vr(qr,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[vr(qr,{size:{xs:12,md:4},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(Yo,{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"})}}),vr(qr,{size:{xs:12,md:2},get children(){return vr(Yo,{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"})}}),vr(qr,{size:{xs:12,md:2},get children(){return vr(Yo,{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),W(o,vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{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")},...nt.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(Yo,{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),W(o,vr(Sn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return vr(_t,{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=>vr(Ar,{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),W(o,vr(Sn,{get label(){return t("dialog.font.preview")},get children(){return vr(Hc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var jc=/*#__PURE__*/te("<div class=oasis-editor-font-dialog-kerning-line>"),Vc=/*#__PURE__*/te('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function Kc(e){const t=Lo(),{ctrl:n}=e;return o=Vc(),W(o,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:4},get children(){return vr(ao,{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 kc.map(e=>({value:String(e),label:`${e}%`}))}})}}),vr(qr,{size:{xs:12,md:8},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(go,{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"})}})]}})}}),vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(go,{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"})}}),vr(qr,{size:12,get children(){var e=jc();return W(e,vr(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),W(e,vr(go,{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),W(e,vr(Ln,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),W(o,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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)}))]}})}})]}}),vr(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),W(o,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return vr(Hc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),W(o,vr(Ln,{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 _c(e){const t=Lo(),n=$c(e);return vr(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 vr(bc,{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 vr(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:vr(Uc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:vr(Kc,{ctrl:n})}]}})}})}var Gc=/*#__PURE__*/te("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),Xc=/*#__PURE__*/te("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Yc(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function qc(e){const t=Lo(),[n,o]=gn([]);fe(()=>{e.isOpen&&o(e.initial.map(Yc))});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 vr(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=Xc(),r=n.firstChild,a=r.nextSibling,W(r,vr(H,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),W(a,vr(H,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),W(a,vr(H,{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=Gc(),i=e.firstChild;return W(e,vr(_t,{get each(){return n()},get fallback(){return vr(Ln,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>vr(qr,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[vr(qr,{size:{xs:12,md:4},get children(){return vr(Xn,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),vr(qr,{size:{xs:6,md:3},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:6,md:3},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:2},get children(){return vr(H,{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),W(i,vr(H,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var Zc=96/72;function Jc(e){const[t,n]=gn(""),[o,r]=gn(""),[a,i]=gn(null),[l,s]=gn(null),[c,d]=gn("none"),[u,p]=gn(null),[g,f]=gn(!1),[m,h]=gn(null),[b,y]=gn(null),[v,x]=gn("multiple"),[w,S]=gn(null),[I,C]=gn(!1),[T,k]=gn(""),[P,R]=gn("none"),[B,M]=gn(null),[A,F]=gn(""),[O,D]=gn(!1),[E,L]=gn(!1),[N,$]=gn(!1),[z,H]=gn(!1),[W,U]=gn(!1),[j,V]=gn(!1),[K,_]=gn(!1),[G,X]=gn(!0),[Y,q]=gn([]);fe(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(dn(e.initial.indentLeft??"")),s(dn(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(dn(e.initial.spacingBefore??"")),y(dn(e.initial.spacingAfter??"")),C(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=dn(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/Zc):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"),M(dn(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),X(e.initial.widowControl??!0),q(e.initial.tabs??[]);const u=dn(e.initial.indentFirstLine??""),g=dn(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()*Zc:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*Zc:null,lineRule:"exact"}}},J=ln(()=>{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()} ${A().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:A().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:I(),outlineLevel:""===i?null:Number(i),shading:T().trim()||null,borders:Q(),pageBreakBefore:W(),keepWithNext:j(),keepLinesTogether:K(),widowControl:G(),tabs:Y()}};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:I,setContextualSpacing:C,shading:T,setShading:k,borderStyle:P,setBorderStyle:R,borderWidth:B,setBorderWidth:M,borderColor:A,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:G,setWidowControl:X,tabs:Y,setTabs:q,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:J,handleApply:()=>{e.onApply(ee(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(ee()),e.onClose()}}}var Qc=/*#__PURE__*/te("<div class=oasis-editor-paragraph-dialog-panel>"),ed=/*#__PURE__*/te("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),td=/*#__PURE__*/te("<div>"),nd=/*#__PURE__*/te("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function od(e){const t=Lo(),[n,o]=gn(!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:I,lineAt:C,setLineAt:T,contextualSpacing:k,setContextualSpacing:P,shading:R,setShading:B,borderStyle:M,setBorderStyle:A,borderWidth:F,setBorderWidth:O,borderColor:D,setBorderColor:E,sideTop:L,setSideTop:N,sideRight:$,setSideRight:z,sideBottom:U,setSideBottom:j,sideLeft:V,setSideLeft:K,pageBreakBefore:_,setPageBreakBefore:G,keepWithNext:X,setKeepWithNext:Y,keepLinesTogether:q,setKeepLinesTogether:Z,widowControl:J,setWidowControl:Q,tabs:ee,setTabs:te,atEnabled:ne,previewStyle:oe,handleApply:re,handleSetDefault:ae}=Jc(e),ie=vr(ao,{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=vr(ao,{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=Qc(),W(ce,vr(Un,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},children:ie}),vr(qr,{size:{xs:12,md:6},children:le})]}})}}),null),W(ce,vr(Un,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},get children(){return vr(Xn,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(Xn,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(Xn,{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"})}}),vr(qr,{size:12,get children(){return vr(fr,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:b,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),W(ce,vr(Un,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:4},get children(){return vr(Xn,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return y()??""},onChange:v,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(Xn,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return x()??""},onChange:w,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),vr(qr,{size:{xs:12,md:4}}),vr(qr,{size:{xs:12,md:8},get children(){return vr(ao,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return S()},onChange:e=>{I(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")}]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(Xn,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===S()?"0.05":"1"},get disabled(){return!ne()},get value(){return C()??""},onChange:T,"data-testid":"editor-paragraph-dialog-line-at"})}}),vr(qr,{size:12,get children(){return vr(fr,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return k()},onChange:P,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),W(ce,vr(Un,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:3},get children(){return vr(ao,{get label(){return t("paragraph.borderStyleLabel")},get value(){return M()},onChange:e=>{const t=e;A(t),"none"===t?(N(!1),z(!1),j(!1),K(!1)):L()||$()||U()||V()||(N(!0),z(!0),j(!0),K(!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")}]}})}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(Xn,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===M()},get value(){return F()??""},onChange:O,"data-testid":"editor-paragraph-dialog-border-width"})}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(Yo,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===M()},get value(){return D()||"#000000"},onChange:E,"data-testid":"editor-paragraph-dialog-border-color"})}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(Yo,{get label(){return t("paragraph.shadingLabel")},get value(){return R()||"#ffffff"},onChange:B,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),vr(Sn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[vr(fr,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===M()},get checked(){return L()},onChange:N,"data-testid":"editor-paragraph-dialog-border-side-top"}),vr(fr,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===M()},get checked(){return $()},onChange:z,"data-testid":"editor-paragraph-dialog-border-side-right"}),vr(fr,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===M()},get checked(){return U()},onChange:j,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),vr(fr,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===M()},get checked(){return V()},onChange:K,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),ce);var ce;const de=(ue=Qc(),W(ue,vr(Un,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return vr(ba,{direction:"column",spacing:1,get children(){return[vr(fr,{get label(){return t("paragraph.widowControlLabel")},get checked(){return J()},onChange:Q,"data-testid":"editor-paragraph-dialog-widow-control"}),vr(fr,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return X()},onChange:Y,"data-testid":"editor-paragraph-dialog-keep-with-next"}),vr(fr,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return q()},onChange:Z,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),vr(fr,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return _()},onChange:G,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ue);var ue,pe;return pe=td(),W(pe,vr(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=nd(),r=n.firstChild,a=r.nextSibling,W(r,vr(H,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),W(r,vr(H,{variant:"secondary",onClick:ae,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),W(a,vr(H,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),W(a,vr(H,{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[vr(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"}]}}),vr(Sn,{get label(){return t("paragraph.preview")},get children(){var e=ed();return W(e,()=>t("paragraph.previewText")),Qt(t=>zt(e,oe(),t)),e}})]}}),null),W(pe,vr(qc,{get isOpen(){return n()},get initial(){return ee()},onClose:()=>{o(!1)},onApply:te}),null),pe}function rd(e,t){const n=dn(e);return null===n?null:"percent"===t?`${n}%`:n}function ad(e,t,n){if("none"===e)return null;const o=dn(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function id(e){const[t,n]=Fe({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:""});fe(()=>{var t;e.isOpen&&n($e({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=ad(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:rd(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:rd(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:dn(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:dn(e.floatingY)??0},distanceTop:dn(e.floatingDistanceTop)??0,distanceRight:dn(e.floatingDistanceRight)??0,distanceBottom:dn(e.floatingDistanceBottom)??0,distanceLeft:dn(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:rd(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:rd(e.columnWidth,"points"),cellWidth:rd(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:dn(e.marginTop),right:dn(e.marginRight),bottom:dn(e.marginBottom),left:dn(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 ld(e,t,n,o,r=!1,a=!1){return vr(go,{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 sd=/*#__PURE__*/te("<div class=oasis-editor-table-properties-panel>");function cd(e){const t=Lo(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=sd(),W(r,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},get children(){return ld(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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),W(r,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[vr(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=>vr(jo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),vr(qr,{container:!0,spacing:1.5,get children(){return vr(qr,{size:{xs:12,md:6},get children(){return ld(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),W(r,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[vr(fr,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),vr(fr,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),vr(X,{get when(){return"around"===n().tableWrapping},get children(){return[vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(ao,{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}))]}})}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(ao,{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}))]}})}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),vr(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 dd=/*#__PURE__*/te("<div class=oasis-editor-table-properties-panel>");function ud(e){const t=Lo(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=dd(),W(r,vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:6},get children(){return ld(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),vr(qr,{size:{xs:12,md:6},get children(){return vr(ao,{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),W(r,vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[vr(fr,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),vr(fr,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),vr(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 pd=/*#__PURE__*/te("<div class=oasis-editor-table-properties-panel>");function gd(e){const t=Lo(),n=e.ctrl.set;return o=pd(),W(o,vr(qr,{container:!0,spacing:1.5,get children(){return vr(qr,{size:{xs:12,md:6},get children(){return ld(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var fd=/*#__PURE__*/te("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),md=/*#__PURE__*/te("<div class=oasis-editor-table-properties-panel>");function hd(e){const t=Lo(),n=()=>e.ctrl.form,o=e.ctrl.set,r=ln(()=>{const e=ad(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=md(),W(i,vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:4},get children(){return ld(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:4},get children(){return vr(ao,{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),W(i,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[vr(fr,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),vr(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"}),vr(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),W(i,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:3},get children(){return ld(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),W(i,vr(Un,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[vr(qr,{container:!0,spacing:1.5,get children(){return[vr(qr,{size:{xs:12,md:3},get children(){return vr(ao,{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")}]}})}}),vr(qr,{size:{xs:12,md:3},get children(){return ld(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(Yo,{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"})}}),vr(qr,{size:{xs:12,md:3},get children(){return vr(Yo,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),vr(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[vr(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"}),vr(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"}),vr(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"}),vr(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"}),vr(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"}),vr(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"}),vr(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"}),vr(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=fd(),Qt(t=>zt(e,r(),t)),e)];var e}}),null),i;var i}var bd=/*#__PURE__*/te("<div class=oasis-editor-table-properties-panel>");function yd(e){const t=Lo(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=bd(),W(r,vr(go,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),W(r,vr(xo,{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 vd(e){const t=Lo(),n=id(e);return vr(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 vr(bc,{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 vr(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:vr(cd,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:vr(ud,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:vr(gd,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:vr(hd,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:vr(yd,{ctrl:n})}]}})}})}var xd=/*#__PURE__*/te("<p data-testid=editor-new-document-message>");function wd(e){const t=Lo();return vr(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 vr(bc,{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=xd();return W(e,()=>t("dialog.newDocument.message")),e}})}function Sd(e){const t=Lo(),n=()=>"accept"===e.action;return vr(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 vr(bc,{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 vr(ht,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Id=/*#__PURE__*/te("<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>"),Cd=/*#__PURE__*/te("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),Td=/*#__PURE__*/te("<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>"),kd=/*#__PURE__*/te("<option>"),Pd=/*#__PURE__*/te("<button type=button class=oasis-editor-symbol-dialog-tile>"),Rd=/*#__PURE__*/te("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),Bd=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function Md(e){const t=Lo(),[n,o]=gn("common"),[r,a]=gn(jn[0]),[i,l]=gn(Bd[0]),[s,c]=gn(jn[0].codePoint),d=ln(()=>(e.isOpen,$o())),u=ln(()=>"all"===n()?eo.flatMap(e=>e.entries):eo.find(e=>e.id===n())?.entries??jn),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&($r(t),e.onInsert(t,i()),e.onClose())};return vr(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[vr(H,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),vr(H,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(w=Id(),S=w.firstChild,I=S.firstChild,C=I.nextSibling,T=S.nextSibling.firstChild,k=T.nextSibling,P=k.firstChild,W(I,()=>t("dialog.symbol.font")),C.addEventListener("change",e=>{l(e.currentTarget.value)}),W(C,vr(_t,{each:Bd,children:e=>{return(t=kd()).value=e,W(t,e),t;var t}})),W(T,()=>t("dialog.symbol.subset")),k.addEventListener("change",e=>{o(e.currentTarget.value)}),W(P,()=>t("symbols.category.all")),W(k,vr(_t,{each:eo,children:e=>{return n=kd(),W(n,()=>t(e.labelKey)),Qt(()=>n.value=e.id),n;var n}}),null),Qt(()=>C.value=i()),Qt(()=>k.value=n()),w),(e=Td(),f=e.firstChild,m=f.nextSibling.firstChild,h=m.nextSibling,b=h.nextSibling,y=b.firstChild,v=y.nextSibling,x=b.nextSibling,W(f,vr(X,{get when(){return d().length>0},get children(){var e=Cd(),n=e.firstChild,o=n.nextSibling;return W(n,()=>t("dialog.symbol.recent")),W(o,vr(_t,{get each(){return d()},children:e=>{return(t=Pd()).$$click=()=>p(e),W(t,()=>e.character),Qt(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&ut(t,"title",n.e=o),r!==n.t&&ut(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),W(f,vr(_t,{get each(){return u()},children:e=>{return(t=Rd()).$$dblclick=g,t.$$click=()=>p(e),W(t,()=>e.character),Qt(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&&ut(t,"title",n.t=a),i!==n.a&&ut(t,"aria-label",n.a=i),l!==n.o&&ut(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),W(m,()=>t("dialog.symbol.preview")),W(h,()=>r().character),W(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),ut(v,"spellcheck",!1),W(x,()=>t("dialog.symbol.doubleClickHelp")),Qt(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&ut(f,"aria-label",e.e=n),o!==e.t&&Sa(h,"font-family",e.t=o),e},{e:void 0,t:void 0}),Qt(()=>v.value=s()),e)];var e,f,m,h,b,y,v,x,w,S,I,C,T,k,P}})}Qe(["input","click","dblclick"]);var Ad=/*#__PURE__*/te("<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>"),Fd=/*#__PURE__*/te("<button type=button data-testid=editor-equation-template>"),Od=[["\\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 Dd(e){const t=Lo(),[n,o]=gn(""),[r,a]=gn(Co);fe(()=>{if(!e.isOpen)return;const t=e.initial??Co;a(t),o(R(t))});const i=e=>{o(e),a(E(e))};return vr(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[vr(H,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),vr(H,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Ad(),o=e.firstChild,a=o.nextSibling,l=a.firstChild,s=l.nextSibling,c=a.nextSibling;return W(o,vr(_t,{each:Od,children:([e,t])=>{return(n=Fd()).$$click=()=>i(t),W(n,e),n;var n}})),W(l,()=>t("dialog.equation.linear")),s.$$input=e=>i(e.currentTarget.value),ut(s,"spellcheck",!1),W(c,()=>R(r())||t("dialog.equation.empty")),Qt(()=>ut(o,"aria-label",t("dialog.equation.structures"))),Qt(()=>s.value=n()),e}})}Qe(["input","click"]);var Ed=/*#__PURE__*/te("<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 Ld(e){const t=Lo(),{fr:n}=e,o=e=>{n.isOpen()&&"Escape"===e.key&&n.setIsOpen(!1)},r=e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext())};return er(()=>{window.addEventListener("keydown",o,!0)}),Lr(()=>{window.removeEventListener("keydown",o,!0)}),vr(X,{get when(){return n.isOpen()},get children(){var e=Ed(),o=e.firstChild,a=o.nextSibling,i=a.firstChild,l=i.firstChild,s=i.nextSibling;return e.$$keydown=r,W(o,vr(ht,{get children(){return t("find.title")}}),null),W(o,vr(y,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),W(l,vr(go,{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),W(l,vr(Ln,{class:"oasis-editor-fr-counter",get children(){return le(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),W(i,vr(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[vr(y,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),vr(y,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),W(s,vr(go,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),W(s,vr(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[vr(y,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),vr(y,{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),W(a,vr(ba,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[vr(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})}),vr(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}})}Qe(["keydown"]);var Nd=/*#__PURE__*/te("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),$d=/*#__PURE__*/te("<i>"),zd=/*#__PURE__*/te("<span class=oasis-editor-context-menu-shortcut>"),Hd=/*#__PURE__*/te("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),Wd=/*#__PURE__*/te("<div class=oasis-editor-context-menu-separator>"),Ud=/*#__PURE__*/te("<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())},o=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},a=()=>{e.isOpen&&e.onClose()};return er(()=>{window.addEventListener("keydown",n,!0),window.addEventListener("mousedown",o,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a,!0)}),Lr(()=>{window.removeEventListener("keydown",n,!0),window.removeEventListener("mousedown",o,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a,!0)}),fe(()=>{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`}),vr(X,{get when(){return e.isOpen},get children(){var n=Nd();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?Ft(t,n):t=n,W(n,vr(_t,{get each(){return e.items},children:t=>vr(X,{get when(){return"separator"!==t.type},get fallback(){return Wd()},get children(){var n=Hd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},W(n,vr(X,{get when(){return t.icon},get fallback(){return e=Ud(),W(e,vr(Qr,{size:16})),e;var e},get children(){var e=$d();return Qt(()=>ut(e,"data-lucide",t.icon)),e}}),o),W(o,()=>t.label),W(n,vr(X,{get when(){return t.shortcut},get children(){var e=zd();return W(e,()=>t.shortcut),e}}),null),Qt(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&ut(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),Qt(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&Sa(n,"left",t.e=o),r!==t.t&&Sa(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function Vd(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[vr(wd,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),vr(Sd,{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)}}),vr(Md,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),vr(Dd,{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)}}),vr(vc,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),vr(xc,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),vr(wc,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),vr(Cc,{get composer(){return e.commentComposer}}),vr(Ld,{get fr(){return e.findReplace}}),vr(_c,{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}}),vr(od,{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}}),vr(vd,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),vr(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}})]}Qe(["contextmenu","click"]);var Kd=/*#__PURE__*/te("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function _d(e){let t,n;const o=tt(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=Ue({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[vr(X,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return vr(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 showRuler(){return o.showRuler()},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}})})()}}),vr(X,{get when(){return!e.useComposedShell()},get children(){return vr(L,{get editor(){return e.runtime.runtimeEditor},get children(){var l=Kd(),s=l.firstChild;return W(l,vr(X,{get when(){return e.chrome.showOutline()},get children(){return vr(ho,{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),W(s,vr(j,{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 Gd=/*#__PURE__*/te("<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 Xd(e){const t=Lo(),n=()=>{g(),xe(),e.onClose()},o=()=>{G(!1),xe(),e.onClose()};return vr(X,{get when(){return e.isOpen},get children(){var e=Gd(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return W(r,vr(P,{height:72,class:"oasis-editor-welcome-mark"}),a),W(a,()=>t("welcome.title")),W(i,()=>t("welcome.body")),W(l,()=>t("welcome.note")),W(s,vr(H,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),W(s,vr(H,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var Yd=/* @__PURE__ */ko(O(),1),qd=Ct(),Zd="word/comments.xml";function Jd(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 Qd(e){return e.localName??e.tagName}function eu(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 tu(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 nu(e){let t="";for(const n of Jd(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===Qd(n)){t+=n.textContent??"";continue}if("tab"===Qd(n)){t+="\t";continue}if("br"===Qd(n)||"cr"===Qd(n)){t+="\n";continue}}t+=nu(n)}return t}function ou(e){return Jd(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===Qd(e))}function ru(e){return ou(e).map(nu).join("\n").trim()}function au(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===Qd(t)?t:void 0}function iu(e,t){const n=eu(ou(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=ou(t)[0];n&&o&&o.setAttributeNS(no,"w14:paraId",n)}function lu(e,t){const n=ou(e),o=ou(t);n[0]&&o[0]&&Kn(n[0],o[0]);const r=new Set(Jd(t).filter(e=>e.namespaceURI!==ur).map(e=>`${e.namespaceURI??""}\0${Qd(e)}`));for(const a of Jd(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${Qd(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function su(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(Zd);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=au(e),o=au(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Jd(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Qd(i))continue;const e=eu(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of Jd(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Qd(i))continue;const e=eu(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new qd.XMLSerializer).serializeToString(t);tu(i,t),ru(i)===ru(t)?iu(i,t):lu(i,t),(new qd.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new qd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Zd,a),!0)}var cu="http://schemas.microsoft.com/office/word/2012/wordml",du="word/commentsExtended.xml";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 pu(e){return e.localName??e.tagName}function gu(e){return`${e.namespaceURI??""}\0${pu(e)}`}function fu(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 mu(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function hu(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 bu(e){const t=/* @__PURE__ */new Map,n=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(ur,"comment"))){const e=fu(o,"id"),n=o.getElementsByTagNameNS(ur,"p").item(0),r=n?fu(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function yu(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===cu&&"commentsEx"===pu(t)?t:void 0}function vu(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))||mu(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(uu(t).map(gu));for(const r of uu(e))o.has(gu(r))||t.appendChild(r.cloneNode(!0))}function xu(e,t,n,o){const r=yu(t),a=yu(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))||mu(t,o,o.value)}}(r,a);const i=bu(e),l=bu(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 uu(e)){if(n.namespaceURI!==cu||"commentEx"!==pu(n))continue;const e=fu(n,"paraId");e&&t.set(e,n)}return t}(a),d=uu(r),u=new Set(uu(a).filter(e=>!(e.namespaceURI===cu&&"commentEx"===pu(e))).map(gu));for(const p of d){if(p.namespaceURI===cu&&"commentEx"===pu(p)){const e=fu(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&vu(p,n,s);continue}u.has(gu(p))||(a.appendChild(p.cloneNode(!0)),u.add(gu(p)))}return(new qd.XMLSerializer).serializeToString(a.ownerDocument)}var wu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Su(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 Iu(e){return e.localName??e.tagName}function Cu(e){return`${e.namespaceURI??""}\0${Iu(e)}`}function Tu(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 ku(e,t){return Su(e).find(e=>e.namespaceURI===wu&&Iu(e)===t)}function Pu(e,t){return e.filter(e=>e.namespaceURI===wu&&t.has(Iu(e)))}function Ru(e){if(e.namespaceURI!==wu)return;const t=Iu(e);if("p"===t){const t=Tu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=ku(e,"sdtPr"),n=t?ku(t,"id"):void 0,o=n?Tu(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function Bu(e,t,n){const o=(new qd.DOMParser).parseFromString(e,"application/xml"),r=(new qd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==wu||i.namespaceURI!==wu||Iu(a)!==n||Iu(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=Su(a),s=Su(i),c=new Set(s.map(Cu));return l.forEach((e,t)=>{if(e.namespaceURI===wu||c.has(Cu(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>Cu(t)===Cu(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new qd.XMLSerializer).serializeToString(r)}function Mu(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=Bu(e,t,n),a=(new qd.DOMParser).parseFromString(e,"application/xml"),i=(new qd.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==wu||s.namespaceURI!==wu||Iu(l)!==n||Iu(s)!==n)return r;const c=Su(l),d=Su(s),u=function(e,t,n){const o=Pu(e,n),r=Pu(t,n);return o.length===r.length&&o.every((e,t)=>Iu(e)===Iu(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==wu||o.has(Iu(e)))return;const n=Cu(e),r=p.get(n)??0;if(p.set(n,r+1),Su(s).filter(e=>Cu(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===wu&&o.has(Iu(e)));if(!a)return;const i=Ru(a);if(i){const e=Pu(n,o).find(e=>Ru(e)===i);if(e)return e}if(!r)return;const l=Pu(e,o),s=Pu(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 qd.XMLSerializer).serializeToString(i)}var Au="word/document.xml",Fu=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Ou(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 Du(e){return e.localName??e.tagName}function Eu(e){return`${e.namespaceURI??""}\0${Du(e)}`}function Lu(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 Nu(e,t){return Ou(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Du(e)===t)}function $u(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Fu.has(Du(e))}function zu(e){return e.filter($u)}function Hu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=Du(e);if("p"===t){const t=Lu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Nu(e,"sdtPr"),n=t?Lu(Nu(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Wu(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml"),o=(new qd.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"!==Du(r)||"document"!==Du(a))return t;!function(e,t){const n=Ou(e),o=Nu(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===Du(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=Ou(t).find(t=>!i.has(t)&&Eu(t)===Eu(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=Nu(r,"body"),l=Nu(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=Ou(i),c=Ou(l),d=function(e,t){const n=zu(e),o=zu(t);return n.length===o.length&&n.every((e,t)=>Du(e)===Du(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if($u(e))return;const n=Eu(e),o=u.get(n)??0;if(u.set(n,o+1),Ou(l).filter(e=>Eu(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find($u);if(!o)return;const r=Hu(o);return r?zu(n).find(e=>Hu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=zu(e),r=zu(n),a=e.slice(t+1).find($u);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"===Du(e))}(c)??null)}),(new qd.XMLSerializer).serializeToString(o)}async function Uu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(Au);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Wu(e,Bu(e,t,"document"))}(n.data,r);return a!==r&&(t.file(Au,a),!0)}var ju="word/document.xml",Vu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";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){const t=(new qd.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Vu,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function Gu(e){const t=[];return _u(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===Vu&&"headerReference"===r.localName?"header":r.namespaceURI===Vu&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Ku(r,"id");if(!a)continue;const i=Ku(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 Xu(e){return new Map(e.map(e=>[e.id,e]))}async function Yu(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(ju)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=_u(n.data),a=_u(o);if(r.length!==a.length)return!1;const i=Gu(n.data),l=Gu(o),s=new Map(i.map(e=>[e.key,e])),c=Xu(n.relationships??[]),d=Xu(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 On(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=Mu(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var qu="word/document.xml",Zu={"/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"},Ju=["/officeDocument",...Object.keys(Zu)];function Qu(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function ep(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){for(const[t,n]of Object.entries(Zu))if(e.type.endsWith(t))return n}function np(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=co(e);return void 0===n?t.get(e)??e:null===n?e:ep(t.get(n)??n)}function op(e,t){for(const[n,o]of t)if(o===e)return n;return e}function rp(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 ap(e,t){const n=e.parts[t];return"xml"===n?.kind?fa(n.data):[]}function ip(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:ap(e,bo):e.parts[t]?.relationships??ap(e,ep(t));return On(t,n)}function lp(e,t,n){return ip(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function sp(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,Ju.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=On(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:rp(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function cp(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(Qu(e)===Qu(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 dp(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 up(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===Wt(o))}async function pp(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Yd.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>vn(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(qu,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=tp(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!==qu&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new Yd.default;for(const c of Object.keys(n.parts))dp(l,n,c);for(const c of i)l.remove(c),l.remove(ep(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=co(a);if(null==i)continue;const l=ip(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=op(i,n);o.has(ep(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=vn(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=np(e,a),o=co(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=lp(n,r,i),c=cp(s,sp(fa(await d.async("string")),s,e,r,a),t);l.file(t,bt(c));continue}const r=await d.async("uint8array");up(n,e,t,r)||l.file(t,r)}return s&&l.file(_o,function(e,t,n,o){const r=Gr(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 gp="word/document.xml",fp=["first","even","default"];function mp(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 hp(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 bp(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 yp(e,t){const n=[],o=e=>{for(const r of bp(e))r.localName===t&&n.push(r),o(r)};return o(e),n}function vp(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 xp(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 wp(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml"),n=[],o=yp(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of bp(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=vp(r,"id");if(!a)continue;const i=vp(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 Sp(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function Ip(e,t){const n=e.parts[t]?.relationships??fa(Sp(e,mp(t)));return On(t,n)}function Cp(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 Tp(e,t){const n=Sp(e,e.mainDocumentPart),o=await(t.file(gp)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=wp(n),a=wp(o),i=Cp(r.references,Ip(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=fp.indexOf(e.type),o=fp.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=Cp(a.references,await async function(e,t){const n=await(e.file(mp(t))?.async("string"));return On(t,fa(n))}(t,gp)),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 kp(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function Pp(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 Rp(e,t,n,o){for(const r of n)if(!(await Pp(e,t,o?mp(r.current.partPath):r.current.partPath,r.source.baselinePath?o?mp(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function Bp(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?mp(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 Mp(e,t,n){const o=await(e.file(gp)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[gp],a=Wt((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of yp(n,r)){const n=vp(e,"id"),r=n?t.get(n):void 0;r&&(o=xp(e,"id",r.id)||o)}return o?(new qd.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(gp,t)}}const r=mp(gp),a=fa(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:hp(gp,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(kp(e)===kp(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 Ap(e,t,n){const o=n[0],r=o.source.partPath;if(!(await Rp(e,t,n,!1))){await Bp(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=mp(r);if(!(await Rp(e,t,n,!0))){await Bp(e,n,!0);const t=mp(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=On(l,[e])[0]?.resolvedTarget;return t?{...e,target:hp(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=mp(c.current.partPath);t!==a&&e.remove(t)}}async function Fp(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 Ap(e,t,o)}async function Op(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Yd.default.loadAsync(t),r=await Tp(n,o);r.matches.length>0&&(await Mp(o,n,r),await Fp(o,n,r),await async function(e,t){const n=await(e.file(_o)?.async("string"));if(!n)return;const o=Gr(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(_o,la(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return pp(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[mp(d)];const a=r[n.mainDocumentPart],i=Ip(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=mp(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:bt(i)});const c=r[_o];return c&&(r[_o]={...c,data:la(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var Dp=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],Ep=/* @__PURE__ */new Set(["p","tbl"]),Lp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function Np(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 $p(e){return e.localName??e.tagName}function zp(e){return`${e.namespaceURI??""}\0${$p(e)}`}function Hp(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 Wp(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 Up(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&$p(n)===t?n:void 0}function jp(e){const t=Hp(e,"type");if(t&&Lp.has(t))return`type:${t}`;const n=Hp(e,"id");return n?`id:${n}`:void 0}function Vp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ep.has($p(e))}function Kp(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==$p(e))return;const t=Hp(e,"paraId");return t?`p:${t}`:void 0}function _p(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=Np(e),o=Np(t),r=function(e,t){const n=e.filter(Vp),o=t.filter(Vp);return n.length===o.length&&n.every((e,t)=>$p(e)===$p(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Vp(e))return;const l=zp(e),s=a.get(l)??0;if(a.set(l,s+1),Np(t).filter(e=>zp(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Vp);if(!r)return;const a=Kp(r);if(a){const e=n.filter(Vp).find(e=>Kp(e)===a);if(e)return e}if(!o)return;const i=e.filter(Vp),l=n.filter(Vp),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 Gp(e,t,n,o){const r=Up(t,o.rootName),a=Up(n,o.rootName);if(!r||!a)return n;const i=Np(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&$p(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of Np(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||$p(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=Hp(c,"type");if(t){n&&Lp.has(n)?a.replaceChild(c.cloneNode(!0),t):_p(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=Hp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new qd.XMLSerializer).serializeToString(a.ownerDocument)}var Xp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Yp="word/numbering.xml";function qp(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 Zp(e){return e.localName??e.tagName}function Jp(e){return`${e.namespaceURI??""}\0${Zp(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 eg(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(Xp,`w:${t}`,n)}function tg(e,t){return qp(e).find(e=>e.namespaceURI===Xp&&Zp(e)===t)}function ng(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 og(e,t){const n=new Set(qp(t).map(Jp));for(const o of qp(e))o.namespaceURI===Xp||n.has(Jp(o))||t.appendChild(o.cloneNode(!0))}function rg(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 ag=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function ig(e,t){ng(e,t);const n=qp(e),o=new Map(qp(t).map(e=>[Jp(e),e]));n.forEach((e,r)=>{const a=Jp(e),i=o.get(a),l=Zp(e);if(i)return ng(e,i),void(e.namespaceURI===Xp&&"rPr"===l?function(e,t){ng(e,t);const n=qp(e),o=new Map(qp(t).map(e=>[Jp(e),e]));n.forEach((e,r)=>{const a=Jp(e),i=o.get(a);if(i)return ng(e,i),void og(e,i);e.namespaceURI===Xp&&"rFonts"===Zp(e)||rg(n,r,e,t,e=>o.get(Jp(e)))})}(e,i):og(e,i));if(e.namespaceURI!==Xp||!ag.has(l)){if(e.namespaceURI===Xp&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of qp(e))o.namespaceURI===Xp&&"rFonts"===Zp(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}rg(n,r,e,t,e=>o.get(Jp(e)))}})}function lg(e){return function(e){return e.namespaceURI===Xp&&"lvl"===Zp(e)?`${Jp(e)}\0${Qp(e,"ilvl")??"0"}`:Jp(e)}(e)}function sg(e,t,n){const o=tg(t,"abstractNumId"),r=o?Qp(o,"val"):void 0;if(!r)return;const a=qp(e).find(e=>e.namespaceURI===Xp&&"abstractNum"===Zp(e)&&Qp(e,"abstractNumId")===r);return a?qp(a).find(e=>e.namespaceURI===Xp&&"lvl"===Zp(e)&&(Qp(e,"ilvl")??"0")===n):void 0}function cg(e,t){const n=t.cloneNode(!0);ig(e,n);const o=tg(e,"pPr"),r=tg(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function dg(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=Qp(tg(t,"start")??t,"val")??"1";for(const r of qp(e)){const e=Zp(r);if(r.namespaceURI===Xp&&"startOverride"===e){const e=r.cloneNode(!0);eg(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==Xp||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(cg(r,t))}return n}function ug(e){if(e.namespaceURI!==Xp)return Jp(e);const t=Zp(e);return"abstractNum"===t?`${Jp(e)}\0${Qp(e,"abstractNumId")??""}`:"num"===t?`${Jp(e)}\0${Qp(e,"numId")??""}`:Jp(e)}function pg(e,t){const n=function(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new qd.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===Xp&&o.namespaceURI===Xp&&"numbering"===Zp(n)&&"numbering"===Zp(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;ng(o,r);const a=qp(o),i=new Map(qp(r).map(e=>[ug(e),e]));return a.forEach((e,t)=>{const n=ug(e),o=i.get(n),l=Zp(e);if(o)return ng(e,o),void(e.namespaceURI===Xp&&"abstractNum"===l?function(e,t){ng(e,t);const n=qp(e),o=new Map(qp(t).map(e=>[lg(e),e]));n.forEach((e,r)=>{const a=lg(e),i=o.get(a);if(i)return ng(e,i),void(e.namespaceURI===Xp&&"lvl"===Zp(e)?ig(e,i):og(e,i));rg(n,r,e,t,e=>o.get(lg(e)))})}(e,o):e.namespaceURI===Xp&&"num"===l?function(e,t,n){ng(e,t);const o=tg(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of qp(t))a.namespaceURI===Xp&&"lvlOverride"===Zp(a)&&r.set(Qp(a,"ilvl")??"0",a);for(const a of qp(e)){const e=Zp(a);if(a.namespaceURI!==Xp||"abstractNumId"!==e){if(a.namespaceURI===Xp&&"lvlOverride"===e){const e=Qp(a,"ilvl")??"0",o=dg(a,sg(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===Xp||qp(t).some(e=>Jp(e)===Jp(a))||t.appendChild(a.cloneNode(!0))}else o&&(ng(a,o),og(a,o))}}(e,o,r):og(e,o));rg(a,t,e,r,e=>i.get(ug(e)))}),(new qd.XMLSerializer).serializeToString(r.ownerDocument)}async function gg(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(Yp);if(!n||!o)return!1;const r=await o.async("string"),a=pg(n,r);return a!==r&&(t.file(Yp,a),!0)}var fg=[{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 mg(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 hg="http://schemas.openxmlformats.org/wordprocessingml/2006/main",bg=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function yg(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 vg(e){return e.localName??e.tagName}function xg(e){return`${e.namespaceURI??""}\0${vg(e)}`}function wg(e){const t=[],n=e=>{for(const o of yg(e))o.namespaceURI===hg&&"sectPr"===vg(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function Sg(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 Ig(e){return e.namespaceURI===hg&&bg.has(vg(e))}function Cg(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml"),o=(new qd.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=wg(n),l=wg(o);return 0===i.length||i.length!==l.length?t:(Sg(r,a),i.forEach((e,t)=>{!function(e,t){Sg(e,t);const n=yg(e),o=yg(t),r=/* @__PURE__ */new Map;for(const i of o){const e=xg(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=xg(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){Sg(e,s);continue}if(Ig(e))continue;const c=n.slice(i+1).map(e=>r.get(xg(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new qd.XMLSerializer).serializeToString(o))}var Tg="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function kg(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 Pg(e){return e.localName??e.tagName}function Rg(e,t){const n=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Tg&&Pg(n)===t?n:void 0}function Bg(e){return kg(e).length>0?(new qd.XMLSerializer).serializeToString(e.ownerDocument):void 0}var Mg=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),Ag=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Fg(e){const t=Rg(e,"settings");if(!t)return e;for(const n of[...kg(t)]){if(n.namespaceURI!==Tg)continue;const e=Pg(n);if(Mg.has(e)){t.removeChild(n);continue}const o=Ag.get(e);if(o){for(const e of[...kg(n)])e.namespaceURI===Tg&&o.has(Pg(e))&&n.removeChild(e);0===kg(n).length&&t.removeChild(n)}}return Bg(t)}function Og(e){const t=Rg(e,"styles");if(!t)return e;for(const n of[...kg(t)])n.namespaceURI===Tg&&"style"===Pg(n)&&t.removeChild(n);return Bg(t)}function Dg(e){const t=Rg(e,"fonts");if(!t)return e;for(const n of[...kg(t)])n.namespaceURI===Tg&&"font"===Pg(n)&&t.removeChild(n);return Bg(t)}async function Eg(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 Lg="word/styles.xml";function Ng(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 $g(e){return e.localName??e.tagName}function zg(e){return`${e.namespaceURI??""}\0${$g(e)}`}function Hg(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 Wg(e,t){return Ng(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&$g(e)===t)}function Ug(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===$g(e)?`${zg(e)}\0${Hg(e,"type")??""}`:zg(e)}function jg(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===$g(t)?t:void 0}function Vg(e,t){const n=Wg(e,"pPr");if(!n)return!1;const o=Wg(t,"pPr"),r=new qd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=ar(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 qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===$g(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=Ng(e),a=r.indexOf(n),i=Ng(t),l=new Map(i.map(e=>[Ug(e),e])),s=r.slice(a+1).map(e=>l.get(Ug(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function Kg(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(Lg);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 Ng(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==$g(i))continue;const e=Hg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Ng(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==$g(i))continue;const e=Hg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Vg(i,t)||a)}return a?(new qd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Lg,a),!0)}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 Gg(e){return e.localName??e.tagName}function Xg(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 Yg(e,t){const n=function(e){if(!e)return;const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Gg(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${ur}" xmlns:w14="${no}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};v(r,`<w:r xmlns:w="${ur}" xmlns:w14="${no}">${e}<w:t/></w:r>`);const a=function(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===Gg(t)?t:void 0}(Rr(r,o));if(!a)return t;let i=_g(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===Gg(e));return!i&&Xg(n)&&(i=a.ownerDocument.createElementNS(ur,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(Kn(n,i),0!==_g(i).length||Xg(i)?(new qd.XMLSerializer).serializeToString(i):""):""}var qg="word/styles.xml";function Zg(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 Jg(e){return e.localName??e.tagName}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 ef(e,t){return Zg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Jg(e)===t)}function tf(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Jg(t)?t:void 0}function nf(e,t){const n=ef(e,"rPr");if(!n)return!1;const o=ef(t,"rPr"),r=new qd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=Yg(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 qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Jg(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=Zg(e),a=r.indexOf(n),i=Zg(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&Jg(t)===Jg(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function of(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(qg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=tf(e),o=tf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Zg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Jg(i))continue;const e=Qg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Zg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Jg(i))continue;const e=Qg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=nf(i,t)||a)}return a?(new qd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(qg,a),!0)}var rf="word/styles.xml",af=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);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){return`${e.namespaceURI??""}\0${sf(e)}`}function df(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 uf(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 pf(e,t){return lf(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&sf(e)===t)}function gf(e){return e?(new qd.XMLSerializer).serializeToString(e):""}function ff(e,t){if(!e)return;const n=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&sf(n)===t?n:void 0}function mf(e,t,n){switch(e){case"pPr":return ar(t,n);case"rPr":return Yg(t,n);case"tblPr":return Ho(t,n);case"trPr":return Hr(t,n);case"tcPr":return zn(t,n);default:return n}}function hf(e,t,n,o){const r=lf(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&af.has(sf(e)));return i?pf(t,sf(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===sf(e)&&af.has(o)?lf(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===sf(e))??null:null}function bf(e,t,n){const o=pf(e,n);if(!o)return!1;const r=pf(t,n),a=gf(r),i=mf(n,gf(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=ff(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,hf(e,t,o,n)),!0)}function yf(e,t){uf(e,t);let n=!1;for(const r of af)n=bf(e,t,r)||n;const o=new Set(lf(t).map(cf));for(const r of lf(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&af.has(sf(r))||o.has(cf(r))||(t.appendChild(r.cloneNode(!0)),o.add(cf(r)),n=!0);return n}function vf(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(ur,"w:tblStylePr");uf(e,n);let o=!1;for(const r of lf(e)){const e=sf(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&af.has(e)){const t=ff(mf(e,gf(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function xf(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==sf(e))return;const t=df(e,"type");return t?`tblStylePr:${t}`:void 0}function wf(e,t){let n=!1;n=bf(e,t,"tblPr")||n;const o=lf(e).filter(e=>void 0!==xf(e)),r=/* @__PURE__ */new Map;for(const a of lf(t)){const e=xf(a);e&&r.set(e,a)}for(const a of o){const o=xf(a),i=r.get(o);if(i){n=yf(a,i)||n;continue}const l=vf(a);if(!l)continue;const s=lf(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==xf(e)),u=d?r.get(xf(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function Sf(e){const t=(new qd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===sf(t)?t:void 0}async function If(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(rf);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Sf(e),o=Sf(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)){const e=df(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;if("table"!==df(i,"type"))continue;const e=df(i,"styleId"),t=e?r.get(e):void 0;t&&(a=wf(i,t)||a)}return a?(new qd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(rf,a),!0)}var Cf="http://schemas.openxmlformats.org/wordprocessingml/2006/main";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 kf(e){return e.localName??e.tagName}function Pf(e){return`${e.namespaceURI??""}\0${kf(e)}`}function Rf(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 Bf(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 Mf(e,t,n){const o=(new qd.DOMParser).parseFromString(e,"application/xml"),r=(new qd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===Cf&&i.namespaceURI===Cf&&kf(a)===n&&kf(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Af(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 Ff(e,t){const n=new Set(Tf(t).map(Pf));for(const o of Tf(e))o.namespaceURI===Cf||n.has(Pf(o))||t.appendChild(o.cloneNode(!0))}var Of=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var Df=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Ef(e){return e.namespaceURI===Cf&&"tblStylePr"===kf(e)?`${Pf(e)}\0${Rf(e,"type")??""}`:Pf(e)}function Lf(e){return e.namespaceURI===Cf&&"style"===kf(e)?`${Pf(e)}\0${Rf(e,"styleId")??""}`:Pf(e)}var Nf=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function $f(e){return e.namespaceURI===Cf&&"font"===kf(e)?`${Pf(e)}\0${Rf(e,"name")??""}`:Pf(e)}var zf=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=Mf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Bf(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=Tf(o),l=new Map(Tf(r).map(e=>[Pf(e),e]));return i.forEach((e,t)=>{const n=Pf(e),o=l.get(n),s=kf(e),c=e.namespaceURI===Cf?a.get(s):void 0;if(o)return Bf(e,o),void(c?function(e,t,n){Bf(e,t);const o=Tf(t),r=new Map(o.map(e=>[Pf(e),e])),a=Tf(e);a.forEach((e,o)=>{const i=Pf(e),l=r.get(i);if(l)return Bf(e,l),void Ff(e,l);e.namespaceURI===Cf&&n.has(kf(e))||Af(a,o,e,t,e=>r.get(Pf(e)))})}(e,o,c):Ff(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Tf(e))r.namespaceURI===Cf&&t.has(kf(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(Pf(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===Cf&&Of.has(s)||Af(i,t,e,r,e=>l.get(Pf(e)))}),(new qd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=Mf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Bf(o,r);const a=Tf(o),i=new Map(Tf(r).map(e=>[Lf(e),e]));return a.forEach((e,t)=>{const n=Lf(e),o=i.get(n);if(o)return Bf(e,o),void(e.namespaceURI===Cf&&"style"===kf(e)?function(e,t){Bf(e,t);const n=Tf(e),o=new Map(Tf(t).map(e=>[Ef(e),e]));n.forEach((e,r)=>{const a=Ef(e),i=o.get(a);if(i)return Bf(e,i),void Ff(e,i);e.namespaceURI===Cf&&Df.has(kf(e))||Af(n,r,e,t,e=>o.get(Ef(e)))})}(e,o):Ff(e,o));Af(a,t,e,r,e=>i.get(Lf(e)))}),(new qd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=Mf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Bf(o,r);const a=Tf(o),i=new Map(Tf(r).map(e=>[$f(e),e]));return a.forEach((e,t)=>{const n=$f(e),o=i.get(n);if(o)return Bf(e,o),void(e.namespaceURI===Cf&&"font"===kf(e)&&function(e,t){Bf(e,t);const n=Tf(e),o=new Map(Tf(t).map(e=>[Pf(e),e]));n.forEach((e,r)=>{const a=Pf(e),i=o.get(a);i?Bf(e,i):e.namespaceURI===Cf&&Nf.has(kf(e))||Af(n,r,e,t,e=>o.get(Pf(e)))})}(e,o));Af(a,t,e,r,e=>i.get($f(e)))}),(new qd.XMLSerializer).serializeToString(r.ownerDocument)}}];function Hf(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 Wf="word/document.xml";function Uf(e){const t=(new qd.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 pp(e,t);const r=await Yd.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 zf){const r=Hf(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 gg(n,r)||l),i.styles&&(l=await Kg(n,r)||l,l=await of(n,r)||l,l=await If(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await Eg(e,"word/settings.xml",Fg)||n),t.styles||(n=await Eg(e,"word/styles.xml",Og)||n),t.fontTable||(n=await Eg(e,"word/fontTable.xml",Dg)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of fg){const r=mg(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=Bu(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 Dp){const a=Wp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=Gp(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await su(n,r)||l,l=await async function(e,t){const n=hu(e,"/comments"),o=hu(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(du);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=xu(n,o,i,l);return s!==l&&(t.file(du,s),!0)}(n,r)||l,l=await Yu(n,r)||l,l=await Uu(n,r)||l;const s=await(r.file(Wf)?.async("string"));if(!s||Uf(o.data)!==Uf(s)){return pp(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=Cg(o.data,s);c!==s&&(r.file(Wf,c),l=!0);return Op(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function Vf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function Kf(e){const t=(new qd.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 _f(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 Gf(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 Xf(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 Yf(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=Vf(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=Kf(r.data);if(a&&Vf(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 qd.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=_f(i[0]);if(!s||1!==s.index)return null;if(!Gf(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=_f(i[m]);if(!e)return null;const t=Xf(c).filter(t=>Gf(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(Xf(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 qd.XMLSerializer).serializeToString(r.document),!0)}function qf(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 Zf(e){return e.blocks.map(Qf).filter(Boolean).join("\n")}function Jf(e){return e.cells.map(Zf).filter(Boolean).join("\t")}function Qf(e){return"paragraph"===e.type?J(e):e.rows.map(Jf).filter(Boolean).join("\n")}function em(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])qf(t,e,n.text,"");"textBox"===n.kind&&nm(n.textBox.blocks,t)}}function tm(e,t){for(const n of e.rows){const e=Jf(n);for(const o of n.sdtWrappers??[])qf(t,o,e,"\n");for(const o of n.cells){const e=Zf(o);for(const n of o.sdtWrappers??[])qf(t,n,e,"\n");nm(o.blocks,t)}}}function nm(e,t){if(e)for(const n of e){const e=Qf(n);for(const o of n.sdtWrappers??[])qf(t,o,e,"\n");"paragraph"===n.type?em(n,t):tm(n,t)}}async function om(e){if(!e.sourcePackage)return oe(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 qe(e))nm(o.blocks,t),nm(o.header,t),nm(o.firstPageHeader,t),nm(o.evenPageHeader,t),nm(o.footer,t),nm(o.firstPageFooter,t),nm(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&Yf(e.sourcePackage,t,r)&&(n+=1)}}(t);return jf(t,await oe(t))}async function rm(e){if(!e.sourcePackage)return Dt(e);const t=await om(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function am(e){switch(e){case"dashed":return[nn(5),nn(3)];case"dotted":return[nn(1),nn(3)];default:return}}async function im(e,t,o,r,a,i,l,s){const c=t.rotation;c&&(e.saveGraphicsState(o.pageIndex),e.rotateAbout(o.pageIndex,nn(r+i/2),nn(a+l/2),c)),function(e,t,o,r,a,i,l){const s=n(o.shape?.preset,nn(r),nn(a),nn(i),nn(l)),c=o.shape?.fill,d=o.shape?.borderColor,u=o.shape?.borderWidthPt??(d?.75:0);e.drawPath(t,{segments:s,fill:c,stroke:d&&u>0?d:void 0,lineWidth:u})}(e,o.pageIndex,t,r,a,i,l),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=Uo({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=b(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,nn(c),nn(d),nn(u),nn(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:Cr(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,o,r,a,i,l,s),c&&e.restoreGraphicsState(o.pageIndex)}async function lm(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=gr({object:ro(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await im(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var sm=/* @__PURE__ */new WeakMap;function cm(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 dm(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=cm(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?cm(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 um(e,t,n){const o=$(t,n.src);if(!o)return null;let r=sm.get(e);r||(r=/* @__PURE__ */new Map,sm.set(e,r));const a=r.get(o);if(a)return a;const i=dm(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 pm(e,t,r,a,i,l,s,c){const d=await um(e,r,a);if(!d)return;const u=a.intrinsicWidth??a.width,p=a.intrinsicHeight??a.height,g=u/Math.max(1,p),f=s/Math.max(1,c);let m=i,h=l,b=s,y=c;"fit"===a.cropFit&&g>0&&(g>f?(y=s/g,h+=(c-y)/2):(b=c*g,m+=(s-b)/2));const v="fill"!==a.cropFit||a.crop?a.crop:(()=>{if(g>f){const e=f/g,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(g<f){const e=g/f,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),x=a.cropShape?.preset,w=x?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}})}(n(x,i,l,s,c),i,l,s,c,a.rotation??0):null,S=a.transparency??0,I="fit"===a.cropFit&&Boolean(a.rotation);w&&(e.saveGraphicsState(t),e.clipPath(t,w)),I&&(e.saveGraphicsState(t),e.rotateAbout(t,i+s/2,l+c/2,a.rotation??0)),S>0&&e.saveGraphicsState(t),S>0&&e.setOpacity(t,1-Math.min(1,S)),e.drawImage(t,{resourceName:d,x:m,y:h,width:b,height:y,rotation:I?void 0:a.rotation,crop:v}),S>0&&e.restoreGraphicsState(t),I&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t);const C=a.border;if(!C)return;const T=a.rotation;T&&!w&&(e.saveGraphicsState(t),e.rotateAbout(t,i+s/2,l+c/2,T));const k=o(C.dash);w?e.drawPath(t,{segments:w,stroke:C.color,lineWidth:C.widthPt??1}):e.drawRect(t,{x:i,y:l,width:s,height:c,stroke:C.color,lineWidth:C.widthPt??1,...k.length>0?{dashArray:k}:{}}),T&&!w&&e.restoreGraphicsState(t)}function gm(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 fm(e,t,n){const o=gm(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 mm(e,t,n,o,r,a,i){const l=fm(e,t,n.fontSize??14.6667);return l?{x:nn(o+l.left),y:nn(r+e.top+a),width:nn(Math.max(0,l.right-l.left)),height:nn(Math.max(2,e.height-i))}:null}function hm(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=fm(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=Jt(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:nn(g.x0),y0:nn(g.y0),x1:nn(g.x1),y1:nn(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function bm(e,t,n,o,r,a,i){const l=_(i),s=(r,i)=>{e.drawLine(t,{x1:nn(n),y1:nn(r),x2:nn(o),y2:nn(r),stroke:a,lineWidth:nn(l),dashArray:i})};if(Nt(i))return s(r-ge),void s(r+ge);Q(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)*p;e.drawLine(t,{x1:nn(l),y1:nn(s),x2:nn(c),y2:nn(o),stroke:a,lineWidth:nn(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,Vt(i))}function ym(e,t){const n=Tn(So(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 vm(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=nn(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:nn(t)+u*e,y:nn(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*nn(e.radiusPt*Wr),l=ym(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:nn(t)+c,y:nn(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=nn(e.distPt*Wr);o.drawText(r,{...d,x:nn(t)+Math.cos(i)*l,y:nn(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:nn(t)+u,y:nn(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=ym(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:nn(t),y:nn(a)+nn(e.distPt*Wr)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:nn(t),y:nn(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 xm(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=gr({object:Gn(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 pm(e.writer,e.pageIndex,e.document,r,nn(l.x),nn(l.y),nn(l.width),nn(l.height))}}}function wm(e,t,n,o,r,a,i,l){const s=fm(n,o,i.fontSize??14.6667);if(!s)return;const c=a+an(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:nn(d),y1:nn(c-yr),x2:nn(u),y2:nn(c-yr),stroke:p,lineWidth:nn(1)}),void e.drawLine(t,{x1:nn(d),y1:nn(c+yr),x2:nn(u),y2:nn(c+yr),stroke:p,lineWidth:nn(1)})):void bm(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:nn(d),y1:nn(c),x2:nn(u),y2:nn(c),stroke:p,lineWidth:nn(1)})}async function Sm(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 pm(e,t,a,r.image,nn(i+n.left),nn(l+o.top+o.height-r.image.height),nn(r.image.width),nn(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 im(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=st(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:nn(i+c.left),y:nn(l+o.top+o.height*et),text:kt(r.math),fontSize:Yt(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=st(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=Yt(d),g=(d.baselineShift??0)*Wr,f=Te(n.style,a.styles),m=se(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*et-g+m,b=gm(o,r),y=b.map(e=>No(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=fm(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:nn(r+l.left),y:nn(a+n.top),width:nn(l.right-l.left),height:nn(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=mm(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=mm(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=mm(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:nn(Math.max(.5,l.width*Wr))})}(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=Te(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*Wr})).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:nn(i+n.left),y1:nn(m),x2:nn(i+r.left),y2:nn(m),stroke:s,lineWidth:nn("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=Te(n.style,a.styles).align??"left",x=Mt(d,Yt(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=>No(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;vm({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&Xe(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&&vm(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:hm(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&wm(e,t,o,r,i,l,d,"underline"),d.strike&&wm(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&wm(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=xa[l];if(!s)return;const c=gm(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:nn(r+l-.25*u),y:nn(p),text:s,fontSize:nn(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function Im(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=Jr(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=st(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=na(n,r.styles),f=Yt(u),m=c.length*f*.62*Wr,h=w(n,r.styles,d.left,m);e.drawText(t,{x:nn(a+Math.max(0,h||g)),y:nn(i+o.top+o.height*et),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Cm(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=Re(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:nn(p),y:nn(a),width:nn(Math.max(0,g-p)),height:nn(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:nn(n),y1:nn(o),x2:nn(r),y2:nn(i),stroke:h.color,lineWidth:h.width,dashArray:am(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:nn(p),y1:nn(a),x2:nn(p),y2:nn(f),stroke:m.color,lineWidth:m.width,dashArray:am(m.type)})}async function Tm(e,t,n,o,r,a,i,l,s,c){for(const d of o){Im(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await Sm(e,t,n,d,o,r,a,i,l,c)}}function km(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:nn(o),y1:nn(r),x2:nn(a),y2:nn(i),stroke:n.color,lineWidth:nn(n.width),dashArray:am(n.type)})}function Pm(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;km(e,t,n.borders.top,a,i,l,i),km(e,t,n.borders.right,l,i,l,s),km(e,t,n.borders.bottom,a,s,l,s),km(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&km(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&km(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function Rm(e,t,n,o,r,a,i,l,s,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?sn(d,n.tableSegment):d;if(0===u.rows.length)return;const p=Zn({table:u,state:{document:o},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:n.estimatedHeight});for(const g of p.cells)g.shading&&e.drawRect(t,{x:nn(r+g.left),y:nn(a+g.top),width:nn(g.width),height:nn(g.height),fill:g.shading});for(const g of p.cells)if(Pm(e,t,g,r,a),g.revision){const n="insert"===g.revision.type?"#059669":"delete"===g.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:nn(r+g.left+1),y:nn(a+g.top+1),width:nn(Math.max(0,g.width-2)),height:nn(Math.max(0,g.height-2)),stroke:n,lineWidth:nn(2)})}for(const g of p.cells)for(const n of g.paragraphs)await Tm(e,t,n.paragraph,n.lines,o,r+n.originX,a+n.originY,l,s,c)}var Bm={drawParagraph:Tm,drawTableBlock:Rm};async function Mm(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=Te(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+Re(n).top;Cm(e,t,n,f.layout.lines,r,g,i),c&&(await xm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await lm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Bm,layer:"behind"})),await Tm(e,t,f.sourceBlock,f.layout.lines,o,r,m,l,s,Bm),c&&(await xm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await lm({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Bm,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Er(f.sourceBlock,i),a=Xo({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 Rm(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,l,s,Bm);break}await Rm(e,t,f,o,r,p,i,l,s,Bm);break;default:Cr(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=Te(f.sourceBlock.style,o.styles),s=Te(l.sourceBlock.style,o.styles);if(pt(n,s)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+Re(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:nn(c),y1:nn(s),x2:nn(d),y2:nn(s),stroke:u.color,lineWidth:u.width,dashArray:am(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function Am(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 um(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 Fm=[{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 Om(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function Dm(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Em=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Fm)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Om(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=Y(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(Om(t,n,o))??this.faces.get(Om(this.fallbackFamily,n,o))??this.faces.get(Om(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(Y).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(Ot)){const e=await Gt(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 c(e.families);for(const n of t){const e=`Remote${Dm(n.postscriptName||n.family)}`;this.registerFontFace({key:Om(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 ne){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 Gt(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${Dm(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}},Lm="%PDF-1.4\n% Oasis PDF\n",Nm=[{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 $m(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function zm(e){return(new TextEncoder).encode(e).byteLength}function Hm(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function Wm(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Um(e,t){if(!e)return t;const n=Tn(So(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function jm(e,t,n){const[o,r,a]=Um(e,n);return`${$m(o)} ${$m(r)} ${$m(a)} ${t}`}function Vm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var Km=/* @__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 _m(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:Km.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function Gm(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(Wm).join("")}function Xm(e){return Wm(e)}function Ym(e){return`% OasisText ${Gm(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function qm(e){return e&&0!==e.length?`[${e.map(e=>$m(e)).join(" ")}] 0 d`:null}var Zm=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(`${$m(e.lineWidth??1)} w`);const t=qm(e.dashArray);t&&n.push(t)}n.push([$m(e.x),$m(t.height-e.y-e.height),$m(e.width),$m(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=qm(e.dashArray),o=["q",jm(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${$m(e.lineWidth??1)} w`,`${$m(e.x1)} ${$m(t.height-e.y1)} m`,`${$m(e.x2)} ${$m(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(`${$m(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${$m(r.x)} ${$m(n(r.y))} m`);break;case"line":o.push(`${$m(r.x)} ${$m(n(r.y))} l`);break;case"cubic":o.push(`${$m(r.x1)} ${$m(n(r.y1))} ${$m(r.x2)} ${$m(n(r.y2))} ${$m(r.x)} ${$m(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(`${$m(i)} ${$m(l)} ${$m(-l)} ${$m(i)} ${$m(s)} ${$m(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${$m(e)} ${$m(r.height-t-o)} ${$m(n)} ${$m(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(`${$m(r.x)} ${$m(n(r.y))} m`);break;case"line":o.push(`${$m(r.x)} ${$m(n(r.y))} l`);break;case"cubic":o.push(`${$m(r.x1)} ${$m(n(r.y1))} ${$m(r.x2)} ${$m(n(r.y2))} ${$m(r.x)} ${$m(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):`<${_m(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${$m(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${$m(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${$m(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([Ym(n.text),"BT",jm(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[jm(n.strokeColor??n.color,"RG",[0,0,0]),`${$m(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${$m(n.x)} ${$m(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([Ym(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${$m(n.x)} ${$m(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",[$m(e.width),"0","0",$m(e.height),$m(e.x),$m(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",[$m(p),$m(g),$m(f),$m(m),$m(h),$m(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",[$m(h),$m(b),$m(y),$m(v),$m(x),$m(w),"cm"].join(" "),`0 0 ${$m(a)} ${$m(i)} re W n`,[$m(l),"0","0",$m(s),$m(c),$m(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function Jm(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function Qm(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function eh(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function th(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 nh(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=Qm(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 oh(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:Qm(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 rh(e,t,n){return e.seek(t),eh(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=eh(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 ah(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 ih(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=eh(e,o,t).map(t=>(e.seek(t),Qm(e,e.u16())));return{coverage:th(e,n),sets:r}}function lh(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 sh(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function ch(e,t){e.seek(t);const n=e.u16();return eh(e,n,t).map(t=>(e.seek(t),{backtrack:Qm(e,e.u16()),input:Qm(e,Math.max(0,e.u16()-1)),lookahead:Qm(e,e.u16()),records:lh(e,e.u16())}))}function dh(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 sh(t,n,i.records,o),e}}}return null}function uh(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=th(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=Qm(e,t),r=th(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=ih(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=ih(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=eh(e,o,t).map(t=>(e.seek(t),eh(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:Qm(e,Math.max(0,o-1))}}))),a=th(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=eh(e,e.u16(),t),o=eh(e,e.u16(),t),r=eh(e,e.u16(),t),a=lh(e,e.u16()),i=n.map(t=>th(e,t)),l=o.map(t=>th(e,t)),s=r.map(t=>th(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 sh(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=eh(e,o,t),a=th(e,n),i=r.map(t=>ch(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:dh(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=th(e,n),c=nh(e,o),d=nh(e,r),u=nh(e,a),p=l.map(t=>0===t?[]:ch(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?dh(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return Jm(e,t,uh);default:return null}}var ph=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new We(t),{featureToLookups:o,lookupListOffset:r}=oh(n),a=rh(n,r,uh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return ah(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 gh(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 fh(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function mh(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=gh(e,e.u16()),n=th(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=fh(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=gh(e,t);const l=th(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=eh(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=gh(e,r),i=gh(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=th(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=fh(r),u=d+fh(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]=gh(e,r),e.seek(p+o+d),f[t*c+n]=gh(e,a)}const m=th(e,o),h=nh(e,n),b=nh(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 Jm(e,t,mh);default:return null}}var hh=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new We(t),{featureToLookups:o,lookupListOffset:r}=oh(n),a=rh(n,r,mh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=ah(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}}}},bh=/* @__PURE__ */new Set(["kern"]),yh=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?ph.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?hh.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=>!bh.has(e))??[],r=t?.filter(e=>bh.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}}},vh=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 xh(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function wh(e,t){return xh(e).getUint16(t)}function Sh(e,t,n){xh(e).setUint16(t,n,!1)}function Ih(e,t,n){xh(e).setUint32(t,n,!1)}function Ch(e){return e+3&-4}function Th(e){const t=e.reduce((e,t)=>e+Ch(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=Ch(r.byteLength);return n}function kh(e,t){const n=[],o=xh(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 Ph(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function Rh(e,t){if(e.byteLength<10||function(e,t){return xh(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=wh(e,n),t(wh(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 Bh(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>Ih(t,4*n,e)),t}function Mh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)Sh(n,4*o,e.advanceWidthForGlyph(o)),Sh(n,4*o+2,0);return n}var Ah=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=kh(o,wh(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=Ph(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||Rh(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=kh(o,wh(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=Ph(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=Ch(t.byteLength)}}u.push(g);const f=r.slice();Ih(f,8,0),Sh(f,50,1);const m=a.slice();Sh(m,34,s+1);const h=i.slice();Sh(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:Mh(e,s),loca:Bh(u),maxp:h,glyf:Th(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=xr(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 Fh=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 yh(e);return{program:e,layouter:t.hasShaping?t:new vh(e),subsetter:new Ah}}(function(e){const t=Se.decodeSync(e);return Ee.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?`<${Xm(e.glyphId)}>`:`<${Xm(e.glyphId)}> ${$m(t)}`}).join(" ")}] TJ`:`<${r.map(e=>Xm(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=`${Hm(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${zm(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=`${Vm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Vm(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($m).join(" ")}]`,`/ItalicAngle ${$m(r.italicAngle)}`,`/Ascent ${$m(r.ascent*e.scale)}`,`/Descent ${$m(r.descent*e.scale)}`,`/CapHeight ${$m(r.capHeight*e.scale)}`,`/XHeight ${$m(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=>$m(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${zm(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${Gm(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(`<${Wm(o)}> <${Wm(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"))}},Oh=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=`${Hm(e)}>`;return[`<< /Length ${zm(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"]))}},Dh=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 Eh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Eh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>$m(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:Um(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($m).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Eh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map($m).join(" ")}]`,`/C1 [${t.map($m).join(" ")}]`,"/N 1",">>"].join("\n")}var Lh=new TextEncoder;function Nh(e){return"string"==typeof e?zm(e):e.length}function $h(e){const t=e.reduce((e,t)=>e+Nh(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Lh.encode(r):r;n.set(e,o),o+=e.length}return n}function zh(e){const t=me(Lh.encode(e));return $h([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function Hh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function Wh(e){return`<FEFF${Gm(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Uh(e){const t=[];if(e.title&&t.push(`/Title ${Wh(e.title)}`),e.author&&t.push(`/Author ${Wh(e.author)}`),e.subject&&t.push(`/Subject ${Wh(e.subject)}`),e.keywords&&t.push(`/Keywords ${Wh(e.keywords)}`),e.producer&&t.push(`/Producer (${Hh(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 Vh(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 ${$m(t)} /CA ${$m(t)} >>`));const m=[];for(const B of e){const e=s(zh(`${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 (${Hh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Hh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${$m(t)} ${$m(o)} ${$m(n)} ${$m(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 ${$m(B.width)} ${$m(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`(${Hh(t.name)}) [${n} 0 R /XYZ ${$m(t.x)} ${$m(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 "+Wh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${Hh(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=Uh(i);e&&(w=s(e))}const S=[Lm];let I=Nh(Lm);const C=[0],T=e=>{S.push(e),I+=Nh(e)};for(const B of l)C[B.id]=I,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const k=I;let P=`xref\n0 ${l.length+1}\n`;P+="0000000000 65535 f \n";for(const B of l)P+=`${String(C[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")),$h(S)}var Kh=class{pages=[];streams=[];fonts;images=new Oh;shadings=new Dh;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=Nm){this.fonts=new Fh(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 Zm(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}),Vh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function _h(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=nn(i),s=nn(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 Gh(e){e=cn(e);const t=new Em,n=Ia(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new Kh(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=To(e),a=function(e){return b(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(ia(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,nn(s.pageSettings.width)),r=Math.max(1,nn(s.pageSettings.height)),c=o.addPage({width:n,height:r});await Am(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=on(s.pageSettings);await Mm(o,c,s.headerBlocks,e,d,s.headerTop??qt(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??hr(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=ue(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 Mm(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,_h(o,c,r.left,i,l))}}else await Mm(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,_h(o,c,d,i,l));await Mm(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:nn(d),y1:nn(s.footnoteSeparatorTop+.5),x2:nn(d+Math.min(180,.35*u)),y2:nn(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:nn(1)}),await Yh(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 Am(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function Xh(e){const t=await Gh(e);return new Blob([t],{type:"application/pdf"})}async function Yh(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,Rn(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=st(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:nn(a),y:nn(d+12),text:o,fontSize:Yt(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await Mm(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function qh(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Zh(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 Jh(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 Qh(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 eb(e){return function(e){const t=Ve(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=Te(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=st(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=Te(t.style,e.styles),r=t.runs[0],a=st(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:J(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 tb(e,t){const n=to(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=pa(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 nb(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 ob(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function rb(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function ab(e){return"page"===e?.positionV?.relativeFrom}function ib(e){return tb(e,e=>"image"===e.kind)}function lb(e,t,n){return hb(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function sb(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function cb(e,t){return hb(e,e=>{const n={...e},o=function(e){if(!e)return;const t=sb(e.left),n=sb(e.top),o=sb(e.right),r=sb(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 db(e,t){const n=ib(e),o=n&&Dr(n.run);return o?cb(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=sb(a.left),l=sb(a.top),s=sb(a.right),c=sb(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 ub(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 pb(e){return hb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function gb(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function fb(e,t,n=90){const o=ib(e);if(!o||!Dr(o.run))return e;const r="right"===t?-n:n,a=gb(function(e){const t=ib(e);return(t&&Dr(t.run))?.rotation??0}(e)+r);return hb(e,e=>({...e,rotation:a}))}function mb(e,t){const n=function(e){const t=ib(e),n=t&&Dr(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?hb(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function hb(e,t){const n=ib(e);if(!n||!Dr(n.run))return e;const o=pa(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Yn(e))});return Ce(e,i,N(i,to(e)))}function bb(e,t){return hb(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function yb(e,t){const n=ib(e);if(!n)return e;const o=pa(e),{paragraphIndex:a,offset:i,run:l}=n,s=zr(o,t.paragraphId);if(s<0)return e;const c=o[s],u=jt(c,t),p=s===a&&u>i?u-1:u;if(s===a&&p===i)return e;const g=e=>Ut(e,[...Rt(e,0,i),...Rt(e,i+1,Lt(e))]),f=(e,t)=>d(e,Math.max(0,Math.min(t,Lt(e))),[Xr("",Z(e,t),Dr(l))]),m=o.map((e,t)=>t===a&&t===s?f(g(e),p):t===a?g(e):t===s?f(e,p):r([e])[0]),h=m[s],b=Math.max(0,Math.min(p+1,Lt(h)));return Ce(e,m,re(Bt(h,b)))}function vb(e,t,n,o=0){const r=on(ye(t));if(!n)return r;const a=Ur(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function xb(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await Jh(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=vb(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=Vn(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Le(n),i=Xr("",Z(o,a),t),l=d(o,a,[i]),s=pa(n).map((e,t)=>t===r?l:mn(e));return Ce(n,s,re(Bt(l,a+1)))}(n?Ma(e,{anchor:n,focus:n}):e,{src:r,width:g,height:f,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:Oi})}}}var wb={"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 Sb(e){return function(e){const[t,n]=gn(null),o=(e,t)=>{const[n,o]=wb[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=m(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 Jh(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:Ao(e.now()-a,2)});let l=null,s=-1,c=0;const d=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-c>=40))return;l=t,s=r??s,c=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",eb(d));const u=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(d),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:Ao(e.now()-u,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(Cn(d));const p=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Ao(e.now()-p,2)});const g=qe(d).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),f=Oo(d).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:g,paragraphs:f,durationMs:Ao(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=xb({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),s=function(e){const t=e.download??qh,n=e.print??Zh;let o=!1;return{handleExportDocx:async()=>{const n=await rm(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await Xh(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await Xh(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>rm(e.document()),exportPdfBlob:()=>Xh(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),c=async t=>{e.isReadOnly()||await i.handleImportFile(t)},d=async(e,t)=>{await l.insertImageFromFile(e,t)},u=async t=>{e.isReadOnly()||t&&(await d(t),e.focusInput())};return{importProgress:t,handleImportFile:c,handleExportDocx:async()=>s.handleExportDocx(),handleExportPdf:async()=>s.handleExportPdf(),handlePrint:async()=>s.handlePrint(),exportDocxBlob:s.exportDocxBlob,exportPdfBlob:s.exportPdfBlob,insertImageFromFile:d,handleInsertImage:u}}(e)}function Ib(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Cb(e){return" "===e||"\t"===e||"\n"===e}function Tb(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 kb(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=kb(n.blocks,t);if(e)return e}}return null}function Pb(e,t){const n=to(t),o=[],r=e.surfaceRect,a=new Map(pa(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 Ne(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=kb(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=kb(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=en(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=Tb(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&&Cb(Ib(w,e));)e+=1;for(;a>e&&Cb(Ib(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?jt(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}}function Rb(e,t){if(e)for(const n of e)if("paragraph"!==n.type)for(const e of n.rows)for(const n of e.cells)Rb(n.blocks,t);else t.push(n.id)}function Bb(e){const t=[],n=e=>{if(e)for(const o of e)if("paragraph"!==o.type)for(const e of o.rows)for(const t of e.cells)n(t.blocks);else for(const e of o.runs)t.push(e.text)};return n(e),t.join("").trim()}function Mb(e){return e.cells.flatMap(e=>e.blocks)}function Ab(e){return e.rows.flatMap(Mb)}function Fb(e){return{id:e.id,type:e.type,author:e.author,date:e.date}}function Ob(e){return{id:e.id,type:"property",author:e.author,date:e.date}}function Db(e){const t=[];return e.style?.revision&&t.push(Fb(e.style.revision)),e.style?.propertyRevision&&t.push(Ob(e.style.propertyRevision)),t}function Eb(e){const t=[];return e.style?.revision&&t.push(Fb(e.style.revision)),e.style?.propertyRevision&&t.push(Ob(e.style.propertyRevision)),e.propertyExceptionsRevision&&t.push(Ob(e.propertyExceptionsRevision)),t}function Lb(e){const t=[];return e.style?.revision&&t.push(Ob(e.style.revision)),e.gridRevision&&t.push({id:e.gridRevision.id,type:"grid",author:e.gridRevision.author,date:e.gridRevision.date}),t}function Nb(e){const t=[],n=/* @__PURE__ */new Set,o=(e,o,r,a,i,l)=>{if(n.has(e.id))return;n.add(e.id);const s=[];Rb(l,s),t.push({...e,scope:o,tableId:r,rowIndex:a,cellIndex:i,paragraphIds:s,snippet:Bb(l)})},r=e=>{if(e)for(const t of e)if("paragraph"!==t.type){for(const e of Lb(t))o(e,"table",t.id,void 0,void 0,Ab(t));t.rows.forEach((e,n)=>{for(const r of Eb(e))o(r,"row",t.id,n,void 0,Mb(e));e.cells.forEach((e,a)=>{for(const r of Db(e))o(r,"cell",t.id,n,a,e.blocks);r(e.blocks)})})}};for(const a of Ne(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])r(e);for(const a of Object.values(e.document.footnotes?.items??{}))r(a.blocks);for(const a of Object.values(e.document.endnotes?.items??{}))r(a.blocks);return t}function $b(e){const t=[],n=/* @__PURE__ */new Set;return Ne(e.document).forEach((e,o)=>{const r=e.propertyRevision;if(!r||n.has(r.id))return;n.add(r.id);const a=[];Rb(e.blocks,a);const i=Bb(e.blocks);t.push({id:r.id,type:"property",author:r.author,date:r.date,sectionId:e.id,sectionIndex:o,paragraphIds:a,snippet:i.length>96?`${i.slice(0,93)}…`:i})}),t}var zb={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments",formatting:"showMarkupFormatting"};function Hb(e,t){return e[zb[t]]??!0}function Wb(e,t){return"boolean"==typeof t.allAuthors?Kb(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=_b(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=_b(n);return Kb(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Xb(e)):t.section?function(e,t){const n=zb[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function Ub(e,t){return e.markupAuthors?.includes(t)??!0}function jb(e,t,n){return!("insert"===t&&!Hb(e,"insertions"))&&(!("delete"===t&&!Hb(e,"deletions"))&&(!("property"===t&&!Hb(e,"formatting"))&&Ub(e,n)))}function Vb(e){const t=/* @__PURE__ */new Map;for(const n of Nb(e))if(jb(e,n.type,n.author))for(const e of n.paragraphIds)t.has(e)||t.set(e,null);for(const n of function(e){const t=[];for(const n of $b(e))jb(e,n.type,n.author)&&t.push(...n.paragraphIds);return t}(e))t.has(n)||t.set(n,null);for(const n of Ve(e.document)){const o=[];let r=0;for(const t of n.runs){const n=t.text.length,a=t.revision,i="delete"===a?.type,l=t.styles?.propertyRevision;let s=!1;!a||"insert"!==a.type&&"delete"!==a.type?l&&(s=jb(e,"property",l.author)):s=jb(e,a.type,a.author),s&&(i?o.push({start:Math.max(0,r-1),end:r+1}):n>0&&o.push({start:r,end:r+n})),i||(r+=n)}if(0===o.length)continue;const a=t.get(n.id);void 0===a?t.set(n.id,o):null!==a&&t.set(n.id,[...a,...o])}return t}function Kb(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 _b(e){return[...new Set(e)].sort()}function Gb(e,t){for(const n of e.runs){const e=n.revision?.author??n.revisionRangeMarker?.author??n.styles?.propertyRevision?.author;e&&t.add(e)}}function Xb(e){const t=/* @__PURE__ */new Set,n=e=>{e&&t.add(e)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){n(r.style?.revision?.author),n(r.gridRevision?.author);for(const e of r.rows){n(e.style?.revision?.author),n(e.style?.propertyRevision?.author);for(const t of e.cells)n(t.style?.revision?.author),n(t.style?.propertyRevision?.author),o(t.blocks)}}else Gb(r,t)},r=Ve(e.document);for(const s of r)Gb(s,t);for(const s of Ne(e.document)){for(const e of[s.blocks,s.header,s.firstPageHeader,s.evenPageHeader,s.footer,s.firstPageFooter,s.evenPageFooter])o(e);n(s.propertyRevision?.author)}const a=e.document.footnotes?.items??{};for(const s of Object.values(a))o(s.blocks);const i=e.document.endnotes?.items??{};for(const s of Object.values(i))o(s.blocks);const l=e.document.comments?.items??{};for(const s of Object.values(l)){const e=s.author??s.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function Yb(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,l=r.styles?.propertyRevision;let s,c,d;if(!i||"insert"!==i.type&&"delete"!==i.type?l&&(s=l.id,c="property",d=l.author):(s=i.id,c=i.type,d=i.author),void 0!==s&&void 0!==c&&void 0!==d&&jb(t,c,d)&&a>e){const t=n.at(-1);t&&t.revisionId===s&&t.type===c&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:s,type:c})}}return n}function qb(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=Yb(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.push(...function(e,t){const{surfaceRect:n}=e,o=[],r=/* @__PURE__ */new Set;for(const i of e.paragraphs){const e=i.tableCell;if(!e)continue;const t=`${e.tableId}:${e.rowIndex}:${e.cellIndex}`;r.has(t)||(r.add(t),o.push({tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,left:e.left,top:e.top,width:e.width,height:e.height}))}const a=[];for(const i of Nb(t)){if(!jb(t,i.type,i.author))continue;const e=o.filter(e=>e.tableId===i.tableId&&("table"===i.scope||e.rowIndex===i.rowIndex&&("row"===i.scope||e.cellIndex===i.cellIndex)));if(0===e.length)continue;const r=Math.min(...e.map(e=>e.left)),l=Math.min(...e.map(e=>e.top)),s=Math.max(...e.map(e=>e.left+e.width)),c=Math.max(...e.map(e=>e.top+e.height));a.push({revisionId:i.id,type:i.type,variant:"cell",left:r-n.left,top:l-n.top,width:s-r,height:c-l})}return a}(e,t)),o.push(...function(e,t){const{surfaceRect:n}=e,o=[];for(const r of $b(t)){if(!jb(t,r.type,r.author))continue;const a=new Set(r.paragraphIds),i=/* @__PURE__ */new Map;for(const t of e.paragraphs){if(!a.has(t.paragraphId))continue;const e=i.get(t.pageIndex)??[];e.push(t),i.set(t.pageIndex,e)}for(const e of i.values()){const t=Math.min(...e.map(e=>e.left)),a=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.left+e.width)),l=Math.max(...e.map(e=>e.top+e.height));o.push({revisionId:r.id,type:r.type,variant:"section",left:t-n.left,top:a-n.top,width:i-t,height:l-a})}}return o}(e,t)),o}function Zb(e,t){const{surfaceRect:n}=e,o=/* @__PURE__ */new Map;for(const s of e.pages??[]){const e=s.left+s.width-12-168;o.set(s.index,e-n.left)}const r=e.paragraphs,a=[];for(const s of function(e){const t=/* @__PURE__ */new Map,n=(e,n,o)=>{const r=t.get(e.id);if(r)return r.paragraphIds.push(...n),void(o&&r.snippetParts.push(o));t.set(e.id,{...e,paragraphIds:[...n],snippetParts:o?[o]:[]})};for(const o of Ve(e.document))for(const e of o.runs){const t=e.revision,r=e.styles?.propertyRevision,a=!t||"insert"!==t.type&&"delete"!==t.type?r?{id:r.id,type:"property",author:r.author,date:r.date,scope:"run"}:void 0:{id:t.id,type:t.type,author:t.author,date:t.date,scope:"run"};a&&n(a,[o.id],e.text)}for(const o of Nb(e))n({id:o.id,type:o.type,author:o.author,date:o.date,scope:o.scope},o.paragraphIds,o.snippet);for(const o of $b(e))n({id:o.id,type:o.type,author:o.author,date:o.date,scope:"section"},o.paragraphIds,o.snippet);return[...t.values()].map(e=>{return{id:e.id,type:e.type,author:e.author,date:e.date,scope:e.scope,snippet:(t=e.snippetParts.join("").trim(),t.length>96?`${t.slice(0,93)}…`:t),paragraphIds:[...new Set(e.paragraphIds)]};var t})}(t)){if(!jb(t,s.type,s.author))continue;const e=new Set(s.paragraphIds);let i;for(const t of r)e.has(t.paragraphId)&&(!i||t.top<i.top)&&(i=t);if(!i)continue;const l=o.get(i.pageIndex);if(void 0===l)continue;const c=i.lines[0];a.push({descriptor:s,pageIndex:i.pageIndex,top:(c?c.top:i.top)-n.top,lineHeight:c?c.height:i.height,connectorLeft:i.left+i.width-n.left,balloonLeft:l})}a.sort((e,t)=>e.pageIndex-t.pageIndex||e.top-t.top);const i=/* @__PURE__ */new Map,l=[];for(const s of a){const e=i.get(s.pageIndex)??-1/0,t=Math.max(s.top,e+6);i.set(s.pageIndex,t+42);const n=s.descriptor;l.push({revisionId:n.id,type:n.type,variant:"balloon",left:s.balloonLeft,top:t,width:168,height:42,author:n.author,date:n.date,snippet:n.snippet,connectorLeft:s.connectorLeft,connectorTop:s.top+Math.max(1,s.lineHeight/2),connectorWidth:Math.max(4,s.balloonLeft-s.connectorLeft)})}return l}var Jb={composeMeasuredParagraphLines:e=>ca.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>ca.resolveRenderedLineHeightPx(e,t)};function Qb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function ey(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 ty(){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&&Qb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&Qb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&ey(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&ey(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 ny(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 oy(e){return function(e){const[t,n]=gn({}),[o,r]=gn({}),[a,i]=gn({left:0,top:0,height:28}),[l,s]=gn([]),[c,d]=gn([]),[u,p]=gn([]),[g,f]=gn([]),[m,h]=gn(null),[b,y]=gn(null),[v,x]=gn(null),[w,S]=gn({left:0,top:0,height:28,visible:!1}),[I,C]=gn(null),T=ty(),k=ln(()=>{Tr();const t=void 0===(n=e.state.reviewDisplayMode)||"all"===n?null:"original"===n?"original":"final";var n;return null===t?e.state.document:Nr(e.state.document,t).document}),P=ln(()=>(Tr(),T(To(k(),void 0,t(),o(),{measurer:Jb})))),R=tt();let B=0;const M=(t="selection")=>{const n=e.surfaceRef();if(!n)return s([]),d([]),p([]),f([]),h(null),y(null),x(null),void S(e=>({...e,visible:!1}));const o=R.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:P(),zoomFactor:e.zoomFactor?.()});if(!o)return s([]),d([]),p([]),f([]),h(null),y(null),x(null),void S(e=>({...e,visible:!1}));const r=e.state.reviewDisplayMode??"all";if("all"!==r)return s([]),h(null),y(null),x(null),S({left:0,top:0,height:28,visible:!1}),i({left:0,top:0,height:28}),d([]),p([]),void f("simple"===r&&!1!==e.state.showRevisionMarkup?function(e,t){const n=Vb(t);if(0===n.size)return[];const o=e.surfaceRect,r=/* @__PURE__ */new Map;for(const l of e.paragraphs){const e=r.get(l.pageIndex);(void 0===e||l.left<e)&&r.set(l.pageIndex,l.left)}const a=/* @__PURE__ */new Map;for(const l of e.pages??[]){const e=r.get(l.index),t=void 0===e?0:e-l.left;a.set(l.index,l.left+(t>0?.5*t:12)-o.left)}const i=[];for(const l of e.paragraphs){const e=n.get(l.paragraphId);if(void 0===e)continue;const t=a.get(l.pageIndex)??l.left-o.left-12,r=l.lines;if(0===r.length){i.push({paragraphId:l.paragraphId,left:t,top:l.top-o.top,height:Math.max(1,l.height)});continue}const s=null===e?r:r.filter(t=>e.some(e=>e.start<t.endOffset&&e.end>t.startOffset)),c=s.length>0?s:[r[0]];for(const n of c)i.push({paragraphId:l.paragraphId,left:t,top:n.top-o.top,height:Math.max(1,n.height)})}return i}(o,e.state):[]);const a=Pb(o,e.state);f([]),s(a.selectionBoxes),p(!1===e.state.showRevisionMarkup?[]:[...qb(o,e.state),...Zb(o,e.state)]),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!Hb(t,"comments"))return[];const o=e.surfaceRect,r=new Map(pa(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const l=n.items[i];if(!l?.start||!l?.end||!Ub(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)),h(a.selectedImageBox),y(a.selectedTextBoxBox),x(a.selectedTableBox),i(a.inputBox),S(a.caretBox)},A=(e="selection")=>{const t=++B;queueMicrotask(()=>{t===B&&M(e)})},F=(e="content-change")=>(A(e),!1),O=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(r(e=>ny(e,t.paragraphIds??[])),Qo()),A(e),t.resolveWhenDone?Promise.resolve():null),D=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),r({}),Qo();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];r(t=>ny(t,e)),Qo()}A("content-change")}},E=async()=>{n({}),r({}),Qo(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),A("import")};fe(()=>{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")}),fe(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||A("content-change")}),fe(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.showMarkupFormatting,e.state.markupAuthors,A("content-change")}),fe(()=>{e.state.reviewDisplayMode,A("content-change")}),fe(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{A("scroll")},o=()=>{A("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),Lr(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const L=()=>C(null),N=()=>{B+=1,R.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:o,documentLayout:P,canvasSnapshotProvider:R,inputBox:a,selectionBoxes:l,commentHighlights:c,revisionMarkupBoxes:u,changeBarBoxes:g,selectedImageBox:m,selectedTextBoxBox:b,selectedTableBox:v,caretBox:w,preferredColumnX:I,setPreferredColumnX:C,clearPreferredColumn:L,requestInputBoxSync:A,scheduleDeferredLayoutMeasurement:O,stabilizeLayoutAfterImport:E,syncMeasuredLayoutMetrics:F,syncInputBox:M,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:r,applyInvalidation:D,onCleanupHook:N}}(e)}function ry(e){return Array.isArray(e)?e.map(ry):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,ry(t)])):e}function ay(e){const{builtinStyle:t,customStyle:n,...o}=e;return JSON.stringify(ry(o))}var iy=new Map(Object.values(Pn).flatMap(e=>{const t=ea(e);return t?[[e.id,{key:t,signature:ay(e)}]]:[]}));function ly(e){if(!0===e.customStyle||void 0!==e.builtinStyle)return;const t=iy.get(e.id);return t?.signature===ay(e)?t.key:void 0}function sy(e,t,n){const[o,r]=gn("Initial"),[a,i]=gn(!1),l=()=>n.enabled??!1,s=n.persistence,c=ga(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 fe(Jn(()=>e.document,e=>{l()&&a()&&c(e)},{defer:!0})),er(async()=>{if(!l())return i(!0),void r("Saved");try{const e=await s.loadDocument();e&&t(function(e){if(e.sourcePackage||!e.styles)return e;let t;for(const[n,o]of Object.entries(e.styles)){const r=ly(o);r&&(t??={...e.styles},t[n]={...o,builtinStyle:r})}return t?{...e,styles:t}:e}(e))}catch(e){n.logger?.error("persistence:load failed",e)}finally{i(!0),r("Saved")}}),{status:o}}function cy(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function dy(e){return function(e){const t=(e,t)=>{const n=qe(e.document),o=Math.max(0,Math.min(lo(e),n.length-1)),r=bn(e),a=n[o];if(!a)return e;const i=[...n],l={...a},s=yo("");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:cy(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:cy(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=pa(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=pa(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=Bt(i,n<0?Lt(i):0);return e.applyTransactionalState(()=>yb(r,l),{mergeKey:Ei}),e.focusInput(),!0}const l=r[i],s=n<0?Lt(l):0;return e.applyTransactionalState(e=>yb(e,Bt(l,s)),{mergeKey:Ei}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(sr)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function uy(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 py(e){return function(e){const[t,n]=gn([]),[o,r]=gn([]);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=Yr("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:cy(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const l=Yr("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>qe(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=pa(e),r=pa(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=Dr(o),i=Dr(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),Yr("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 gy(e){let t=e.state.document,n=e.state.selection;fe(()=>{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,wi&&(Ci={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 fy(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:f,getImageOps:m}=e,h=Sb({state:()=>r,applyState:l,applyTransactionalState:(e,t)=>j(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await D()},resetEditorChromeState:()=>q(),focusInput:d,requestLocalFontAccess:g,prepareDocumentFonts:async e=>{await dt(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),b=()=>"done"!==h.importProgress()?.phase&&"error"!==h.importProgress()?.phase&&null!==h.importProgress(),{measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,revisionMarkupBoxes:T,changeBarBoxes:k,selectedImageBox:P,selectedTextBoxBox:R,selectedTableBox:B,caretBox:M,preferredColumnX:A,setPreferredColumnX:F,clearPreferredColumn:O,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:E,setMeasuredParagraphLayouts:L,applyInvalidation:N,onCleanupHook:$}=oy({state:r,surfaceRef:u,viewportRef:p,isImporting:b,zoomFactor:f}),z=uy({key:t().persistenceKey}),{status:H}=sy(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=Cn(e);a(t),q()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??z,logger:n}),{undoStack:W,redoStack:U,applyTransactionalState:j,applyHistoryState:V,resetTransactionGrouping:K,updateHistoryState:_,getHistoryState:G,clearHistory:X}=py({stateSnapshot:i,commitState:a,cloneState:s,applyLayoutInvalidation:N}),Y=dy({state:()=>r,stateSnapshot:i,applyHistoryState:V,applyTransactionalState:j,focusInput:d,clearPreferredColumn:O,imageOps:m,updateHistoryState:_,getHistoryState:G}),q=()=>{O(),E({}),L({}),Qo(),w.clear(),X()};return gy({state:r,isImportInProgress:b,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:h,isImportInProgress:b,measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,revisionMarkupBoxes:T,changeBarBoxes:k,selectedImageBox:P,selectedTextBoxBox:R,selectedTableBox:B,caretBox:M,preferredColumnX:A,setPreferredColumnX:F,clearPreferredColumn:O,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:E,setMeasuredParagraphLayouts:L,applyLayoutInvalidation:N,onCleanupHook:$,fallbackPersistence:z,persistenceStatus:H,undoStack:W,redoStack:U,applyTransactionalState:j,applyHistoryState:V,resetTransactionGrouping:K,updateHistoryState:_,getHistoryState:G,clearHistory:X,historyActions:Y,resetEditorChromeState:q}}(e)}function my(e){return tb(e,e=>"textBox"===e.kind)}function hy(e,t){const n=my(e);if(!n||!Jo(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=pa(e).map((e,t)=>t!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Yn(e))});return Ce(e,i,N(i,to(e)))}function by(e,t){const n=my(e);if(!n||!Jo(n.run))return e;const{paragraphIndex:o,run:r}=n,a=pa(e).map((e,n)=>n!==o?mn(e):{...mn(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Yn(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return Ce(e,a,N(a,to(e)))}function yy(e,t,n,o={}){const r=my(e),a=r&&Jo(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=pa(e).map((e,t)=>t!==p?mn(e):{...mn(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Yn(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*Br}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*Br}})}return a}(t.floating,f,m,s,c)),{...e,textBox:n}})});return Ce(e,h,N(h,to(e)))}var vy=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),xy=e=>e.rows.reduce((e,t)=>Math.max(e,vy(t)),0),wy=(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 Sy(e){if(!e)return null;for(const t of e.blocks){const e=Ae(t)[0];if(e)return e}return null}var Iy=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=Sy(e);if(t)return t}return null};function Cy(e,t){return e.some(e=>Ae(e).some(e=>e.id===t))}var Ty=(e,t,n)=>{const o=St(e,t);if(!o)return null;const r=C(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!Cy(o,n))continue;const e=Bo(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=St(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=Ne(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 i=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),l=i.findIndex(e=>function(e,t){return e.blocks.some(e=>Ae(e).some(e=>e.id===t))}(e,t));if(-1===l)return null;const s=Sy(i[l+n]);return s?Bt(s,0):null};function ky(e,t){return Boolean(e?.some(e=>Ae(e).some(e=>e.id===t)))}function Py(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])=>ky(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>ky(e,o))?.[0]??"footer":"blocks"}function Ry(e){const t=St(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function By(e,t){if("footnote"===t){const t=Ry(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=qe(e.document),o=lo(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=Py(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var My=(e,t,n="main")=>{if("footnote"===n){const n=Ry(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=lo(e),r=qe(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const l=Py(e,i,n),s=[...r];return s[a]="blocks"===l?{...i,blocks:t}:{...i,[l]:t},{...e,document:{...e.document,sections:s}}};function Ay(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Fy(e,t){const n=Bo(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:Ay(t),targetBlocks:e}:null}function Oy(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]=Po(a),Fy(i,n)}var Dy=(e,t,n)=>{const o=C(e.document,e.selection.focus.paragraphId,lo(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?Fy(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:dr(r.targetCell.blocks.map(e=>"paragraph"===e.type?mn(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),i=qe(a.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...i),{...My(e,r.targetBlocks,o.zone),selection:a.selection}};function Ey(e,t){const n=C(e.document,e.selection.focus.paragraphId,lo(e));return n?Oy(e,t,n):null}function Ly(e,t,n,o){const r=My(e,t,n);return o?{...r,selection:{anchor:Bt(o,0),focus:Bt(o,0)}}:r}function Ny(e,t,n,o){const r=t.getTargetBlocks(e,n),a=Bo(r,o);return a?.[a.length-1]?.table??null}function $y(e,t){const n=C(e.document,e.selection.focus.paragraphId,lo(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Ny(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function zy(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=$y(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=Ny(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=$y(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!==$y(t,e),s=t=>{const n=$y(t,e);return Boolean(n&&xy(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function Hy(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function Wy(e){return e.blocks.flatMap(Ae)}function Uy(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function jy(e,t){return function(e,t){const n=e.selection,o=lo(e),r=C(e.document,n.anchor.paragraphId,o),a=C(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 i=t.getTargetBlocks(e,r.zone),l=Bo(i,r.tablePath),s=Bo(i,a.tablePath),c=l?.[l.length-1],d=s?.[s.length-1];if(!c||!d||c.table!==d.table)return null;const u=Uy(r),p=Uy(a),g=c.table,f=en(g),m=f.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex),h=f.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex);return m&&h?{anchorLocation:u,focusLocation:p,anchorCell:m,focusCell:h,tableBlock:g,tableLayout:f}:null}(e,t)}function Vy(e){return function(e){const t=t=>{const n=t.selection,o=jy(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=Hy(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Hy(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?Wy(d)[0]:void 0,g=u?Wy(u):[],f=g[g.length-1];return p&&f?{anchor:Bt(p,0),focus:Bt(f,J(f).length)}:null},n=t=>{const n=jy(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=jy(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Hy(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=jy(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 Ky(e){if(e)for(const t of e.blocks){const e=Ae(t)[0];if(e)return e}}function _y(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Oy(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Gy(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=>Po(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=_y(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?ns():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=>Po(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=Ky(d);return u?Ly(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=_y(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?ns():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>Po(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=Dn([yo("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Ky(d);return u?Ly(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Ey(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?ns():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):Dn([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=Dn([yo("")],u);t.cells[a.cellIndex]=n}const p=Ky(l);return p?Ly(n,i,a.zone,p):n},i=n=>{const o=Ey(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?ns():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>Po(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},()=>Dn([yo("")]))];l.cells.splice(a.cellIndex,1,...p);const g=Ky(p[0]);return g?Ly(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 Xy(e,t){e.style={...e.style??{},revision:{...ns(),type:t}}}function Yy(e){if(!e)return null;for(const t of e.blocks){const e=Ae(t)[0];if(e)return e}return null}function qy(e,t,n){const o=Yy(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=Yy(r);if(e)return e}return Iy(e)}function Zy(e){return function(e){const t=(t,n)=>{const o=Ey(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=en(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=sa(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=Dn([yo("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return Dn([yo("")],t.colSpan)})),t.trackChangesEnabled&&Xy(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=qy(r,wy(c,d),c);return Ly(t,i,a.zone,u)}c=sa(l.cells.map(e=>Dn([yo("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&Xy(c,"insert"),r.rows.splice(s,0,c);const d=qy(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return Ly(t,i,a.zone,d)},n=t=>{const n=Ey(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 Xy(i,"delete"),Ly(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?en(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=en(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=qy(o,c?wy(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,vy(c)-1))):null);return Ly(t,a,r.zone,d)},o=(t,n)=>{const o=Ey(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=en(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=Dn([yo("")]);t.trackChangesEnabled&&Xy(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:{...ns(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=Dn([yo("")]);t.trackChangesEnabled&&Xy(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=qy(r,l?wy(l,o):null);return Ly(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=Dn([yo("")]);t.trackChangesEnabled&&Xy(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=qy(r,s);return Ly(t,i,a.zone,c)},r=t=>{const n=Ey(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(xy(o)<=1)return t;if(t.trackChangesEnabled){const e=en(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=wy(t,e);n&&Xy(n,"delete")}return Ly(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=en(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=qy(o,n&&wy(n,Math.min(e,Math.max(0,vy(n)-1))));return Ly(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=qy(o,l);return Ly(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function Jy(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(Ae);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p=n({...r,document:dr(d,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Bt(d[0],0),focus:Bt(d[d.length-1],J(d[d.length-1]).length)}}),g=pa(p),f=l[l.length-1];if(!f)return r;const m=Oy(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=lt(r.blocks,o))}return My(r,m.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function Qy(e){return function(e){const t=By,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Vy({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=zy({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Gy({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I}=Zy({getTargetBlocks:t}),C=(e,n)=>Dy(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P}=Jy({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?ns():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...Dn([yo("")]),style:{width:o}});const t=sa(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...ma(a),style:{width:"100%"}},l=Pr(e,e.selection.focus),s=Ne(e.document),c=lo(e),d=bn(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&Ae(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:re(Bt(h,0))}}(e,t,n),{mergeKey:Di}),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:I,getRowVisualWidth:vy,getTableVisualWidth:xy,findCellAtVisualColumn:wy,findFirstNavigableParagraphInTable:Iy,updateBlocksInCurrentSection:My,resolveAdjacentTableCellPosition:Ty,applyTableAwareParagraphEdit:C,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P,insertTableCommand:R}}(e)}function ev(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function tv(e,t){let n=null;const o=(e,t,n)=>{const o=pa(e).find(e=>e.id===t);return o?{anchor:Bt(o,n),focus:Bt(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=ev(),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}=Ca(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:cy(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 nv(e,t){let n=null;const o=ev(),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=pa(e).find(e=>e.id===t);return o?{anchor:Bt(o,n),focus:Bt(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:cy(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 ov(e,t){return Math.max(1e-4,1-e-t)}function rv(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 av(e){let t=null;const n=(e,t,n)=>{const o=pa(e).find(e=>e.id===t);return o?{anchor:Bt(o,n),focus:Bt(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=ev(),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=ov(a,l)/o,d=ov(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=ov(a,l)/o,d=ov(i,s)/r,u=Be(e.handleDirection,"x"),p=Be(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=rv(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=gt(o+t,24,o+l/c);const e=rv(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=rv(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=gt(r+n,24,r+s/d);const e=rv(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(cb(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:cy(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=ib(o(u,g)),m=f&&Dr(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 iv(e){return function(e){const[t,n]=gn(!1),[o,r]=gn(!1),[a,i]=gn(null);fe(()=>{o()&&!m(e.state)&&r(!1)});const l=()=>{m(e.state)?r(e=>!e):r(!1)},[s,c]=gn({x:0,y:0}),[d,u]=gn(null);let p=null,g=null,f=null;const m=e=>{const t=to(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=pa(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:$(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=ev(),x=()=>{y(),g=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)},w=()=>{x()},S=tv({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>lb(e,t,n),getMaxWidth:(t,n)=>vb(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}),I=nv({label:"image",applyRotate:(e,t)=>function(e,t){const n=gb(t);return hb(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}),C=av({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),T=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))},k=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=>yb(e,o),{mergeKey:Ei})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},P=(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",T),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},R=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=Ve(e.state.document).find(e=>e.id===t);r&&e.applyState(Ma(e.state,{anchor:Bt(r,n),focus:Bt(r,n+1)})),P(t,n,o),e.focusInputAfterPointerSelection()},B=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,o,r,e.state)},M=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),I.start(t,n,o,e.state)},A=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),C.start(t,n,o,r,e.state)},F=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:l,draggedImageInfo:a,mousePos:s,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:P,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:I.stop,stopImageCrop:C.stop,handleImagePointerDown:R,handleImageResizeHandlePointerDown:B,handleImageRotateHandlePointerDown:M,handleImageCropHandlePointerDown:A,handleImageCropBodyPointerDown:F}}(e)}function lv(e){return function(e){const t=e=>{const t=my(e),n=t&&Jo(t.run);return n?{width:n.width,height:rt(n,e,0)}:null},n=tv({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>yy(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=vb(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=nv({label:"text box",applyRotate:(e,t)=>hy(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 sv(e){return function(e){const[t,n]=gn(void 0),o=()=>{n(void 0)};fe(()=>{Vn(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=Pe(e.state()),o=t();return Vn(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(Vn(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(Vn(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(Vn(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 cv(e,t,n={}){if(!t)return[];const o=[],r=Ve(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=J(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:Bt(e,n),focus:Bt(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function dv(e,t,n,o={}){const r=cv(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=Ma(a,{anchor:e.anchor,focus:e.focus}),a=za(a,n)}return a}function uv(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*U+(r<e?e-r:r>i?r-i:0)}function pv(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*U+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 gv(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=pv(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function fv(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function mv(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=uv(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=Bt(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)&&fv(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&fv(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=Bt(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}=pv(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=uv(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:gv(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=Bt(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 hv(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){wi&&(Ii=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 Pi(null),null;const s=mv({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return Pi(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var bv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],yv=/* @__PURE__ */new Map;function vv(){return bv.map(e=>({...e}))}var xv=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function wv(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 Sv(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=wv(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=Sv(e.slice(0,o+1),t),l=Sv(e.slice(o),t);return[...i.slice(0,-1),...l]}function Iv(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 vv();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]=xv[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 vv();const a=.012*Math.max(t,n);let i=Sv(r,a),l=a;for(;i.length>40;)l*=1.6,i=Sv(r,l);return i.length<3?vv():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function Cv(e){const t=e.src,n=yv.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 vv();const r=Iv(o.mask,o.width,o.height);return yv.set(t,r),r.map(e=>({...e}))}function Tv(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>ib(t())?"image":my(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},l=(e,n)=>{const r=$(t().document,n),a=t=>{const n=Cv(t);o(t=>function(e,t,n){const o=pa(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...mn(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Yn(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:mn(e));return r?Ce(e,a,N(a,to(e))):e}(t,e,n),{mergeKey:_i})},i=pn(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=ib(e),n=t&&Dr(t.run);return n?ob(n.floating):null}(t()):"textBox"===e?function(e){const t=my(e),n=t&&Jo(t.run);return n?ob(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=ib(e),n=t&&Dr(t.run);return ab(n?.floating)}(t()):"textBox"===e&&function(e){const t=my(e),n=t&&Jo(t.run);return ab(n?.floating)}(t())},setPreset:e=>{if(i(El,(t,n)=>"image"===n?function(e,t){return bb(e,e=>nb(e,t))}(t,e):function(e,t){return by(e,e=>nb(e,t))}(t,e)),"tight"===e||"through"===e){const e=ib(t()),n=e&&Dr(e.run);n&&!n.wrapPolygon&&l(e.run.id,n.src)}},setFixedPosition:e=>i(Ll,(t,n)=>"image"===n?function(e,t){return bb(e,e=>e?rb(e,t):e)}(t,e):function(e,t){return by(e,e=>e?rb(e,t):e)}(t,e))}}function kv(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?Qh(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=Qh(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 Pv=/* @__PURE__ */new WeakMap;function Rv(e,t){return function(e){return qe(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function Bv(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=Pv.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 Pv.set(a,c),c}function Mv(e,t,n,o,r,a){const i=Bv(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=Rv(n,l.geometry.tableId);if(!s)return null;const c=en(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 Av=1/.75;function Fv(e){return.75*e}function Ov(e){return e*Av}var Dv=Ms;function Ev(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Ov(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Ov(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Ov(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Ov(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Ov(e.style.borderRight.width)):1)}function Lv(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=Dv(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Ov(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 Nv(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,Ov(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,Fv(a[s]));return{widthsPt:l,maxColumnIndex:r}}function $v(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Ov(10),r=Math.max(Ov(10),t.minRowHeightPx??Ov(10)),a=Math.max(10,Fv(Math.max(r,o+n)));return function(e,t,n,o){return Bs(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function zv(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 Hv=null;function Wv(e,t){Hv=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 Uv(e){e&&Hv!==e||(Hv=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function jv(e,t){Wv(e,t)}function Vv(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Kv(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function _v(e){const[t,n]=gn(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 Uv();const i=Mv(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Wv("left"===i.side||"right"===i.side,l):Uv()},c=ev(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Vv(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:zv(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Kv(o),o=null),null!==a&&(Kv(a),a=null),n(null),Uv(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?$v(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=Fv(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,Fv(i[t.index]??Ov(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 As(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,Fv(i[e]??Ov(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=Rv(e,t.tableId),g=Dv(p?.style?.width),f=d?u:null!==g?g:void 0;return As(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=Vv(s))))},handlePointerDown:t=>{r=null,null!==o&&(Kv(o),o=null),Uv();const a=e.surfaceRef();if(!a)return!1;const i=Mv(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=en(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}=Nv(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Ov(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,vt(n,e.document.styles)),1);a[o]=Math.max(s,c+Ev(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:Dv(i.tableNode.style?.indentLeft)??0,guideBounds:zv(e.viewportRef)}),jv(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=Lv(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 Ov(10);const a=Ov(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:zv(e.viewportRef)}),jv(!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 Gv=null;function Xv(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=Ov(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 Yv(e){const[t,n]=gn(null);let o=null,r=null;const a={},i=ev(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Vv(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&&(Kv(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Gv===a&&(Gv=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}=Xv(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=As(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,Fv(e*o))}),Bs(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}=Xv(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=Bv(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=Rv(e.state(),t);if(!s||!c)return;const u=en(c),{widthsPt:p}=Nv(c,u,s),g=Lv(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}),Gv=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 qv=null;function Zv(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=Zv(n.blocks,t,!0,!1);if(e)return e}}return null}function Jv(e,t){for(const n of Ne(e)){for(const e of[n.blocks,n.header,n.footer]){const n=Zv(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=Zv(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=Zv(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=Zv(n.blocks,t,!1,!1);if(e)return e}return null}function Qv(e){return function(e){const[t,n]=gn(!1),[o,r]=gn(null),[a,i]=gn(null),[l,s]=gn(0),[c,d]=gn(0),[u,p]=gn({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=ev(),v=()=>{f=null,null!==g&&(Kv(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),qv===m&&(qv=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=Jv(e,n);return Boolean(o?.table&&Ae(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),qv=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Vv(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=Jv(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return ks(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*Hn,y:(t.y??0)+(n.clientY-l())*Hn,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 ex=e=>"touch"===e.pointerType;function tx(e,t){if(!e||0===e.length){const e=x(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Ae(n)[0]??null,blocks:e}}function nx(e,t,n){const o=Ve(e.document).filter(t=>{const o=St(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:Bt(t,0),end:a?Bt(a,0):Bt(t,J(t).length)}}function ox(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?St(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=x("header"),t=x("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:un(s.pageSettings??K),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=tx(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=tx(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?Bt(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=lo(n),a=A(n.document,o.anchor.paragraphId,r),i=A(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},w=()=>{t=null,o=null,g=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",P)},S=e=>{g=e,window.addEventListener("pointermove",T),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",P)},I=()=>{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(St(i.document,t.paragraphId)?.sectionIndex!==St(i.document,a.paragraphId)?.sectionIndex)return;const l=Ma(i,{anchor:t,focus:a.position});b(i,a.zone,l,a.position),y("selection:drag")},C=()=>{o&&(null!==n&&(h(n),n=null),I())},T=e=>{null!==g&&e.pointerId!==g||(!f||f.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(I))):Math.hypot(e.clientX-f.clientX,e.clientY-f.clientY)>20&&w())},k=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(),w(),void(o&&(L(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}C(),y("selection:end"),w(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},P=e=>{null!==g&&e.pointerId!==g||w()},R=(n,o,r)=>{if(r<2)return t=null,w(),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),w(),e.focusInputAfterPointerSelection()},B=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=Bt(r,o.textBox.startOffset),i=Bt(r,o.textBox.endOffset);b(n,o.zone,Ma(n,{anchor:a,focus:i}),a),w(),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=Bt(a,o.image.startOffset),l=Bt(a,o.image.endOffset);b(n,o.zone,Ma(n,{anchor:i,focus:l}),i),w(),ex(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()},F=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,Ma(n,{anchor:n.selection.anchor,focus:o.position}),o.position),S(r),e.focusInputAfterPointerSelection()},O=(n,o,r)=>{t=null;const a=nx(n,r,o.zone);b(n,o.zone,Ma(n,{anchor:a.start,focus:a.end}),a.start),w(),e.focusInputAfterPointerSelection()},D=(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=Bt(r,o.paragraphOffset);return b(n,o.zone,Ma(n,{anchor:t,focus:t}),t),w(),void e.openEquationDialog(i.math,i.id)}const l=Je(J(r),o.paragraphOffset),s=Bt(r,l.start),c=Bt(r,l.end);b(n,o.zone,Ma(n,{anchor:s,focus:c}),s),w(),e.focusInputAfterPointerSelection()},E=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!ex(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,w(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?B(n,o):o.image?M(n,o,a):a.shiftKey&&o.resolvedFromParagraph?F(n,o,a.pointerId):r>=3&&i?O(n,o,i):2===r&&i?D(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),ex(a)||S(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():R(n,o,r)},L=(t,n,o)=>{E(e.state(),t,n,o),e.focusInputSync()},N=()=>{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=Je(J(a),o.paragraphOffset),l=Bt(a,i.start),s=Bt(a,i.end);b(r,o.zone,Ma(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},$=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)=>ex(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,ex(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(N,500),longPressFired:!1},void S(t.pointerId);t.preventDefault(),E(m,h,g,t)},z=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=nx(o,i,a.zone);b(o,a.zone,Ma(o,{anchor:l.start,focus:l.end}),l.start),w(),e.focusInputAfterPointerSelection()},H=(e,t)=>{0===t.button&&(ex(t)||t.preventDefault(),$(t))};return{handleSurfacePointerDown:$,handleSurfaceClick:z,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:H,stopDragging:w}}(e)}function rx(e){return function(e){const[t,n]=gn(!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=Zo(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}=Le(e);if(r<t)return e;const a=pa(e),i=r-t,l=Ut(n,[...Rt(n,0,i),...Rt(n,r,Lt(n))],Z(n,i)),s=a.map((e,t)=>t===o?l:e);return Ce(e,s,re(Bt(l,i)))}(e,s);return t.length>0?za(n,t,c):n}),{mergeKey:Fi}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(wn("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=pa(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=Zo(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>za(e,o,u)),{mergeKey:Ai}),n.currentTarget.value="",e.focusInput(),po("input:text")},d=()=>{e.logger.debug("input:composition start"),l(),i=null,o=Zo(e.pendingCaretTextStyle()),n(!0)},u=t=>{e.isReadOnly()||s(t.data??"",!1)},p=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:u,handleCompositionEnd:p,composing:t}}(e)}var ax="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 ix(e,t){const n=to(e);if(n.isCollapsed)return!1;const o=pa(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=jt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function lx(e){return function(e){const[t,n]=gn(!1),[o,r]=gn(null),[a,i]=gn(!1),[l,s]=gn(null),[c,d]=gn(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: ${ax} !important; }`,document.head.appendChild(p))},h=ev(),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?nl:ol}),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=>ix(e,t)?Ma(e,{anchor:t,focus:t}):e,{mergeKey:rl}),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):ix(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 sx(e){return e.blocks.flatMap(Ae)}function cx(e,t){if(!e)return;const n=sx(e);return"start"===t?n[0]:n[n.length-1]}function dx(e){return function(e){const t=(t,n)=>{const o=e.state(),r=pa(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:J(r).length,i=Bt(r,a);return e.clearPreferredColumn(),e.applyState(Ma(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=pa(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:J(a).length,l=Bt(a,i);return e.clearPreferredColumn(),e.applyState(Ma(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=pa(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const l=J(i),s=o.selection.focus.offset,c=l.length;if(!n&&!Vn(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Aa(o):Fa(o)),!0;let d=i,u=s;"left"===t?0===s&&a>0?(d=r[a-1],u=J(d).length):u=ze(l,s):s===c&&a<r.length-1?(d=r[a+1],u=0):u=Oe(l,s);const p=Bt(d,u);return e.clearPreferredColumn(),e.applyState(Ma(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=pa(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const i=e.surfaceRef(),l=i?.getBoundingClientRect()??null,s=e.preferredColumnX(),c=null===s?e.caretBox().left+(l?.left??0):s,d=i?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:i,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let u=a+t;const p=C(o.document,o.selection.focus.paragraphId,lo(o)),g=p?.tablePath[p.tablePath.length-1];if(p&&g){const e=By(o,p.zone),n=Bo(e,p.tablePath),a=n?.[n.length-1]?.table;if(a){const e=en(a),n=e.find(e=>e.rowIndex===g.rowIndex&&e.cellIndex===g.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&&sx(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=cx(e.cell,"start")?.id,n=t?d?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??c,r=n?n.left+n.width:c;return{entry:e,distance:c<o?o-c:c>r?c-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=cx(i.cell,t<0?"end":"start");u=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=cx(a.rows[0]?.cells[0],"start");e&&(u=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=cx(t,"end");n&&(u=r.findIndex(e=>e.id===n.id)+1)}}}if(u<0||u>=r.length)return!1;const f=r[u];let m=0;const h=d?yn(d,f.id):[],b=t<0?h[h.length-1]:h[0];if(b&&b.lines.length>0){const e=b.lines,n=t<0?e[e.length-1]:e[0];m=n.slots.length?n.slots.reduce((e,t)=>Math.abs(c-t.left)<Math.abs(c-e.left)?t:e,n.slots[0]).offset:0}else m=Math.min(jt(f,o.selection.focus),J(f).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Ma(e,{anchor:n?e.selection.anchor:Bt(f,m),focus:Bt(f,m)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function ux(e){return function(e){const[t,n]=gn(null),o=(t,o)=>{const r=pa(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 Ne(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 px(e){const t=pa(e);if(!t.length)return null;const n=to(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:Rt(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:Lt(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Zo(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(st(r?r.styles:Z(o,n.startParagraphOffset),o.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===Lt(o));return{text:a,paragraph:i?Or(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function gx(e,t){const n=pa(e);if(!n.length)return e;const o=to(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:Lt(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===Lt(e))}(e,n,o),s=l?Or(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)),u=a<i&&Rt(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Zo(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!kn(e.styles,o)});if(!d&&!u)return e;r=!0;let p=u?Ye(e,a,i,e=>{if("text"!==e.kind)return e;const n=Zo(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&&(p={...p,style:s,list:c}),p});return r?Ce(e,a,N(a,o)):e}function fx(e){const t=pa(e);if(!t.length)return"";const n=to(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function mx(e){const[t,n]=gn(null);let o=null,r=null,a="";const i=()=>{o=null,r=null,a="",n(null)};at()&&(fe(()=>{t()&&(e.isReadOnly()||e.state().document!==r)&&i()}),Lr(i));const l=()=>!e.isReadOnly()&&pa(e.state()).length>0,s=t=>{if(!l())return!1;const i=e.state(),s=px(i);return!!s&&(o=s,r=i.document,a=fx(i),n(t),e.focusInput(),!0)};return{mode:t,canCapture:l,armOnce:()=>s("once"),armContinuous:()=>s("continuous"),cancel:i,applyToSelection:n=>{if(!o||!t())return!1;if(e.isReadOnly()||e.state().document!==r)return i(),!1;const l=e.state();if(fx(l)===a)return!1;const s=function(e,t){const n=pa(e);if(0===n.length)return null;const o=to(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=Je(J(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Bt(r,a.start),focus:Bt(r,a.end)}}}(l,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return we(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==r)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>gx(e,o));return c=n.document!==t.document,n}),"once"===t()?i():c&&(r=e.state().document)}),c&&e.focusInput(),c}}}function hx(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:l,focusInputAfterPointerSelection:s,focusInputSync:c,surfaceRef:d,viewportRef:u,zoomFactor:p,insertImageFromFile:g,getForcePlainTextPaste:f,setForcePlainTextPaste:m,getCommandsController:h,applyTransactionalState:b,clearPreferredColumn:y,resetTransactionGrouping:v,updateHistoryState:x,caretBox:w,preferredColumnX:S,setPreferredColumnX:I,documentLayout:C,canvasSnapshotProvider:T}=e,k=()=>ib(t),P=()=>my(t),R=Tv({state:()=>t,resetTransactionGrouping:v,applyTransactionalState:b,focusInput:l}),B=hv({state:()=>t,surfaceRef:()=>d()??null,viewportRef:()=>u()??null,documentLayout:C,canvasSnapshotProvider:T,zoomFactor:p}).resolveSurfaceHitAtPoint,M=function(e){const[t,n]=gn(""),[o,r]=gn(""),[a,i]=gn({matchCase:!1,wholeWord:!1}),[l,s]=gn([]),[c,d]=gn(-1),[u,p]=gn(!1);fe(Jn([()=>e.state.document,t,a],([e,t,n])=>{const o=cv(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(Ma(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(Ma(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:Zi})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>dv(e,n,o(),a()),{mergeKey:Ji}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:b,focusInput:l}),A=Qy({applyTransactionalState:b,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:Bn(e).document,selection:t}),focusInput:l,logger:n}),F=mx({state:()=>t,isReadOnly:o,applyTransactionalState:b,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:l}),O=(e,t)=>B(e,t)?.position??null,D=iv({state:t,surfaceRef:d,resolvePositionAtSurfacePoint:O,applyState:r,applyTransactionalState:b,updateHistoryState:x,focusInput:l,focusInputAfterPointerSelection:s,cloneState:a,logger:n,zoomFactor:p}),E=lv({state:t,surfaceRef:d,applyState:r,updateHistoryState:x,focusInput:l,cloneState:a,logger:n,zoomFactor:p}),L=sv({state:()=>t,commandsController:h,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:l,logger:n}),N=function(e){const t=()=>e.state,n=_v({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=Yv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=Qv({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=ux({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),l=lx({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}),s=ox({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:i,textDrag:{tryStartTextDrag:l.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),c=rx({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}),d=dx({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:u,handleCut:p,handlePaste:g,handleDrop:f}=kv({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:l,surfaceEvents:s,textInput:c,navigation:d,handleCopy:u,handleCut:p,handlePaste:g,handleDrop:f}}({state:t,applyState:r,applyTransactionalState:b,isReadOnly:o,logger:n,focusInput:l,focusInputAfterPointerSelection:s,focusInputSync:c,clearPreferredColumn:y,resetTransactionGrouping:v,surfaceRef:d,viewportRef:u,caretBox:()=>w(),preferredColumnX:()=>S(),setPreferredColumnX:I,zoomFactor:p,documentLayout:C,canvasSnapshotProvider:T,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:A,imageOps:D,styleController:L,formatPainter:F,getForcePlainTextPaste:f,setForcePlainTextPaste:m,clipboardActions:e.clipboardActions,insertImageFromFile:g,openEquationDialog:e.openEquationDialog}),$=e=>{0===e.button&&(L.clearPendingCaretTextStyle(),e.preventDefault(),l())};return{selectedImageRun:k,selectedTextBoxRun:P,layoutOptionsOverlay:R,fr:M,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:A,imageOps:D,textBoxOps:E,styleController:L,formatPainter:F,onEditorPointerDown:$,tableResize:N.tableResize,tableCornerResize:N.tableCornerResize,tableDrag:N.tableDrag,revisionController:N.revisionController,textDrag:N.textDrag,surfaceEventsWithTextDrag:N.surfaceEvents,textInput:N.textInput,navigation:N.navigation,handleCopy:N.handleCopy,handleCut:N.handleCut,handlePaste:N.handlePaste,handleDrop:N.handleDrop}}(e)}function bx(e){if("main"!==(e.activeZone??"main"))return e;const t=Vn(e.selection)?e:Me(e),{paragraph:n,index:o,offset:r}=Le(t),a=pr(),i=function(e){const t=e.footnotes,n=t?.settings?.numberFormat??"decimal";let o=(t?.settings?.startAt??1)-1;const r=/* @__PURE__ */new Set;for(const{run:a}of Mr(e)){const e=qn(a);e&&!e.customMark&&(r.has(e.footnoteId)||(r.add(e.footnoteId),o+=1))}return lr(o+1,n)}(t.document),l=yt(a.id,i),s=d(n,r,[l]),c=pa(t).map((e,t)=>t===o?s:e),u=Bt(s,r+i.length),p=Ce(t,c,zo(u)),g=function(e){return e||{items:{}}}(p.document.footnotes),f={...p.document,footnotes:{...g,items:{...g.items,[a.id]:a}}},m=Wn(f),h=a.blocks.flatMap(Ae).find(Boolean);return h?{...p,document:m,selection:zo(Bt(h,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...p,document:m}}function yx(e){if(!e)return;const{propertyRevision:t,...n}=e;return Object.keys(n).length>0?n:void 0}function vx(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:vx(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 xx(e,t,n){const o=Ne(e.document).map(e=>({...e,blocks:vx(e.blocks,t,n),header:e.header?vx(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?vx(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?vx(e.evenPageHeader,t,n):void 0,footer:e.footer?vx(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?vx(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?vx(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function wx(e,t,n){const o=Ne(e.document),r=o.findIndex(e=>e.propertyRevision?.id===t);if(-1===r)return e;const a=o[r],i=a.propertyRevision,l=[...o];if(n)l[r]={...a,propertyRevision:void 0};else{const e=structuredClone(i.previous);l[r]={...a,pageSettings:e.pageSettings,pageBorder:e.pageBorder,pageNumbering:e.pageNumbering,verticalAlignment:e.verticalAlignment,bidi:e.bidi,propertyRevision:void 0};const t=l[r+1];t&&(l[r+1]={...t,breakType:e.nextBreakType})}return{...e,document:{...e.document,sections:l}}}function Sx(e,t){const n=pa(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.styles?.propertyRevision?.id===t?{...e,styles:yx(e.styles)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return wx(xx(Ce(e,n,N(n,to(e))),t,!0),t,!0)}function Ix(e,t){const n=pa(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}const n=e.styles?.propertyRevision;return n?.id===t?{...e,styles:yx(n.previous)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return wx(xx(Ce(e,n,N(n,to(e))),t,!1),t,!1)}function Cx(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>Cx(e,t))))}function Tx(e,t,n){for(const o of e)if("paragraph"!==o.type){Cx(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=>Cx(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),Tx(e.blocks,t,n)}}}function kx(e){const t=to(e),n=pa(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:Lt(e),l=Rt(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id),t.styles?.propertyRevision?.id&&o.add(t.styles.propertyRevision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Ne(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&Tx(e,r,o);for(const a of $b(e))a.paragraphIds.some(e=>r.has(e))&&o.add(a.id);return o}function Px(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),n.styles?.propertyRevision?.id&&t.add(n.styles.propertyRevision.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 Ne(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 Rx(e){return Px(e).size>0}function Bx(e,t){if(!Rx(e))return e;const n=tr(e.document,t);if(!n.changed)return e;const o=pa({...e,document:n.document}),r=N(o,to(e));return{...e,document:n.document,selection:r}}function Mx(e){const t=to(e),n=pa(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:Lt(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 Ax(e){const t=to(e),n=pa(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return mn(e);if(!e.list)return mn(e);const o=e.list.level??0;return o<=0?V(e):be(e,o-1)});return Ce(e,n,N(n,t))}function Fx(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:i,applySelectionAwareTextCommand:l,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:c,focusInput:d,clearPreferredColumn:u,resetTransactionGrouping:p,toolbarStyleState:g,selectionCollapsed:f,selectedImageRun:m}=e,h=e=>{u(),p(),o(e),d()},b=e=>{u(),p(),l(e),d()},y=e=>{u(),p(),s(e),d()},v=(e,t)=>{u(),p(),i(e,t),d()},x=()=>{const e=to(t);return pa(t).slice(e.startIndex,e.endIndex+1)},w=()=>x().some(e=>Boolean(e.list)),S=()=>{const e=t.selection.focus.paragraphId;return pa(t).find(t=>t.id===e)??null},C=()=>{const e=S();return!!e?.list&&(u(),p(),f()&&0===J(e).length?s(e=>function(e){const t=to(e),n=pa(e).map((e,n)=>n<t.startIndex||n>t.endIndex?mn(e):V(e));return Ce(e,n,N(n,t))}(e)):i(e=>c(e,e=>function(e){const t=Vn(e.selection)?e:Me(e),{paragraph:n,index:o,offset:a}=Le(t),i=Ut(n,Rt(n,0,a),Z(n,a)),l=Rt(n,a,Lt(n)),s=l.length>0?de(n,l.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=yo("");return e.style=n.style?{...n.style}:void 0,e.list=it(n.list),e})(),c=pa(t),d=[...r(c.slice(0,o)),i,s,...r(c.slice(o+1))];return Ce(t,d,re(Bt(s,0)))}(e)),{mergeKey:Li}),d(),!0)},T=()=>{const e=t.selection,n=lo(t),o=A(t.document,e.anchor.paragraphId,n),r=A(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}]`:""},k=e=>{if(f())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${T()}`),b(t=>Ka(t,e))},P=e=>{f()||b(t=>function(e,t){const n=to(e);if(n.isCollapsed)return e;const o=pa(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:Lt(o);return Ye(o,a,i,n=>{let r=Io(Va(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!st(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return Ce(e,o,N(o,n))}(t,e))},R=(e,o)=>{if(f())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}]${T()}`),b(t=>_a(t,e,o))},B=(e,t)=>{y(n=>je(n,e,t))},M=e=>{const t=!g()[e];B(e,"widowControl"===e?t:!!t||null)},F=()=>{v(e=>c(e,e=>Zr(e)))},O=()=>"main"===(t.activeZone??"main"),D=()=>{O()&&v(e=>bx(e))},E=e=>{const n=Mx(t);f()&&!n||v(t=>function(e,t){const n=to(e);if(!n.isCollapsed)return _a(e,"link",t);const o=pa(e)[n.startIndex];if(!o)return e;const r=Et(o,n.startParagraphOffset);if(!r)return e;const a=_a(Ma(e,{anchor:Bt(o,r.startOffset),focus:Bt(o,r.endOffset)}),"link",t),i=pa(a)[n.startIndex];return i?{...a,selection:{anchor:Bt(i,r.startOffset),focus:Bt(i,r.endOffset)}}:a}(t,e),{mergeKey:Ni})},L=()=>{const n=Mx(t)??"";f()&&!n||e.openLinkDialog(n)},$=()=>e.openFontDialog(),z=()=>e.openParagraphDialog(),H=()=>{E(null)},W=()=>{const t=m();if(!t)return;const n=Dr(t.run)?.alt??"";e.openImageAltDialog(n)},U=t=>{m()&&v(n=>function(e,t,n){const o=ib(e);if(!o||!Dr(o.run))return e;const a=pa(e),i=o.paragraphIndex+1,l=i<a.length&&wr(a[i])?tn(a[i],t,n):Xt(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 Ce(e,c,re(Bt(d,q(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:zi})},j=()=>{m()&&e.openImageCaptionDialog(function(e){const t=ib(e);if(!t||!Dr(t.run))return null;const n=pa(e);return Ie(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:k,applyToggleCharacterBorderCommand:()=>{f()||b(e=>function(e){const t=to(e);if(t.isCollapsed)return e;const n=pa(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:Lt(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:Lt(e);return Ye(e,o,a,e=>({...e,styles:Ya(e.styles,r)}))});return Ce(e,a,N(a,t))}(e))},applyValueStyleCommand:R,applyUnderlineStyleCommand:P,applyChangeTextCaseCommand:e=>{f()||b(t=>Ja(t,e))},applyClearFormattingCommand:()=>{f()||b(e=>function(e){const t=to(e);if(t.isCollapsed)return e;const n=pa(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:Lt(e);return Ye(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Ce(e,n,N(n,t))}(e))},applyParagraphStyleCommand:B,toggleParagraphFlagCommand:M,applyParagraphListCommand:e=>{y(t=>function(e,t){const n=to(e),o=pa(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 mn(e);const o=mn(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 Ce(e,s,N(s,n))}(t,e))},handleListFormatChange:e=>{y(t=>function(e,t){const n=to(e),o=pa(e).map((e,o)=>o<n.startIndex||o>n.endIndex?mn(e):e.list?{...mn(e),list:{...e.list,format:t||void 0}}:mn(e));return Ce(e,o,N(o,n))}(t,e))},handleListStartAtChange:e=>{y(t=>function(e,t){const n=to(e),o=pa(e).map((e,o)=>o<n.startIndex||o>n.endIndex?mn(e):e.list?{...mn(e),list:{...e.list,startAt:null!==t?t:void 0}}:mn(e));return Ce(e,o,N(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{h(wt(t,e))},applyInsertPageBreakCommand:F,canInsertFootnoteCommand:O,applyInsertFootnoteCommand:D,handleStyleChange:e=>{y(t=>I(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{h(a(t,e,n))},applyToggleTrackChangesCommand:()=>{h(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleRevisionMarkupCommand:()=>{h(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(t))},applySetReviewDisplayModeCommand:e=>{h(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(t,e))},applyShowMarkupCommand:e=>{h(Wb(t,e))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),d()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),d()},applyAcceptRevisionsCommand:()=>{v(e=>function(e){let t=e;for(const n of kx(e))t=Sx(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{v(e=>function(e){let t=e;for(const n of kx(e))t=Ix(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{v(e=>function(e){return Bx(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{v(e=>function(e){return Bx(e,"reject")}(e))},applyLinkCommand:E,promptForLink:L,openFontDialog:$,openParagraphDialog:z,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:H,applyImageAltCommand:e=>{m()&&v(t=>function(e,t){return hb(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:$i})},promptForImageAlt:W,applyImageCaptionCommand:U,promptForImageCaption:j,applyImageWidthCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||v(t=>function(e,t){const n=ib(e),o=n&&Dr(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Wo));return lb(e,r,r*(o.height/o.width))}(t,e),{mergeKey:Hi})},applyImageHeightCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||v(t=>function(e,t){const n=ib(e),o=n&&Dr(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*Wo));return lb(e,r*(o.width/o.height),r)}(t,e),{mergeKey:Hi})},applyImageCropAspectCommand:e=>{if(!m())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&&v(e=>"reset"===t?pb(e):db(e,t),{mergeKey:Wi})},applyImageCropShapeCommand:e=>{m()&&v(t=>function(e,t){const n=t?.trim();return hb(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:Wi})},applyImageCropFillCommand:()=>{m()&&v(e=>function(e){const t=ib(e),n=t&&Dr(t.run);return n?hb(cb(e,{crop:ub(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Wi})},applyImageCropFitCommand:()=>{m()&&v(e=>function(e){return hb(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Wi})},resetImageCropCommand:()=>{m()&&v(e=>pb(e),{mergeKey:Wi})},applyImageBorderCommand:e=>{m()&&v(t=>function(e,t){return hb(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=>{m()&&v(t=>mb(t,e),{mergeKey:Ui})},rotateImageCommand:e=>{m()&&v(t=>fb(t,e),{mergeKey:ji})},applyImageTransparencyCommand:e=>{m()&&v(t=>function(e,t){return null===ib(e)?e:hb(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:Vi})},resetImageCommand:()=>{m()&&v(e=>function(e){return null===ib(e)?e:hb(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:Ki})},handleListTab:e=>!A(t.document,t.selection.focus.paragraphId,lo(t))&&(!!w()&&(y(t=>"indent"===e?function(e){const t=to(e),n=pa(e).map((e,n)=>n<t.startIndex||n>t.endIndex?mn(e):e.list?be(e,(e.list.level??0)+1):mn(e));return Ce(e,n,N(n,t))}(t):Ax(t)),!0)),handleListEnter:C,handleListBoundaryBackspace:e=>{const n=S();return!(!n?.list||!f())&&(0===jt(n,t.selection.focus)&&(u(),p(),s(e=>Ax(e)),e.currentTarget.value="",d(),!0))}}}(e)}function Ox(e){return{fontFamily:e.fontFamily??"",fontSize:In(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 Dx(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 Ex(e){return function(e){const t=Fx({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:()=>Vn(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:Ox(e.toolbarStyleState())})},openParagraphDialog:()=>{e.setParagraphDialog({isOpen:!0,initial:Dx(e.toolbarStyleState())})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Lx(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Nx=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}},$x=[{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=pa(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Ma(t,{anchor:Bt(o,0),focus:Bt(r,J(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 zx(e){return function(e){const t=new Nx;$x.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(),!Vn(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))),n.currentTarget.value="",void e.focusInput();const t=pa(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===jt(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>Ax(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=J(r),l=Je(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(Ma(t,{anchor:Bt(r,l.start),focus:Bt(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(Ma(t,{anchor:Bt(r,a),focus:Bt(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(Aa(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 Hx=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var Wx={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"}},Ux={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},jx={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 Vx(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function Kx(e,t){return function(e,t){const n=Wx[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 _x(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Gx(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function Xx(e){return null!=e&&""!==e?Number(e):null}function Yx({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:Xx(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||"simple"===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,()=>(Ht(),{isActive:f()})),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)},()=>In(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)),()=>{const e=d();return e.mixedParagraphStyles?"":e.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(Xx(e)),()=>d().characterScale),setCharacterSpacing:s("setCharacterSpacing",e=>r.setCharacterSpacing(Xx(e)),()=>d().characterSpacing),setRunSnapToGrid:s("setRunSnapToGrid",e=>r.setRunSnapToGrid(_x(e)),()=>d().snapToGrid),setFitText:s("setFitText",e=>r.setFitText(Xx(e)),()=>d().fitText),setBaselineShift:s("setBaselineShift",e=>r.setBaselineShift(Xx(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(Xx(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(Xx(e)),()=>d().stylisticSet)}}function qx({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(_x(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(Xx(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(Xx(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(_x(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Gx(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Gx(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(_x(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(_x(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(_x(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(_x(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(_x(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(_x(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(_x(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(_x(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(_x(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(_x(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(_x(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(_x(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(_x(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(_x(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(Xx(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(Xx(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(Xx(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(Xx(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",Xx(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(Xx(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(Xx(e))),setListLevel:r("setListLevel",e=>t.setListLevel(Xx(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=fo(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 Jx({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 Qx({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 ew({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 tw({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(_x(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(_x(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(_x(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(_x(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(Xx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(Xx(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Gx(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 nw({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 ow({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",()=>{e.openParagraphDialog()})}}var rw=/* @__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"]),aw=/* @__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"]),iw=/* @__PURE__ */new WeakMap;function lw(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!aw.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=iw.get(n);r||(r=/* @__PURE__ */new WeakMap,iw.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==tb(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((rw.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function sw(e){return{state:()=>e.styleController.toolbarStyleState()}}function cw(e){return{isCollapsed:()=>Vn(e.state().selection)}}function dw(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var uw={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function pw(e){return/\p{L}|\p{N}/u.test(e)}function gw(e){return"."===e||"!"===e||"?"===e}function fw(e,t){return Bt(e,t)}function mw(e,t,n,o){return e-n||t-o}function hw(e,t){const n=pa(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:fw(o,t.startOffset),focus:fw(r,t.endOffset)}}:e}function bw(e,t,n){if(!t.length)return null;const o=pa(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?to(e,o).end:to(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=jt(l,a);return("next"===n?t.find(e=>mw(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>mw(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function yw(e){const t=pa(e),n=[],o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(const a of[...Nb(e),...$b(e)]){const e=a.paragraphIds[0];if(!e)continue;const t=r.get(e)??[];t.push(a.id),r.set(e,t)}return t.forEach((e,t)=>{for(const i of r.get(e.id)??[])o.has(i)||(o.add(i),n.push({id:i,startIndex:t,startOffset:0,endIndex:t,endOffset:e.runs.reduce((e,t)=>e+t.text.length,0)}));let a=0;for(const r of e.runs){const e=[r.revision?.id,r.styles?.propertyRevision?.id].filter(e=>"string"==typeof e);for(const i of e)o.has(i)||(o.add(i),n.push({id:i,startIndex:t,startOffset:a,endIndex:t,endOffset:a+r.text.length}));a+=r.text.length}}),n}function vw(e,t){const n=bw(e,yw(e),t);return n?hw(e,n):e}function xw(e){const t=pa(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)));mw(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>mw(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function ww(e,t){const n=bw(e,xw(e),t);return n?hw(e,n):e}function Sw(e){const t=xw(e);if(!t.length)return null;const n=to(e),o=t.find(e=>0===mw(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===mw(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>mw(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&mw(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function Iw(e,t){const n=yw(e).find(e=>e.id===t);return n?hw(e,n):e}var Cw=e=>Math.round(e/_n*96);function Tw(e,t=3){const n=[];for(const o of Ve(e.document)){const e=Fn(o.style?.styleId);if(null===e||e>t)continue;const r=J(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function kw(e){const t=xn(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 Pw(e,t){const n=yo("");return n.runs=e,t&&(n.style=t),n}function Rw(e,t,n){const o=void 0!==t?String(t):"";return Pw([kw({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:Cw(40),indentLeft:Cw(397*(e.level-1))})}function Bw(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return Ao(o*Hn,2)}function Mw(e,t,n,o){const r=Ne(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:re(Bt(o,0))}}function Aw(e,t=()=>{},n=3){if("main"!==bn(e))return e;const o=lo(e),r=Ne(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>Rw(e,t(e.id),n));return[Pw([kw({text:"",fieldChar:{kind:"begin"}}),kw({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),kw({text:"",fieldChar:{kind:"separate"}})]),...o,Pw([kw({text:"",fieldChar:{kind:"end"}})])]}(Tw(e,n),t,Bw(r)),i=Pr(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&Ae(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return Mw(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function Fw(e){let n=0,o="",r=-1,a=-1,i=!1;for(let l=0;l<e.length;l+=1){const s=e[l];if("paragraph"===s.type)for(const e of s.runs){const s=ot(e),c=t(e);if("begin"===s?.kind)n+=1,1===n&&(a=l,o="",i=!1,r=-1);else if(1===n&&void 0!==c)o+=c,/\bTOC\b/i.test(o)&&(i=!0);else if("separate"===s?.kind)1===n&&(r=l);else if("end"===s?.kind){if(1===n&&i)return{startBlockIndex:r>=0?r:a,endBlockIndex:l};n=Math.max(0,n-1)}}}return null}function Ow(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?wo(n):11,r="increase"===t?nr(o):Nn(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",Sr(r)),!0},n=e=>{const t=To(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=Ve(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:Bt(n,0),focus:Bt(o,J(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Le(e),o=J(t);let r=n,a=n;for(;r>0&&pw(o[r-1]);)r-=1;for(;a<o.length&&pw(o[a]);)a+=1;return Ma(e,{anchor:Bt(t,r),focus:Bt(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Le(e),o=J(t);let r=n;for(;r>0&&!gw(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!gw(o[a]);)a+=1;return a<o.length&&(a+=1),Ma(e,{anchor:Bt(t,r),focus:Bt(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=pa(e),n=to(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Ma(e,{anchor:Bt(o,0),focus:Bt(r,Lt(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=pa(e),a=$n(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Ma(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=cv(e.document,t)[Math.max(1,n)-1];return o?Ma(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 Ma(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=Vn(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Le(n),i=Z(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=pa(n).map((e,t)=>t===r?s:e);return Ce(n,c,re(Bt(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=pa(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?Ce(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=Ne(e.document)[lo(e)];return!!t&&null!==Fw(t.blocks)}(e.state()),hasRevisionsInSelection:()=>kx(e.state()).size>0,hasRevisionsInDocument:()=>Rx(e.state()),hasNavigableRevisions:()=>yw(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),xw(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=vw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=vw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=ww(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=ww(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==Sw(e.state()),isSelectedCommentResolved:()=>Boolean(Sw(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=>Aw(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=lo(e),r=Ne(e.document)[o];if(!r)return e;const a=Fw(r.blocks);if(!a)return e;const i=Tw(e,n).map(e=>Rw(e,t(e.id),Bw(r)));return Mw(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=>dv(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:Ji}),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:Hb(e,"insertions"),deletions:Hb(e,"deletions"),comments:Hb(e,"comments"),formatting:Hb(e,"formatting"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Xb(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:()=>(At(),!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,uw[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=>Ga(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>Ga(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>Vn(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 Dw(e,t){const n=my(e),o=n&&Jo(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=pa(e).map((e,n)=>n!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Yn(e))});return Ce(e,i,N(i,to(e)))}function Ew(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 Lw(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*Br),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*Br)}}}function Nw(e,t){const n=tb(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=pa(e).map((e,t)=>t!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id!==a.id?Yn(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Yn(e))});return Ce(e,i,N(i,to(e)))}function $w(e,t,n=90){return zw(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 zw(e,t){const n=my(e);if(!n||!Jo(n.run))return e;const{paragraphIndex:o,run:r}=n,a=pa(e).map((e,n)=>n!==o?mn(e):{...mn(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Yn(e))});return Ce(e,a,N(a,to(e)))}function Hw(e,t){return zw(e,e=>({...e,body:t(e.body??{})}))}var Ww={normal:"toolbar.style.builtin.normal",heading1:"toolbar.style.builtin.heading1",heading2:"toolbar.style.builtin.heading2",heading3:"toolbar.style.builtin.heading3",heading4:"toolbar.style.builtin.heading4",heading5:"toolbar.style.builtin.heading5",heading6:"toolbar.style.builtin.heading6",heading7:"toolbar.style.builtin.heading7",heading8:"toolbar.style.builtin.heading8",heading9:"toolbar.style.builtin.heading9",title:"toolbar.style.builtin.title",subtitle:"toolbar.style.builtin.subtitle",caption:"toolbar.style.builtin.caption",quote:"toolbar.style.builtin.quote",emphasis:"toolbar.style.builtin.emphasis",strong:"toolbar.style.builtin.strong",header:"toolbar.style.builtin.header",footer:"toolbar.style.builtin.footer",footnoteText:"toolbar.style.builtin.footnoteText",footnoteReference:"toolbar.style.builtin.footnoteReference"};function Uw(e,t=!0){const n=ea(e)??(t?ly(e):void 0);return n?Ww[n]:void 0}function jw(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of Ve(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 r=u(e.id,n),a="table"===e.type?mo(e.id,n).tableStyle:void 0,i=a?.conditionalFormats?.wholeTable,l=a?.conditionalFormats?.firstRow,s=a?.conditionalFormats?.band1Horz,c=i?.borders?.borderBottom??a?.borders?.borderBottom;return{id:e.id,name:e.name,labelKey:Uw(e,!t.sourcePackage),type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:r.fontFamily?.trim()||void 0,fontSize:"number"==typeof r.fontSize?r.fontSize:void 0,color:r.color??void 0,bold:r.bold??void 0,italic:r.italic??void 0,tablePreview:a?{wholeFill:i?.shading,headerFill:l?.shading,bandFill:s?.shading,borderColor:c?.color,headerColor:l?.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:()=>ac(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=ve(t),o=qe(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=Vn(e.selection)?e:Me(e),{paragraph:a,offset:i}=Le(r),l=Rt(a,0,i),s=Rt(a,i,Lt(a)),c=yo(""),d={...a,runs:l.length?l:yo("").runs},u={...a,id:c.id,runs:s.length?s:c.runs},p=[...i>0?[d]:[],...o,...s.length||"table"===o[o.length-1]?.type?[u]:[]];let g=!1;const f=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===a.id)return g=!0,t=!0,p;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=f(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},m=r.activeZone??"main";let h=r.document;if("footnote"===m&&r.activeFootnoteId&&r.document.footnotes?.items[r.activeFootnoteId]){const e=r.document.footnotes,t=e.items[r.activeFootnoteId],n=f(t.blocks);g&&(h={...r.document,footnotes:{...e,items:{...e.items,[r.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=qe(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const a="header"===m?"header":"footer"===m?"footer":"blocks",i=f(o[a]??[]);if(g){const e=[...t];e[n]={...o,[a]:i},h={...r.document,sections:e}}}if(!g)return e;const b=o[o.length-1],y="paragraph"!==b.type||s.length?Bt(u,0):Bt(b,Lt(b));return{...r,document:h,selection:re(y)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=Vn(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Le(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:[yo("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:nb(void 0,"front")},s=Xr("",Z(o,a),void 0,l),c=d(o,a,[s]),u=pa(n).map((e,t)=>t===r?c:mn(e));return Ce(n,u,re(Bt(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Dw(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:Nl}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Dw(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:$l}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Dw(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:zl}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=pa(e).map((e,n)=>n!==o?mn(e):{...mn(e),runs:e.runs.map(e=>e.id!==r.id?Yn(e):"image"===e.kind?{...e,image:{...e.image,floating:Ew(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Ew(e.textBox.floating,t)}}:Yn(e))});return Ce(e,a,N(a,to(e)))}(e,t),{mergeKey:Hl}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(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=pa(e).map((e,t)=>t!==o?mn(e):{...mn(e),runs:e.runs.map(e=>e.id!==r.id?Yn(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)}}:Yn(e))});return Ce(e,i,N(i,to(e)))}(e,t),{mergeKey:Wl}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=tb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=pa(e).map((e,o)=>o!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id!==a.id?Yn(e):"image"===e.kind?{...e,image:{...e.image,floating:Lw(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Lw(e.textBox.floating,t,n)}}:Yn(e))});return Ce(e,i,N(i,to(e)))}(e,t,n),{mergeKey:Ul}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=pa(e).map((e,n)=>n!==o?mn(e):{...mn(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Yn(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?rb(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?rb(n,t):n}}}return Yn(e)})});return Ce(e,a,N(a,to(e)))}(e,t),{mergeKey:jl}),setFloatingRotation:t=>e.applyTransactionalState(e=>Nw(e,t),{mergeKey:Vl}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>nb(e,t),{paragraphIndex:r,run:a}=n,i=pa(e).map((e,t)=>t!==r?mn(e):{...mn(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Yn(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 Yn(e)})});return Ce(e,i,N(i,to(e)))}(e,t),{mergeKey:Kl}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(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=pa(e).map((e,t)=>t!==r?mn(e):{...mn(e),runs:e.runs.map(e=>e.id!==a.id?Yn(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)}}:Yn(e))});return Ce(e,i,N(i,to(e)))}(e,t),{mergeKey:_l}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=tb(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=pa(e).map((e,t)=>t!==l?mn(e):{...mn(e),runs:e.runs.map(e=>{if(e.id!==s.id)return Yn(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 Yn(e)})});return Ce(e,c,N(c,to(e)))}(e,t),{mergeKey:Gl}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Dw(e,e=>({...e,preset:t}))}(e,t),{mergeKey:Xl}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Hw(e,e=>({...e,vert:n}))}(e,t),{mergeKey:Yl}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Hw(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:ql}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return zw(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:Zl}),rotateTextBox:t=>e.applyTransactionalState(e=>$w(e,t),{mergeKey:Jl}),getTextBoxSizeCm:()=>function(e){const t=my(e),n=t&&Jo(t.run);return n?{width:n.width/Wo,height:n.height/Wo}:null}(e.state()),isTextBoxSelected:()=>null!==my(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return zw(e,e=>({...e,width:Math.max(24,Math.round(t*Wo))}))}(e,t),{mergeKey:Ql}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return zw(e,e=>({...e,height:Math.max(24,Math.round(t*Wo))}))}(e,t),{mergeKey:es})}}function Vw(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!Vn(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function Kw(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=ib(e),n=t&&Dr(t.run);return n?{width:n.width/Wo,height:n.height/Wo}: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=ib(e);return(t&&Dr(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=ib(e);return(t&&Dr(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=ib(e),n=t&&Dr(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==ib(e.state())}}function _w(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 Gw(e,t){const n=bn(e),o=Ne(e.document);if("header"===n||"footer"===n){const r=lo(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=mt(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=lo(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 Xw(e,t){return null!==qw(e,t)}function Yw(e,t){const n=qw(e,t);if(!n)return e;const{nextBlocks:o}=n,r=Gw(e,o),a=o.flatMap(Ae);return{...r,selection:Zw(e.selection,a)}}function qw(e,t){const n=bn(e);if("footnote"===n)return null;const o=Kr(e,n);if(0===o.length)return null;const r=to(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)=>{Ae(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 Zw(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 Bt(r,Math.min(e.offset,Lt(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Jw(e,t){const n=function(e){const t=bn(e);if("footnote"===t)return null;const n=Kr(e,t);if(0===n.length)return null;const o=to(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=Ae(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:Qw(J(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=Gw(e,l),c=l.flatMap(Ae);return{...s,selection:eS(e.selection,c)}}function Qw(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function eS(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 Bt(r,Math.min(e.offset,Lt(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function tS(e,t){const n=to(e),o=pa(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=Fn(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 mn(e);const i=Fn(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?mn(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 mn(e);a=!0;const o=mn(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return mn(e);a=!0;const l=mn(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?Ce(e,i,N(i,n)):e}var nS=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function oS(e,t){return Math.abs(e-t)<1e-6}function rS(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var aS=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var iS=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var lS={width:1.5,type:"solid",color:"#000000"};function sS(e,t){const n=t.text??J(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 cS(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=to(e),o=pa(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 aS.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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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:iS.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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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{...mn(e),style:l}});return r?Ce(e,a,N(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=je(e,"indentFirstLine",null);return n=je(n,"indentHanging",null),"firstLine"===t?n=je(n,"indentFirstLine",o):"hanging"===t&&(n=je(n,"indentHanging",o)),n},{mergeKey:Gi}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=je(e,"borderTop",t);return n=je(n,"borderRight",t),n=je(n,"borderBottom",t),n=je(n,"borderLeft",t),n},{mergeKey:Xi}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>je(e,"borderBottom",lS),{mergeKey:Xi}),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=to(e),o=Math.min(8,Math.max(0,Math.round(t))),r=pa(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?Ce(e,i,N(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Xw(e.state(),"up")?(e.applyTransactionalState(e=>Yw(e,"up"),{mergeKey:Yi}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Xw(e.state(),"down")?(e.applyTransactionalState(e=>Yw(e,"down"),{mergeKey:qi}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Xw(e.state(),"up"),canMoveParagraphsDown:()=>Xw(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>tS(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>tS(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=to(e),n=pa(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||nS.every(e=>!(e in r)))return e;o=!0;const a=mn(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?Ce(e,r,N(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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=va(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!oS(e.position,t));return d.some(e=>oS(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=>!oS(e.position,t.position)),p.push(rS(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=mn(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=Ce(e,d,N(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:el}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=to(e),o=pa(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=mn(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?Ce(e,i,N(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return je(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>Jw(e,t)),hasDropCap:()=>function(e){const t=to(e);return pa(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=to(e),o=pa(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?mn(e):i?{...mn(e),dropCap:void 0}:{...mn(e),dropCap:sS(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Ce(e,l,N(l,n))}(e,t)),e.focusInput()}}}function dS(e){const t=Ne(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(lo(e),t.length-1))}}function uS(e,t){const{sections:n,sectionIndex:o}=dS(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 pS(e,t,n="default"){const o=aa(t,n);return uS(e,e=>e[o]?e:{...e,[o]:[x(t)]})}function gS(e,t,n="default"){const o=aa(t,n),r=uS(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:bn(r)===t?bS(r):r}function fS(e,t,n="default"){const o=pS(e,t,n),{sections:r,sectionIndex:a}=dS(o),i=(r[a][aa(t,n)]??[]).flatMap(Ae).find(Boolean);return i?{...o,selection:zo(Bt(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function mS(e){const{sections:t,sectionIndex:n}=dS(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function hS(e){const{sections:t,sectionIndex:n}=dS(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function bS(e){const{sections:t,sectionIndex:n}=dS(e),o=(t[n]?.blocks??[]).flatMap(Ae).find(Boolean);return o?{...e,selection:zo(Bt(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function yS(e){return function(e,t){const n=Vn(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Le(n),l=Rt(o,0,i),s=Rt(o,i,Lt(o)),c={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Z(o,i)},d=Ut(o,[...l,c,...s]),u=pa(n),p=[...r(u.slice(0,a)),d,...r(u.slice(a+1))];return Ce(n,p,re(Bt(d,i+c.text.length)))}(e,"PAGE")}function vS(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function xS(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},vS("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},vS("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[vS("PAGE",void 0,`run:page-field:${n}`,t)]}function wS(e,t="page",n){return function(e,t){const n=Vn(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Le(n),l=Z(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,Lt(o))]),d=pa(n),u=[...r(d.slice(0,a)),c,...r(d.slice(a+1))],p=s.reduce((e,t)=>e+t.text.length,0);return Ce(n,u,re(Bt(c,i+p)))}(e,xS(t,n))}function SS(e){const t=Ne(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(lo(e),t.length-1))}}function IS(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return wS(e,o,r);const i="top"===t?"header":"footer",l=aa(i,"default"),{sections:s,sectionIndex:c}=SS(e);if(0===s.length)return e;const d={id:Go("paragraph"),type:"paragraph",runs:xS(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:zo(Bt(d,0)),activeSectionIndex:c,activeZone:i}}function CS(e){const t={isLandscape:()=>{const t=lo(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=lo(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=lo(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=lo(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=lo(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=>Mn(e,t)),e.focusInput()},getPageNumbering:()=>{const t=lo(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:()=>Vo(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ra(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>ft(e,t)),e.focusInput()},getColumns:()=>cr(e.state()),setColumns:t=>{e.applyTransactionalState(e=>ua(e,t)),e.focusInput()},getVerticalAlign:()=>hn(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>h(e,t)),e.focusInput()},getSectionStart:()=>{const t=lo(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=lo(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>io(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 TS(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>fS(e,"header")),editFooter:()=>t(e=>fS(e,"footer")),editFirstPageHeader:()=>t(e=>fS(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>fS(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>fS(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>fS(e,"footer","evenPage")),insertPageNumber:()=>t(e=>yS(e)),insertPageNumberXOfY:()=>t(e=>wS(e,"xOfY")),placePageNumberTop:()=>t(e=>IS(e,"top")),placePageNumberBottom:()=>t(e=>IS(e,"bottom")),exit:()=>t(e=>function(e){return bS(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>mS(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(mS(e)===t)return e;let n=e;return t?(n=pS(n,"header","firstPage"),n=pS(n,"footer","firstPage"),n):(n=gS(n,"header","firstPage"),gS(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>hS(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(hS(e)===t)return e;let n=e;return t?(n=pS(n,"header","evenPage"),n=pS(n,"footer","evenPage"),n):(n=gS(n,"header","evenPage"),gS(n,"footer","evenPage"))}(t,e))}}function kS(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function PS(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=to(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:oo(),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:()=>kS(e.state()).map(e=>({id:e.id,name:e.name}))}}var RS=["January","February","March","April","May","June","July","August","September","October","November","December"],BS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function MS(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?BS[e.getDay()]:3===i.length?BS[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?RS[e.getMonth()]:3===i.length?RS[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 AS(e,t){const n=t.type??"REF";if(!function(e,t){return kS(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=Vn(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Le(o),s=Z(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},u=Ut(a,[...Rt(a,0,l),d,...Rt(a,l,Lt(a))]),p=pa(o),g=[...r(p.slice(0,i)),u,...r(p.slice(i+1))];return Ce(o,g,re(Bt(u,l+d.text.length)))}function FS(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,a=Vn(e.selection)?e:Me(e),{paragraph:i,index:l,offset:s}=Le(a),c=Z(i,s),d=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},u={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:MS(o,n),kind:"field",field:d,styles:c},p=Ut(i,[...Rt(i,0,s),u,...Rt(i,s,Lt(i))]),g=pa(a),f=[...r(g.slice(0,l)),p,...r(g.slice(l+1))],m=u.text.length;return Ce(a,f,re(Bt(p,s+m)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=MS(n,t);return 0===o.length?e:za(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>AS(e,t)),e.focusInput()}}}function OS(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=lo(e),n=C(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=Ne(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=Bo(o,n.tablePath);return r?.[r.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=Ko(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(C(e.state().document,e.state().selection.focus.paragraphId,lo(e.state()))),selectionLabel:()=>{const t=e.state();if(to(t).isCollapsed)return null;const n=lo(t),o=C(t.document,t.selection.anchor.paragraphId,n),r=C(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=i(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=i(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 Ts(t,"tblLook",o)},Fl),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Ts(t,"styleId",e||null),Ol),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Ts(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Dl),canSetAutoFit:()=>null!==ss(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return vs(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...ns(),type:"property",previous:{...r??{}}}});let a=os(r,"layout",n);return"window"===t?a=os(a,"width","100%"):"contents"===t&&(a=os(a,"width",null)),{...o,style:a}})}(t,e),Pl),distributeColumns:()=>o(e=>vs(e,e=>{const t=en(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}}}),Dl),distributeRows:()=>o(e=>vs(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}}),Dl),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!==ss(e.state()),convertToText:()=>o(e=>Fs(e),xl),canConvertToTable:()=>{return!ss(t=e.state())&&null!==hs(t);var t},convertToTable:()=>o(e=>Os(e),wl),canSplitTableAtRow:()=>function(e){const t=ss(e);if(!t)return!1;const n=ms(e);if(!n)return!1;const o=gs(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=ss(e);if(!t)return e;const n=ms(e);if(!n)return e;const o=gs(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=ma(i),c=ys(e,[l,yo(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:re(Bt(d,0))}:e}(e),Sl),canSortTable:()=>function(e){const t=ss(e);if(!t)return!1;const n=ms(e);if(!n)return!1;const o=gs(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=>Es(t,e),"ascending"===e?Il:Cl),canDeleteTable:()=>null!==ss(e.state()),deleteTable:()=>o(e=>function(e){const t=ss(e);if(!t)return e;const n=ms(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=yo(""),n=ys(e,[t]);return n===e?e:{...n,selection:re(Bt(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=ys(e,[]);if(a===e)return e;if(r){const e=pa(a).find(e=>e.id===r);if(e)return{...a,selection:re(Bt(e,0))}}return a}(e),Tl),canToggleRepeatHeaderRows:()=>function(e){const t=ss(e);if(!t)return!1;const n=ms(e);if(!n)return!1;const o=gs(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=ss(e);if(!t)return!1;const n=ms(e);if(!n)return!1;const o=gs(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&Ns(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=ss(e);if(!t)return e;const n=ms(e);if(!n)return e;const o=gs(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=Ns(o.rows[0]);return vs(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),Rl),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),al),split:()=>o(t=>e.tableOps.splitSelectedTable(t),il),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),ll),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),ll),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),sl),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),cl),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),cl),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),dl),canDeleteCell:()=>Zs(e.state()),deleteCell:()=>o(e=>Js(e),kl),cellShading:e=>o(t=>Is(t,"shading",e||null),ul),cellBorders:()=>o(e=>Cs(e,{width:1,type:"solid",color:"#64748b"}),pl),cellNoBorders:()=>o(e=>Cs(e,{width:0,type:"none",color:"transparent"}),pl),applyBorderPreset:e=>o(t=>function(e,t,n=xs){const o=Ss(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,ws);c("top",ws),c("right",ws),c("bottom",ws),c("left",ws);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 Ae(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:{...ns(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=os(o,e,r);return{...t,style:o}},f=Ne(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),pl),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Ts(e,"width","100%"),gl),alignLeft:()=>o(e=>Is(e,"horizontalAlign","left"),fl),alignCenter:()=>o(e=>Is(e,"horizontalAlign","center"),fl),alignRight:()=>o(e=>Is(e,"horizontalAlign","right"),fl),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,Is(Is(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},ml),getCellAlignmentState:()=>function(e){const t=Ss(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=>Is(t,"verticalAlign",e),hl),setCellTextDirection:e=>o(t=>Is(t,"textDirection",e),bl),setCellWidth:e=>o(t=>function(e,t){return Is(e,"width",t)}(t,e),yl),setCellNoWrap:e=>o(t=>function(e,t){return Is(e,"noWrap",t)}(t,e),yl),setCellFitText:e=>o(t=>function(e,t){return Is(e,"fitText",t)}(t,e),yl),canSetCellMargins:()=>null!==ss(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Is(n,"paddingTop",t.top)),void 0!==t.right&&(n=Is(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Is(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Is(n,"paddingLeft",t.left)),n}(t,e),Bl),canSetCellSpacing:()=>$s(e.state()),setCellSpacing:e=>o(t=>function(e,t){return $s(e)?Ts(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),Bl),canSetTableIndent:()=>zs(e.state()),setTableIndent:e=>o(t=>function(e,t){return zs(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Ts(e,"indentLeft",null):Ts(e,"indentLeft",Math.round(2*t)/2):e}(t,e),Bl),canSetTableAlignment:()=>null!==ss(e.state()),setTableAlignment:e=>o(t=>Ws(t,e),Bl),canEvaluateTableFormula:()=>null!==ss(e.state()),evaluateTableFormula:e=>o(t=>Vs(t,e),Ml),canSelectTable:()=>null!==ss(e.state()),selectTablePart:t=>e.applyState(Ys(e.state(),t)),canSetActiveTableRowHeight:()=>null!==ss(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=Ps(n,"height",t.height),void 0!==t.heightRule&&(n=Ps(n,"heightRule",t.heightRule)),n}(t,e),Al),canSetActiveTableRowBreakAcrossPages:()=>Us(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Us(e)?Ps(e,"cantSplit",null===t?null:!t):e}(t,e),Al),canSetActiveTableRowHeader:()=>null!==ss(e.state()),setActiveTableRowHeader:e=>o(t=>Rs(t,e),Rl),canSetActiveTableColumnWidth:()=>null!==ss(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=ss(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=gs(is(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=en(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:As(e,a.id,{[l]:t})}(t,e),vl),canSetActiveTableWidth:()=>null!==ss(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=ss(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=gs(is(e.document,o,r.zone),r.tablePath);return a?ks(e,a.id,"width",t):e}(t,e),gl),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function DS(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>Kx(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Ux[t]??Ux.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]=jx[t]??jx.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=>Vx(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return Vx(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return Vx(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 ES(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:{...Yx({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}),...qx({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}),...ow({dialog:e.dialog,actionCommand:r}),...Jx({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...tw({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...nw({design:e.design,actionCommand:r}),...Qx({bookmark:e.bookmark,actionCommand:r}),...ew({fields:e.fields,actionCommand:r})}}}({gate:lw(e),style:sw(e),selection:cw(e),history:dw(e),formatting:Ow(e),document:jw(e),link:Vw(e),image:Kw(e),browser:_w(e),paragraph:cS(e),section:CS(e),headerFooter:TS(e),table:OS(e),design:DS(e),bookmark:PS(e),fields:FS(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var LS=[{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 NS(t){const n=ES(t.essentials),{runtimePlugins:o,toolbarRegistry:r,menuRegistry:a,dispose:i}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=Qn(),i=new e;for(const e of Fr(t.t))a.register(e);for(const e of LS)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,ribbonGroupGrid:t.ribbonGroupGrid,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}),l=function(e){const[t,n]=gn(!1),[o,r]=gn(new Do({doc:e.initialDocument}));let a=!1;const i=e=>{const t=ta(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=Tt(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=Tt(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await Do.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:o,focusEditor:t.focusEditor,logger:t.logger,onExecuted:t.onExecuted,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return er(()=>{l.initialize()}),Lr(()=>{l.dispose(),i()}),{toolbarRegistry:r,menuRegistry:a,runtimeReady:l.runtimeReady,runtimeEditor:l.runtimeEditor,commandStateOf:l.commandStateOf,toolbarHost:l.toolbarHost}}var $S=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function zS(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!$S.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 HS(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Ex({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=zS((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}=NS({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:Lx({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=ic(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=Ve(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:Px(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:Px(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(Cn(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=or();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=Kx(e,n.themeId)),e=Vx(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}),fe(()=>{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}=zx({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=>{Hx.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}]`),wn("input-to-layout"),v(e),po("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 WS(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 US(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=WS(e,n.commentId)??WS(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 jS(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 VS(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!jS(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),!jS(e,t.items[i]))return!1;r.push(i)}}return!0}function KS(e){const[t,n]=gn(null),[o,r]=gn(""),[a,i]=gn(!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!==Eo(e.state()),p=t=>d()&&Boolean(e.state().document.comments?.items[t]),g=()=>d()&&null!==Sw(e.state()),f=t=>!e.isReadOnly()&&jS(s(),e.state().document.comments?.items[t]),m=()=>{const t=Sw(e.state());return null!==t&&f(t.id)},h=t=>!e.isReadOnly()&&VS(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)=>US(e,t,{id:Go("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()},I=t=>{if(!h(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!VS(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},C=(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||!jS(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=Sw(e.state());return null!==t&&h(t.id)},deleteSelected:()=>{const t=Sw(e.state());return!!t&&I(t.id)},deleteById:I,canResolveId:b,canResolveSelected:()=>{const t=Sw(e.state());return null!==t&&b(t.id)},resolveSelected:t=>{const n=Sw(e.state());return!!n&&C(n.id,t)},resolveById:C,authorName:()=>c()?.displayName??o(),authorLocked:()=>void 0!==s(),openNew:()=>!!u()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!g())return!1;const t=Sw(e.state());return!!t&&x(t.id)},openReplyToId:x,openEdit:()=>{if(!m())return!1;const t=Sw(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:Go("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&&!jS(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!d())return t;const n="edit"===a.mode?_e(t,a.commentId,u):"reply"===a.mode?Mo(t,a.parentId,p):l({...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 _S=/*#__PURE__*/te("<div class=oasis-review-comments-filters role=group>"),GS=/*#__PURE__*/te("<div class=oasis-review-comments-list>"),XS=/*#__PURE__*/te("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),YS=/*#__PURE__*/te("<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>"),qS=/*#__PURE__*/te("<div class=oasis-review-thread-replies>"),ZS=/*#__PURE__*/te("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),JS=/*#__PURE__*/te("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),QS=/*#__PURE__*/te("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function eI(e){const t=Lo(),[n,o]=gn("all"),[r,a]=gn(!1),[i,l]=gn(""),[s,c]=gn(null),[d,u]=gn(null),p=()=>e.state().document.comments,g=ln(()=>{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,...k(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),f=e=>k(p()?.items??{},e),m=ln(()=>{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=YS(),v=y.firstChild,x=v.nextSibling,W(v,vr(ht,{as:"strong",get children(){return t("review.commentsPanel")}}),null),W(v,vr(H,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),W(x,vr(H,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),W(x,vr(H,{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),W(y,vr(ht,{as:"p",get children(){return le(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${p()?.order.length??0}`}}),null),W(y,vr(go,{get label(){return le(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),W(y,vr(X,{get when(){return!r()},get children(){return[(a=_S(),W(a,vr(H,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),W(a,vr(H,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),W(a,vr(H,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),Qt(()=>ut(a,"aria-label",t("review.filterComments"))),a),(r=GS(),W(r,vr(X,{get when(){return 0===g().length},get children(){return vr(ht,{as:"p",get children(){return t("review.noComments")}})}}),null),W(r,vr(_t,{get each(){return g()},children:n=>{return o=ZS(),r=o.firstChild,a=r.nextSibling,W(r,vr(ht,{as:"strong",get children(){return n.author||"—"}}),null),W(r,vr(ht,{as:"span",get children(){return le(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),W(o,vr(ht,{as:"p",get children(){return n.text}}),a),W(a,vr(H,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),W(a,vr(X,{get when(){return e.composer.canEditId(n.id)},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),W(a,vr(X,{get when(){return e.composer.canResolveId(n.id)},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return le(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),W(a,vr(X,{get when(){return e.composer.canReplyId(n.id)},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),W(a,vr(X,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[vr(H,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-comment-delete",get children(){return le(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),vr(X,{get when(){return d()===n.id},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),W(o,vr(X,{get when(){return f(n.id).length>0},get children(){return vr(H,{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 le(()=>s()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${f(n.id).length})`}})}}),null),W(o,vr(X,{get when(){return s()===n.id},get children(){var o=qS();return W(o,vr(_t,{get each(){return f(n.id)},children:n=>{return o=JS(),r=o.firstChild,W(o,vr(ht,{as:"strong",get children(){return n.author||"—"}}),r),W(o,vr(ht,{as:"p",get children(){return n.text}}),r),W(r,vr(X,{get when(){return e.composer.canEditId(n.id)},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),W(r,vr(X,{get when(){return e.composer.canReplyId(n.id)},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),W(r,vr(X,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[vr(H,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-reply-delete",get children(){return le(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),vr(X,{get when(){return d()===n.id},get children(){return vr(H,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),Qt(()=>ut(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),Qt(()=>ut(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),W(y,vr(X,{get when(){return r()},get children(){var n=XS();return W(n,vr(X,{get when(){return 0===m().length},get children(){return vr(ht,{as:"p",get children(){return t("review.activity.empty")}})}}),null),W(n,vr(_t,{get each(){return m()},children:n=>{return o=QS(),r=o.firstChild,W(r,vr(ht,{as:"strong",get children(){return n.actorName}}),null),W(r,vr(ht,{as:"span",get children(){return h(n.timestamp)}}),null),W(o,vr(ht,{as:"p",get children(){return[le(()=>(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))," — ",le(()=>n.targetAuthor),le(()=>le(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),W(o,vr(X,{get when(){return Boolean(p()?.items[n.commentId])},get children(){return vr(H,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),Qt(()=>ut(o,"data-activity-kind",n.kind)),o;var o,r}}),null),Qt(()=>ut(n,"aria-label",t("review.activity.title"))),n}}),null),Qt(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&ut(y,"aria-label",e.e=n),o!==e.t&&ut(x,"aria-label",e.t=o),e},{e:void 0,t:void 0}),y;var y,v,x}var tI="oasis-reviewing-pane-v1";function nI(){const[e,t]=gn(function(){try{return"true"===globalThis.localStorage?.getItem(tI)}catch{return!1}}()),n=e=>{t(e),function(e){try{globalThis.localStorage?.setItem(tI,String(e))}catch{}}(e)};return{open:()=>e(),toggle:()=>(n(!e()),!0),close:()=>{n(!1)}}}var oI=/*#__PURE__*/te("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),rI=/*#__PURE__*/te("<div class=oasis-review-revision-footer>"),aI=/*#__PURE__*/te('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),iI=/*#__PURE__*/te("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function lI(e,t){const n=pa(e),o=[];for(const a of n)for(const e of a.runs)e.revision?.id!==t&&e.styles?.propertyRevision?.id!==t||o.push(e.text);const r=o.join("").trim();return r.length>96?`${r.slice(0,93)}…`:r}function sI(e){const t=Lo(),n=ln(()=>{const t=e.state(),n=pa(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}));const n=t.styles?.propertyRevision;n&&(o.has(n.id)||o.set(n.id,n.author),r.has(n.id)||r.set(n.id,{date:n.date,type:"property"}))}const a=new Map(Nb(t).map(e=>[e.id,e])),i=new Map($b(t).map(e=>[e.id,e]));return yw(t).map(e=>{const n=r.get(e.id),l=a.get(e.id),s=i.get(e.id);return{id:e.id,type:n?.type??l?.type??s?.type??"insert",author:o.get(e.id)??l?.author??s?.author??"—",date:n?.date??l?.date??s?.date,snippet:lI(t,e.id)||l?.snippet||s?.snippet||"",section:void 0!==s}})}),o=ln(()=>{const t=e.state();return n().filter(e=>jb(t,e.type,e.author))});return r=aI(),a=r.firstChild,W(a,vr(ht,{as:"strong",get children(){return t("review.reviewingPane")}}),null),W(a,vr(H,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),W(r,vr(ht,{as:"p",get children(){return[le(()=>t("review.revisionCount")),": ",le(()=>o().length)]}}),null),W(r,vr(X,{get when(){return n().length-o().length>0},get children(){return vr(ht,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),W(r,vr(X,{get when(){return o().length>0},get fallback(){return vr(ht,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=oI();return W(n,vr(_t,{get each(){return o()},children:n=>{return o=iI(),r=o.firstChild,a=r.nextSibling,W(r,vr(ht,{as:"span",get class(){return"oasis-review-revision-type "+(e=n.type,n.section?"review-revisions-icon-section":"delete"===e?"review-revisions-icon-delete":"property"===e?"review-revisions-icon-property":"grid"===e?"review-revisions-icon-grid":"review-revisions-icon-insert");var e},get"data-revision-type"(){return n.type},get children(){return[vr(It,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),vr(ht,{as:"span",get children(){return e=n.type,o=n.section,t(o?"review.revisionSection":"insert"===e||"delete"===e?"insert"===e?"review.revisionInsert":"review.revisionDelete":"grid"===e?"review.revisionGrid":"review.revisionProperty");var e,o}})]}}),null),W(r,vr(ht,{as:"p",get children(){return n.snippet||"—"}}),null),W(r,vr(ht,{as:"span",get children(){return n.author}}),null),W(a,vr(H,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),W(a,vr(H,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),W(a,vr(H,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),Qt(e=>{var t=n.id,r=n.section?"true":void 0;return t!==e.e&&ut(o,"data-comment-id",e.e=t),r!==e.t&&ut(o,"data-revision-section",e.t=r),e},{e:void 0,t:void 0}),o;var o,r,a}})),n}}),null),W(r,vr(X,{get when(){return o().length>0},get children(){var n=rI();return W(n,vr(H,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),W(n,vr(H,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),Qt(()=>ut(r,"aria-label",t("review.reviewingPane"))),r;var r,a}var cI=/*#__PURE__*/te('<div class="oasis-editor-shell oasis-editor-app">');function dI(e={}){const t=e.runtime?.client??z(),[n,o]=gn({}),r=()=>({...e.ui??{},...n(),toolbar:{...e.ui?.toolbar??{},...n().toolbar??{}}}),a=()=>({...e.document??{},...void 0===n().readOnly?{}:{readOnly:n().readOnly}}),i=()=>({...r(),readOnly:a().readOnly}),l=e=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...i(),...e}),c=()=>e.runtime??{};ki();const d=s(()=>r().locale??"pt-BR"),u=Ke("app"),{state:p,commitState:g,getStateSnapshot:f}=function(e){const t=e.initialState?Bn(e.initialState):e.initialDocument?Cn(e.initialDocument):or();let n=t;const[o,r]=gn(t),a=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}}});return{state:a,setStateSignal:r,commitState:e=>{const t=An(e===a?n:e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),m=e=>{g(e)},h=Bn;let b=!1;const{showChrome:y,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,showRuler:C,toggleOutline:k,toolbarView:P,toolbarLayout:R,isReadOnly:B,useComposedShell:M,loadingOptions:O,loadingLabel:E,shellComponent:L}=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,showRuler:()=>t().showRuler??t().showChrome??!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?S:Pt}}}({ui:r,documentOptions:a,updateUiState:l,state:()=>p}),N=function(){const[e,t]=gn(!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.focused,H=N.setFocused,U=N.focusInput,j=N.focusInputAfterPointerSelection,V=N.focusInputSync,[K,_]=gn(!1!==r().loading),G=ce(),{linkDialog:Y,setLinkDialog:q,imageAltDialog:Z,setImageAltDialog:J,imageCaptionDialog:Q,setImageCaptionDialog:ee,contextMenu:te,setContextMenu:ne,fontDialog:oe,setFontDialog:re,paragraphDialog:ae,setParagraphDialog:ie,tablePropertiesDialog:se,setTablePropertiesDialog:de,revisionBulkDialog:ue,setRevisionBulkDialog:pe,newDocumentDialog:ge,setNewDocumentDialog:fe,symbolDialog:me,setSymbolDialog:he,equationDialog:be,setEquationDialog:ye}=function(){const[e,t]=gn({isOpen:!1}),[n,o]=gn({isOpen:!1}),[r,a]=gn({isOpen:!1}),[i,l]=gn({isOpen:!1,initialHref:""}),[s,c]=gn({isOpen:!1,initialAlt:""}),[d,u]=gn({isOpen:!1,initialCaption:""}),[p,g]=gn({isOpen:!1,x:0,y:0}),[f,m]=gn({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]=gn({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]=gn({isOpen:!1,action:"accept",count:0}),[x,w]=gn({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}}(),[ve,xe]=gn(!1),we=()=>N.viewportRef,Se=()=>N.surfaceRef,Ie=fy({documentOptions:a,logger:u,runtimeClient:t,state:p,commitState:g,getStateSnapshot:f,applyState:m,cloneState:h,isReadOnly:B,focusInput:U,surfaceRef:Se,viewportRef:we,zoomFactor:G.zoomFactor,getImageOps:()=>Ye.imageOps}),{docIO:Ce,measuredBlockHeights:Te,measuredParagraphLayouts:ke,documentLayout:Pe,canvasSnapshotProvider:Re,inputBox:Be,selectionBoxes:Me,commentHighlights:Ae,revisionMarkupBoxes:Fe,changeBarBoxes:Oe,selectedImageBox:De,selectedTextBoxBox:Ee,selectedTableBox:Le,caretBox:Ne,preferredColumnX:$e,setPreferredColumnX:ze,clearPreferredColumn:He,onCleanupHook:We,persistenceStatus:Ue,applyTransactionalState:je,resetTransactionGrouping:Ve,updateHistoryState:_e}=Ie,Xe=li({state:()=>p,isReadOnly:B,applyTransactionalState:je,applyTableAwareParagraphEdit:(e,t)=>Ye.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:He,resetTransactionGrouping:Ve,focusInput:U}),Ye=hx({clipboardActions:Xe,state:p,logger:u,isReadOnly:B,applyState:m,cloneState:h,focusInput:U,focusInputAfterPointerSelection:j,focusInputSync:V,surfaceRef:Se,viewportRef:we,zoomFactor:G.zoomFactor,insertImageFromFile:Ce.insertImageFromFile,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},getCommandsController:()=>vt.commandsController,applyTransactionalState:je,clearPreferredColumn:He,resetTransactionGrouping:Ve,updateHistoryState:_e,caretBox:Ne,preferredColumnX:$e,setPreferredColumnX:ze,measuredBlockHeights:Te,measuredParagraphLayouts:ke,documentLayout:Pe,canvasSnapshotProvider:Re,openEquationDialog:(e,t)=>{ye({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:qe,fr:Ze,tableOps:Je,imageOps:Qe,textBoxOps:et,styleController:tt,onEditorPointerDown:nt,tableResize:ot,tableCornerResize:rt,tableDrag:at,revisionController:it,textDrag:lt,surfaceEventsWithTextDrag:st,textInput:ct,handleCopy:dt,handleCut:pt,handlePaste:gt,handleDrop:ft}=Ye,[mt,ht]=gn(!1),bt=nI(),yt=KS({state:()=>p,isReadOnly:B,applyTransactionalState:je,focusInput:U,access:()=>c().review}),vt=HS({commandSearch:{isOpen:mt,setIsOpen:e=>{ht(e)}},setCommandSearchOpen:ht,clipboardActions:Xe,document:Ie,interaction:Ye,commentComposer:yt,state:p,logger:u,isReadOnly:B,focusInput:U,applyState:m,getStateSnapshot:f,cloneState:h,setFocused:H,setInitialLoading:_,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},locale:()=>r().locale??"pt-BR",translator:d,runtimeClient:t,runtimeOptions:c,documentOptions:a,getUiState:i,updateUiState:l,zoom:G,importInputRef:()=>N.importInputRef,imageInputRef:()=>N.imageInputRef,setLinkDialog:q,setImageAltDialog:J,setImageCaptionDialog:ee,setNewDocumentDialog:fe,setSymbolDialog:he,setEquationDialog:ye,setTablePropertiesDialog:de,setFontDialog:re,setParagraphDialog:ie,setRevisionBulkDialog:pe,toggleOutline:k,isOutlineVisible:I,toggleRevisionsPanel:()=>{bt.toggle()},revisionsPanelVisible:bt.open}),{commandsController:xt,runtimeReady:wt,runtimeEditor:St,toolbarHost:It,toolbarRegistry:Ct,menuRegistry:Tt,handleKeyDown:kt}=vt,Rt=()=>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}(Ct.getOrdered(),Tt.getItems(),d),Mt=e=>{try{return!1!==St().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:At,computeFontSizeOptions:Ft,applyFontDialogValues:Ot,applyParagraphDialogValues:Dt,setParagraphDialogDefault:Et,applyTablePropertiesDialogValues:Lt,buildContextMenuItems:Nt,handleEditorContextMenu:zt,closeContextMenu:Ht}=dc({clipboardActions:Xe,state:()=>p,selection:()=>p.selection,toolbarStyleState:tt.toolbarStyleState,isReadOnly:B,t:d,logger:u,setFontDialog:re,setParagraphDialog:ie,setTablePropertiesDialog:de,setContextMenu:ne,clearPreferredColumn:He,resetTransactionGrouping:Ve,applyTransactionalState:je,applyTableAwareParagraphEdit:Je.applyTableAwareParagraphEdit,focusInput:U,promptForLink:xt.promptForLink,tableOps:Je}),{layout:Wt,overlays:Ut,refs:jt,surfaceHandlers:Vt,inputHandlers:_t,fileHandlers:Gt}=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,changeBarBoxes:n.changeBarBoxes,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:Pe,remoteWebFonts:a().remoteWebFonts,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:G.zoomPercent,setZoomPercent:G.setZoomPercent,zoomFactor:G.zoomFactor},overlays:{selectionBoxes:Me,commentHighlights:Ae,revisionMarkupBoxes:Fe,changeBarBoxes:Oe,onReplyToComment:e=>{yt.openReplyToId(e)},onEditComment:e=>{yt.openEditToId(e)},canEditComment:yt.canEditId,canReplyComment:yt.canReplyId,selectedImageBox:De,selectedTextBoxBox:Ee,selectedTableBox:Le,layoutOptions:qe,caretBox:Ne,inputBox:Be,hoveredRevision:it.hoveredRevision,focused:$,showCaret:()=>function(e,t){if(!t.visible||!Vn(e.selection))return!1;const n=lo(e),o=A(e.document,e.selection.anchor.paragraphId,n),r=A(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(p,Ne()),importProgress:Ce.importProgress,imageCropMode:Qe.cropMode},refs:{focusController:N},files:{handleImportFile:Ce.handleImportFile,handleInsertImage:Ce.handleInsertImage},surface:{surfaceEvents:st,tableResize:ot,tableCornerResize:rt,tableDrag:at,revisionController:it,handleDrop:ft,onEditorPointerDown:nt,handleImagePointerDown:Qe.handleImagePointerDown,handleImageResizeHandlePointerDown:Qe.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:et.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Qe.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Qe.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Qe.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:et.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:zt},input:{textInput:ct,setFocused:H,handleCopy:dt,handleCut:pt,handlePaste:gt,handleKeyDown:e=>{if("Escape"===e.key&&Ye.formatPainter.mode())return Ye.formatPainter.cancel(),void e.preventDefault();kt(e)},handleKeyUp:e=>{Ye.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Ye.formatPainter.applyToSelection("keyboard")}}});return er(()=>{F(),En(),vo(),ha(()=>Se()??null),wa(),(r().showWelcome??!0)&&!Kt()&&$t()&&xe(!0)}),Lr(()=>{We(),st.stopDragging(),lt.stopDrag(),ot.stop(),rt.stop(),at.stop(),Qe.stopImageDrag(),Qe.stopImageResize(),Qe.stopImageCrop(),et.stopTextBoxResize(),T()}),vr(Ge,{translator:d,get children(){var e=cI();return Sa(e,"--oasis-editor-gutter-x","34px"),W(e,vr(X,{get when(){return le(()=>!(M()||!y()))()&&w()},get children(){return vr(fn,{host:It,registry:Ct,get showFileGroup(){return!!le(()=>"ribbon"===P())()||!x()},get view(){return P()},get layout(){return R()}})}}),null),W(e,vr(di,{get notice(){return Xe.notice},onDismiss:()=>{Xe.dismiss(),U()}}),null),W(e,vr(X,{get when(){return yt.panelOpen()},get children(){return vr(eI,{state:()=>p,composer:yt,locale:()=>r().locale??"pt-BR",get onClose(){return yt.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=pa(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:Bt(s,a.offset),focus:Bt(c,i.offset)}}:e}(p,e);t!==p&&(m(t),U())}})}}),null),W(e,vr(X,{get when(){return bt.open()},get children(){return vr(sI,{state:()=>p,get onClose(){return bt.close},onNavigate:e=>{const t=Iw(p,e);t!==p&&(m(t),U())},onAccept:e=>{const t=Iw(p,e);t!==p&&(m(t),xt.applyAcceptRevisionsCommand(),U())},onReject:e=>{const t=Iw(p,e);t!==p&&(m(t),xt.applyRejectRevisionsCommand(),U())},onAcceptAll:()=>St().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>St().commands.execute("requestRejectAllRevisions")})}}),null),W(e,vr(yi,{get isOpen(){return mt()},get entries(){return Rt()},isEnabled:Mt,onExecute:e=>{St().commands.execute(e.command,e.payload),ht(!1),U()},onClose:()=>{ht(!1),U()}}),null),W(e,vr(Vd,{commentComposer:yt,dialogs:{linkDialog:Y,setLinkDialog:q,imageAltDialog:Z,setImageAltDialog:J,imageCaptionDialog:Q,setImageCaptionDialog:ee,contextMenu:te,setContextMenu:ne,fontDialog:oe,setFontDialog:re,paragraphDialog:ae,setParagraphDialog:ie,tablePropertiesDialog:se,setTablePropertiesDialog:de,revisionBulkDialog:ue,setRevisionBulkDialog:pe,newDocumentDialog:ge,setNewDocumentDialog:fe,symbolDialog:me,setSymbolDialog:he,equationDialog:be,setEquationDialog:ye},findReplace:Ze,fontFamilyOptions:At,fontSizeOptions:Ft,contextMenuItems:Nt,focusInput:U,get applyLinkCommand(){return xt.applyLinkCommand},get applyImageAltCommand(){return xt.applyImageAltCommand},get applyImageCaptionCommand(){return xt.applyImageCaptionCommand},applyFontDialogValues:Ot,applyParagraphDialogValues:Dt,setParagraphDialogDefault:Et,applyTablePropertiesDialogValues:Lt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{St().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),U()},insertSymbol:(e,t)=>{St().commands.execute("insertText",{text:e,fontFamily:t}),U()},applyEquation:(e,t)=>{t?St().commands.execute("updateEquation",{runId:t,expression:e}):St().commands.execute("insertEquation",e),U()},closeContextMenu:Ht}),null),W(e,vr(_d,{useComposedShell:M,shellComponent:L,runtime:{state:()=>p,toolbarHost:It,runtimeEditor:St,persistenceStatus:Ue,toolbarRegistry:Ct,menuRegistry:Tt},chrome:{showChrome:y,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,showRuler:C,toolbarView:P,toolbarLayout:R},view:{isReadOnly:B,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:Te,measuredParagraphLayouts:ke,documentLayout:Pe,layout:Wt,overlays:Ut,refs:jt,surfaceHandlers:Vt,inputHandlers:_t,fileHandlers:Gt}}),null),W(e,vr(hc,{state:p,get surfaceRef(){return Se()},documentLayout:Pe,snapshotProvider:Re,get zoomFactor(){return G.zoomFactor},tableResize:ot,tableCornerResize:rt,imageOps:Qe,tableDrag:at,textDrag:lt}),null),W(e,vr(X,{get when(){return K()||!wt()},get children(){return vr(D,{get label(){return E()},get class(){return O()?.class},get style(){return O()?.style}})}}),null),W(e,vr(Xd,{get isOpen(){return le(()=>!(!ve()||K()))()&&wt()},onClose:()=>xe(!1)}),null),Qt(t=>{var n=r().theme??"light",o=!!M(),a=!!B(),i=!("simplified"!==r().toolbar?.ribbonStyle),l=!(null===Ye.formatPainter.mode());return n!==t.e&&ut(e,"data-theme",t.e=n),o!==t.t&&e.classList.toggle("oasis-editor-docs",t.t=o),a!==t.a&&e.classList.toggle("oasis-editor-read-only",t.a=a),i!==t.o&&e.classList.toggle("oasis-editor-ribbon-simplified",t.o=i),l!==t.i&&e.classList.toggle("oasis-editor-format-painter-active",t.i=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})}export{dI as OasisEditorApp};
|