oasis-editor 0.0.403 → 0.0.404
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-DWpOSren.js +1 -0
- package/dist/assets/{importDocxWorker-gjomIN7s.js → importDocxWorker-Cza4hyf3.js} +2 -2
- package/dist/core/document/tocLinks.d.ts +13 -0
- package/dist/core/document/tocOutline.d.ts +5 -0
- package/dist/{defaultToolbar-DEdxC5tS.js → defaultToolbar-DOUMCB_G.js} +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/OasisEditorApp-Dy8dQUQs.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-CjpNFd0O.js";import{$ as t,$i as n,$n as o,$r as r,$t as a,A as i,An as s,Ar as l,At as c,B as d,Bi as u,Bn as p,C as g,Ci as f,Cn as m,Cr as h,Ct as b,D as y,Di as v,Dn as x,Dr as w,Dt as S,E as I,Ei as C,En as T,Er as k,Et as P,F as R,Fn as B,Ft as M,G as O,Gi as A,Gn as F,Gt as D,H as E,Hi as L,Hn as N,I as z,In as $,It as H,J as W,Ji as U,Jn as j,Jr as V,Jt as K,K as _,Ki as X,Kn as G,Kt as q,L as Y,Ln as Z,Lt as J,M as Q,Mn as ee,Mr as te,Mt as ne,N as oe,Nn as re,Nt as ae,O as ie,Oi as se,On as le,Or as ce,Ot as de,P as ue,Pn as pe,Pr as ge,Pt as fe,Q as me,Qi as he,Qn as be,Qr as ye,Qt as ve,R as xe,Ri as we,Rn as Se,Rt as Ie,S as Ce,Si as Te,Sn as ke,Sr as Pe,St as Re,T as Be,Ti as Me,Tn as Oe,Tr as Ae,Tt as Fe,U as De,Ui as Ee,Un as Le,V as Ne,Vi as ze,Vn as $e,W as He,Wi as We,Wn as Ue,Wt as je,X as Ve,Xi as Ke,Xn as _e,Xr as Xe,Xt as Ge,Y as qe,Yi as Ye,Yn as Ze,Yr as Je,Yt as Qe,Z as et,Zn as tt,Zr as nt,Zt as ot,_ as rt,_i as at,_n as it,_r as st,_t as lt,a as ct,aa as dt,ai as ut,an as pt,ar as gt,at as ft,b as mt,bi as ht,bn as bt,br as yt,bt as vt,c as xt,ca as wt,ci as St,cn as It,cr as Ct,ct as Tt,d as kt,da as Pt,di as Rt,dn as Bt,dr as Mt,dt as Ot,ei as At,en as Ft,er as Dt,et as Et,f as Lt,fa as Nt,fi as zt,fn as $t,fr as Ht,ft as Wt,g as Ut,ga as jt,gi as Vt,gn as Kt,gr as _t,gt as Xt,h as Gt,ha as qt,hn as Yt,hr as Zt,ht as Jt,i as Qt,ia as en,ii as tn,in as nn,ir as on,it as rn,j as an,jn as sn,jr as ln,k as cn,ki as dn,kn as un,kr as pn,kt as gn,l as fn,la as mn,ln as hn,lr as bn,lt as yn,m as vn,ma as xn,mi as wn,mn as Sn,mr as In,mt as Cn,n as Tn,na as kn,ni as Pn,nn as Rn,nr as Bn,nt as Mn,o as On,oa as An,oi as Fn,on as Dn,or as En,ot as Ln,p as Nn,pi as zn,pn as $n,pr as Hn,q as Wn,qi as Un,qn as jn,qr as Vn,qt as Kn,r as _n,ra as Xn,ri as Gn,rn as qn,rr as Yn,rt as Zn,s as Jn,sa as Qn,si as eo,sn as to,sr as no,st as oo,t as ro,ta as ao,ti as io,tn as so,tr as lo,tt as co,u as uo,ua as po,un as go,ur as fo,ut as mo,v as ho,vi as bo,vn as yo,vr as vo,vt as xo,w as wo,wi as So,wn as Io,wr as Co,wt as To,x as ko,xi as Po,xn as Ro,xr as Bo,xt as Mo,y as Oo,yi as Ao,yn as Fo,yr as Do,yt as Eo,z as Lo,zi as No,zn as zo}from"./defaultToolbar-DEdxC5tS.js";import{$ as $o,$t as Ho,A as Wo,An as Uo,Ar as jo,B as Vo,Bn as Ko,C as _o,Cn as Xo,Cr as Go,D as qo,Dn as Yo,Dr as Zo,E as Jo,En as Qo,Er as er,F as tr,Fn as nr,Gn as or,H as rr,Hn as ar,Ht as ir,I as sr,In as lr,J as cr,Jn as dr,K as ur,Kn as pr,Kt as gr,L as fr,Mn as mr,Nn as hr,O as br,On as yr,Or as vr,Pn as xr,Q as wr,Qn as Sr,Qt as Ir,R as Cr,Rn as Tr,S as kr,Sn as Pr,Sr as Rr,St as Br,T as Mr,Tn as Or,Tr as Ar,U as Fr,Un as Dr,Ut as Er,Vn as Lr,Vt as Nr,W as zr,Wn as $r,Wt as Hr,Xn as Wr,Xt as Ur,Yn as jr,Yt as Vr,Z as Kr,Zn as _r,Zt as Xr,_ as Gr,_n as qr,_r as Yr,_t as Zr,a as Jr,an as Qr,b as ea,bn as ta,bt as na,c as oa,cr as ra,ct as aa,d as ia,dn as sa,dt as la,en as ca,et as da,f as ua,fr as pa,ft as ga,g as fa,gn as ma,gr as ha,gt as ba,h as ya,hn as va,hr as xa,ht as wa,i as Sa,in as Ia,it as Ca,jn as Ta,jr as ka,k as Pa,kn as Ra,kr as Ba,l as Ma,lr as Oa,lt as Aa,m as Fa,mn as Da,mt as Ea,n as La,nn as Na,nr as za,nt as $a,o as Ha,on as Wa,or as Ua,ot as ja,p as Va,pn as Ka,pt as _a,q as Xa,qt as Ga,rn as qa,rr as Ya,s as Za,st as Ja,tn as Qa,u as ei,un as ti,ur as ni,ut as oi,v as ri,vn as ai,vr as ii,vt as si,w as li,wn as ci,wr as di,x as ui,xn as pi,xr as gi,xt as fi,y as mi,yr as hi,zn as bi}from"./sourcePackage-CHvo6ql3.js";function yi(e,t){return{document:e.document,selection:t}}function vi(e,t){if(!Ia(e.selection))return an(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=oe(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return yi(e,Y(Dr(i,Math.min(r,bi(i)))))}function xi(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=oe(e),i=bi(o);if(t<0&&a>0)return yi(e,{anchor:e.selection.anchor,focus:Dr(o,a-1)});if(t>0&&a<i)return yi(e,{anchor:e.selection.anchor,focus:Dr(o,a+1)});if(t<0&&r>0){const t=n[r-1];return yi(e,{anchor:e.selection.anchor,focus:Dr(t,bi(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return yi(e,{anchor:e.selection.anchor,focus:Dr(t,0)})}return e}function wi(e,t){const{paragraphs:n,index:o,offset:r}=oe(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return yi(e,{anchor:e.selection.anchor,focus:Dr(i,Math.min(r,bi(i)))})}function Si(e){const t=Qr(e);if(t.isCollapsed)return"";const n=ma(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return Ko(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(Ko(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(Ko(n[i]));return o.push(Ko(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Ii(e,t){return{...e,selection:{anchor:ca(e,t.anchor),focus:ca(e,t.focus)}}}function Ci(e){if(!Ia(e.selection))return an(e,"start");const{paragraph:t,index:n,offset:o}=oe(e),r=ma(e);if(Lr(t,o)&&"before-markers"!==e.selection.focus.fieldBoundaryAffinity)return{...e,selection:Y(ar(t,o,"before-markers"))};if(o>0)return{...e,selection:Y(ar(t,o-1,"after-markers"))};if(0===n)return e;const a=r[n-1];return{...e,selection:Y(ar(a,bi(a),"after-markers"))}}function Ti(e){if(!Ia(e.selection))return an(e,"end");const{paragraph:t,index:n,offset:o}=oe(e),r=ma(e),a=bi(t);if(Lr(t,o)&&"after-markers"!==e.selection.focus.fieldBoundaryAffinity)return{...e,selection:Y(ar(t,o,"after-markers"))};if(o<a)return{...e,selection:Y(ar(t,o+1,"before-markers"))};if(n>=r.length-1)return e;const i=r[n+1];return{...e,selection:Y(ar(i,0,"before-markers"))}}function ki(e,t){const n=Qr(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=ma(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}var Pi=Nr(),Ri="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Bi="http://schemas.microsoft.com/office/2011/relationships",Mi="application/vnd.openxmlformats-officedocument.",Oi=16777216,Ai=4096,Fi=/* @__PURE__ */new Map([[Ri+"/chart",/* @__PURE__ */new Set([Mi+"drawingml.chart+xml"])],[Bi+"/chartStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartstyle+xml"])],[Bi+"/chartColorStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartcolorstyle+xml"])],[Ri+"/image",/* @__PURE__ */new Set(["image/png","image/jpeg","image/gif","image/bmp","image/tiff"])],[Ri+"/package",/* @__PURE__ */new Set([Mi+"spreadsheetml.sheet"])]]),Di="oasis.opc-chart-transfer.v1",Ei=e=>{throw Error("Opaque transfer rejected: "+e)};function Li(e){if(!e||"object"!=typeof e||Array.isArray(e))return Ei("expected record");const t=Object.getPrototypeOf(e);return t!==Object.prototype&&null!==t?Ei("unexpected record prototype"):e}function Ni(e,t=Oi){return"string"!=typeof e||!e.length||e.length>t?Ei("invalid string or size"):e}function zi(e,t){return!Array.isArray(e)||e.length>t?Ei("invalid array or count"):e}function $i(e){const t=Ni(e,512);return!/^[A-Za-z0-9_.\-/]+$/.test(t)||t.split("/").some(e=>!e||"."===e||".."===e||"_rels"===e)||t.endsWith(".rels")||"__proto__"===t||"constructor"===t||"prototype"===t?Ei("unsafe part path"):t}function Hi(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return Ei("unsafe XML declaration");const t=new Pi.DOMParser({onError:()=>Ei("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||Ei("missing XML root")}function Wi(e,t){const n=zi(e,Ai).map(e=>function(e,t){const n=Li(e),o=Ni(n.id,256),r=Ni(n.type,512),a=Ni(n.target,512);if(!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(o)||!Fi.has(r))return Ei("unsupported relationship");if(void 0!==n.targetMode&&"Internal"!==n.targetMode)return Ei("external relationship");if(!/^[A-Za-z0-9_.\-/]+$/.test(a))return Ei("unsafe relationship URI");const i=$i(n.resolvedTarget);return Ea(t,a)!==i?Ei("inconsistent relationship target"):{id:o,type:r,target:a,targetMode:"Internal",resolvedTarget:i}}(e,t));return new Set(n.map(e=>e.id)).size!==n.length?Ei("duplicate relationship ID"):n}function Ui(e){const t=Li(e),n=$i(t.path),o=Ni(t.contentType,256),r=Ni(t.data),a=o.endsWith("+xml");return[...Fi.values()].some(e=>e.has(o))?t.kind!==(a?"xml":"binary")||t.encoding!==(a?"utf8":"base64")?Ei("inconsistent part encoding"):a||/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(r)?(a&&Hi(r),{path:n,contentType:o,kind:a?"xml":"binary",encoding:a?"utf8":"base64",data:r,relationships:Wi(t.relationships,n)}):Ei("invalid base64"):Ei("unsupported content type")}function ji(e){const t=Li(e);if("oasis.opc-chart-transfer.v1"!==t.format)return Ei("unsupported format");const n=$i(t.ownerPath),o=Ni(t.fragmentXml,1048576),r=Ni(t.signature,2097152),a=Wi(t.relationships,n),i=zi(t.parts,128).map(Li);let s=o.length+r.length,l=a.length;for(const m of i){if(s+=Ni(m.data).length,l+=zi(m.relationships,Ai).length,3*s>Oi)return Ei("aggregate size limit");if(l>Ai)return Ei("aggregate relationship limit")}const c=i.map(Ui),d=Hi(o),u=Pa(d);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==d.namespaceURI||"drawing"!==d.localName||!u||"chart"!==u.objectKind||"inline"!==u.placement||u.signature!==r)return Ei("unsupported or changed chart fragment");if(1!==a.filter(e=>e.type===Ri+"/chart").length||a.some(e=>e.type!==Ri+"/chart")||JSON.stringify([...u.relationshipIds].sort())!==JSON.stringify(a.map(e=>e.id).sort()))return Ei("chart relationship mismatch");const p=new Map(c.map(e=>[e.path,e]));if(p.size!==c.length||p.has(n))return Ei("duplicate or story-dependent part");if(new Set([n,...p.keys()].map(e=>e.toLowerCase())).size!==c.length+1)return Ei("aliased part path");const g=[...a],f=/* @__PURE__ */new Set;for(let m=0;m<g.length;m++){const e=g[m],t=p.get(e.resolvedTarget);if(!t||!Fi.get(e.type)?.has(t.contentType))return Ei("missing dependency or incompatible relationship type");if(!f.has(t.path)){if(f.add(t.path),t.contentType!==Mi+"drawingml.chart+xml"&&t.relationships.length)return Ei("unsupported nested dependency owner");if(t.relationships.some(e=>e.type===Ri+"/chart"))return Ei("nested chart dependency");g.push(...t.relationships)}}return f.size!==c.length?Ei("unreachable payload part"):{format:Di,ownerPath:n,fragmentXml:o,signature:r,relationships:a,parts:c.sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:0)}}var Vi=/* @__PURE__ */e(si(),1);var Ki=new Set(["chart","diagramData","diagramLayout","diagramQuickStyle","diagramColors","oleObject","package","image"].map(e=>"http://schemas.openxmlformats.org/officeDocument/2006/relationships/"+e)),_i=(e,t)=>Object.hasOwn(e.parts,t),Xi=e=>Array.from(e.childNodes).filter(e=>1===e.nodeType);function Gi(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))throw Error("Unsupported XML declarations");const t=new Pi.DOMParser({onError:()=>{throw Error("Invalid XML")}}).parseFromString(e,"application/xml");if(!t.documentElement)throw Error("Missing XML root");return t}function qi(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.startsWith("/")&&!e.split("/").some(e=>""===e||"."===e||".."===e)}function Yi(e,t,n){const o=t.parts[e],r=n.parts[e];if(!o||!r||!qi(e)||o.kind!==r.kind||o.data!==r.data||o.contentType!==r.contentType||o.encoding!==r.encoding)return!1;const a=o.contentType??"";return/^word\/charts\//.test(e)&&/^application\/vnd\.(?:openxmlformats-officedocument\.drawingml\.chart|ms-office\.chart(?:style|colorstyle))\+xml$/i.test(a)||/^word\/diagrams\//.test(e)&&/^application\/vnd\.openxmlformats-officedocument\.drawingml\.diagram(?:Data|Layout|Style|Colors)\+xml$/i.test(a)||/^word\/embeddings\//.test(e)&&/^(?:application\/vnd\.openxmlformats-officedocument\.(?:spreadsheetml\.sheet|wordprocessingml\.document|presentationml\.presentation|oleObject)|application\/vnd\.ms-excel)$/i.test(a)||/^word\/media\//.test(e)&&/^image\//.test(a)}function Zi(e,t){if(e.includes(t))return!0;const n=[Gi(e).documentElement];for(;n.length;){const e=n.pop();if(Array.from(e.attributes).some(e=>e.value.includes(t)))return!0;for(const o of Array.from(e.childNodes))if(1===o.nodeType)n.push(o);else if(o.nodeValue?.includes(t))return!0}return!1}function Ji(e,t){return e.id===t.id&&e.type===t.type&&e.mode===(t.targetMode??"Internal")&&e.resolved===t.resolvedTarget}function Qi(e,t,n){const o=e=>({removeEdges:[],removeParts:[],...e?{skippedReason:e}:{}});if(!n.length)return o();try{if(e.mainDocumentPart!==t.mainDocumentPart)return o("Main part changed");if(Object.keys(t.parts).some(e=>e.startsWith("_xmlsignatures/")))return o("Signed package");const r=br(e),a=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const b of n){const n=r.objects.filter(e=>e.signature===b.signature),s=1===n.length?n[0]:void 0;if(!s||s.ownerPath!==e.mainDocumentPart||s.ownerPath!==b.ownerPath||s.ordinal!==b.ordinal||s.issues.length)return o("Ambiguous deletion intent");for(const o of s.partPaths)Yi(o,e,t)&&a.add(o);for(const e of s.relationshipIds)i.add(e)}if(!a.size)return o();const s=function(e){const t=[];for(const[n,o]of Object.entries(e.parts)){const r=oi(n);if(void 0===r)continue;if(null!==r&&!_i(e,r))throw Error("Relationship without owner");if("xml"!==o.kind)throw Error("Non-XML relationship part");const a=Gi(o.data).documentElement;if("http://schemas.openxmlformats.org/package/2006/relationships"!==a.namespaceURI||"Relationships"!==a.localName)throw Error("Invalid relationship root");const i=/* @__PURE__ */new Set;for(const o of Xi(a)){if("http://schemas.openxmlformats.org/package/2006/relationships"!==o.namespaceURI||"Relationship"!==o.localName)throw Error("Unknown relationship element");const a=o.getAttribute("Id"),s=o.getAttribute("Type"),l=o.getAttribute("Target"),c=o.getAttribute("TargetMode")||"Internal";if(!a||!s||!l||i.has(a)||"Internal"!==c&&"External"!==c)throw Error("Invalid or duplicate relationship");i.add(a);const d={owner:r,relPath:n,id:a,type:s,target:l,mode:c};if("Internal"===c){if(!/^[A-Za-z0-9_.\-/]+$/.test(l))throw Error("Ambiguous internal relationship URI");const t=Ea(r,l);if(!t||!qi(t)||!_i(e,t)||void 0!==oi(t)||"[Content_Types].xml"===t)throw Error("Unresolved internal relationship");d.resolved=t}t.push(d)}}return t}(t),l=t.parts[t.mainDocumentPart];if(!l||"xml"!==l.kind)return o("Missing main story XML");const c=/* @__PURE__ */new Set;for(const n of s)n.owner===t.mainDocumentPart&&"Internal"===n.mode&&n.resolved&&a.has(n.resolved)&&i.has(n.id)&&Ki.has(n.type)&&e.parts[e.mainDocumentPart]?.relationships?.find(e=>Ji(n,e))&&!Zi(l.data,n.id)&&c.add(n);if(!c.size)return o();const d=/* @__PURE__ */new Map;for(const e of s)if(!c.has(e)){const t=d.get(e.owner)??[];t.push(e),d.set(e.owner,t)}const u=/* @__PURE__ */new Set,p=[null,...Object.keys(t.parts).filter(e=>!a.has(e)&&"[Content_Types].xml"!==e&&void 0===oi(e))];for(let e=0;e<p.length;e++){const t=p[e];if(null!==t){if(u.has(t))continue;u.add(t)}for(const e of d.get(t)??[])e.resolved&&!u.has(e.resolved)&&p.push(e.resolved)}const g=/* @__PURE__ */new Set,f=[...c].flatMap(e=>e.resolved?[e.resolved]:[]);for(let e=0;e<f.length;e++){const t=f[e];if(a.has(t)&&!g.has(t)){g.add(t);for(const e of d.get(t)??[])e.resolved&&f.push(e.resolved)}}const m=[...g].filter(e=>!u.has(e)).sort(),h=new Set(m);for(const e of s)if(e.resolved&&h.has(e.resolved)&&!c.has(e)&&(null===e.owner||!h.has(e.owner)))return o("Retained incoming edge");return{removeEdges:[...c],removeParts:m}}catch(r){return o(r instanceof Error?r.message:String(r))}}var es="word/comments.xml";function ts(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 ns(e){return e.localName??e.tagName}function os(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 rs(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 as(e){let t="";for(const n of ts(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===ns(n)){t+=n.textContent??"";continue}if("tab"===ns(n)){t+="\t";continue}if("br"===ns(n)||"cr"===ns(n)){t+="\n";continue}}t+=as(n)}return t}function is(e){return ts(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===ns(e))}function ss(e){return is(e).map(as).join("\n").trim()}function ls(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===ns(t)?t:void 0}function cs(e,t){const n=os(is(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=is(t)[0];n&&o&&o.setAttributeNS(fi,"w14:paraId",n)}function ds(e,t){const n=is(e),o=is(t);n[0]&&o[0]&&Mr(n[0],o[0]);const r=new Set(ts(t).filter(e=>e.namespaceURI!==Br).map(e=>`${e.namespaceURI??""}\0${ns(e)}`));for(const a of ts(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${ns(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function us(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(es);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=ls(e),o=ls(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of ts(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==ns(i))continue;const e=os(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of ts(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==ns(i))continue;const e=os(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new Pi.XMLSerializer).serializeToString(t);rs(i,t),ss(i)===ss(t)?cs(i,t):ds(i,t),(new Pi.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new Pi.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(es,a),!0)}var ps="http://schemas.microsoft.com/office/word/2012/wordml",gs="word/commentsExtended.xml";function fs(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 ms(e){return e.localName??e.tagName}function hs(e){return`${e.namespaceURI??""}\0${ms(e)}`}function bs(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 ys(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function vs(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 xs(e){const t=/* @__PURE__ */new Map,n=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(Br,"comment"))){const e=bs(o,"id"),n=o.getElementsByTagNameNS(Br,"p").item(0),r=n?bs(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function ws(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===ps&&"commentsEx"===ms(t)?t:void 0}function Ss(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))||ys(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(fs(t).map(hs));for(const r of fs(e))o.has(hs(r))||t.appendChild(r.cloneNode(!0))}function Is(e,t,n,o){const r=ws(t),a=ws(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))||ys(t,o,o.value)}}(r,a);const i=xs(e),s=xs(n),l=/* @__PURE__ */new Map;for(const[p,g]of i){const e=s.get(p);e&&l.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of fs(e)){if(n.namespaceURI!==ps||"commentEx"!==ms(n))continue;const e=bs(n,"paraId");e&&t.set(e,n)}return t}(a),d=fs(r),u=new Set(fs(a).filter(e=>!(e.namespaceURI===ps&&"commentEx"===ms(e))).map(hs));for(const p of d){if(p.namespaceURI===ps&&"commentEx"===ms(p)){const e=bs(p,"paraId"),t=e?l.get(e):void 0,n=t?c.get(t):void 0;n&&Ss(p,n,l);continue}u.has(hs(p))||(a.appendChild(p.cloneNode(!0)),u.add(hs(p)))}return(new Pi.XMLSerializer).serializeToString(a.ownerDocument)}var Cs="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Ts(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 ks(e){return e.localName??e.tagName}function Ps(e){return`${e.namespaceURI??""}\0${ks(e)}`}function Rs(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 Bs(e,t){return Ts(e).find(e=>e.namespaceURI===Cs&&ks(e)===t)}function Ms(e,t){return e.filter(e=>e.namespaceURI===Cs&&t.has(ks(e)))}function Os(e){if(e.namespaceURI!==Cs)return;const t=ks(e);if("p"===t){const t=Rs(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Bs(e,"sdtPr"),n=t?Bs(t,"id"):void 0,o=n?Rs(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function As(e,t,n){const o=(new Pi.DOMParser).parseFromString(e,"application/xml"),r=(new Pi.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==Cs||i.namespaceURI!==Cs||ks(a)!==n||ks(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 s=Ts(a),l=Ts(i),c=new Set(l.map(Ps));return s.forEach((e,t)=>{if(e.namespaceURI===Cs||c.has(Ps(e)))return;const n=s.slice(t+1).map(e=>l.find(t=>Ps(t)===Ps(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new Pi.XMLSerializer).serializeToString(r)}function Fs(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=As(e,t,n),a=(new Pi.DOMParser).parseFromString(e,"application/xml"),i=(new Pi.DOMParser).parseFromString(r,"application/xml"),s=a.documentElement,l=i.documentElement;if(!s||!l||s.namespaceURI!==Cs||l.namespaceURI!==Cs||ks(s)!==n||ks(l)!==n)return r;const c=Ts(s),d=Ts(l),u=function(e,t,n){const o=Ms(e,n),r=Ms(t,n);return o.length===r.length&&o.every((e,t)=>ks(e)===ks(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Cs||o.has(ks(e)))return;const n=Ps(e),r=p.get(n)??0;if(p.set(n,r+1),Ts(l).filter(e=>Ps(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===Cs&&o.has(ks(e)));if(!a)return;const i=Os(a);if(i){const e=Ms(n,o).find(e=>Os(e)===i);if(e)return e}if(!r)return;const s=Ms(e,o),l=Ms(n,o),c=s.indexOf(a);return c>=0?l[c]:void 0}(c,t,d,o,u);(a||u)&&l.insertBefore(e.cloneNode(!0),a??null)}),(new Pi.XMLSerializer).serializeToString(i)}var Ds="word/document.xml",Es=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Ls(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 Ns(e){return e.localName??e.tagName}function zs(e){return`${e.namespaceURI??""}\0${Ns(e)}`}function $s(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 Hs(e,t){return Ls(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ns(e)===t)}function Ws(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Es.has(Ns(e))}function Us(e){return e.filter(Ws)}function js(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=Ns(e);if("p"===t){const t=$s(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Hs(e,"sdtPr"),n=t?$s(Hs(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Vs(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml"),o=(new Pi.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"!==Ns(r)||"document"!==Ns(a))return t;!function(e,t){const n=Ls(e),o=Hs(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===Ns(e))),i=/* @__PURE__ */new Set;for(let s=a.length-1;s>=0;s-=1){const e=a[s],n=Ls(t).find(t=>!i.has(t)&&zs(t)===zs(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=Hs(r,"body"),s=Hs(a,"body");if(!i||!s)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,s);const l=Ls(i),c=Ls(s),d=function(e,t){const n=Us(e),o=Us(t);return n.length===o.length&&n.every((e,t)=>Ns(e)===Ns(o[t]))}(l,c),u=/* @__PURE__ */new Map;return l.forEach((e,t)=>{if(Ws(e))return;const n=zs(e),o=u.get(n)??0;if(u.set(n,o+1),Ls(s).filter(e=>zs(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(Ws);if(!o)return;const r=js(o);return r?Us(n).find(e=>js(e)===r):void 0}(l,t,c),a=d?function(e,t,n){const o=Us(e),r=Us(n),a=e.slice(t+1).find(Ws);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(l,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&s.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===Ns(e))}(c)??null)}),(new Pi.XMLSerializer).serializeToString(o)}async function Ks(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(Ds);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Vs(e,As(e,t,"document"))}(n.data,r);return a!==r&&(t.file(Ds,a),!0)}function _s(e){return e.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id")||void 0}function Xs(e){return e.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main","type")||"default"}function Gs(e,t){const n=e.getAttributeNodeNS(na,"id");return!(!n||n.value===t)&&(e.setAttributeNS(na,n.name,t),!0)}var qs="word/document.xml",Ys="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Zs(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Ys,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function Js(e){const t=[];return Zs(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===Ys&&"headerReference"===r.localName?"header":r.namespaceURI===Ys&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=_s(r);if(!a)continue;const i=Xs(r),s=`${e}:${i}`,l=o.get(s)??0;o.set(s,l+1),t.push({key:`${n}:${e}:${i}:${l}`,kind:e,relationshipId:a})}}),t}function Qs(e){return new Map(e.map(e=>[e.id,e]))}async function el(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(qs)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=Zs(n.data),a=Zs(o);if(r.length!==a.length)return!1;const i=Js(n.data),s=Js(o),l=new Map(i.map(e=>[e.key,e])),c=Qs(n.relationships??[]),d=Qs(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`}(qs))?.async("string"));return wa(qs,_a(t))}(t));let u=!1;for(const p of s){const n=l.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,s=await(t.file(i)?.async("string"));if(!s)continue;const g="header"===p.kind?"hdr":"ftr",f=Fs(a.data,s,g);f!==s&&(t.file(i,f),u=!0)}return u}var tl="word/document.xml",nl={"/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"},ol=["/officeDocument",...Object.keys(nl)];function rl(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function al(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 il(e){for(const[t,n]of Object.entries(nl))if(e.type.endsWith(t))return n}function sl(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=oi(e);return void 0===n?t.get(e)??e:null===n?e:al(t.get(n)??n)}function ll(e,t){for(const[n,o]of t)if(o===e)return n;return e}function cl(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 dl(e,t){const n=e.parts[t];return"xml"===n?.kind?_a(n.data):[]}function ul(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:dl(e,Aa):e.parts[t]?.relationships??dl(e,al(t));return wa(t,n)}function pl(e,t,n){return ul(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function gl(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,ol.find(e=>i.endsWith(e)));var i;const s=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,l=wa(n,[e])[0]?.resolvedTarget,c=s?.resolvedTarget??(l?r.get(l)??l:void 0);return c?{...e,...s?{id:s.id,type:s.type}:{},target:cl(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function fl(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(rl(e)===rl(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 ml(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 hl(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===Jr(o))}async function bl(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Vi.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>la(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(tl,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=il(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!==tl&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),s=new Vi.default;for(const c of Object.keys(n.parts))ml(s,n,c);for(const c of i)s.remove(c),s.remove(al(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=oi(a);if(null==i)continue;const s=ul(t,i),l=s.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(l.length===s.length)continue;const c=ll(i,n);o.has(al(c))||(0===l.length?e.remove(a):e.file(a,Zr(l)))}}(s,n,a,r,i);let l=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=la(c);if("[Content_Types].xml"===e){l=await d.async("string");continue}const t=sl(e,a),o=oi(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,l=pl(n,r,i),c=fl(l,gl(_a(await d.async("string")),l,e,r,a),t);s.file(t,Zr(c));continue}const r=await d.async("uint8array");hl(n,e,t,r)||s.file(t,r)}return l&&s.file(Ja,function(e,t,n,o){const r=ga(t),a={};for(const[s,l]of Object.entries(r.overrides))a[n.get(s)??s]=l;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return ba({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,l,a,i)),s.generateAsync({type:"arraybuffer"})}var yl="word/document.xml",vl=["first","even","default"];function xl(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 wl(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 Sl(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 Il(e,t){const n=[],o=e=>{for(const r of Sl(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&r.localName===t&&n.push(r),o(r)};return o(e),n}function Cl(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml"),n=[],o=Il(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of Sl(e)){const e="http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&"headerReference"===r.localName?"header":"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=_s(r);if(!a)continue;const i=Xs(r),s=`${e}:${i}`,l=o.get(s)??0;o.set(s,l+1),n.push({key:`${t}:${e}:${i}:${l}`,sectionIndex:t,kind:e,type:i,occurrence:l,relationshipId:a})}}),{references:n,sectionCount:o.length}}function Tl(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function kl(e,t){const n=e.parts[t]?.relationships??_a(Tl(e,xl(t)));return wa(t,n)}function Pl(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 Rl(e,t){const n=Tl(e,e.mainDocumentPart),o=await(t.file(yl)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=Cl(n),a=Cl(o),i=Pl(r.references,kl(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=vl.indexOf(e.type),o=vl.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 s=Pl(a.references,await async function(e,t){const n=await(e.file(xl(t))?.async("string"));return wa(t,_a(n))}(t,yl)),l=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of s){const e=l.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 Bl(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function Ml(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===Jr(await a.async("uint8array")):void 0===r}async function Ol(e,t,n,o){for(const r of n)if(!(await Ml(e,t,o?xl(r.current.partPath):r.current.partPath,r.source.baselinePath?o?xl(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function Al(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?xl(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?Jr(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 Fl(e,t,n){const o=await(e.file(yl)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[yl],a=Jr((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of Il(n,r)){const n=_s(e),r=n?t.get(n):void 0;r&&(o=Gs(e,r.id)||o)}return o?(new Pi.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(yl,t)}}const r=xl(yl),a=_a(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:wl(yl,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,Zr(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(Bl(e)===Bl(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 Dl(e,t,n){const o=n[0],r=o.source.partPath;if(!(await Ol(e,t,n,!1))){await Al(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 i of n)i.current.partPath!==r&&e.remove(i.current.partPath);const a=xl(r);if(!(await Ol(e,t,n,!0))){await Al(e,n,!0);const t=xl(o.current.partPath),i=await(e.file(t)?.async("string"));i&&e.file(a,Zr(function(e,t,n){return e.map(e=>{if("External"===e.targetMode)return e;const o=wa(t,[e])[0]?.resolvedTarget;return o?{...e,target:wl(n,o),targetMode:"Internal",resolvedTarget:o}:e})}(_a(i),o.current.partPath,r)))}for(const i of n){const t=xl(i.current.partPath);t!==a&&e.remove(t)}}async function El(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 Dl(e,t,o)}async function Ll(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Vi.default.loadAsync(t),r=await Rl(n,o);r.matches.length>0&&(await Fl(o,n,r),await El(o,n,r),await async function(e,t){const n=await(e.file(Ja)?.async("string"));if(!n)return;const o=ga(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(Ja,ba(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return bl(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[xl(d)];const a=r[n.mainDocumentPart],i=kl(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const s=xl(n.mainDocumentPart),l=r[s];l&&(r[s]={...l,data:Zr(i)});const c=r[Ja];return c&&(r[Ja]={...c,data:ba(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var Nl=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],zl=/* @__PURE__ */new Set(["p","tbl"]),$l=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function Hl(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 Wl(e){return e.localName??e.tagName}function Ul(e){return`${e.namespaceURI??""}\0${Wl(e)}`}function jl(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 Vl(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 Kl(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Wl(n)===t?n:void 0}function _l(e){const t=jl(e,"type");if(t&&$l.has(t))return`type:${t}`;const n=jl(e,"id");return n?`id:${n}`:void 0}function Xl(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&zl.has(Wl(e))}function Gl(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Wl(e))return;const t=jl(e,"paraId");return t?`p:${t}`:void 0}function ql(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=Hl(e),o=Hl(t),r=function(e,t){const n=e.filter(Xl),o=t.filter(Xl);return n.length===o.length&&n.every((e,t)=>Wl(e)===Wl(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Xl(e))return;const s=Ul(e),l=a.get(s)??0;if(a.set(s,l+1),Hl(t).filter(e=>Ul(e)===s)[l])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Xl);if(!r)return;const a=Gl(r);if(a){const e=n.filter(Xl).find(e=>Gl(e)===a);if(e)return e}if(!o)return;const i=e.filter(Xl),s=n.filter(Xl),l=i.indexOf(r);return l>=0?s[l]: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 Yl(e,t,n,o){const r=Kl(t,o.rootName),a=Kl(n,o.rootName);if(!r||!a)return n;const i=Hl(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Wl(e)===o.entryName),s=/* @__PURE__ */new Map;for(const c of Hl(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Wl(c)!==o.entryName)continue;const e=_l(c);e&&s.set(e,c)}const l=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=_l(c);if(!e)continue;const t=s.get(e),n=jl(c,"type");if(t){n&&$l.has(n)?a.replaceChild(c.cloneNode(!0),t):ql(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=jl(c,"id");o&&l.has(o)&&a.appendChild(c.cloneNode(!0))}return(new Pi.XMLSerializer).serializeToString(a.ownerDocument)}var Zl="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Jl="word/numbering.xml";function Ql(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 ec(e){return e.localName??e.tagName}function tc(e){return`${e.namespaceURI??""}\0${ec(e)}`}function nc(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 oc(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(Zl,`w:${t}`,n)}function rc(e,t){return Ql(e).find(e=>e.namespaceURI===Zl&&ec(e)===t)}function ac(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 ic(e,t){const n=new Set(Ql(t).map(tc));for(const o of Ql(e))o.namespaceURI===Zl||n.has(tc(o))||t.appendChild(o.cloneNode(!0))}function sc(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 lc=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function cc(e,t){ac(e,t);const n=Ql(e),o=new Map(Ql(t).map(e=>[tc(e),e]));n.forEach((e,r)=>{const a=tc(e),i=o.get(a),s=ec(e);if(i)return ac(e,i),void(e.namespaceURI===Zl&&"rPr"===s?function(e,t){ac(e,t);const n=Ql(e),o=new Map(Ql(t).map(e=>[tc(e),e]));n.forEach((e,r)=>{const a=tc(e),i=o.get(a);if(i)return ac(e,i),void ic(e,i);e.namespaceURI===Zl&&"rFonts"===ec(e)||sc(n,r,e,t,e=>o.get(tc(e)))})}(e,i):ic(e,i));if(e.namespaceURI!==Zl||!lc.has(s)){if(e.namespaceURI===Zl&&"rPr"===s){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of Ql(e))o.namespaceURI===Zl&&"rFonts"===ec(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}sc(n,r,e,t,e=>o.get(tc(e)))}})}function dc(e){return function(e){return e.namespaceURI===Zl&&"lvl"===ec(e)?`${tc(e)}\0${nc(e,"ilvl")??"0"}`:tc(e)}(e)}function uc(e,t,n){const o=rc(t,"abstractNumId"),r=o?nc(o,"val"):void 0;if(!r)return;const a=Ql(e).find(e=>e.namespaceURI===Zl&&"abstractNum"===ec(e)&&nc(e,"abstractNumId")===r);return a?Ql(a).find(e=>e.namespaceURI===Zl&&"lvl"===ec(e)&&(nc(e,"ilvl")??"0")===n):void 0}function pc(e,t){const n=t.cloneNode(!0);cc(e,n);const o=rc(e,"pPr"),r=rc(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function gc(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=nc(rc(t,"start")??t,"val")??"1";for(const r of Ql(e)){const e=ec(r);if(r.namespaceURI===Zl&&"startOverride"===e){const e=r.cloneNode(!0);oc(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==Zl||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(pc(r,t))}return n}function fc(e){if(e.namespaceURI!==Zl)return tc(e);const t=ec(e);return"abstractNum"===t?`${tc(e)}\0${nc(e,"abstractNumId")??""}`:"num"===t?`${tc(e)}\0${nc(e,"numId")??""}`:tc(e)}function mc(e,t){const n=function(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new Pi.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===Zl&&o.namespaceURI===Zl&&"numbering"===ec(n)&&"numbering"===ec(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;ac(o,r);const a=Ql(o),i=new Map(Ql(r).map(e=>[fc(e),e]));return a.forEach((e,t)=>{const n=fc(e),o=i.get(n),s=ec(e);if(o)return ac(e,o),void(e.namespaceURI===Zl&&"abstractNum"===s?function(e,t){ac(e,t);const n=Ql(e),o=new Map(Ql(t).map(e=>[dc(e),e]));n.forEach((e,r)=>{const a=dc(e),i=o.get(a);if(i)return ac(e,i),void(e.namespaceURI===Zl&&"lvl"===ec(e)?cc(e,i):ic(e,i));sc(n,r,e,t,e=>o.get(dc(e)))})}(e,o):e.namespaceURI===Zl&&"num"===s?function(e,t,n){ac(e,t);const o=rc(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of Ql(t))a.namespaceURI===Zl&&"lvlOverride"===ec(a)&&r.set(nc(a,"ilvl")??"0",a);for(const a of Ql(e)){const e=ec(a);if(a.namespaceURI!==Zl||"abstractNumId"!==e){if(a.namespaceURI===Zl&&"lvlOverride"===e){const e=nc(a,"ilvl")??"0",o=gc(a,uc(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===Zl||Ql(t).some(e=>tc(e)===tc(a))||t.appendChild(a.cloneNode(!0))}else o&&(ac(a,o),ic(a,o))}}(e,o,r):ic(e,o));sc(a,t,e,r,e=>i.get(fc(e)))}),(new Pi.XMLSerializer).serializeToString(r.ownerDocument)}async function hc(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(Jl);if(!n||!o)return!1;const r=await o.async("string"),a=mc(n,r);return a!==r&&(t.file(Jl,a),!0)}var bc=[{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 yc(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 vc="http://schemas.openxmlformats.org/wordprocessingml/2006/main",xc=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function wc(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 Sc(e){return e.localName??e.tagName}function Ic(e){return`${e.namespaceURI??""}\0${Sc(e)}`}function Cc(e){const t=[],n=e=>{for(const o of wc(e))o.namespaceURI===vc&&"sectPr"===Sc(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function Tc(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 kc(e){return e.namespaceURI===vc&&xc.has(Sc(e))}function Pc(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml"),o=(new Pi.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=Cc(n),s=Cc(o);return 0===i.length||i.length!==s.length?t:(Tc(r,a),i.forEach((e,t)=>{!function(e,t){Tc(e,t);const n=wc(e),o=wc(t),r=/* @__PURE__ */new Map;for(const i of o){const e=Ic(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=Ic(e),s=a.get(o)??0;a.set(o,s+1);const l=r.get(o)?.[s];if(l){Tc(e,l);continue}if(kc(e))continue;const c=n.slice(i+1).map(e=>r.get(Ic(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,s[t])}),(new Pi.XMLSerializer).serializeToString(o))}var Rc="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Bc(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 Mc(e){return e.localName??e.tagName}function Oc(e,t){const n=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Rc&&Mc(n)===t?n:void 0}function Ac(e){return Bc(e).length>0?(new Pi.XMLSerializer).serializeToString(e.ownerDocument):void 0}var Fc=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),Dc=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Ec(e){const t=Oc(e,"settings");if(!t)return e;for(const n of[...Bc(t)]){if(n.namespaceURI!==Rc)continue;const e=Mc(n);if(Fc.has(e)){t.removeChild(n);continue}const o=Dc.get(e);if(o){for(const e of[...Bc(n)])e.namespaceURI===Rc&&o.has(Mc(e))&&n.removeChild(e);0===Bc(n).length&&t.removeChild(n)}}return Ac(t)}function Lc(e){const t=Oc(e,"styles");if(!t)return e;for(const n of[...Bc(t)])n.namespaceURI===Rc&&"style"===Mc(n)&&t.removeChild(n);return Ac(t)}function Nc(e){const t=Oc(e,"fonts");if(!t)return e;for(const n of[...Bc(t)])n.namespaceURI===Rc&&"font"===Mc(n)&&t.removeChild(n);return Ac(t)}async function zc(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 $c="word/styles.xml";function Hc(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 Wc(e){return e.localName??e.tagName}function Uc(e){return`${e.namespaceURI??""}\0${Wc(e)}`}function jc(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 Vc(e,t){return Hc(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Wc(e)===t)}function Kc(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Wc(e)?`${Uc(e)}\0${jc(e,"type")??""}`:Uc(e)}function _c(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Wc(t)?t:void 0}function Xc(e,t){const n=Vc(e,"pPr");if(!n)return!1;const o=Vc(t,"pPr"),r=new Pi.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",s=ea(a,i);if(s===i)return!1;if(!s)return!!o&&(t.removeChild(o),!0);const l=function(e){if(!e)return;const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Wc(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=Hc(e),a=r.indexOf(n),i=Hc(t),s=new Map(i.map(e=>[Kc(e),e])),l=r.slice(a+1).map(e=>s.get(Kc(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function Gc(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($c);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=_c(e),o=_c(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Hc(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Wc(i))continue;const e=jc(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Hc(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Wc(i))continue;const e=jc(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Xc(i,t)||a)}return a?(new Pi.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file($c,a),!0)}function qc(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 Yc(e){return e.localName??e.tagName}function Zc(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 Jc(e,t){const n=function(e){if(!e)return;const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Yc(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${Br}" xmlns:w14="${fi}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};Vo(r,`<w:r xmlns:w="${Br}" xmlns:w14="${fi}">${e}<w:t/></w:r>`);const a=function(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===Yc(t)?t:void 0}(ui(r,o));if(!a)return t;let i=qc(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===Yc(e));return!i&&Zc(n)&&(i=a.ownerDocument.createElementNS(Br,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(Mr(n,i),0!==qc(i).length||Zc(i)?(new Pi.XMLSerializer).serializeToString(i):""):""}var Qc="word/styles.xml";function ed(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 td(e){return e.localName??e.tagName}function nd(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 od(e,t){return ed(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&td(e)===t)}function rd(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===td(t)?t:void 0}function ad(e,t){const n=od(e,"rPr");if(!n)return!1;const o=od(t,"rPr"),r=new Pi.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",s=Jc(a,i);if(s===i)return!1;if(!s)return!!o&&(t.removeChild(o),!0);const l=function(e){if(!e)return;const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===td(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=ed(e),a=r.indexOf(n),i=ed(t),s=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&td(t)===td(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function id(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(Qc);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=rd(e),o=rd(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of ed(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==td(i))continue;const e=nd(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of ed(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==td(i))continue;const e=nd(i,"styleId"),t=e?r.get(e):void 0;t&&(a=ad(i,t)||a)}return a?(new Pi.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Qc,a),!0)}var sd="word/styles.xml",ld=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function cd(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 dd(e){return e.localName??e.tagName}function ud(e){return`${e.namespaceURI??""}\0${dd(e)}`}function pd(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 gd(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 fd(e,t){return cd(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&dd(e)===t)}function md(e){return e?(new Pi.XMLSerializer).serializeToString(e):""}function hd(e,t){if(!e)return;const n=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&dd(n)===t?n:void 0}function bd(e,t,n){switch(e){case"pPr":return ea(t,n);case"rPr":return Jc(t,n);case"tblPr":return _o(t,n);case"trPr":return li(t,n);case"tcPr":return kr(t,n);default:return n}}function yd(e,t,n,o){const r=cd(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ld.has(dd(e)));return i?fd(t,dd(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===dd(e)&&ld.has(o)?cd(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===dd(e))??null:null}function vd(e,t,n){const o=fd(e,n);if(!o)return!1;const r=fd(t,n),a=md(r),i=bd(n,md(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const s=hd(i,n);if(!s)return!1;const l=s.cloneNode(!0);return r?(t.replaceChild(l,r),!0):(t.insertBefore(l,yd(e,t,o,n)),!0)}function xd(e,t){gd(e,t);let n=!1;for(const r of ld)n=vd(e,t,r)||n;const o=new Set(cd(t).map(ud));for(const r of cd(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&ld.has(dd(r))||o.has(ud(r))||(t.appendChild(r.cloneNode(!0)),o.add(ud(r)),n=!0);return n}function wd(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(Br,"w:tblStylePr");gd(e,n);let o=!1;for(const r of cd(e)){const e=dd(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&ld.has(e)){const t=hd(bd(e,md(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function Sd(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==dd(e))return;const t=pd(e,"type");return t?`tblStylePr:${t}`:void 0}function Id(e,t){let n=!1;n=vd(e,t,"tblPr")||n;const o=cd(e).filter(e=>void 0!==Sd(e)),r=/* @__PURE__ */new Map;for(const a of cd(t)){const e=Sd(a);e&&r.set(e,a)}for(const a of o){const o=Sd(a),i=r.get(o);if(i){n=xd(a,i)||n;continue}const s=wd(a);if(!s)continue;const l=cd(e),c=l.indexOf(a),d=l.slice(c+1).find(e=>void 0!==Sd(e)),u=d?r.get(Sd(d))??null:null;t.insertBefore(s.cloneNode(!0),u),n=!0}return n}function Cd(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===dd(t)?t:void 0}async function Td(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(sd);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Cd(e),o=Cd(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of cd(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===dd(i)){const e=pd(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of cd(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==dd(i))continue;if("table"!==pd(i,"type"))continue;const e=pd(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Id(i,t)||a)}return a?(new Pi.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(sd,a),!0)}var kd="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Pd(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 Rd(e){return e.localName??e.tagName}function Bd(e){return`${e.namespaceURI??""}\0${Rd(e)}`}function Md(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 Od(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 Ad(e,t,n){const o=(new Pi.DOMParser).parseFromString(e,"application/xml"),r=(new Pi.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===kd&&i.namespaceURI===kd&&Rd(a)===n&&Rd(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Fd(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 Dd(e,t){const n=new Set(Pd(t).map(Bd));for(const o of Pd(e))o.namespaceURI===kd||n.has(Bd(o))||t.appendChild(o.cloneNode(!0))}var Ed=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var Ld=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Nd(e){return e.namespaceURI===kd&&"tblStylePr"===Rd(e)?`${Bd(e)}\0${Md(e,"type")??""}`:Bd(e)}function zd(e){return e.namespaceURI===kd&&"style"===Rd(e)?`${Bd(e)}\0${Md(e,"styleId")??""}`:Bd(e)}var $d=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function Hd(e){return e.namespaceURI===kd&&"font"===Rd(e)?`${Bd(e)}\0${Md(e,"name")??""}`:Bd(e)}var Wd=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=Ad(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Od(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=Pd(o),s=new Map(Pd(r).map(e=>[Bd(e),e]));return i.forEach((e,t)=>{const n=Bd(e),o=s.get(n),l=Rd(e),c=e.namespaceURI===kd?a.get(l):void 0;if(o)return Od(e,o),void(c?function(e,t,n){Od(e,t);const o=Pd(t),r=new Map(o.map(e=>[Bd(e),e])),a=Pd(e);a.forEach((e,o)=>{const i=Bd(e),s=r.get(i);if(s)return Od(e,s),void Dd(e,s);e.namespaceURI===kd&&n.has(Rd(e))||Fd(a,o,e,t,e=>r.get(Bd(e)))})}(e,o,c):Dd(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Pd(e))r.namespaceURI===kd&&t.has(Rd(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=>s.get(Bd(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===kd&&Ed.has(l)||Fd(i,t,e,r,e=>s.get(Bd(e)))}),(new Pi.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=Ad(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Od(o,r);const a=Pd(o),i=new Map(Pd(r).map(e=>[zd(e),e]));return a.forEach((e,t)=>{const n=zd(e),o=i.get(n);if(o)return Od(e,o),void(e.namespaceURI===kd&&"style"===Rd(e)?function(e,t){Od(e,t);const n=Pd(e),o=new Map(Pd(t).map(e=>[Nd(e),e]));n.forEach((e,r)=>{const a=Nd(e),i=o.get(a);if(i)return Od(e,i),void Dd(e,i);e.namespaceURI===kd&&Ld.has(Rd(e))||Fd(n,r,e,t,e=>o.get(Nd(e)))})}(e,o):Dd(e,o));Fd(a,t,e,r,e=>i.get(zd(e)))}),(new Pi.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=Ad(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Od(o,r);const a=Pd(o),i=new Map(Pd(r).map(e=>[Hd(e),e]));return a.forEach((e,t)=>{const n=Hd(e),o=i.get(n);if(o)return Od(e,o),void(e.namespaceURI===kd&&"font"===Rd(e)&&function(e,t){Od(e,t);const n=Pd(e),o=new Map(Pd(t).map(e=>[Bd(e),e]));n.forEach((e,r)=>{const a=Bd(e),i=o.get(a);i?Od(e,i):e.namespaceURI===kd&&$d.has(Rd(e))||Fd(n,r,e,t,e=>o.get(Bd(e)))})}(e,o));Fd(a,t,e,r,e=>i.get(Hd(e)))}),(new Pi.XMLSerializer).serializeToString(r.ownerDocument)}}];function Ud(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 jd="word/document.xml";function Vd(e){const t=(new Pi.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS(Br,"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 Kd(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return bl(e,t);const r=await Vi.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 s=await async function(e,t){let n=!1;for(const o of Wd){const r=Ud(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"),s=o.merge(r,i);s!==i&&(t.file(o.rebuiltPath,s),n=!0)}return n}(n,r);a&&(s=await hc(n,r)||s),i.styles&&(s=await Gc(n,r)||s,s=await id(n,r)||s,s=await Td(n,r)||s),s=await async function(e,t){let n=!1;return t.settings||(n=await zc(e,"word/settings.xml",Ec)||n),t.styles||(n=await zc(e,"word/styles.xml",Lc)||n),t.fontTable||(n=await zc(e,"word/fontTable.xml",Nc)||n),n}(r,i)||s,s=await async function(e,t){let n=!1;for(const o of bc){const r=yc(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),s=As(r,i,o.rootLocalName);s!==i&&(t.file(o.rebuiltPath,s),n=!0)}return n}(n,r)||s,s=await async function(e,t,n){let o=!1;for(const r of Nl){const a=Vl(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const s=await i.async("string"),l=Yl(e,a,s,r);l!==s&&(n.file(r.rebuiltPath,l),o=!0)}return o}(e,n,r)||s,s=await us(n,r)||s,s=await async function(e,t){const n=vs(e,"/comments"),o=vs(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(gs);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),s=await a.async("string"),l=Is(n,o,i,s);return l!==s&&(t.file(gs,l),!0)}(n,r)||s,s=await el(n,r)||s,s=await Ks(n,r)||s;const l=await(r.file(jd)?.async("string"));if(!l||Vd(o.data)!==Vd(l)){return bl(e,s?await r.generateAsync({type:"arraybuffer"}):t)}const c=Pc(o.data,l);c!==l&&(r.file(jd,c),s=!0);return Ll(e,s?await r.generateAsync({type:"arraybuffer"}):t)}function _d(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function Xd(e){const t=(new Pi.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 Gd(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 qd(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 Yd(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 Zd(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=_d(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=Xd(r.data);if(a&&_d(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 Pi.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 s=i.at(-1)?.startsWith("@")?i.pop():null,l=Gd(i[0]);if(!l||1!==l.index)return null;if(!qd(r,l.prefix,l.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=Gd(i[m]);if(!e)return null;const t=Yd(c).filter(t=>qd(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!s)return{document:o,element:c};const d=s.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(Yd(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 Pi.XMLSerializer).serializeToString(r.document),!0)}function Jd(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 Qd(e){return e.blocks.map(tu).filter(Boolean).join("\n")}function eu(e){return e.cells.map(Qd).filter(Boolean).join("\t")}function tu(e){return"paragraph"===e.type?Ko(e):e.rows.map(eu).filter(Boolean).join("\n")}function nu(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])Jd(t,e,n.text,"");"textBox"===n.kind&&ru(n.textBox.blocks,t)}}function ou(e,t){for(const n of e.rows){const e=eu(n);for(const o of n.sdtWrappers??[])Jd(t,o,e,"\n");for(const o of n.cells){const e=Qd(o);for(const n of o.sdtWrappers??[])Jd(t,n,e,"\n");ru(o.blocks,t)}}}function ru(e,t){if(e)for(const n of e){const e=tu(n);for(const o of n.sdtWrappers??[])Jd(t,o,e,"\n");"paragraph"===n.type?nu(n,t):ou(n,t)}}async function au(e,t={}){if(!e.sourcePackage)return Ha(e);const n=(o=e.sourcePackage,{...o,contentTypes:{defaults:{...o.contentTypes.defaults},overrides:{...o.contentTypes.overrides}},rootRelationships:o.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(o.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...o.diagnostics?{diagnostics:o.diagnostics.map(e=>({...e}))}:{},...o.rebuiltPartHashes?{rebuiltPartHashes:{...o.rebuiltPartHashes}}:{}});var o;const r=br(n),a=r.diagnostics.filter(e=>"error"===e.level);if(a.length)throw new Jo(a);n.opaqueObjects=r.objects;const i={...e,sourcePackage:n};!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of mr(e))ru(o.blocks,t),ru(o.header,t),ru(o.firstPageHeader,t),ru(o.evenPageHeader,t),ru(o.footer,t),ru(o.firstPageFooter,t),ru(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&Zd(e.sourcePackage,t,r)&&(n+=1)}}(i);const s=r.objects.length>0,l=e.opaqueRelocationIntent,c=l?Ma(n,l,l.destinationOwner):void 0,d=await oa(i,n);let u=await Kd(i,d);if(c){if(e.opaqueDeletionIntents?.length)throw new Error("Cannot combine opaque deletion and relocation");u=await async function(e,t){const n=await Vi.default.loadAsync(e);if(!n.file(t.destinationOwner))throw Error("Original destination story was not retained");const o=t.destinationOwner.lastIndexOf("/"),r=(o>=0?t.destinationOwner.slice(0,o+1):"")+"_rels/"+t.destinationOwner.slice(o+1)+".rels",a=await(n.file(r)?.async("string"))??'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>';if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(a))throw Error("Unsafe relationship XML");const i=new Pi.DOMParser({onError:()=>{throw Error("Malformed relationships")}}).parseFromString(a,"application/xml"),s=i.documentElement;if(!s||"http://schemas.openxmlformats.org/package/2006/relationships"!==s.namespaceURI||"Relationships"!==s.localName)throw Error("Invalid destination relationships");const l=/* @__PURE__ */new Set;for(const c of Array.from(s.getElementsByTagNameNS(aa,"Relationship"))){const e=c.getAttribute("Id");if(!e||l.has(e))throw Error("Duplicate destination relationship");l.add(e)}for(const c of t.addedRelationships){if(l.has(c.id)||!c.resolvedTarget||!n.file(c.resolvedTarget))throw Error("Relocation relationship collision or missing target");l.add(c.id);const e=i.createElementNS(aa,s.prefix?s.prefix+":Relationship":"Relationship");e.setAttribute("Id",c.id),e.setAttribute("Type",c.type),e.setAttribute("Target",c.target),s.appendChild(e)}return n.file(r,(new Pi.XMLSerializer).serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,c)}if(s||t.requireOpaquePreservation||c||e.opaqueDeletionIntents?.length){const{captureDocxSourcePackage:o}=await import("./sourcePackage-CHvo6ql3.js").then(e=>e.r),r=await o(u),a=qo(n,r,e.opaqueDeletionIntents,c?function(e,t){const n=e.opaqueObjects?.find(e=>e.ownerPath===t.sourceOwner&&e.ordinal===t.sourceOrdinal&&e.signature===t.sourceSignature),o=e.parts[t.destinationOwner];if(!n||!o)throw Error("Relocation source missing");const r={...e,parts:{...e.parts,[t.destinationOwner]:{...o,relationships:[...o.relationships??[],...t.addedRelationships]}}},a=Wo(r,t.destinationOwner,t.destinationRun.relationshipIds);if(a.issues.length)throw Error("Invalid relocation closure");return{original:n,expected:{...n,ownerPath:t.destinationOwner,signature:t.destinationRun.signature,fragmentXml:t.destinationRun.fragmentXml,relationshipIds:t.destinationRun.relationshipIds,...a}}}(n,c):void 0);if(a.length)throw new Jo(a);const i=e.opaqueDeletionIntents??[];if(i.length&&!1!==t.pruneDeletedOpaqueDependencies){const t=Qi(n,r,i);if(t.removeEdges.length||t.removeParts.length){const r=await async function(e,t){if(!t.removeParts.length&&!t.removeEdges.length)return e;const n=await Vi.default.loadAsync(e),o=new Pi.XMLSerializer,r=async e=>{const t=n.file(e);if(!t)throw Error("Missing planned OPC part "+e);return Gi(await t.async("string"))};for(const l of new Set(t.removeEdges.map(e=>e.relPath))){const e=await r(l),a=e.documentElement,i=new Set(t.removeEdges.filter(e=>e.relPath===l).map(e=>e.id));for(const t of Xi(a))i.has(t.getAttribute("Id")??"")&&(i.delete(t.getAttribute("Id")),a.removeChild(t));if(i.size)throw Error("OPC relationship plan became stale");Xi(a).length?n.file(l,o.serializeToString(e)):n.remove(l)}const a=new Set(t.removeParts);for(const[l,c]of Object.entries(n.files)){if(c.dir)continue;const e=oi(l);(a.has(l)||"string"==typeof e&&a.has(e))&&n.remove(l)}const i=await r(Ja),s=i.documentElement;if("http://schemas.openxmlformats.org/package/2006/content-types"!==s.namespaceURI||"Types"!==s.localName)throw Error("Invalid OPC content types");for(const l of Xi(s))"http://schemas.openxmlformats.org/package/2006/content-types"===l.namespaceURI&&"Override"===l.localName&&a.has((l.getAttribute("PartName")??"").replace(/^\//,""))&&s.removeChild(l);return n.file(Ja,o.serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,t),a=await o(r),s=qo(n,a,i);if(s.length)throw new Jo(s);return Ca(r,e)}}}return Ca(u,e)}async function iu(e,t={}){if(!e.sourcePackage)return Za(e);const n=await au(e,t);return new Blob([n],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}var su="http://schemas.openxmlformats.org/wordprocessingml/2006/main",lu="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",cu="http://schemas.openxmlformats.org/officeDocument/2006/relationships",du=e=>{throw Error("Opaque insertion rejected: "+e)};function uu(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return du("unsafe XML declaration");const t=new Pi.DOMParser({onError:()=>du("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||du("missing XML root")}function pu(e){const t=[],n=[e];for(let o=0;o<n.length;o++){const e=n[o];t.push(e);for(const t of Array.from(e.childNodes))1===t.nodeType&&n.push(t)}return t}function gu(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function fu(e,t){const n=e.split("/").slice(0,-1),o=t.split("/");for(;n.length&&o.length&&n[0]===o[0];)n.shift(),o.shift();const r="../".repeat(n.length)+o.join("/");return Ea(e,r)!==t?du("unrepresentable relative target"):r}function mu(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e)}var hu={"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":"xml","application/vnd.ms-office.chartstyle+xml":"xml","application/vnd.ms-office.chartcolorstyle+xml":"xml","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/bmp":"bmp","image/tiff":"tiff"};var bu="http://schemas.openxmlformats.org/wordprocessingml/2006/main",yu="[Content_Types].xml",vu="application/vnd.openxmlformats-package.relationships+xml",xu=e=>{throw Error("Opaque transfer application rejected: "+e)};function wu(e,t,n){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return xu("unsafe XML declaration");const o=new Pi.DOMParser({onError:()=>xu("malformed XML")}).parseFromString(e,"application/xml");return o.documentElement?.namespaceURI!==t||o.documentElement.localName!==n?xu("unexpected XML root"):o}function Su(e){return Array.from(e.childNodes).filter(e=>1===e.nodeType)}function Iu(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function Cu(e){return(new Pi.XMLSerializer).serializeToString(e)}function Tu(e,t){return e.byteLength===t.byteLength&&e.every((e,n)=>e===t[n])}function ku(e){const t=/* @__PURE__ */new Set;for(const[n,o]of Object.entries(e.files)){if(o.dir)continue;const e=n.toLowerCase();if(t.has(e)||void 0!==o.unsafeOriginalName&&o.unsafeOriginalName!==n)return xu("ambiguous ZIP entry");if(t.add(e),e.startsWith("_xmlsignatures/"))return xu("signed package")}}async function Pu(e,t,n){const o=await Vi.default.loadAsync(e);ku(o);const r=await La(e);!function(e){if([...e.rootRelationships,...Object.values(e.parts).flatMap(e=>e.relationships??[])].some(e=>e.type.includes("digital-signature"))||[...Object.values(e.contentTypes.defaults),...Object.values(e.contentTypes.overrides)].some(e=>e.includes("digital-signature")))xu("signed package")}(r);const a=function(e,t){const n=ji(e),o=t.mainDocumentPart,r=Object.hasOwn(t.parts,o)?t.parts[o]:void 0;if(!mu(o)||!r||"xml"!==r.kind)return du("missing destination main story");const a=uu(r.data);if(a.namespaceURI!==su||"document"!==a.localName)return du("only Transitional main story is supported");if(br(t).diagnostics.some(e=>"error"===e.level))return du("destination opaque inspection errors");const i=/* @__PURE__ */new Set,s=e=>{if("[Content_Types].xml"!==e&&!mu(e))return du("ambiguous destination OPC path");i.add(e.toLowerCase())};for(const[k,P]of Object.entries(t.parts)){if(P.path!==k)return du("inconsistent destination part path");s(k),"[Content_Types].xml"===k||k.endsWith(".rels")||s(gu(k));for(const e of P.relationships??[])if("External"!==e.targetMode){if(!e.resolvedTarget||Ea(k,e.target)!==e.resolvedTarget)return du("unresolved destination relationship");s(e.resolvedTarget)}}for(const k of Object.keys(t.contentTypes.overrides))s(k);for(const k of t.rootRelationships)if("External"!==k.targetMode){if(!k.resolvedTarget||Ea(null,k.target)!==k.resolvedTarget)return du("unresolved root relationship");s(k.resolvedTarget)}if(new Set(Object.keys(t.parts).map(e=>e.toLowerCase())).size!==Object.keys(t.parts).length)return du("aliased destination parts");let l="";for(let k=1;k<=1e5;k++){const e="word/oasis-transfer-"+k;if(![...i].some(t=>t===e||t.startsWith(e+"/")||e.startsWith(t+"/"))){l=e;break}}if(!l)return du("part namespace exhausted");const c=new Map(n.parts.map((e,t)=>[e.path,l+"/part-"+(t+1)+"."+hu[e.contentType]])),d=(e,t,n=e.id)=>{const o=c.get(e.resolvedTarget);return o?{...e,id:n,target:fu(t,o),resolvedTarget:o,targetMode:"Internal"}:du("unmapped dependency")},u=n.parts.map(e=>{const t=c.get(e.path);return{...e,path:t,relationships:e.relationships.map(e=>d(e,t))}}),p=new Set((r.relationships??[]).map(e=>e.id));if(p.size!==(r.relationships??[]).length)return du("duplicate destination relationship ID");const g=pu(a).flatMap(e=>Array.from(e.attributes).map(e=>e.value));let f=1;const m=n.relationships.map(e=>{let t;do{t="rIdOasisTransfer"+f++}while(p.has(t)||r.data.includes(t)||g.some(e=>e.includes(t)));return p.add(t),{from:e.id,to:t}}),h=new Map(m.map(e=>[e.from,e.to])),b=n.relationships.map(e=>d(e,o,h.get(e.id))),y=uu(n.fragmentXml),v=pu(y),x=v.filter(e=>e.namespaceURI===lu&&"docPr"===e.localName),w=v.filter(e=>"http://schemas.openxmlformats.org/drawingml/2006/chart"===e.namespaceURI&&"chart"===e.localName);if(1!==x.length||1!==w.length||!h.has(w[0].getAttributeNS(cu,"id")??""))return du("ambiguous chart or drawing identity");for(const k of v){if(k!==y&&k.namespaceURI===su)return du("nested WordprocessingML in chart drawing");for(const e of Array.from(k.attributes)){if("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"===e.namespaceURI)return du("unsupported extended drawing identity");if(e.namespaceURI===cu||"http://purl.oclc.org/ooxml/officeDocument/relationships"===e.namespaceURI||"urn:schemas-microsoft-com:office:office"===e.namespaceURI&&"relid"===e.localName){if(k!==w[0]||e.namespaceURI!==cu||"id"!==e.localName||!h.has(e.value))return du("unknown chart relationship reference");k.setAttributeNS(cu,e.name,h.get(e.value))}else if("http://www.w3.org/2000/xmlns/"!==e.namespaceURI&&h.has(e.value))return du("unknown attribute may reference a relationship")}}const S=/* @__PURE__ */new Set;for(const k of Object.values(t.parts)){if("xml"!==k.kind||!k.data.includes("docPr"))continue;const e=k.path===o?a:uu(k.data);for(const t of pu(e)){if(t.namespaceURI!==lu||"docPr"!==t.localName)continue;const e=t.getAttribute("id")??"";if(!/^\d+$/.test(e)||Number(e)>4294967295)return du("invalid destination drawing ID");S.add(Number(e))}}let I=1879048192;for(;S.has(I)&&I<2147483647;)I++;if(S.has(I))return du("drawing identity exhausted");x[0].setAttribute("id",String(I));const C=Pa(y);if(!C)return du("chart projection lost");const T=ji({...n,ownerPath:o,fragmentXml:C.fragmentXml,signature:C.signature,relationships:b,parts:u});return{destinationOwner:o,destinationRun:C,addedRelationships:T.relationships,addedParts:T.parts,contentTypeOverrides:Object.fromEntries(T.parts.map(e=>[e.path,e.contentType])),pathMapping:[...c].map(([e,t])=>({from:e,to:t})),relationshipMapping:m,drawingId:I}}(t,r),i=a.destinationOwner,s=r.parts[i],l=wu(s.data,bu,"document"),c=l.documentElement,d=Su(c).filter(e=>e.namespaceURI===bu&&"body"===e.localName);if(1!==d.length)return xu("ambiguous document body");const u=Su(d[0]).filter(e=>e.namespaceURI===bu&&"p"===e.localName);if(!Number.isSafeInteger(n)||n<0||n>=u.length)return xu("invalid paragraph index");const p=u[n],g=wu(a.destinationRun.fragmentXml,bu,"drawing"),f=l.createElementNS(bu,c.prefix?c.prefix+":r":"r");f.appendChild(l.importNode(g.documentElement,!0)),p.appendChild(f);const m=Cu(l),h=Iu(i),b=function(e,t){const n=wu(e,aa,"Relationships"),o=n.documentElement,r=/* @__PURE__ */new Set;for(const a of Su(o)){const e=a.getAttribute("Id")??"";if("http://schemas.openxmlformats.org/package/2006/relationships"!==a.namespaceURI||"Relationship"!==a.localName||!e||r.has(e)||!a.getAttribute("Type")||!a.getAttribute("Target"))return xu("ambiguous existing relationships");const t=a.getAttribute("TargetMode");if(t&&"Internal"!==t&&"External"!==t)return xu("unknown relationship mode");r.add(e)}for(const a of t){if(r.has(a.id))return xu("relationship collision");r.add(a.id);const e=n.createElementNS(aa,o.prefix?o.prefix+":Relationship":"Relationship");e.setAttribute("Id",a.id),e.setAttribute("Type",a.type),e.setAttribute("Target",a.target),o.appendChild(e)}return Cu(n)}(await(o.file(h)?.async("string"))??'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>',a.addedRelationships),y=await(o.file(yu)?.async("string"));if(!y)return xu("missing content types");const v=function(e,t){const n=wu(e,ja,"Types"),o=n.documentElement,r=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set;let i;for(const s of Su(o)){if("http://schemas.openxmlformats.org/package/2006/content-types"!==s.namespaceURI)return xu("unexpected content type element");const e=s.getAttribute("ContentType")??"";if(!e)return xu("missing content type");if("Default"===s.localName){const t=(s.getAttribute("Extension")??"").toLowerCase();if(!t||a.has(t))return xu("duplicate or invalid content type default");a.add(t),"rels"===t&&(i=e)}else{if("Override"!==s.localName)return xu("unknown content type element");{const e=(s.getAttribute("PartName")??"").toLowerCase();if(!e.startsWith("/")||r.has(e))return xu("duplicate or invalid content type override");r.add(e)}}}if(i&&i!==vu)return xu("inconsistent relationship content type");if(!i){const e=n.createElementNS(ja,o.prefix?o.prefix+":Default":"Default");e.setAttribute("Extension","rels"),e.setAttribute("ContentType",vu),o.insertBefore(e,Su(o).find(e=>"Override"===e.localName)??null)}for(const[s,l]of Object.entries(t.contentTypeOverrides)){const e="/"+s;if(r.has(e.toLowerCase()))return xu("content type override collision");r.add(e.toLowerCase());const t=n.createElementNS(ja,o.prefix?o.prefix+":Override":"Override");t.setAttribute("PartName",e),t.setAttribute("ContentType",l),o.appendChild(t)}return Cu(n)}(y,a),x={...r,parts:{...r.parts,[i]:{...s,data:m,relationships:[...s.relationships??[],...a.addedRelationships]}},contentTypes:{defaults:{...r.contentTypes.defaults,rels:vu},overrides:{...r.contentTypes.overrides,...a.contentTypeOverrides}}};for(const N of a.addedParts)x.parts[N.path]={...N,originalHash:""};const w=br(r),S=br(x);if(S.diagnostics.some(e=>"error"===e.level)||S.objects.length!==w.objects.length+1)return xu("unexpected predicted inventory");const I=S.objects.filter(e=>e.ownerPath===i&&e.signature===a.destinationRun.signature);if(1!==I.length||JSON.stringify(I[0].partPaths)!==JSON.stringify(a.addedParts.map(e=>e.path).sort()))return xu("predicted inserted closure mismatch");const C=S.objects.filter(e=>e!==I[0]),T=e=>JSON.stringify([e.ownerPath,e.kind,e.signature,e.edges,e.partPaths]);if(JSON.stringify(C.map(T).sort())!==JSON.stringify(w.objects.map(T).sort()))return xu("predicted loss of original objects");if(1!==Array.from(c.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing","docPr")).filter(e=>Number(e.getAttribute("id"))===a.drawingId).length)return xu("drawing ID collision");const k=await Vi.default.loadAsync(e),P=/* @__PURE__ */new Set,R=new Set(Object.keys(k.files).map(e=>e.toLowerCase())),B=(e,t,n=!1)=>{const o=e.toLowerCase();if(R.has(o)||P.has(o))return xu("part collision");P.add(o),k.file(e,t,{base64:n})};for(const N of a.addedParts)B(N.path,N.data,"base64"===N.encoding),N.relationships.length&&B(Iu(N.path),Zr(N.relationships));o.file(h)||P.add(h.toLowerCase()),k.file(i,m),k.file(h,b),k.file(yu,v);const M=await k.generateAsync({type:"arraybuffer",compression:"DEFLATE"}),O=await Vi.default.loadAsync(M);ku(O);const A=await La(M),F=qo(x,A);if(F.length)throw new Jo(F);const D=/* @__PURE__ */new Set([i,h,yu]);for(const[N,z]of Object.entries(o.files)){if(z.dir||D.has(N))continue;const e=O.file(N);if(!e||!Tu(await z.async("uint8array"),await e.async("uint8array")))return xu("existing part changed: "+N)}for(const[N,z]of Object.entries(O.files))if(!z.dir&&!o.file(N)&&!P.has(N.toLowerCase()))return xu("unexpected added part: "+N);for(const N of a.addedParts){const e=A.parts[N.path];if(!e||e.contentType!==N.contentType||e.kind!==N.kind||e.encoding!==N.encoding||e.data!==N.data)return xu("copied payload mismatch")}for(const[N,z]of Object.entries(r.parts))if(A.parts[N]?.contentType!==z.contentType)return xu("existing part content type changed");for(const[N,z]of Object.entries(r.contentTypes.defaults))if(A.contentTypes.defaults[N]!==z)return xu("existing default changed");for(const[N,z]of Object.entries(r.contentTypes.overrides))if(A.contentTypes.overrides[N]!==z)return xu("existing override changed");const E=A.parts[i]?.relationships??[],L=x.parts[i].relationships??[];return JSON.stringify(E)!==JSON.stringify(L)?xu("owner relationships changed"):{buffer:M,plan:a}}var Ru=e=>{throw Error("Opaque editor transfer rejected: "+e)};function Bu(e){return 1!==e.sections?.length?Ru("only one section is supported"):e.sections[0].blocks.filter(e=>"paragraph"===e.type)}function Mu(e){if(!e.document.sourcePackage||"main"!==Da(e)||1!==e.document.sections?.length||e.trackChangesEnabled||e.document.opaqueDeletionIntents?.length||e.document.opaqueRelocationIntent||e.document.bookmarks?.order.length||e.document.comments?.order.length)return Ru("unsupported state or pending opaque edit")}function Ou(e){Mu(e);const t=ki(e,e=>"opaque"===e.kind);if(!t||"opaque"!==t.run.kind||t.run.revision||t.run.sdtWrappers?.length||!Bu(e.document).some(e=>e.id===t.paragraph.id))return Ru("select one unwrapped chart in the main story");const n=e.document.sourcePackage,o=t.run.opaque,r=br(n).objects.filter(e=>e.ownerPath===n.mainDocumentPart&&e.signature===o.signature),a=1===r.length?r[0]:void 0;return a&&a.fragmentXml===o.fragmentXml&&JSON.stringify(a.relationshipIds)===JSON.stringify(o.relationshipIds)?function(e,t){const n=br(e);if(n.diagnostics.some(e=>"error"===e.level))return Ei("source inspection errors");const o=n.objects.filter(e=>e.signature===t.signature),r=1===o.length?o[0]:void 0;if(!r||r.ownerPath!==t.ownerPath||r.ordinal!==t.ordinal)return Ei("ambiguous original identity");if("chart"!==r.kind||"inline"!==r.geometry?.placement)return Ei("only inline charts are supported");const a=Wo(e,r.ownerPath,r.relationshipIds);if(a.issues.length)return Ei("unresolved source closure");const i=e.parts[r.ownerPath],s=a.partPaths.map(t=>{const n=Object.hasOwn(e.parts,t)?e.parts[t]:void 0;return n?{path:n.path,contentType:n.contentType,kind:n.kind,encoding:n.encoding,data:n.data,relationships:n.relationships??[]}:Ei("missing source part")});return ji({format:Di,ownerPath:r.ownerPath,fragmentXml:r.fragmentXml,signature:r.signature,relationships:(i.relationships??[]).filter(e=>r.relationshipIds.includes(e.id)),parts:s})}(n,a):Ru("selection is not an unchanged original")}function Au(e){return JSON.stringify(Bu(e).map(e=>{const t=[];let n=0;for(const o of e.runs)"opaque"===o.kind&&t.push([n,o.kind,o.opaque.signature]),n+=o.text.length;return[e.runs.map(e=>e.text).join(""),t]}))}function Fu(e,t,n,o){const r=xe(t,n,[o]),a=Dr(r,n+1);return Sn(e,ma(e).map(e=>e.id===t.id?r:e),{anchor:a,focus:a})}async function Du(e,t){Mu(e);const n=Qr(e);if(!n.isCollapsed)return Ru("paste requires a collapsed caret");const o=ma(e)[n.startIndex],r=Bu(e.document).findIndex(e=>e.id===o?.id);if(!o||r<0)return Ru("caret must be in a direct body paragraph");const a=n.startParagraphOffset;if(!Number.isSafeInteger(a)||a<0||a>bi(o))return Ru("invalid caret");if(o.runs.some(e=>"text"!==e.kind&&"opaque"!==e.kind||e.revision||e.sdtWrappers?.length||e.styles?.link))return Ru("unsupported destination runs");const i=await au(e.document);if(Au(await ve(i.slice(0)))!==Au(e.document))return Ru("destination body projection mismatch");const s=await Pu(i,t,r),l=await La(s.buffer),c=l.opaqueObjects?.filter(e=>e.signature===s.plan.destinationRun.signature&&e.ownerPath===l.mainDocumentPart);if(1!==c?.length)return Ru("staged chart identity mismatch");const d={...s.plan.destinationRun,fragmentXml:c[0].fragmentXml,relationshipIds:[...c[0].relationshipIds]},u={id:Rr("run"),kind:"opaque",text:"",opaque:d,styles:{}},p=function(e,t){const n=e.document.sourcePackage,o=br(n).objects,r=br(t).objects,a=/* @__PURE__ */new Set,i=ma(e).map(e=>{let i=!1;const s=e.runs.map(e=>{if("opaque"!==e.kind)return e;const s=e.opaque,l=o.filter(e=>e.signature===s.signature),c=r.filter(e=>e.signature===s.signature),d=l[0],u=c[0];return 1!==l.length||1!==c.length||!d||!u||d.ownerPath!==n.mainDocumentPart||u.ownerPath!==t.mainDocumentPart||d.kind!==s.objectKind||d.fragmentXml!==s.fragmentXml||JSON.stringify(d.relationshipIds)!==JSON.stringify(s.relationshipIds)||JSON.stringify(d.edges)!==JSON.stringify(u.edges)||JSON.stringify(d.partPaths)!==JSON.stringify(u.partPaths)||d.partPaths.some(e=>{const o=n.parts[e],r=t.parts[e];return!o||!r||o.kind!==r.kind||o.contentType!==r.contentType||o.encoding!==r.encoding||o.data!==r.data})||a.has(d.signature)?Ru("cannot rebind original chart provenance"):(a.add(d.signature),u.fragmentXml===s.fragmentXml?e:(i=!0,{...e,opaque:{...s,fragmentXml:u.fragmentXml,relationshipIds:[...u.relationshipIds]}}))});return i?{...e,runs:s}:e});return Sn(e,i,e.selection)}(e,l),g=ma(p).find(e=>e.id===o.id);if(!g)return Ru("target paragraph lost during rebind");const f={...Fu(p,g,bi(g),u).document,sourcePackage:l};if(Au(await ve(s.buffer))!==Au(f))return Ru("staged body projection mismatch");l.rebuiltPartHashes=await Sa(f,l);const m=Fu(p,g,a,u),h={...m,document:{...m.document,sourcePackage:l}},b=await au(h.document);return Au(await ve(b))!==Au(h.document)?Ru("exported caret position mismatch"):h}var Eu="application/x-oasis-chart-token",Lu="web "+Eu;function Nu(e){return"application/x-oasis-chart-token"===e||"web application/x-oasis-chart-token"===e}var zu,$u=0;function Hu(e){const t=++$u;zu=void 0;const n=Ou(e),o=globalThis.crypto.randomUUID();let r=!1;return{token:o,confirm:()=>!r&&t===$u&&(r=!0,zu={token:o,manifest:n,expires:Date.now()+3e5},!0)}}function Wu(e){return zu&&Date.now()>=zu.expires&&(zu=void 0),zu&&zu.token===e?structuredClone(zu.manifest):void 0}function Uu(e){const t=ma(e),n=Qr(e,t);if(n.isCollapsed)return!1;for(let o=n.startIndex;o<=n.endIndex;o++){const e=t[o];if(!e)continue;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:bi(e);let i=0;for(const t of e.runs){const e=i+t.text.length;if("opaque"===t.kind&&i<a&&e>r)return!0;i=e}}return!1}function ju(e){const t=Qr(e);if(t.isCollapsed)return"";const n=ma(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 s=n[i];if(!s)continue;const l=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:bi(s),d=rn(s,l,c),u=Ao(s,e.document,d.map(e=>e.text).join("")),p=Vt(d,e.document);if(s.list?.kind){const e="bullet"===s.list.kind?"ul":"ol";r!==s.list.kind&&(a(),o.push(`<${e}>`),r=s.list.kind),o.push(`<li${u}>${p}</li>`);continue}a(),o.push(`<p${u}>${p}</p>`)}return a(),o.join("")}function Vu(e,t){if(0===t.length||me(e))return e;const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(n),i=ma(n),s=0===bi(o);if(me(n))return e;const{beforeRuns:l,afterRuns:c}=Lo(o,a),u=t.map(e=>{const t=di(e.runs.map(e=>({text:e.text,styles:Fr(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let p,g=Y(Dr(o,a));if(1===u.length){const e=u[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=d(o,[...l,...e.runs.map(Cr),...c],Zn(o,a));n.style=s&&void 0!==e.style?.tabs?{...o.style,tabs:e.style.tabs}:o.style?{...o.style}:e.style?{...e.style}:void 0,n.list=o.list?{...o.list}:e.list?{...e.list}:void 0,p=[...fr(i.slice(0,r)),n,...fr(i.slice(r+1))],g=Y(Dr(n,l.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=u[0],t=u[u.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),f=d(o,[...l,...e.runs.map(Cr)],Zn(o,a));f.style=s&&void 0!==e.style?.tabs?{...o.style,tabs:e.style.tabs}:o.style?{...o.style}:e.style?{...e.style}:void 0,f.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const m=u.slice(1,-1).map(tr),h=d(t,[...t.runs.map(Cr),...c],void 0);h.list=t.list?{...t.list}:void 0,p=[...fr(i.slice(0,r)),f,...m,h,...fr(i.slice(r+1))],g=Y(Dr(h,n))}return Sn(n,p,g)}function Ku(e){return e.map(Cr)}function _u(e){return e.reduce((e,t)=>e+t.text.length,0)}function Xu(e,t,n){if(0===n.length)return e;const o=ma(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=$r(a,t),s=Ku(n[0].runs);if(1===n.length){const t=xe(a,i,s),n=o.map((e,n)=>n===r?t:e),l=_u(s),c=Dr(t,i),d=Dr(t,i+l);return Sn(e,n,{anchor:c,focus:d})}const l=rn(a,0,i),c=rn(a,i,bi(a)),u=n[n.length-1],p=n.slice(1,-1),g=d(tr(n[0].paragraphTemplate),[...l,...s],Zn(a,i)),f=p.map(e=>d(tr(e.paragraphTemplate),Ku(e.runs))),m=d(tr(u.paragraphTemplate),[...Ku(u.runs),...c],Zn(a,i)),h=[...o.slice(0,r),g,...f,m,...o.slice(r+1)],b=Dr(g,_u(l)),y=Dr(m,_u(u.runs));return Sn(e,h,{anchor:b,focus:y})}function Gu(e,n,o={}){const r=Qr(e);if(r.isCollapsed)return e;if(function(e,t){const n=Qr(e);if(n.isCollapsed)return!1;const o=ma(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=$r(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,n))return e;if(me(e))return e;const a=ma(e).find(e=>e.id===n.paragraphId);if(a&&(t(a)||et(a,$r(a,n),$r(a,n))))return e;const i=function(e){const t=Qr(e);if(t.isCollapsed)return[];const n=ma(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:bi(e),s=rn(e,a,i);o.push({paragraphTemplate:tr(e),runs:s})}return o}(e);if(0===i.length)return e;const s=i.flatMap(e=>e.runs);if(s.some(e=>"opaque"===e.kind)){if(o.copy||e.trackChangesEnabled||1!==s.length||"opaque"!==s[0].kind||s[0].revision||s[0].sdtWrappers?.length||1!==i.length)return e;const t=ma(e),a=t.findIndex(e=>e.id===n.paragraphId);if(a<0)return e;const l=t[a],c=$r(l,n),d=r.endParagraphOffset-r.startParagraphOffset,u=a===r.startIndex&&c>r.endParagraphOffset?c-d:c,p=Q(e),g=ma(p).find(e=>e.id===l.id);return g?Xu(p,Dr(g,u),i):e}if(o.copy)return Xu(e,n,i);const l=function(e,t){const n=Qr(e),o=ma(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=$r(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return Dr(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,n);return Xu(Q(e),l,i)}function qu(e,t,n){if(0===t.length)return e;if(Ia(e.selection)&&!e.trackChangesEnabled?Wn(e):me(e))return e;const o=Ia(e.selection)?e:Q(e),{paragraph:r,index:a,offset:i}=oe(o),s=n?{...n}:Zn(r,i),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:s,kind:"text"};o.trackChangesEnabled&&(l.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=!e.trackChangesEnabled&&Ia(e.selection)?e.selection.focus.fieldBoundaryAffinity:void 0,d=xe(r,i,[l],c),u=ma(o).map((e,t)=>t===a?d:e);return Sn(o,u,Y(ar(d,i+t.length,c)))}function Yu(e){return qu(e,"\v")}function Zu(e,n,o){if(0===n.length)return e;const r=n.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!r.includes("\n"))return qu(e,r,o);if(Ve(e))return e;const a=Ia(e.selection)?e:Q(e),{paragraph:i,index:s,offset:l}=oe(a);if(Ve(a))return e;const c=r.split("\n"),u=o?{...o}:Zn(i,l),{beforeRuns:p,afterRuns:g}=Lo(i,l,a.selection.focus.fieldBoundaryAffinity),f=d(i,[...p,er(c[0],u)],u),m=c.slice(1,-1).map(e=>De([{text:e,styles:u}])),h=d(t(i)?He(i,[]):De([]),[er(c[c.length-1],u),...g],u),b=ma(a),y=[...b.slice(0,s),f,...m,h,...b.slice(s+1)];return Sn(a,y,Y(ar(h,c[c.length-1].length,"before-markers")))}function Ju(e,t){const n=ma(e),o=Qr(e,n);if(o.startIndex!==o.endIndex)return;const r=n[o.startIndex];if(!r)return;let a=o.startParagraphOffset,i=o.endParagraphOffset;if(o.isCollapsed&&("backward"===t?a-=1:i+=1),a<0||i>bi(r)||i-a!==1)return;let s,l=0;for(const h of r.runs){if(l===a&&"opaque"===h.kind&&""===h.text){s=h;break}l+=h.text.length}if(!s)return;if(e.trackChangesEnabled||s.revision||"main"!==Da(e))return e;const c=e.document.sourcePackage;if(!c)return e;const d=s.opaque.signature,u=(c.opaqueObjects??[]).filter(e=>e.signature===d);if(1!==u.length||u[0].ownerPath!==c.mainDocumentPart||u[0].issues.length)return e;const p=u[0],g=e.document.opaqueDeletionIntents??[];if(g.some(e=>e.ownerPath===p.ownerPath&&e.ordinal===p.ordinal))return e;const f=Q({...e,selection:{anchor:Dr(r,a),focus:Dr(r,i)}}),m={ownerPath:p.ownerPath,ordinal:p.ordinal,signature:p.signature};return{...f,document:{...f.document,opaqueDeletionIntents:[...g,m]}}}function Qu(e){const n=Ju(e,"backward");if(void 0!==n)return n;if(!Ia(e.selection))return Q(e);const{paragraph:o,index:r,offset:a}=oe(e),i=ma(e);if(a>0){if(e.trackChangesEnabled&&Et(e)||O(e,o,a-1,a))return e;if(t(o)){const t={...e,selection:{anchor:Dr(o,a-1),focus:Dr(o,a)}};return Q(t)}if(e.trackChangesEnabled){const t=o.runs;let n=0,s=-1,l=-1;for(let e=0;e<t.length;e+=1){const o=n+t[e].text.length;if(a<=o){s=e,l=a-n;break}n=o}if(-1!==s){const n=t[s];if("insert"===n.revision?.type){const t=[...rn(o,0,a-1),...rn(o,a,bi(o))],n=d(o,t),s=i.map((e,t)=>t===r?n:e);return Sn(e,s,Y(Dr(n,a-1)))}const c=n.text[l-1],u={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...n.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...rn(o,0,a-1),u,...rn(o,a,bi(o))],g=d(o,p),f=i.map((e,t)=>t===r?g:e);return Sn(e,f,Y(Dr(g,a-1)))}}const n=d(o,[...rn(o,0,a-1),...rn(o,a,bi(o))],Zn(o,a-1)),s=i.map((e,t)=>t===r?n:e);return Sn(e,s,Y(Dr(n,a-1)))}if(0===r)return e;const s=i[r-1];if(qe(e,s,o))return e;const l=d(s,[...s.runs.map(Cr),...o.runs.map(Cr)]),c=[...i.slice(0,r-1),l,...i.slice(r+1)];return Sn(e,c,Y(ar(l,bi(s),W(s,o))))}function ep(e){const n=Ju(e,"forward");if(void 0!==n)return n;if(!Ia(e.selection))return Q(e);const{paragraph:o,index:r,offset:a}=oe(e),i=ma(e);if(a<bi(o)){if(e.trackChangesEnabled&&Et(e)||O(e,o,a,a+1))return e;if(t(o)){const t={...e,selection:{anchor:Dr(o,a),focus:Dr(o,a+1)}};return Q(t)}if(e.trackChangesEnabled){const t=o.runs;let n=0,s=-1,l=-1;for(let e=0;e<t.length;e+=1){const o=n+t[e].text.length;if(a<o){s=e,l=a-n;break}n=o}if(-1!==s){const n=t[s];if("insert"===n.revision?.type){const t=[...rn(o,0,a),...rn(o,a+1,bi(o))],n=d(o,t),s=i.map((e,t)=>t===r?n:e);return Sn(e,s,Y(Dr(n,a)))}const c=n.text[l],u={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...n.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...rn(o,0,a),u,...rn(o,a+1,bi(o))],g=d(o,p),f=i.map((e,t)=>t===r?g:e);return Sn(e,f,Y(Dr(g,a)))}}const n=d(o,[...rn(o,0,a),...rn(o,a+1,bi(o))],Zn(o,a)),s=i.map((e,t)=>t===r?n:e);return Sn(e,s,Y(Dr(n,a)))}if(r>=i.length-1)return e;const s=i[r+1];if(qe(e,o,s))return e;const l=d(o,[...o.runs.map(Cr),...s.runs.map(Cr)]),c=[...i.slice(0,r),l,...i.slice(r+2)];return Sn(e,c,Y(ar(l,a,W(o,s))))}function tp(e,t,n,o,r){let a=zr(n,o,r);const i=lr(a,t.style?.styleId,e.document.styles);return!r&&i[o]&&(a={...a,[o]:!1}),!r||"superscript"!==o&&"subscript"!==o||(a=tp(e,t,a,"superscript"===o?"subscript":"superscript",!1)),a}function np(e,t){const n=Qr(e);if(n.isCollapsed||_(e))return e;const o=ma(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:bi(t);return rn(t,a,i).map(n=>({...n,styles:lr(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,s=r===n.endIndex?n.endParagraphOffset:bi(o);return R(e,o,i,s,n=>({...n,styles:tp(e,o,n.styles,t,a)}))});return Sn(e,i,z(i,n))}function op(e,t,n){const o=Qr(e);if(o.isCollapsed||_(e))return e;const r=ma(e).map((r,a)=>{if(a<o.startIndex||a>o.endIndex)return r;const i=a===o.startIndex?o.startParagraphOffset:0,s=a===o.endIndex?o.endParagraphOffset:bi(r);return R(e,r,i,s,e=>({...e,styles:ur(e.styles,t,n)}))});return Sn(e,r,z(r,o))}function rp(e,t){const n=Qr(e);if(n.isCollapsed||_(e))return e;const o=ma(e),r=e.document.styles,a=o.map((o,a)=>{if(a<n.startIndex||a>n.endIndex)return o;const i=a===n.startIndex?n.startParagraphOffset:0,s=a===n.endIndex?n.endParagraphOffset:bi(o);return R(e,o,i,s,e=>{const n=(lr(e.styles,o.style?.styleId,r).fontSize??14.6667)*xa,a=Math.max(1,Math.min(1638,n+t));return{...e,styles:ur(e.styles,"fontSize",a/xa)}})});return Sn(e,a,z(a,n))}var ap={width:.5,type:"solid",color:"#000000"};function ip(e,t){const n={...e??{}};return t?n.textBorder=ap:delete n.textBorder,Object.keys(n).length>0?n:void 0}function sp(e){return/\p{L}/u.test(e)}function lp(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=sp(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&&sp(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function cp(e,t){return function(e,t){const n=Qr(e);if(n.isCollapsed)return e;const o=ma(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:bi(e),i=t(rn(e,r,a).map(e=>e.text).join(""));let s=0;return ue(e,r,a,e=>{const t=e.text.length,n=i.slice(s,s+t);return s+=t,{...e,text:n}})});return Sn(e,o,z(o,n))}(e,e=>lp(e,t))}var dp=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function up(e,t){const n=Fr(e)??{};delete n.link;for(const o of dp)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function pp(e,t){if(0===t.length)return[];const n=Qr(e),o=ma(e)[n.startIndex];if(!o)return t;const r=Zn(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:up(r,e.styles)})),style:rr(o.style),list:o.list?{...o.list}:void 0}))}function gp(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:[er("")];n.push({runs:r.map(e=>{const t=Ya(e);return{text:e.text,styles:Fr(e.styles),image:t?{...t}:void 0}}),style:e?bo(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,v(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,[er(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=dn(e.tagName);if(t){a(e,t);continue}if(se(e.tagName)){r(e,v(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=v(e,void 0);n.length>0&&r(null,n)}return n}async function fp(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.stateSnapshot?.()??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(),a=n.flatMap(e=>e.types.filter(Nu).map(t=>({item:e,type:t})));if(a.length){if(1!==a.length||"rich"!==e)return{kind:"unsupported"};try{const e=await a[0].item.getType(a[0].type);if(e.size>128)return{kind:"unsupported"};const t=await e.text();return t.length<=128?{kind:"chart",token:t}:{kind:"unsupported"}}catch{return{kind:"unsupported"}}}let i="",s="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(i=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(s=await(await t.getType("text/plain")).text());if(i||s)return{kind:"content",html:i,text:s};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(l){return e.onError?.(l),e.onIssue?.("access-denied"),!1}if(e.isReadOnly())return!1;if(e.state().document!==n.document)return e.onIssue?.("document-changed"),!1;if("chart"===r.kind){if("rich"!==t||!e.stateSnapshot)return e.onIssue?.("unsupported"),!1;const o=Wu(r.token);if(!o)return e.onIssue?.("unsupported"),!1;if(e.stateSnapshot()!==n)return e.onIssue?.("document-changed"),!1;let a;try{a=await Du(n,o)}catch(l){return e.isReadOnly()||(e.onError?.(l),e.onIssue?.("unsupported")),!1}if(e.isReadOnly())return!1;if(e.stateSnapshot()!==n)return e.onIssue?.("document-changed"),!1;let i=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.isReadOnly()||t!==n?t:(i=!0,a)),i?e.focusInput():e.isReadOnly()||e.onIssue?.("document-changed"),i}if("content"!==r.kind)return e.onIssue?.(r.kind),!1;const a="text"!==t?gp(r.html):[],i="merge"===t?pp({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return e.onIssue?.("unsupported"),!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let s=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},l=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Vu(e,i):Zu(e,r.text));return s=l.document!==t.document,l}),s&&e.focusInput(),s}function mp(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 hp(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>mp(e))}catch{}return Promise.resolve(mp(e))}async function bp(e,t){if(Uu(e)){let n;try{n=Hu(e)}catch{return t?.("unsupported"),!1}const o="undefined"!=typeof navigator?navigator.clipboard:void 0;if(!o?.write||"undefined"==typeof ClipboardItem)return t?.("unsupported"),!1;try{const e=new ClipboardItem({[Lu]:new Blob([n.token],{type:Lu.slice(4)})});return await o.write([e]),n.confirm()}catch{return t?.("access-denied"),!1}}const n=await function(e){const t=Si(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=ju(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,()=>hp(t))}catch{}return hp(t)}(e);return!n&&Si(e)&&t?.("access-denied"),n}function yp(e){return function(e){const[t,n]=Pt();let o,r=0;Nt()&&qt(()=>{r++});const a=()=>{n(void 0),o=void 0},i=()=>{r++,a()},s=async(t,i="rich")=>{const s=++r;a();const l=e.stateSnapshot?.()??e.state(),c=a=>{s===r&&(n({action:t,issue:a,..."paste"===t?{mode:i}:{}}),"access-denied"!==a&&"unsupported"!==a||("paste"!==t||"unsupported"===a&&"rich"!==i||(o={document:l.document,mode:i}),e.focusInput()),e.onIssue?.(a))};if("copy"===t)return bp(l,c);const d={...e,onIssue:c,isReadOnly:()=>s!==r||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.stateSnapshot?.()??e.state();if(Uu(t))return e.onIssue?.("unsupported"),!1;if(!Si(t))return!1;if(!(await bp(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=>Qu(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):fp(d,i)},l=()=>{const t=o;return i(),t?.document===e.state().document?t.mode:void 0},c=(t,o)=>{r++,a(),n({action:t,issue:o,..."paste"===t?{mode:"rich"}:{}}),e.onIssue?.(o)};return{notice:t,dismiss:i,reportNativeIssue:c,requestGeneration:()=>r,consumePasteMode:l,copy:()=>s("copy"),cut:()=>s("cut"),paste:(e="rich")=>s("paste",e),hasSelection:()=>Si(e.state()).length>0}}(e)}var vp=/*#__PURE__*/kn("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),xp=/*#__PURE__*/kn("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function wp(e){const t=We();let o;const[r,a]=Pt(12);wt(()=>{if(!e.notice())return;const t=o?.parentElement;if(!t)return;const n=()=>{const e=t.getBoundingClientRect(),n=t.querySelector(".oasis-editor-toolbar"),r=n?n.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),s=window.innerHeight-e.top-(o?.offsetHeight??0)-12;a(Math.max(i,Math.min(r,s)))};queueMicrotask(n);const r=new ResizeObserver(n);r.observe(t),o&&r.observe(o);const i=t.querySelector(".oasis-editor-toolbar");i&&r.observe(i),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),qt(()=>{r.disconnect(),window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)})});return i=vp(),"function"==typeof o?Xn(o,i):o=i,Ye(i,Qn(dt,{get when(){return e.notice()},children:n=>{return o=xp(),Ye(o,Qn(tn,{name:"clipboard"}),null),Ye(o,Qn(io,{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),Ye(o,Qn(Ie,{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}})),po(e=>n(i,"top",`${r()}px`)),i;var i}var Sp=/[\s\-–—/_([{]/;function Ip(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||Sp.test(e[t-1]??"")}(o,r)?e+=100:e+=200,e+=Math.round(n.length/o.length*50),e}let a=0,i=-1,s=-1,l=0;for(const d of n){const e=o.indexOf(d,a);if(-1===e)return null;-1===i&&(i=e),l+=e-a,a=e+1,s=e}const c=s-i+1;return Math.max(1,120-l-4*Math.abs(c-n.length))}function Cp(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=Ip(n,t.label),r=Ip(n,t.command),a=Math.max(o??Number.NEGATIVE_INFINITY,(r??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var Tp=/*#__PURE__*/kn("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),kp=/*#__PURE__*/kn("<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>"),Pp=/*#__PURE__*/kn("<kbd class=oasis-command-search-shortcut>"),Rp=/*#__PURE__*/kn("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function Bp(e){const t=We(),[n,o]=Pt(""),[r,a]=Pt(0);let i;wt(()=>{e.isOpen&&(o(""),a(0),queueMicrotask(()=>{i?.focus()}))});const s=mn(()=>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=Cp(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));wt(()=>{s(),a(e=>Math.min(e,Math.max(0,s().length-1)))});const l=t=>e.isEnabled(t.command,t.payload),c=t=>{l(t)&&e.onExecute(t)},d=e=>{const t=s().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=s()[r()];e&&c(e);break}case"Escape":t.preventDefault(),e.onClose()}};return Qn(dt,{get when(){return e.isOpen},get children(){var d=kp(),p=d.firstChild;return X(d,"click",e.onClose,!0),p.$$keydown=u,p.$$click=e=>e.stopPropagation(),Ye(p,Qn(P,{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 Ke(()=>!!s()[r()])()?`editor-command-search-option-${r()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),Ye(p,Qn(io,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),Ye(p,Qn(dt,{get when(){return s().length>0},get fallback(){return Qn(io,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=Tp();return Ye(e,Qn(en,{get each(){return s()},children:(e,t)=>{const n=()=>t()===r(),o=()=>l(e);return(i=Rp()).$$click=()=>c(e),i.addEventListener("mouseenter",()=>{a(t())}),Ye(i,Qn(io,{as:"span",get children(){return e.label}}),null),Ye(i,Qn(dt,{get when(){return e.shortcut},get children(){var t=Pp();return Ye(t,()=>e.shortcut),t}}),null),po(r=>{var a=`editor-command-search-option-${t()}`,s=n(),l=!o()||void 0,c=!!n(),d=!o(),u=e.command;return a!==r.e&&he(i,"id",r.e=a),s!==r.t&&he(i,"aria-selected",r.t=s),l!==r.a&&he(i,"aria-disabled",r.a=l),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&&he(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),Ye(p,Qn(Pn,{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),po(()=>he(p,"aria-label",t("commandSearch.title"))),d}})}function Mp(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function Op(e){return Mp(e.command)}U(["click","keydown"]);var Ap=!1,Fp=null,Dp=null,Ep=null,Lp=[];function Np(){"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}()?Ap&&(delete window.__oasisCanvasDebug,Ap=!1):Ap||(window.__oasisCanvasDebug={getLastHit:()=>Fp?{...Fp}:null,getLayoutSnapshot:()=>Dp?{...Dp,surfaceRect:{...Dp.surfaceRect},pages:Dp.pages.map(e=>({...e})),paragraphs:Dp.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:Dp.inlineImages.map(e=>({...e})),inlineTextBoxes:Dp.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:Dp.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Ep?{anchor:{...Ep.anchor},focus:{...Ep.focus},activeZone:Ep.activeZone,activeSectionIndex:Ep.activeSectionIndex}:null,getMissEvents:()=>Lp.map(e=>({...e})),clearMissEvents:()=>{Lp=[]}},Ap=!0))}function zp(e){Ap&&e&&(Fp={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var $p=["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 Hp(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function Wp(e){return function(e){const[t,n]=Pt([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))Hp(r,o,i.textStyle?.fontFamily);Hp(r,o,t.fontFamily);for(const i of n)Hp(a,o,i);for(const i of $p)Hp(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(Tn);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(Qt(e))}const o=Qt(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 m();e.length>0&&n(e)}}}(e)}var Up="insertText",jp="composition",Vp="insertImage",Kp="insertTable",_p="moveImage",Xp="splitListItem",Gp="link",qp="imageAlt",Yp="imageCaption",Zp="imageResize",Jp="imageCrop",Qp="imageFlip",eg="imageRotate",tg="imageTransparency",ng="imageReset",og="layoutWrapPolygon",rg="specialIndent",ag="paraBorders",ig="paragraphMoveUp",sg="paragraphMoveDown",lg="findReplace",cg="findReplaceAll",dg="tableProperties",ug="paragraph-dialog",pg="font-dialog",gg="copyTextByDrag",fg="moveTextByDrag",mg="mergeTable",hg="splitTable",bg="insertTableColumn",yg="deleteTableColumn",vg="insertTableRow",xg="deleteTableRow",wg="tableShading",Sg="tableBorders",Ig="tableWidth",Cg="tableAlign",Tg="tableCellAlignment",kg="tableCellVerticalAlign",Pg="tableCellTextDirection",Rg="tableCellWidth",Bg="tableColumnWidth",Mg="tableToText",Og="textToTable",Ag="tableSplitAtRow",Fg="tableSortAscending",Dg="tableSortDescending",Eg="tableDelete",Lg="deleteTableCell",Ng="tableAutoFit",zg="tableRepeatHeaderRows",$g="tableCellMargins",Hg="tableFormula",Wg="tableRowHeight",Ug="tableStyleOptions",jg="tableStyleGallery",Vg="tableDistribute",Kg="layoutWrapPreset",_g="layoutFixedPosition",Xg="shapeFill",Gg="shapeOutline",qg="shapeOutlineWidth",Yg="floatingAlign",Zg="floatingReorder",Jg="floatingNudge",Qg="floatingFixedPosition",ef="floatingRotation",tf="floatingWrap",nf="floatingWrapText",of="floatingPositionPreset",rf="shapePreset",af="textBoxTextDirection",sf="textBoxVerticalAlign",lf="textBoxAlt",cf="textBoxRotate",df="textBoxWidthCm",uf="textBoxHeightCm";function pf(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 gf(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function ff(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function mf(e,t){const n=Ta(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 hf(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:hf(e.blocks,t)}))}))}})}function bf(e,t,n){const o=Ta(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function yf(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function vf(e){const t=Ka(e),n=Or(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:yf(n)}:null}function xf(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 s=xf(i.blocks,t.slice(1),n);if(s===i.blocks)return e;const l=[...a.cells];l[o.cellIndex]={...i,blocks:s};const c=[...r.rows];c[o.rowIndex]={...a,cells:l};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function wf(e,t){return Boolean(e?.some(e=>Uo(e).some(e=>e.id===t)))}function Sf(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?wf(e.firstPageHeader,n)?"firstPage":wf(e.evenPageHeader,n)?"evenPage":"default":wf(e.firstPageFooter,n)?"firstPage":wf(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[ai(t,o)]??null}return null}function If(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?wf(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:wf(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?wf(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:wf(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function Cf(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?Cf(a.blocks,t.slice(1)):null}function Tf(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 s=Tf(i.blocks,t.slice(1),n);if(!s)return null;const l=[...a.cells];l[o.cellIndex]={...i,blocks:s};const c=[...r.rows];c[o.rowIndex]={...a,cells:l};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function kf(e){const t=vf(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return Rf(e,r);const a=Ta(e.document)[n];return a?Sf(a,o.zone,r):null}function Pf(e){const t=e.selection.focus.paragraphId,n=Da(e);if("footnote"===n)return Rf(e,t);const o=Ka(e),r=Ta(e.document)[o];return r?Sf(r,n,t):null}function Rf(e,t){const n=Xo(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function Bf(e,t){const n=vf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>Tf(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Xo(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 s=Ta(e.document).map((e,t)=>t===o?If(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}function Mf(e,t){const n=vf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>xf(e,r.tablePath,t);if("footnote"===r.zone){const t=Xo(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 s=Ta(e.document).map((e,t)=>t===o?If(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}var Of={width:.5,type:"solid",color:"#000000"},Af={width:0,type:"none",color:"transparent"};function Ff(e){const t=Ka(e),n=Or(e.document,e.selection.anchor.paragraphId,t),o=Or(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=bf(e.document,t,n.zone);if(!r)return null;const a=Ra(r,n.tablePath),i=Ra(r,o.tablePath),s=a?.[a.length-1],l=i?.[i.length-1];if(!s||!l||s.table!==l.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=Ga(s.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 Df(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=Ff(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of Uo(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=Qr(e),o=ma(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:{...gf(),type:"property",previous:{...r??{}}}}),{...o,style:ff(r,t,n)}},a=Ta(e.document).map(e=>({...e,blocks:Kt(e.blocks,o,r),header:e.header?Kt(e.header,o,r):void 0,footer:e.footer?Kt(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function Ef(e,t){let n=Df(e,"borderTop",t);return n=Df(n,"borderRight",t),n=Df(n,"borderBottom",t),n=Df(n,"borderLeft",t),n}function Lf(e,t,n){const o=function(e){const t=Qr(e),n=ma(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)}))})),s={...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:{...gf(),type:"property",previous:{...r??{}}}}),{...o,style:ff(r,t,n)}})(s):s});return mf(e,r)}function Nf(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:{...gf(),type:"property",previous:{...a??{}}}}),{...r,style:ff(a,n,o)}};return mf(e,e=>hf(e,r))}function zf(e,t,n){const o=vf(e);if(!o)return e;return Mf(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:{...gf(),type:"property",previous:{...o??{}}}}),{...r,style:ff(o,t,n)}})():r);return{...r,rows:a}})}function $f(e,t){const n=vf(e);if(!n)return e;return Mf(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:{...gf(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:ff(a,"isHeader",i??null)}})}))}function Hf(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:{...gf(),type:"property",previous:{...r??{}}}}),{...t,style:ff(r,"height",n[o])}});return{...o,rows:r}};return mf(e,e=>hf(e,o))}function Wf(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*xa:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Uf(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=Ga(a),s=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),l=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(l);let d=!1,u=!0;for(let e=0;e<l;e+=1){const t=Wf(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=s.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?{...gf(),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={...gf(),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?{...gf(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return mf(e,e=>hf(e,a))}function jf(e){const t=vf(e);if(!t)return e;const n=kf(e);if(!n)return e;const o=Cf(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(tr(n));return t}(o);if(0===r.length)return e;const a=Bf(e,r);if(a===e)return e;const i=r[0];return{...a,selection:Y(Dr(i,0))}}function Vf(e){if(vf(e))return e;if(!Pf(e))return e;const t=ma(e);if(0===t.length)return e;const n=Qr(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(Kf),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>Ba(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:Rr("paragraph"),type:"paragraph",runs:o.length>0?o:[Ar("")]};return vr([r])})));return Zo(o)}(o),a=o[0].id,i=o[o.length-1].id;let s=null,l=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=Da(e),r=Ka(e);if("footnote"===o){const o=Xo(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=Ta(e.document).map((e,a)=>a===r?If(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 s=0;s<e.length;s+=1){const o=e[s];"paragraph"===o.type&&(o.id===t&&(r=s),o.id===n&&(a=s))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let s=r;s<=a;s+=1)if("paragraph"!==e[s].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?(s=n,l=!0,t):e});return l&&s?{...c,selection:Y(Dr(s,0))}:e}function Kf(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=Cr(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 _f(e,t){const n=vf(e);if(!n)return e;const o=n.loc.cellIndex;return Mf(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const l of e.rows)l.isHeader?o.push(l):r.push(l);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=Xf(e.cells[t]),r=Xf(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),s=[...o,...i];return s.length===e.rows.length&&s.every((t,n)=>t===e.rows[n])?e.rows:s}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function Xf(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Uo(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Gf(e){return!0===e.isHeader}function qf(e){return null!==vf(e)}function Yf(e){return null!==vf(e)}var Zf=/* @__PURE__ */new Set(["left","center","right"]);function Jf(e,t){const n=vf(e);if(!n)return e;if(null!==t&&!Zf.has(t))return e;const o=function(e,t){const n=vf(e);if(!n)return null;const o=Ra(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,bf(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:Lf(e,"align",a)}function Qf(e){return null!==vf(e)}var em=["SUM","AVERAGE","COUNT","MIN","MAX"];function tm(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 em.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=vf(e);if(!o)return e;const r=kf(e);if(!r)return e;const a=Cf(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=Ga(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(!om(r,i,t))continue;if(!rm(r,i,t))continue;const e=am(nm(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const s=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)),l=o.loc.rowIndex,c=o.loc.cellIndex,d=Mf(e,e=>({...e,rows:e.rows.map((e,t)=>t!==l?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Go(s)]})})}));if(d===e)return e;const u=Go(s);return{...d,selection:Y(Dr(u,s.length))}}function nm(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Uo(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function om(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 rm(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 am(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 im(e,t){const n=function(e){const t=vf(e);if(!t)return null;const n=kf(e);if(!n)return null;const o=Cf(n,t.loc.tablePath);if(!o)return null;const r=Ga(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 s=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),l=s[0].cell,c=s[s.length-1].cell,d=sm(l),u=sm(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:Dr(p,0),focus:Dr(g,Ko(g).length)}}:e}function sm(e){return e.blocks.flatMap(Uo)}function lm(e){const t=function(e){const t=vf(e);if(!t)return null;const n=kf(e);if(!n)return null;const o=Cf(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function cm(e){const t=vf(e);if(!t)return e;const n=kf(e);if(!n)return e;const o=Cf(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 s=Mf(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(s===e)return e;const l=i.cells[Math.min(a,i.cells.length-2)],c=l?l.blocks.flatMap(Uo)[0]??null:null;return c?{...s,selection:Y(Dr(c,0))}:s}var dm={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 um(e){const t=Ka(e),n=Or(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Ra(function(e,t){const n=Ta(e.document)[Ka(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=Ga(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 pm(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 gm(e){return!!e&&"none"!==e.type&&e.width>0}function fm(e,t="table"){const n=pm(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=pm(o?.style?.height),i=pm(r?.style?.width),s=e.table.gridCols?.[e.visualColumnIndex],l=pm(s),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(gm)[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{...dm,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:pm(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:l.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:gm(c.borderTop),borderRight:gm(c.borderRight),borderBottom:gm(c.borderBottom),borderLeft:gm(c.borderLeft),borderStart:gm(c.borderStart),borderEnd:gm(c.borderEnd),borderTopLeftToBottomRight:gm(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:gm(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function mm(e,t,n){return Df(e,t,n)}function hm(e){return Boolean(um(e))}function bm(e,t="table"){const n=um(e);return n?fm(n,t):null}function ym(e){const t=()=>hm(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=bm(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=um(e);if(!n)return e;let o=e;return o=Nf(o,n.tableId,"width",t.tableWidth),o=Nf(o,n.tableId,"align",t.tableAlign),o=Nf(o,n.tableId,"indentLeft",t.tableIndentLeft),o=Nf(o,n.tableId,"floating",t.tableFloating),o=Nf(o,n.tableId,"tblOverlap",t.tableOverlap),o=Nf(o,n.tableId,"altTitle",t.altTitle),o=Nf(o,n.tableId,"altDescription",t.altDescription),o=$f(o,t.repeatHeader),o=zf(o,"height",t.rowHeight),o=zf(o,"heightRule",t.rowHeightRule),o=zf(o,"cantSplit",t.cantSplit),o=zf(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Uf(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=mm(o,"width",t.cellWidth),o=mm(o,"verticalAlign",t.cellVerticalAlign),o=mm(o,"textDirection",t.cellTextDirection),o=mm(o,"noWrap",t.cellNoWrap),o=mm(o,"fitText",t.cellFitText),o=mm(o,"hideMark",t.cellHideMark),o=mm(o,"paddingTop",t.margins.top),o=mm(o,"paddingRight",t.margins.right),o=mm(o,"paddingBottom",t.margins.bottom),o=mm(o,"paddingLeft",t.margins.left),o=mm(o,"borderTop",t.borders.top),o=mm(o,"borderRight",t.borders.right),o=mm(o,"borderBottom",t.borders.bottom),o=mm(o,"borderLeft",t.borders.left),o=mm(o,"borderStart",t.borders.start),o=mm(o,"borderEnd",t.borders.end),o=mm(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=mm(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=mm(o,"shading",t.shading),o}(e,n),{mergeKey:dg}),e.focusInput())}}}function vm(e){return function(e){const t=e.t,n=e.clipboardActions??yp({...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=!Ia(e.state().selection),i=e.isReadOnly(),s=[{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}],l=e.table;return l?.isInsideTable()&&s.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:l.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:l.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:l.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:l.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:l.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:l.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:l.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!l.canMerge(),testId:"editor-context-menu-table-merge",onSelect:l.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!l.canSplit(),testId:"editor-context-menu-table-split",onSelect:l.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:l.openBordersAndShading}),s},s=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},l=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:i,closeContextMenu:l,handleEditorContextMenu:s,programmaticCopy:o,programmaticCut:r,programmaticPaste:a}}(e)}function xm(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),mg),split:()=>o(e=>n.splitSelectedTable(e),hg),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),bg),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),bg),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),yg),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),vg),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),vg),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),xg)}}function wm(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=Wp({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:ct(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()||(Ia(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=op(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=op(o,"fontSize",Jn(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=op(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=op(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=op(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=np(o,"bold")),t.italic!==Boolean(n.italic)&&(o=np(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=op(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=op(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=np(o,"underline")),t.strike!==Boolean(n.strike)&&(o=np(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=np(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=np(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=np(o,"subscript")),t.superscript&&t.subscript&&(o=np(o,"subscript")),t.strike&&t.doubleStrike&&(o=np(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=np(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=np(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=np(o,"hidden"));const s=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(s??null)&&(o=op(o,"characterScale",t.characterScale));const l=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(l??null)&&(o=op(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=op(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=op(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=op(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=op(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=op(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=op(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=np(o,"contextualAlternates")),o},{mergeKey:pg})),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;if(e.clearPreferredColumn(),e.resetTransactionGrouping(),n.tabsOnly)return e.applyTransactionalState(e=>(t.tabChanges??[]).reduce($n,e)),void e.focusInput();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=ie(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=ie(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=ie(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=ie(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=ie(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=ie(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=ie(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=ie(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=ie(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=ie(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=ie(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=ie(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=ie(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=ie(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=ie(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=ie(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=ie(r,"widowControl",t.widowControl)),t.tabChanges?.length?r=t.tabChanges.reduce($n,r):JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=ie(r,"tabs",t.tabs.length>0?t.tabs:null));const s="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,l={borderTop:n.borderSideTop?s:null,borderRight:n.borderSideRight?s:null,borderBottom:n.borderSideBottom?s:null,borderLeft:n.borderSideLeft?s: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(l[t])&&(r=ie(r,t,c[t]));return r},{mergeKey:ug}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=xr(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:pf(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}),s=i.openParagraphDialog,l=ym({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=l.openTablePropertiesDialog,d=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},u=vm({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:s,table:xm({state:e.state,tableOps:e.tableOps,isInsideTable:l.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:l.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function Sm(e){const t=mn(()=>{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=ma(e.state).find(e=>e.id===t.paragraphId),r=n?$r(n,t):0,a=V(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=Xe(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const s=e.caretViewport?.()??null;if(s)return r=s.left,a=s.top,i=Math.max(12,Math.min(36,s.height)),{viewportLeft:r,viewportTop:a,height:i};const l=e.pointerPos?.()??null;return l?(r=l.x,a=l.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return Qn(dt,{get when(){return t()},children:e=>Qn(It,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var Im=/*#__PURE__*/kn("<div class=oasis-editor-table-resize-guide>"),Cm=/*#__PURE__*/kn("<div class=oasis-editor-table-resize-outline>"),Tm=/*#__PURE__*/kn("<img class=oasis-editor-image-ghost>"),km=/*#__PURE__*/kn("<div class=oasis-editor-table-ghost>");function Pm(e){return[Qn(dt,{get when(){return e.tableResize.resizing()},children:e=>{return t=Im(),po(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=ao(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),Qn(dt,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Cm(),po(o=>{var r=`${e().left}px`,a=`${e().top}px`,i=`${e().width}px`,s=`${e().height}px`;return r!==o.e&&n(t,"left",o.e=r),a!==o.t&&n(t,"top",o.t=a),i!==o.a&&n(t,"width",o.a=i),s!==o.o&&n(t,"height",o.o=s),o},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),Qn(dt,{get when(){return Ke(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return o=Tm(),po(r=>{var a=t().src,i=`${t().width}px`,s=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",c=e.imageOps.mousePos().y-t().offsetY+"px";return a!==r.e&&he(o,"src",r.e=a),i!==r.t&&n(o,"width",r.t=i),s!==r.a&&n(o,"height",r.a=s),l!==r.o&&n(o,"left",r.o=l),c!==r.i&&n(o,"top",r.i=c),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o;var o}}),Qn(dt,{get when(){return Ke(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return o=km(),po(r=>{var a=`${t().width}px`,i=`${t().height}px`,s=e.tableDrag.mousePos().x-t().offsetX+"px",l=e.tableDrag.mousePos().y-t().offsetY+"px";return a!==r.e&&n(o,"width",r.e=a),i!==r.t&&n(o,"height",r.t=i),s!==r.a&&n(o,"left",r.a=s),l!==r.o&&n(o,"top",r.o=l),r},{e:void 0,t:void 0,a:void 0,o:void 0}),o;var o}}),Qn(dt,{get when(){return Ke(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>Qn(Sm,{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})}),Qn(dt,{get when(){return Ke(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>Qn(Sm,{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})}),Qn(dt,{get when(){return Ke(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>Qn(Sm,{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 Rm(e){return[Qn(to,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),Qn(to,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Bm(e){const t=We(),[n,o]=Pt(e.initialValue);let r;wt(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return Qn(ae,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return Qn(Rm,{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 Qn(P,{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 Mm(e){const t=We();return Qn(Bm,{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 Om(e){const t=We();return Qn(Bm,{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 Am(e){const t=We();return Qn(Bm,{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 Fm=/*#__PURE__*/kn("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Dm=/*#__PURE__*/kn("<div class=oasis-editor-comment-composer>");function Em(e){const t=We(),[n,o]=Pt(""),[r,a]=Pt("");let i;const s=e.composer.draft,l=()=>("edit"===s()?.mode||n().trim().length>0)&&r().trim().length>0,c=()=>{l()&&e.composer.submit(n(),r())};return wt(()=>{s()&&(o("edit"===s()?.mode?s()?.commentAuthor??"":e.composer.authorName()),a("edit"===s()?.mode?s()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),Qn(ae,{get isOpen(){return null!==s()},get title(){return t("edit"===s()?.mode?"toolbar.editComment":"reply"===s()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[Qn(to,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),Qn(to,{variant:"primary",get disabled(){return!l()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var l=Dm();return Ye(l,Qn(dt,{get when(){return"reply"===s()?.mode},get children(){var e=Fm();return Ye(e,Qn(io,{as:"strong",get children(){return[Ke(()=>t("comment.replyTo"))," ",Ke(()=>s()?.parentAuthor)]}}),null),Ye(e,Qn(io,{as:"p",get children(){return s()?.parentText}}),null),e}}),null),Ye(l,Qn(P,{get label(){return t("comment.author")},get value(){return n()},onChange:o,maxLength:150,required:!0,get disabled(){return"edit"===s()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),Ye(l,Qn(Fe,{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),l}})}var Lm=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],Nm=[33,50,66,75,90,100,105,110,115,120,150,200];function zm(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function $m(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function Hm(e){return null==e||""===e?"":String(e)}function Wm(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Um(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function jm(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Vm(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 Km(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 _m(e,t){const n=[],o=jm(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Xm(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 Gm(e){return{characterScale:Hm(e.characterScale),spacingMode:Wm(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Um(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:Hm(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:Hm(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function qm(e){const t=We(),[n,o]=Pt("font"),[r,a]=Pt(Xm(e.initial)),[i,s]=Pt(Gm(e.initial));wt(()=>{e.isOpen&&(o("font"),a(Xm(e.initial)),s(Gm(e.initial)))});const l=mn(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=mn(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=mn(()=>{const t=new Set(Lm);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=mn(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=mn(()=>{const e=i();return e.characterScale.trim()&&null===zm(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===$m(e.spacingAmount)||"normal"!==e.positionMode&&null===$m(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===$m(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===jm(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=mn(()=>function(e,t){const n=Number(e.fontSize),o=zm(t.characterScale)??100,r="normal"===t.spacingMode?null:$m(t.spacingAmount),a="normal"===t.positionMode?null:$m(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,s=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,l=[];return e.underline&&"none"!==e.underlineStyle&&l.push("underline"),e.strike&&l.push("line-through"),e.doubleStrike&&l.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":l.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":s??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":Vm(t.ligatures),"font-variant-numeric":Km(t.numberSpacing,t.numberForm),"font-feature-settings":_m(t.stylisticSet,t.contextualAlternates)}}(r(),i()));return{activeTab:n,setActiveTab:e=>o(e),fontTabValues:r,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:s,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{s(n=>({...n,[e]:t}))},selectedFontStyle:l,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()?zm(t.characterScale):null,s="normal"===t.spacingMode?null:$m(t.spacingAmount),l="normal"===t.positionMode?null:$m(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?$m(t.kerningThreshold):null,d=jm(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===s?null:"condensed"===t.spacingMode?-s:s,baselineShift:null===l?null:"lowered"===t.positionMode?-l:l,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 Ym=/*#__PURE__*/kn("<div>");function Zm(e){const t=We();return n=Ym(),Ye(n,()=>t("dialog.font.previewText")),po(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&Un(n,t.e=o),r!==t.t&&he(n,"data-testid",t.t=r),t.a=ao(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Jm=/*#__PURE__*/kn('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Qm(e){const t=We(),{ctrl:n}=e;return o=Jm(),Ye(o,Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:12,get children(){return Qn(P,{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"})}}),Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{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}))]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(Re,{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)}))]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return[Qn(P,{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"}),Qn(c,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{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),Ye(o,Qn(de,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[Qn(de,{size:{xs:12,md:4},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(To,{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"})}}),Qn(de,{size:{xs:12,md:2},get children(){return Qn(To,{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"})}}),Qn(de,{size:{xs:12,md:2},get children(){return Qn(To,{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),Ye(o,Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{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")},...Tt.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(To,{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),Ye(o,Qn(S,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return Qn(en,{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=>Qn(lt,{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),Ye(o,Qn(S,{get label(){return t("dialog.font.preview")},get children(){return Qn(Zm,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var eh=/*#__PURE__*/kn("<div class=oasis-editor-font-dialog-kerning-line>"),th=/*#__PURE__*/kn('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function nh(e){const t=We(),{ctrl:n}=e;return o=th(),Ye(o,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:4},get children(){return Qn(Re,{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 Nm.map(e=>({value:String(e),label:`${e}%`}))}})}}),Qn(de,{size:{xs:12,md:8},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(P,{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"})}})]}})}}),Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(P,{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"})}}),Qn(de,{size:12,get children(){var e=eh();return Ye(e,Qn(b,{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),Ye(e,Qn(P,{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),Ye(e,Qn(c,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),Ye(o,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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)}))]}})}})]}}),Qn(b,{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),Ye(o,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return Qn(Zm,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),Ye(o,Qn(c,{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 oh(e){const t=We(),n=qm(e);return Qn(ae,{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 Qn(Rm,{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 Qn(ne,{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:Qn(Qm,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:Qn(nh,{ctrl:n})}]}})}})}var rh=/*#__PURE__*/kn("<div class=oasis-editor-word-tabs-fields><div><div class=oasis-editor-word-tabs-list role=group>"),ah=/*#__PURE__*/kn("<div class=oasis-editor-word-tabs-fields>"),ih=/*#__PURE__*/kn("<div class=oasis-editor-word-tabs-actions>"),sh=(e,t)=>Math.abs(e-t)<$t,lh=e=>null!==e&&Number.isFinite(e)&&Math.abs(e)<=1584;function ch(e){const t=We(),[n,o]=Pt([]),[r,a]=Pt([]),[i,s]=Pt(null),[l,d]=Pt("left"),[u,p]=Pt("none"),[g,f]=Pt(36),[m,h]=Pt(36),b=e=>{s(e.position),"clear"!==e.type&&d(e.type),p(e.leader??"none")};wt(()=>{if(!e.isOpen)return;const t=e.initial.filter(e=>"clear"!==e.type).map(e=>({...e})).sort((e,t)=>e.position-t.position);o(t),a([]);const n=e.initialDefault??36;f(n),h(n),s(null),d("left"),p("none");const r=t.find(t=>void 0!==e.selectedPosition&&sh(t.position,e.selectedPosition));r&&b(r)});const y=()=>n().find(e=>null!==i()&&sh(e.position,i())),v=()=>{const e=g();return null!==e&&Number.isFinite(e)&&e>=1&&e<=1584},x=()=>lh(i())&&(Boolean(y())||n().length<64),w=()=>{const e=i();if(!lh(e)||!x())return;const t={position:e,type:l(),..."bar"!==l()&&"none"!==u()?{leader:u()}:{}};o(n=>[...n.filter(t=>!sh(t.position,e)),t].sort((e,t)=>e.position-t.position)),a(e=>[...e,{set:[t]}])},S=()=>{const e=i();lh(e)&&y()&&(o(t=>t.filter(t=>!sh(t.position,e))),a(t=>[...t,{clear:[e]}]),s(null))},I=()=>{o([]),s(null),a(e=>[...e,{clearAll:!0}])},C=()=>{if(!v())return;const t=[...r()];g()!==m()&&t.push({default:g()}),e.onApply(n().map(e=>({...e})),t),e.onClose()};return Qn(ae,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},testId:"editor-tab-stops-dialog",class:"oasis-editor-word-tabs-dialog",initialFocusTestId:"editor-tab-stops-position",get footer(){return[Qn(to,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),Qn(to,{variant:"primary",get disabled(){return!v()},onClick:C,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}})]},get children(){return[(r=rh(),a=r.firstChild,m=a.firstChild,Ye(a,Qn(Mo,{get label(){return t("paragraph.tabsPosition")},step:"0.05",min:-Bt,max:Bt,get value(){return i()??""},onChange:s,"data-testid":"editor-tab-stops-position",get error(){return Ke(()=>!(null===i()||lh(i())))()?t("paragraph.tabsInvalidPosition"):void 0}}),m),Ye(m,Qn(en,{get each(){return n()},get fallback(){return Qn(c,{as:"p",get children(){return t("paragraph.tabsEmpty")}})},children:e=>Qn(to,{variant:"ghost",class:"oasis-editor-word-tabs-option",get"aria-pressed"(){return Ke(()=>null!==i())()&&sh(i(),e.position)},onClick:()=>b(e),"data-testid":"editor-tab-stops-option",get children(){return[Ke(()=>Number(e.position.toFixed(2)))," pt"]}})})),Ye(r,Qn(Mo,{get label(){return t("paragraph.tabsDefaultInterval")},step:"0.05",min:"1",max:Bt,get value(){return g()??""},onChange:f,"data-testid":"editor-tab-stops-default",get error(){return Ke(()=>!v())()?t("paragraph.tabsInvalidInterval"):void 0}}),null),po(()=>he(m,"aria-label",t("paragraph.tabsDefined"))),r),(o=ah(),Ye(o,Qn(vt,{get label(){return t("paragraph.tabsAlignment")},get value(){return l()},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")}]},onChange:e=>d(e)}),null),Ye(o,Qn(vt,{get label(){return t("paragraph.tabsLeader")},get value(){return Ke(()=>"bar"===l())()?"none":u()},get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:"2 ............"},{value:"hyphen",label:"3 ----------"},{value:"underscore",label:"4 ________"},{value:"heavy",label:"5 ━━━━━━"},{value:"middleDot",label:"6 ············"}]},get disabled(){return"bar"===l()},onChange:e=>p(e)}),null),o),(e=ih(),Ye(e,Qn(to,{get disabled(){return!x()},onClick:w,"data-testid":"editor-tab-stops-set",get children(){return t("paragraph.tabsSet")}}),null),Ye(e,Qn(to,{get disabled(){return!y()},onClick:S,"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsClear")}}),null),Ye(e,Qn(to,{onClick:I,"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}}),null),e),Qn(c,{as:"p",get children(){return t("paragraph.tabsDraftHelp")}})];var e,o,r,a,m}})}var dh=96/72;function uh(e){const[t,n]=Pt(""),[o,r]=Pt(""),[a,i]=Pt(null),[s,l]=Pt(null),[c,d]=Pt("none"),[u,p]=Pt(null),[g,f]=Pt(!1),[m,h]=Pt(null),[b,y]=Pt(null),[v,x]=Pt("multiple"),[w,S]=Pt(null),[I,C]=Pt(!1),[T,k]=Pt(""),[P,R]=Pt("none"),[B,M]=Pt(null),[O,A]=Pt(""),[F,D]=Pt(!1),[E,L]=Pt(!1),[N,z]=Pt(!1),[$,H]=Pt(!1),[W,U]=Pt(!1),[j,V]=Pt(!1),[K,_]=Pt(!1),[X,G]=Pt(!0),[q,Y]=Pt([]),[Z,J]=Pt([]),[Q,ee]=Pt(36);wt(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(oo(e.initial.indentLeft??"")),l(oo(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(oo(e.initial.spacingBefore??"")),y(oo(e.initial.spacingAfter??"")),C(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:s}=(t=e.initial.lineRule??"",o=oo(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/dh):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(s);const c=e.initial.borderStyle;R("solid"===c||"dashed"===c||"dotted"===c?c:"none"),M(oo(e.initial.borderWidth??"")),A(e.initial.borderColor??""),D(e.initial.borderSideTop??!1),L(e.initial.borderSideRight??!1),z(e.initial.borderSideBottom??!1),H(e.initial.borderSideLeft??!1),U(e.initial.pageBreakBefore??!1),V(e.initial.keepWithNext??!1),_(e.initial.keepLinesTogether??!1),G(e.initial.widowControl??!0),Y(e.initial.tabs??[]),J([]),ee(e.initial.defaultTabStop??36);const u=oo(e.initial.indentFirstLine??""),g=oo(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 te=()=>{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()*dh:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*dh:null,lineRule:"exact"}}},ne=mn(()=>{const e=a(),n=s(),o="firstLine"===c()?u():null,r="hanging"===c()?u():null,i=null!==o?o:null!==r?-r:null,l="none"!==P()?`${B()??.5}pt ${P()} ${O().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=te(),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":l&&F()?l:void 0,"border-right":l&&E()?l:void 0,"border-bottom":l&&N()?l:void 0,"border-left":l&&$()?l:void 0}}),oe=()=>{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:O().trim()||"#000000"};return{top:F()?n:null,right:E()?n:null,bottom:N()?n:null,left:$()?n:null}},re=()=>{const e=u(),{lineHeight:n,lineRule:r}=te(),i=o();return{align:t()||null,indentLeft:a(),indentRight:s(),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:oe(),pageBreakBefore:W(),keepWithNext:j(),keepLinesTogether:K(),widowControl:X(),tabs:q(),...Z().length?{tabChanges:Z()}:{}}};return{align:t,setAlign:n,outlineLevel:o,setOutlineLevel:r,indentLeft:a,setIndentLeft:i,indentRight:s,setIndentRight:l,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:O,setBorderColor:A,sideTop:F,setSideTop:D,sideRight:E,setSideRight:L,sideBottom:N,setSideBottom:z,sideLeft:$,setSideLeft:H,pageBreakBefore:W,setPageBreakBefore:U,keepWithNext:j,setKeepWithNext:V,keepLinesTogether:K,setKeepLinesTogether:_,widowControl:X,setWidowControl:G,tabs:q,setTabs:Y,defaultTabStop:Q,setDefaultTabStop:ee,setTabChanges:J,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:ne,handleApply:()=>{e.onApply(re(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(re()),e.onClose()}}}var ph=/*#__PURE__*/kn("<div class=oasis-editor-paragraph-dialog-panel>"),gh=/*#__PURE__*/kn("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),fh=/*#__PURE__*/kn("<div>"),mh=/*#__PURE__*/kn("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function hh(e){const t=We(),[n,o]=Pt(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:s,indentLeft:l,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:g,specialBy:f,setSpecialBy:m,mirrorIndents:h,setMirrorIndents:y,spacingBefore:v,setSpacingBefore:x,spacingAfter:w,setSpacingAfter:I,lineMode:C,setLineMode:T,lineAt:k,setLineAt:P,contextualSpacing:R,setContextualSpacing:B,shading:M,setShading:O,borderStyle:A,setBorderStyle:F,borderWidth:D,setBorderWidth:E,borderColor:L,setBorderColor:N,sideTop:z,setSideTop:$,sideRight:H,setSideRight:W,sideBottom:U,setSideBottom:j,sideLeft:V,setSideLeft:K,pageBreakBefore:_,setPageBreakBefore:X,keepWithNext:G,setKeepWithNext:q,keepLinesTogether:Y,setKeepLinesTogether:Z,widowControl:J,setWidowControl:Q,tabs:ee,setTabs:te,defaultTabStop:oe,setDefaultTabStop:re,setTabChanges:ie,atEnabled:se,previewStyle:le,handleApply:ce,handleSetDefault:ue}=uh(e),pe=Qn(Re,{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")}]}}),ge=Qn(Re,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:s,"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])}))]}}),fe=(me=ph(),Ye(me,Qn(xo,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},children:pe}),Qn(de,{size:{xs:12,md:6},children:ge})]}})}}),null),Ye(me,Qn(xo,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},get children(){return Qn(Mo,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return l()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Mo,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Mo,{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"})}}),Qn(de,{size:12,get children(){return Qn(b,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:y,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),Ye(me,Qn(xo,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:4},get children(){return Qn(Mo,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return v()??""},onChange:x,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(Mo,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return w()??""},onChange:I,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),Qn(de,{size:{xs:12,md:4}}),Qn(de,{size:{xs:12,md:8},get children(){return Qn(Re,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return C()},onChange:e=>{T(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")}]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(Mo,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===C()?"0.05":"1"},get disabled(){return!se()},get value(){return k()??""},onChange:P,"data-testid":"editor-paragraph-dialog-line-at"})}}),Qn(de,{size:12,get children(){return Qn(b,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return R()},onChange:B,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),Ye(me,Qn(xo,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:3},get children(){return Qn(Re,{get label(){return t("paragraph.borderStyleLabel")},get value(){return A()},onChange:e=>{const t=e;F(t),"none"===t?($(!1),W(!1),j(!1),K(!1)):z()||H()||U()||V()||($(!0),W(!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")}]}})}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(Mo,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===A()},get value(){return D()??""},onChange:E,"data-testid":"editor-paragraph-dialog-border-width"})}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(To,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===A()},get value(){return L()||"#000000"},onChange:N,"data-testid":"editor-paragraph-dialog-border-color"})}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(To,{get label(){return t("paragraph.shadingLabel")},get value(){return M()||"#ffffff"},onChange:O,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),Qn(S,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[Qn(b,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===A()},get checked(){return z()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),Qn(b,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===A()},get checked(){return H()},onChange:W,"data-testid":"editor-paragraph-dialog-border-side-right"}),Qn(b,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===A()},get checked(){return U()},onChange:j,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),Qn(b,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===A()},get checked(){return V()},onChange:K,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),me);var me;const he=(be=ph(),Ye(be,Qn(xo,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return Qn(gn,{direction:"column",spacing:1,get children(){return[Qn(b,{get label(){return t("paragraph.widowControlLabel")},get checked(){return J()},onChange:Q,"data-testid":"editor-paragraph-dialog-widow-control"}),Qn(b,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return G()},onChange:q,"data-testid":"editor-paragraph-dialog-keep-with-next"}),Qn(b,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Y()},onChange:Z,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),Qn(b,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return _()},onChange:X,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),be);var be,ye;return ye=fh(),Ye(ye,Qn(ae,{get isOpen(){return Ke(()=>!(!e.isOpen||n()))()&&!e.initial.tabsOnly},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",testId:"editor-paragraph-dialog",get footer(){return n=mh(),r=n.firstChild,a=r.nextSibling,Ye(r,Qn(to,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),Ye(r,Qn(to,{variant:"secondary",onClick:ue,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),Ye(a,Qn(to,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),Ye(a,Qn(to,{variant:"primary",onClick:ce,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[Qn(ne,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:fe,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:he,testId:"editor-paragraph-dialog-tab-breaks"}]}}),Qn(S,{get label(){return t("paragraph.preview")},get children(){var e=gh();return Ye(e,()=>t("paragraph.previewText")),po(t=>ao(e,le(),t)),e}})]}}),null),Ye(ye,Qn(ch,{get isOpen(){return Ke(()=>!!e.isOpen)()&&(n()||!!e.initial.tabsOnly)},get initial(){return ee()},get initialDefault(){return oe()},get selectedPosition(){return e.initial.selectedTabPosition},onClose:()=>{o(!1),e.initial.tabsOnly&&e.onClose()},onApply:(t,n)=>{te(t),ie(e=>[...e,...n]);for(const e of n)"number"==typeof e.default&&re(e.default);e.initial.tabsOnly&&ce()}}),null),ye}function bh(e,t){const n=oo(e);return null===n?null:"percent"===t?`${n}%`:n}function yh(e,t,n){if("none"===e)return null;const o=oo(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function vh(e){const[t,n]=Rt({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:""});wt(()=>{var t;e.isOpen&&n(zt({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=yh(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:bh(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:bh(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:oo(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:oo(e.floatingY)??0},distanceTop:oo(e.floatingDistanceTop)??0,distanceRight:oo(e.floatingDistanceRight)??0,distanceBottom:oo(e.floatingDistanceBottom)??0,distanceLeft:oo(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:bh(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:bh(e.columnWidth,"points"),cellWidth:bh(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:oo(e.marginTop),right:oo(e.marginRight),bottom:oo(e.marginBottom),left:oo(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 xh(e,t,n,o,r=!1,a=!1){return Qn(P,{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 wh=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-panel>");function Sh(e){const t=We(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=wh(),Ye(r,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},get children(){return xh(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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),Ye(r,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[Qn(vt,{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=>Qn(Eo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),Qn(de,{container:!0,spacing:1.5,get children(){return Qn(de,{size:{xs:12,md:6},get children(){return xh(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),Ye(r,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[Qn(b,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),Qn(b,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),Qn(dt,{get when(){return"around"===n().tableWrapping},get children(){return[Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(Re,{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}))]}})}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(Re,{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}))]}})}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),Qn(b,{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 Ih=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-panel>");function Ch(e){const t=We(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=Ih(),Ye(r,Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:6},get children(){return xh(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),Qn(de,{size:{xs:12,md:6},get children(){return Qn(Re,{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),Ye(r,Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[Qn(b,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),Qn(b,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),Qn(b,{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 Th=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-panel>");function kh(e){const t=We(),n=e.ctrl.set;return o=Th(),Ye(o,Qn(de,{container:!0,spacing:1.5,get children(){return Qn(de,{size:{xs:12,md:6},get children(){return xh(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var Ph=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),Rh=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-panel>");function Bh(e){const t=We(),n=()=>e.ctrl.form,o=e.ctrl.set,r=mn(()=>{const e=yh(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=Rh(),Ye(i,Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:4},get children(){return xh(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:4},get children(){return Qn(Re,{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),Ye(i,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[Qn(b,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),Qn(b,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),Qn(b,{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),Ye(i,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:3},get children(){return xh(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),Ye(i,Qn(xo,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[Qn(de,{container:!0,spacing:1.5,get children(){return[Qn(de,{size:{xs:12,md:3},get children(){return Qn(Re,{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")}]}})}}),Qn(de,{size:{xs:12,md:3},get children(){return xh(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(To,{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"})}}),Qn(de,{size:{xs:12,md:3},get children(){return Qn(To,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),Qn(gn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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"}),Qn(b,{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=Ph(),po(t=>ao(e,r(),t)),e)];var e}}),null),i;var i}var Mh=/*#__PURE__*/kn("<div class=oasis-editor-table-properties-panel>");function Oh(e){const t=We(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=Mh(),Ye(r,Qn(P,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),Ye(r,Qn(Fe,{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 Ah(e){const t=We(),n=vh(e);return Qn(ae,{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 Qn(Rm,{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 Qn(ne,{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:Qn(Sh,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:Qn(Ch,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:Qn(kh,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:Qn(Bh,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:Qn(Oh,{ctrl:n})}]}})}})}var Fh=/*#__PURE__*/kn("<p data-testid=editor-new-document-message>");function Dh(e){const t=We();return Qn(ae,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return Qn(Rm,{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=Fh();return Ye(e,()=>t("dialog.newDocument.message")),e}})}function Eh(e){const t=We(),n=()=>"accept"===e.action;return Qn(ae,{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 Qn(Rm,{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 Qn(io,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Lh=/*#__PURE__*/kn("<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>"),Nh=/*#__PURE__*/kn("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),zh=/*#__PURE__*/kn("<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>"),$h=/*#__PURE__*/kn("<option>"),Hh=/*#__PURE__*/kn("<button type=button class=oasis-editor-symbol-dialog-tile>"),Wh=/*#__PURE__*/kn("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),Uh=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function jh(e){const t=We(),[o,r]=Pt("common"),[a,i]=Pt(kt[0]),[s,l]=Pt(Uh[0]),[c,d]=Pt(kt[0].codePoint),u=mn(()=>(e.isOpen,fn())),p=mn(()=>"all"===o()?Lt.flatMap(e=>e.entries):Lt.find(e=>e.id===o())?.entries??kt),g=e=>{i(e),d(e.codePoint)},f=()=>{const t=a().character;t&&(uo(t),e.onInsert(t,s()),e.onClose())};return Qn(ae,{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[Qn(to,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),Qn(to,{variant:"primary",onClick:f,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(S=Lh(),I=S.firstChild,C=I.firstChild,T=C.nextSibling,k=I.nextSibling.firstChild,P=k.nextSibling,R=P.firstChild,Ye(C,()=>t("dialog.symbol.font")),T.addEventListener("change",e=>{l(e.currentTarget.value)}),Ye(T,Qn(en,{each:Uh,children:e=>{return(t=$h()).value=e,Ye(t,e),t;var t}})),Ye(k,()=>t("dialog.symbol.subset")),P.addEventListener("change",e=>{r(e.currentTarget.value)}),Ye(R,()=>t("symbols.category.all")),Ye(P,Qn(en,{each:Lt,children:e=>{return n=$h(),Ye(n,()=>t(e.labelKey)),po(()=>n.value=e.id),n;var n}}),null),po(()=>T.value=s()),po(()=>P.value=o()),S),(e=zh(),m=e.firstChild,h=m.nextSibling.firstChild,b=h.nextSibling,y=b.nextSibling,v=y.firstChild,x=v.nextSibling,w=y.nextSibling,Ye(m,Qn(dt,{get when(){return u().length>0},get children(){var e=Nh(),n=e.firstChild,o=n.nextSibling;return Ye(n,()=>t("dialog.symbol.recent")),Ye(o,Qn(en,{get each(){return u()},children:e=>{return(t=Hh()).$$click=()=>g(e),Ye(t,()=>e.character),po(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&he(t,"title",n.e=o),r!==n.t&&he(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),Ye(m,Qn(en,{get each(){return p()},children:e=>{return(t=Wh()).$$dblclick=f,t.$$click=()=>g(e),Ye(t,()=>e.character),po(n=>{var o=!(a().character!==e.character),r=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,s=`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),r!==n.t&&he(t,"title",n.t=r),i!==n.a&&he(t,"aria-label",n.a=i),s!==n.o&&he(t,"data-testid",n.o=s),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),Ye(h,()=>t("dialog.symbol.preview")),Ye(b,()=>a().character),Ye(v,()=>t("dialog.symbol.code")),x.$$input=e=>(e=>{d(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||i({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),he(x,"spellcheck",!1),Ye(w,()=>t("dialog.symbol.doubleClickHelp")),po(e=>{var o=t("dialog.symbol.title"),r=s();return o!==e.e&&he(m,"aria-label",e.e=o),r!==e.t&&n(b,"font-family",e.t=r),e},{e:void 0,t:void 0}),po(()=>x.value=c()),e)];var e,m,h,b,y,v,x,w,S,I,C,T,k,P,R}})}U(["input","click","dblclick"]);var Vh=/*#__PURE__*/kn("<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>"),Kh=/*#__PURE__*/kn("<button type=button data-testid=editor-equation-template>"),_h=[["\\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 Xh(e){const t=We(),[n,o]=Pt(""),[r,a]=Pt(we);wt(()=>{if(!e.isOpen)return;const t=e.initial??we;a(t),o(fo(t))});const i=e=>{o(e),a(bn(e))};return Qn(ae,{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[Qn(to,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),Qn(to,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Vh(),o=e.firstChild,a=o.nextSibling,s=a.firstChild,l=s.nextSibling,c=a.nextSibling;return Ye(o,Qn(en,{each:_h,children:([e,t])=>{return(n=Kh()).$$click=()=>i(t),Ye(n,e),n;var n}})),Ye(s,()=>t("dialog.equation.linear")),l.$$input=e=>i(e.currentTarget.value),he(l,"spellcheck",!1),Ye(c,()=>fo(r())||t("dialog.equation.empty")),po(()=>he(o,"aria-label",t("dialog.equation.structures"))),po(()=>l.value=n()),e}})}U(["input","click"]);var Gh=/*#__PURE__*/kn("<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 qh(e){const t=We(),{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 jt(()=>{window.addEventListener("keydown",o,!0)}),qt(()=>{window.removeEventListener("keydown",o,!0)}),Qn(dt,{get when(){return n.isOpen()},get children(){var e=Gh(),o=e.firstChild,a=o.nextSibling,i=a.firstChild,s=i.firstChild,l=i.nextSibling;return e.$$keydown=r,Ye(o,Qn(io,{get children(){return t("find.title")}}),null),Ye(o,Qn(Pn,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),Ye(s,Qn(P,{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),Ye(s,Qn(c,{class:"oasis-editor-fr-counter",get children(){return Ke(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),Ye(i,Qn(gn,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[Qn(Pn,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),Qn(Pn,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),Ye(l,Qn(P,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),Ye(l,Qn(gn,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[Qn(Pn,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),Qn(Pn,{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),Ye(a,Qn(gn,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[Qn(b,{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})}),Qn(b,{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}})}U(["keydown"]);var Yh=/*#__PURE__*/kn("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),Zh=/*#__PURE__*/kn("<i>"),Jh=/*#__PURE__*/kn("<span class=oasis-editor-context-menu-shortcut>"),Qh=/*#__PURE__*/kn("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),eb=/*#__PURE__*/kn("<div class=oasis-editor-context-menu-separator>"),tb=/*#__PURE__*/kn("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function nb(e){let t;At({refs:()=>[t],open:()=>e.isOpen,onDismiss:()=>e.onClose()});const o=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},r=()=>{e.isOpen&&e.onClose()};return jt(()=>{window.addEventListener("contextmenu",o,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r,!0)}),qt(()=>{window.removeEventListener("contextmenu",o,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r,!0)}),wt(()=>{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`}),Qn(dt,{get when(){return e.isOpen},get children(){var o=Yh();o.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?Xn(t,o):t=o,Ye(o,Qn(en,{get each(){return e.items},children:t=>Qn(dt,{get when(){return"separator"!==t.type},get fallback(){return eb()},get children(){var n=Qh(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},Ye(n,Qn(dt,{get when(){return t.icon},get fallback(){return e=tb(),Ye(e,Qn(Gn,{size:16})),e;var e},get children(){var e=Zh();return po(()=>he(e,"data-lucide",t.icon)),e}}),o),Ye(o,()=>t.label),Ye(n,Qn(dt,{get when(){return t.shortcut},get children(){var e=Jh();return Ye(e,()=>t.shortcut),e}}),null),po(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&he(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),po(t=>{var r=`${e.x}px`,a=`${e.y}px`;return r!==t.e&&n(o,"left",t.e=r),a!==t.t&&n(o,"top",t.t=a),t},{e:void 0,t:void 0}),o}})}function ob(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:s,fontDialog:l,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[Qn(Dh,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),Qn(Eh,{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)}}),Qn(jh,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),Qn(Xh,{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)}}),Qn(Mm,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),Qn(Om,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),Qn(Am,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),Qn(Em,{get composer(){return e.commentComposer}}),Qn(qh,{get fr(){return e.findReplace}}),Qn(oh,{get isOpen(){return l().isOpen},get initial(){return l().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...l(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),Qn(hh,{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}}),Qn(Ah,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),Qn(nb,{get isOpen(){return s().isOpen},get x(){return s().x},get y(){return s().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}U(["contextmenu","click"]);var rb=/*#__PURE__*/kn("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function ab(e){let t,n;const o=D(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=je({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[Qn(dt,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return Qn(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}})})()}}),Qn(dt,{get when(){return!e.useComposedShell()},get children(){return Qn(J,{get editor(){return e.runtime.runtimeEditor},get children(){var s=rb(),l=s.firstChild;return Ye(s,Qn(dt,{get when(){return e.chrome.showOutline()},get children(){return Qn(Vn,{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})}}),l),Ye(l,Qn(q,{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}})),s}})}})]}var ib=/*#__PURE__*/kn("<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 sb(e){const t=We(),n=()=>{Ro(),le(),e.onClose()},o=()=>{x(!1),le(),e.onClose()};return Qn(dt,{get when(){return e.isOpen},get children(){var e=ib(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,s=i.nextSibling,l=s.nextSibling;return Ye(r,Qn(L,{height:72,class:"oasis-editor-welcome-mark"}),a),Ye(a,()=>t("welcome.title")),Ye(i,()=>t("welcome.body")),Ye(s,()=>t("welcome.note")),Ye(l,Qn(to,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),Ye(l,Qn(to,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}function lb(e){switch(e){case"dashed":return[ft(5),ft(3)];case"dotted":return[ft(1),ft(3)];default:return}}async function cb(e,t,n,o,r,a,i,s){const l=t.rotation;l&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,ft(o+a/2),ft(r+i/2),l)),function(e,t,n,o,r,a,i){const s=B(n.shape?.preset,ft(o),ft(r),ft(a),ft(i)),l=n.shape?.fill,c=n.shape?.borderColor,d=n.shape?.borderWidthPt??(c?.75:0);e.drawPath(t,{segments:s,fill:l,stroke:c&&d>0?c:void 0,lineWidth:d})}(e,n.pageIndex,t,o,r,a,i),await async function(e,t,n,o,r,a,i,s){if(0===t.blocks.length)return;const l=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+l.left,d=r+l.top,u=Math.max(1,a-l.left-l.right),p=Math.max(1,i-l.top-l.bottom),g=G({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=pi(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,ft(c),ft(d),ft(u),ft(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await s.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,s);break;case"table":await s.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,s);break;default:ra(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,o,r,a,i,s),l&&e.restoreGraphicsState(n.pageIndex)}async function db(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:s,contentTop:l,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=s+(a.get(g.startOffset)?.left??0),b=d+p.top,y=_e({object:Ze(f),pageSettings:i,contentLeft:s,contentTop:l,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await cb(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var ub=/* @__PURE__ */new WeakMap;function pb(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 gb(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=pb(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?pb(e):null,!r)return null}const s=i?a.naturalWidth:t,l=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(l)),data:r.data}}async function fb(e,t,n){const o=hr(t,n.src);if(!o)return null;let r=ub.get(e);r||(r=/* @__PURE__ */new Map,ub.set(e,r));const a=r.get(o);if(a)return a;const i=gb(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 mb(e,t,n,o,r,a,i,s){const l=await fb(e,n,o);if(!l)return;const c=o.intrinsicWidth??o.width,d=o.intrinsicHeight??o.height,u=c/Math.max(1,d),p=i/Math.max(1,s);let g=r,f=a,m=i,h=s;"fit"===o.cropFit&&u>0&&(u>p?(h=i/u,f+=(s-h)/2):(m=s*u,g+=(i-m)/2));const b="fill"!==o.cropFit||o.crop?o.crop:(()=>{if(u>p){const e=p/u,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(u<p){const e=u/p,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),y=o.cropShape?.preset,v=y?function(e,t,n,o,r,a){if(!a)return e;const i=t+o/2,s=n+r/2,l=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(l)-(t-s)*Math.sin(l),y:s+(e-i)*Math.sin(l)+(t-s)*Math.cos(l)});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}})}(B(y,r,a,i,s),r,a,i,s,o.rotation??0):null,x=o.transparency??0,w="fit"===o.cropFit&&Boolean(o.rotation);v&&(e.saveGraphicsState(t),e.clipPath(t,v)),w&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+s/2,o.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:l,x:g,y:f,width:m,height:h,rotation:w?void 0:o.rotation,crop:b}),x>0&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t),v&&e.restoreGraphicsState(t);const S=o.border;if(!S)return;const I=o.rotation;I&&!v&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+s/2,I));const C=ge(S.dash);v?e.drawPath(t,{segments:v,stroke:S.color,lineWidth:S.widthPt??1}):e.drawRect(t,{x:r,y:a,width:i,height:s,stroke:S.color,lineWidth:S.widthPt??1,...C.length>0?{dashArray:C}:{}}),I&&!v&&e.restoreGraphicsState(t)}function hb(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 bb(e,t,n){const o=hb(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],s=r.get(i.offset+1);return{left:a.left,right:s?.left??i.left+.55*n}}function yb(e,t,n,o,r,a,i){const s=bb(e,t,n.fontSize??14.6667);return s?{x:ft(o+s.left),y:ft(r+e.top+a),width:ft(Math.max(0,s.right-s.left)),height:ft(Math.max(2,e.height-i))}:null}function vb(e,t,n,o,r,a,i){const s=i.textFill;if(!s||"gradient"!==s.type||s.stops.length<2)return;const l=bb(n,o,i.fontSize??14.6667);if(!l)return;const c=r+l.left,d=r+l.right,u=a+n.top,p=a+n.top+n.height,g=ee(c,u,d,p,s.angle??0);return e.registerAxialGradient(t,{x0:ft(g.x0),y0:ft(g.y0),x1:ft(g.x1),y1:ft(g.y1),stops:s.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function xb(e,t,n,o,r,a,i){const l=C(i),c=(r,i)=>{e.drawLine(t,{x1:ft(n),y1:ft(r),x2:ft(o),y2:ft(r),stroke:a,lineWidth:ft(l),dashArray:i})};if(Te(i))return c(r-s),void c(r+s);f(i)?function(e,t,n,o,r,a,i){let s=n,l=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*Po;e.drawLine(t,{x1:ft(s),y1:ft(l),x2:ft(c),y2:ft(o),stroke:a,lineWidth:ft(i)}),s=c,l=o}}(e,t,n,o,r,a,l):c(r,Me(i))}function wb(e,t,n,o,r,a,i){const s=new Map(n.slots.map(e=>[e.offset,e]));for(const l of o.chars){if("\t"!==l.char)continue;const o=s.get(l.paragraphOffset),c=s.get(l.paragraphOffset+1);if(!o||!c)continue;const d=n.resolvedTabs?.[l.paragraphOffset]?.leader;if(!d||c.left<=o.left+2)continue;const u="underscore"===d?a+2:a;e.drawLine(t,{x1:ft(r+o.left),y1:ft(u),x2:ft(r+c.left),y2:ft(u),stroke:i,lineWidth:ft("heavy"===d?1.5:1),dashArray:"dot"===d||"middleDot"===d?[1,3]:"hyphen"===d?[5,3]:void 0})}}function Sb(e,t){const n=Ur(Vr(e));if(!n)return e;const o=Math.max(0,Math.min(1,t));return Xr(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function Ib(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:s,gradientShadingName:l,styles:c,baseTextOptions:d}=e,u=ft(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:ft(t)+u*e,y:ft(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*ft(e.radiusPt*Yr),s=Sb(e.color,.4*(e.alpha??.5)),l=[[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 l)o.drawText(r,{...d,x:ft(t)+c,y:ft(a)+u,text:n,color:s})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,s=ft(e.distPt*Yr);o.drawText(r,{...d,x:ft(t)+Math.cos(i)*s,y:ft(a)+Math.sin(i)*s,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:ft(t)+u,y:ft(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,l=Sb(s,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:ft(t),y:ft(a)+ft(e.distPt*Yr)+i,text:n,color:l})}const p=c.textOutline;o.drawText(r,{...d,x:ft(t),y:ft(a),text:n,color:s,...l?{gradientShadingName:l}:p?{renderMode:2,strokeColor:p.color??s,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function Cb(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),s=_e({object:j(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 mb(e.writer,e.pageIndex,e.document,r,ft(s.x),ft(s.y),ft(s.width),ft(s.height))}}}function Tb(e,t,n,o,r,a,i,s){const l=bb(n,o,i.fontSize??14.6667);if(!l)return;const c=a+sn(s,n.top,n.height),d=r+l.left,u=r+l.right,p="underline"===s?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==s)return"doubleStrike"===s?(e.drawLine(t,{x1:ft(d),y1:ft(c-un),x2:ft(u),y2:ft(c-un),stroke:p,lineWidth:ft(1)}),void e.drawLine(t,{x1:ft(d),y1:ft(c+un),x2:ft(u),y2:ft(c+un),stroke:p,lineWidth:ft(1)})):void xb(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:ft(d),y1:ft(c),x2:ft(u),y2:ft(c),stroke:p,lineWidth:ft(1)})}async function kb(e,t,n,o,r,a,i,s,l,c){if(r.opaque){const n=o.slots.find(e=>e.offset===r.startOffset);if(!n)return;const a=i+n.left,l=s+o.top+o.height-r.opaque.height,c=r.opaque.width,d=r.opaque.height;for(const[o,r,i,s]of[[a,l,a+c,l],[a+c,l,a+c,l+d],[a+c,l+d,a,l+d],[a,l+d,a,l],[a,l,a+c,l+d]])e.drawLine(t,{x1:ft(o),y1:ft(r),x2:ft(i),y2:ft(s),stroke:"#64748b",lineWidth:.75});return}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 mb(e,t,a,r.image,ft(i+n.left),ft(s+o.top+o.height-r.image.height),ft(r.image.width),ft(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 cb(e,r.textBox,{document:a,fontRegistry:l,pageIndex:t},i+n.left,s+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=lr(r.styles,n.style?.styleId,a.styles),u=l.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:ft(i+c.left),y:ft(s+o.top+o.height*st),text:Ct(r.math),fontSize:Ln(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=lr(r.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=l.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=Ln(d),g=(d.baselineShift??0)*Yr,f=nr(n.style,a.styles),m=Do(f.textAlignment,d.fontSize??14.6667,o.height),h=s+o.top+o.height*st-g+m,b=hb(o,r),y=b.map(e=>Ht(e.char,d)).join("");if(0===b.length||0===y.length)return void wb(e,t,o,r,i,h,d.color??"#000000");!function(e,t,n,o,r,a,i){if(!i.link)return;const s=bb(n,o,i.fontSize??14.6667);if(!s||s.right<=s.left)return;const l=i.link.startsWith("#");e.addLinkAnnotation(t,{x:ft(r+s.left),y:ft(a+n.top),width:ft(s.right-s.left),height:ft(n.height),...l?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,o,r,i,s,d),function(e,t,n,o,r,a,i){if(!i.shading)return;const s=yb(n,o,i,r,a,2,4);s&&e.drawRect(t,{...s,fill:i.shading})}(e,t,o,r,i,s,d),function(e,t,n,o,r,a,i){if(!i.highlight)return;const s=yb(n,o,i,r,a,2,4);s&&e.drawRect(t,{...s,fill:i.highlight})}(e,t,o,r,i,s,d),function(e,t,n,o,r,a,i){const s=i.textBorder;if(!s||"none"===s.type||s.width<=0)return;const l=yb(n,o,i,r,a,1,2);l&&e.drawRect(t,{...l,stroke:s.color,lineWidth:ft(Math.max(.5,s.width*Yr))})}(e,t,o,r,i,s,d),wb(e,t,o,r,i,h,d.color??"#000000");const v=nr(n.style,a.styles).align??"left",x=So(d,Ln(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 s="justify"===i?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=[])," "!==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 l of s){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>Ht(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;Ib({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of l){const n=Boolean(o.smallCaps&&Mt(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&&Ib(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:vb(e,t,o,r,i,s,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&Tb(e,t,o,r,i,s,d,"underline"),d.strike&&Tb(e,t,o,r,i,s,d,"strike"),d.doubleStrike&&Tb(e,t,o,r,i,s,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,o,r,a,i){const s=i.emphasisMark;if(!s||"none"===s)return;const l=ht[s];if(!l)return;const c=hb(n,o),d="underDot"===s,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],s=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:ft(r+s-.25*u),y:ft(p),text:l,fontSize:ft(u),color:i.color??"#000000"})}}(e,t,o,r,i,s,d)}function Pb(e,t,n,o,r,a,i,s,l){if(0!==o.index)return;const c=Pr(n,l);if(!c)return;const d=o.slots[0];if(!d)return;const u=lr(void 0,n.style?.styleId,r.styles),p=s.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=no(n,r.styles),f=Ln(u),m=c.length*f*.62*Yr,h=En(n,r.styles,d.left,m);e.drawText(t,{x:ft(a+Math.max(0,h||g)),y:ft(i+o.top+o.height*st),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Rb(e,t,n,o,r,a,i){const s=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],l=s.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!l)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=yt(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:ft(p),y:ft(a),width:ft(Math.max(0,g-p)),height:ft(u),fill:n.shading});for(const[h,b]of s){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:ft(n),y1:ft(o),x2:ft(r),y2:ft(i),stroke:h.color,lineWidth:h.width,dashArray:lb(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:ft(p),y1:ft(a),x2:ft(p),y2:ft(f),stroke:m.color,lineWidth:m.width,dashArray:lb(m.type)})}async function Bb(e,t,n,o,r,a,i,s,l,c){for(const d of o){for(const n of d.barTabPositionsPx??[])e.drawLine(t,{x1:ft(a+n),y1:ft(i+d.top),x2:ft(a+n),y2:ft(i+d.top+d.height),stroke:"#000000",lineWidth:ft(1)});Pb(e,t,n,d,r,a,i,s,l);for(const o of d.fragments)await kb(e,t,n,d,o,r,a,i,s,c)}}function Mb(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:ft(o),y1:ft(r),x2:ft(a),y2:ft(i),stroke:n.color,lineWidth:ft(n.width),dashArray:lb(n.type)})}function Ob(e,t,n,o,r){const a=o+n.left,i=r+n.top,s=a+n.width,l=i+n.height;Mb(e,t,n.borders.top,a,i,s,i),Mb(e,t,n.borders.right,s,i,s,l),Mb(e,t,n.borders.bottom,a,l,s,l),Mb(e,t,n.borders.left,a,i,a,l),n.borders.topLeftToBottomRight&&Mb(e,t,n.borders.topLeftToBottomRight,a,i,s,l),n.borders.topRightToBottomLeft&&Mb(e,t,n.borders.topRightToBottomLeft,s,i,a,l)}async function Ab(e,t,n,o,r,a,i,s,l,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?gr(d,n.tableSegment):d;if(0===u.rows.length)return;const p=$({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:ft(r+g.left),y:ft(a+g.top),width:ft(g.width),height:ft(g.height),fill:g.shading});for(const g of p.cells)if(Ob(e,t,g,r,a),g.revision){const n="insert"===g.revision.type?"#059669":"delete"===g.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:ft(r+g.left+1),y:ft(a+g.top+1),width:ft(Math.max(0,g.width-2)),height:ft(Math.max(0,g.height-2)),stroke:n,lineWidth:ft(2)})}for(const g of p.cells)for(const n of g.paragraphs)await Bb(e,t,n.paragraph,n.lines,o,r+n.originX,a+n.originY,s,l,c)}var Fb={drawParagraph:Bb,drawTableBlock:Ab};async function Db(e,t,n,o,r,a,i,s,l,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=nr(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+yt(n).top;Rb(e,t,n,f.layout.lines,r,g,i),c&&(await Cb({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await db({writer:e,document:o,fontRegistry:s,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Fb,layer:"behind"})),await Bb(e,t,f.sourceBlock,f.layout.lines,o,r,m,s,l,Fb),c&&(await Cb({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await db({writer:e,document:o,fontRegistry:s,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Fb,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Z(f.sourceBlock,i),a=tt({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 Ab(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,s,l,Fb);break}await Ab(e,t,f,o,r,p,i,s,l,Fb);break;default:ra(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const s=n[g+1];if("paragraph"===s?.sourceBlock.type&&s.layout&&s.sourceBlock.id!==f.sourceBlock.id){const n=nr(f.sourceBlock.style,o.styles),l=nr(s.sourceBlock.style,o.styles);if(Bo(n,l)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+yt(n).top;let s=0;for(const e of f.layout.lines)s=Math.max(s,e.top+e.height);const l=o+s,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:ft(c),y1:ft(l),x2:ft(d),y2:ft(l),stroke:u.color,lineWidth:u.width,dashArray:lb(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function Eb(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 s=r?.watermark;if("text"===s?.kind&&s.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:s.text,fontSize:s.fontSize??48,color:s.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===s?.kind&&s.src&&i){const r={src:s.src,width:360,height:180},a=await fb(e,i,r);if(a){const i=s.scale??1,l=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-l)/2,y:(o-c)/2,width:l,height:c}),e.restoreGraphicsState(t)}}}var Lb=[{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 Nb(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function zb(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var $b=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Lb)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Nb(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=ce(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(Nb(t,n,o))??this.faces.get(Nb(this.fallbackFamily,n,o))??this.faces.get(Nb(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(ce).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(k)){const e=await w(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 Hn(e.families);for(const n of t){const e=`Remote${zb(n.postscriptName||n.family)}`;this.registerFontFace({key:Nb(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 Ae){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 w(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,s=`${zb(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,l={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:s,pdfResource:{kind:"unicode",resourceName:s,family:n.family,fontData:o}};this.registerFontFace(l),r.push(l)}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}},Hb="%PDF-1.4\n% Oasis PDF\n",Wb=[{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 Ub(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function jb(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Vb(e,t){if(!e)return t;const n=Ur(Vr(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Kb(e,t,n){const[o,r,a]=Vb(e,n);return`${Ub(o)} ${Ub(r)} ${Ub(a)} ${t}`}function _b(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var Xb=/* @__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 Gb(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:Xb.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function qb(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(jb).join("")}function Yb(e,t=[]){const n=new TextEncoder,o=n.encode(["<< /Length "+e.byteLength,...t,">>"].join(" ")+"\nstream\n"),r=n.encode("\nendstream"),a=new Uint8Array(o.length+e.length+r.length);return a.set(o),a.set(e,o.length),a.set(r,o.length+e.length),a}function Zb(e,t=[]){return Yb(ln(e,{level:9}),["/Filter /FlateDecode",...t])}function Jb(e,t){const n=[...new Set(t)].sort((e,t)=>e-t),o=[];let r=-1,a=-2,i=[];const s=()=>{i.length&&o.push(r+" ["+i.join(" ")+"]")};for(const l of n)(l!==a+1||r<0)&&(s(),r=l,i=[]),i.push(Ub(e[l]??0)),a=l;return s(),o.join(" ")}function Qb(e){return jb(e)}function ey(e){return`% OasisText ${qb(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function ty(e){return e&&0!==e.length?`[${e.map(e=>Ub(e)).join(" ")}] 0 d`:null}var ny=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(Kb(e.fill,"rg",[1,1,1])),e.stroke){n.push(Kb(e.stroke,"RG",[0,0,0])),n.push(`${Ub(e.lineWidth??1)} w`);const t=ty(e.dashArray);t&&n.push(t)}n.push([Ub(e.x),Ub(t.height-e.y-e.height),Ub(e.width),Ub(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=ty(e.dashArray),o=["q",Kb(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${Ub(e.lineWidth??1)} w`,`${Ub(e.x1)} ${Ub(t.height-e.y1)} m`,`${Ub(e.x2)} ${Ub(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(Kb(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(Kb(e.stroke,"RG",[0,0,0])),o.push(`${Ub(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${Ub(r.x)} ${Ub(n(r.y))} m`);break;case"line":o.push(`${Ub(r.x)} ${Ub(n(r.y))} l`);break;case"cubic":o.push(`${Ub(r.x1)} ${Ub(n(r.y1))} ${Ub(r.x2)} ${Ub(n(r.y2))} ${Ub(r.x)} ${Ub(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),s=Math.sin(a),l=e-e*i+r*s,c=r-e*s-r*i;o.commands.push(`${Ub(i)} ${Ub(s)} ${Ub(-s)} ${Ub(i)} ${Ub(l)} ${Ub(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${Ub(e)} ${Ub(r.height-t-o)} ${Ub(n)} ${Ub(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(`${Ub(r.x)} ${Ub(n(r.y))} m`);break;case"line":o.push(`${Ub(r.x)} ${Ub(n(r.y))} l`);break;case"cubic":o.push(`${Ub(r.x1)} ${Ub(n(r.y1))} ${Ub(r.x2)} ${Ub(n(r.y2))} ${Ub(r.x)} ${Ub(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):`<${Gb(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${Ub(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Ub(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Ub(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([ey(n.text),"BT",Kb(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Kb(n.strokeColor??n.color,"RG",[0,0,0]),`${Ub(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Ub(n.x)} ${Ub(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([ey(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Ub(n.x)} ${Ub(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,s=r?.right??0,l=r?.bottom??0;if(r&&(a>0||i>0||s>0||l>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:s,bottom:l});if(0===o)return void t.commands.push(["q",[Ub(e.width),"0","0",Ub(e.height),Ub(e.x),Ub(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",[Ub(p),Ub(g),Ub(f),Ub(m),Ub(h),Ub(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,s=a/Math.max(1e-4,1-o.left-o.right),l=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*s,d=-o.bottom*l,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",[Ub(h),Ub(b),Ub(y),Ub(v),Ub(x),Ub(w),"cm"].join(" "),`0 0 ${Ub(a)} ${Ub(i)} re W n`,[Ub(s),"0","0",Ub(l),Ub(c),Ub(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function oy(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function ry(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function ay(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function iy(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 sy(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=ry(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 ly(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:ry(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(),s=e.u16(),l=[];65535!==i&&l.push(i);for(let c=0;c<s;c+=1)l.push(e.u16());return l}(e,t),i=/* @__PURE__ */new Map;for(const s of a){const e=r[s];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 cy(e,t,n){return e.seek(t),ay(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=ay(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 dy(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 uy(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=ay(e,o,t).map(t=>(e.seek(t),ry(e,e.u16())));return{coverage:iy(e,n),sets:r}}function py(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 gy(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function fy(e,t){e.seek(t);const n=e.u16();return ay(e,n,t).map(t=>(e.seek(t),{backtrack:ry(e,e.u16()),input:ry(e,Math.max(0,e.u16()-1)),lookahead:ry(e,e.u16()),records:py(e,e.u16())}))}function my(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 gy(t,n,i.records,o),e}}}return null}function hy(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=iy(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=ry(e,t),r=iy(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=uy(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 s=n.codePoints,l=i.map((e,t)=>({id:e,codePoints:0===t?s:[]}));return e.splice(t,1,...l),i.length}}}(e,t);case 3:return function(e,t){const n=uy(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=ay(e,o,t).map(t=>(e.seek(t),ay(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:ry(e,Math.max(0,o-1))}}))),a=iy(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=ay(e,e.u16(),t),o=ay(e,e.u16(),t),r=ay(e,e.u16(),t),a=py(e,e.u16()),i=n.map(t=>iy(e,t)),s=o.map(t=>iy(e,t)),l=r.map(t=>iy(e,t));return{apply(e,t,n){if(0===s.length)return null;if(t+s.length>e.length)return null;for(let o=0;o<s.length;o+=1)if(s[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<l.length;o+=1){const n=e[t+s.length+o];if(!n||l[o](n.id)<0)return null}return gy(e,t,a,n),s.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=ay(e,o,t),a=iy(e,n),i=r.map(t=>fy(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:my(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(),s=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();s[g]=0===n?0:t+n}const l=iy(e,n),c=sy(e,o),d=sy(e,r),u=sy(e,a),p=s.map(t=>0===t?[]:fy(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(l(o.id)<0)return null;const r=d(o.id),a=p[r];return a?my(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return oy(e,t,hy);default:return null}}var by=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new _t(t),{featureToLookups:o,lookupListOffset:r}=ly(n),a=cy(n,r,hy);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return dy(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 yy(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 vy(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function xy(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=yy(e,e.u16()),n=iy(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=vy(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=yy(e,t);const s=iy(e,o);return{apply(e,t,o){const r=s(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(),s=ay(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=yy(e,r),i=yy(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),l=iy(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=l(e[n]);if(r<0||r>=s.length)return null;const a=s[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(),s=t+e.u16(),l=e.u16(),c=e.u16(),d=vy(r),u=d+vy(a),p=e.tell(),g=new Array(l*c),f=new Array(l*c);for(let t=0;t<l;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=yy(e,r),e.seek(p+o+d),f[t*c+n]=yy(e,a)}const m=iy(e,o),h=sy(e,n),b=sy(e,s);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),s=b(r);if(a>=l||s>=c)return null;const d=a*c+s,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 oy(e,t,xy);default:return null}}var wy=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new _t(t),{featureToLookups:o,lookupListOffset:r}=ly(n),a=cy(n,r,xy);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=dy(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}}}},Sy=/* @__PURE__ */new Set(["kern"]),Iy=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?by.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?wy.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=>!Sy.has(e))??[],r=t?.filter(e=>Sy.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=[],s=[];let l=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}),s.push({xAdvance:o}),l+=o}return{glyphs:i,positions:s,advanceWidth:l}}},Cy=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 Ty(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ky(e,t){return Ty(e).getUint16(t)}function Py(e,t){return Ty(e).getInt16(t)}function Ry(e,t,n){Ty(e).setUint16(t,n,!1)}function By(e,t,n){Ty(e).setUint32(t,n,!1)}function My(e){return e+3&-4}function Oy(e){const t=e.reduce((e,t)=>e+My(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=My(r.byteLength);return n}function Ay(e,t){const n=[],o=Ty(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 Fy(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function Dy(e,t){if(e.byteLength<10||Py(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)throw new Error("Truncated composite glyph");o=ky(e,n),t(ky(e,n+2),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 Ey(e,t,n){const o=/* @__PURE__ */new Map;for(const h of t.values())for(const t of h){if(!Number.isInteger(t)||t<=0||t>1114111||t>=55296&&t<=57343)continue;const r=n.get(e.glyphForCodePoint(t));r&&o.set(t,r)}const r=[...o].sort(([e],[t])=>e-t),a=[];for(const[h,b]of r){const e=a[a.length-1];e&&h===e.end+1&&b===e.gid+h-e.start?e.end=h:a.push({start:h,end:h,gid:b})}const i=new Uint8Array(16+12*a.length);Ry(i,0,12),By(i,4,i.length),By(i,12,a.length),a.forEach((e,t)=>{const n=16+12*t;By(i,n,e.start),By(i,n+4,e.end),By(i,n+8,e.gid)});const s=a.filter(e=>e.start<65535).map(e=>({...e,end:Math.min(e.end,65534)}));s.push({start:65535,end:65535,gid:0});const l=s.length,c=16+8*l,d=c<=65535?new Uint8Array(c):null;if(d){const e=2**Math.floor(Math.log2(l));Ry(d,0,4),Ry(d,2,c),Ry(d,6,2*l),Ry(d,8,2*e),Ry(d,10,Math.log2(e)),Ry(d,12,2*l-2*e),s.forEach((e,t)=>{Ry(d,14+2*t,e.end),Ry(d,16+2*l+2*t,e.start),Ry(d,16+4*l+2*t,e.gid-e.start&65535)})}if(d&&r.every(([e])=>e<65535)){const e=new Uint8Array(12+d.length);return Ry(e,2,1),Ry(e,4,3),Ry(e,6,1),By(e,8,12),e.set(d,12),e}const u=d?2:1,p=4+8*u,g=new Uint8Array(p+(d?.length??0)+i.length);Ry(g,2,u),d&&(Ry(g,4,3),Ry(g,6,1),By(g,8,p),g.set(d,p));const f=d?12:4,m=p+(d?.length??0);return Ry(g,f,3),Ry(g,f+2,10),By(g,f+4,m),g.set(i,m),g}function Ly(e,t,n,o){const r=e.getRawTableData("glyf"),a=e.getRawTableData("loca"),i=e.getRawTableData("head"),s=e.getRawTableData("hhea"),l=e.getRawTableData("maxp");if(!(r&&a&&i&&s&&l))throw new Error("Missing required TrueType tables for subsetting");const c=Ay(a,ky(i,50)),d=[],u=[];let p=0;for(const x of t){d.push(p);const e=Fy(c,x);if(!e||e.end<e.start||e.end>r.length)throw new Error("Invalid glyph range");if(e.end===e.start)continue;const t=r.slice(e.start,e.end);Dy(t,(e,o)=>{const r=n.get(e);if(void 0===r)throw new Error("Missing composite dependency");Ry(t,o,r)}),u.push(t),p+=My(t.length)}d.push(p);const g=function(e){const t=e.every(e=>e%2==0&&e<=131070),n=new Uint8Array(e.length*(t?2:4));return e.forEach((e,o)=>{t?Ry(n,2*o,e/2):By(n,4*o,e)}),{data:n,format:t?0:1}}(d),f=function(e,t,n){const o=e.getRawTableData("hmtx"),r=ky(n,34);if(!o||r<1||r>e.glyphCount)throw new Error("Invalid source hmtx");const a=t.map(t=>e.advanceWidthForGlyph(t));let i=a.length;for(;i>1&&a[i-1]===a[i-2];)i--;const s=new Uint8Array(4*i+2*(t.length-i));return t.forEach((e,t)=>{const n=e<r?4*e+2:4*r+2*(e-r),l=t<i?4*t+2:4*i+2*(t-i);t<i&&Ry(s,4*t,a[t]),Ty(s).setInt16(l,Py(o,n))}),{data:s,longCount:i}}(e,t,s),m=i.slice();By(m,8,0),Ry(m,50,g.format);const h=s.slice();Ry(h,34,f.longCount);const b=l.slice();Ry(b,4,t.length);const y={cmap:Ey(e,o,n),head:m,hhea:h,maxp:b,hmtx:f.data,loca:g.data,glyf:Oy(u)};for(const x of["OS/2","name","cvt ","fpgm","prep","gasp"]){const t=e.getRawTableData(x);t&&(y[x]=t)}const v=e.getRawTableData("post");return v&&v.length>=32&&(y.post=v.slice(0,32),By(y.post,0,196608)),y}var Ny=class{createSubset(e,t){const n=/* @__PURE__ */new Map,o=[];for(const l of t)o.push(l.id),n.has(l.id)||n.set(l.id,l.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=Ay(o,ky(r,50)),i=/* @__PURE__ */new Set([0,...t]),s=Array.from(i);for(;s.length>0;){const t=s.pop(),o=Fy(a,t);if(!o||t>=e.glyphCount||o.end<o.start||o.end>n.byteLength)throw new Error("Invalid subset glyph range");o.end!==o.start&&Dy(n.slice(o.start,o.end),e=>{i.has(e)||(i.add(e),s.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=new Map(r.map((e,t)=>[e,t])),i=Ly(e,r,a,n),s=l(65536,new Map(Object.entries(i).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,c=[],d=[];for(const l of r)c[l]=e.advanceWidthForGlyph(l)/e.unitsPerEm*1e3,d[l]=n.get(l)??[0];return{fontFile:s,widths:c,unicode:d,encodeGlyph:e=>a.get(e)??0}}};var zy=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 Iy(e);return{program:e,layouter:t.hasShaping?t:new Cy(e),subsetter:new Ny}}(function(e){const t=pn.decodeSync(e);return Zt.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?`<${Qb(e.glyphId)}>`:`<${Qb(e.glyphId)}> ${Ub(t)}`}).join(" ")}] TJ`:`<${r.map(e=>Qb(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>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=n.fontFile,r=t(Zb(o,[`/Length1 ${o.byteLength}`])),a=e.font.program.metadata,i=a.familyClass>>8||0;let s=4;a.isFixedPitch&&(s|=1),i>=1&&i<=7&&(s|=2),10===i&&(s|=8),a.macStyleItalic&&(s|=64);const l=`${_b(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${_b(a.postscriptName,e.resource.family)}`,c=a.bbox,d=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${s}`,`/FontBBox [${[c.minX*e.scale,c.minY*e.scale,c.maxX*e.scale,c.maxY*e.scale].map(Ub).join(" ")}]`,`/ItalicAngle ${Ub(a.italicAngle)}`,`/Ascent ${Ub(a.ascent*e.scale)}`,`/Descent ${Ub(a.descent*e.scale)}`,`/CapHeight ${Ub(a.capHeight*e.scale)}`,`/XHeight ${Ub(a.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${r} 0 R`,">>"].join("\n")),u=[...e.usedGlyphs.keys()],p=Math.max(0,...u),g=new Uint8Array(2*(p+1)),f=new DataView(g.buffer);for(const v of u)f.setUint16(2*v,n.encodeGlyph(v));const m=u.every(e=>n.encodeGlyph(e)===e)?"/Identity":t(Zb(g))+" 0 R",h=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [${Jb(n.widths,e.usedGlyphs.keys())}]`,`/CIDToGIDMap ${m}`,">>"].filter(Boolean).join("\n")),b=function(e){const t=[...e].filter(([e,t])=>e>=0&&e<=65535&&t.length>0).sort(([e],[t])=>e-t).map(([e,t])=>"<"+jb(e)+"> <"+qb([...t])+">"),n=[];for(let o=0;o<t.length;o+=100){const e=t.slice(o,o+100);n.push(e.length+" beginbfchar",...e,"endbfchar")}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,"endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(new Map([...e.usedGlyphs].map(([e,t])=>[e,t.codePoints]))),y=t(Zb((new TextEncoder).encode(b)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${h} 0 R]`,`/ToUnicode ${y} 0 R`,">>"].join("\n"))}},$y=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(Yb(e.data,["/Filter /DCTDecode","/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},Hy=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 Wy(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Wy(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>Ub(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:Vb(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(Ub).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Wy(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Ub).join(" ")}]`,`/C1 [${t.map(Ub).join(" ")}]`,"/N 1",">>"].join("\n")}var Uy=new TextEncoder;function jy(e){return"string"==typeof e?(t=e,(new TextEncoder).encode(t).byteLength):e.length;var t}function Vy(e){return Zb(Uy.encode(e))}function Ky(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function _y(e){return`<FEFF${qb(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Xy(e){const t=[];if(e.title&&t.push(`/Title ${_y(e.title)}`),e.author&&t.push(`/Author ${_y(e.author)}`),e.subject&&t.push(`/Subject ${_y(e.subject)}`),e.keywords&&t.push(`/Keywords ${_y(e.keywords)}`),e.producer&&t.push(`/Producer (${Ky(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 Gy(e){return e.children.reduce((e,t)=>e+1+Gy(t),0)}function qy(e,t,n,o,r=[],a=[],i){const s=[],l=e=>{const t=s.length+1;return s.push({id:t,body:e}),t},c=l(""),d=l(""),{resourceXml:u}=t.buildFontObjects(l),p=n.buildImageObjects(l),g=o.buildShadingObjects(l),f=/* @__PURE__ */new Map;for(const B of e)for(const[e,t]of B.graphicsStateOpacities??[])f.has(e)||f.set(e,l(`<< /Type /ExtGState /ca ${Ub(t)} /CA ${Ub(t)} >>`));const m=[];for(const B of e){const e=l(Vy(`${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} >>`:"",s=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 (${Ky(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Ky(e.uri??"")}) >>`;return l(["<< /Type /Annot /Subtype /Link",`/Rect [${Ub(t)} ${Ub(o)} ${Ub(n)} ${Ub(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=s.length>0?`\n/Annots [${s.map(e=>`${e} 0 R`).join(" ")}]`:"",h=l(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${Ub(B.width)} ${Ub(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=l(`<< /Dests ${l(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${Ky(t.name)}) [${n} 0 R /XYZ ${Ub(t.x)} ${Ub(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=l("");const e=t=>t.map(t=>{const n=l("");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,l=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+_y(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",l?`/Next ${l.id} 0 R`:"",`/Dest (${Ky(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 ${Gy(o)}`)),c.push(">>"),s[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;s[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(s[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"),s[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=Xy(i);e&&(w=l(e))}const S=[Hb];let I=jy(Hb);const C=[0],T=e=>{S.push(e),I+=jy(e)};for(const B of s)C[B.id]=I,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const k=I;let P=`xref\n0 ${s.length+1}\n`;P+="0000000000 65535 f \n";for(const B of s)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 ${s.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(k),"%%EOF",""].join("\n")),function(e){const t=e.reduce((e,t)=>e+jy(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Uy.encode(r):r;n.set(e,o),o+=e.length}return n}(S)}var Yy=class{pages=[];streams=[];fonts;images=new $y;shadings=new Hy;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=Wb){this.fonts=new zy(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 ny(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}),qy(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function Zy(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const s=ft(i),l=ft(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:l,y:s});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:l,y:s}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function Jy(e){e=fa(e);const t=new $b,n=Pe(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new Yy(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 a=p(e),i=function(e){return pi(e)}(e),s=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(r(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const r of a.pages){const n=Math.max(1,ft(r.pageSettings.width)),a=Math.max(1,ft(r.pageSettings.height)),c=o.addPage({width:n,height:a});await Eb(o,c,n,a,e.design,e.sections?.[r.sectionIndex??0]?.pageBorder,e);const d=r.pageSettings.margins.left+r.pageSettings.margins.gutter,u=Wr(r.pageSettings);await Db(o,c,r.headerBlocks,e,d,r.headerTop??_r(r.pageSettings),u,t,i,r.pageSettings);const p=r.bodyTop??dr(r.pageSettings);if(r.blocks.some(e=>void 0!==e.columnIndex)){const n=jr(r.pageSettings),a=/* @__PURE__ */new Map;for(const e of r.blocks){const t=e.columnIndex??0,n=a.get(t)??[];n.push(e),a.set(t,n)}for(const[d,u]of a){const a=n[d]??n[0];await Db(o,c,u,e,a.left,p,a.width,t,i,r.pageSettings,Zy(o,c,a.left,s,l))}}else await Db(o,c,r.blocks,e,d,p,u,t,i,r.pageSettings,Zy(o,c,d,s,l));await Db(o,c,r.footerBlocks,e,d,r.footerTop??r.bodyBottom??r.pageSettings.height,u,t,i,r.pageSettings),r.footnoteBlocks&&r.footnoteBlocks.length>0&&void 0!==r.footnoteTop&&(void 0!==r.footnoteSeparatorTop&&o.drawLine(c,{x1:ft(d),y1:ft(r.footnoteSeparatorTop+.5),x2:ft(d+Math.min(180,.35*u)),y2:ft(r.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:ft(1)}),await ev(o,c,r.footnoteBlocks,r.footnoteReferenceIds??[],e,d,r.footnoteTop,u,t,i))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await Eb(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function Qy(e){const t=await Jy(e);return new Blob([t],{type:"application/pdf"})}async function ev(e,t,n,o,r,a,i,s,l,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,Kr(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=lr(void 0,n?.style?.styleId,r.styles),s=l.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:ft(a),y:ft(d+12),text:o,fontSize:Ln(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:s.writerResourceName})}u.add(n)}await Db(e,t,[g],r,a+24,d,Math.max(24,s-24),l,c),d+=Math.max(0,g.estimatedHeight)+2}}function tv(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function nv(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 ov(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 rv(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 av(e){return function(e){const t=Qo(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=nr(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=lr(o.styles,i.style?.styleId,e.styles),s=t.fontFamily??"<null>";n.set(s,(n.get(s)??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=nr(t.style,e.styles),r=t.runs[0],a=lr(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:Ko(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 iv(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 sv(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function lv(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function cv(e){return"page"===e?.positionV?.relativeFrom}function dv(e){return ki(e,e=>"image"===e.kind)}function uv(e,t,n){return xv(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function pv(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function gv(e,t){return xv(e,e=>{const n={...e},o=function(e){if(!e)return;const t=pv(e.left),n=pv(e.top),o=pv(e.right),r=pv(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 fv(e,t){const n=dv(e),o=n&&Ya(n.run);return o?gv(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=pv(a.left),s=pv(a.top),l=pv(a.right),c=pv(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-l);return{crop:{...a,left:i+t/2,right:l+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-s-c);return{crop:{...a,top:s+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function mv(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 hv(e){return xv(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function bv(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function yv(e,t,n=90){const o=dv(e);if(!o||!Ya(o.run))return e;const r="right"===t?-n:n,a=bv(function(e){const t=dv(e);return(t&&Ya(t.run))?.rotation??0}(e)+r);return xv(e,e=>({...e,rotation:a}))}function vv(e,t){const n=function(e){const t=dv(e),n=t&&Ya(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?xv(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function xv(e,t){const n=dv(e);if(!n||!Ya(n.run))return e;const o=ma(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}function wv(e,t){return xv(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function Sv(e,t){const n=dv(e);if(!n)return e;const o=ma(e),{paragraphIndex:r,offset:a,run:i}=n,s=qa(o,t.paragraphId);if(s<0)return e;const l=o[s],c=$r(l,t),u=s===r&&c>a?c-1:c;if(s===r&&u===a)return e;const p=e=>d(e,[...rn(e,0,a),...rn(e,a+1,bi(e))]),g=(e,t)=>xe(e,Math.max(0,Math.min(t,bi(e))),[er("",Zn(e,t),Ya(i))]),f=o.map((e,t)=>t===r&&t===s?g(p(e),u):t===r?p(e):t===s?g(e,u):fr([e])[0]),m=f[s],h=Math.max(0,Math.min(u+1,bi(m)));return Sn(e,f,Y(Dr(m,h)))}function Iv(e,t,n,o=0){const r=Wr(pr(t));if(!n)return r;const a=jn(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function Cv(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await ov(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,s=a.naturalHeight||300,l=e.state(),c=n?.paragraphId??l.selection.focus.paragraphId,d=Iv(e.surfaceRef(),l.document,c,l.activeSectionIndex??0),u=i>d?d/i:1,p=Math.max(24,Math.round(i*u)),g=Math.max(24,Math.round(s*u));e.logger.info(`image insert:decoded natural=${i}x${s} fitted=${p}x${g} maxWidth=${d}`),e.applyTransactionalState(e=>function(e,t){const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(n),i=er("",Zn(o,a),t),s=xe(o,a,[i]),l=ma(n).map((e,t)=>t===r?s:tr(e));return Sn(n,l,Y(Dr(s,a+1)))}(n?Ii(e,{anchor:n,focus:n}):e,{src:r,width:p,height:g,intrinsicWidth:i,intrinsicHeight:s}),{mergeKey:Vp})}}}var Tv={"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 kv(e){return function(e){const[t,n]=Pt(null),o=(e,t)=>{const[n,o]=Tv[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=ot(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 ov(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:In(e.now()-a,2)});let s=null,l=-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!==s;if(!(a||void 0!==r&&(l<0||r-l>=1)||o-c>=40))return;s=t,l=r??l,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",av(d));const u=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(d),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:In(e.now()-u,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(Ir(d));const p=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:In(e.now()-p,2)});const g=mr(d).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),f=Yo(d).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:g,paragraphs:f,durationMs:In(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}),s=Cv({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),l=function(e){const t=e.download??tv,n=e.print??nv;let o=!1;return{handleExportDocx:async()=>{const n=await iu(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await Qy(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await Qy(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>iu(e.document()),exportPdfBlob:()=>Qy(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),c=async t=>{e.isReadOnly()||await i.handleImportFile(t)},d=async(e,t)=>{await s.insertImageFromFile(e,t)},u=async t=>{e.isReadOnly()||t&&(await d(t),e.focusInput())};return{importProgress:t,handleImportFile:c,handleExportDocx:async()=>l.handleExportDocx(),handleExportPdf:async()=>l.handleExportPdf(),handlePrint:async()=>l.handlePrint(),exportDocxBlob:l.exportDocxBlob,exportPdfBlob:l.exportPdfBlob,insertImageFromFile:d,handleInsertImage:u}}(e)}function Pv(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Rv(e){return" "===e||"\t"===e||"\n"===e}function Bv(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 Mv(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=Mv(n.blocks,t);if(e)return e}}return null}function Ov(e,t){const n=Qr(t),o=[],r=e.surfaceRect,a=new Map(ma(t).map((e,t)=>[e.id,t]));let i=null,s=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&&(s={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 l=(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(l&&c&&l.tableId===c.tableId&&(l.rowIndex!==c.rowIndex||l.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of Ta(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Mv(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Mv(n.blocks,t);if(e)return e}return null}(t.document,l.tableId);if(n){const t=Ga(n),a=t.find(e=>e.rowIndex===l.rowIndex&&e.cellIndex===l.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const s=Math.min(a.visualRowIndex,i.visualRowIndex),l=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<=l&&e.visualRowIndex+e.rowSpan-1>=s,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||s))for(const w of e.paragraphs){const e=Bv(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&&Rv(Pv(w,e));)e+=1;for(;a>e&&Rv(Pv(w,a-1));)a-=1;if(e>=a)continue;const s=n.slots.find(t=>t.offset===e),l=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!s||!l)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:s.left-r.left+1,top:d-r.top,width:Math.max(1,l.left-s.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 s of o){const e=Math.abs(t-s.offset);e<a&&(r=s,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?$r(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&&!s};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:s,selectedTableBox:v}}function Av(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)Av(n.blocks,t);else t.push(n.id)}function Fv(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 Dv(e){return e.cells.flatMap(e=>e.blocks)}function Ev(e){return e.rows.flatMap(Dv)}function Lv(e){return{id:e.id,type:e.type,author:e.author,date:e.date}}function Nv(e){return{id:e.id,type:"property",author:e.author,date:e.date}}function zv(e){const t=[];return e.style?.revision&&t.push(Lv(e.style.revision)),e.style?.propertyRevision&&t.push(Nv(e.style.propertyRevision)),t}function $v(e){const t=[];return e.style?.revision&&t.push(Lv(e.style.revision)),e.style?.propertyRevision&&t.push(Nv(e.style.propertyRevision)),e.propertyExceptionsRevision&&t.push(Nv(e.propertyExceptionsRevision)),t}function Hv(e){const t=[];return e.style?.revision&&t.push(Nv(e.style.revision)),e.gridRevision&&t.push({id:e.gridRevision.id,type:"grid",author:e.gridRevision.author,date:e.gridRevision.date}),t}function Wv(e){const t=[],n=/* @__PURE__ */new Set,o=(e,o,r,a,i,s)=>{if(n.has(e.id))return;n.add(e.id);const l=[];Av(s,l),t.push({...e,scope:o,tableId:r,rowIndex:a,cellIndex:i,paragraphIds:l,snippet:Fv(s)})},r=e=>{if(e)for(const t of e)if("paragraph"!==t.type){for(const e of Hv(t))o(e,"table",t.id,void 0,void 0,Ev(t));t.rows.forEach((e,n)=>{for(const r of $v(e))o(r,"row",t.id,n,void 0,Dv(e));e.cells.forEach((e,a)=>{for(const r of zv(e))o(r,"cell",t.id,n,a,e.blocks);r(e.blocks)})})}};for(const a of Ta(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 Uv(e){const t=[],n=/* @__PURE__ */new Set;return Ta(e.document).forEach((e,o)=>{const r=e.propertyRevision;if(!r||n.has(r.id))return;n.add(r.id);const a=[];Av(e.blocks,a);const i=Fv(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 jv={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments",formatting:"showMarkupFormatting"};function Vv(e,t){return e[jv[t]]??!0}function Kv(e,t){return"boolean"==typeof t.allAuthors?qv(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=Yv(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=Yv(n);return qv(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Jv(e)):t.section?function(e,t){const n=jv[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function _v(e,t){return e.markupAuthors?.includes(t)??!0}function Xv(e,t,n){return!("insert"===t&&!Vv(e,"insertions"))&&(!("delete"===t&&!Vv(e,"deletions"))&&(!("property"===t&&!Vv(e,"formatting"))&&_v(e,n)))}function Gv(e){const t=/* @__PURE__ */new Map;for(const n of Wv(e))if(Xv(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 Uv(e))Xv(e,n.type,n.author)&&t.push(...n.paragraphIds);return t}(e))t.has(n)||t.set(n,null);for(const n of Qo(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,s=t.styles?.propertyRevision;let l=!1;!a||"insert"!==a.type&&"delete"!==a.type?s&&(l=Xv(e,"property",s.author)):l=Xv(e,a.type,a.author),l&&(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 qv(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 Yv(e){return[...new Set(e)].sort()}function Zv(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 Jv(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 Zv(r,t)},r=Qo(e.document);for(const l of r)Zv(l,t);for(const l of Ta(e.document)){for(const e of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])o(e);n(l.propertyRevision?.author)}const a=e.document.footnotes?.items??{};for(const l of Object.values(a))o(l.blocks);const i=e.document.endnotes?.items??{};for(const l of Object.values(i))o(l.blocks);const s=e.document.comments?.items??{};for(const l of Object.values(s)){const e=l.author??l.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function Qv(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,s=r.styles?.propertyRevision;let l,c,d;if(!i||"insert"!==i.type&&"delete"!==i.type?s&&(l=s.id,c="property",d=s.author):(l=i.id,c=i.type,d=i.author),void 0!==l&&void 0!==c&&void 0!==d&&Xv(t,c,d)&&a>e){const t=n.at(-1);t&&t.revisionId===l&&t.type===c&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:l,type:c})}}return n}function ex(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=Qv(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),s=t.slots.find(e=>e.offset===a)??t.slots[t.slots.length-1];i&&s&&o.push({revisionId:r.revisionId,type:r.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,s.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 Wv(t)){if(!Xv(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)),s=Math.min(...e.map(e=>e.top)),l=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:s-n.top,width:l-r,height:c-s})}return a}(e,t)),o.push(...function(e,t){const{surfaceRect:n}=e,o=[];for(const r of Uv(t)){if(!Xv(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)),s=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:s-a})}}return o}(e,t)),o}function tx(e,t){const{surfaceRect:n}=e,o=e.paragraphs,r=/* @__PURE__ */new Map;for(const c of o){const e=c.left+c.width,t=r.get(c.pageIndex);(void 0===t||e>t)&&r.set(c.pageIndex,e)}const a=/* @__PURE__ */new Map;for(const c of e.pages??[]){const e=c.left+c.width,t=r.get(c.index)??e-Math.min(96,c.width),o=Math.max(0,e-t),i=Math.min(168,Math.max(84,o-16));a.set(c.index,{left:e-8-i-n.left,width:i})}const i=[];for(const c 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 Qo(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 Wv(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 Uv(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(!Xv(t,c.type,c.author))continue;const e=new Set(c.paragraphIds);let r;for(const t of o)e.has(t.paragraphId)&&(!r||t.top<r.top)&&(r=t);if(!r||!a.has(r.pageIndex))continue;const s=r.lines[0];i.push({descriptor:c,pageIndex:r.pageIndex,top:(s?s.top:r.top)-n.top})}i.sort((e,t)=>e.pageIndex-t.pageIndex||e.top-t.top);const s=/* @__PURE__ */new Map,l=[];for(const c of i){const e=s.get(c.pageIndex)??-1/0,t=Math.max(c.top,e+6);s.set(c.pageIndex,t+58);const n=a.get(c.pageIndex),o=c.descriptor;l.push({revisionId:o.id,type:o.type,variant:"balloon",left:n.left,top:t,width:n.width,height:58,author:o.author,date:o.date,snippet:o.snippet})}return l}var nx={composeMeasuredParagraphLines:e=>on.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>on.resolveRenderedLineHeightPx(e,t)};function ox(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function rx(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 ax(){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&&ox(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&ox(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&rx(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&rx(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 ix(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 sx(e){return function(e){const[t,n]=Pt({}),[o,r]=Pt({}),[a,i]=Pt({left:0,top:0,height:28}),[s,l]=Pt([]),[c,d]=Pt([]),[u,g]=Pt([]),[f,m]=Pt([]),[h,b]=Pt(null),[y,v]=Pt(null),[x,w]=Pt(null),[S,I]=Pt({left:0,top:0,height:28,visible:!1}),[C,T]=Pt(null),k=ax(),P=mn(()=>{zo();const t=void 0===(n=e.state.reviewDisplayMode)||"all"===n?null:"original"===n?"original":"final";var n;return null===t?e.state.document:Ot(e.state.document,t).document}),R=mn(()=>(zo(),k(p(P(),void 0,t(),o(),{measurer:nx})))),B=D();let M=0;const O=(t="selection")=>{const n=e.surfaceRef();if(!n)return l([]),d([]),g([]),m([]),b(null),v(null),w(null),void I(e=>({...e,visible:!1}));const o=B.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:R(),zoomFactor:e.zoomFactor?.()});if(!o)return l([]),d([]),g([]),m([]),b(null),v(null),w(null),void I(e=>({...e,visible:!1}));const r=e.state.reviewDisplayMode??"all";if("all"!==r)return l([]),b(null),v(null),w(null),I({left:0,top:0,height:28,visible:!1}),i({left:0,top:0,height:28}),d([]),g([]),void m("simple"===r&&!1!==e.state.showRevisionMarkup?function(e,t){const n=Gv(t);if(0===n.size)return[];const o=e.surfaceRect,r=/* @__PURE__ */new Map;for(const s of e.paragraphs){const e=r.get(s.pageIndex);(void 0===e||s.left<e)&&r.set(s.pageIndex,s.left)}const a=/* @__PURE__ */new Map;for(const s of e.pages??[]){const e=r.get(s.index),t=void 0===e?0:e-s.left;a.set(s.index,s.left+(t>0?.5*t:12)-o.left)}const i=[];for(const s of e.paragraphs){const e=n.get(s.paragraphId);if(void 0===e)continue;const t=a.get(s.pageIndex)??s.left-o.left-12,r=s.lines;if(0===r.length){i.push({paragraphId:s.paragraphId,left:t,top:s.top-o.top,height:Math.max(1,s.height)});continue}const l=null===e?r:r.filter(t=>e.some(e=>e.start<t.endOffset&&e.end>t.startOffset)),c=l.length>0?l:[r[0]];for(const n of c)i.push({paragraphId:s.paragraphId,left:t,top:n.top-o.top,height:Math.max(1,n.height)})}return i}(o,e.state):[]);const a=Ov(o,e.state);m([]),l(a.selectionBoxes),g(!1===e.state.showRevisionMarkup?[]:[...ex(o,e.state),...tx(o,e.state)]),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!Vv(t,"comments"))return[];const o=e.surfaceRect,r=new Map(ma(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const s=n.items[i];if(!s?.start||!s?.end||!_v(t,s.author))continue;const l=r.get(s.start.paragraphId),c=r.get(s.end.paragraphId);if(void 0!==l&&void 0!==c)for(const t of e.paragraphs){const e=r.get(t.paragraphId);if(void 0===e||e<l||e>c)continue;const n=e===l?s.start.offset:0,d=e===c?s.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),s=r.slots.find(e=>e.offset===t)??r.slots[r.slots.length-1];n&&s&&a.push({commentId:i,left:n.left-o.left,top:r.top-o.top,width:Math.max(1,s.left-n.left),height:r.height})}}}return a}(o,e.state)),b(a.selectedImageBox),v(a.selectedTextBoxBox),w(a.selectedTableBox),i(a.inputBox),I(a.caretBox)},A=(e="selection")=>{const t=++M;queueMicrotask(()=>{t===M&&O(e)})},F=(e="content-change")=>(A(e),!1),E=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(r(e=>ix(e,t.paragraphIds??[])),Se()),A(e),t.resolveWhenDone?Promise.resolve():null),L=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),r({}),Se();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];r(t=>ix(t,e)),Se()}A("content-change")}},N=async()=>{n({}),r({}),Se(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),A("import")};wt(()=>{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")}),wt(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||A("content-change")}),wt(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.showMarkupFormatting,e.state.markupAuthors,A("content-change")}),wt(()=>{e.state.reviewDisplayMode,A("content-change")}),wt(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{A("scroll")},o=()=>{A("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),qt(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const z=()=>T(null),$=()=>{M+=1,B.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:o,documentLayout:R,canvasSnapshotProvider:B,inputBox:a,selectionBoxes:s,commentHighlights:c,revisionMarkupBoxes:u,changeBarBoxes:f,selectedImageBox:h,selectedTextBoxBox:y,selectedTableBox:x,caretBox:S,preferredColumnX:C,setPreferredColumnX:T,clearPreferredColumn:z,requestInputBoxSync:A,scheduleDeferredLayoutMeasurement:E,stabilizeLayoutAfterImport:N,syncMeasuredLayoutMetrics:F,syncInputBox:O,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:r,applyInvalidation:L,onCleanupHook:$}}(e)}function lx(e){return Array.isArray(e)?e.map(lx):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,lx(t)])):e}function cx(e){const{builtinStyle:t,customStyle:n,...o}=e;return JSON.stringify(lx(o))}var dx=new Map(Object.values(Oa).flatMap(e=>{const t=Ue(e);return t?[[e.id,{key:t,signature:cx(e)}]]:[]}));function ux(e){if(!0===e.customStyle||void 0!==e.builtinStyle)return;const t=dx.get(e.id);return t?.signature===cx(e)?t.key:void 0}function px(e,t,n){const[o,r]=Pt("Initial"),[a,i]=Pt(!1),s=()=>n.enabled??!1,l=n.persistence,c=nt(async e=>{if(s()&&a()){r("Saving...");try{const t=JSON.parse(JSON.stringify(zn(e)));await l.saveDocument(t),r("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),r("Error")}}},1e3);return wt(xn(()=>e.document,e=>{s()&&a()&&c(e)},{defer:!0})),jt(async()=>{if(!s())return i(!0),void r("Saved");try{const e=await l.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=ux(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 gx(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function fx(e){return function(e){const t=(e,t)=>{const n=mr(e.document),o=Math.max(0,Math.min(Ka(e),n.length-1)),r=Da(e),a=n[o];if(!a)return e;const i=[...n],s={...a},l=Go("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(l):e.push(l),s.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(l):e.push(l),s.footer=e}else{const e=[...a.blocks];t<0?e.unshift(l):e.push(l),s.blocks=e}return i[o]=s,{...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:gx(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:gx(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=ma(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=ma(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const s=Dr(i,n<0?bi(i):0);return e.applyTransactionalState(()=>Sv(r,s),{mergeKey:_p}),e.focusInput(),!0}const s=r[i],l=n<0?bi(s):0;return e.applyTransactionalState(e=>Sv(e,Dr(s,l)),{mergeKey:_p}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(Xt)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function mx(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"),s=i.objectStore(t).put(o,n);s.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${s.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 hx(e){return function(e){const[t,n]=Pt([]),[o,r]=Pt([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},s=t=>{e.commitState(e.cloneState(t))},l=(t,n)=>{const o=e.stateSnapshot(),r=lo("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:gx(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const s=lo("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>mr(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=ma(e),r=ma(t),a=/* @__PURE__ */new Map;for(const s of o)a.set(s.id,s);const i=[];for(const s of r){const e=a.get(s.id);if(!e){i.push(s.id);continue}if(e===s)continue;if(e.runs.length!==s.runs.length){i.push(s.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=s.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=Ya(o),i=Ya(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(s.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(s),lo("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:l,applyHistoryState:s,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 bx(e){let t=e.state.document,n=e.state.selection;wt(()=>{const o=e.state.document,r=e.state.selection,a=o!==t,i=r!==n;var s;if(t=o,n=r,e.state.activeSectionIndex,e.state.activeZone,s=e.state,Ap&&(Ep={anchor:{paragraphId:s.selection.anchor.paragraphId,runId:s.selection.anchor.runId,offset:s.selection.anchor.offset},focus:{paragraphId:s.selection.focus.paragraphId,runId:s.selection.focus.runId,offset:s.selection.focus.offset},activeZone:s.activeZone??"main",activeSectionIndex:s.activeSectionIndex??0}),e.isImportInProgress())return;const l=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(l),a&&(e.emit("change",l),e.emit("documentChange",l.document)),i&&e.emit("selectionChange",l.selection)})}function yx(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:i,applyState:s,cloneState:l,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:g,getImageOps:f}=e,m=kv({state:()=>r,applyState:s,applyTransactionalState:(e,t)=>U(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await F()},resetEditorChromeState:()=>q(),focusInput:d,requestLocalFontAccess:Ro,prepareDocumentFonts:async e=>{await Fo(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),h=()=>"done"!==m.importProgress()?.phase&&"error"!==m.importProgress()?.phase&&null!==m.importProgress(),{measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:I,revisionMarkupBoxes:C,changeBarBoxes:T,selectedImageBox:k,selectedTextBoxBox:P,selectedTableBox:R,caretBox:B,preferredColumnX:M,setPreferredColumnX:O,clearPreferredColumn:A,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:D,setMeasuredParagraphLayouts:E,applyInvalidation:L,onCleanupHook:N}=sx({state:r,surfaceRef:u,viewportRef:p,isImporting:h,zoomFactor:g}),z=mx({key:t().persistenceKey}),{status:$}=px(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=Ir(e);a(t),q()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??z,logger:n}),{undoStack:H,redoStack:W,applyTransactionalState:U,applyHistoryState:j,resetTransactionGrouping:V,updateHistoryState:K,getHistoryState:_,clearHistory:X}=hx({stateSnapshot:i,commitState:a,cloneState:l,applyLayoutInvalidation:L}),G=fx({state:()=>r,stateSnapshot:i,applyHistoryState:j,applyTransactionalState:U,focusInput:d,clearPreferredColumn:A,imageOps:f,updateHistoryState:K,getHistoryState:_}),q=()=>{A(),D({}),E({}),Se(),x.clear(),X()};return bx({state:r,isImportInProgress:h,cloneState:l,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:m,isImportInProgress:h,measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:I,revisionMarkupBoxes:C,changeBarBoxes:T,selectedImageBox:k,selectedTextBoxBox:P,selectedTableBox:R,caretBox:B,preferredColumnX:M,setPreferredColumnX:O,clearPreferredColumn:A,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:D,setMeasuredParagraphLayouts:E,applyLayoutInvalidation:L,onCleanupHook:N,fallbackPersistence:z,persistenceStatus:$,undoStack:H,redoStack:W,applyTransactionalState:U,applyHistoryState:j,resetTransactionGrouping:V,updateHistoryState:K,getHistoryState:_,clearHistory:X,historyActions:G,resetEditorChromeState:q}}(e)}function vx(e){return ki(e,e=>"textBox"===e.kind)}function xx(e,t){const n=vx(e);if(!n||!Ua(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=ma(e).map((e,t)=>t!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}function wx(e,t){const n=vx(e);if(!n||!Ua(n.run))return e;const{paragraphIndex:o,run:r}=n,a=ma(e).map((e,n)=>n!==o?tr(e):{...tr(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Cr(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return Sn(e,a,z(a,Qr(e)))}function Sx(e,t,n,o={}){const r=vx(e),a=r&&Ua(r.run);if(!r||!a)return e;const i=o.handleDirection??"se",s=i.includes("n")||i.includes("s"),l=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=ma(e).map((e,t)=>t!==p?tr(e):{...tr(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Cr(e);const t=e.textBox,n={...t,width:d,height:u};return s&&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*pa}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*pa}})}return a}(t.floating,f,m,l,c)),{...e,textBox:n}})});return Sn(e,h,z(h,Qr(e)))}var Ix=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),Cx=e=>e.rows.reduce((e,t)=>Math.max(e,Ix(t)),0),Tx=(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 kx(e){if(!e)return null;for(const t of e.blocks){const e=Uo(t)[0];if(e)return e}return null}var Px=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=kx(e);if(t)return t}return null};function Rx(e,t){return e.some(e=>Uo(e).some(e=>e.id===t))}var Bx=(e,t,n)=>{const o=Xo(e,t);if(!o)return{kind:"outside"};const r=Or(e,t,o.sectionIndex);if(!r)return{kind:"outside"};const a=function(e,t,n){for(const o of e){if(!Rx(o,n))continue;const e=Ra(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Xo(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=Ta(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{kind:"blocked"};const i=a.rows.filter(e=>!e.style?.hidden).flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),s=i.findIndex(e=>function(e,t){return e.blocks.some(e=>Uo(e).some(e=>e.id===t))}(e,t));if(-1===s)return{kind:"blocked"};const l=s+n;if(l<0)return{kind:"beforeFirst"};if(l>=i.length)return{kind:"afterLast"};const c=i[l],d=c.blocks.every(e=>"paragraph"===e.type),u=c.blocks.flatMap(Uo),p=d?u[0]:c.blocks.find(e=>"paragraph"===e.type)??u[0];if(!p)return{kind:"blocked"};const g=d?u[u.length-1]:p;return{kind:"adjacent",selection:{anchor:Dr(p,0),focus:Dr(g,bi(g))}}},Mx=(e,t,n)=>{const o=Bx(e,t,n);return"adjacent"===o.kind?o.selection.anchor:null};function Ox(e,t){return Boolean(e?.some(e=>Uo(e).some(e=>e.id===t)))}function Ax(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])=>Ox(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>Ox(e,o))?.[0]??"footer":"blocks"}function Fx(e){const t=Xo(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function Dx(e,t){if("footnote"===t){const t=Fx(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=mr(e.document),o=Ka(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=Ax(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var Ex=(e,t,n="main")=>{if("footnote"===n){const n=Fx(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=Ka(e),r=mr(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const s=Ax(e,i,n),l=[...r];return l[a]="blocks"===s?{...i,blocks:t}:{...i,[s]:t},{...e,document:{...e.document,sections:l}}};function Lx(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Nx(e,t){const n=Ra(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:Lx(t),targetBlocks:e}:null}function zx(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]=Cn(a),Nx(i,n)}var $x=(e,t,n)=>{const o=Xo(e.document,e.selection.focus.paragraphId),r=Xo(e.document,e.selection.anchor.paragraphId);if(!o||!r)return n(e);if(o.zone!==r.zone||o.sectionIndex!==r.sectionIndex||o.footnoteId!==r.footnoteId)return e;const a=Or(e.document,e.selection.focus.paragraphId,Ka(e)),i=o.zone;let s,l;if(a){const n=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?Nx(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 s={...i,cells:[...i.cells]};a.rows[e.rowIndex]=s;const l=s.cells[e.cellIndex];if(!l)break;const c={...l,blocks:[...l.blocks]};s.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,a);if(!n)return e;s=n.targetBlocks,l=n.targetCell.blocks}else{const o=t(e,i);if(o.length&&o.every(e=>"paragraph"===e.type)&&o.some(t=>t.id===e.selection.anchor.paragraphId)&&o.some(t=>t.id===e.selection.focus.paragraphId))return n(e);s=[...o],l=s}const c=function(e,t){const n=e.findIndex(e=>"paragraph"===e.type&&e.id===t.anchor.paragraphId),o=e.findIndex(e=>"paragraph"===e.type&&e.id===t.focus.paragraphId);if(n<0||o<0)return null;let r=Math.min(n,o),a=Math.max(n,o)+1;if(e.slice(r,a).some(e=>"paragraph"!==e.type))return null;for(;r>0&&"paragraph"===e[r-1]?.type;)r--;for(;a<e.length&&"paragraph"===e[a]?.type;)a++;return{start:r,end:a}}(l,e.selection);if(!c)return e;const d=Wa(l.slice(c.start,c.end).map(e=>"paragraph"===e.type?tr(e):e),e.document.pageSettings,void 0,e.document.styles,void 0,e.document.assets),u={...e,activeSectionIndex:0,activeZone:"main",document:{...d,settings:e.document.settings},selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}},p=n(u),g=mr(p.document)[0]?.blocks??[];if(p===u&&JSON.stringify(g)===JSON.stringify(l.slice(c.start,c.end))&&JSON.stringify(p.selection)===JSON.stringify(e.selection))return e;l.splice(c.start,c.end-c.start,...g);const f=Ex(e,s,i),m=ma(e),h=ma(f),b=e.document.bookmarks,y=e.document.comments;return{...f,document:{...f.document,...b?{bookmarks:yo(b,m,h)}:{},...y?{comments:it(y,m,h)}:{}},selection:p.selection}};function Hx(e,t){const n=Or(e.document,e.selection.focus.paragraphId,Ka(e));return n?zx(e,t,n):null}function Wx(e,t,n,o){const r=Ex(e,t,n);return o?{...r,selection:{anchor:Dr(o,0),focus:Dr(o,0)}}:r}function Ux(e,t,n,o){const r=t.getTargetBlocks(e,n),a=Ra(r,o);return a?.[a.length-1]?.table??null}function jx(e,t){const n=Or(e.document,e.selection.focus.paragraphId,Ka(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Ux(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function Vx(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=jx(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=Ux(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=jx(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),s=t=>null!==jx(t,e),l=t=>{const n=jx(t,e);return Boolean(n&&Cx(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:s,canEditSelectedTableColumn:l}}(e)}function Kx(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function _x(e){return e.blocks.flatMap(Uo)}function Xx(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Gx(e,t){return function(e,t){const n=e.selection,o=Ka(e),r=Or(e.document,n.anchor.paragraphId,o),a=Or(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),s=Ra(i,r.tablePath),l=Ra(i,a.tablePath),c=s?.[s.length-1],d=l?.[l.length-1];if(!c||!d||c.table!==d.table)return null;const u=Xx(r),p=Xx(a),g=c.table,f=Ga(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 qx(e){return function(e){const t=t=>{const n=t.selection,o=Gx(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),s=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}..${s}]`);const l=Kx(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Kx(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[l.rowIndex]?.cells[l.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?_x(d)[0]:void 0,g=u?_x(u):[],f=g[g.length-1];return p&&f?{anchor:Dr(p,0),focus:Dr(f,bi(f))}:null},n=t=>{const n=Gx(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),s=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:s,zone:n.anchorLocation.zone}},o=t=>{const n=Gx(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Kx(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=Gx(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 Yx(e){if(e)for(const t of e.blocks){const e=Uo(t)[0];if(e)return e}}function Zx(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?zx(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Jx(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=>Cn(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Zx(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,s=a.rows[o.rowIndex];if(!s)return n;const l=s.cells.slice(o.startCellIndex,o.endCellIndex+1);if(l.length<2)return n;const c=n.trackChangesEnabled?gf():void 0,d={...l[0],colSpan:l.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:l.flatMap(e=>e.blocks.map(e=>Cn(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:"horizontal",currentCellCount:1,previousCells:l.map(t)}}:{}};s.cells.splice(o.startCellIndex,l.length,d);const u=Yx(d);return u?Wx(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Zx(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,s=[];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;s.push(r)}if(s.length<2)return n;const l=Math.max(1,s[0].colSpan??1);if(!s.every(e=>Math.max(1,e.colSpan??1)===l))return n;const c=n.trackChangesEnabled?gf():void 0,d={...s[0],rowSpan:s.length,vMerge:"restart",blocks:s.flatMap(e=>e.blocks.map(e=>Cn(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:"vertical",currentCellCount:1,previousCells:s.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=vr([Go("")],l);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Yx(d);return u?Wx(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Hx(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex]?.cells[a.cellIndex],l=Math.max(1,s?.rowSpan??1);if(!s||l<=1||"restart"!==s.vMerge)return n;const c=t(s),d=n.trackChangesEnabled?gf():void 0,u=Math.max(1,s.colSpan??1);s.rowSpan=void 0,s.vMerge=void 0,d&&(s.style={...s.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},s.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:l-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):vr([],u)})]});for(let e=1;e<l;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=vr([Go("")],u);t.cells[a.cellIndex]=n}const p=Yx(s);return p?Wx(n,i,a.zone,p):n},i=n=>{const o=Hx(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex],l=s?.cells[a.cellIndex],c=Math.max(1,l?.colSpan??1);if(!s||!l||c<=1)return n;const d=t(l),u=n.trackChangesEnabled?gf():void 0,p=[{...l,colSpan:void 0,blocks:l.blocks.map(e=>Cn(e)),...u?{style:{...l.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},()=>vr([Go("")]))];s.cells.splice(a.cellIndex,1,...p);const g=Yx(p[0]);return g?Wx(n,i,a.zone,g):n},s=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:s}}(e)}function Qx(e,t){e.style={...e.style??{},revision:{...gf(),type:t}}}function ew(e){if(!e)return null;for(const t of e.blocks){const e=Uo(t)[0];if(e)return e}return null}function tw(e,t,n){const o=ew(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=ew(r);if(e)return e}return Px(e)}function nw(e){return function(e){const t=(t,n)=>{const o=Hx(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex];if(!s)return t;const l=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=Ga(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),s=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=Ba(s.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<l&&e.visualRowIndex+e.rowSpan>l);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=vr([Go("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return vr([Go("")],t.colSpan)})),t.trackChangesEnabled&&Qx(c,"insert"),r.rows.splice(l,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=tw(r,Tx(c,d),c);return Wx(t,i,a.zone,u)}c=Ba(s.cells.map(e=>vr([Go("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&Qx(c,"insert"),r.rows.splice(l,0,c);const d=tw(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return Wx(t,i,a.zone,d)},n=t=>{const n=Hx(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,targetBlocks:r,location:a}=n,i=o.rows[o.rows.length-1];if(!i||!i.cells.length)return t;const s=i.cells.map(e=>{const t=vr([Go("")],Math.max(1,e.colSpan??1));if(e.style){const{revision:n,...o}=e.style;t.style=o}return t}),l=Math.max(o.gridCols?.length??0,Cx(o));for(let e=s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0);e<l;e++)s.push(vr([Go("")]));const c=Ba(s);return t.trackChangesEnabled&&Qx(c,"insert"),o.rows.push(c),Wx(t,r,a.zone,ew(s[0]))},o=t=>{const n=Hx(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 Qx(i,"delete"),Wx(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const s=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),l=s?Ga(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(s){const e=Ga(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=tw(o,c?Tx(c,Math.min(l?.visualColumnIndex??r.cellIndex,Math.max(0,Ix(c)-1))):null);return Wx(t,a,r.zone,d)},r=(t,n)=>{const o=Hx(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=Ga(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=vr([Go("")]);t.trackChangesEnabled&&Qx(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:{...gf(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=vr([Go("")]);t.trackChangesEnabled&&Qx(n,"insert"),e.push(n)}n.cells=e}const s=r.rows[a.rowIndex],l=tw(r,s?Tx(s,o):null);return Wx(t,i,a.zone,l)}const s=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=vr([Go("")]);t.trackChangesEnabled&&Qx(n,"insert"),e.cells.splice(s,0,n)}const l=r.rows[a.rowIndex]?.cells[s],c=tw(r,l);return Wx(t,i,a.zone,c)},a=t=>{const n=Hx(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(Cx(o)<=1)return t;if(t.trackChangesEnabled){const e=Ga(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=Tx(t,e);n&&Qx(n,"delete")}return Wx(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Ga(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=tw(o,n&&Tx(n,Math.min(e,Math.max(0,Ix(n)-1))));return Wx(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],s=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],l=tw(o,s);return Wx(t,a,r.zone,l)};return{insertSelectedTableRow:t,appendTableRowForTab:n,deleteSelectedTableRow:o,insertSelectedTableColumn:r,deleteSelectedTableColumn:a}}(e)}function ow(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:s,cells:l,zone:c}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${s.length} (${l.length} cells) in zone ${c}`);const d=[],u=[];for(const e of l){const t=e.cell.blocks.flatMap(Uo);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p={...r,activeSectionIndex:0,activeZone:"main",document:{...Wa(d,r.document.pageSettings,void 0,r.document.styles,void 0,r.document.assets),settings:r.document.settings},selection:{anchor:Dr(d[0],0),focus:Dr(d[d.length-1],bi(d[d.length-1]))}},g=n(p);if(g===p)return r;const f=ma(g);if(f.length!==d.length)return r;const m=s[s.length-1];if(!m)return r;const h=zx(r,e.getTargetBlocks,{blockIndex:i,rowIndex:m.rowIndex,cellIndex:m.cellIndex,paragraphIndex:0,tablePath:s,zone:c});if(!h)return r;let b=0;for(let e=0;e<l.length;e+=1){const t=l[e],n=u[e]??0,o=f.slice(b,b+n);b+=n;const r=h.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=Yt(r.blocks,o))}return Ex(r,h.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function rw(e){return function(e){const t=Dx,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=qx({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=Vx({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Jx({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:l,canSplitSelectedTableCell:s,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:S,insertSelectedTableColumn:I,deleteSelectedTableColumn:C}=nw({getTargetBlocks:t}),T=(e,n)=>$x(e,t,n),{withExpandedTableCellSelection:k,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R}=ow({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,logger:e.logger}),B=(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?gf():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...vr([Go("")]),style:{width:o}});const t=Ba(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...Zo(a),style:{width:"100%"}},s=ca(e,e.selection.focus),l=Ta(e.document),c=Ka(e),d=Da(e),u=e=>{const t=e.findIndex(e=>e.id===s.paragraphId||"paragraph"!==e.type&&Uo(e).some(e=>e.id===s.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=l[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=[...l];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:Y(Dr(h,0))}}(e,t,n),{mergeKey:Kp}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:S,insertSelectedTableColumn:I,deleteSelectedTableColumn:C,getRowVisualWidth:Ix,getTableVisualWidth:Cx,findCellAtVisualColumn:Tx,findFirstNavigableParagraphInTable:Px,updateBlocksInCurrentSection:Ex,resolveAdjacentTableCellPosition:Mx,resolveTableTabTarget:Bx,applyTableAwareParagraphEdit:T,withExpandedTableCellSelection:k,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R,insertTableCommand:B}}(e)}function aw(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function iw(e,t){let n=null;const o=(e,t,n)=>{const o=ma(e).find(e=>e.id===t);return o?{anchor:Dr(o,n),focus:Dr(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=aw(),i=i=>{if(!a.owns(i))return;const s=n;if(!s)return;const l=t.zoomFactor?.()??1,c=(i.clientX-s.startClientX)/l,d=(i.clientY-s.startClientY)/l,u=e.getMaxWidth(t.state,s.paragraphId),{width:p,height:g}=Ge(s,c,d,i.shiftKey,u),f=o(t.state,s.paragraphId,s.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,s.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,s)},s=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:gx(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),l(),t.focusInput()},l=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)};return{start:(l,c,d,u,p)=>{const g=o(p,l,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:l,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",s),window.addEventListener("pointercancel",s))},stop:l}}function sw(e,t){let n=null;const o=aw(),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 s=((e,t,n)=>{const o=ma(e).find(e=>e.id===t);return o?{anchor:Dr(o,n),focus:Dr(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);s?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,s),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:gx(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,s,l)=>{const c=s.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(l)},o.claim(s),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function lw(e,t){return Math.max(1e-4,1-e-t)}function cw(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 dw(e){let t=null;const n=(e,t,n)=>{const o=ma(e).find(e=>e.id===t);return o?{anchor:Dr(o,n),focus:Dr(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=aw(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const s=e.zoomFactor?.()??1,l=(a.clientX-i.startClientX)/s,c=(a.clientY-i.startClientY)/s,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=lw(a,s)/o,d=lw(i,l)/r,u=1-a-s,p=1-i-l,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,l,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=lw(a,s)/o,d=lw(i,l)/r,u=K(e.handleDirection,"x"),p=K(e.handleDirection,"y");let g=a,f=s,m=o;if(0!==u)if(u<0){m=Qe(o-t,24,o+a/c);const e=cw(a,s,a-(m-o)*c,s);g=e.near,f=e.far}else{m=Qe(o+t,24,o+s/c);const e=cw(a,s,a,s-(m-o)*c);g=e.near,f=e.far}let h=i,b=l,y=r;if(0!==p)if(p<0){y=Qe(r-n,24,r+i/d);const e=cw(i,l,i-(y-r)*d,l);h=e.near,b=e.far}else{y=Qe(r+n,24,r+l/d);const e=cw(i,l,i,l-(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,l,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(gv(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:gx(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),s(),e.focusInput()},s=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},l=(s,l,c,d,u,p)=>{const g=n(u,s,l);if(!g)return;const f=dv(o(u,g)),m=f&&Ya(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:s,paragraphOffset:l,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)=>l(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>l(e,t,"se",n,o,"move"),stop:s}}function uw(e){return function(e){const[t,n]=Pt(!1),[o,r]=Pt(!1),[a,i]=Pt(null);wt(()=>{o()&&!m(e.state)&&r(!1)});const s=()=>{m(e.state)?r(e=>!e):r(!1)},[l,c]=Pt({x:0,y:0}),[d,u]=Pt(null);let p=null,g=null,f=null;const m=e=>{const t=Qr(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=ma(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:hr(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=aw(),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=iw({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>uv(e,t,n),getMaxWidth:(t,n)=>Iv(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=sw({label:"image",applyRotate:(e,t)=>function(e,t){const n=bv(t);return xv(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=dw({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=>Sv(e,o),{mergeKey:_p})):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 s=r.currentTarget,l=a?{left:a.left,top:a.top,width:a.width,height:a.height}:s?.getBoundingClientRect();if(!l)return;const d=m(e.state);g={paragraphId:t,paragraphOffset:o,startClientX:r.clientX,startClientY:r.clientY,src:d?.src??"",width:d?.width??l.width,height:d?.height??l.height,offsetX:r.clientX-l.left,offsetY:r.clientY-l.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=Qo(e.state.document).find(e=>e.id===t);r&&e.applyState(Ii(e.state,{anchor:Dr(r,n),focus:Dr(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)},O=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),C.start(t,n,o,r,e.state)},A=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:s,draggedImageInfo:a,mousePos:l,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:P,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:I.stop,stopImageCrop:C.stop,handleImagePointerDown:R,handleImageResizeHandlePointerDown:B,handleImageRotateHandlePointerDown:M,handleImageCropHandlePointerDown:O,handleImageCropBodyPointerDown:A}}(e)}function pw(e){return function(e){const t=e=>{const t=vx(e),n=t&&Ua(t.run);return n?{width:n.width,height:pe(n,e,0)}:null},n=iw({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>Sx(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=Iv(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=sw({label:"text box",applyRotate:(e,t)=>xx(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 gw(e){return function(e){const[t,n]=Pt(void 0),o=()=>{n(void 0)};wt(()=>{Ia(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=go(e.state()),o=t();return Ia(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},s=(t,n)=>{if(Ia(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)},l=t=>{if(Ia(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(Ia(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:s,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:l}}(e)}function fw(e,t,n={}){if(!t)return[];const o=[],r=Qo(e),{matchCase:a=!1,wholeWord:i=!1}=n,s=a?"g":"gi";let l=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(l=`\\b${l}\\b`);const c=new RegExp(l,s);return r.forEach((e,t)=>{const n=Ko(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:Dr(e,n),focus:Dr(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function mw(e,t,n,o={}){const r=fw(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=Ii(a,{anchor:e.anchor,focus:e.focus}),a=qu(a,n)}return a}function hw(e,t,n,o,r,a){const i=e+n,s=t+o;return(a<t?t-a:a>s?a-s:0)*vo+(r<e?e-r:r>i?r-i:0)}function bw(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,s=e.slots[0].height;for(const l of e.slots){const e=n<l.top?l.top-n:n>l.top+l.height?n-(l.top+l.height):0,c=Math.abs(t-l.left),d=e*vo+c;d<r&&(r=d,o=l.offset,a=l.left,i=l.top,s=l.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:s}}function yw(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=bw(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function vw(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function xw(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,s=a.top+(e.clientY-a.top)/r,l=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=hw(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,s);if(!l)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"}(l,s),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const s=e.floatingTextBoxes[i];if(s.pageIndex===t&&s.zone===n&&(!s.behindDoc||a)&&o>=s.left&&o<=s.left+s.width&&r>=s.top&&r<=s.top+s.height)return s}return null}(t,l.index,c,i,s,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===l.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=Dr(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 s=e.floatingImages[i];if(s.pageIndex===t&&s.zone===n&&(!s.behindDoc||a)&&vw(o,r,s))return s}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&vw(o,r,i))return i;return null}(t,l.index,c,i,s,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===l.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=Dr(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:s,score:l,slotLeft:c,slotTop:d,slotHeight:u}=bw(e,t,n);(!o||l<o.score)&&(o={paragraph:i,offset:s,score:l,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=hw(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:yw(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===l.index&&e.zone===c),i,s);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,l.index,c,i,s);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=p.caretViewport;let h;if(m&&i!==m.left){const e=g.lines.filter(e=>s>=e.top&&s<=e.top+e.height&&e.slots.some(e=>e.offset===f&&e.left===m.left&&e.top===m.top));if(1===e.length){const t=e[0].slots,n=t.filter(e=>e.offset===f),o=t.find(e=>e.offset===f-1),r=t.find(e=>e.offset===f+1);1===n.length&&o&&r&&o.left<m.left&&m.left<r.left&&(h=i<m.left?"before-markers":"after-markers")}}const b=ar(g.paragraph,f,h);return{zone:c,footnoteId:g.footnoteId,paragraphId:g.paragraphId,paragraphOffset:f,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:g.tableCell?.anchorPosition,caretViewport:p.caretViewport}}function ww(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),s=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){Ap&&(Dp=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)}(s),!s)return zp(null),null;const l=xw({snapshot:s,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return zp(l),l};return{resolveSurfaceHitAtPoint:t}}(e)}var Sw=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],Iw=/* @__PURE__ */new Map;function Cw(){return Sw.map(e=>({...e}))}var Tw=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function kw(e,t,n){const[o,r]=e,[a,i]=t,[s,l]=n,c=s-a,d=l-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 Pw(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 l=1;l<e.length-1;l+=1){const t=kw(e[l],r,a);t>n&&(n=t,o=l)}if(n<=t)return[r,a];const i=Pw(e.slice(0,o+1),t),s=Pw(e.slice(o),t);return[...i.slice(0,-1),...s]}function Rw(e,t,n){let o=0;for(let l=0;l<e.length;l+=1)1===e[l]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return Cw();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 s=r,l=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]=Tw[n],d=s+r,u=l+a;if(o(d,u)){i.push([s,l]),c=(n+4)%8,s=d,l=u,e=!0;break}}if(!e){i.push([s,l]);break}if(s===r&&l===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return Cw();const a=.012*Math.max(t,n);let i=Pw(r,a),s=a;for(;i.length>40;)s*=1.6,i=Pw(r,s);return i.length<3?Cw():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function Bw(e){const t=e.src,n=Iw.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 s=i.getContext("2d",{willReadFrequently:!0});if(!s)return null;let l;s.drawImage(e,0,0,r,a);try{l=s.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)l[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return Cw();const r=Rw(o.mask,o.width,o.height);return Iw.set(t,r),r.map(e=>({...e}))}function Mw(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>dv(t())?"image":vx(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},s=(e,n)=>{const r=hr(t().document,n),a=t=>{const n=Bw(t);o(t=>function(e,t,n){const o=ma(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...tr(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Cr(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:tr(e));return r?Sn(e,a,z(a,Qr(e))):e}(t,e,n),{mergeKey:og})},i=re(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=dv(e),n=t&&Ya(t.run);return n?sv(n.floating):null}(t()):"textBox"===e?function(e){const t=vx(e),n=t&&Ua(t.run);return n?sv(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=dv(e),n=t&&Ya(t.run);return cv(n?.floating)}(t()):"textBox"===e&&function(e){const t=vx(e),n=t&&Ua(t.run);return cv(n?.floating)}(t())},setPreset:e=>{if(i(Kg,(t,n)=>"image"===n?function(e,t){return wv(e,e=>iv(e,t))}(t,e):function(e,t){return wx(e,e=>iv(e,t))}(t,e)),"tight"===e||"through"===e){const e=dv(t()),n=e&&Ya(e.run);n&&!n.wrapPolygon&&s(e.run.id,n.src)}},setFixedPosition:e=>i(_g,(t,n)=>"image"===n?function(e,t){return wv(e,e=>e?lv(e,t):e)}(t,e):function(e,t){return wx(e,e=>e?lv(e,t):e)}(t,e))}}function Ow(e){return function(e){let t=0;Nt()&&qt(()=>{t++});const n=n=>{if(t++,e.onNativeClipboardStart?.(),Uu(e.state()))return n.preventDefault(),void(n.clipboardData&&function(e,t){try{const n=Hu(e);return t.setData(Eu,n.token),!!Array.from(t.types).includes("application/x-oasis-chart-token")&&n.confirm()}catch{return!1}}(e.stateSnapshot?.()??e.state(),n.clipboardData)?e.onNativeClipboardSuccess?.():e.onNativeClipboardIssue?.("copy","unsupported"));const o=Si(e.state());if(0!==o.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",ju(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},o=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();if(Uu(e.state()))return n.preventDefault(),void e.onNativeClipboardIssue?.("cut","unsupported");const o=Si(e.state());if(0!==o.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",ju(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qu(e))),e.focusInput()}},r=n=>{const o=++t;if(e.isReadOnly())return void n.preventDefault();const r=e.consumePasteMode?.(),a=e.clipboardRequestGeneration?.(),i=()=>o!==t||e.clipboardRequestGeneration?.()!==a,s=Array.from(n.clipboardData?.types??[]).filter(Nu);if(n.clipboardData&&s.length){n.preventDefault();const t=e.forcePlainTextPaste();e.setForcePlainTextPaste(!1);const o=1===s.length?Wu(n.clipboardData.getData(s[0])):void 0,a=e.stateSnapshot?.();return t||r&&"rich"!==r||!o||!a?void e.onNativeClipboardIssue?.("paste","unsupported"):(n.currentTarget.value="",(async()=>{let t;try{t=await Du(a,o)}catch{return void(i()||e.isReadOnly()||e.onNativeClipboardIssue?.("paste","unsupported"))}if(i()||e.isReadOnly())return;if(e.stateSnapshot?.()!==a)return void e.onNativeClipboardIssue?.("paste","document-changed");let n=!1;e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>i()||e.isReadOnly()||o!==a?o:(n=!0,t)),n?(e.onNativeClipboardSuccess?.(),e.focusInput()):e.onNativeClipboardIssue?.("paste","document-changed")})())}if(e.forcePlainTextPaste()||"text"===r){e.setForcePlainTextPaste(!1);const t=n.clipboardData?.getData("text/plain")??"";return 0===t.length?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>Zu(e,t))),n.currentTarget.value="",void e.focusInput())}const l="merge"!==r?rv(n.clipboardData):null;if(l)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(l),n.currentTarget.value="",void e.focusInput();const c=gp(n.clipboardData?.getData("text/html")??""),d="merge"===r?pp(e.state(),c):c;if(d.length>0)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Vu(e,d))),n.currentTarget.value="",void e.focusInput();const u=n.clipboardData?.getData("text/plain")??"";0!==u.length&&(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Zu(e,u))),n.currentTarget.value="",e.focusInput())},a=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();const o=rv(n.dataTransfer);if(!o)return;n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const r=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY)??e.state().selection.focus;e.insertImageFromFile(o,r),e.focusInput()};return{handleCopy:n,handleCut:o,handlePaste:r,handleDrop:a}}(e)}var Aw=/* @__PURE__ */new WeakMap;function Fw(e,t){return function(e){return mr(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function Dw(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=Aw.get(a);if(i)return i;const s=/* @__PURE__ */new Map,l=/* @__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=s.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),s.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=l.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)):l.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of s.entries())for(const e of u.values()){const t=l.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 s.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 Aw.set(a,c),c}function Ew(e,t,n,o,r,a){const i=Dw(t,n,o,r,a);if(0===i.length)return null;let s=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&&(!s||n<s.distance)&&(s={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!s||o<s.distance)&&(s={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!s||n<s.distance)&&(s={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!s||o<s.distance)&&(s={geometry:d,cell:t,side:"bottom",distance:o})}}if(!s)return null;const l=Fw(n,s.geometry.tableId);if(!l)return null;const c=Ga(l).find(e=>e.rowIndex===s.cell.rowIndex&&e.cellIndex===s.cell.cellIndex);return c?{tableId:s.geometry.tableId,rowIndex:s.cell.rowIndex,cellIndex:s.cell.cellIndex,side:s.side,rect:s.cell,tableNode:l,layoutEntry:c,tableGeometry:s.geometry}:null}var Lw=1/.75;function Nw(e){return.75*e}function zw(e){return e*Lw}var $w=Wf;function Hw(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,zw(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?zw(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?zw(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,zw(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,zw(e.style.borderRight.width)):1)}function Ww(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 s=0;s<o;s+=1){const n=$w(e.rows[s]?.style?.height);if(null!==n){a[s]=Math.max(1,zw(n));continue}const o=t.find(e=>e.rowIndex===s&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[s]=Math.max(1,e.height))}}return a}function Uw(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 l=0;l<o;l+=1)a[l]=Math.max(1,zw(e.gridCols[l]));else for(const l of t){if(1!==l.colSpan)continue;const e=i.get(`${l.rowIndex}:${l.cellIndex}`);e&&(a[l.visualColumnIndex]=Math.max(1,e.width))}const s={};for(let l=0;l<o;l+=1)s[l]=Math.max(10,Nw(a[l]));return{widthsPt:s,maxColumnIndex:r}}function jw(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??zw(10),r=Math.max(zw(10),t.minRowHeightPx??zw(10)),a=Math.max(10,Nw(Math.max(r,o+n)));return function(e,t,n,o){return Hf(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Vw(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 Kw=null;function _w(e,t){Kw=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 Xw(e){e&&Kw!==e||(Kw=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Gw(e,t){_w(e,t)}function qw(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Yw(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Zw(e){const[t,n]=Pt(null);let o=null,r=null,a=null,i=null;const s={},l=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Xw();const i=Ew(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?_w("left"===i.side||"right"===i.side,s):Xw()},c=aw(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=qw(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:Vw(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Yw(o),o=null),null!==a&&(Yw(a),a=null),n(null),Xw(s),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?jw(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=Nw(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??{},s=a[t.index]??10,l=Math.max(10,Nw(i[t.index]??zw(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(l,s-o),i=s-r;n+i<0&&(i=-n,r=s-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Uf(e,t.tableId,a,c,d)}let c=Math.max(l,s+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,Nw(i[e]??zw(10)));let r=n-(c-s);r<o&&(r=o,c=s+(n-o),c=Math.max(l,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=Fw(e,t.tableId),g=$w(p?.style?.width),f=d?u:null!==g?g:void 0;return Uf(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=qw(l))))},handlePointerDown:t=>{r=null,null!==o&&(Yw(o),o=null),Xw();const a=e.surfaceRef();if(!a)return!1;const i=Ew(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const l=e.state(),u=Ga(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}=Uw(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=zw(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const s of n){if(1!==s.colSpan)continue;if(!i.get(`${s.rowIndex}:${s.cellIndex}`))continue;const n=t.rows[s.rowIndex]?.cells[s.cellIndex];if(!n)continue;const o=s.visualColumnIndex,l=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,gt(n,e.document.styles)),1);a[o]=Math.max(l,c+Hw(n)+12,r)}return a}(l,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:$w(i.tableNode.style?.indentLeft)??0,guideBounds:Vw(e.viewportRef)}),Gw(!0,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=Ww(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 zw(10);const a=zw(10);let i=a;for(let s=0;s<r.cells.length;s+=1){if(!r.cells[s])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===s);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===s);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:Vw(e.viewportRef)}),Gw(!1,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var Jw=null;function Qw(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=zw(10),s=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,l=s>0?i/s:0;return{scaleX:Math.max(a,t),scaleY:Math.max(l,n)}}function eS(e){const[t,n]=Pt(null);let o=null,r=null;const a={},i=aw(),s=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=qw(l)))},l=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(Yw(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Jw===a&&(Jw=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}=Qw(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const l of Object.keys(t.widthsPt)){const e=Number(l);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=Uf(e,t.tableId,r,a),s={};return t.rowHeightsPx.forEach((e,t)=>{s[t]=Math.max(10,Nw(e*o))}),Hf(i,t.tableId,s)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=Qw(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 l=Dw(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=Fw(e.state(),t);if(!l||!c)return;const u=Ga(c),{widthsPt:p}=Uw(c,u,l),g=Ww(c,u,l),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:l.bounds.left,top:l.bounds.top,width:Math.max(1,l.bounds.width),height:Math.max(1,l.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),Jw=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",s),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var tS=null;function nS(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=nS(n.blocks,t,!0,!1);if(e)return e}}return null}function oS(e,t){for(const n of Ta(e)){for(const e of[n.blocks,n.header,n.footer]){const n=nS(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=nS(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=nS(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=nS(n.blocks,t,!1,!1);if(e)return e}return null}function rS(e){return function(e){const[t,n]=Pt(!1),[o,r]=Pt(null),[a,i]=Pt(null),[s,l]=Pt(0),[c,d]=Pt(0),[u,p]=Pt({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=aw(),v=()=>{f=null,null!==g&&(Yw(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),tS===m&&(tS=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=oS(e,n);return Boolean(o?.table&&Uo(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-s())<=4)return;n(!0),tS=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=qw(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=oS(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return Nf(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*xa,y:(t.y??0)+(n.clientY-s())*xa,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?I(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}),l(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 aS=e=>"touch"===e.pointerType;function iS(e,t){if(!e||0===e.length){const e=ka(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Uo(n)[0]??null,blocks:e}}function sS(e,t,n){const o=Qo(e.document).filter(t=>{const o=Xo(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:Dr(t,0),end:a?Dr(a,0):Dr(t,Ko(t).length)}}function lS(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,s=0,l=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?Xo(o.document,r.paragraphId)?.footnoteId:void 0,s="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!s)return void e.applyState(o);let l=o.document,c=t.activeSectionIndex??0;if(!l.sections||0===l.sections.length){const e=ka("header"),t=ka("footer");l={...l,sections:[{id:"section:1",blocks:[],pageSettings:Sr(l.pageSettings??or),header:[e],footer:[t]}]},c=0}const d=l.sections,u=d[c];let p=u.header,g=u.footer,f=null;if("header"===n){const e=iS(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=iS(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},l={...l,sections:e}}const m=r||(f?Dr(f,0):o.selection.anchor);e.applyState({...o,document:l,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=Ka(n),a=ci(n.document,o.anchor.paragraphId,r),i=ci(n.document,o.focus.paragraphId,r),s=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",l=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}] [${s}→${l}]`)},v=()=>{f?.longPressHandle&&clearTimeout(f.longPressHandle),f=null},x=()=>{t=null,o=null,g=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",k)},w=e=>{g=e,window.addEventListener("pointermove",C),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",k)},S=()=>{if(n=null,!t)return;const r=o;if(o=null,!r)return;const a=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(Xo(i.document,t.paragraphId)?.sectionIndex!==Xo(i.document,a.paragraphId)?.sectionIndex)return;const s=Ii(i,{anchor:t,focus:a.position});b(i,a.zone,s,a.position),y("selection:drag")},I=()=>{o&&(null!==n&&(h(n),n=null),S())},C=e=>{null!==g&&e.pointerId!==g||(!f||f.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(S))):Math.hypot(e.clientX-f.clientX,e.clientY-f.clientY)>20&&x())},T=t=>{if(null===g||t.pointerId===g){if(f&&!f.longPressFired){const n=f,o=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return v(),x(),void(o&&(D(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}I(),y("selection:end"),x(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},k=e=>{null!==g&&e.pointerId!==g||x()},P=(n,o,r)=>{if(r<2)return t=null,x(),void e.focusInputAfterPointerSelection();t=null,o.resolvedFromParagraph?b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position):b(n,o.zone,n),x(),e.focusInputAfterPointerSelection()},R=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=Dr(r,o.textBox.startOffset),i=Dr(r,o.textBox.endOffset);b(n,o.zone,Ii(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},B=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=Dr(a,o.image.startOffset),s=Dr(a,o.image.endOffset);b(n,o.zone,Ii(n,{anchor:i,focus:s}),i),x(),aS(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()},M=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,Ii(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},O=(n,o,r)=>{t=null;const a=sS(n,r,o.zone);b(n,o.zone,Ii(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},A=(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=Dr(r,o.paragraphOffset);return b(n,o.zone,Ii(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const s=Dn(Ko(r),o.paragraphOffset),l=Dr(r,s.start),c=Dr(r,s.end);b(n,o.zone,Ii(n,{anchor:l,focus:c}),l),x(),e.focusInputAfterPointerSelection()},F=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!aS(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,x(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?R(n,o):o.image?B(n,o,a):a.shiftKey&&o.resolvedFromParagraph?M(n,o,a.pointerId):r>=3&&i?O(n,o,i):2===r&&i?A(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),aS(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,o,r)},D=(t,n,o)=>{F(e.state(),t,n,o),e.focusInputSync()},E=()=>{const n=f;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const o=n.hit;if(!o?.resolvedFromParagraph)return;const r=e.state(),a=e.getParagraphById(r.document,o.paragraphId);if(!a)return;const i=Dn(Ko(a),o.paragraphOffset),s=Dr(a,i.start),l=Dr(a,i.end);b(r,o.zone,Ii(r,{anchor:s,focus:l}),s),t=s,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-s);r=n-a<=450&&o<=((e,t)=>aS(e)?20:t)(t,6)&&t.button===l?r+1:1,a=n,i=t.clientX,s=t.clientY,l=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,aS(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(E,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),F(m,h,g,t)},N=n=>{if(n.detail<3)return;n.preventDefault();const o=e.state(),r=Math.hypot(n.clientX-u,n.clientY-p),a=Date.now()-d<=600&&r<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(o.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const s=sS(o,i,a.zone);b(o,a.zone,Ii(o,{anchor:s.start,focus:s.end}),s.start),x(),e.focusInputAfterPointerSelection()},z=(e,t)=>{0===t.button&&(aS(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:z,stopDragging:x}}(e)}function cS(e){return function(e){const[n,r]=Pt(!1);let a,i=0,s="",l=null;const c=()=>{i=0,s="",a=void 0},u=(n,o)=>{if(!o&&n===s)return;if(0===i&&0===n.length)return void(o&&c());const r=i,u=Fr(a);e.clearPreferredColumn(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>{const o=function(e,n){if(n<=0)return e;const{paragraph:o,index:r,offset:a}=oe(e);if(a<n)return e;const i=ma(e),s=a-n;if(O(e,o,s,a))return e;const l=d(o,t(o)?co(o,s,a,()=>null):[...rn(o,0,s),...rn(o,a,bi(o))],Zn(o,s)),c=i.map((e,t)=>t===r?l:e);return Sn(e,c,Y(Dr(l,s)))}(e,r);return n.length>0?qu(o,n,u):o}),{mergeKey:jp}),o?(c(),l=n.length>0?n:null):(i=n.length,s=n)},p=t=>{if(Dt("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(t.currentTarget.value)}`),t.currentTarget.value="",void c();const r=t.currentTarget.value;if(0===r.length)return;if(n())return e.logger.debug(`input:composing buffer=${JSON.stringify(r)}`),void u(r,!1);if(null!==l){const n=r===l;if(l=null,n)return e.logger.debug(`input:suppressed text=${JSON.stringify(r)}`),void(t.currentTarget.value="")}const a=e.state(),i=a.selection,s=ma(a).find(e=>e.id===i.anchor.paragraphId)?.runs.find(e=>e.id===i.anchor.runId),d=s?{bold:s.styles?.bold,italic:s.styles?.italic,underline:s.styles?.underline}:null;e.logger.info(`input:text ${JSON.stringify(r)} (len=${r.length}) at ${i.anchor.paragraphId}:${i.anchor.runId}[${i.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const p=Fr(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>qu(e,r,p)),{mergeKey:Up}),t.currentTarget.value="",e.focusInput(),o("input:text")},g=()=>{e.logger.debug("input:composition start"),c(),l=null,a=Fr(e.pendingCaretTextStyle()),r(!0)},f=t=>{e.isReadOnly()||u(t.data??"",!1)},m=t=>{if(r(!1),e.isReadOnly())return t.currentTarget.value="",void c();const n=t.data??t.currentTarget.value,o=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(n)} (len=${n.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),u(n,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:p,handleCompositionStart:g,handleCompositionUpdate:f,handleCompositionEnd:m,composing:n}}(e)}var dS="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 uS(e,t){const n=Qr(e);if(n.isCollapsed)return!1;const o=ma(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=$r(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function pS(e,t,n,o,r,a){if(n.zone===Da(e))return r(e,e=>Gu(e,t,{copy:o}));if(o||n.tableCellAnchorPosition||!["main","header","footer"].includes(n.zone))return e;if("main"!==n.zone&&"header"!==n.zone&&"footer"!==n.zone)return e;try{return function(e,t){const n=e.document.sourcePackage,o=Da(e);if(!n||1!==e.document.sections?.length||e.trackChangesEnabled||e.document.opaqueRelocationIntent||e.document.opaqueDeletionIntents?.length)throw Error("Relocation requires a single-section source-backed document without pending opaque edits or tracked changes");if("main"!==o&&"header"!==o&&"footer"!==o)throw Error("Unsupported source zone");if(o===t.zone||"main"!==o&&e.activeHeaderFooterStory&&"default"!==e.activeHeaderFooterStory)throw Error("Only distinct default stories are supported");if(e.document.bookmarks?.order.length||e.document.comments?.order.length)throw Error("Cross-story anchors are not supported");const r=ki(e,e=>"opaque"===e.kind);if(!r||"opaque"!==r.run.kind||"inline"!==r.run.opaque.placement||r.run.revision||r.run.sdtWrappers?.length)throw Error("Select exactly one unwrapped inline opaque object");const a=ei(n,o),i=ei(n,t.zone),s=r.run.opaque.signature,l=(n.opaqueObjects??[]).filter(e=>e.signature===s),c=1===l.length?l[0]:void 0;if(!c||c.ownerPath!==a)throw Error("Ambiguous source identity");const d=Ma(n,c,i),u=e.document.sections[0],p="main"===o?u.blocks:u[o],g="main"===t.zone?u.blocks:u[t.zone];if(!p?.some(e=>"paragraph"===e.type&&e.id===r.paragraph.id)||!g?.some(e=>"paragraph"===e.type&&e.id===t.paragraphId))throw Error("Only top-level paragraphs of existing stories are supported");const f={...e,activeSectionIndex:0,activeZone:t.zone,activeHeaderFooterStory:"default"},m=ma(f).find(e=>e.id===t.paragraphId);if(!m||!Number.isInteger(t.offset)||t.offset<0||t.offset>bi(m))throw Error("Invalid destination offset");const h={...Q(e),activeZone:t.zone,activeSectionIndex:0,activeHeaderFooterStory:"default"},b=ma(h),y=b.find(e=>e.id===t.paragraphId);if(!y)throw Error("Destination unavailable after deletion");const v=Cr(r.run);if("opaque"!==v.kind)throw Error("Invalid cloned object");const x=xe(y,t.offset,[{...v,opaque:d.destinationRun}]),w=Sn(h,b.map(e=>e.id===x.id?x:e),{anchor:Dr(x,t.offset),focus:Dr(x,t.offset+1)});return{...w,document:{...w.document,opaqueRelocationIntent:{ownerPath:c.ownerPath,ordinal:c.ordinal,signature:c.signature,destinationOwner:i}}}}(e,{zone:n.zone,paragraphId:n.paragraphId,offset:n.paragraphOffset})}catch(i){return a?.(i),e}}function gS(e){return function(e){const[t,n]=Pt(!1),[o,r]=Pt(null),[a,i]=Pt(!1),[s,l]=Pt(null),[c,d]=Pt(null);let u=null,p=null,g=null,f=null;const m=()=>{p&&(p.remove(),p=null)},h=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${dS} !important; }`,document.head.appendChild(p))},b=aw(),y=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,f=null,n(!1),r(null),i(!1),l(null),d(null),m(),b.release(),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)},v=o=>{if(!b.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),h()}l({x:o.clientX,y:o.clientY});const s=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY,{forDrag:!0});if(f=s?.resolvedFromParagraph?s:null,!s?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=s.tableCellAnchorPosition??s.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${s.zone}|src=${s.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:s.zone,resolvedFromParagraph:s.resolvedFromParagraph,paragraphId:s.paragraphId,paragraphOffset:s.paragraphOffset,hitPosition:`${s.position.paragraphId}:${s.position.runId}[${s.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:s.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(s.caretViewport??null)},x=n=>{if(b.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}),"pointercancel"!==n.type){if(t()&&o()&&f){const t=o(),r=n.ctrlKey||n.metaKey,a=f;e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(n=>pS(n,t,a,r,e.applyTableAwareParagraphEdit,t=>e.logger?.warn?.("text-drag:relocation-rejected",t)),{mergeKey:r?gg:fg}),e.logger?.info("text-drag:apply",{mode:r?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position,n=e.state(),o=uS(r=n,i=t)?Ii(r,{anchor:i,focus:i}):r;o!==n&&e.applyState(o),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}var r,i;y(),e.focusInputAfterPointerSelection()}else y()},w=(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):uS(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},l({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),f=null,d(o.caretViewport??null),n(!1),b.claim(t),window.addEventListener("pointermove",v),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),!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:s,caretViewport:c,tryStartTextDrag:w,stopDrag:y}}(e)}function fS(e){return e.blocks.flatMap(Uo)}function mS(e,t){if(!e)return;const n=fS(e);return"start"===t?n[0]:n[n.length-1]}function hS(e){return function(e){const t=(t,n)=>{const o=e.state(),r=ma(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:Ko(r).length,i=Dr(r,a);return e.clearPreferredColumn(),e.applyState(Ii(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=ma(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:Ko(a).length,s=Dr(a,i);return e.clearPreferredColumn(),e.applyState(Ii(o,{anchor:n?o.selection.anchor:s,focus:s})),!0},o=(t,n)=>{const o=e.state(),r=ma(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const s=Ko(i),l=$r(i,o.selection.focus),c=s.length;if(!n&&!Ia(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ci(o):Ti(o)),!0;let d=i,u=l;"left"===t?0===l&&a>0?(d=r[a-1],u=Ko(d).length):u=pt(s,l):l===c&&a<r.length-1?(d=r[a+1],u=0):u=nn(s,l);const p=Dr(d,u);return e.clearPreferredColumn(),e.applyState(Ii(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=ma(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const i=e.surfaceRef(),s=i?.getBoundingClientRect()??null,l=e.preferredColumnX(),c=null===l?e.caretBox().left+(s?.left??0):l,d=i?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:i,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let u=a+t;const p=Or(o.document,o.selection.focus.paragraphId,Ka(o)),g=p?.tablePath[p.tablePath.length-1];if(p&&g){const e=Dx(o,p.zone),n=Ra(e,p.tablePath),a=n?.[n.length-1]?.table;if(a){const e=Ga(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&&fS(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=mS(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 s=mS(i.cell,t<0?"end":"start");u=s?r.findIndex(e=>e.id===s.id):-1;break}}else if(t<0){const e=mS(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=mS(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?Je(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($r(f,o.selection.focus),Ko(f).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Ii(e,{anchor:n?e.selection.anchor:Dr(f,m),focus:Dr(f,m)})),e.focusInput(),!0},i=()=>{const t=e.state();if(!Ia(t.selection))return!1;const n=e.surfaceRef(),o=e.caretBox();if(!n||!o.visible)return!1;const r=ma(t).find(e=>e.id===t.selection.focus.paragraphId);if(!r)return!1;const a=$r(r,t.selection.focus);if(a<=0)return!1;const i=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:n,state:t,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});return!!i&&function(e,t,n){if(t<=0||!Number.isFinite(n))return!1;const o=e.filter(e=>e.startOffset<=t&&e.endOffset>=t&&n>=e.top-.5&&n<e.top+e.height-.5);return 1===o.length&&o[0].startOffset===t}(Je(i,r.id).flatMap(e=>e.lines),a,o.top+i.surfaceRect.top+Math.min(1,o.height/2))};return{isCaretAtWrappedLineStart:i,moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function bS(e){return function(e){const[t,n]=Pt(null),o=(t,o)=>{const r=ma(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 Ta(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 s=o.currentTarget.getBoundingClientRect(),l=e.surfaceRef()?.getBoundingClientRect();if(!l)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(s.left-l.left)/c,top:(s.top-l.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function yS(e){const t=ma(e);if(!t.length)return null;const n=Qr(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:rn(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:bi(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Fr(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(lr(r?r.styles:Zn(o,n.startParagraphOffset),o.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===bi(o));return{text:a,paragraph:i?rr(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function vS(e,t){const n=ma(e);if(!n.length)return e;const o=Qr(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:bi(e),s=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===bi(e))}(e,n,o),l=s?rr(t.paragraph):e.style,c=s?t.list?{...t.list}:void 0:e.list,d=s&&(JSON.stringify(l)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),u=a<i&&rn(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Fr(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!Xa(e.styles,o)});if(!d&&!u)return e;r=!0;let p=u?ue(e,a,i,e=>{if("text"!==e.kind)return e;const n=Fr(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 s&&(p={...p,style:l,list:c}),p});return r?Sn(e,a,z(a,o)):e}function xS(e){const t=ma(e);if(!t.length)return"";const n=Qr(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function wS(e){const[t,n]=Pt(null);let o=null,r=null,a="";const i=()=>{o=null,r=null,a="",n(null)};Nt()&&(wt(()=>{t()&&(e.isReadOnly()||e.state().document!==r)&&i()}),qt(i));const s=()=>!e.isReadOnly()&&ma(e.state()).length>0,l=t=>{if(!s())return!1;const i=e.state(),l=yS(i);return!!l&&(o=l,r=i.document,a=xS(i),n(t),e.focusInput(),!0)};return{mode:t,canCapture:s,armOnce:()=>l("once"),armContinuous:()=>l("continuous"),cancel:i,applyToSelection:n=>{if(!o||!t())return!1;if(e.isReadOnly()||e.state().document!==r)return i(),!1;const s=e.state();if(xS(s)===a)return!1;const l=function(e,t){const n=ma(e);if(0===n.length)return null;const o=Qr(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=Dn(Ko(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Dr(r,a.start),focus:Dr(r,a.end)}}}(s,"pointer"===n);if(!l)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return An(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==r)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:l.selection},e=>vS(e,o));return c=n.document!==t.document,n}),"once"===t()?i():c&&(r=e.state().document)}),c&&e.focusInput(),c}}}function SS(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:i,focusInputAfterPointerSelection:s,focusInputSync:l,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:g,setForcePlainTextPaste:f,getCommandsController:m,applyTransactionalState:h,clearPreferredColumn:b,resetTransactionGrouping:y,updateHistoryState:v,caretBox:x,preferredColumnX:w,setPreferredColumnX:S,documentLayout:I,canvasSnapshotProvider:C}=e,T=()=>dv(t),k=()=>vx(t),P=Mw({state:()=>t,resetTransactionGrouping:y,applyTransactionalState:h,focusInput:i}),R=ww({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:I,canvasSnapshotProvider:C,zoomFactor:u}).resolveSurfaceHitAtPoint,B=function(e){const[t,n]=Pt(""),[o,r]=Pt(""),[a,i]=Pt({matchCase:!1,wholeWord:!1}),[s,l]=Pt([]),[c,d]=Pt(-1),[u,p]=Pt(!1);wt(xn([()=>e.state.document,t,a],([e,t,n])=>{const o=fw(e,t,n);l(o),0===o.length?d(-1):(c()>=o.length||-1===c())&&d(0)}));const g=t=>{const n=s()[t];n&&e.applyState(Ii(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:o,setReplaceTerm:r,findOptions:a,setFindOptions:i,matches:s,currentIndex:c,findNext:()=>{const e=s().length;if(0===e)return;const t=(c()+1)%e;d(t),g(t)},findPrevious:()=>{const e=s().length;if(0===e)return;const t=(c()-1+e)%e;d(t),g(t)},replace:()=>{if(0===s().length||-1===c())return;const t=s()[c()];e.applyTransactionalState(e=>qu(Ii(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:lg})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>mw(e,n,o(),a()),{mergeKey:cg}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:h,focusInput:i}),M=rw({applyTransactionalState:h,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:Jt(e).document,selection:t}),focusInput:i,logger:n}),O=wS({state:()=>t,isReadOnly:o,applyTransactionalState:h,applyTableAwareParagraphEdit:M.applyTableAwareParagraphEdit,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i}),A=(e,t)=>R(e,t)?.position??null,F=uw({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:A,applyState:r,applyTransactionalState:h,updateHistoryState:v,focusInput:i,focusInputAfterPointerSelection:s,cloneState:a,logger:n,zoomFactor:u}),D=pw({state:t,surfaceRef:c,applyState:r,updateHistoryState:v,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),E=gw({state:()=>t,commandsController:m,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i,logger:n}),L=function(e){const t=()=>e.state,n=Zw({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=eS({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=rS({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=bS({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=gS({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyState:e.applyState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),s=lS({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:yr,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),l=cS({state:t,isReadOnly:e.isReadOnly,logger:e.logger,clearPreferredColumn:e.clearPreferredColumn,pendingCaretTextStyle:e.styleController.pendingCaretTextStyle,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput}),c=hS({state:t,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,surfaceRef:()=>e.surfaceRef()??null,caretBox:e.caretBox,preferredColumnX:e.preferredColumnX,setPreferredColumnX:e.setPreferredColumnX,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),{handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}=Ow({state:t,stateSnapshot:e.getStateSnapshot,onNativeClipboardIssue:e.clipboardActions?.reportNativeIssue,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,consumePasteMode:e.clipboardActions?.consumePasteMode,onNativeClipboardSuccess:e.clipboardActions?.dismiss,onNativeClipboardStart:e.clipboardActions?.dismiss,clipboardRequestGeneration:e.clipboardActions?.requestGeneration,setForcePlainTextPaste:e.setForcePlainTextPaste,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,insertImageFromFile:e.insertImageFromFile,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint});return{tableResize:n,tableCornerResize:o,tableDrag:r,revisionController:a,textDrag:i,surfaceEvents:s,textInput:l,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,getStateSnapshot:e.getStateSnapshot,applyState:r,applyTransactionalState:h,isReadOnly:o,logger:n,focusInput:i,focusInputAfterPointerSelection:s,focusInputSync:l,clearPreferredColumn:b,resetTransactionGrouping:y,surfaceRef:c,viewportRef:d,caretBox:()=>x(),preferredColumnX:()=>w(),setPreferredColumnX:S,zoomFactor:u,documentLayout:I,canvasSnapshotProvider:C,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:A,tableOps:M,imageOps:F,styleController:E,formatPainter:O,getForcePlainTextPaste:g,setForcePlainTextPaste:f,clipboardActions:e.clipboardActions,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),N=e=>{0===e.button&&(E.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:T,selectedTextBoxRun:k,layoutOptionsOverlay:P,fr:B,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:A,tableOps:M,imageOps:F,textBoxOps:D,styleController:E,formatPainter:O,onEditorPointerDown:N,tableResize:L.tableResize,tableCornerResize:L.tableCornerResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}(e)}function IS(e){if("main"!==(e.activeZone??"main"))return e;const t=Ia(e.selection)?e:Q(e),{paragraph:n,index:o,offset:r}=oe(t),a=gi(),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 $o(e)){const e=za(a);e&&!e.customMark&&(r.has(e.footnoteId)||(r.add(e.footnoteId),o+=1))}return wr(o+1,n)}(t.document),s=jo(a.id,i),l=xe(n,r,[s]),c=ma(t).map((e,t)=>t===o?l:e),d=Dr(l,r+i.length),u=Sn(t,c,Na(d)),p=function(e){return e||{items:{}}}(u.document.footnotes),g={...u.document,footnotes:{...p,items:{...p.items,[a.id]:a}}},f=da(g),m=a.blocks.flatMap(Uo).find(Boolean);return m?{...u,document:f,selection:Na(Dr(m,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...u,document:f}}function CS(e){if(!e)return;const{propertyRevision:t,...n}=e;return Object.keys(n).length>0?n:void 0}function TS(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 l=0;l<i.length;l+=1){const e=i[l];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[l+t];n&&(n.cells[o]=e)})}}}const s=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:TS(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===s.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:s}]})}function kS(e,t,n){const o=Ta(e.document).map(e=>({...e,blocks:TS(e.blocks,t,n),header:e.header?TS(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?TS(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?TS(e.evenPageHeader,t,n):void 0,footer:e.footer?TS(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?TS(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?TS(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function PS(e,t,n){const o=Ta(e.document),r=o.findIndex(e=>e.propertyRevision?.id===t);if(-1===r)return e;const a=o[r],i=a.propertyRevision,s=[...o];if(n)s[r]={...a,propertyRevision:void 0};else{const e=structuredClone(i.previous);s[r]={...a,pageSettings:e.pageSettings,pageBorder:e.pageBorder,pageNumbering:e.pageNumbering,verticalAlignment:e.verticalAlignment,bidi:e.bidi,propertyRevision:void 0};const t=s[r+1];t&&(s[r+1]={...t,breakType:e.nextBreakType})}return{...e,document:{...e.document,sections:s}}}function RS(e,t){const n=ma(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:CS(e.styles)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:d(e,n)});return PS(kS(Sn(e,n,z(n,Qr(e))),t,!0),t,!0)}function BS(e,t){const n=ma(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:CS(n.previous)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:d(e,n)});return PS(kS(Sn(e,n,z(n,Qr(e))),t,!1),t,!1)}function MS(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>MS(e,t))))}function OS(e,t,n){for(const o of e)if("paragraph"!==o.type){MS(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=>MS(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),OS(e.blocks,t,n)}}}function AS(e){const t=Qr(e),n=ma(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:bi(e),s=rn(e,r,i);for(const t of s)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 Ta(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&OS(e,r,o);for(const a of Uv(e))a.paragraphIds.some(e=>r.has(e))&&o.add(a.id);return o}function FS(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 Ta(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 DS(e){return FS(e).size>0}function ES(e,t){if(!DS(e))return e;const n=Wt(e.document,t);if(!n.changed)return e;const o=ma({...e,document:n.document}),r=z(o,Qr(e));return{...e,document:n.document,selection:r}}function LS(e){const t=Qr(e),n=ma(e);if(t.isCollapsed){const e=n[t.startIndex];return e?Mn(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:bi(e);return rn(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 NS(e){const t=Qr(e),n=ma(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return tr(e);if(!e.list)return tr(e);const o=e.list.level??0;return o<=0?Ne(e):E(e,o-1)});return Sn(e,n,z(n,t))}function zS(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:r,applySelectionAwareTextCommand:a,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:l,focusInput:c,clearPreferredColumn:u,resetTransactionGrouping:p,toolbarStyleState:g,selectionCollapsed:f,selectedImageRun:m}=e,h=e=>{u(),p(),o(e),c()},b=e=>{u(),p(),a(e),c()},v=e=>{u(),p(),s(e),c()},x=(e,t)=>{u(),p(),r(e,t),c()},w=()=>{const e=Qr(t);return ma(t).slice(e.startIndex,e.endIndex+1)},S=()=>w().some(e=>Boolean(e.list)),I=()=>{const e=t.selection.focus.paragraphId;return ma(t).find(t=>t.id===e)??null},C=()=>{const e=I();return!!e?.list&&(u(),p(),f()&&0===Ko(e).length?s(e=>function(e){const t=Qr(e),n=ma(e).map((e,n)=>n<t.startIndex||n>t.endIndex?tr(e):Ne(e));return Sn(e,n,z(n,t))}(e)):r(e=>l(e,e=>function(e){if(me(e))return e;const t=Ia(e.selection)?e:Q(e),{paragraph:n,index:o,offset:r}=oe(t);if(me(t))return e;const{beforeRuns:a,afterRuns:i}=Lo(n,r),s=d(n,a,Zn(n,r)),l=i.length>0?d(He(n,[]),i):(()=>{const e=Go("");return e.style=n.style?{...n.style}:void 0,e.list=sr(n.list),e})(),c=ma(t),u=[...fr(c.slice(0,o)),s,l,...fr(c.slice(o+1))];return Sn(t,u,Y(Dr(l,0)))}(e)),{mergeKey:Xp}),c(),!0)},T=()=>{const e=t.selection,n=Ka(t),o=ci(t.document,e.anchor.paragraphId,n),r=ci(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=>np(t,e))},P=e=>{f()||b(t=>function(e,t){const n=Qr(e);if(n.isCollapsed||_(e))return e;const o=ma(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:bi(o);return R(e,o,a,i,n=>{let r=ur(tp(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!lr(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return Sn(e,o,z(o,n))}(t,e))},B=(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=>op(t,e,o))},M=(e,t)=>{v(n=>ie(n,e,t))},O=e=>{const t=!g()[e];M(e,"widowControl"===e?t:!!t||null)},A=()=>{x(e=>l(e,e=>wo(e)))},F=()=>"main"===(t.activeZone??"main"),D=()=>{F()&&x(e=>IS(e))},L=e=>{const n=LS(t);f()&&!n||x(t=>function(e,t){const n=Qr(e);if(!n.isCollapsed)return op(e,"link",t);const o=ma(e)[n.startIndex];if(!o)return e;const r=Mn(o,n.startParagraphOffset);if(!r)return e;const a=op(Ii(e,{anchor:Dr(o,r.startOffset),focus:Dr(o,r.endOffset)}),"link",t),i=ma(a)[n.startIndex];return i?{...a,selection:{anchor:Dr(i,r.startOffset),focus:Dr(i,r.endOffset)}}:a}(t,e),{mergeKey:Gp})},N=()=>{const n=LS(t)??"";f()&&!n||e.openLinkDialog(n)},$=()=>e.openFontDialog(),H=t=>e.openParagraphDialog(t),W=()=>{L(null)},U=()=>{const t=m();if(!t)return;const n=Ya(t.run)?.alt??"";e.openImageAltDialog(n)},j=t=>{m()&&x(n=>function(e,t,n){const o=dv(e);if(!o||!Ya(o.run))return e;const r=ma(e),a=o.paragraphIndex+1,i=a<r.length&&Fa(r[a]),s=i?Gr(r[a],t,n):ia(t,n,1);if(i&&s===r[a])return e;const l=a<r.length&&Fa(r[a])?[...fr(r.slice(0,a)),s,...fr(r.slice(a+1))]:[...fr(r.slice(0,a)),s,...fr(r.slice(a))],c=ya(l,e.document.styles),d=c[a]??s;return Sn(e,c,Y(Dr(d,ua(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:Yp})},V=()=>{m()&&e.openImageCaptionDialog(function(e){const t=dv(e);if(!t||!Ya(t.run))return null;const n=ma(e);return Va(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:k,applyToggleCharacterBorderCommand:()=>{f()||b(e=>function(e){const t=Qr(e);if(t.isCollapsed||_(e))return e;const n=ma(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:bi(e);return rn(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((n,o)=>{if(o<t.startIndex||o>t.endIndex)return n;const a=o===t.startIndex?t.startParagraphOffset:0,i=o===t.endIndex?t.endParagraphOffset:bi(n);return R(e,n,a,i,e=>({...e,styles:ip(e.styles,r)}))});return Sn(e,a,z(a,t))}(e))},applyValueStyleCommand:B,applyUnderlineStyleCommand:P,applyChangeTextCaseCommand:e=>{f()||b(t=>cp(t,e))},applyClearFormattingCommand:()=>{f()||b(e=>function(e){const t=Qr(e);if(t.isCollapsed||_(e))return e;const n=ma(e).map((n,o)=>{if(o<t.startIndex||o>t.endIndex)return n;const r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:bi(n);return R(e,n,r,a,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Sn(e,n,z(n,t))}(e))},applyParagraphStyleCommand:M,toggleParagraphFlagCommand:O,applyParagraphListCommand:e=>{v(t=>function(e,t){const n=Qr(e),o=ma(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),s=i.length>0&&i.every(e=>e.list?.kind===t),l=o.map((e,n)=>{if(n<r||n>a)return tr(e);const o=tr(e);return s?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return Sn(e,l,z(l,n))}(t,e))},handleListFormatChange:e=>{v(t=>function(e,t){const n=Qr(e),o=ma(e).map((e,o)=>o<n.startIndex||o>n.endIndex?tr(e):e.list?{...tr(e),list:{...e.list,format:t||void 0}}:tr(e));return Sn(e,o,z(o,n))}(t,e))},handleListStartAtChange:e=>{v(t=>function(e,t){const n=Qr(e),o=ma(e).map((e,o)=>o<n.startIndex||o>n.endIndex?tr(e):e.list?{...tr(e),list:{...e.list,startAt:null!==t?t:void 0}}:tr(e));return Sn(e,o,z(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{h(Be(t,e))},applyInsertPageBreakCommand:A,canInsertFootnoteCommand:F,applyInsertFootnoteCommand:D,handleStyleChange:e=>{v(t=>y(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{h(i(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(Kv(t,e))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),c()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),c()},applyAcceptRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of AS(e))t=RS(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of AS(e))t=BS(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{x(e=>function(e){return ES(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{x(e=>function(e){return ES(e,"reject")}(e))},applyLinkCommand:L,promptForLink:N,openFontDialog:$,openParagraphDialog:H,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:W,applyImageAltCommand:e=>{m()&&x(t=>function(e,t){return xv(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:qp})},promptForImageAlt:U,applyImageCaptionCommand:j,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=dv(e),o=n&&Ya(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*ha));return uv(e,r,r*(o.height/o.width))}(t,e),{mergeKey:Zp})},applyImageHeightCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=dv(e),o=n&&Ya(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*ha));return uv(e,r*(o.width/o.height),r)}(t,e),{mergeKey:Zp})},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&&x(e=>"reset"===t?hv(e):fv(e,t),{mergeKey:Jp})},applyImageCropShapeCommand:e=>{m()&&x(t=>function(e,t){const n=t?.trim();return xv(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:Jp})},applyImageCropFillCommand:()=>{m()&&x(e=>function(e){const t=dv(e),n=t&&Ya(t.run);return n?xv(gv(e,{crop:mv(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Jp})},applyImageCropFitCommand:()=>{m()&&x(e=>function(e){return xv(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Jp})},resetImageCropCommand:()=>{m()&&x(e=>hv(e),{mergeKey:Jp})},applyImageBorderCommand:e=>{m()&&x(t=>function(e,t){return xv(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()&&x(t=>vv(t,e),{mergeKey:Qp})},rotateImageCommand:e=>{m()&&x(t=>yv(t,e),{mergeKey:eg})},applyImageTransparencyCommand:e=>{m()&&x(t=>function(e,t){return null===dv(e)?e:xv(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:tg})},resetImageCommand:()=>{m()&&x(e=>function(e){return null===dv(e)?e:xv(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:ng})},handleListTab:e=>!ci(t.document,t.selection.focus.paragraphId,Ka(t))&&(!!S()&&(v(t=>"indent"===e?function(e){const t=Qr(e),n=ma(e).map((e,n)=>n<t.startIndex||n>t.endIndex?tr(e):e.list?E(e,(e.list.level??0)+1):tr(e));return Sn(e,n,z(n,t))}(t):NS(t)),!0)),handleListEnter:C,handleListBoundaryBackspace:e=>{const n=I();return!(!n?.list||!f())&&(0===$r(n,t.selection.focus)&&(u(),p(),s(e=>NS(e)),e.currentTarget.value="",c(),!0))}}}(e)}function $S(e){return{fontFamily:e.fontFamily??"",fontSize:ct(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 HS(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 WS(e){return function(e){const t=zS({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:()=>Ia(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:$S(e.toolbarStyleState())})},openParagraphDialog:t=>{e.setParagraphDialog({isOpen:!0,initial:{...HS(e.toolbarStyleState()),defaultTabStop:e.state.document.settings?.defaultTabStop??36,...void 0!==t?{tabsOnly:!0,selectedTabPosition:t}:{}}})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function US(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}function jS(e){const t=e.document.settings?.defaultTabStop;return("number"==typeof t&&Number.isFinite(t)&&t>0?t:36)*Yr}function VS(e,t){const n=ma(e);if(!n.length)return e;const o=Qr(e,n),r=jS(e);let a=!1;const i=n.map((n,i)=>{if(i<o.startIndex||i>o.endIndex)return n;if(n.list){const e=n.list.level??0,o=Math.max(0,Math.min(8,e+t));return o===e?n:(a=!0,E(n,o))}const s=nr(n.style,e.document.styles).indentLeft??0;if(t<0&&s<=0)return n;const l=t<0?Math.max(0,s-r):s+r;return l!==s&&Number.isFinite(l)?(a=!0,{...n,style:{...n.style,indentLeft:l}}):n});return a?Sn(e,i,e.selection):e}function KS(e,t){const n=ma(e);if(!n.length)return e;const o=Qr(e,n);if(!o.isCollapsed||0!==o.startParagraphOffset)return e;const r=n[o.startIndex];if(!r||r.list)return e;const a=nr(r.style,e.document.styles),i=a.indentFirstLine??0,s=a.indentHanging??0;if(t>0&&(0!==i||0!==s))return VS(e,1);if(t<0&&i<=0)return e;const l=t>0?jS(e):Math.max(0,i-jS(e)),c=n.map((e,t)=>t===o.startIndex?{...e,style:{...e.style,indentFirstLine:l,indentHanging:0}}:e);return Sn(e,c,e.selection)}function _S(e){const t=ma(e);if(!t.length)return null;const n=Qr(e,t);if(!n.isCollapsed||0!==n.startParagraphOffset)return null;const o=t[n.startIndex];if(!o||o.list)return null;const r=nr(o.style,e.document.styles);return(r.indentLeft??0)>0?"paragraph":(r.indentFirstLine??0)>0&&(r.indentHanging??0)<=0?"firstLine":null}function XS(e){const t=_S(e);return"paragraph"===t?VS(e,-1):"firstLine"===t?KS(e,-1):e}var GS=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}},qS=[{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=ma(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Ii(t,{anchor:Dr(o,0),focus:Dr(r,Ko(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:"updateSelectedFields",command:"updateSelectedFields",key:"F9",execute:e=>!!e.executeCommand&&(!1!==e.canExecuteCommand?.("updateSelectedFields")&&e.executeCommand("updateSelectedFields"),!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=>wo(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=>qu(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=>Yu(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=>cn(e))),e.focusInput()),!0)}];function YS(e){return function(e){const t=new GS;qS.forEach(e=>t.register(e));const n=n=>{if(n.defaultPrevented)return;const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="Tab"===e||"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(),!Ia(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qu(e))),n.currentTarget.value="",void e.focusInput();const t=ma(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===$r(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>NS(e)),n.currentTarget.value="",void e.focusInput();const a=$r(r,o.selection.focus),i=Ko(r),s="Backspace"===n.key?pt(i,a):nn(i,a);return"Backspace"===n.key?0===a||s===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qu(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ii(t,{anchor:Dr(r,s),focus:Dr(r,a)}),e=>Qu(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ep(e))):s>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ii(t,{anchor:Dr(r,a),focus:Dr(r,s)}),e=>Qu(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ep(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.altKey||n.ctrlKey||n.metaKey||!_S(o)?(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qu(e))),n.currentTarget.value="",void e.focusInput()):(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!1!==e.canExecuteCommand?.("outdent")&&e.applySelectionAwareParagraphCommand(XS),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ep(e))),n.currentTarget.value="",void e.focusInput();case"Tab":return void function(e,t,n){const o=t.selection.focus.paragraphId,r=Xo(t.document,o),a=!!r&&Boolean(Or(t.document,o,r.sectionIndex)),i=ma(t);if(!i.length)return;const s=Qr(t,i),l=i[s.startIndex];if(!l)return;const c=!s.isCollapsed&&(s.startIndex!==s.endIndex||0===s.startParagraphOffset&&s.endParagraphOffset===bi(l)),d=nr(l.style,t.document.styles),u=s.isCollapsed&&0===s.startParagraphOffset&&!l.list,p=e.autoTabIndentEnabled?.()??!0,g=function(e){if(e.alt||e.ctrl||e.meta){const t=!e.meta&&!e.shift&&(e.ctrl&&!e.alt||e.isMac&&e.alt&&!e.ctrl);return e.inTable&&t?"insertLiteralTab":"passThrough"}return e.inTable?"navigateCell":e.reverseFirstLineIndent||!e.shift&&e.autoIndentAtStart?"changeFirstLineIndent":e.shift||e.wholeParagraphs||e.atListStart||e.atWrappedLineStart?"changeParagraphIndent":"insertLiteralTab"}({inTable:a,shift:n.shiftKey,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,isMac:e.isMacPlatform?.()??!1,atWrappedLineStart:p&&s.isCollapsed&&s.startParagraphOffset>0&&!a&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&(e.isCaretAtWrappedLineStart?.()??!1),wholeParagraphs:c,atListStart:Boolean(l.list)&&s.isCollapsed&&0===s.startParagraphOffset,autoIndentAtStart:p&&u&&Ko(l).length>0,reverseFirstLineIndent:n.shiftKey&&p&&u&&(d.indentLeft??0)<=0&&(d.indentFirstLine??0)>0});if("passThrough"!==g){switch(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),g){case"insertLiteralTab":{const t=Fr(e.pendingCaretTextStyle?.());e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>qu(e,"\t",t)));break}case"navigateCell":{const r=n.shiftKey?-1:1,a=e.resolveTableTabTarget?.(t.document,o,r);if("adjacent"===a?.kind)e.applySelectionPreservingStructure(a.selection);else if("afterLast"===a?.kind&&1===r&&e.appendTableRowForTab&&!1!==e.canExecuteCommand?.("tableInsertRowAfter"))e.applyTransactionalState(e.appendTableRowForTab);else if(!a){const n=e.resolveAdjacentTableCellPosition(t.document,o,r);n&&e.applySelectionPreservingStructure({anchor:n,focus:n})}break}case"changeFirstLineIndent":case"changeParagraphIndent":{const t=n.shiftKey?"outdent":"indent";if(!1===e.canExecuteCommand?.(t))break;e.applySelectionAwareParagraphCommand(e=>"changeFirstLineIndent"===g?KS(e,n.shiftKey?-1:1):VS(e,n.shiftKey?-1:1));break}}n.currentTarget.value="",e.focusInput()}}(e,o,n);case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(xi(o,-1))):(e.clearPreferredColumn(),e.applyState(Ci(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return xi(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Ti(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return wi(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return vi(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return wi(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return vi(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var ZS=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var JS={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"}},QS={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},eI={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 tI(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function nI(e,t){return function(e,t){const n=JS[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 oI(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function rI(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function aI(e){return null!=e&&""!==e?Number(e):null}function iI({gate:e,style:t,selection:n,history:o,formatting:r,dialog:a,link:i,command:s,valueCommand:l,actionCommand:c}){const d=t.state;return{selectAll:s("selectAll",r.selectAll),selectWord:s("selectWord",r.selectWord),selectSentence:s("selectSentence",r.selectSentence),selectParagraph:s("selectParagraph",r.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:l("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:s("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:aI(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:s("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:s("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:s("pastePlainText",r.pastePlainText),formatPainter:s("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:s("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:s("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:s("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:s("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:s("underline",r.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:s("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:s("wordUnderline",r.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:s("strike",r.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:s("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:s("smallCaps",r.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:s("allCaps",r.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:s("hidden",r.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:s("noProof",r.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:s("webHidden",r.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:s("specVanish",r.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:s("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:s("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:s("shadow",r.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:s("emboss",r.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:s("engrave",r.engrave,()=>({isActive:Boolean(d().imprint)})),outline:s("outline",r.outline,()=>({isActive:Boolean(d().outline)})),superscript:s("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:s("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:s("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:s("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:s("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:s("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:s("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:s("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:s("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:s("find",r.find),replace:s("replace",r.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),setReviewDisplayMode:l("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:s("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),toggleRevisionMarkup:s("toggleRevisionMarkup",r.toggleRevisionMarkup,()=>({isActive:r.areRevisionMarkupVisible()})),showMarkupOptions:l("showMarkupOptions",()=>!1,()=>r.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{r.applyShowMarkup(e??{})}),toggleOutlinePanel:s("toggleOutlinePanel",r.toggleOutlinePanel,()=>({isActive:r.areOutlineVisible()})),toggleRevisionsPanel:s("toggleRevisionsPanel",r.toggleRevisionsPanel,()=>({isActive:r.areRevisionsPanelVisible()})),acceptRevisions:s("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:s("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:s("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:s("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),requestAcceptAllRevisions:s("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&r.hasRevisionsInDocument()})),requestRejectAllRevisions:s("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:s("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:s("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:s("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:s("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:s("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:s("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:s("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:s("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:s("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:s("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:s("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:s("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:s("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:s("togglePreciseFonts",r.togglePreciseFonts,()=>(Co(),{isActive:h()})),undo:s("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:s("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:s("pageBreak",r.pageBreak),lineBreak:s("lineBreak",r.lineBreak),columnBreak:s("columnBreak",r.columnBreak),splitBlock:s("splitBlock",r.splitBlock),insertNonBreakingSpace:s("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:s("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:s("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:s("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:s("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:s("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:s("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:s("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:l("setFontFamily",e=>r.setFontFamily(e||null),()=>d().fontFamily),setFontSize:l("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=Jn(t);return null!==n&&r.setFontSize(n)},()=>ct(d().fontSize)),increaseFontSize:s("increaseFontSize",r.increaseFontSize),decreaseFontSize:s("decreaseFontSize",r.decreaseFontSize),growFont1:s("growFont1",r.growFont1),shrinkFont1:s("shrinkFont1",r.shrinkFont1),changeTextCase:c("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:s("clearFormatting",r.clearFormatting),setColor:l("setColor",e=>r.setColor(e??null),()=>d().color||null),setHighlight:l("setHighlight",e=>r.setHighlight(e??null),()=>d().highlight||null),setTextShading:l("setTextShading",e=>r.setTextShading(e??null),()=>d().textShading||null),setStyleId:l("setStyleId",e=>r.setStyleId(String(e)),()=>{const e=d();return e.mixedParagraphStyles?"":e.styleId||"normal"}),setCharacterStyleId:l("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:l("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:l("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:l("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:l("setCharacterScale",e=>r.setCharacterScale(aI(e)),()=>d().characterScale),setCharacterSpacing:l("setCharacterSpacing",e=>r.setCharacterSpacing(aI(e)),()=>d().characterSpacing),setRunSnapToGrid:l("setRunSnapToGrid",e=>r.setRunSnapToGrid(oI(e)),()=>d().snapToGrid),setFitText:l("setFitText",e=>r.setFitText(aI(e)),()=>d().fitText),setBaselineShift:l("setBaselineShift",e=>r.setBaselineShift(aI(e)),()=>d().baselineShift),setEmphasisMark:l("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:l("setTextEffect",e=>r.setTextEffect(e||null),()=>d().textEffect),setKerning:l("setKerning",e=>r.setKerning(aI(e)),()=>d().kerningThreshold),setLigatures:l("setLigatures",e=>r.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:l("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:l("setNumberForm",e=>r.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:l("setStylisticSet",e=>r.setStylisticSet(aI(e)),()=>d().stylisticSet)}}function sI({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const s=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(s().link),isActive:Boolean(s().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 lI({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(oI(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(aI(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(aI(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(oI(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(rI(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(rI(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(oI(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(oI(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(oI(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(oI(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(oI(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(oI(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(oI(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(oI(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(oI(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(oI(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(oI(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(oI(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(oI(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(oI(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(aI(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(aI(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(aI(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(aI(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",aI(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(aI(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(aI(e))),setListLevel:r("setListLevel",e=>t.setListLevel(aI(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=Gt(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 cI({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 dI({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 uI({fields:e,actionCommand:t}){return{updateBodyFields:t("updateBodyFields",()=>{e.updateBodyFields?.()},()=>({isEnabled:!!e.updateBodyFields&&(e.canUpdateBodyFields?.()??!0)})),updateSelectedFields:t("updateSelectedFields",()=>{e.updateSelectedFields?.()},()=>({isEnabled:!!e.updateSelectedFields&&(e.canUpdateBodyFields?.()??!0)})),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 pI({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(oI(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(oI(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(oI(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(oI(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(aI(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(aI(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(rI(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 gI({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 fI({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",t=>{const n="number"==typeof t&&Number.isFinite(t)?t:void 0;e.openParagraphDialog(n)})}}var mI=/* @__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"]),hI=/* @__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"]),bI=/* @__PURE__ */new WeakMap;function yI(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!hI.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=bI.get(n);r||(r=/* @__PURE__ */new WeakMap,bI.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==ki(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((mI.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function vI(e){return{state:()=>e.styleController.toolbarStyleState()}}function xI(e){return{isCollapsed:()=>Ia(e.state().selection)}}function wI(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var SI={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function II(e){return/\p{L}|\p{N}/u.test(e)}function CI(e){return"."===e||"!"===e||"?"===e}function TI(e,t){return Dr(e,t)}function kI(e,t,n,o){return e-n||t-o}function PI(e,t){const n=ma(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:TI(o,t.startOffset),focus:TI(r,t.endOffset)}}:e}function RI(e,t,n){if(!t.length)return null;const o=ma(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?Qr(e,o).end:Qr(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const s=o[i],l=$r(s,a);return("next"===n?t.find(e=>kI(e.startIndex,e.startOffset,i,l)>0):[...t].reverse().find(e=>kI(e.startIndex,e.startOffset,i,l)<0))??("next"===n?t[0]:t[t.length-1])}function BI(e){const t=ma(e),n=[],o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(const a of[...Wv(e),...Uv(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 MI(e,t){const n=RI(e,BI(e),t);return n?PI(e,n):e}function OI(e){const t=ma(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),s=n.get(e.end.paragraphId);if(void 0===i||void 0===s)continue;const l=t[i],c=t[s],d=Math.max(0,Math.min(e.start.offset,l.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)));kI(i,d,s,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:s,endOffset:u})}return r.sort((e,t)=>kI(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function AI(e,t){const n=RI(e,OI(e),t);return n?PI(e,n):e}function FI(e){const t=OI(e);if(!t.length)return null;const n=Qr(e),o=t.find(e=>0===kI(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===kI(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>kI(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&kI(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function DI(e,t){const n=BI(e).find(e=>e.id===t);return n?PI(e,n):e}function EI(e){const t=ir(e);if(t.error||"TOC"!==t.command)return;const n=t.tokens.slice(1);let o,r,a,i=!1,s=!1,l=!1;const c=/* @__PURE__ */new Set;for(let d=0;d<n.length;d++){const e=n[d];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(c.has(t))return;if(c.add(t),"o"===t){const e=n[++d];if("quoted"!==e?.kind)return;const t=/^([1-9])-([1-9])$/.exec(e.value);if(!t)return;if(o=Number(t[1]),r=Number(t[2]),o>r)return}else if("t"===t){const e=n[++d];if("quoted"!==e?.kind||e.value.length>4096||/[\r\n\t\\]/.test(e.value))return;const t=e.value.split(",").map(e=>e.trim());if(t.length<2||t.length%2||t.length>128)return;const o=/* @__PURE__ */new Set,r=[];for(let n=0;n<t.length;n+=2){const e=t[n],a=t[n+1],i=e.toLowerCase();if(!e||e.length>256||!/^[1-9]$/.test(a)||o.has(i))return;o.add(i),r.push({name:e,level:Number(a)})}a=r}else if("h"===t)i=!0;else if("z"===t)s=!0;else{if("u"!==t)return;l=!0}}if(void 0===o||void 0===r){if(!a||l)return;return{startLevel:1,endLevel:Math.max(...a.map(e=>e.level)),hyperlinks:i,hideWebNumbers:s,useOutline:l,styleMappings:a,customOnly:!0}}return{startLevel:o,endLevel:r,hyperlinks:i,hideWebNumbers:s,useOutline:l,...a?{styleMappings:a}:{}}}function LI(e){return!e.sdtWrappers?.length&&!e.numberingRevision&&!e.dropCap&&e.runs.every(e=>!(e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.hidden||e.styles?.rtl))}function NI(e){if(!LI(e)||e.list||e.dropCap||1!==e.runs.length)return!1;const t=e.runs[0];return"text"===t.kind&&t.text.length<=8192&&t.text.includes("\t")&&!/[\r\n]/.test(t.text)}function zI(e){const t=[];for(let n=0;n<e.length;){if("paragraph"!==e[n]?.type){n++;continue}const o=n,r=[];for(;n<e.length&&"paragraph"===e[n]?.type;)r.push(e[n]),n++;const a=cr(r);if(!a.diagnostics.length)for(const e of a.spans){if(null!==e.parentIndex||!e.separator||!e.end||e.beginMarker.fieldLock||e.beginMarker.dirty||e.code.some(e=>"instruction"!==e.kind)||e.begin.paragraphIndex!==e.separator.paragraphIndex||e.begin.paragraphIndex>=e.end.paragraphIndex)continue;const n=r[e.begin.paragraphIndex],a=r[e.end.paragraphIndex];if(!LI(n)||!LI(a)||0!==e.begin.runIndex||e.separator.runIndex!==n.runs.length-1||0!==e.end.runIndex||1!==a.runs.length||"fieldChar"!==n.runs[0]?.kind||"fieldChar"!==n.runs.at(-1)?.kind||"fieldChar"!==a.runs[0]?.kind)continue;const i=EI(e.code.map(e=>"instruction"===e.kind?e.raw:"").join(""));if(!i)continue;const s=e.begin.paragraphIndex,l=e.end.paragraphIndex;r.slice(s+1,l).every(NI)&&(e.result.length!==l-s-1||e.result.some((e,t)=>"run"!==e.kind||e.point.paragraphIndex!==s+t+1)||t.push({...i,startBlockIndex:o+s,endBlockIndex:o+l}))}}return 1===t.length?t[0]:void 0}function $I(e,t){const n=F(e,t),o=Ta(e),r=/* @__PURE__ */new Map;return o.forEach((e,t)=>{for(const n of e.blocks)"paragraph"===n.type&&r.set(n.id,r.has(n.id)?null:t)}),e=>{const t=r.get(e);if(null==t)return;const a=o[t],i=n.pageIndexAt(e,0);if(void 0===i)return;const s=n.forPage(i);return s.sectionNumber===t+1&&void 0!==s.pageNumber?Er(s.pageNumber,a.pageNumbering?.format):void 0}}var HI=e=>` TOC \\o "1-${e}" \\h \\z \\u `,WI=e=>Math.round(e/ii*96);function UI(e,t=3){const n=[];for(const o of Qo(e.document)){const e=ye(o.style?.styleId);if(null===e||e>t)continue;const r=Ko(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function jI(e,t,n=9){if(n<t.endLevel||t.styleMappings?.some(e=>e.level>n))return;if(!t.styleMappings)return UI(e,t.endLevel).filter(e=>e.level>=t.startLevel);const o=Object.values(e.document.styles??{}),r=e=>e.trim().toLowerCase(),a=/* @__PURE__ */new Map;for(const{name:l,level:c}of t.styleMappings){const e=r(l),t=o.filter(t=>r(t.id)===e||r(t.name)===e);if(1!==t.length||"paragraph"!==t[0].type)return;const n=t[0].id;if(a.has(n))return;a.set(n,c)}const i=/* @__PURE__ */new Set;for(const l of Ta(e.document)){const e=zI(l.blocks);if(e)for(const t of l.blocks.slice(e.startBlockIndex,e.endBlockIndex+1))i.add(t.id)}const s=[];for(const l of Qo(e.document)){const e=l.style?.styleId,n=void 0===e?void 0:a.get(e),o=t.customOnly?null:ye(e),r=null!==o&&o>=t.startLevel&&o<=t.endLevel?o:void 0;if(void 0!==n&&void 0!==r&&n!==r)return;const c=n??r;if(void 0===c)continue;if(i.has(l.id))return;const d=Ko(l).trim();d&&s.push({id:l.id,level:c,text:d})}return s}function VI(e){const t=Ar(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 KI(e,t){const n=Go("");return n.runs=e,t&&(n.style=t),n}function _I(e,t,n){const o=void 0!==t?String(t):"";return KI([VI({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:WI(40),indentLeft:WI(397*(e.level-1))})}function XI(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return In(o*xa,2)}function GI(e){return KI([VI({text:"",fieldChar:{kind:"begin"}}),VI({text:"",fieldInstruction:HI(e)}),VI({text:"",fieldChar:{kind:"separate"}})])}function qI(e,t,n,o){const r=Ta(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:Y(Dr(o,0))}}function YI(e,t=()=>{},n=3){if("main"!==Da(e)||!Number.isInteger(n)||n<1||n>9)return e;const o=Ka(e),r=Ta(e.document)[o];if(!r)return e;const a=function(e,t,n,o){const r=e.map(e=>{const o=t(e.id);return _I(e,void 0!==o&&Hr(o)?o:void 0,n)});return[GI(o),...r,KI([VI({text:"",fieldChar:{kind:"end"}})])]}(UI(e,n),t,XI(r),n),i=ca(e,e.selection.focus),s=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&Uo(e).some(e=>e.id===i.paragraphId)),l=-1===s?r.blocks.length:s+1;return qI(e,o,[...r.blocks.slice(0,l),...a,...r.blocks.slice(l)],a[0])}var ZI=zI;function JI(e,t=()=>{},n=9){if("main"!==Da(e)||!Number.isInteger(n)||n<1||n>9)return e;const o=Ka(e),r=Ta(e.document)[o];if(!r)return e;const a=ZI(r.blocks);if(!a||n<a.endLevel)return e;const i=jI(e,a,n);if(!i)return e;const s=new Map(Qo(e.document).map(e=>[e.id,e]));if(i.some(e=>{const t=s.get(e.id);return!t||t.sdtWrappers?.length||t.numberingRevision||t.dropCap||t.runs.some(e=>"text"!==e.kind||e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.hidden||e.styles?.rtl)||e.text.length>4096||/[\r\n\t]/.test(e.text)}))return e;const l=r.blocks.slice(a.startBlockIndex+1,a.endBlockIndex),c=i.map(e=>t(e.id));if(c.some(e=>void 0!==e&&!Hr(e)))return e;if(c.some(e=>void 0===e)&&l.some(e=>"paragraph"===e.type&&/\t\S/.test(Ko(e))))return e;const d=i.map((e,t)=>_I(e,c[t],XI(r)));return l.length===d.length&&l.every((e,t)=>"paragraph"===e.type&&Ko(e)===Ko(d[t]))?e:qI(e,o,[...r.blocks.slice(0,a.startBlockIndex+1),...d,...r.blocks.slice(a.endBlockIndex)],d[0]??r.blocks[a.startBlockIndex])}function QI(e,t=p,n=6,o=9){const r=(t,n,o)=>({state:e,layout:o,status:t,passes:n,updatedEntries:0});if("main"!==Da(e)||e.trackChangesEnabled||!Number.isSafeInteger(n)||n<1||!Number.isSafeInteger(o)||o<1||o>9)return r("unsupported",0);const a=Math.min(n,6),i=Ka(e),s=Ta(e.document)[i];if(!s)return r("unsupported",0);const l=zI(s.blocks);if(!l||o<l.endLevel)return r("unsupported",0);const c=s.blocks[l.startBlockIndex].id,d=s.blocks[l.endBlockIndex].id,u=new Set(s.blocks.slice(l.startBlockIndex+1,l.endBlockIndex).map(e=>e.id)),g=jI(e,l,o);if(!g||g.length>2048)return r("unsupported",0);const f=JSON.stringify(g.map(e=>[e.id,e.level,e.text])),m=/* @__PURE__ */new Set;let h,b=e;for(let p=1;p<=a;p++){let n;try{n=t(b.document)}catch{return r("unsupported",p,h)}h??=n;const a=Ta(b.document)[i]?.blocks,s=a&&zI(a);if(!a||!s||a[s.startBlockIndex]?.id!==c||a[s.endBlockIndex]?.id!==d)return r("unsupported",p,h);const l=jI(b,s,o);if(!l||JSON.stringify(l.map(e=>[e.id,e.level,e.text]))!==f)return r("unsupported",p,h);const g=$I(b.document,n),y=l.map(e=>g(e.id));if(y.some(e=>void 0===e))return r("unresolved",p,h);const v=JI(b,g,o);if(v===b){const t=a.slice(s.startBlockIndex+1,s.endBlockIndex);return t.length!==l.length||t.some((e,t)=>"paragraph"!==e.type||Ko(e)!==`${l[t].text}\t${y[t]}`)?r("unsupported",p,h):{state:b===e?e:{...b,selection:e.selection},layout:n,status:b===e?"unchanged":"updated",passes:p,updatedEntries:b===e?0:l.length}}if(u.has(e.selection.anchor.paragraphId)||u.has(e.selection.focus.paragraphId))return r("unsupported",p,h);const x=JSON.stringify([l.map((e,t)=>[e.id,e.text,y[t]]),n.pages.map(e=>[e.index,e.sectionIndex])]);if(m.has(x))return r("nonconvergent",p,h);m.add(x),b={...v,selection:e.selection}}return r("nonconvergent",a,h)}function eC(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?Qt(n):11,r="increase"===t?On(o):xt(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",_n(r)),!0};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=Qo(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:Dr(n,0),focus:Dr(o,Ko(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=oe(e),o=Ko(t);let r=n,a=n;for(;r>0&&II(o[r-1]);)r-=1;for(;a<o.length&&II(o[a]);)a+=1;return Ii(e,{anchor:Dr(t,r),focus:Dr(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=oe(e),o=Ko(t);let r=n;for(;r>0&&!CI(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!CI(o[a]);)a+=1;return a<o.length&&(a+=1),Ii(e,{anchor:Dr(t,r),focus:Dr(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=ma(e),n=Qr(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Ii(e,{anchor:Dr(o,0),focus:Dr(r,bi(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=ma(e),a=Qa(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Ii(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=fw(e.document,t)[Math.max(1,n)-1];return o?Ii(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 Ii(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=>qu(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){if(me(e))return e;const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(n),i=Zn(o,a),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},l=xe(o,a,[s]),c=ma(n).map((e,t)=>t===r?l:e);return Sn(n,c,Y(Dr(l,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=ma(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?Sn(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){if("main"!==Da(e))return!1;const t=Ta(e.document)[Ka(e)];return!!t&&void 0!==ZI(t.blocks)}(e.state()),hasRevisionsInSelection:()=>AS(e.state()).size>0,hasRevisionsInDocument:()=>DS(e.state()),hasNavigableRevisions:()=>BI(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),OI(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=MI(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=MI(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=AI(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=AI(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==FI(e.state()),isSelectedCommentResolved:()=>Boolean(FI(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=>{const t=YI(e);if(t===e)return e;const n=QI(t);return"updated"===n.status||"unchanged"===n.status?n.state:t}),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>QI(e).state),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=>mw(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:cg}),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:Vv(e,"insertions"),deletions:Vv(e,"deletions"),comments:Vv(e,"comments"),formatting:Vv(e,"formatting"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Jv(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:()=>(Io(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>wo(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>qu(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Yu(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>cn(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return qu(e,SI[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=>rp(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>rp(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>Ia(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 tC(e,t){const n=vx(e),o=n&&Ua(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=ma(e).map((e,n)=>n!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}function nC(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 oC(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*pa),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*pa)}}}function rC(e,t){const n=ki(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=ma(e).map((e,t)=>t!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id!==a.id?Cr(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}function aC(e,t,n=90){return iC(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 iC(e,t){const n=vx(e);if(!n||!Ua(n.run))return e;const{paragraphIndex:o,run:r}=n,a=ma(e).map((e,n)=>n!==o?tr(e):{...tr(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Cr(e))});return Sn(e,a,z(a,Qr(e)))}function sC(e,t){return iC(e,e=>({...e,body:t(e.body??{})}))}var lC={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 cC(e,t=!0){const n=Ue(e)??(t?ux(e):void 0);return n?lC[n]:void 0}function dC(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of Qo(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=Tr(e.id,n),a="table"===e.type?sa(e.id,n).tableStyle:void 0,i=a?.conditionalFormats?.wholeTable,s=a?.conditionalFormats?.firstRow,l=a?.conditionalFormats?.band1Horz,c=i?.borders?.borderBottom??a?.borders?.borderBottom;return{id:e.id,name:e.name,labelKey:cC(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:s?.shading,bandFill:l?.shading,borderColor:c?.color,headerColor:s?.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:()=>hm(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=at(t),o=mr(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return Vu(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=Ia(e.selection)?e:Q(e),{paragraph:a,offset:i}=oe(r),s=rn(a,0,i),l=rn(a,i,bi(a)),c=Go(""),d={...a,runs:s.length?s:Go("").runs},u={...a,id:c.id,runs:l.length?l:c.runs},p=[...i>0?[d]:[],...o,...l.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=mr(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||l.length?Dr(u,0):Dr(b,bi(b));return{...r,document:h,selection:Y(y)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(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),s={width:150,height:100,blocks:[Go("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:iv(void 0,"front")},l=er("",Zn(o,a),void 0,s),c=xe(o,a,[l]),d=ma(n).map((e,t)=>t===r?c:tr(e));return Sn(n,d,Y(Dr(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return tC(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:Xg}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,tC(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Gg}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return tC(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:qg}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=ma(e).map((e,n)=>n!==o?tr(e):{...tr(e),runs:e.runs.map(e=>e.id!==r.id?Cr(e):"image"===e.kind?{...e,image:{...e.image,floating:nC(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:nC(e.textBox.floating,t)}}:Cr(e))});return Sn(e,a,z(a,Qr(e)))}(e,t),{mergeKey:Yg}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(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=ma(e).map((e,t)=>t!==o?tr(e):{...tr(e),runs:e.runs.map(e=>e.id!==r.id?Cr(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)}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}(e,t),{mergeKey:Zg}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=ki(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=ma(e).map((e,o)=>o!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id!==a.id?Cr(e):"image"===e.kind?{...e,image:{...e.image,floating:oC(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:oC(e.textBox.floating,t,n)}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}(e,t,n),{mergeKey:Jg}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=ma(e).map((e,n)=>n!==o?tr(e):{...tr(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Cr(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?lv(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?lv(n,t):n}}}return Cr(e)})});return Sn(e,a,z(a,Qr(e)))}(e,t),{mergeKey:Qg}),setFloatingRotation:t=>e.applyTransactionalState(e=>rC(e,t),{mergeKey:ef}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>iv(e,t),{paragraphIndex:r,run:a}=n,i=ma(e).map((e,t)=>t!==r?tr(e):{...tr(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Cr(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 Cr(e)})});return Sn(e,i,z(i,Qr(e)))}(e,t),{mergeKey:tf}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(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=ma(e).map((e,t)=>t!==r?tr(e):{...tr(e),runs:e.runs.map(e=>e.id!==a.id?Cr(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)}}:Cr(e))});return Sn(e,i,z(i,Qr(e)))}(e,t),{mergeKey:nf}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=ki(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:s,run:l}=n,c=ma(e).map((e,t)=>t!==s?tr(e):{...tr(e),runs:e.runs.map(e=>{if(e.id!==l.id)return Cr(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 Cr(e)})});return Sn(e,c,z(c,Qr(e)))}(e,t),{mergeKey:of}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return tC(e,e=>({...e,preset:t}))}(e,t),{mergeKey:rf}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return sC(e,e=>({...e,vert:n}))}(e,t),{mergeKey:af}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return sC(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:sf}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return iC(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:lf}),rotateTextBox:t=>e.applyTransactionalState(e=>aC(e,t),{mergeKey:cf}),getTextBoxSizeCm:()=>function(e){const t=vx(e),n=t&&Ua(t.run);return n?{width:n.width/ha,height:n.height/ha}:null}(e.state()),isTextBoxSelected:()=>null!==vx(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return iC(e,e=>({...e,width:Math.max(24,Math.round(t*ha))}))}(e,t),{mergeKey:df}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return iC(e,e=>({...e,height:Math.max(24,Math.round(t*ha))}))}(e,t),{mergeKey:uf})}}function uC(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!Ia(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function pC(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=dv(e),n=t&&Ya(t.run);return n?{width:n.width/ha,height:n.height/ha}: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=dv(e);return(t&&Ya(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=dv(e);return(t&&Ya(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=dv(e),n=t&&Ya(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==dv(e.state())}}function gC(e){const t=e.clipboardActions??yp({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 fC(e,t){const n=Da(e),o=Ta(e.document);if("header"===n||"footer"===n){const r=Ka(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",s=ta(a,n,i,t),l=[...o];return l[r]=s,{...e,document:{...e.document,sections:l}}}if("main"===n){const n=Ka(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 mC(e,t){return null!==bC(e,t)}function hC(e,t){const n=bC(e,t);if(!n)return e;const{nextBlocks:o}=n,r=fC(e,o),a=o.flatMap(Uo);return{...r,selection:yC(e.selection,a)}}function bC(e,t){const n=Da(e);if("footnote"===n)return null;const o=va(e,n);if(0===o.length)return null;const r=Qr(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let s=n;s<=o;s+=1){const e=t[s];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 s=a;s<=i;s+=1)if("paragraph"!==e[s].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{Uo(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:s}=a,l=o.slice(i,s+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),...l,e,...o.slice(s+1)]}else{if(s===o.length-1)return null;const e=o[s+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...l,...o.slice(s+2)]}return{nextBlocks:c}}function yC(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 Dr(r,Math.min(e.offset,bi(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function vC(e,t){const n=function(e){const t=Da(e);if("footnote"===t)return null;const n=va(e,t);if(0===n.length)return null;const o=Qr(e),r=/* @__PURE__ */new Set;for(let s=o.startIndex;s<=o.endIndex;s+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=Uo(n[o]).length;if(s<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 s=a;s<=i;s+=1)if("paragraph"!==n[s].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:xC(Ko(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 s=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],l=fC(e,s),c=s.flatMap(Uo);return{...l,selection:wC(e.selection,c)}}function xC(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function wC(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 Dr(r,Math.min(e.offset,bi(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function SC(e,t){const n=Qr(e),o=ma(e);let r=1;for(let s=0;s<n.startIndex;s+=1){const e=ye(o[s]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return tr(e);const i=ye(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?tr(e):(a=!0,E(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return tr(e);a=!0;const o=tr(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return tr(e);a=!0;const s=tr(e);return s.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},s});return a?Sn(e,i,z(i,n)):e}var IC=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];var CC=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var TC=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var kC={width:1.5,type:"solid",color:"#000000"};function PC(e,t){const n=t.text??Ko(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 RC(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=Qr(e),o=ma(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 CC.has(t)?t:a})();if(a===i)return e;r=!0;const s=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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:TC.has(t)?t:a;if(a===i)return e;r=!0;const s=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...tr(e),style:s}});return r?Sn(e,a,z(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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 s=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...tr(e),style:s}});return r?Sn(e,a,z(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=ie(e,"indentFirstLine",null);return n=ie(n,"indentHanging",null),"firstLine"===t?n=ie(n,"indentFirstLine",o):"hanging"===t&&(n=ie(n,"indentHanging",o)),n},{mergeKey:rg}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=ie(e,"borderTop",t);return n=ie(n,"borderRight",t),n=ie(n,"borderBottom",t),n=ie(n,"borderLeft",t),n},{mergeKey:ag}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>ie(e,"borderBottom",kC),{mergeKey:ag}),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=Qr(e),o=Math.min(8,Math.max(0,Math.round(t))),r=ma(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,E(e,o)):e);return a?Sn(e,i,z(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>VS(e,-1)),e.focusInput()},indent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>VS(e,1)),e.focusInput()},moveParagraphsUp:()=>{mC(e.state(),"up")?(e.applyTransactionalState(e=>hC(e,"up"),{mergeKey:ig}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{mC(e.state(),"down")?(e.applyTransactionalState(e=>hC(e,"down"),{mergeKey:sg}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>mC(e.state(),"up"),canMoveParagraphsDown:()=>mC(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>SC(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>SC(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=Qr(e),n=ma(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||IC.every(e=>!(e in r)))return e;o=!0;const a=tr(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?Sn(e,r,z(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.resetTransactionGrouping(),e.applyTransactionalState(e=>$n(e,t),{mergeKey:ug}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Qr(e),o=ma(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=tr(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?Sn(e,i,z(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return ie(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>vC(e,t)),hasDropCap:()=>function(e){const t=Qr(e);return ma(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=Qr(e),o=ma(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,s=o.map((e,n)=>n<r||n>a?tr(e):i?{...tr(e),dropCap:void 0}:{...tr(e),dropCap:PC(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Sn(e,s,z(s,n))}(e,t)),e.focusInput()}}}function BC(e){const t=Ta(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Ka(e),t.length-1))}}function MC(e,t){const{sections:n,sectionIndex:o}=BC(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 OC(e,t,n="default"){const o=ai(t,n);return MC(e,e=>e[o]?e:{...e,[o]:[ka(t)]})}function AC(e,t,n="default"){const o=ai(t,n),r=MC(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:Da(r)===t?LC(r):r}function FC(e,t,n="default"){const o=OC(e,t,n),{sections:r,sectionIndex:a}=BC(o),i=(r[a][ai(t,n)]??[]).flatMap(Uo).find(Boolean);return i?{...o,selection:Na(Dr(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function DC(e){const{sections:t,sectionIndex:n}=BC(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function EC(e){const{sections:t,sectionIndex:n}=BC(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function LC(e){const{sections:t,sectionIndex:n}=BC(e),o=(t[n]?.blocks??[]).flatMap(Uo).find(Boolean);return o?{...e,selection:Na(Dr(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function NC(e){return function(e,t){const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(n),i=rn(o,0,a),s=rn(o,a,bi(o)),l={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Zn(o,a)},c=d(o,[...i,l,...s]),u=ma(n),p=[...fr(u.slice(0,r)),c,...fr(u.slice(r+1))];return Sn(n,p,Y(Dr(c,a+l.text.length)))}(e,"PAGE")}function zC(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function $C(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of-prefix:${n}`,text:"Page ",kind:"text"},zC("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of-separator:${n}`,text:" of ",kind:"text"},zC("NUMPAGES",void 0,`run:numpages-field:${n}`,t)]:[zC("PAGE",void 0,`run:page-field:${n}`,t)]}function HC(e,t="page",n){return function(e,t){const n=Ia(e.selection)?e:Q(e),{paragraph:o,index:r,offset:a}=oe(n),i=Zn(o,a),s=t.map((e,t)=>e.styles?e:{...e,styles:i,id:`${e.id}:${t}`}),l=d(o,[...rn(o,0,a),...s,...rn(o,a,bi(o))]),c=ma(n),u=[...fr(c.slice(0,r)),l,...fr(c.slice(r+1))],p=s.reduce((e,t)=>e+t.text.length,0);return Sn(n,u,Y(Dr(l,a+p)))}(e,$C(t,n))}function WC(e){const t=Ta(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Ka(e),t.length-1))}}function UC(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return HC(e,o,r);const i="top"===t?"header":"footer",s=ai(i,"default"),{sections:l,sectionIndex:c}=WC(e);if(0===l.length)return e;const d={id:Rr("paragraph"),type:"paragraph",runs:$C(o,r),style:{styleId:i,align:a}},u={...l[c],[s]:[d]},p=[...l];return p[c]=u,{...e,document:{...e.document,sections:p},selection:Na(Dr(d,0)),activeSectionIndex:c,activeZone:i}}function jC(e){const t={isLandscape:()=>{const t=Ka(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=Ka(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=Ka(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=Ka(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=Ka(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=>mt(e,t)),e.focusInput()},getPageNumbering:()=>{const t=Ka(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=WC(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 i(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>vn(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ko(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>Ce(e,t)),e.focusInput()},getColumns:()=>Nn(e.state()),setColumns:t=>{e.applyTransactionalState(e=>Oo(e,t)),e.focusInput()},getVerticalAlign:()=>rt(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>g(e,t)),e.focusInput()},getSectionStart:()=>{const t=Ka(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=Ka(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>Ut(e.state()),setBidi:t=>{e.applyTransactionalState(e=>ho(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 VC(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>FC(e,"header")),editFooter:()=>t(e=>FC(e,"footer")),editFirstPageHeader:()=>t(e=>FC(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>FC(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>FC(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>FC(e,"footer","evenPage")),insertPageNumber:()=>t(e=>NC(e)),insertPageNumberXOfY:()=>t(e=>HC(e,"xOfY")),placePageNumberTop:()=>t(e=>UC(e,"top")),placePageNumberBottom:()=>t(e=>UC(e,"bottom")),exit:()=>t(e=>function(e){return LC(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>DC(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(DC(e)===t)return e;let n=e;return t?(n=OC(n,"header","firstPage"),n=OC(n,"footer","firstPage"),n):(n=AC(n,"header","firstPage"),AC(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>EC(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(EC(e)===t)return e;let n=e;return t?(n=OC(n,"header","evenPage"),n=OC(n,"footer","evenPage"),n):(n=AC(n,"header","evenPage"),AC(n,"footer","evenPage"))}(t,e))}}function KC(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function _C(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=Qr(e),a=e.document.bookmarks,i=a?.order??[],s=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,l={id:hi(),name:s,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[l.id]:l},order:[...i,l.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:()=>KC(e.state()).map(e=>({id:e.id,name:e.name}))}}var XC=["January","February","March","April","May","June","July","August","September","October","November","December"],GC=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function qC(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 s=e.getHours();switch(t){case"d":n+=i.length>=4?GC[e.getDay()]:3===i.length?GC[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?XC[e.getMonth()]:3===i.length?XC[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(s);break;case"h":n+=i.length>=2?o(s%12==0?12:s%12):String(s%12==0?12:s%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+=s<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}var YC=e=>p(e,void 0,void 0,void 0,{cachedBodyPageFields:!0});function ZC(e,t){const n=t.get(e.paragraphId);if(!n)return e;let o=0;for(const r of n.edits){if(e.offset<=r.start)break;if(e.offset<r.end)throw Error("interior anchor must be rejected before mapping");o+=r.text.length-(r.end-r.start)}return o?{...e,offset:e.offset+o}:e}function JC(e,t){if(!e)return e;let n=!1;const o={...e.items};for(const[r,a]of Object.entries(o)){const e=a.start?ZC(a.start,t):void 0,i=a.end?ZC(a.end,t):void 0;e===a.start&&i===a.end||(o[r]={...a,start:e,end:i},n=!0)}return n?{...e,items:o}:e}function QC(e,t,n){const o=t.get(e.paragraphId)?.edits.find(t=>t.runId===e.runId);if(!o)return e;const r=e.offset===o.end-o.start?o.text.length:"selection"===n?Math.min(e.offset,o.text.length):e.offset;return r===e.offset?e:{...e,offset:r}}function eT(e){return!e.list&&!e.dropCap&&!e.sdtWrappers?.length&&!e.numberingRevision&&!e.style?.bidi&&(!e.style?.textDirection||"lrTb"===e.style.textDirection)&&e.runs.every(N)&&new Set(e.runs.map(e=>e.id)).size===e.runs.length}function tT(e){const t=/* @__PURE__ */new Map;for(const n of[e.document.bookmarks,e.document.comments])for(const e of Object.values(n?.items??{}))for(const n of[e.start,e.end]){if(!n)continue;const e=t.get(n.paragraphId)??[];e.push(n.offset),t.set(n.paragraphId,e)}return t}function nT(e,t=YC,n="all",o){const r=o||e.document.coreTimestamps?{...e.document.coreTimestamps,...o}:void 0,a=t(e.document),i=(t,n)=>({state:e,layout:a,status:t,passes:n,updatedFields:0}),s=Ta(e.document),l=s.flatMap(e=>e.blocks);if(e.trackChangesEnabled||"main"!==Da(e)||Object.keys(e.document.footnotes?.items??{}).length||Object.keys(e.document.endnotes?.items??{}).length||s.some((e,t)=>t>0&&e.breakType&&"nextPage"!==e.breakType)||l.some(e=>"paragraph"!==e.type)||new Set(l.map(e=>e.id)).size!==l.length)return i("unsupported",0);let c=/* @__PURE__ */new Map;if($e(l,c),"selection"===n&&(c=function(e,t,n){const o=e=>{const n=t.findIndex(t=>t.id===e.paragraphId);if(n<0)return;const o=t[n],r=o.runs.findIndex(t=>t.id===e.runId);return r<0||!Number.isInteger(e.offset)||e.offset<0||e.offset>o.runs[r].text.length?void 0:{index:n,runIndex:r,offset:o.runs.slice(0,r).reduce((e,t)=>e+t.text.length,0)+e.offset,affinity:e.fieldBoundaryAffinity}},r=o(e.selection.anchor),a=o(e.selection.focus),i=/* @__PURE__ */new Map;if(!r||!a)return i;const[s,l]=r.index<a.index||r.index===a.index&&r.offset<=a.offset?[r,a]:[a,r],c=s.index===l.index&&s.offset===l.offset;if(c&&(r.runIndex!==a.runIndex||r.affinity!==a.affinity))return i;for(let d=s.index;d<=l.index;d++){const e=t[d],o=n.get(e.id);if(!o)continue;let r=0;const a=e.runs.map(e=>{const t=r;return r+=e.text.length,t}),u=o.filter(t=>{const n=a[t.runIndex],o=n+e.runs[t.runIndex].text.length;return n!==o&&(c?!("before-markers"===s.affinity&&s.offset===n||"after-markers"===s.affinity&&s.offset===o)&&(s.offset>n&&s.offset<o||s.runIndex===t.runIndex&&s.offset>=n&&s.offset<=o):n<(d===l.index?l.offset:r)&&o>(d===s.index?s.offset:0))});u.length&&i.set(e.id,u)}return i}(e,l,c)),!c.size)return i("unchanged",0);const d=ri(e.document);let u=e,p=a;const g=/* @__PURE__ */new Set,f=/* @__PURE__ */new Set;for(let m=1;m<=6;m++){const o=F(u.document,p),a=Le(u.document,p),s=Ta(u.document),l=tT(u),h=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(const e of p.pages)for(const t of e.blocks){if("paragraph"!==t.sourceBlock.type||!t.layout)continue;const n=t.sourceBlock.id,o=t.layout.startOffset??0,r=t.layout.endOffset??o+t.layout.text.length;o!==(b.get(n)??0)||r<o||r-o!==t.layout.text.length||r>bi(t.sourceBlock)?h.set(n,null):(b.set(n,r),h.has(n)?h.get(n)!==e.index&&h.set(n,null):h.set(n,e.index))}const y=/* @__PURE__ */new Map,v=/* @__PURE__ */new Set,x=[];for(const e of s)for(const t of e.blocks){if("paragraph"!==t.type||!eT(t))continue;const i=c.get(t.id),p=h.get(t.id);if(!i||null==p||b.get(t.id)!==bi(t))continue;const f=o.forPage(p),m=[];let w=0;for(const e of t.runs)m.push(w),w+=e.text.length;for(const{runIndex:o,field:c}of i){const i=t.runs[o],h=JSON.stringify([t.id,o]);if(x.push(JSON.stringify([h,i.text,p])),"PAGE"===c.type&&!c.format&&e.pageNumbering?.format&&"decimal"!==e.pageNumbering.format)continue;if("PAGEREF"===c.type&&s.some(e=>e.pageNumbering?.format&&"decimal"!==e.pageNumbering.format))continue;const b=i.styles?.language?.value?.toLowerCase(),S="pt-br"===b?"pt-BR":b?.startsWith("en")?"en-US":r?.locale,I=$a(c,{...f,styleRefText:(e,n,r)=>a.forBody(t.id,e,n,{output:r,offset:m[o],locale:"pt-BR"===S?"pt-BR":"en-US"}),sequenceValue:d.get(mi(t.id,o)),documentVariables:u.document.documentVariables,documentProperties:u.document.documentProperties,temporal:r?{...r,locale:S}:void 0},i.text),C=m[o],T=C+i.text.length;if("resolved"!==I.status||!I.text.length||I.text.length>65536||!i.text.length||/[\r\n\t]/.test(I.text)||Array.from(I.text).length!==I.text.length)continue;if(I.text!==i.text&&((l.get(t.id)??[]).some(e=>!Number.isInteger(e)||e<0||e>w||e>C&&e<T)||"all"===n&&[u.selection.anchor,u.selection.focus].some(e=>e.paragraphId===t.id&&e.runId===i.id&&0!==e.offset&&e.offset!==i.text.length)))continue;if(v.add(h),I.text===i.text)continue;const k=y.get(t.id)??{paragraph:t,edits:[]};k.edits.push({runIndex:o,runId:i.id,start:C,end:T,text:I.text}),y.set(t.id,k),g.add(h)}}if([...g].some(e=>!v.has(e)))return i("nonconvergent",m);if(!y.size)return{state:u,layout:p,status:u===e?"unchanged":"updated",passes:m,updatedFields:g.size};const w=JSON.stringify([p.pages.length,x]);if(f.has(w))return i("nonconvergent",m);f.add(w);for(const e of y.values())e.edits.sort((e,t)=>e.start-t.start);const S={...u.document,sections:s.map(e=>({...e,blocks:e.blocks.map(e=>{const t=y.get(e.id);if("paragraph"!==e.type||!t)return e;const n=new Map(t.edits.map(e=>[e.runIndex,e.text]));return{...e,runs:e.runs.map((e,t)=>n.has(t)?{...e,text:n.get(t)}:e)}})})),bookmarks:JC(u.document.bookmarks,y),comments:JC(u.document.comments,y)};u={...u,document:S,selection:{anchor:QC(u.selection.anchor,y,n),focus:QC(u.selection.focus,y,n)}},p=t(S)}return i("nonconvergent",6)}function oT(e,t){const n=t.type??"REF",o=function(e,t){return KC(e).find(e=>e.name===t)}(e,t.bookmark);if(!o)return e;const r=Ia(e.selection)?e:Q(e),{paragraph:a,index:i,offset:s}=oe(r),l=Zn(a,s),c={type:n,bookmark:t.bookmark},u="REF"===n?F(e.document).bookmarkText(o.name):void 0,p={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:u&&!/[\r\n]/.test(u)?u:"1",kind:"field",field:c,styles:l},g=d(a,[...rn(a,0,s),p,...rn(a,s,bi(a))]),f=ma(r),m=[...fr(f.slice(0,i)),g,...fr(f.slice(i+1))];return Sn(r,m,Y(Dr(g,s+p.text.length)))}function rT(e){const t=()=>!e.isReadOnly()&&"main"===Da(e.state())&&!e.state().trackChangesEnabled,n=n=>{if(!t())return;e.resetTransactionGrouping();const o={now:Date.now(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};e.applyTransactionalState(e=>nT(e,void 0,n,o).state),e.clearPreferredColumn(),e.focusInput()};return{canUpdateBodyFields:t,updateBodyFields:()=>n("all"),updateSelectedFields:()=>n("selection"),insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,r=Ia(e.selection)?e:Q(e),{paragraph:a,index:i,offset:s}=oe(r),l=Zn(a,s),c=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:qC(o,n),kind:"field",field:c,styles:l},p=d(a,[...rn(a,0,s),u,...rn(a,s,bi(a))]),g=ma(r),f=[...fr(g.slice(0,i)),p,...fr(g.slice(i+1))],m=u.text.length;return Sn(r,f,Y(Dr(p,s+m)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=qC(n,t);return 0===o.length?e:qu(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>oT(e,t)),e.focusInput()}}}function aT(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=Ka(e),n=Or(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=Ta(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=Ra(o,n.tablePath);return r?.[r.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=ti(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(Or(e.state().document,e.state().selection.focus.paragraphId,Ka(e.state()))),selectionLabel:()=>{const t=e.state();if(Qr(t).isCollapsed)return null;const n=Ka(t),o=Or(t.document,t.selection.anchor.paragraphId,n),r=Or(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 s=e.selectionBoxes().length;return 0===s?null:`Table selection: ${s} cell${1===s?"":"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 Lf(t,"tblLook",o)},Ug),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Lf(t,"styleId",e||null),jg),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Lf(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Vg),canSetAutoFit:()=>null!==vf(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Mf(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...gf(),type:"property",previous:{...r??{}}}});let a=ff(r,"layout",n);return"window"===t?a=ff(a,"width","100%"):"contents"===t&&(a=ff(a,"width",null)),{...o,style:a}})}(t,e),Ng),distributeColumns:()=>o(e=>Mf(e,e=>{const t=Ga(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),s=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:s,style:{...e.style??{},width:r}}}),Vg),distributeRows:()=>o(e=>Mf(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}}),Vg),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!==vf(e.state()),convertToText:()=>o(e=>jf(e),Mg),canConvertToTable:()=>{return!vf(t=e.state())&&null!==Pf(t);var t},convertToTable:()=>o(e=>Vf(e),Og),canSplitTableAtRow:()=>function(e){const t=vf(e);if(!t)return!1;const n=kf(e);if(!n)return!1;const o=Cf(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=vf(e);if(!t)return e;const n=kf(e);if(!n)return e;const o=Cf(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),s={...o,rows:a},l=Zo(i),c=Bf(e,[s,Go(""),l]);if(c===e)return e;const d=l.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:Y(Dr(d,0))}:e}(e),Ag),canSortTable:()=>function(e){const t=vf(e);if(!t)return!1;const n=kf(e);if(!n)return!1;const o=Cf(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=>_f(t,e),"ascending"===e?Fg:Dg),canDeleteTable:()=>null!==vf(e.state()),deleteTable:()=>o(e=>function(e){const t=vf(e);if(!t)return e;const n=kf(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=Go(""),n=Bf(e,[t]);return n===e?e:{...n,selection:Y(Dr(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=Bf(e,[]);if(a===e)return e;if(r){const e=ma(a).find(e=>e.id===r);if(e)return{...a,selection:Y(Dr(e,0))}}return a}(e),Eg),canToggleRepeatHeaderRows:()=>function(e){const t=vf(e);if(!t)return!1;const n=kf(e);if(!n)return!1;const o=Cf(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=vf(e);if(!t)return!1;const n=kf(e);if(!n)return!1;const o=Cf(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&Gf(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=vf(e);if(!t)return e;const n=kf(e);if(!n)return e;const o=Cf(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=Gf(o.rows[0]);return Mf(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),zg),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),mg),split:()=>o(t=>e.tableOps.splitSelectedTable(t),hg),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),bg),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),bg),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),yg),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),vg),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),vg),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),xg),canDeleteCell:()=>lm(e.state()),deleteCell:()=>o(e=>cm(e),Lg),cellShading:e=>o(t=>Df(t,"shading",e||null),wg),cellBorders:()=>o(e=>Ef(e,{width:1,type:"solid",color:"#64748b"}),Sg),cellNoBorders:()=>o(e=>Ef(e,{width:0,type:"none",color:"transparent"}),Sg),applyBorderPreset:e=>o(t=>function(e,t,n=Of){const o=Ff(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 s=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},l=(e,t,o,r,a=n)=>{s(e,t,a),o&&o.cell.id!==e?.cell.id&&s(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 s=o.startCol;s<=o.endCol;s+=1){const o=i.get(`${n}:${s}`);o&&a.has(o.cell.id)&&l(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${s}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,s=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)&&l(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${s}`),"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)&&l(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)&&l(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"])s(e,t,Af);c("top",Af),c("right",Af),c("bottom",Af),c("left",Af);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)s(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)s(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 Uo(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:{...gf(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=ff(o,e,r);return{...t,style:o}},f=Ta(e.document).map(e=>({...e,blocks:Kt(e.blocks,p,g),header:e.header?Kt(e.header,p,g):void 0,footer:e.footer?Kt(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),Sg),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Lf(e,"width","100%"),Ig),alignLeft:()=>o(e=>Df(e,"horizontalAlign","left"),Cg),alignCenter:()=>o(e=>Df(e,"horizontalAlign","center"),Cg),alignRight:()=>o(e=>Df(e,"horizontalAlign","right"),Cg),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,Df(Df(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},Tg),getCellAlignmentState:()=>function(e){const t=Ff(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=>Df(t,"verticalAlign",e),kg),setCellTextDirection:e=>o(t=>Df(t,"textDirection",e),Pg),setCellWidth:e=>o(t=>function(e,t){return Df(e,"width",t)}(t,e),Rg),setCellNoWrap:e=>o(t=>function(e,t){return Df(e,"noWrap",t)}(t,e),Rg),setCellFitText:e=>o(t=>function(e,t){return Df(e,"fitText",t)}(t,e),Rg),canSetCellMargins:()=>null!==vf(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Df(n,"paddingTop",t.top)),void 0!==t.right&&(n=Df(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Df(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Df(n,"paddingLeft",t.left)),n}(t,e),$g),canSetCellSpacing:()=>qf(e.state()),setCellSpacing:e=>o(t=>function(e,t){return qf(e)?Lf(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),$g),canSetTableIndent:()=>Yf(e.state()),setTableIndent:e=>o(t=>function(e,t){return Yf(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Lf(e,"indentLeft",null):Lf(e,"indentLeft",Math.round(2*t)/2):e}(t,e),$g),canSetTableAlignment:()=>null!==vf(e.state()),setTableAlignment:e=>o(t=>Jf(t,e),$g),canEvaluateTableFormula:()=>null!==vf(e.state()),evaluateTableFormula:e=>o(t=>tm(t,e),Hg),canSelectTable:()=>null!==vf(e.state()),selectTablePart:t=>e.applyState(im(e.state(),t)),canSetActiveTableRowHeight:()=>null!==vf(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=zf(n,"height",t.height),void 0!==t.heightRule&&(n=zf(n,"heightRule",t.heightRule)),n}(t,e),Wg),canSetActiveTableRowBreakAcrossPages:()=>Qf(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Qf(e)?zf(e,"cantSplit",null===t?null:!t):e}(t,e),Wg),canSetActiveTableRowHeader:()=>null!==vf(e.state()),setActiveTableRowHeader:e=>o(t=>$f(t,e),zg),canSetActiveTableColumnWidth:()=>null!==vf(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=vf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Cf(bf(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=Ga(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const s=i.visualColumnIndex;return null===t?e:Uf(e,a.id,{[s]:t})}(t,e),Bg),canSetActiveTableWidth:()=>null!==vf(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=vf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Cf(bf(e.document,o,r.zone),r.tablePath);return a?Nf(e,a.id,"width",t):e}(t,e),Ig),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function iT(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>nI(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=QS[t]??QS.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]=eI[t]??eI.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=>tI(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return tI(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return tI(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 sT(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:{...iI({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}),...sI({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...lI({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...fI({dialog:e.dialog,actionCommand:r}),...cI({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...pI({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...gI({design:e.design,actionCommand:r}),...dI({bookmark:e.bookmark,actionCommand:r}),...uI({fields:e.fields,actionCommand:r})}}}({gate:yI(e),style:vI(e),selection:xI(e),history:wI(e),formatting:eC(e),document:dC(e),link:uC(e),image:pC(e),browser:gC(e),paragraph:RC(e),section:jC(e),headerFooter:VC(e),table:aT(e),design:iT(e),bookmark:_C(e),fields:rT(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var lT=[{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:"tableOfContents"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"updateTableOfContents"},{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_update_selected_fields",path:"Tools/Update Selected Fields",labelKey:"menu.tools.updateSelectedFields",command:"updateSelectedFields",icon:"refresh-cw",shortcut:"F9"},{id:"tools_update_body_fields",path:"Tools/Update All Body Fields",labelKey:"menu.tools.updateBodyFields",command:"updateBodyFields",icon:"refresh-cw"},{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 cT(e){const t=sT(e.essentials),{runtimePlugins:n,toolbarRegistry:o,menuRegistry:r,dispose:a}=function(e){const t=[e.essentialsPlugin,...e.externalPlugins??[]],n=[],o=[],r=mo(),a=new yn;for(const i of ro(e.t))r.register(i);for(const i of lT)a.register(i);for(const i of t){for(const e of i.toolbar??[]){const t={type:"button",id:e.id,testId:e.id,command:e.command,iconName:e.icon,tab:e.tab??"plugins",group:e.group??"general",groupLabel:e.groupLabel,row:e.row??1,ribbonSize:e.ribbonSize,ribbonGroupResize:e.ribbonGroupResize,ribbonGroupLayout:e.ribbonGroupLayout,ribbonGroupGrid:e.ribbonGroupGrid,order:e.order};r.register(t),n.push(e.id)}for(const e of i.menubar??[])a.register({id:e.id,path:e.path,command:e.command,icon:e.icon,shortcut:e.shortcut}),o.push(e.id)}return e.customizeToolbar?.(r),e.customizeMenubar?.(a),{runtimePlugins:t,toolbarRegistry:r,menuRegistry:a,dispose:()=>{for(const e of n)r.remove(e);for(const e of o)a.unregister(e)}}}({essentialsPlugin:t,externalPlugins:e.externalPlugins,t:e.t,customizeToolbar:e.customizeToolbar,customizeMenubar:e.customizeMenubar}),i=function(e){const[t,n]=Pt(!1),[o,r]=Pt(new St({doc:e.initialDocument}));let a=!1;const i=e=>{const t=No(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=u(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=u(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await St.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:e.initialDocument,runtimePlugins:n,focusEditor:e.focusEditor,logger:e.logger,onExecuted:e.onExecuted,onReady:e.onReady,onSettled:e.onSettled,onError:e.onError});return jt(()=>{i.initialize()}),qt(()=>{i.dispose(),a()}),{toolbarRegistry:o,menuRegistry:r,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}var dT=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function uT(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!dT.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 pT(e){return function(e){const{document:t,interaction:n,runtimeClient:r}=e,{commandsController:a,keyboardCommandsController:i}=WS({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 s;const l=uT((e,t)=>{if(!s)throw new Error("repeat tracking used before ready");return s().commands.execute(e,t)},(e,t)=>!!s&&s().commands.canExecute(e,t)),c=()=>{l.execute()},d=()=>l.canExecute(),{runtimeReady:u,runtimeEditor:p,commandStateOf:g,toolbarHost:f,toolbarRegistry:m,menuRegistry:h}=cT({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:a,keyboardCommandsController:i,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:US({isDirty:()=>r.isDirty(),resetDocument:()=>r.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),saveDocument:()=>{r.save().catch(t=>e.logger.error("document:save failed",t))},openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openCommandSearch:()=>e.setCommandSearchOpen(!0),repeatLastAction:c,canRepeatLastAction:d,openTablePropertiesDialog:t=>{const n=bm(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=Qo(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:a.openFontDialog,openParagraphDialog:a.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:FS(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:FS(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=>{s=()=>t,r.resolveReady(t),e.runtimeOptions().onReady?.(r)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>r.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(Ir(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=Ho();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=nI(e,n.themeId)),e=tI(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})})(r,{runtimeReady:u,runtimeEditor:p,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:m,menuRegistry:h}),wt(()=>{if(!u())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());p().dispatch(()=>t)});const{handleKeyDown:b}=function(e){const{state:t,isReadOnly:n,logger:r,focusInput:a,clearPreferredColumn:i,resetTransactionGrouping:s,applyState:l,applyTransactionalState:c,setForcePlainTextPaste:d,selectedImageRun:u,commandsController:p,tableOps:g,navigation:f,historyActions:m,styleController:h,findReplace:b,commandSearch:y,runtimeEditor:v}=e,{handleKeyDown:x}=YS({state:t,isReadOnly:n,clearPreferredColumn:i,resetTransactionGrouping:s,applyState:l,applyTransactionalState:c,applyTableAwareParagraphEdit:g.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:g.applySelectionAwareParagraphCommand,focusInput:a,commandsController:p,pendingCaretTextStyle:h.pendingCaretTextStyle,autoTabIndentEnabled:Oe,isMacPlatform:()=>"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),isCaretAtWrappedLineStart:f.isCaretAtWrappedLineStart,selectedImageRun:u,setForcePlainTextPaste:d,moveSelectionByWord:f.moveSelectionByWord,moveSelectionToDocumentBoundary:f.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:f.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:m.moveSelectedImageByParagraph,performUndo:m.performUndo,performRedo:m.performRedo,moveVerticalSelection:f.moveVerticalSelection,moveVerticalByBlock:f.moveVerticalByBlock,resolveAdjacentTableCellPosition:g.resolveAdjacentTableCellPosition,resolveTableTabTarget:g.resolveTableTabTarget,appendTableRowForTab:g.appendTableRowForTab,applySelectionPreservingStructure:m.applySelectionPreservingStructure,toggleFindReplace:e=>{b.setIsOpen(e??!b.isOpen())},toggleReplace:e=>{b.setIsOpen(e??!b.isOpen())},toggleCommandSearch:e=>{y.setIsOpen(e??!y.isOpen())},executeCommand:(e,t)=>v().commands.execute(e,t),canExecuteCommand:e=>v().commands.canExecute(e)});return{handleKeyDown:e=>{ZS.includes(e.key)&&h.clearPendingCaretTextStyle();const n=[e.ctrlKey?"Ctrl":null,e.metaKey?"Meta":null,e.altKey?"Alt":null,e.shiftKey?"Shift":null].filter(Boolean).join("+"),a=n?`${n}+${e.key}`:e.key,i=t().selection;r.debug(`key:down ${a} at ${i.anchor.paragraphId}:${i.anchor.runId}[${i.anchor.offset}]`),Dt("input-to-layout"),x(e),o("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:i,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,commandSearch:e.commandSearch,runtimeEditor:p});return{commandsController:a,runtimeReady:u,runtimeEditor:p,commandStateOf:g,toolbarHost:f,toolbarRegistry:m,menuRegistry:h,handleKeyDown:b}}(e)}function gT(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 fT(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=gT(e,n.commentId)??gT(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 mT(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 hT(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!mT(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),!mT(e,t.items[i]))return!1;r.push(i)}}return!0}function bT(e){const[t,n]=Pt(null),[o,r]=Pt(""),[a,i]=Pt(!1),s=()=>e.access?.(),l=()=>{const e=s()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},c=()=>!(e.isReadOnly()||s()&&null===l()),d=()=>c()&&null!==so(e.state()),u=t=>c()&&Boolean(e.state().document.comments?.items[t]),p=()=>c()&&null!==FI(e.state()),g=t=>!e.isReadOnly()&&mT(s(),e.state().document.comments?.items[t]),f=()=>{const t=FI(e.state());return null!==t&&g(t.id)},m=t=>!e.isReadOnly()&&hT(s(),e.state().document.comments,t),h=g,b=(e="Local editor")=>{const t=l();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},y=(e,t,n,o,r,a)=>fT(e,t,{id:Rr("review-activity"),kind:n,commentId:o,...b(r),timestamp:Date.now(),...a?{parentId:a}:{}}),v=t=>{if(!u(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)},x=t=>{if(!g(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)},w=()=>{n(null),e.focusInput()},S=t=>{if(!m(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!hT(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 s of Object.values(n.items)){if(!s.parentId)continue;const e=a.get(s.parentId)??[];e.push(s.id),a.set(s.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?y(r,a,"comment-deleted",t):a}),o},I=(t,n)=>{if(!h(t))return!1;const o=e.state();let r=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==o.document||!mT(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?y(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:d,canReply:p,canReplyId:u,canEdit:f,canEditId:g,canDeleteId:m,canDeleteSelected:()=>{const t=FI(e.state());return null!==t&&m(t.id)},deleteSelected:()=>{const t=FI(e.state());return!!t&&S(t.id)},deleteById:S,canResolveId:h,canResolveSelected:()=>{const t=FI(e.state());return null!==t&&h(t.id)},resolveSelected:t=>{const n=FI(e.state());return!!n&&I(n.id,t)},resolveById:I,authorName:()=>l()?.displayName??o(),authorLocked:()=>void 0!==s(),openNew:()=>!!d()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!p())return!1;const t=FI(e.state());return!!t&&v(t.id)},openReplyToId:v,openEdit:()=>{if(!f())return!1;const t=FI(e.state());return!!t&&x(t.id)},openEditToId:x,close:w,submit:(n,o)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!g(a.commentId))return!1;if("edit"!==a.mode&&!c())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":l()?.displayName??n.trim(),d=o.trim();if(!i||!d||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===d)return w(),!0;const u="edit"===a.mode?null:{id:Rr("comment"),author:i,...l()?{authorId:l().id}:{},text:d,date:Date.now()};let p=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!mT(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!c())return t;const n="edit"===a.mode?Ft(t,a.commentId,d):"reply"===a.mode?qn(t,a.parentId,u):Rn({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},u);return p=n.document!==t.document,p?y(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:u.id,i,"reply"===a.mode?a.parentId:void 0):n}),p&&("edit"!==a.mode&&r(i),w()),p}}}var yT=/*#__PURE__*/kn("<div class=oasis-review-comments-filters role=group>"),vT=/*#__PURE__*/kn("<div class=oasis-review-comments-list>"),xT=/*#__PURE__*/kn("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),wT=/*#__PURE__*/kn("<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>"),ST=/*#__PURE__*/kn("<div class=oasis-review-thread-replies>"),IT=/*#__PURE__*/kn("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),CT=/*#__PURE__*/kn("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),TT=/*#__PURE__*/kn("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function kT(e){const t=We(),[n,o]=Pt("all"),[r,i]=Pt(!1),[s,l]=Pt(""),[c,d]=Pt(null),[u,p]=Pt(null),g=()=>e.state().document.comments,f=mn(()=>{const e=g();if(!e)return[];const t=s().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,...a(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),m=e=>a(g()?.items??{},e),h=mn(()=>{const t=s().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),b=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",y=t=>{u()===t?e.composer.deleteById(t)&&(p(null),c()===t&&d(null)):p(t)};return v=wT(),x=v.firstChild,w=x.nextSibling,Ye(x,Qn(io,{as:"strong",get children(){return t("review.commentsPanel")}}),null),Ye(x,Qn(to,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),Ye(w,Qn(to,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{i(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),Ye(w,Qn(to,{size:"sm",variant:"ghost",get"aria-pressed"(){return r()},onClick:()=>{i(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),Ye(v,Qn(io,{as:"p",get children(){return Ke(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${g()?.order.length??0}`}}),null),Ye(v,Qn(P,{get label(){return Ke(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return s()},onChange:l,"data-testid":"review-comments-search"}),null),Ye(v,Qn(dt,{get when(){return!r()},get children(){return[(a=yT(),Ye(a,Qn(to,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),Ye(a,Qn(to,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),Ye(a,Qn(to,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),po(()=>he(a,"aria-label",t("review.filterComments"))),a),(r=vT(),Ye(r,Qn(dt,{get when(){return 0===f().length},get children(){return Qn(io,{as:"p",get children(){return t("review.noComments")}})}}),null),Ye(r,Qn(en,{get each(){return f()},children:n=>{return o=IT(),r=o.firstChild,a=r.nextSibling,Ye(r,Qn(io,{as:"strong",get children(){return n.author||"—"}}),null),Ye(r,Qn(io,{as:"span",get children(){return Ke(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),Ye(o,Qn(io,{as:"p",get children(){return n.text}}),a),Ye(a,Qn(to,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),Ye(a,Qn(dt,{get when(){return e.composer.canEditId(n.id)},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),Ye(a,Qn(dt,{get when(){return e.composer.canResolveId(n.id)},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return Ke(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),Ye(a,Qn(dt,{get when(){return e.composer.canReplyId(n.id)},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),Ye(a,Qn(dt,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[Qn(to,{size:"sm",variant:"ghost",onClick:()=>y(n.id),"data-testid":"review-comment-delete",get children(){return Ke(()=>u()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),Qn(dt,{get when(){return u()===n.id},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),Ye(o,Qn(dt,{get when(){return m(n.id).length>0},get children(){return Qn(to,{size:"sm",variant:"ghost",get"aria-expanded"(){return c()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{d(c()===n.id?null:n.id)},get children(){return Ke(()=>c()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${m(n.id).length})`}})}}),null),Ye(o,Qn(dt,{get when(){return c()===n.id},get children(){var o=ST();return Ye(o,Qn(en,{get each(){return m(n.id)},children:n=>{return o=CT(),r=o.firstChild,Ye(o,Qn(io,{as:"strong",get children(){return n.author||"—"}}),r),Ye(o,Qn(io,{as:"p",get children(){return n.text}}),r),Ye(r,Qn(dt,{get when(){return e.composer.canEditId(n.id)},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),Ye(r,Qn(dt,{get when(){return e.composer.canReplyId(n.id)},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),Ye(r,Qn(dt,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[Qn(to,{size:"sm",variant:"ghost",onClick:()=>y(n.id),"data-testid":"review-reply-delete",get children(){return Ke(()=>u()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),Qn(dt,{get when(){return u()===n.id},get children(){return Qn(to,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),po(()=>he(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),po(()=>he(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),Ye(v,Qn(dt,{get when(){return r()},get children(){var n=xT();return Ye(n,Qn(dt,{get when(){return 0===h().length},get children(){return Qn(io,{as:"p",get children(){return t("review.activity.empty")}})}}),null),Ye(n,Qn(en,{get each(){return h()},children:n=>{return o=TT(),r=o.firstChild,Ye(r,Qn(io,{as:"strong",get children(){return n.actorName}}),null),Ye(r,Qn(io,{as:"span",get children(){return b(n.timestamp)}}),null),Ye(o,Qn(io,{as:"p",get children(){return[Ke(()=>(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))," — ",Ke(()=>n.targetAuthor),Ke(()=>Ke(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),Ye(o,Qn(dt,{get when(){return Boolean(g()?.items[n.commentId])},get children(){return Qn(to,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),po(()=>he(o,"data-activity-kind",n.kind)),o;var o,r}}),null),po(()=>he(n,"aria-label",t("review.activity.title"))),n}}),null),po(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&he(v,"aria-label",e.e=n),o!==e.t&&he(w,"aria-label",e.t=o),e},{e:void 0,t:void 0}),v;var v,x,w}var PT="oasis-reviewing-pane-v1",RT={open:!1,scrollTop:0};function BT(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:0}function MT(){const e=function(){try{const e=globalThis.localStorage?.getItem(PT);if(!e)return RT;if("true"===e)return{open:!0,scrollTop:0};if("false"===e)return{open:!1,scrollTop:0};const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))return RT;const n=t;return{open:!0===n.open,scrollTop:BT(n.scrollTop)}}catch{return RT}}(),[t,n]=Pt(e.open),[o,r]=Pt(e.scrollTop),a=()=>{!function(e){try{globalThis.localStorage?.setItem(PT,JSON.stringify(e))}catch{}}({open:t(),scrollTop:o()})},i=e=>{n(e),a()};return{open:()=>t(),toggle:()=>(i(!t()),!0),close:()=>{i(!1)},scrollTop:()=>o(),setScrollTop:e=>{const t=BT(e);t!==o()&&(r(t),a())}}}var OT=/*#__PURE__*/kn("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),AT=/*#__PURE__*/kn("<div class=oasis-review-revision-footer>"),FT=/*#__PURE__*/kn('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),DT=/*#__PURE__*/kn("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function ET(e,t){const n=ma(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 LT(e){const t=We(),n=mn(()=>{const t=e.state(),n=ma(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(Wv(t).map(e=>[e.id,e])),i=new Map(Uv(t).map(e=>[e.id,e]));return BI(t).map(e=>{const n=r.get(e.id),s=a.get(e.id),l=i.get(e.id);return{id:e.id,type:n?.type??s?.type??l?.type??"insert",author:o.get(e.id)??s?.author??l?.author??"—",date:n?.date??s?.date??l?.date,snippet:ET(t,e.id)||s?.snippet||l?.snippet||"",section:void 0!==l}})}),o=mn(()=>{const t=e.state();return n().filter(e=>Xv(t,e.type,e.author))});let r,a=!1;const i=()=>{const t=r,n=e.scrollTop;!t||"number"!=typeof n||n<=0||t.scrollHeight<=t.clientHeight||(t.scrollTop=n,a=!0,t.scrollTop!==n&&e.onScroll?.(t.scrollTop))};wt(()=>{o().length,a||queueMicrotask(i)});return s=FT(),l=s.firstChild,Ye(l,Qn(io,{as:"strong",get children(){return t("review.reviewingPane")}}),null),Ye(l,Qn(to,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),Ye(s,Qn(io,{as:"p",get children(){return[Ke(()=>t("review.revisionCount")),": ",Ke(()=>o().length)]}}),null),Ye(s,Qn(dt,{get when(){return n().length-o().length>0},get children(){return Qn(io,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),Ye(s,Qn(dt,{get when(){return o().length>0},get fallback(){return Qn(io,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=OT();return n.addEventListener("scroll",t=>{e.onScroll?.(t.currentTarget.scrollTop)}),Xn(e=>{r=e,queueMicrotask(i)},n),Ye(n,Qn(en,{get each(){return o()},children:n=>{return o=DT(),r=o.firstChild,a=r.nextSibling,Ye(r,Qn(io,{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[Qn(tn,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),Qn(io,{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),Ye(r,Qn(io,{as:"p",get children(){return n.snippet||"—"}}),null),Ye(r,Qn(io,{as:"span",get children(){return n.author}}),null),Ye(a,Qn(to,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),Ye(a,Qn(to,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),Ye(a,Qn(to,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),po(e=>{var t=n.id,r=n.section?"true":void 0;return t!==e.e&&he(o,"data-comment-id",e.e=t),r!==e.t&&he(o,"data-revision-section",e.t=r),e},{e:void 0,t:void 0}),o;var o,r,a}})),n}}),null),Ye(s,Qn(dt,{get when(){return o().length>0},get children(){var n=AT();return Ye(n,Qn(to,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),Ye(n,Qn(to,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),po(()=>he(s,"aria-label",t("review.reviewingPane"))),s;var s,l}var NT=/*#__PURE__*/kn('<div class="oasis-editor-shell oasis-editor-app">');function zT(e={}){const t=e.runtime?.client??wn(),[n,o]=Pt({}),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}),s=e=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...i(),...e}),l=()=>e.runtime??{};Np();const c=A(()=>r().locale??"pt-BR"),d=eo("app"),{state:u,commitState:p,getStateSnapshot:g}=function(e){const t=e.initialState?Jt(e.initialState):e.initialDocument?Ir(e.initialDocument):Ho();let n=t;const[o,r]=Pt(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=qr(e===a?n:e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),f=e=>{p(e)},m=Jt;let h=!1;const{showChrome:b,showTitleBar:y,showMenubar:v,showToolbar:x,showOutline:w,showRuler:S,toggleOutline:I,toolbarView:C,toolbarLayout:k,isReadOnly:P,useComposedShell:R,loadingOptions:B,loadingLabel:O,shellComponent:F}=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?M:"balloon"===e?fe:H}}}({ui:r,documentOptions:a,updateUiState:s,state:()=>u}),D=function(){const[e,t]=Pt(!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}}}(),E=D.focused,L=D.setFocused,N=D.focusInput,z=D.focusInputAfterPointerSelection,$=D.focusInputSync,[W,U]=Pt(!1!==r().loading),j=Kn(),{linkDialog:V,setLinkDialog:K,imageAltDialog:_,setImageAltDialog:X,imageCaptionDialog:G,setImageCaptionDialog:q,contextMenu:Y,setContextMenu:Z,fontDialog:J,setFontDialog:Q,paragraphDialog:ee,setParagraphDialog:ne,tablePropertiesDialog:oe,setTablePropertiesDialog:re,revisionBulkDialog:ae,setRevisionBulkDialog:ie,newDocumentDialog:se,setNewDocumentDialog:le,symbolDialog:ce,setSymbolDialog:de,equationDialog:ue,setEquationDialog:pe}=function(){const[e,t]=Pt({isOpen:!1}),[n,o]=Pt({isOpen:!1}),[r,a]=Pt({isOpen:!1}),[i,s]=Pt({isOpen:!1,initialHref:""}),[l,c]=Pt({isOpen:!1,initialAlt:""}),[d,u]=Pt({isOpen:!1,initialCaption:""}),[p,g]=Pt({isOpen:!1,x:0,y:0}),[f,m]=Pt({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]=Pt({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]=Pt({isOpen:!1,action:"accept",count:0}),[x,w]=Pt({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:s,imageAltDialog:l,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}}(),[ge,me]=Pt(!1),ye=()=>D.viewportRef,ve=()=>D.surfaceRef,xe=yx({documentOptions:a,logger:d,runtimeClient:t,state:u,commitState:p,getStateSnapshot:g,applyState:f,cloneState:m,isReadOnly:P,focusInput:N,surfaceRef:ve,viewportRef:ye,zoomFactor:j.zoomFactor,getImageOps:()=>Ge.imageOps}),{docIO:we,measuredBlockHeights:Se,measuredParagraphLayouts:Ie,documentLayout:Ce,canvasSnapshotProvider:Te,inputBox:Pe,selectionBoxes:Re,commentHighlights:Be,revisionMarkupBoxes:Me,changeBarBoxes:Oe,selectedImageBox:Ae,selectedTextBoxBox:Fe,selectedTableBox:De,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,clearPreferredColumn:He,onCleanupHook:We,persistenceStatus:Ue,applyTransactionalState:je,resetTransactionGrouping:Ve,updateHistoryState:_e}=xe,Xe=yp({state:()=>u,stateSnapshot:g,isReadOnly:P,applyTransactionalState:je,applyTableAwareParagraphEdit:(e,t)=>Ge.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:He,resetTransactionGrouping:Ve,focusInput:N}),Ge=SS({clipboardActions:Xe,state:u,getStateSnapshot:g,logger:d,isReadOnly:P,applyState:f,cloneState:m,focusInput:N,focusInputAfterPointerSelection:z,focusInputSync:$,surfaceRef:ve,viewportRef:ye,zoomFactor:j.zoomFactor,insertImageFromFile:we.insertImageFromFile,getForcePlainTextPaste:()=>h,setForcePlainTextPaste:e=>{h=e},getCommandsController:()=>wt.commandsController,applyTransactionalState:je,clearPreferredColumn:He,resetTransactionGrouping:Ve,updateHistoryState:_e,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:$e,measuredBlockHeights:Se,measuredParagraphLayouts:Ie,documentLayout:Ce,canvasSnapshotProvider:Te,openEquationDialog:(e,t)=>{pe({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:st,surfaceEventsWithTextDrag:lt,textInput:ct,handleCopy:pt,handleCut:gt,handlePaste:ft,handleDrop:mt}=Ge,[ht,yt]=Pt(!1),vt=MT(),xt=bT({state:()=>u,isReadOnly:P,applyTransactionalState:je,focusInput:N,access:()=>l().review}),wt=pT({commandSearch:{isOpen:ht,setIsOpen:e=>{yt(e)}},setCommandSearchOpen:yt,clipboardActions:Xe,document:xe,interaction:Ge,commentComposer:xt,state:u,logger:d,isReadOnly:P,focusInput:N,applyState:f,getStateSnapshot:g,cloneState:m,setFocused:L,setInitialLoading:U,getForcePlainTextPaste:()=>h,setForcePlainTextPaste:e=>{h=e},locale:()=>r().locale??"pt-BR",translator:c,runtimeClient:t,runtimeOptions:l,documentOptions:a,getUiState:i,updateUiState:s,zoom:j,importInputRef:()=>D.importInputRef,imageInputRef:()=>D.imageInputRef,setLinkDialog:K,setImageAltDialog:X,setImageCaptionDialog:q,setNewDocumentDialog:le,setSymbolDialog:de,setEquationDialog:pe,setTablePropertiesDialog:re,setFontDialog:Q,setParagraphDialog:ne,setRevisionBulkDialog:ie,toggleOutline:I,isOutlineVisible:w,toggleRevisionsPanel:()=>{vt.toggle()},revisionsPanelVisible:vt.open}),{commandsController:St,runtimeReady:It,runtimeEditor:Ct,toolbarHost:Tt,toolbarRegistry:kt,menuRegistry:Rt,handleKeyDown:Bt}=wt,Mt=()=>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=Op(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=Mp(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}(kt.getOrdered(),Rt.getItems(),c),Ot=e=>{try{return!1!==Ct().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:At,computeFontSizeOptions:Ft,applyFontDialogValues:Dt,applyParagraphDialogValues:Et,setParagraphDialogDefault:Lt,applyTablePropertiesDialogValues:Nt,buildContextMenuItems:zt,handleEditorContextMenu:$t,closeContextMenu:Ht}=wm({clipboardActions:Xe,state:()=>u,selection:()=>u.selection,toolbarStyleState:tt.toolbarStyleState,isReadOnly:P,t:c,logger:d,setFontDialog:Q,setParagraphDialog:ne,setTablePropertiesDialog:re,setContextMenu:Z,clearPreferredColumn:He,resetTransactionGrouping:Ve,applyTransactionalState:je,applyTableAwareParagraphEdit:Je.applyTableAwareParagraphEdit,focusInput:N,promptForLink:St.promptForLink,tableOps:Je}),{layout:Wt,overlays:Ut,refs:Vt,surfaceHandlers:Kt,inputHandlers:_t,fileHandlers:Xt}=function(e){const{layout:t,overlays:n,refs:o,surface:r,input:a,files:i}=e;return{layout:{documentLayout:t.documentLayout,remoteWebFonts:t.remoteWebFonts,pageGutter:t.pageGutter,initialZoomMode:t.initialZoomMode,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:Ce,remoteWebFonts:a().remoteWebFonts,pageGutter:r().pageGutter,initialZoomMode:r().zoom?.initialMode,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:j.zoomPercent,setZoomPercent:j.setZoomPercent,zoomFactor:j.zoomFactor},overlays:{selectionBoxes:Re,commentHighlights:Be,revisionMarkupBoxes:Me,changeBarBoxes:Oe,onReplyToComment:e=>{xt.openReplyToId(e)},onEditComment:e=>{xt.openEditToId(e)},canEditComment:xt.canEditId,canReplyComment:xt.canReplyId,selectedImageBox:Ae,selectedTextBoxBox:Fe,selectedTableBox:De,layoutOptions:qe,caretBox:Le,inputBox:Pe,hoveredRevision:it.hoveredRevision,focused:E,showCaret:()=>function(e,t){if(!t.visible||!Ia(e.selection))return!1;const n=Ka(e),o=ci(e.document,e.selection.anchor.paragraphId,n),r=ci(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(u,Le()),importProgress:we.importProgress,imageCropMode:Qe.cropMode},refs:{focusController:D},files:{handleImportFile:we.handleImportFile,handleInsertImage:we.handleInsertImage},surface:{surfaceEvents:lt,tableResize:ot,tableCornerResize:rt,tableDrag:at,revisionController:it,handleDrop:mt,onEditorPointerDown:nt,handleImagePointerDown:Qe.handleImagePointerDown,handleImageResizeHandlePointerDown:Qe.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:et.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Qe.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Qe.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Qe.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:et.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:$t},input:{textInput:ct,setFocused:L,handleCopy:pt,handleCut:gt,handlePaste:ft,handleKeyDown:e=>{if("Escape"===e.key&&Ge.formatPainter.mode())return Ge.formatPainter.cancel(),void e.preventDefault();Bt(e)},handleKeyUp:e=>{Ge.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Ge.formatPainter.applyToSelection("keyboard")}}});return jt(()=>{ut(),Yn(),be(),Bn(()=>ve()??null),bt(),(r().showWelcome??!0)&&!T()&&ke()&&me(!0)}),qt(()=>{We(),lt.stopDragging(),st.stopDrag(),ot.stop(),rt.stop(),at.stop(),Qe.stopImageDrag(),Qe.stopImageResize(),Qe.stopImageCrop(),et.stopTextBoxResize(),Fn()}),Qn(Ee,{translator:c,get children(){var e=NT();return Ye(e,Qn(dt,{get when(){return Ke(()=>!(R()||!b()))()&&x()},get children(){return Qn(te,{host:Tt,registry:kt,get showFileGroup(){return!!Ke(()=>"ribbon"===C())()||!v()},get view(){return C()},get layout(){return k()}})}}),null),Ye(e,Qn(wp,{get notice(){return Xe.notice},onDismiss:()=>{Xe.dismiss(),N()}}),null),Ye(e,Qn(dt,{get when(){return xt.panelOpen()},get children(){return Qn(kT,{state:()=>u,composer:xt,locale:()=>r().locale??"pt-BR",get onClose(){return xt.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 s=ma(e),l=s.find(e=>e.id===a.paragraphId),c=s.find(e=>e.id===i.paragraphId);return l&&c?{...e,selection:{anchor:Dr(l,a.offset),focus:Dr(c,i.offset)}}:e}(u,e);t!==u&&(f(t),N())}})}}),null),Ye(e,Qn(dt,{get when(){return vt.open()},get children(){return Qn(LT,{state:()=>u,get onClose(){return vt.close},get scrollTop(){return vt.scrollTop()},get onScroll(){return vt.setScrollTop},onNavigate:e=>{const t=DI(u,e);t!==u&&(f(t),N())},onAccept:e=>{const t=DI(u,e);t!==u&&(f(t),St.applyAcceptRevisionsCommand(),N())},onReject:e=>{const t=DI(u,e);t!==u&&(f(t),St.applyRejectRevisionsCommand(),N())},onAcceptAll:()=>Ct().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>Ct().commands.execute("requestRejectAllRevisions")})}}),null),Ye(e,Qn(Bp,{get isOpen(){return ht()},get entries(){return Mt()},isEnabled:Ot,onExecute:e=>{Ct().commands.execute(e.command,e.payload),yt(!1),N()},onClose:()=>{yt(!1),N()}}),null),Ye(e,Qn(ob,{commentComposer:xt,dialogs:{linkDialog:V,setLinkDialog:K,imageAltDialog:_,setImageAltDialog:X,imageCaptionDialog:G,setImageCaptionDialog:q,contextMenu:Y,setContextMenu:Z,fontDialog:J,setFontDialog:Q,paragraphDialog:ee,setParagraphDialog:ne,tablePropertiesDialog:oe,setTablePropertiesDialog:re,revisionBulkDialog:ae,setRevisionBulkDialog:ie,newDocumentDialog:se,setNewDocumentDialog:le,symbolDialog:ce,setSymbolDialog:de,equationDialog:ue,setEquationDialog:pe},findReplace:Ze,fontFamilyOptions:At,fontSizeOptions:Ft,contextMenuItems:zt,focusInput:N,get applyLinkCommand(){return St.applyLinkCommand},get applyImageAltCommand(){return St.applyImageAltCommand},get applyImageCaptionCommand(){return St.applyImageCaptionCommand},applyFontDialogValues:Dt,applyParagraphDialogValues:Et,setParagraphDialogDefault:Lt,applyTablePropertiesDialogValues:Nt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{Ct().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),N()},insertSymbol:(e,t)=>{Ct().commands.execute("insertText",{text:e,fontFamily:t}),N()},applyEquation:(e,t)=>{t?Ct().commands.execute("updateEquation",{runId:t,expression:e}):Ct().commands.execute("insertEquation",e),N()},closeContextMenu:Ht}),null),Ye(e,Qn(ab,{useComposedShell:R,shellComponent:F,runtime:{state:()=>u,toolbarHost:Tt,runtimeEditor:Ct,persistenceStatus:Ue,toolbarRegistry:kt,menuRegistry:Rt},chrome:{showChrome:b,showTitleBar:y,showMenubar:v,showToolbar:x,showOutline:w,showRuler:S,toolbarView:C,toolbarLayout:k},view:{isReadOnly:P,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:Se,measuredParagraphLayouts:Ie,documentLayout:Ce,layout:Wt,overlays:Ut,refs:Vt,surfaceHandlers:Kt,inputHandlers:_t,fileHandlers:Xt}}),null),Ye(e,Qn(Pm,{state:u,get surfaceRef(){return ve()},documentLayout:Ce,snapshotProvider:Te,get zoomFactor(){return j.zoomFactor},tableResize:ot,tableCornerResize:rt,imageOps:Qe,tableDrag:at,textDrag:st}),null),Ye(e,Qn(dt,{get when(){return W()||!It()},get children(){return Qn(ze,{get label(){return O()},get class(){return B()?.class},get style(){return B()?.style}})}}),null),Ye(e,Qn(sb,{get isOpen(){return Ke(()=>!(!ge()||W()))()&&It()},onClose:()=>me(!1)}),null),po(t=>{var n=r().theme??"light",o=!!R(),a=!!P(),i=!("two-line"!==r().toolbar?.ribbonStyle),s=!("simplified"!==r().toolbar?.ribbonStyle),l=!(null===Ge.formatPainter.mode()),c={"--oasis-editor-gutter-x":`${hn(r().pageGutter)}px`,...void 0!==r().pageGutter?{"--oasis-editor-gutter-top":`${hn(r().pageGutter)}px`,"--oasis-editor-gutter-bottom":`${hn(r().pageGutter)}px`}:{}};return n!==t.e&&he(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-two-line",t.o=i),s!==t.i&&e.classList.toggle("oasis-editor-ribbon-simplified",t.i=s),l!==t.n&&e.classList.toggle("oasis-editor-format-painter-active",t.n=l),t.s=ao(e,c,t.s),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),e}})}export{zT as OasisEditorApp};
|