oasis-editor 0.0.231 → 0.0.232
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-QuRS1JVm.js +1 -0
- package/dist/app/controllers/useEditorClipboard.d.ts +3 -0
- package/dist/defaultToolbar-BLpx6Q1W.js +1 -0
- package/dist/i18n/locales/en.d.ts +7 -0
- package/dist/i18n/locales/pt-BR.d.ts +7 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/ui/app/clipboardPaste.d.ts +2 -0
- package/dist/ui/app/clipboardWrite.d.ts +2 -2
- package/dist/ui/app/createEditorChrome.d.ts +2 -0
- package/dist/ui/app/createEditorClipboardActions.d.ts +19 -0
- package/dist/ui/app/createEditorCommandRuntime.d.ts +2 -0
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +2 -0
- package/dist/ui/app/essentials/browser.d.ts +2 -6
- package/dist/ui/app/essentials/types.d.ts +2 -0
- package/dist/ui/app/useEditorContextMenuClipboard.d.ts +5 -3
- package/dist/ui/app/useEditorInteractionWiring.d.ts +2 -0
- package/dist/ui/components/ClipboardFeedback.d.ts +6 -0
- package/dist/ui/components/Toolbar/primitives/popoverBranch.d.ts +2 -0
- package/package.json +3 -2
- package/dist/OasisEditorApp-IDmEjhGJ.js +0 -1
- package/dist/defaultToolbar-D9PBASVE.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,$a as t,$n as n,$t as o,A as r,Aa as a,Ai as i,An as l,Ar as s,B as c,Ba as d,Bi as u,Bn as p,Bo as g,Br as f,Bt as m,C as h,Ca as b,Ci as y,Cn as v,Co as x,Cr as w,Ct as S,D as I,Da as C,Di as T,Dn as P,Do as k,Dr as R,E as B,Ea as M,En as F,Eo as A,Er as O,Et as D,F as E,Fa as L,Fi as N,Fn as $,Fo as z,Fr as H,Ft as W,G as U,Ga as j,Gi as V,Gn as K,Go as _,Gr as X,Gt as G,H as Y,Ha as q,Hi as Z,Hn as J,Ho as Q,Hr as ee,Ht as te,I as ne,Ia as oe,Ii as re,In as ae,Io as ie,Ir as le,It as se,J as ce,Ja as de,Jn as ue,Jr as pe,Jt as ge,K as fe,Ka as me,Kn as he,Ko as be,Kr as ye,Kt as ve,L as xe,La as we,Li as Se,Ln as Ie,Lo as Ce,Lr as Te,Lt as Pe,M as ke,Ma as Re,Mi as Be,Mn as Me,Mo as Fe,Mr as Ae,N as Oe,Na as De,Ni as Ee,Nn as Le,Nr as Ne,Nt as $e,O as ze,Oa as He,Oi as We,On as Ue,Oo as je,Or as Ve,P as Ke,Pa as _e,Pi as Xe,Pn as Ge,Po as Ye,Pr as qe,Pt as Ze,Q as Je,Qa as Qe,Qn as et,Qt as tt,R as nt,Ra as ot,Ri as rt,Rn as at,Ro as it,Rr as lt,Rt as st,S as ct,Sa as dt,Si as ut,Sn as pt,So as gt,Sr as ft,St as mt,T as ht,Ta as bt,Tn as yt,Tr as vt,Tt as xt,U as wt,Ua as St,Ui as It,Un as Ct,Uo as Tt,Ur as Pt,Ut as kt,V as Rt,Va as Bt,Vi as Mt,Vn as Ft,Vo as At,Vr as Ot,Vt as Dt,W as Et,Wa as Lt,Wi as Nt,Wn as $t,Wr as zt,Wt as Ht,X as Wt,Xa as Ut,Xn as jt,Xr as Vt,Xt as Kt,Y as _t,Ya as Xt,Yn as Gt,Yo as Yt,Yr as qt,Yt as Zt,Z as Jt,Za as Qt,Zn as en,Zr as tn,Zt as nn,_ as on,_a as rn,_i as an,_n as ln,_o as sn,_r as cn,_t as dn,a as un,aa as pn,an as gn,ao as fn,ar as mn,at as hn,b as bn,ba as yn,bi as vn,bn as xn,bo as wn,br as Sn,bt as In,c as Cn,ca as Tn,cn as Pn,co as kn,cr as Rn,ct as Bn,d as Mn,da as Fn,dn as An,do as On,dr as Dn,dt as En,ea as Ln,en as Nn,eo as $n,er as zn,et as Hn,f as Wn,fa as Un,fi as jn,fn as Vn,fo as Kn,fr as _n,ft as Xn,g as Gn,ga as Yn,gi as qn,gn as Zn,go as Jn,gr as Qn,gt as eo,h as to,ha as no,hi as oo,hn as ro,ho as ao,hr as io,ht as lo,i as so,ia as co,in as uo,io as po,ir as go,it as fo,j as mo,ja as ho,jn as bo,jo as yo,jr as vo,k as xo,ka as wo,ki as So,kn as Io,ko as Co,kr as To,l as Po,la as ko,ln as Ro,lo as Bo,lr as Mo,lt as Fo,m as Ao,ma as Oo,mi as Do,mn as Eo,mo as Lo,mr as No,mt as $o,n as zo,na as Ho,nn as Wo,no as Uo,nr as jo,nt as Vo,o as Ko,oa as _o,on as Xo,oo as Go,or as Yo,ot as qo,p as Zo,pa as Jo,pi as Qo,pn as er,po as tr,pr as nr,pt as or,q as rr,qa as ar,qn as ir,qo as lr,qr as sr,qt as cr,r as dr,ra as ur,rn as pr,ro as gr,rr as fr,s as mr,sa as hr,sn as br,so as yr,sr as vr,st as xr,t as wr,ta as Sr,ti as Ir,tn as Cr,to as Tr,tr as Pr,u as kr,ua as Rr,un as Br,uo as Mr,ur as Fr,ut as Ar,v as Or,va as Dr,vi as Er,vn as Lr,vo as Nr,vr as $r,vt as zr,w as Hr,wa as Wr,wi as Ur,wn as jr,wo as Vr,wr as Kr,wt as _r,x as Xr,xa as Gr,xi as Yr,xn as qr,xo as Zr,xr as Jr,xt as Qr,y as ea,ya as ta,yi as na,yn as oa,yo as ra,yr as aa,yt as ia,z as la,za as sa,zi as ca,zn as da,zo as ua,zr as pa,zt as ga}from"./defaultToolbar-D9PBASVE.js";var fa=!1,ma=null,ha=null,ba=null,ya=[];function va(){"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}()?fa&&(delete window.__oasisCanvasDebug,fa=!1):fa||(window.__oasisCanvasDebug={getLastHit:()=>ma?{...ma}:null,getLayoutSnapshot:()=>ha?{...ha,surfaceRect:{...ha.surfaceRect},pages:ha.pages.map(e=>({...e})),paragraphs:ha.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:ha.inlineImages.map(e=>({...e})),inlineTextBoxes:ha.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:ha.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>ba?{anchor:{...ba.anchor},focus:{...ba.focus},activeZone:ba.activeZone,activeSectionIndex:ba.activeSectionIndex}:null,getMissEvents:()=>ya.map(e=>({...e})),clearMissEvents:()=>{ya=[]}},fa=!0))}function xa(e){fa&&e&&(ma={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var wa=["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 Sa(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function Ia(e){return function(e){const[t,n]=Tt([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))Sa(r,o,i.textStyle?.fontFamily);Sa(r,o,t.fontFamily);for(const i of n)Sa(a,o,i);for(const i of wa)Sa(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(zo);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(so(e))}const o=so(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 p();e.length>0&&n(e)}}}(e)}var Ca="insertText",Ta="composition",Pa="insertImage",ka="insertTable",Ra="moveImage",Ba="splitListItem",Ma="link",Fa="imageAlt",Aa="imageCaption",Oa="imageResize",Da="imageCrop",Ea="imageFlip",La="imageRotate",Na="imageTransparency",$a="imageReset",za="layoutWrapPolygon",Ha="specialIndent",Wa="paraBorders",Ua="paragraphMoveUp",ja="paragraphMoveDown",Va="findReplace",Ka="findReplaceAll",_a="tableProperties",Xa="paragraph-dialog",Ga="font-dialog",Ya="copyTextByDrag",qa="moveTextByDrag",Za="collapseSelectionByClick",Ja="mergeTable",Qa="splitTable",ei="insertTableColumn",ti="deleteTableColumn",ni="insertTableRow",oi="deleteTableRow",ri="tableShading",ai="tableBorders",ii="tableWidth",li="tableAlign",si="tableCellVerticalAlign",ci="tableCellTextDirection",di="tableCellWidth",ui="tableColumnWidth",pi="tableToText",gi="textToTable",fi="tableSplitAtRow",mi="tableSortAscending",hi="tableSortDescending",bi="tableDelete",yi="deleteTableCell",vi="tableAutoFit",xi="tableRepeatHeaderRows",wi="tableCellMargins",Si="tableFormula",Ii="tableRowHeight",Ci="tableStyleOptions",Ti="tableStyleGallery",Pi="tableDistribute",ki="layoutWrapPreset",Ri="layoutFixedPosition",Bi="shapeFill",Mi="shapeOutline",Fi="shapeOutlineWidth",Ai="floatingAlign",Oi="floatingReorder",Di="floatingNudge",Ei="floatingFixedPosition",Li="floatingRotation",Ni="floatingWrap",$i="floatingWrapText",zi="floatingPositionPreset",Hi="shapePreset",Wi="textBoxTextDirection",Ui="textBoxVerticalAlign",ji="textBoxAlt",Vi="textBoxRotate",Ki="textBoxWidthCm",_i="textBoxHeightCm";function Xi(e){return e.map(o)}function Gi(e){return e.reduce((e,t)=>e+t.text.length,0)}function Yi(e,t,n){if(0===n.length)return e;const o=Oo(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=sa(a,t),l=Xi(n[0].runs);if(1===n.length){const t=Y(a,i,l),n=o.map((e,n)=>n===r?t:e),s=Gi(l),c=ot(t,i),d=ot(t,i+s);return la(e,n,{anchor:c,focus:d})}const s=U(a,0,i),c=U(a,i,oe(a)),d=n[n.length-1],u=n.slice(1,-1),p=fe(Kt(n[0].paragraphTemplate),[...s,...l],Et(a,i)),g=u.map(e=>fe(Kt(e.paragraphTemplate),Xi(e.runs))),f=fe(Kt(d.paragraphTemplate),[...Xi(d.runs),...c],Et(a,i)),m=[...o.slice(0,r),p,...g,f,...o.slice(r+1)],h=ot(p,Gi(s)),b=ot(f,Gi(d.runs));return la(e,m,{anchor:h,focus:b})}function qi(e,t,n={}){if(hr(e).isCollapsed)return e;if(function(e,t){const n=hr(e);if(n.isCollapsed)return!1;const o=Oo(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=sa(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,t))return e;const o=function(e){const t=hr(e);if(t.isCollapsed)return[];const n=Oo(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:oe(e),l=U(e,a,i);o.push({paragraphTemplate:Kt(e),runs:l})}return o}(e);if(0===o.length)return e;if(n.copy)return Yi(e,t,o);const r=function(e,t){const n=hr(e),o=Oo(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=sa(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return ot(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,t);return Yi(Ke(e),r,o)}function Zi(e,t,n){if(0===t.length)return e;const o=_o(e.selection)?e:Ke(e),{paragraph:r,index:a,offset:i}=E(o),l=n?{...n}:Et(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:l,kind:"text"};o.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=Y(r,i,[s]),d=Oo(o).map((e,t)=>t===a?c:e);return la(o,d,nt(ot(c,i+t.length)))}function Ji(e){return Zi(e,"\v")}function Qi(e,t,n){if(0===t.length)return e;const o=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!o.includes("\n"))return Zi(e,o,n);const r=_o(e.selection)?e:Ke(e),{paragraph:a,index:i,offset:l}=E(r),s=o.split("\n"),c=n?{...n}:Et(a,l),d=U(a,0,l),u=fe(a,[...d,Kn(s[0],c)],c),p=U(a,l,oe(a)),g=s.slice(1,-1).map(e=>_t([{text:e,styles:c}])),f=_t([{text:s[s.length-1],styles:c},...p.map(e=>({text:e.text,styles:e.styles}))]),m=Oo(r),h=[...m.slice(0,i),u,...g,f,...m.slice(i+1)];return la(r,h,nt(ot(f,s[s.length-1].length)))}function el(e){if(!_o(e.selection))return Ke(e);const{paragraph:t,index:n,offset:r}=E(e),a=Oo(e);if(r>0){if(e.trackChangesEnabled){const o=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<o.length;e+=1){const t=i+o[e].text.length;if(r<=t){l=e,s=r-i;break}i=t}if(-1!==l){const i=o[l];if("insert"===i.revision?.type){const o=[...U(t,0,r-1),...U(t,r,oe(t))],i=fe(t,o),l=a.map((e,t)=>t===n?i:e);return la(e,l,nt(ot(i,r-1)))}const c=i.text[s-1],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},u=[...U(t,0,r-1),d,...U(t,r,oe(t))],p=fe(t,u),g=a.map((e,t)=>t===n?p:e);return la(e,g,nt(ot(p,r-1)))}}const o=fe(t,[...U(t,0,r-1),...U(t,r,oe(t))],Et(t,r-1)),i=a.map((e,t)=>t===n?o:e);return la(e,i,nt(ot(o,r-1)))}if(0===n)return e;const i=a[n-1],l=fe(i,[...i.runs.map(o),...t.runs.map(o)]),s=[...a.slice(0,n-1),l,...a.slice(n+1)];return la(e,s,nt(ot(l,oe(i))))}function tl(e){if(!_o(e.selection))return Ke(e);const{paragraph:t,index:n,offset:r}=E(e),a=Oo(e);if(r<oe(t)){if(e.trackChangesEnabled){const o=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<o.length;e+=1){const t=i+o[e].text.length;if(r<t){l=e,s=r-i;break}i=t}if(-1!==l){const i=o[l];if("insert"===i.revision?.type){const o=[...U(t,0,r),...U(t,r+1,oe(t))],i=fe(t,o),l=a.map((e,t)=>t===n?i:e);return la(e,l,nt(ot(i,r)))}const c=i.text[s],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},u=[...U(t,0,r),d,...U(t,r+1,oe(t))],p=fe(t,u),g=a.map((e,t)=>t===n?p:e);return la(e,g,nt(ot(p,r)))}}const o=fe(t,[...U(t,0,r),...U(t,r+1,oe(t))],Et(t,r)),i=a.map((e,t)=>t===n?o:e);return la(e,i,nt(ot(o,r)))}if(n>=a.length-1)return e;const i=a[n+1],l=fe(t,[...t.runs.map(o),...i.runs.map(o)]),s=[...a.slice(0,n),l,...a.slice(n+2)];return la(e,s,nt(ot(l,r)))}function nl(e,t){const n=hr(e);if(n.isCollapsed)return e;const o=Oo(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((e,t)=>{const o=n.startIndex+t,r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:oe(e);return U(e,r,a)}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.[t])),i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:oe(e);return ne(e,r,i,e=>({...e,styles:Wo(e.styles,t,a)}))});return la(e,i,xe(i,n))}function ol(e,t,n){const o=hr(e);if(o.isCollapsed)return e;const r=Oo(e).map((e,r)=>{if(r<o.startIndex||r>o.endIndex)return e;const a=r===o.startIndex?o.startParagraphOffset:0,i=r===o.endIndex?o.endParagraphOffset:oe(e);return ne(e,a,i,e=>({...e,styles:pr(e.styles,t,n)}))});return la(e,r,xe(r,o))}function rl(e,t){const n=hr(e);if(n.isCollapsed)return e;const o=Oo(e),r=e.document.styles,a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:oe(e);return ne(e,a,i,n=>{const o=(De(n.styles,e.style?.styleId,r).fontSize??14.6667)*Uo,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:pr(n.styles,"fontSize",a/Uo)}})});return la(e,a,xe(a,n))}var al={width:.5,type:"solid",color:"#000000"};function il(e,t){const n={...e??{}};return t?n.textBorder=al:delete n.textBorder,Object.keys(n).length>0?n:void 0}function ll(e){return/\p{L}/u.test(e)}function sl(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=ll(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&&ll(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function cl(e,t){return function(e,t){const n=hr(e);if(n.isCollapsed)return e;const o=Oo(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:oe(e),i=t(U(e,r,a).map(e=>e.text).join(""));let l=0;return ne(e,r,a,e=>{const t=e.text.length,n=i.slice(l,l+t);return l+=t,{...e,text:n}})});return la(e,o,xe(o,n))}(e,e=>sl(e,t))}function dl(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 ul(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function pl(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function gl(e,t){const n=He(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 fl(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:fl(e.blocks,t)}))}))}})}function ml(e,t,n){const o=He(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function hl(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function bl(e){const t=Fn(e),n=dt(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:hl(n)}:null}function yl(e,t,n){const o=t[0];if(!o)return e;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return e;if(1===t.length){const t=n(r);if(t===r)return e;const a=[...e];return a[o.tableBlockIndex]=t,a}const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return e;const l=yl(i.blocks,t.slice(1),n);if(l===i.blocks)return e;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function vl(e,t){return Boolean(e?.some(e=>C(e).some(e=>e.id===t)))}function xl(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?vl(e.firstPageHeader,n)?"firstPage":vl(e.evenPageHeader,n)?"evenPage":"default":vl(e.firstPageFooter,n)?"firstPage":vl(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[Yn(t,o)]??null}return null}function wl(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?vl(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:vl(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?vl(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:vl(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function Sl(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?Sl(a.blocks,t.slice(1)):null}function Il(e,t,n){const o=t[0];if(!o)return null;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return null;if(1===t.length)return[...e.slice(0,o.tableBlockIndex),...n,...e.slice(o.tableBlockIndex+1)];const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return null;const l=Il(i.blocks,t.slice(1),n);if(!l)return null;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function Cl(e){const t=bl(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return Pl(e,r);const a=He(e.document)[n];return a?xl(a,o.zone,r):null}function Tl(e){const t=e.selection.focus.paragraphId,n=Un(e);if("footnote"===n)return Pl(e,t);const o=Fn(e),r=He(e.document)[o];return r?xl(r,n,t):null}function Pl(e,t){const n=yn(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function kl(e,t){const n=bl(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>Il(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=yn(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=He(e.document).map((e,t)=>t===o?wl(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function Rl(e,t){const n=bl(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>yl(e,r.tablePath,t);if("footnote"===r.zone){const t=yn(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=He(e.document).map((e,t)=>t===o?wl(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var Bl={width:.5,type:"solid",color:"#000000"},Ml={width:0,type:"none",color:"transparent"};function Fl(e){const t=Fn(e),n=dt(e.document,e.selection.anchor.paragraphId,t),o=dt(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=ml(e.document,t,n.zone);if(!r)return null;const a=M(r,n.tablePath),i=M(r,o.tablePath),l=a?.[a.length-1],s=i?.[i.length-1];if(!l||!s||l.table!==s.table)return null;const c=n.tablePath[n.tablePath.length-1],d=o.tablePath[o.tablePath.length-1];if(!c||!d)return null;const u=Vt(l.table),p=u.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex),g=u.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex);if(!p||!g)return null;const f=Math.min(p.visualRowIndex,g.visualRowIndex),m=Math.max(p.visualRowIndex+p.rowSpan-1,g.visualRowIndex+g.rowSpan-1),h=Math.min(p.visualColumnIndex,g.visualColumnIndex),b=Math.max(p.visualColumnIndex+p.colSpan-1,g.visualColumnIndex+g.colSpan-1);return{entries:u,selectedEntries:u.filter(e=>e.visualRowIndex<=m&&e.visualRowIndex+e.rowSpan-1>=f&&e.visualColumnIndex<=b&&e.visualColumnIndex+e.colSpan-1>=h),startRow:f,endRow:m,startCol:h,endCol:b}}function Al(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=Fl(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of C(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=hr(e),o=Oo(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:{...ul(),type:"property",previous:{...r??{}}}}),{...o,style:pl(r,t,n)}},a=He(e.document).map(e=>({...e,blocks:Rt(e.blocks,o,r),header:e.header?Rt(e.header,o,r):void 0,footer:e.footer?Rt(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function Ol(e,t){let n=Al(e,"borderTop",t);return n=Al(n,"borderRight",t),n=Al(n,"borderBottom",t),n=Al(n,"borderLeft",t),n}function Dl(e,t,n){const o=function(e){const t=hr(e),n=Oo(e),o=/* @__PURE__ */new Set;for(let r=t.startIndex;r<=t.endIndex;r+=1)o.add(n[r].id);return o}(e),r=a=>a.map(a=>{if("paragraph"===a.type)return a;const i=a.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:r(e.blocks)}))})),l={...a,rows:i};return function(e,t){return e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>"paragraph"===e.type&&t.has(e.id))))}(a,o)?(o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&!r?.revision&&(r={...r??{},revision:{...ul(),type:"property",previous:{...r??{}}}}),{...o,style:pl(r,t,n)}})(l):l});return gl(e,r)}function El(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:{...ul(),type:"property",previous:{...a??{}}}}),{...r,style:pl(a,n,o)}};return gl(e,e=>fl(e,r))}function Ll(e,t,n){const o=bl(e);if(!o)return e;return Rl(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:{...ul(),type:"property",previous:{...o??{}}}}),{...r,style:pl(o,t,n)}})():r);return{...r,rows:a}})}function Nl(e,t){const n=bl(e);if(!n)return e;return Rl(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:{...ul(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:pl(a,"isHeader",i??null)}})}))}function $l(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:{...ul(),type:"property",previous:{...r??{}}}}),{...t,style:pl(r,"height",n[o])}});return{...o,rows:r}};return gl(e,e=>fl(e,o))}function zl(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*Uo:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Hl(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=Vt(a),l=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),s=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(s);let d=!1,u=!0;for(let e=0;e<s;e+=1){const t=zl(n[e]);if(null!==t){c[e]=Math.max(1,t),d=!0;continue}const o=a.gridCols?.[e];if(!("number"==typeof o&&Number.isFinite(o)&&o>0)){u=!1;break}c[e]=o}const p=a.rows.map((t,o)=>{const r=t.cells.map((t,r)=>{const a=l.get(`${o}:${r}`);if(!a)return t;const i=n[a.visualColumnIndex+a.colSpan-1];if(void 0!==i&&1===a.colSpan){const n=e.trackChangesEnabled&&!t.style?.propertyRevision?{...ul(),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={...ul(),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?{...ul(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return gl(e,e=>fl(e,a))}function Wl(e){const t=bl(e);if(!t)return e;const n=Cl(e);if(!n)return e;const o=Sl(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(Kt(n));return t}(o);if(0===r.length)return e;const a=kl(e,r);if(a===e)return e;const i=r[0];return{...a,selection:nt(ot(i,0))}}function Ul(e){if(bl(e))return e;if(!Tl(e))return e;const t=Oo(e);if(0===t.length)return e;const n=hr(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(jl),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>ao(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:kn("paragraph"),type:"paragraph",runs:o.length>0?o:[On("")]};return Lo([r])})));return tr(o)}(o),a=o[0].id,i=o[o.length-1].id;let l=null,s=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=Un(e),r=Fn(e);if("footnote"===o){const o=yn(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=He(e.document).map((e,a)=>a===r?wl(e,o,n,t):e);return{...e,document:{...e.document,sections:a}}}(e,e=>{const{nextBlocks:t,cell:n}=function(e,t,n,o){let r=-1,a=-1;for(let l=0;l<e.length;l+=1){const o=e[l];"paragraph"===o.type&&(o.id===t&&(r=l),o.id===n&&(a=l))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let l=r;l<=a;l+=1)if("paragraph"!==e[l].type)return{nextBlocks:null,cell:null};const i=o.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return{nextBlocks:[...e.slice(0,r),o,...e.slice(a+1)],cell:i??null}}(e,a,i,r);return t&&n?(l=n,s=!0,t):e});return s&&l?{...c,selection:nt(ot(l,0))}:e}function jl(e){const t=[];let n=[];const r=()=>{n.length>0&&t.push(n),n=[]};for(const a of e.runs){const e=a.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&r();const i=e[t];if(i.length>0){const e=o(a);e.id=`run:${Math.random().toString(36).slice(2,9)}`,e.text=i,n.push(e)}}}return n.length>0&&t.push(n),t}function Vl(e,t){const n=bl(e);if(!n)return e;const o=n.loc.cellIndex;return Rl(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const s of e.rows)s.isHeader?o.push(s):r.push(s);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=Kl(e.cells[t]),r=Kl(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),l=[...o,...i];return l.length===e.rows.length&&l.every((t,n)=>t===e.rows[n])?e.rows:l}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function Kl(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:C(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function _l(e){return!0===e.isHeader}function Xl(e){return null!==bl(e)}function Gl(e){return null!==bl(e)}var Yl=/* @__PURE__ */new Set(["left","center","right"]);function ql(e,t){const n=bl(e);if(!n)return e;if(null!==t&&!Yl.has(t))return e;const o=function(e,t){const n=bl(e);if(!n)return null;const o=M(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,ml(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:Dl(e,"align",a)}function Zl(e){return null!==bl(e)}var Jl=["SUM","AVERAGE","COUNT","MIN","MAX"];function Ql(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 Jl.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=bl(e);if(!o)return e;const r=Cl(e);if(!r)return e;const a=Sl(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=Vt(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(!ts(r,i,t))continue;if(!ns(r,i,t))continue;const e=os(es(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const l=function(e){if(Number.isInteger(e)||!Number.isFinite(e))return String(e);const t=Math.round(1e6*e)/1e6;return String(t)}(function(e,t){switch(e){case"SUM":return t.reduce((e,t)=>e+t,0);case"AVERAGE":return t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0;case"COUNT":return t.length;case"MIN":return t.length>0?Math.min(...t):0;case"MAX":return t.length>0?Math.max(...t):0}}(n.function,i)),s=o.loc.rowIndex,c=o.loc.cellIndex,d=Rl(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Bo(l)]})})}));if(d===e)return e;const u=Bo(l);return{...d,selection:nt(ot(u,l.length))}}function es(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:C(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function ts(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 ns(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 os(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 rs(e,t){const n=function(e){const t=bl(e);if(!t)return null;const n=Cl(e);if(!n)return null;const o=Sl(n,t.loc.tablePath);if(!o)return null;const r=Vt(o),a=r.find(e=>e.rowIndex===t.loc.rowIndex&&e.cellIndex===t.loc.cellIndex);return a?{table:o,entries:r,active:a}:null}(e);if(!n)return e;const{table:o,entries:r,active:a}=n,i=function(e,t,n,o){switch(o){case"cell":return[n];case"row":{const e=n.visualRowIndex,o=n.visualRowIndex+n.rowSpan;return t.filter(t=>{const n=t.visualRowIndex,r=t.visualRowIndex+t.rowSpan;return n<o&&e<r})}case"column":{const e=n.visualColumnIndex,o=n.visualColumnIndex+n.colSpan;return t.filter(t=>{const n=t.visualColumnIndex,r=t.visualColumnIndex+t.colSpan;return n<o&&e<r})}case"table":return[...t]}}(0,r,a,t);if(0===i.length)return e;const l=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),s=l[0].cell,c=l[l.length-1].cell,d=as(s),u=as(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:ot(p,0),focus:ot(g,we(g).length)}}:e}function as(e){return e.blocks.flatMap(C)}function is(e){const t=function(e){const t=bl(e);if(!t)return null;const n=Cl(e);if(!n)return null;const o=Sl(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function ls(e){const t=bl(e);if(!t)return e;const n=Cl(e);if(!n)return e;const o=Sl(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex,a=t.loc.cellIndex,i=o.rows[r];if(!i||i.cells.length<=1||a>=i.cells.length)return e;const l=Rl(e,e=>{const t=e.rows.map((e,t)=>{if(t!==r)return e;const n=e.cells.filter((e,t)=>t!==a);return{...e,cells:n}});return{...e,rows:t}});if(l===e)return e;const s=i.cells[Math.min(a,i.cells.length-2)],c=s?s.blocks.flatMap(C)[0]??null:null;return c?{...l,selection:nt(ot(c,0))}:l}var ss={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 cs(e){const t=Fn(e),n=dt(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=M(function(e,t){const n=He(e.document)[Fn(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=Vt(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 ds(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 us(e){return!!e&&"none"!==e.type&&e.width>0}function ps(e,t="table"){const n=ds(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=ds(o?.style?.height),i=ds(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=ds(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(us)[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{...ss,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:ds(e.table.style?.indentLeft).value,tableWrapping:u?"around":"none",floatingSummary:u,floatingHorizontalAnchor:e.table.style?.floating?.horizontalAnchor??"margin",floatingVerticalAnchor:e.table.style?.floating?.verticalAnchor??"text",floatingX:null!=e.table.style?.floating?.x?String(e.table.style.floating.x):"0",floatingY:null!=e.table.style?.floating?.y?String(e.table.style.floating.y):"0",floatingXAlign:e.table.style?.floating?.xAlign??"",floatingYAlign:e.table.style?.floating?.yAlign??"",floatingDistanceTop:String(e.table.style?.floating?.distanceTop??0),floatingDistanceRight:String(e.table.style?.floating?.distanceRight??0),floatingDistanceBottom:String(e.table.style?.floating?.distanceBottom??0),floatingDistanceLeft:String(e.table.style?.floating?.distanceLeft??0),floatingOverlap:e.table.style?.tblOverlap??"overlap",rowHeight:a.value,rowHeightRule:o?.style?.heightRule??"",repeatHeader:Boolean(o?.isHeader),allowBreakAcrossPages:!0!==o?.style?.cantSplit,hiddenRow:!0===o?.style?.hidden,columnWidth:s.value,cellWidth:i.value,cellVerticalAlign:c.verticalAlign??"",cellTextDirection:c.textDirection??"",cellNoWrap:!0===c.noWrap,cellFitText:!0===c.fitText,cellHideMark:!0===c.hideMark,marginTop:null!=c.paddingTop?String(c.paddingTop):"",marginRight:null!=c.paddingRight?String(c.paddingRight):"",marginBottom:null!=c.paddingBottom?String(c.paddingBottom):"",marginLeft:null!=c.paddingLeft?String(c.paddingLeft):"",borderStyle:d?.type??"none",borderWidth:d?String(d.width):"",borderColor:d?.color??"",borderTop:us(c.borderTop),borderRight:us(c.borderRight),borderBottom:us(c.borderBottom),borderLeft:us(c.borderLeft),borderStart:us(c.borderStart),borderEnd:us(c.borderEnd),borderTopLeftToBottomRight:us(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:us(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function gs(e,t,n){return Al(e,t,n)}function fs(e){return Boolean(cs(e))}function ms(e,t="table"){const n=cs(e);return n?ps(n,t):null}function hs(e){const t=()=>fs(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=ms(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=cs(e);if(!n)return e;let o=e;return o=El(o,n.tableId,"width",t.tableWidth),o=El(o,n.tableId,"align",t.tableAlign),o=El(o,n.tableId,"indentLeft",t.tableIndentLeft),o=El(o,n.tableId,"floating",t.tableFloating),o=El(o,n.tableId,"tblOverlap",t.tableOverlap),o=El(o,n.tableId,"altTitle",t.altTitle),o=El(o,n.tableId,"altDescription",t.altDescription),o=Nl(o,t.repeatHeader),o=Ll(o,"height",t.rowHeight),o=Ll(o,"heightRule",t.rowHeightRule),o=Ll(o,"cantSplit",t.cantSplit),o=Ll(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Hl(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=gs(o,"width",t.cellWidth),o=gs(o,"verticalAlign",t.cellVerticalAlign),o=gs(o,"textDirection",t.cellTextDirection),o=gs(o,"noWrap",t.cellNoWrap),o=gs(o,"fitText",t.cellFitText),o=gs(o,"hideMark",t.cellHideMark),o=gs(o,"paddingTop",t.margins.top),o=gs(o,"paddingRight",t.margins.right),o=gs(o,"paddingBottom",t.margins.bottom),o=gs(o,"paddingLeft",t.margins.left),o=gs(o,"borderTop",t.borders.top),o=gs(o,"borderRight",t.borders.right),o=gs(o,"borderBottom",t.borders.bottom),o=gs(o,"borderLeft",t.borders.left),o=gs(o,"borderStart",t.borders.start),o=gs(o,"borderEnd",t.borders.end),o=gs(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=gs(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=gs(o,"shading",t.shading),o}(e,n),{mergeKey:_a}),e.focusInput())}}}function bs(e){const t=hr(e);if(t.isCollapsed)return"";const n=Oo(e),o=[];let r=null;const a=()=>{r&&(o.push("bullet"===r?"</ul>":"</ol>"),r=null)};for(let i=t.startIndex;i<=t.endIndex;i+=1){const l=n[i];if(!l)continue;const s=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:oe(l),d=U(l,s,c),u=Ee(l.style),p=u.length>0?` style="${u}"`:"",g=Be(d,e.document);if(l.list?.kind){const e="bullet"===l.list.kind?"ul":"ol";r!==l.list.kind&&(a(),o.push(`<${e}>`),r=l.list.kind),o.push(`<li${p}>${g}</li>`);continue}a(),o.push(`<p${p}>${g}</p>`)}return a(),o.join("")}function ys(e,t){if(0===t.length)return e;const n=_o(e.selection)?e:Ke(e),{paragraph:r,index:a,offset:i}=E(n),l=Oo(n),s=U(r,0,i),c=U(r,i,oe(r)),d=t.map(e=>{const t=Mr(e.runs.map(e=>({text:e.text,styles:Cr(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let u,p=nt(ot(r,i));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=fe(r,[...s,...e.runs.map(o),...c],Et(r,i));n.style=r.style?{...r.style}:e.style?{...e.style}:void 0,n.list=r.list?{...r.list}:e.list?{...e.list}:void 0,u=[...tt(l.slice(0,a)),n,...tt(l.slice(a+1))],p=nt(ot(n,s.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=d[0],t=d[d.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),g=fe(r,[...s,...e.runs.map(o)],Et(r,i));g.style=r.style?{...r.style}:e.style?{...e.style}:void 0,g.list=r.list?{...r.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(Kt),m=fe(t,[...t.runs.map(o),...c],void 0);m.list=t.list?{...t.list}:void 0,u=[...tt(l.slice(0,a)),g,...f,m,...tt(l.slice(a+1))],p=nt(ot(m,n))}return la(n,u,p)}function vs(e,t){return{document:e.document,selection:t}}function xs(e,t){if(!_o(e.selection))return Oe(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=E(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return vs(e,nt(ot(i,Math.min(r,oe(i)))))}function ws(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=E(e),i=oe(o);if(t<0&&a>0)return vs(e,{anchor:e.selection.anchor,focus:ot(o,a-1)});if(t>0&&a<i)return vs(e,{anchor:e.selection.anchor,focus:ot(o,a+1)});if(t<0&&r>0){const t=n[r-1];return vs(e,{anchor:e.selection.anchor,focus:ot(t,oe(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return vs(e,{anchor:e.selection.anchor,focus:ot(t,0)})}return e}function Ss(e,t){const{paragraphs:n,index:o,offset:r}=E(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return vs(e,{anchor:e.selection.anchor,focus:ot(i,Math.min(r,oe(i)))})}function Is(e){const t=hr(e);if(t.isCollapsed)return"";const n=Oo(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return we(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(we(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(we(n[i]));return o.push(we(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Cs(e,t){return{...e,selection:{anchor:Ho(e,t.anchor),focus:Ho(e,t.focus)}}}function Ts(e){if(!_o(e.selection))return Oe(e,"start");const{paragraph:t,index:n,offset:o}=E(e),r=Oo(e);if(o>0)return{document:e.document,selection:nt(ot(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:nt(ot(a,oe(a)))}}function Ps(e){if(!_o(e.selection))return Oe(e,"end");const{paragraph:t,index:n,offset:o}=E(e),r=Oo(e);if(o<oe(t))return{document:e.document,selection:nt(ot(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:nt(ot(a,0))}}function ks(){return"undefined"!=typeof navigator&&Boolean(navigator.clipboard?.write||navigator.clipboard?.writeText)||"undefined"!=typeof document&&"function"==typeof document.execCommand}function Rs(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 Bs(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>Rs(e))}catch{}return Promise.resolve(Rs(e))}function Ms(e){const t=Is(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=bs(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,()=>Bs(t))}catch{}return Bs(t)}async function Fs(e){if(e.isReadOnly())return!1;const t=e.state();if(!Is(t))return!1;if(!(await Ms(t))||e.isReadOnly()||e.state().document!==t.document)return!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=>el(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}var As=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function Os(e,t){const n=Cr(e)??{};delete n.link;for(const o of As)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function Ds(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:[Kn("")];n.push({runs:r.map(e=>{const t=Ut(e);return{text:e.text,styles:Cr(e.styles),image:t?{...t}:void 0}}),style:e?Z(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,It(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,[Kn(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=V(e.tagName);if(t){a(e,t);continue}if(Nt(e.tagName)){r(e,It(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=It(e,void 0);n.length>0&&r(null,n)}return n}function Es(){return"undefined"!=typeof navigator&&Boolean(navigator.clipboard?.read||navigator.clipboard?.readText)}async function Ls(e,t){if(e.isReadOnly()||!Es())return!1;const n=e.state(),o={anchor:{...n.selection.anchor},focus:{...n.selection.focus}};let r;try{r=await async function(e){const t=navigator.clipboard;if(!t)return null;if("text"===e&&t.readText)try{return{text:await t.readText(),html:""}}catch{}if(t.read)try{const n=await t.read();let o="",r="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(o=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(r=await(await t.getType("text/plain")).text());if(o||r)return{html:o,text:r}}catch{}if(t.readText)try{return{text:await t.readText(),html:""}}catch{return null}return null}(t)}catch(s){return e.onError?.(s),!1}if(!r||e.isReadOnly()||e.state().document!==n.document)return!1;const a="text"!==t?Ds(r.html):[],i="merge"===t?function(e,t){if(0===t.length)return[];const n=hr(e),o=Oo(e)[n.startIndex];if(!o)return t;const r=Et(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:Os(r,e.styles)})),style:Nn(o.style),list:o.list?{...o.list}:void 0}))}({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let l=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},s=e.applyTableAwareParagraphEdit(a,e=>i.length>0?ys(e,i):Qi(e,r.text));return l=s.document!==t.document,s}),l&&e.focusInput(),l}function Ns(e){return function(e){const t=e.t,n=async()=>{await Ms(e.state())||e.logger.warn("contextMenu:copy:failed")},o=async()=>{await Fs({state:e.state,isReadOnly:e.isReadOnly,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.applyTableAwareParagraphEdit,focusInput:e.focusInput})||e.logger.warn("contextMenu:cut:not-completed")},r=async()=>{await Ls({state:e.state,isReadOnly:e.isReadOnly,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput,onError:t=>{e.logger.warn("contextMenu:paste:failed",{error:String(t)})}},"rich")},a=()=>{const a=!_o(e.state().selection),i=e.isReadOnly(),l=[{id:"cut",label:t("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!a,testId:"editor-context-menu-cut",onSelect:()=>{o()}},{id:"copy",label:t("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!a,testId:"editor-context-menu-copy",onSelect:()=>{n()}},{id:"paste",label:t("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{r()}},{id:"sep1",type:"separator"},{id:"link",label:t("contextmenu.link"),icon:"link",disabled:i||!a,testId:"editor-context-menu-link",onSelect:e.promptForLink},{id:"font",label:t("contextmenu.font"),icon:"type",disabled:i||!a,testId:"editor-context-menu-font",onSelect:e.openFontDialog},{id:"paragraph",label:t("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:e.openParagraphDialog}],s=e.table;return s?.isInsideTable()&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:t("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},i=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},l=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:a,closeContextMenu:l,handleEditorContextMenu:i,programmaticCopy:n,programmaticCut:o,programmaticPaste:r}}(e)}function $s(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),Ja),split:()=>o(e=>n.splitSelectedTable(e),Qa),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),ei),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),ei),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),ti),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),ni),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),ni),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),oi)}}function zs(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=Ia({state:e.state,toolbarStyleState:e.toolbarStyleState}),a=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:un(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()||(_o(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=ol(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=ol(o,"fontSize",mr(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=ol(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=ol(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=ol(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=nl(o,"bold")),t.italic!==Boolean(n.italic)&&(o=nl(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=ol(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=ol(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=nl(o,"underline")),t.strike!==Boolean(n.strike)&&(o=nl(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=nl(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=nl(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=nl(o,"subscript")),t.superscript&&t.subscript&&(o=nl(o,"subscript")),t.strike&&t.doubleStrike&&(o=nl(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=nl(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=nl(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=nl(o,"hidden"));const l=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(l??null)&&(o=ol(o,"characterScale",t.characterScale));const s=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(s??null)&&(o=ol(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=ol(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=ol(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=ol(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=ol(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=ol(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=ol(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=nl(o,"contextualAlternates")),o},{mergeKey:Ga})),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}),i=a.openFontDialog,l=function(e){return{openParagraphDialog:()=>{var t;e.setParagraphDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{align:t.align??"",indentLeft:t.indentLeft??"",indentRight:t.indentRight??"",indentFirstLine:t.indentFirstLine??"",indentHanging:t.indentHanging??"",mirrorIndents:t.mirrorIndents??!1,spacingBefore:t.spacingBefore??"",spacingAfter:t.spacingAfter??"",lineHeight:t.lineHeight??"",lineRule:t.lineRule??"",contextualSpacing:t.contextualSpacing??!1,outlineLevel:t.outlineLevel??"",shading:t.shading??"",borderStyle:t.borderStyle??"",borderWidth:t.borderWidth??"",borderColor:t.borderColor??"",borderSideTop:t.borderSideTop??!1,borderSideRight:t.borderSideRight??!1,borderSideBottom:t.borderSideBottom??!1,borderSideLeft:t.borderSideLeft??!1,pageBreakBefore:t.pageBreakBefore??!1,keepWithNext:t.keepWithNext??!1,keepLinesTogether:t.keepLinesTogether??!1,widowControl:t.widowControl??!0,tabs:t.tabs??[]})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(t,n)=>{if(e.isReadOnly())return;e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e=>{if(""===e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null};e.applyTransactionalState(e=>{let a=e;t.align!==(n.align||null)&&(a=r(a,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(a=r(a,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(a=r(a,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(a=r(a,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(a=r(a,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(a=r(a,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(a=r(a,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(a=r(a,"lineHeight",t.lineHeight));const i=n.lineRule||null;t.lineRule!==i&&(a=r(a,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(a=r(a,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(a=r(a,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(a=r(a,"contextualSpacing",t.contextualSpacing));const l=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==l&&(a=r(a,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(a=r(a,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(a=r(a,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(a=r(a,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(a=r(a,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(a=r(a,"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,c={borderTop:n.borderSideTop?s:null,borderRight:n.borderSideRight?s:null,borderBottom:n.borderSideBottom?s:null,borderLeft:n.borderSideLeft?s:null},d={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(d[t])!==JSON.stringify(c[t])&&(a=r(a,t,d[t]));return a},{mergeKey:Xa}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=ho(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:dl(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=l.openParagraphDialog,c=hs({state:e.state,isReadOnly:e.isReadOnly,setTablePropertiesDialog:e.setTablePropertiesDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),d=c.openTablePropertiesDialog,u=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},p=Ns({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:i,openParagraphDialog:s,table:$s({state:e.state,tableOps:e.tableOps,isInsideTable:c.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:u})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:a.applyFontDialogValues,applyParagraphDialogValues:l.applyParagraphDialogValues,setParagraphDialogDefault:l.setParagraphDialogDefault,applyTablePropertiesDialogValues:c.applyTablePropertiesDialogValues,buildContextMenuItems:p.buildContextMenuItems,handleEditorContextMenu:p.handleEditorContextMenu,closeContextMenu:p.closeContextMenu}}(e)}function Hs(e){const t=At(()=>{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=Oo(e.state).find(e=>e.id===t.paragraphId),r=n?sa(n,t):0,a=jn(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=Do(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const l=e.caretViewport?.()??null;if(l)return r=l.left,a=l.top,i=Math.max(12,Math.min(36,l.height)),{viewportLeft:r,viewportTop:a,height:i};const s=e.pointerPos?.()??null;return s?(r=s.x,a=s.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return ua(it,{get when(){return t()},children:e=>ua(Ge,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var Ws=/*#__PURE__*/z("<div class=oasis-editor-table-resize-guide>"),Us=/*#__PURE__*/z("<div class=oasis-editor-table-resize-outline>"),js=/*#__PURE__*/z("<img class=oasis-editor-image-ghost>"),Vs=/*#__PURE__*/z("<div class=oasis-editor-table-ghost>");function Ks(e){return[ua(it,{get when(){return e.tableResize.resizing()},children:e=>{return t=Ws(),Q(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=Ye(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),ua(it,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Us(),Q(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&Fe(t,"left",n.e=o),r!==n.t&&Fe(t,"top",n.t=r),a!==n.a&&Fe(t,"width",n.a=a),i!==n.o&&Fe(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),ua(it,{get when(){return Co(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=js(),Q(o=>{var r=t().src,a=`${t().width}px`,i=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",s=e.imageOps.mousePos().y-t().offsetY+"px";return r!==o.e&&yo(n,"src",o.e=r),a!==o.t&&Fe(n,"width",o.t=a),i!==o.a&&Fe(n,"height",o.a=i),l!==o.o&&Fe(n,"left",o.o=l),s!==o.i&&Fe(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),ua(it,{get when(){return Co(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=Vs(),Q(o=>{var r=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",l=e.tableDrag.mousePos().y-t().offsetY+"px";return r!==o.e&&Fe(n,"width",o.e=r),a!==o.t&&Fe(n,"height",o.t=a),i!==o.a&&Fe(n,"left",o.a=i),l!==o.o&&Fe(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),ua(it,{get when(){return Co(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>ua(Hs,{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})}),ua(it,{get when(){return Co(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>ua(Hs,{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})}),ua(it,{get when(){return Co(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>ua(Hs,{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 _s(e){return[ua(Le,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),ua(Le,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Xs(e){const t=x(),[n,o]=Tt(e.initialValue);let r;g(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return ua(mt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return ua(_s,{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 ua(eo,{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 Gs(e){const t=x();return ua(Xs,{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 Ys(e){const t=x();return ua(Xs,{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 qs(e){const t=x();return ua(Xs,{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 Zs=/*#__PURE__*/z("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Js=/*#__PURE__*/z("<div class=oasis-editor-comment-composer>");function Qs(e){const t=x(),[n,o]=Tt(""),[r,a]=Tt("");let i;const l=e.composer.draft,s=()=>("edit"===l()?.mode||n().trim().length>0)&&r().trim().length>0,c=()=>{s()&&e.composer.submit(n(),r())};return g(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),ua(mt,{get isOpen(){return null!==l()},get title(){return t("edit"===l()?.mode?"toolbar.editComment":"reply"===l()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[ua(Le,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),ua(Le,{variant:"primary",get disabled(){return!s()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var s=Js();return je(s,ua(it,{get when(){return"reply"===l()?.mode},get children(){var e=Zs();return je(e,ua(Er,{as:"strong",get children(){return[Co(()=>t("comment.replyTo"))," ",Co(()=>l()?.parentAuthor)]}}),null),je(e,ua(Er,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),je(s,ua(eo,{get label(){return t("comment.author")},get value(){return n()},onChange:o,maxLength:150,required:!0,get disabled(){return"edit"===l()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),je(s,ua(lo,{ref(e){"function"==typeof i?i(e):i=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return r()},onChange:a,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),c())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),s}})}var ec=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],tc=[33,50,66,75,90,100,105,110,115,120,150,200];function nc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function oc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function rc(e){return null==e||""===e?"":String(e)}function ac(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function ic(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function lc(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function sc(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 cc(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 dc(e,t){const n=[],o=lc(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function uc(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 pc(e){return{characterScale:rc(e.characterScale),spacingMode:ac(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:ic(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:rc(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:rc(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function gc(e){const t=x(),[n,o]=Tt("font"),[r,a]=Tt(uc(e.initial)),[i,l]=Tt(pc(e.initial));g(()=>{e.isOpen&&(o("font"),a(uc(e.initial)),l(pc(e.initial)))});const s=At(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=At(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=At(()=>{const t=new Set(ec);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=At(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=At(()=>{const e=i();return e.characterScale.trim()&&null===nc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===oc(e.spacingAmount)||"normal"!==e.positionMode&&null===oc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===oc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===lc(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),f=At(()=>function(e,t){const n=Number(e.fontSize),o=nc(t.characterScale)??100,r="normal"===t.spacingMode?null:oc(t.spacingAmount),a="normal"===t.positionMode?null:oc(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,l=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,s=[];return e.underline&&"none"!==e.underlineStyle&&s.push("underline"),e.strike&&s.push("line-through"),e.doubleStrike&&s.push("line-through"),{"font-family":e.fontFamily||"inherit","font-size":Number.isFinite(n)&&n>0?`${n}pt`:void 0,"font-weight":e.bold?700:400,"font-style":e.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":l??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":sc(t.ligatures),"font-variant-numeric":cc(t.numberSpacing,t.numberForm),"font-feature-settings":dc(t.stylisticSet,t.contextualAlternates)}}(r(),i()));return{activeTab:n,setActiveTab:e=>o(e),fontTabValues:r,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{l(n=>({...n,[e]:t}))},selectedFontStyle:s,visibleFamilyOptions:c,effectiveSizeOptions:d,customSizeError:u,advancedValidationError:p,previewStyle:f,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()?nc(t.characterScale):null,l="normal"===t.spacingMode?null:oc(t.spacingAmount),s="normal"===t.positionMode?null:oc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?oc(t.kerningThreshold):null,d=lc(t.stylisticSet);return{fontFamily:e.fontFamily.trim()?e.fontFamily.trim():null,fontSize:o?n:null,colorMode:e.colorMode,color:"automatic"===e.colorMode?null:e.color||null,highlight:e.highlight||null,shading:e.shading||null,bold:e.bold,italic:e.italic,underline:a,underlineStyle:r,underlineColor:a&&e.underlineColor||null,strike:e.strike,doubleStrike:e.doubleStrike,superscript:e.superscript,subscript:e.subscript,smallCaps:e.smallCaps,allCaps:e.allCaps,hidden:e.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===t.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===t.positionMode?-s:s,kerningThreshold:c,ligatures:t.ligatures||null,numberSpacing:t.numberSpacing||null,numberForm:t.numberForm||null,stylisticSet:d,contextualAlternates:t.contextualAlternates}}(r(),i());e.onApply(t,e.initial),e.onClose()}}}var fc=/*#__PURE__*/z("<div>");function mc(e){const t=x();return n=fc(),je(n,()=>t("dialog.font.previewText")),Q(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&A(n,t.e=o),r!==t.t&&yo(n,"data-testid",t.t=r),t.a=Ye(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var hc=/*#__PURE__*/z('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function bc(e){const t=x(),{ctrl:n}=e;return o=hc(),je(o,ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:12,get children(){return ua(eo,{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"})}}),ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{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}))]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(Xn,{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)}))]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return[ua(eo,{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"}),ua(In,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{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),je(o,ua(zr,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[ua(zr,{size:{xs:12,md:4},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua($o,{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"})}}),ua(zr,{size:{xs:12,md:2},get children(){return ua($o,{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"})}}),ua(zr,{size:{xs:12,md:2},get children(){return ua($o,{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),je(o,ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{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")},...Je.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua($o,{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),je(o,ua(dn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return ua(Ce,{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=>ua(xr,{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),je(o,ua(dn,{get label(){return t("dialog.font.preview")},get children(){return ua(mc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var yc=/*#__PURE__*/z("<div class=oasis-editor-font-dialog-kerning-line>"),vc=/*#__PURE__*/z('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function xc(e){const t=x(),{ctrl:n}=e;return o=vc(),je(o,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:4},get children(){return ua(Xn,{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 tc.map(e=>({value:String(e),label:`${e}%`}))}})}}),ua(zr,{size:{xs:12,md:8},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(eo,{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"})}})]}})}}),ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(eo,{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"})}}),ua(zr,{size:12,get children(){var e=yc();return je(e,ua(or,{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),je(e,ua(eo,{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),je(e,ua(In,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),je(o,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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)}))]}})}})]}}),ua(or,{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),je(o,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return ua(mc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),je(o,ua(In,{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 wc(e){const t=x(),n=gc(e);return ua(mt,{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 ua(_s,{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 ua(Qr,{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:ua(bc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:ua(xc,{ctrl:n})}]}})}})}var Sc=/*#__PURE__*/z("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),Ic=/*#__PURE__*/z("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Cc(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function Tc(e){const t=x(),[n,o]=Tt([]);g(()=>{e.isOpen&&o(e.initial.map(Cc))});const r=(e,t)=>{o(n=>n.map((n,o)=>o===e?{...n,...t}:n))},a=()=>{o(e=>[...e,{position:null,type:"left",leader:"none"}])},i=()=>{const t=n().filter(e=>null!==e.position).map(e=>({position:e.position,type:e.type,..."none"!==e.leader?{leader:e.leader}:{}})).sort((e,t)=>e.position-t.position);e.onApply(t),e.onClose()};return ua(mt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=Ic(),r=n.firstChild,a=r.nextSibling,je(r,ua(Le,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),je(a,ua(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),je(a,ua(Le,{variant:"primary",onClick:i,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){var e=Sc(),i=e.firstChild;return je(e,ua(Ce,{get each(){return n()},get fallback(){return ua(In,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>ua(zr,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[ua(zr,{size:{xs:12,md:4},get children(){return ua(En,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),ua(zr,{size:{xs:6,md:3},get children(){return ua(Xn,{get label(){return t("paragraph.tabsAlignment")},get value(){return e.type},onChange:e=>r(n(),{type:e}),get options(){return[{value:"left",label:t("paragraph.tabAlignLeft")},{value:"center",label:t("paragraph.tabAlignCenter")},{value:"right",label:t("paragraph.tabAlignRight")},{value:"decimal",label:t("paragraph.tabAlignDecimal")},{value:"bar",label:t("paragraph.tabAlignBar")}]}})}}),ua(zr,{size:{xs:6,md:3},get children(){return ua(Xn,{get label(){return t("paragraph.tabsLeader")},get value(){return e.leader},onChange:e=>r(n(),{leader:e}),get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:t("paragraph.tabLeaderDot")},{value:"hyphen",label:t("paragraph.tabLeaderHyphen")},{value:"underscore",label:t("paragraph.tabLeaderUnderscore")}]}})}}),ua(zr,{size:{xs:12,md:2},get children(){return ua(Le,{variant:"ghost",onClick:()=>(e=>{o(t=>t.filter((t,n)=>n!==e))})(n()),"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsRemove")}})}})]}})}),i),je(i,ua(Le,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var Pc=96/72;function kc(e){const[t,n]=Tt(""),[o,r]=Tt(""),[a,i]=Tt(null),[l,s]=Tt(null),[c,d]=Tt("none"),[u,p]=Tt(null),[f,m]=Tt(!1),[h,b]=Tt(null),[y,v]=Tt(null),[x,w]=Tt("multiple"),[S,I]=Tt(null),[C,T]=Tt(!1),[P,k]=Tt(""),[R,B]=Tt("none"),[M,F]=Tt(null),[A,O]=Tt(""),[D,E]=Tt(!1),[L,N]=Tt(!1),[$,z]=Tt(!1),[H,W]=Tt(!1),[U,j]=Tt(!1),[V,K]=Tt(!1),[_,X]=Tt(!1),[G,Y]=Tt(!0),[q,Z]=Tt([]);g(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(Jt(e.initial.indentLeft??"")),s(Jt(e.initial.indentRight??"")),m(e.initial.mirrorIndents??!1),b(Jt(e.initial.spacingBefore??"")),v(Jt(e.initial.spacingAfter??"")),T(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=Jt(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/Pc):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});w(a),I(l);const c=e.initial.borderStyle;B("solid"===c||"dashed"===c||"dotted"===c?c:"none"),F(Jt(e.initial.borderWidth??"")),O(e.initial.borderColor??""),E(e.initial.borderSideTop??!1),N(e.initial.borderSideRight??!1),z(e.initial.borderSideBottom??!1),W(e.initial.borderSideLeft??!1),j(e.initial.pageBreakBefore??!1),K(e.initial.keepWithNext??!1),X(e.initial.keepLinesTogether??!1),Y(e.initial.widowControl??!0),Z(e.initial.tabs??[]);const u=Jt(e.initial.indentFirstLine??""),g=Jt(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 J=()=>{switch(x()){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:S(),lineRule:null};case"atLeast":return{lineHeight:null!==S()?S()*Pc:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==S()?S()*Pc:null,lineRule:"exact"}}},Q=At(()=>{const e=a(),n=l(),o="firstLine"===c()?u():null,r="hanging"===c()?u():null,i=null!==o?o:null!==r?-r:null,s="none"!==R()?`${M()??.5}pt ${R()} ${A().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=J(),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":P().trim()||void 0,"border-top":s&&D()?s:void 0,"border-right":s&&L()?s:void 0,"border-bottom":s&&$()?s:void 0,"border-left":s&&H()?s:void 0}}),ee=()=>{const e=R();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=M(),n={type:e,width:null!==t&&t>0?t:.5,color:A().trim()||"#000000"};return{top:D()?n:null,right:L()?n:null,bottom:$()?n:null,left:H()?n:null}},te=()=>{const e=u(),{lineHeight:n,lineRule:r}=J(),i=o();return{align:t()||null,indentLeft:a(),indentRight:l(),indentFirstLine:"firstLine"===c()?e:null,indentHanging:"hanging"===c()?e:null,mirrorIndents:f(),spacingBefore:h(),spacingAfter:y(),lineHeight:n,lineRule:r,contextualSpacing:C(),outlineLevel:""===i?null:Number(i),shading:P().trim()||null,borders:ee(),pageBreakBefore:U(),keepWithNext:V(),keepLinesTogether:_(),widowControl:G(),tabs:q()}};return{align:t,setAlign:n,outlineLevel:o,setOutlineLevel:r,indentLeft:a,setIndentLeft:i,indentRight:l,setIndentRight:s,special:c,setSpecial:d,specialBy:u,setSpecialBy:p,mirrorIndents:f,setMirrorIndents:m,spacingBefore:h,setSpacingBefore:b,spacingAfter:y,setSpacingAfter:v,lineMode:x,setLineMode:w,lineAt:S,setLineAt:I,contextualSpacing:C,setContextualSpacing:T,shading:P,setShading:k,borderStyle:R,setBorderStyle:B,borderWidth:M,setBorderWidth:F,borderColor:A,setBorderColor:O,sideTop:D,setSideTop:E,sideRight:L,setSideRight:N,sideBottom:$,setSideBottom:z,sideLeft:H,setSideLeft:W,pageBreakBefore:U,setPageBreakBefore:j,keepWithNext:V,setKeepWithNext:K,keepLinesTogether:_,setKeepLinesTogether:X,widowControl:G,setWidowControl:Y,tabs:q,setTabs:Z,atEnabled:()=>"multiple"===x()||"atLeast"===x()||"exact"===x(),previewStyle:Q,handleApply:()=>{e.onApply(te(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(te()),e.onClose()}}}var Rc=/*#__PURE__*/z("<div class=oasis-editor-paragraph-dialog-panel>"),Bc=/*#__PURE__*/z("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),Mc=/*#__PURE__*/z("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Fc(e){const t=x(),[n,o]=Tt(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:l,indentLeft:s,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:g,specialBy:f,setSpecialBy:m,mirrorIndents:h,setMirrorIndents:b,spacingBefore:y,setSpacingBefore:v,spacingAfter:w,setSpacingAfter:S,lineMode:I,setLineMode:C,lineAt:T,setLineAt:P,contextualSpacing:k,setContextualSpacing:R,shading:B,setShading:M,borderStyle:F,setBorderStyle:A,borderWidth:O,setBorderWidth:D,borderColor:E,setBorderColor:L,sideTop:N,setSideTop:$,sideRight:z,setSideRight:H,sideBottom:W,setSideBottom:U,sideLeft:j,setSideLeft:V,pageBreakBefore:K,setPageBreakBefore:_,keepWithNext:X,setKeepWithNext:G,keepLinesTogether:Y,setKeepLinesTogether:q,widowControl:Z,setWidowControl:J,tabs:ee,setTabs:te,atEnabled:ne,previewStyle:oe,handleApply:re,handleSetDefault:ae}=kc(e),ie=ua(Xn,{get label(){return t("paragraph.alignLabel")},get value(){return r()},onChange:a,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:t("paragraph.alignLeft")},{value:"center",label:t("paragraph.alignCenter")},{value:"right",label:t("paragraph.alignRight")},{value:"justify",label:t("paragraph.alignJustify")}]}}),le=ua(Xn,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:l,"data-testid":"editor-paragraph-dialog-outline-level",get options(){return[{value:"",label:t("paragraph.outlineBodyText")},...Array.from({length:9},(e,n)=>({value:String(n),label:t("paragraph.outlineLevelN",[n+1])}))]}}),se=(ce=Rc(),je(ce,ua(Bn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},children:ie}),ua(zr,{size:{xs:12,md:6},children:le})]}})}}),null),je(ce,ua(Bn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},get children(){return ua(En,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(En,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(En,{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"})}}),ua(zr,{size:12,get children(){return ua(or,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:b,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),je(ce,ua(Bn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:4},get children(){return ua(En,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return y()??""},onChange:v,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(En,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return w()??""},onChange:S,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),ua(zr,{size:{xs:12,md:4}}),ua(zr,{size:{xs:12,md:8},get children(){return ua(Xn,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return I()},onChange:e=>{C(e)},"data-testid":"editor-paragraph-dialog-line-mode",get options(){return[{value:"single",label:t("paragraph.lineSpacingSingle")},{value:"onePointFive",label:t("paragraph.lineSpacingOnePointFive")},{value:"double",label:t("paragraph.lineSpacingDouble")},{value:"atLeast",label:t("paragraph.lineSpacingAtLeast")},{value:"exact",label:t("paragraph.lineSpacingExact")},{value:"multiple",label:t("paragraph.lineSpacingMultiple")}]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(En,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===I()?"0.05":"1"},get disabled(){return!ne()},get value(){return T()??""},onChange:P,"data-testid":"editor-paragraph-dialog-line-at"})}}),ua(zr,{size:12,get children(){return ua(or,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return k()},onChange:R,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),je(ce,ua(Bn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:3},get children(){return ua(Xn,{get label(){return t("paragraph.borderStyleLabel")},get value(){return F()},onChange:e=>{const t=e;A(t),"none"===t?($(!1),H(!1),U(!1),V(!1)):N()||z()||W()||j()||($(!0),H(!0),U(!0),V(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),ua(zr,{size:{xs:12,md:3},get children(){return ua(En,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===F()},get value(){return O()??""},onChange:D,"data-testid":"editor-paragraph-dialog-border-width"})}}),ua(zr,{size:{xs:12,md:3},get children(){return ua($o,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===F()},get value(){return E()||"#000000"},onChange:L,"data-testid":"editor-paragraph-dialog-border-color"})}}),ua(zr,{size:{xs:12,md:3},get children(){return ua($o,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:M,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),ua(dn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[ua(or,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===F()},get checked(){return N()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),ua(or,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===F()},get checked(){return z()},onChange:H,"data-testid":"editor-paragraph-dialog-border-side-right"}),ua(or,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===F()},get checked(){return W()},onChange:U,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),ua(or,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===F()},get checked(){return j()},onChange:V,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),ce);var ce;const de=(ue=Rc(),je(ue,ua(Bn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return ua(ia,{direction:"column",spacing:1,get children(){return[ua(or,{get label(){return t("paragraph.widowControlLabel")},get checked(){return Z()},onChange:J,"data-testid":"editor-paragraph-dialog-widow-control"}),ua(or,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return X()},onChange:G,"data-testid":"editor-paragraph-dialog-keep-with-next"}),ua(or,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Y()},onChange:q,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),ua(or,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return K()},onChange:_,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ue);var ue;return[ua(mt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",get footer(){return n=Mc(),r=n.firstChild,a=r.nextSibling,je(r,ua(Le,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),je(r,ua(Le,{variant:"secondary",onClick:ae,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),je(a,ua(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),je(a,ua(Le,{variant:"primary",onClick:re,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[ua(Qr,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:se,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:de,testId:"editor-paragraph-dialog-tab-breaks"}]}}),ua(dn,{get label(){return t("paragraph.preview")},get children(){var e=Bc();return je(e,()=>t("paragraph.previewText")),Q(t=>Ye(e,oe(),t)),e}})]}}),ua(Tc,{get isOpen(){return n()},get initial(){return ee()},onClose:()=>{o(!1)},onApply:te})]}function Ac(e,t){const n=Jt(e);return null===n?null:"percent"===t?`${n}%`:n}function Oc(e,t,n){if("none"===e)return null;const o=Jt(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function Dc(e){const[t,n]=T({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:""});g(()=>{var t;e.isOpen&&n(We({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=Oc(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:Ac(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:Ac(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:Jt(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:Jt(e.floatingY)??0},distanceTop:Jt(e.floatingDistanceTop)??0,distanceRight:Jt(e.floatingDistanceRight)??0,distanceBottom:Jt(e.floatingDistanceBottom)??0,distanceLeft:Jt(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:Ac(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:Ac(e.columnWidth,"points"),cellWidth:Ac(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:Jt(e.marginTop),right:Jt(e.marginRight),bottom:Jt(e.marginBottom),left:Jt(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 Ec(e,t,n,o,r=!1,a=!1){return ua(eo,{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 Lc=/*#__PURE__*/z("<div class=oasis-editor-table-properties-panel>");function Nc(e){const t=x(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=Lc(),je(r,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},get children(){return Ec(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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),je(r,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[ua(Ar,{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=>ua(Fo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),ua(zr,{container:!0,spacing:1.5,get children(){return ua(zr,{size:{xs:12,md:6},get children(){return Ec(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),je(r,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[ua(or,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),ua(or,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),ua(it,{get when(){return"around"===n().tableWrapping},get children(){return[ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),ua(zr,{size:{xs:12,md:3},get children(){return ua(Xn,{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}))]}})}}),ua(zr,{size:{xs:12,md:3},get children(){return ua(Xn,{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}))]}})}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),ua(or,{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 $c=/*#__PURE__*/z("<div class=oasis-editor-table-properties-panel>");function zc(e){const t=x(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=$c(),je(r,ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:6},get children(){return Ec(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),ua(zr,{size:{xs:12,md:6},get children(){return ua(Xn,{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),je(r,ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[ua(or,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),ua(or,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),ua(or,{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 Hc=/*#__PURE__*/z("<div class=oasis-editor-table-properties-panel>");function Wc(e){const t=x(),n=e.ctrl.set;return o=Hc(),je(o,ua(zr,{container:!0,spacing:1.5,get children(){return ua(zr,{size:{xs:12,md:6},get children(){return Ec(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var Uc=/*#__PURE__*/z("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),jc=/*#__PURE__*/z("<div class=oasis-editor-table-properties-panel>");function Vc(e){const t=x(),n=()=>e.ctrl.form,o=e.ctrl.set,r=At(()=>{const e=Oc(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=jc(),je(i,ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:4},get children(){return Ec(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:4},get children(){return ua(Xn,{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),je(i,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[ua(or,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),ua(or,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),ua(or,{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),je(i,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),je(i,ua(Bn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[ua(zr,{container:!0,spacing:1.5,get children(){return[ua(zr,{size:{xs:12,md:3},get children(){return ua(Xn,{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")}]}})}}),ua(zr,{size:{xs:12,md:3},get children(){return Ec(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),ua(zr,{size:{xs:12,md:3},get children(){return ua($o,{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"})}}),ua(zr,{size:{xs:12,md:3},get children(){return ua($o,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),ua(ia,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[ua(or,{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"}),ua(or,{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"}),ua(or,{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"}),ua(or,{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"}),ua(or,{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"}),ua(or,{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"}),ua(or,{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"}),ua(or,{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=Uc(),Q(t=>Ye(e,r(),t)),e)];var e}}),null),i;var i}var Kc=/*#__PURE__*/z("<div class=oasis-editor-table-properties-panel>");function _c(e){const t=x(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=Kc(),je(r,ua(eo,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),je(r,ua(lo,{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 Xc(e){const t=x(),n=Dc(e);return ua(mt,{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 ua(_s,{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 ua(Qr,{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:ua(Nc,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:ua(zc,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:ua(Wc,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:ua(Vc,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:ua(_c,{ctrl:n})}]}})}})}var Gc=/*#__PURE__*/z("<p data-testid=editor-new-document-message>");function Yc(e){const t=x();return ua(mt,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return ua(_s,{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=Gc();return je(e,()=>t("dialog.newDocument.message")),e}})}var qc=/*#__PURE__*/z("<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>"),Zc=/*#__PURE__*/z("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),Jc=/*#__PURE__*/z("<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>"),Qc=/*#__PURE__*/z("<option>"),ed=/*#__PURE__*/z("<button type=button class=oasis-editor-symbol-dialog-tile>"),td=/*#__PURE__*/z("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),nd=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function od(e){const t=x(),[n,o]=Tt("common"),[r,a]=Tt(Zo[0]),[i,l]=Tt(nd[0]),[s,c]=Tt(Zo[0].codePoint),d=At(()=>(e.isOpen,Mn())),u=At(()=>"all"===n()?Ao.flatMap(e=>e.entries):Ao.find(e=>e.id===n())?.entries??Zo),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&(Wn(t),e.onInsert(t,i()),e.onClose())};return ua(mt,{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[ua(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),ua(Le,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(w=qc(),S=w.firstChild,I=S.firstChild,C=I.nextSibling,T=S.nextSibling.firstChild,P=T.nextSibling,k=P.firstChild,je(I,()=>t("dialog.symbol.font")),C.addEventListener("change",e=>{l(e.currentTarget.value)}),je(C,ua(Ce,{each:nd,children:e=>{return(t=Qc()).value=e,je(t,e),t;var t}})),je(T,()=>t("dialog.symbol.subset")),P.addEventListener("change",e=>{o(e.currentTarget.value)}),je(k,()=>t("symbols.category.all")),je(P,ua(Ce,{each:Ao,children:e=>{return n=Qc(),je(n,()=>t(e.labelKey)),Q(()=>n.value=e.id),n;var n}}),null),Q(()=>C.value=i()),Q(()=>P.value=n()),w),(e=Jc(),f=e.firstChild,m=f.nextSibling.firstChild,h=m.nextSibling,b=h.nextSibling,y=b.firstChild,v=y.nextSibling,x=b.nextSibling,je(f,ua(it,{get when(){return d().length>0},get children(){var e=Zc(),n=e.firstChild,o=n.nextSibling;return je(n,()=>t("dialog.symbol.recent")),je(o,ua(Ce,{get each(){return d()},children:e=>{return(t=ed()).$$click=()=>p(e),je(t,()=>e.character),Q(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&yo(t,"title",n.e=o),r!==n.t&&yo(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),je(f,ua(Ce,{get each(){return u()},children:e=>{return(t=td()).$$dblclick=g,t.$$click=()=>p(e),je(t,()=>e.character),Q(n=>{var o=!(r().character!==e.character),a=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,l=`editor-symbol-dialog-${e.codePoint.replace(/[^A-Z0-9]/g,"-")}`;return o!==n.e&&t.classList.toggle("oasis-editor-symbol-dialog-tile-active",n.e=o),a!==n.t&&yo(t,"title",n.t=a),i!==n.a&&yo(t,"aria-label",n.a=i),l!==n.o&&yo(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),je(m,()=>t("dialog.symbol.preview")),je(h,()=>r().character),je(y,()=>t("dialog.symbol.code")),v.$$input=e=>(e=>{c(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||a({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),yo(v,"spellcheck",!1),je(x,()=>t("dialog.symbol.doubleClickHelp")),Q(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&yo(f,"aria-label",e.e=n),o!==e.t&&Fe(h,"font-family",e.t=o),e},{e:void 0,t:void 0}),Q(()=>v.value=s()),e)];var e,f,m,h,b,y,v,x,w,S,I,C,T,P,k}})}k(["input","click","dblclick"]);var rd=/*#__PURE__*/z("<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>"),ad=/*#__PURE__*/z("<button type=button data-testid=editor-equation-template>"),id=[["\\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 ld(e){const n=x(),[o,r]=Tt(""),[a,i]=Tt(t);g(()=>{if(!e.isOpen)return;const n=e.initial??t;i(n),r(R(n))});const l=e=>{r(e),i(O(e))};return ua(mt,{get isOpen(){return e.isOpen},get title(){return n("dialog.equation.title")},get onClose(){return e.onClose},size:"lg",closeOnOverlayClick:!1,class:"oasis-editor-equation-dialog",get footer(){return[ua(Le,{variant:"secondary",get onClick(){return e.onClose},get children(){return n("generic.cancel")}}),ua(Le,{variant:"primary",onClick:()=>e.onApply(a()),"data-testid":"editor-equation-apply",get children(){return n("dialog.equation.insert")}})]},get children(){var e=rd(),t=e.firstChild,r=t.nextSibling,i=r.firstChild,s=i.nextSibling,c=r.nextSibling;return je(t,ua(Ce,{each:id,children:([e,t])=>{return(n=ad()).$$click=()=>l(t),je(n,e),n;var n}})),je(i,()=>n("dialog.equation.linear")),s.$$input=e=>l(e.currentTarget.value),yo(s,"spellcheck",!1),je(c,()=>R(a())||n("dialog.equation.empty")),Q(()=>yo(t,"aria-label",n("dialog.equation.structures"))),Q(()=>s.value=o()),e}})}k(["input","click"]);var sd=/*#__PURE__*/z("<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 cd(e){const t=x(),{fr:n}=e,o=e=>{"Enter"===e.key?(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext()):"Escape"===e.key&&n.setIsOpen(!1)};return ua(it,{get when(){return n.isOpen()},get children(){var e=sd(),r=e.firstChild,a=r.nextSibling,i=a.firstChild,l=i.firstChild,s=i.nextSibling;return e.$$keydown=o,je(r,ua(Er,{get children(){return t("find.title")}}),null),je(r,ua(na,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),je(l,ua(eo,{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),je(l,ua(In,{class:"oasis-editor-fr-counter",get children(){return Co(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),je(i,ua(ia,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[ua(na,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),ua(na,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),je(s,ua(eo,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),je(s,ua(ia,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[ua(na,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),ua(na,{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),je(a,ua(ia,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[ua(or,{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})}),ua(or,{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}})}k(["keydown"]);var dd=/*#__PURE__*/z("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),ud=/*#__PURE__*/z("<i>"),pd=/*#__PURE__*/z("<span class=oasis-editor-context-menu-shortcut>"),gd=/*#__PURE__*/z("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),fd=/*#__PURE__*/z("<div class=oasis-editor-context-menu-separator>"),md=/*#__PURE__*/z("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function hd(e){let t;const n=t=>{e.isOpen&&"Escape"===t.key&&(t.preventDefault(),e.onClose())},o=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},a=()=>{e.isOpen&&e.onClose()};return lr(()=>{window.addEventListener("keydown",n,!0),window.addEventListener("mousedown",o,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a,!0)}),be(()=>{window.removeEventListener("keydown",n,!0),window.removeEventListener("mousedown",o,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a,!0)}),g(()=>{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`}),ua(it,{get when(){return e.isOpen},get children(){var n=dd();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?ie(t,n):t=n,je(n,ua(Ce,{get each(){return e.items},children:t=>ua(it,{get when(){return"separator"!==t.type},get fallback(){return fd()},get children(){var n=gd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},je(n,ua(it,{get when(){return t.icon},get fallback(){return e=md(),je(e,ua(vn,{size:16})),e;var e},get children(){var e=ud();return Q(()=>yo(e,"data-lucide",t.icon)),e}}),o),je(o,()=>t.label),je(n,ua(it,{get when(){return t.shortcut},get children(){var e=pd();return je(e,()=>t.shortcut),e}}),null),Q(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&yo(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),Q(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&Fe(n,"left",t.e=o),r!==t.t&&Fe(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function bd(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:c,paragraphDialog:d,setParagraphDialog:u,tablePropertiesDialog:p,setTablePropertiesDialog:g,newDocumentDialog:f,setNewDocumentDialog:m,symbolDialog:h,setSymbolDialog:b,equationDialog:y,setEquationDialog:v}=e.dialogs;return[ua(Yc,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),ua(od,{get isOpen(){return h().isOpen},onClose:()=>{b({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{b({isOpen:!1}),e.insertSymbol(t,n)}}),ua(ld,{get isOpen(){return y().isOpen},get initial(){return y().initial},onClose:()=>{v({isOpen:!1}),e.focusInput()},onApply:t=>{v({isOpen:!1}),e.applyEquation(t,y().targetRunId)}}),ua(Gs,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),ua(Ys,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),ua(qs,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),ua(Qs,{get composer(){return e.commentComposer}}),ua(cd,{get fr(){return e.findReplace}}),ua(wc,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...s(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),ua(Fc,{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}}),ua(Xc,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),ua(hd,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}k(["contextmenu","click"]);var yd=/*#__PURE__*/z("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function vd(e){return[ua(it,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return ua(t,{get state(){return n.state()},get toolbarHost(){return n.toolbarHost},get runtimeEditor(){return n.runtimeEditor},get persistenceStatus(){return n.persistenceStatus},get toolbarRegistry(){return n.toolbarRegistry},get menuRegistry(){return n.menuRegistry},get showChrome(){return o.showChrome()},get showTitleBar(){return o.showTitleBar()},get showMenubar(){return o.showMenubar()},get showToolbar(){return o.showToolbar()},get showOutline(){return o.showOutline()},get toolbarView(){return o.toolbarView()},get toolbarLayout(){return o.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get documentLayout(){return r.documentLayout},get viewportHeight(){return r.viewportHeight},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),ua(it,{get when(){return!e.useComposedShell()},get children(){return ua(D,{get editor(){return e.runtime.runtimeEditor},get children(){var t=yd(),n=t.firstChild;return je(n,ua(Ze,{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},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),t}})}})]}var xd=/*#__PURE__*/z("<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 wd(e){const t=x(),n=()=>{at(),$t(),e.onClose()},o=()=>{Ct(!1),$t(),e.onClose()};return ua(it,{get when(){return e.isOpen},get children(){var e=xd(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return je(r,ua(Zr,{height:72,class:"oasis-editor-welcome-mark"}),a),je(a,()=>t("welcome.title")),je(i,()=>t("welcome.body")),je(l,()=>t("welcome.note")),je(s,ua(Le,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),je(s,ua(Le,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var Sd=/* @__PURE__ */Yt(jr(),1),Id=v(),Cd="word/comments.xml";function Td(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 Pd(e){return e.localName??e.tagName}function kd(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 Rd(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 Bd(e){let t="";for(const n of Td(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===Pd(n)){t+=n.textContent??"";continue}if("tab"===Pd(n)){t+="\t";continue}if("br"===Pd(n)||"cr"===Pd(n)){t+="\n";continue}}t+=Bd(n)}return t}function Md(e){return Td(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===Pd(e))}function Fd(e){return Md(e).map(Bd).join("\n").trim()}function Ad(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===Pd(t)?t:void 0}function Od(e,t){const n=kd(Md(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=Md(t)[0];n&&o&&o.setAttributeNS(An,"w14:paraId",n)}function Dd(e,t){const n=Md(e),o=Md(t);n[0]&&o[0]&&Br(n[0],o[0]);const r=new Set(Td(t).filter(e=>e.namespaceURI!==Vn).map(e=>`${e.namespaceURI??""}\0${Pd(e)}`));for(const a of Td(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${Pd(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function Ed(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(Cd);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Ad(e),o=Ad(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Td(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Pd(i))continue;const e=kd(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of Td(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Pd(i))continue;const e=kd(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new Id.XMLSerializer).serializeToString(t);Rd(i,t),Fd(i)===Fd(t)?Od(i,t):Dd(i,t),(new Id.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new Id.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Cd,a),!0)}var Ld="http://schemas.microsoft.com/office/word/2012/wordml",Nd="word/commentsExtended.xml";function $d(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){return e.localName??e.tagName}function Hd(e){return`${e.namespaceURI??""}\0${zd(e)}`}function Wd(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 Ud(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function jd(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 Vd(e){const t=/* @__PURE__ */new Map,n=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(Vn,"comment"))){const e=Wd(o,"id"),n=o.getElementsByTagNameNS(Vn,"p").item(0),r=n?Wd(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function Kd(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===Ld&&"commentsEx"===zd(t)?t:void 0}function _d(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))||Ud(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set($d(t).map(Hd));for(const r of $d(e))o.has(Hd(r))||t.appendChild(r.cloneNode(!0))}function Xd(e,t,n,o){const r=Kd(t),a=Kd(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))||Ud(t,o,o.value)}}(r,a);const i=Vd(e),l=Vd(n),s=/* @__PURE__ */new Map;for(const[p,g]of i){const e=l.get(p);e&&s.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of $d(e)){if(n.namespaceURI!==Ld||"commentEx"!==zd(n))continue;const e=Wd(n,"paraId");e&&t.set(e,n)}return t}(a),d=$d(r),u=new Set($d(a).filter(e=>!(e.namespaceURI===Ld&&"commentEx"===zd(e))).map(Hd));for(const p of d){if(p.namespaceURI===Ld&&"commentEx"===zd(p)){const e=Wd(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&_d(p,n,s);continue}u.has(Hd(p))||(a.appendChild(p.cloneNode(!0)),u.add(Hd(p)))}return(new Id.XMLSerializer).serializeToString(a.ownerDocument)}var Gd="http://schemas.openxmlformats.org/wordprocessingml/2006/main";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 qd(e){return e.localName??e.tagName}function Zd(e){return`${e.namespaceURI??""}\0${qd(e)}`}function Jd(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 Qd(e,t){return Yd(e).find(e=>e.namespaceURI===Gd&&qd(e)===t)}function eu(e,t){return e.filter(e=>e.namespaceURI===Gd&&t.has(qd(e)))}function tu(e){if(e.namespaceURI!==Gd)return;const t=qd(e);if("p"===t){const t=Jd(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Qd(e,"sdtPr"),n=t?Qd(t,"id"):void 0,o=n?Jd(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function nu(e,t,n){const o=(new Id.DOMParser).parseFromString(e,"application/xml"),r=(new Id.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==Gd||i.namespaceURI!==Gd||qd(a)!==n||qd(i)!==n)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(a,i);const l=Yd(a),s=Yd(i),c=new Set(s.map(Zd));return l.forEach((e,t)=>{if(e.namespaceURI===Gd||c.has(Zd(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>Zd(t)===Zd(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new Id.XMLSerializer).serializeToString(r)}function ou(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=nu(e,t,n),a=(new Id.DOMParser).parseFromString(e,"application/xml"),i=(new Id.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==Gd||s.namespaceURI!==Gd||qd(l)!==n||qd(s)!==n)return r;const c=Yd(l),d=Yd(s),u=function(e,t,n){const o=eu(e,n),r=eu(t,n);return o.length===r.length&&o.every((e,t)=>qd(e)===qd(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Gd||o.has(qd(e)))return;const n=Zd(e),r=p.get(n)??0;if(p.set(n,r+1),Yd(s).filter(e=>Zd(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===Gd&&o.has(qd(e)));if(!a)return;const i=tu(a);if(i){const e=eu(n,o).find(e=>tu(e)===i);if(e)return e}if(!r)return;const l=eu(e,o),s=eu(n,o),c=l.indexOf(a);return c>=0?s[c]:void 0}(c,t,d,o,u);(a||u)&&s.insertBefore(e.cloneNode(!0),a??null)}),(new Id.XMLSerializer).serializeToString(i)}var ru="word/document.xml",au=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function iu(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 lu(e){return e.localName??e.tagName}function su(e){return`${e.namespaceURI??""}\0${lu(e)}`}function cu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function du(e,t){return iu(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&lu(e)===t)}function uu(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&au.has(lu(e))}function pu(e){return e.filter(uu)}function gu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=lu(e);if("p"===t){const t=cu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=du(e,"sdtPr"),n=t?cu(du(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function fu(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml"),o=(new Id.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"!==lu(r)||"document"!==lu(a))return t;!function(e,t){const n=iu(e),o=du(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===lu(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=iu(t).find(t=>!i.has(t)&&su(t)===su(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=du(r,"body"),l=du(a,"body");if(!i||!l)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(i,l);const s=iu(i),c=iu(l),d=function(e,t){const n=pu(e),o=pu(t);return n.length===o.length&&n.every((e,t)=>lu(e)===lu(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if(uu(e))return;const n=su(e),o=u.get(n)??0;if(u.set(n,o+1),iu(l).filter(e=>su(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(uu);if(!o)return;const r=gu(o);return r?pu(n).find(e=>gu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=pu(e),r=pu(n),a=e.slice(t+1).find(uu);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(s,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&l.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===lu(e))}(c)??null)}),(new Id.XMLSerializer).serializeToString(o)}async function mu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(ru);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return fu(e,nu(e,t,"document"))}(n.data,r);return a!==r&&(t.file(ru,a),!0)}var hu="word/document.xml",bu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function yu(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 vu(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(bu,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function xu(e){const t=[];return vu(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===bu&&"headerReference"===r.localName?"header":r.namespaceURI===bu&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=yu(r,"id");if(!a)continue;const i=yu(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),t.push({key:`${n}:${e}:${i}:${s}`,kind:e,relationshipId:a})}}),t}function wu(e){return new Map(e.map(e=>[e.id,e]))}async function Su(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(hu)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=vu(n.data),a=vu(o);if(r.length!==a.length)return!1;const i=xu(n.data),l=xu(o),s=new Map(i.map(e=>[e.key,e])),c=wu(n.relationships??[]),d=wu(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`}(hu))?.async("string"));return oa(hu,Lr(t))}(t));let u=!1;for(const p of l){const n=s.get(p.key);if(!n||n.kind!==p.kind)continue;const o=c.get(n.relationshipId),r=d.get(p.relationshipId);if("External"===o?.targetMode||"External"===r?.targetMode||!o?.resolvedTarget||!r?.resolvedTarget)continue;const a=e.parts[o.resolvedTarget];if("xml"!==a?.kind)continue;const i=r.resolvedTarget,l=await(t.file(i)?.async("string"));if(!l)continue;const g="header"===p.kind?"hdr":"ftr",f=ou(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var Iu="word/document.xml",Cu={"/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"},Tu=["/officeDocument",...Object.keys(Cu)];function Pu(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function ku(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 Ru(e){for(const[t,n]of Object.entries(Cu))if(e.type.endsWith(t))return n}function Bu(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=ro(e);return void 0===n?t.get(e)??e:null===n?e:ku(t.get(n)??n)}function Mu(e,t){for(const[n,o]of t)if(o===e)return n;return e}function Fu(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 Au(e,t){const n=e.parts[t];return"xml"===n?.kind?Lr(n.data):[]}function Ou(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:Au(e,Eo):e.parts[t]?.relationships??Au(e,ku(t));return oa(t,n)}function Du(e,t,n){return Ou(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function Eu(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,Tu.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=oa(n,[e])[0]?.resolvedTarget,c=l?.resolvedTarget??(s?r.get(s)??s:void 0);return c?{...e,...l?{id:l.id,type:l.type}:{},target:Fu(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function Lu(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(Pu(e)===Pu(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 Nu(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 $u(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===m(o))}async function zu(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Sd.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>Zn(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(Iu,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=Ru(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!==Iu&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new Sd.default;for(const c of Object.keys(n.parts))Nu(l,n,c);for(const c of i)l.remove(c),l.remove(ku(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=ro(a);if(null==i)continue;const l=Ou(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=Mu(i,n);o.has(ku(c))||(0===s.length?e.remove(a):e.file(a,qr(s)))}}(l,n,a,r,i);let s=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=Zn(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=Bu(e,a),o=ro(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=Du(n,r,i),c=Lu(s,Eu(Lr(await d.async("string")),s,e,r,a),t);l.file(t,qr(c));continue}const r=await d.async("uint8array");$u(n,e,t,r)||l.file(t,r)}return s&&l.file(er,function(e,t,n,o){const r=ln(t),a={};for(const[l,s]of Object.entries(r.overrides))a[n.get(l)??l]=s;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return xn({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,s,a,i)),l.generateAsync({type:"arraybuffer"})}var Hu="word/document.xml",Wu=["first","even","default"];function Uu(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 ju(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 Vu(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 Ku(e,t){const n=[],o=e=>{for(const r of Vu(e))r.localName===t&&n.push(r),o(r)};return o(e),n}function _u(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 Xu(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return r.value!==n&&(e.setAttribute(r.name,n),!0)}return!1}function Gu(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml"),n=[],o=Ku(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of Vu(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=_u(r,"id");if(!a)continue;const i=_u(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),n.push({key:`${t}:${e}:${i}:${s}`,sectionIndex:t,kind:e,type:i,occurrence:s,relationshipId:a})}}),{references:n,sectionCount:o.length}}function Yu(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function qu(e,t){const n=e.parts[t]?.relationships??Lr(Yu(e,Uu(t)));return oa(t,n)}function Zu(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 Ju(e,t){const n=Yu(e,e.mainDocumentPart),o=await(t.file(Hu)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=Gu(n),a=Gu(o),i=Zu(r.references,qu(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=Wu.indexOf(e.type),o=Wu.indexOf(t.type),r=n<0?99:n,a=o<0?99:o;return r!==a?r-a:e.type!==t.type?e.type.localeCompare(t.type):e.occurrence-t.occurrence});let n=1,o=1;for(const r of t)"header"===r.kind?(r.baselinePath=`word/header${n}.xml`,n+=1):(r.baselinePath=`word/footer${o}.xml`,o+=1)}(i);const l=Zu(a.references,await async function(e,t){const n=await(e.file(Uu(t))?.async("string"));return oa(t,Lr(n))}(t,Hu)),s=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of l){const e=s.get(p.key);e&&(c.push({current:p,source:e}),d.add(e.partPath),u.set(p.relationshipId,e.relationship))}return{matches:c,deletedSourcePartPaths:r.sectionCount===a.sectionCount?new Set(i.map(e=>e.partPath).filter(e=>!d.has(e))):/* @__PURE__ */new Set,sourceRelationshipByCurrentId:u}}function Qu(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function ep(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===m(await a.async("uint8array")):void 0===r}async function tp(e,t,n,o){for(const r of n)if(!(await ep(e,t,o?Uu(r.current.partPath):r.current.partPath,r.source.baselinePath?o?Uu(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function np(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?Uu(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?m(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 op(e,t,n){const o=await(e.file(Hu)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[Hu],a=m((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of Ku(n,r)){const n=_u(e,"id"),r=n?t.get(n):void 0;r&&(o=Xu(e,"id",r.id)||o)}return o?(new Id.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(Hu,t)}}const r=Uu(Hu),a=Lr(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:ju(Hu,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,qr(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(Qu(e)===Qu(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 rp(e,t,n){const o=n[0],r=o.source.partPath;if(!(await tp(e,t,n,!1))){await np(e,n,!1);const t=await(e.file(o.current.partPath)?.async("uint8array"));if(!t)throw new Error(`Cannot preserve ${r}: rebuilt header/footer part is missing.`);e.file(r,t)}for(const c of n)c.current.partPath!==r&&e.remove(c.current.partPath);const a=Uu(r);if(!(await tp(e,t,n,!0))){await np(e,n,!0);const t=Uu(o.current.partPath),c=await(e.file(t)?.async("string"));c&&e.file(a,qr((i=Lr(c),l=o.current.partPath,s=r,i.map(e=>{if("External"===e.targetMode)return e;const t=oa(l,[e])[0]?.resolvedTarget;return t?{...e,target:ju(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=Uu(c.current.partPath);t!==a&&e.remove(t)}}async function ap(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 rp(e,t,o)}async function ip(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Sd.default.loadAsync(t),r=await Ju(n,o);r.matches.length>0&&(await op(o,n,r),await ap(o,n,r),await async function(e,t){const n=await(e.file(er)?.async("string"));if(!n)return;const o=ln(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(er,xn(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return zu(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[Uu(d)];const a=r[n.mainDocumentPart],i=qu(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=Uu(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:qr(i)});const c=r[er];return c&&(r[er]={...c,data:xn(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var lp=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],sp=/* @__PURE__ */new Set(["p","tbl"]),cp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function dp(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 up(e){return e.localName??e.tagName}function pp(e){return`${e.namespaceURI??""}\0${up(e)}`}function gp(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 fp(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 mp(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&up(n)===t?n:void 0}function hp(e){const t=gp(e,"type");if(t&&cp.has(t))return`type:${t}`;const n=gp(e,"id");return n?`id:${n}`:void 0}function bp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&sp.has(up(e))}function yp(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==up(e))return;const t=gp(e,"paraId");return t?`p:${t}`:void 0}function vp(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=dp(e),o=dp(t),r=function(e,t){const n=e.filter(bp),o=t.filter(bp);return n.length===o.length&&n.every((e,t)=>up(e)===up(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(bp(e))return;const l=pp(e),s=a.get(l)??0;if(a.set(l,s+1),dp(t).filter(e=>pp(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(bp);if(!r)return;const a=yp(r);if(a){const e=n.filter(bp).find(e=>yp(e)===a);if(e)return e}if(!o)return;const i=e.filter(bp),l=n.filter(bp),s=i.indexOf(r);return s>=0?l[s]:void 0}(n,i,o,r);("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||c||r)&&t.insertBefore(e.cloneNode(!0),c??null)})}function xp(e,t,n,o){const r=mp(t,o.rootName),a=mp(n,o.rootName);if(!r||!a)return n;const i=dp(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&up(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of dp(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||up(c)!==o.entryName)continue;const e=hp(c);e&&l.set(e,c)}const s=function(e,t){const n="footnote"===t?e.footnotes?.items:e.endnotes?.items,o=/* @__PURE__ */new Set;for(const r of Object.values(n??{}))void 0!==r.docxId&&Number.isSafeInteger(r.docxId)&&r.docxId>=1&&o.add(String(r.docxId));return o}(e,o.kind);for(const c of i){const e=hp(c);if(!e)continue;const t=l.get(e),n=gp(c,"type");if(t){n&&cp.has(n)?a.replaceChild(c.cloneNode(!0),t):vp(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=gp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new Id.XMLSerializer).serializeToString(a.ownerDocument)}var wp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Sp="word/numbering.xml";function Ip(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 Cp(e){return e.localName??e.tagName}function Tp(e){return`${e.namespaceURI??""}\0${Cp(e)}`}function Pp(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 kp(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(wp,`w:${t}`,n)}function Rp(e,t){return Ip(e).find(e=>e.namespaceURI===wp&&Cp(e)===t)}function Bp(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 Mp(e,t){const n=new Set(Ip(t).map(Tp));for(const o of Ip(e))o.namespaceURI===wp||n.has(Tp(o))||t.appendChild(o.cloneNode(!0))}function Fp(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 Ap=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function Op(e,t){Bp(e,t);const n=Ip(e),o=new Map(Ip(t).map(e=>[Tp(e),e]));n.forEach((e,r)=>{const a=Tp(e),i=o.get(a),l=Cp(e);if(i)return Bp(e,i),void(e.namespaceURI===wp&&"rPr"===l?function(e,t){Bp(e,t);const n=Ip(e),o=new Map(Ip(t).map(e=>[Tp(e),e]));n.forEach((e,r)=>{const a=Tp(e),i=o.get(a);if(i)return Bp(e,i),void Mp(e,i);e.namespaceURI===wp&&"rFonts"===Cp(e)||Fp(n,r,e,t,e=>o.get(Tp(e)))})}(e,i):Mp(e,i));if(e.namespaceURI!==wp||!Ap.has(l)){if(e.namespaceURI===wp&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of Ip(e))o.namespaceURI===wp&&"rFonts"===Cp(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}Fp(n,r,e,t,e=>o.get(Tp(e)))}})}function Dp(e){return function(e){return e.namespaceURI===wp&&"lvl"===Cp(e)?`${Tp(e)}\0${Pp(e,"ilvl")??"0"}`:Tp(e)}(e)}function Ep(e,t,n){const o=Rp(t,"abstractNumId"),r=o?Pp(o,"val"):void 0;if(!r)return;const a=Ip(e).find(e=>e.namespaceURI===wp&&"abstractNum"===Cp(e)&&Pp(e,"abstractNumId")===r);return a?Ip(a).find(e=>e.namespaceURI===wp&&"lvl"===Cp(e)&&(Pp(e,"ilvl")??"0")===n):void 0}function Lp(e,t){const n=t.cloneNode(!0);Op(e,n);const o=Rp(e,"pPr"),r=Rp(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function Np(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=Pp(Rp(t,"start")??t,"val")??"1";for(const r of Ip(e)){const e=Cp(r);if(r.namespaceURI===wp&&"startOverride"===e){const e=r.cloneNode(!0);kp(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==wp||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(Lp(r,t))}return n}function $p(e){if(e.namespaceURI!==wp)return Tp(e);const t=Cp(e);return"abstractNum"===t?`${Tp(e)}\0${Pp(e,"abstractNumId")??""}`:"num"===t?`${Tp(e)}\0${Pp(e,"numId")??""}`:Tp(e)}function zp(e,t){const n=function(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new Id.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===wp&&o.namespaceURI===wp&&"numbering"===Cp(n)&&"numbering"===Cp(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Bp(o,r);const a=Ip(o),i=new Map(Ip(r).map(e=>[$p(e),e]));return a.forEach((e,t)=>{const n=$p(e),o=i.get(n),l=Cp(e);if(o)return Bp(e,o),void(e.namespaceURI===wp&&"abstractNum"===l?function(e,t){Bp(e,t);const n=Ip(e),o=new Map(Ip(t).map(e=>[Dp(e),e]));n.forEach((e,r)=>{const a=Dp(e),i=o.get(a);if(i)return Bp(e,i),void(e.namespaceURI===wp&&"lvl"===Cp(e)?Op(e,i):Mp(e,i));Fp(n,r,e,t,e=>o.get(Dp(e)))})}(e,o):e.namespaceURI===wp&&"num"===l?function(e,t,n){Bp(e,t);const o=Rp(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of Ip(t))a.namespaceURI===wp&&"lvlOverride"===Cp(a)&&r.set(Pp(a,"ilvl")??"0",a);for(const a of Ip(e)){const e=Cp(a);if(a.namespaceURI!==wp||"abstractNumId"!==e){if(a.namespaceURI===wp&&"lvlOverride"===e){const e=Pp(a,"ilvl")??"0",o=Np(a,Ep(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===wp||Ip(t).some(e=>Tp(e)===Tp(a))||t.appendChild(a.cloneNode(!0))}else o&&(Bp(a,o),Mp(a,o))}}(e,o,r):Mp(e,o));Fp(a,t,e,r,e=>i.get($p(e)))}),(new Id.XMLSerializer).serializeToString(r.ownerDocument)}async function Hp(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(Sp);if(!n||!o)return!1;const r=await o.async("string"),a=zp(n,r);return a!==r&&(t.file(Sp,a),!0)}var Wp=[{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 Up(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 jp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Vp=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function Kp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function _p(e){return e.localName??e.tagName}function Xp(e){return`${e.namespaceURI??""}\0${_p(e)}`}function Gp(e){const t=[],n=e=>{for(const o of Kp(e))o.namespaceURI===jp&&"sectPr"===_p(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function Yp(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 qp(e){return e.namespaceURI===jp&&Vp.has(_p(e))}function Zp(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml"),o=(new Id.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=Gp(n),l=Gp(o);return 0===i.length||i.length!==l.length?t:(Yp(r,a),i.forEach((e,t)=>{!function(e,t){Yp(e,t);const n=Kp(e),o=Kp(t),r=/* @__PURE__ */new Map;for(const i of o){const e=Xp(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=Xp(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){Yp(e,s);continue}if(qp(e))continue;const c=n.slice(i+1).map(e=>r.get(Xp(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new Id.XMLSerializer).serializeToString(o))}var Jp="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Qp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function eg(e){return e.localName??e.tagName}function tg(e,t){const n=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Jp&&eg(n)===t?n:void 0}function ng(e){return Qp(e).length>0?(new Id.XMLSerializer).serializeToString(e.ownerDocument):void 0}var og=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),rg=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function ag(e){const t=tg(e,"settings");if(!t)return e;for(const n of[...Qp(t)]){if(n.namespaceURI!==Jp)continue;const e=eg(n);if(og.has(e)){t.removeChild(n);continue}const o=rg.get(e);if(o){for(const e of[...Qp(n)])e.namespaceURI===Jp&&o.has(eg(e))&&n.removeChild(e);0===Qp(n).length&&t.removeChild(n)}}return ng(t)}function ig(e){const t=tg(e,"styles");if(!t)return e;for(const n of[...Qp(t)])n.namespaceURI===Jp&&"style"===eg(n)&&t.removeChild(n);return ng(t)}function lg(e){const t=tg(e,"fonts");if(!t)return e;for(const n of[...Qp(t)])n.namespaceURI===Jp&&"font"===eg(n)&&t.removeChild(n);return ng(t)}async function sg(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 cg="word/styles.xml";function dg(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 ug(e){return e.localName??e.tagName}function pg(e){return`${e.namespaceURI??""}\0${ug(e)}`}function gg(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 fg(e,t){return dg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ug(e)===t)}function mg(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===ug(e)?`${pg(e)}\0${gg(e,"type")??""}`:pg(e)}function hg(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===ug(t)?t:void 0}function bg(e,t){const n=fg(e,"pPr");if(!n)return!1;const o=fg(t,"pPr"),r=new Id.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=gn(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===ug(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=dg(e),a=r.indexOf(n),i=dg(t),l=new Map(i.map(e=>[mg(e),e])),s=r.slice(a+1).map(e=>l.get(mg(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function yg(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(cg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=hg(e),o=hg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of dg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==ug(i))continue;const e=gg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of dg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==ug(i))continue;const e=gg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=bg(i,t)||a)}return a?(new Id.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(cg,a),!0)}function vg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function xg(e){return e.localName??e.tagName}function wg(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 Sg(e,t){const n=function(e){if(!e)return;const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===xg(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${Vn}" xmlns:w14="${An}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};pt(r,`<w:r xmlns:w="${Vn}" xmlns:w14="${An}">${e}<w:t/></w:r>`);const a=function(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===xg(t)?t:void 0}(Xo(r,o));if(!a)return t;let i=vg(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===xg(e));return!i&&wg(n)&&(i=a.ownerDocument.createElementNS(Vn,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(Br(n,i),0!==vg(i).length||wg(i)?(new Id.XMLSerializer).serializeToString(i):""):""}var Ig="word/styles.xml";function Cg(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 Tg(e){return e.localName??e.tagName}function Pg(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 kg(e,t){return Cg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Tg(e)===t)}function Rg(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Tg(t)?t:void 0}function Bg(e,t){const n=kg(e,"rPr");if(!n)return!1;const o=kg(t,"rPr"),r=new Id.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=Sg(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Tg(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=Cg(e),a=r.indexOf(n),i=Cg(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&Tg(t)===Tg(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function Mg(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(Ig);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Rg(e),o=Rg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Cg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Tg(i))continue;const e=Pg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Cg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Tg(i))continue;const e=Pg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Bg(i,t)||a)}return a?(new Id.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Ig,a),!0)}var Fg="word/styles.xml",Ag=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function Og(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 Dg(e){return e.localName??e.tagName}function Eg(e){return`${e.namespaceURI??""}\0${Dg(e)}`}function Lg(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 Ng(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function $g(e,t){return Og(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Dg(e)===t)}function zg(e){return e?(new Id.XMLSerializer).serializeToString(e):""}function Hg(e,t){if(!e)return;const n=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Dg(n)===t?n:void 0}function Wg(e,t,n){switch(e){case"pPr":return gn(t,n);case"rPr":return Sg(t,n);case"tblPr":return Pn(t,n);case"trPr":return Ro(t,n);case"tcPr":return br(t,n);default:return n}}function Ug(e,t,n,o){const r=Og(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ag.has(Dg(e)));return i?$g(t,Dg(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===Dg(e)&&Ag.has(o)?Og(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Dg(e))??null:null}function jg(e,t,n){const o=$g(e,n);if(!o)return!1;const r=$g(t,n),a=zg(r),i=Wg(n,zg(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=Hg(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,Ug(e,t,o,n)),!0)}function Vg(e,t){Ng(e,t);let n=!1;for(const r of Ag)n=jg(e,t,r)||n;const o=new Set(Og(t).map(Eg));for(const r of Og(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Ag.has(Dg(r))||o.has(Eg(r))||(t.appendChild(r.cloneNode(!0)),o.add(Eg(r)),n=!0);return n}function Kg(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(Vn,"w:tblStylePr");Ng(e,n);let o=!1;for(const r of Og(e)){const e=Dg(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Ag.has(e)){const t=Hg(Wg(e,zg(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function _g(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==Dg(e))return;const t=Lg(e,"type");return t?`tblStylePr:${t}`:void 0}function Xg(e,t){let n=!1;n=jg(e,t,"tblPr")||n;const o=Og(e).filter(e=>void 0!==_g(e)),r=/* @__PURE__ */new Map;for(const a of Og(t)){const e=_g(a);e&&r.set(e,a)}for(const a of o){const o=_g(a),i=r.get(o);if(i){n=Vg(a,i)||n;continue}const l=Kg(a);if(!l)continue;const s=Og(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==_g(e)),u=d?r.get(_g(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function Gg(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Dg(t)?t:void 0}async function Yg(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(Fg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Gg(e),o=Gg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Og(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===Dg(i)){const e=Lg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Og(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Dg(i))continue;if("table"!==Lg(i,"type"))continue;const e=Lg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Xg(i,t)||a)}return a?(new Id.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Fg,a),!0)}var qg="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Zg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Jg(e){return e.localName??e.tagName}function Qg(e){return`${e.namespaceURI??""}\0${Jg(e)}`}function ef(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 tf(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 nf(e,t,n){const o=(new Id.DOMParser).parseFromString(e,"application/xml"),r=(new Id.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===qg&&i.namespaceURI===qg&&Jg(a)===n&&Jg(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function of(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 rf(e,t){const n=new Set(Zg(t).map(Qg));for(const o of Zg(e))o.namespaceURI===qg||n.has(Qg(o))||t.appendChild(o.cloneNode(!0))}var af=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var lf=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function sf(e){return e.namespaceURI===qg&&"tblStylePr"===Jg(e)?`${Qg(e)}\0${ef(e,"type")??""}`:Qg(e)}function cf(e){return e.namespaceURI===qg&&"style"===Jg(e)?`${Qg(e)}\0${ef(e,"styleId")??""}`:Qg(e)}var df=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function uf(e){return e.namespaceURI===qg&&"font"===Jg(e)?`${Qg(e)}\0${ef(e,"name")??""}`:Qg(e)}var pf=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=nf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;tf(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=Zg(o),l=new Map(Zg(r).map(e=>[Qg(e),e]));return i.forEach((e,t)=>{const n=Qg(e),o=l.get(n),s=Jg(e),c=e.namespaceURI===qg?a.get(s):void 0;if(o)return tf(e,o),void(c?function(e,t,n){tf(e,t);const o=Zg(t),r=new Map(o.map(e=>[Qg(e),e])),a=Zg(e);a.forEach((e,o)=>{const i=Qg(e),l=r.get(i);if(l)return tf(e,l),void rf(e,l);e.namespaceURI===qg&&n.has(Jg(e))||of(a,o,e,t,e=>r.get(Qg(e)))})}(e,o,c):rf(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Zg(e))r.namespaceURI===qg&&t.has(Jg(r))||(n.appendChild(r.cloneNode(!0)),o=!0);return o?n:void 0}(e,c);if(n){const e=i.slice(t+1).map(e=>l.get(Qg(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===qg&&af.has(s)||of(i,t,e,r,e=>l.get(Qg(e)))}),(new Id.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=nf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;tf(o,r);const a=Zg(o),i=new Map(Zg(r).map(e=>[cf(e),e]));return a.forEach((e,t)=>{const n=cf(e),o=i.get(n);if(o)return tf(e,o),void(e.namespaceURI===qg&&"style"===Jg(e)?function(e,t){tf(e,t);const n=Zg(e),o=new Map(Zg(t).map(e=>[sf(e),e]));n.forEach((e,r)=>{const a=sf(e),i=o.get(a);if(i)return tf(e,i),void rf(e,i);e.namespaceURI===qg&&lf.has(Jg(e))||of(n,r,e,t,e=>o.get(sf(e)))})}(e,o):rf(e,o));of(a,t,e,r,e=>i.get(cf(e)))}),(new Id.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=nf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;tf(o,r);const a=Zg(o),i=new Map(Zg(r).map(e=>[uf(e),e]));return a.forEach((e,t)=>{const n=uf(e),o=i.get(n);if(o)return tf(e,o),void(e.namespaceURI===qg&&"font"===Jg(e)&&function(e,t){tf(e,t);const n=Zg(e),o=new Map(Zg(t).map(e=>[Qg(e),e]));n.forEach((e,r)=>{const a=Qg(e),i=o.get(a);i?tf(e,i):e.namespaceURI===qg&&df.has(Jg(e))||of(n,r,e,t,e=>o.get(Qg(e)))})}(e,o));of(a,t,e,r,e=>i.get(uf(e)))}),(new Id.XMLSerializer).serializeToString(r.ownerDocument)}}];function gf(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 ff="word/document.xml";function mf(e){const t=(new Id.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS("*","sectPr");let n=0;for(let o=0;o<t.length;o+=1){const e=t.item(o),r=e?.parentNode;e&&"sectPrChange"!==r?.localName&&(n+=1)}return n}async function hf(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return zu(e,t);const r=await Sd.default.loadAsync(t),a=Boolean(r.file("word/numbering.xml")),i={settings:Boolean(r.file("word/settings.xml")),styles:Boolean(r.file("word/styles.xml")),fontTable:Boolean(r.file("word/fontTable.xml"))};let l=await async function(e,t){let n=!1;for(const o of pf){const r=gf(e,o.relationshipSuffix);if(!r)continue;const a=t.file(o.rebuiltPath);if(!a){t.file(o.rebuiltPath,r),n=!0;continue}if(!o.merge)continue;const i=await a.async("string"),l=o.merge(r,i);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r);a&&(l=await Hp(n,r)||l),i.styles&&(l=await yg(n,r)||l,l=await Mg(n,r)||l,l=await Yg(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await sg(e,"word/settings.xml",ag)||n),t.styles||(n=await sg(e,"word/styles.xml",ig)||n),t.fontTable||(n=await sg(e,"word/fontTable.xml",lg)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of Wp){const r=Up(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=nu(r,i,o.rootLocalName);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r)||l,l=await async function(e,t,n){let o=!1;for(const r of lp){const a=fp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=xp(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await Ed(n,r)||l,l=await async function(e,t){const n=jd(e,"/comments"),o=jd(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(Nd);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=Xd(n,o,i,l);return s!==l&&(t.file(Nd,s),!0)}(n,r)||l,l=await Su(n,r)||l,l=await mu(n,r)||l;const s=await(r.file(ff)?.async("string"));if(!s||mf(o.data)!==mf(s)){return zu(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=Zp(o.data,s);c!==s&&(r.file(ff,c),l=!0);return ip(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function bf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function yf(e){const t=(new Id.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 vf(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 xf(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 wf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Sf(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=bf(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=yf(r.data);if(a&&bf(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 Id.DOMParser).parseFromString(e,"application/xml"),r=o.documentElement;if(!r)return null;const a=t.trim().replace(/\/text\(\)$/,"");if(!a.startsWith("/")||a.startsWith("//"))return null;const i=a.split("/").filter(Boolean);if(0===i.length)return null;const l=i.at(-1)?.startsWith("@")?i.pop():null,s=vf(i[0]);if(!s||1!==s.index)return null;if(!xf(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=vf(i[m]);if(!e)return null;const t=wf(c).filter(t=>xf(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!l)return{document:o,element:c};const d=l.slice(1),u=d.indexOf(":");if(u<0)return{document:o,element:c,attribute:{localName:d,qualifiedName:d}};const p=d.slice(0,u),g=d.slice(u+1),f=n.get(p);return f?{document:o,element:c,attribute:{namespaceUri:f,localName:g,qualifiedName:`${p}:${g}`}}:null}(o.xml,t.xpath,function(e){const t=/* @__PURE__ */new Map;if(!e)return t;for(const n of e.matchAll(/xmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])(.*?)\2/g))t.set(n[1],n[3]);return t}(t.prefixMappings));if(!r)return!1;if(r.attribute)r.attribute.namespaceUri?r.element.setAttributeNS(r.attribute.namespaceUri,r.attribute.qualifiedName,n):r.element.setAttribute(r.attribute.localName,n);else{if(wf(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 Id.XMLSerializer).serializeToString(r.document),!0)}function If(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 Cf(e){return e.blocks.map(Pf).filter(Boolean).join("\n")}function Tf(e){return e.cells.map(Cf).filter(Boolean).join("\t")}function Pf(e){return"paragraph"===e.type?we(e):e.rows.map(Tf).filter(Boolean).join("\n")}function kf(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])If(t,e,n.text,"");"textBox"===n.kind&&Bf(n.textBox.blocks,t)}}function Rf(e,t){for(const n of e.rows){const e=Tf(n);for(const o of n.sdtWrappers??[])If(t,o,e,"\n");for(const o of n.cells){const e=Cf(o);for(const n of o.sdtWrappers??[])If(t,n,e,"\n");Bf(o.blocks,t)}}}function Bf(e,t){if(e)for(const n of e){const e=Pf(n);for(const o of n.sdtWrappers??[])If(t,o,e,"\n");"paragraph"===n.type?kf(n,t):Rf(n,t)}}async function Mf(e){if(!e.sourcePackage)return Dt(e);const t={...e,sourcePackage:(n=e.sourcePackage,{...n,contentTypes:{defaults:{...n.contentTypes.defaults},overrides:{...n.contentTypes.overrides}},rootRelationships:n.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(n.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...n.diagnostics?{diagnostics:n.diagnostics.map(e=>({...e}))}:{},...n.rebuiltPartHashes?{rebuiltPartHashes:{...n.rebuiltPartHashes}}:{}})};var n;!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of wo(e))Bf(o.blocks,t),Bf(o.header,t),Bf(o.firstPageHeader,t),Bf(o.evenPageHeader,t),Bf(o.footer,t),Bf(o.firstPageFooter,t),Bf(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&Sf(e.sourcePackage,t,r)&&(n+=1)}}(t);return hf(t,await Dt(t))}async function Ff(e){if(!e.sourcePackage)return te(e);const t=await Mf(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function Af(e){switch(e){case"dashed":return[Po(5),Po(3)];case"dotted":return[Po(1),Po(3)];default:return}}async function Of(e,t,o,r,a,i,l,s){const c=t.rotation;c&&(e.saveGraphicsState(o.pageIndex),e.rotateAbout(o.pageIndex,Po(r+i/2),Po(a+l/2),c)),function(e,t,o,r,a,i,l){const s=n(o.shape?.preset,Po(r),Po(a),Po(i),Po(l)),c=o.shape?.fill,d=o.shape?.borderColor,u=o.shape?.borderWidthPt??(d?.75:0);e.drawPath(t,{segments:s,fill:c,stroke:d&&u>0?d:void 0,lineWidth:u})}(e,o.pageIndex,t,r,a,i,l),await async function(e,t,n,o,r,a,i,l){if(0===t.blocks.length)return;const s=function(e){return{left:e.body?.paddingLeft??0,top:e.body?.paddingTop??0,right:e.body?.paddingRight??0,bottom:e.body?.paddingBottom??0}}(t),c=o+s.left,d=r+s.top,u=Math.max(1,a-s.left-s.right),p=Math.max(1,i-s.top-s.bottom),g=Mo({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=Dr(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,Po(c),Po(d),Po(u),Po(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await l.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,l);break;case"table":await l.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,l);break;default:Qe(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,o,r,a,i,l,s),c&&e.restoreGraphicsState(o.pageIndex)}async function Df(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const p of a){const a=new Map(p.slots.map(e=>[e.offset,e]));for(const g of p.fragments){const f=g.textBox;if(!f?.floating)continue;const m=Boolean(f.floating.behindDoc);if(e.layer&&"behind"===e.layer!==m)continue;const h=l+(a.get(g.startOffset)?.left??0),b=d+p.top,y=nr({object:_n(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await Of(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var Ef=/* @__PURE__ */new WeakMap;function Lf(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 Nf(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=Lf(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?Lf(e):null,!r)return null}const l=i?a.naturalWidth:t,s=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function $f(e,t,n){const o=a(t,n.src);if(!o)return null;let r=Ef.get(e);r||(r=/* @__PURE__ */new Map,Ef.set(e,r));const i=r.get(o);if(i)return i;const l=Nf(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,l),l}async function zf(e,t,o,r,a,i,l,s){const c=await $f(e,o,r);if(!c)return;const d=r.intrinsicWidth??r.width,u=r.intrinsicHeight??r.height,p=d/Math.max(1,u),g=l/Math.max(1,s);let f=a,m=i,h=l,b=s;"fit"===r.cropFit&&p>0&&(p>g?(b=l/p,m+=(s-b)/2):(h=s*p,f+=(l-h)/2));const y="fill"!==r.cropFit||r.crop?r.crop:(()=>{if(p>g){const e=g/p,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(p<g){const e=p/g,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),v=r.cropShape?.preset,x=v?function(e,t,n,o,r,a){if(!a)return e;const i=t+o/2,l=n+r/2,s=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(s)-(t-l)*Math.sin(s),y:l+(e-i)*Math.sin(s)+(t-l)*Math.cos(s)});return e.map(e=>{if("close"===e.type)return e;if("cubic"===e.type){const t=c(e.x1,e.y1),n=c(e.x2,e.y2),o=c(e.x,e.y);return{type:"cubic",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:o.x,y:o.y}}const t=c(e.x,e.y);return{type:e.type,x:t.x,y:t.y}})}(n(v,a,i,l,s),a,i,l,s,r.rotation??0):null,w=r.transparency??0,S="fit"===r.cropFit&&Boolean(r.rotation);x&&(e.saveGraphicsState(t),e.clipPath(t,x)),S&&(e.saveGraphicsState(t),e.rotateAbout(t,a+l/2,i+s/2,r.rotation??0)),w>0&&e.saveGraphicsState(t),w>0&&e.setOpacity(t,1-Math.min(1,w)),e.drawImage(t,{resourceName:c,x:f,y:m,width:h,height:b,rotation:S?void 0:r.rotation,crop:y}),w>0&&e.restoreGraphicsState(t),S&&e.restoreGraphicsState(t),x&&e.restoreGraphicsState(t);const I=r.border;if(!I)return;const C=r.rotation;C&&!x&&(e.saveGraphicsState(t),e.rotateAbout(t,a+l/2,i+s/2,C));const T=Ir(I.dash);x?e.drawPath(t,{segments:x,stroke:I.color,lineWidth:I.widthPt??1}):e.drawRect(t,{x:a,y:i,width:l,height:s,stroke:I.color,lineWidth:I.widthPt??1,...T.length>0?{dashArray:T}:{}}),C&&!x&&e.restoreGraphicsState(t)}function Hf(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 Wf(e,t,n){const o=Hf(e,t);if(0===o.length)return null;const r=new Map(e.slots.map(e=>[e.offset,e])),a=o[0],i=o[o.length-1],l=r.get(i.offset+1);return{left:a.left,right:l?.left??i.left+.55*n}}function Uf(e,t,n,o,r,a,i){const l=Wf(e,t,n.fontSize??14.6667);return l?{x:Po(o+l.left),y:Po(r+e.top+a),width:Po(Math.max(0,l.right-l.left)),height:Po(Math.max(2,e.height-i))}:null}function jf(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=Wf(n,o,i.fontSize??14.6667);if(!s)return;const c=r+s.left,d=r+s.right,u=a+n.top,p=a+n.top+n.height,g=ue(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:Po(g.x0),y0:Po(g.y0),x1:Po(g.x1),y1:Po(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function Vf(e,t,n,o,r,a,i){const l=u(i),s=(r,i)=>{e.drawLine(t,{x1:Po(n),y1:Po(r),x2:Po(o),y2:Po(r),stroke:a,lineWidth:Po(l),dashArray:i})};if(re(i))return s(r-he),void s(r+he);Se(i)?function(e,t,n,o,r,a,i){let l=n,s=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*N;e.drawLine(t,{x1:Po(l),y1:Po(s),x2:Po(c),y2:Po(o),stroke:a,lineWidth:Po(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,ca(i))}function Kf(e,t){const n=Gt(e);if(!n)return e;const o=Math.max(0,Math.min(1,t));return jt(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function _f(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=Po(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:Po(t)+u*e,y:Po(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*Po(e.radiusPt*po),l=Kf(e.color,.4*(e.alpha??.5)),s=[[i,0],[-i,0],[0,i],[0,-i],[.7*i,.7*i],[.7*-i,.7*i],[.7*i,.7*-i],[.7*-i,.7*-i]];for(const[c,u]of s)o.drawText(r,{...d,x:Po(t)+c,y:Po(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=Po(e.distPt*po);o.drawText(r,{...d,x:Po(t)+Math.cos(i)*l,y:Po(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:Po(t)+u,y:Po(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=Kf(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:Po(t),y:Po(a)+Po(e.distPt*po)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:Po(t),y:Po(a),text:n,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function Xf(e){for(const t of e.lines){const n=new Map(t.slots.map(e=>[e.offset,e]));for(const o of t.fragments){const r=o.image;if(!r?.floating)continue;const a=Boolean(r.floating.behindDoc);if("behind"===e.layer!==a)continue;const i=n.get(o.startOffset),l=nr({object:Dn(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 zf(e.writer,e.pageIndex,e.document,r,Po(l.x),Po(l.y),Po(l.width),Po(l.height))}}}function Gf(e,t,n,o,r,a,i,l){const s=Wf(n,o,i.fontSize??14.6667);if(!s)return;const c=a+ir(l,n.top,n.height),d=r+s.left,u=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(e.drawLine(t,{x1:Po(d),y1:Po(c-K),x2:Po(u),y2:Po(c-K),stroke:p,lineWidth:Po(1)}),void e.drawLine(t,{x1:Po(d),y1:Po(c+K),x2:Po(u),y2:Po(c+K),stroke:p,lineWidth:Po(1)})):void Vf(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:Po(d),y1:Po(c),x2:Po(u),y2:Po(c),stroke:p,lineWidth:Po(1)})}async function Yf(e,t,n,o,r,a,i,l,s,c){if(r.image){if(r.image.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await zf(e,t,a,r.image,Po(i+n.left),Po(l+o.top+o.height-r.image.height),Po(r.image.width),Po(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 Of(e,r.textBox,{document:a,fontRegistry:s,pageIndex:t},i+n.left,l+o.top+o.height-r.textBox.height,r.textBox.width,r.textBox.height,c))}if(r.math){const c=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!c)return;const d=De(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:Po(i+c.left),y:Po(l+o.top+o.height*qe),text:vt(r.math),fontSize:kr(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=De(r.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=s.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=kr(d),g=(d.baselineShift??0)*po,f=Re(n.style,a.styles),m=le(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*qe-g+m,b=Hf(o,r),y=b.map(e=>To(e.char,d)).join("");if(!b[0]||0===y.length)return;!function(e,t,n,o,r,a,i){if(!i.link)return;const l=Wf(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:Po(r+l.left),y:Po(a+n.top),width:Po(l.right-l.left),height:Po(n.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.shading)return;const l=Uf(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.shading})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.highlight)return;const l=Uf(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.highlight})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=Uf(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:Po(Math.max(.5,l.width*po))})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i,l,s){const c=new Map(o.slots.map(e=>[e.offset,e])),d=Re(n.style,a.styles).tabs??[];for(const u of r.chars){if("\t"!==u.char)continue;const n=c.get(u.paragraphOffset),r=c.get(u.paragraphOffset+1);if(!n||!r)continue;const a=o.slots[0]?.left??0,p=n.left-a,g=d.filter(e=>"clear"!==e.type).map(e=>({...e,positionPx:e.position*po})).filter(e=>e.positionPx>p+.01).sort((e,t)=>e.positionPx-t.positionPx)[0],f=g?.leader&&"none"!==g.leader?g.leader:void 0;if(!f)continue;const m="underscore"===f?l+2:l;e.drawLine(t,{x1:Po(i+n.left),y1:Po(m),x2:Po(i+r.left),y2:Po(m),stroke:s,lineWidth:Po("heavy"===f?1.5:1),dashArray:"dot"===f||"middleDot"===f?[1,3]:"hyphen"===f?[5,3]:void 0})}}(e,t,n,o,r,a,i,h,d.color??"#000000");const v=Re(n.style,a.styles).align??"left",x=rt(d,kr(d)),w={fontSize:p,bold:d.bold,italic:d.italic,fontResourceName:u.writerResourceName,characterSpacing:d.characterSpacing??0,horizontalScale:d.characterScale??100,fontFeatures:x};!function(e,t,n,o,r,a,i){const l="justify"===i?function(e){const t=[];let n=[];for(const o of e)" "!==o.char?n.push(o):n.length>0&&(t.push(n),n=[]);return n.length>0&&t.push(n),t}(t):function(e){const t=[];let n=[];for(const o of e){const e=n[n.length-1];e&&o.offset>e.offset+1&&(t.push(n),n=[]),n.push(o)}return n.length>0&&t.push(n),t}(t);for(const s of l){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>To(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;_f({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&Ve(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&&_f(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:jf(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&Gf(e,t,o,r,i,l,d,"underline"),d.strike&&Gf(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&Gf(e,t,o,r,i,l,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,o,r,a,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=Xe[l];if(!s)return;const c=Hf(n,o),d="underDot"===l,u=Math.max(4,.35*n.height),p=d?a+n.top+n.height+u:a+n.top+u;for(let g=0;g<c.length;g+=1){const o=c[g];if(" "===o.char||"\t"===o.char||"\n"===o.char)continue;const a=c[g+1],l=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:Po(r+l-.25*u),y:Po(p),text:s,fontSize:Po(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function qf(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=ta(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=De(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=Kr(n,r.styles),f=kr(u),m=c.length*f*.62*po,h=w(n,r.styles,d.left,m);e.drawText(t,{x:Po(a+Math.max(0,h||g)),y:Po(i+o.top+o.height*qe),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Zf(e,t,n,o,r,a,i){const l=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],s=l.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!s)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=Te(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:Po(p),y:Po(a),width:Po(Math.max(0,g-p)),height:Po(u),fill:n.shading});for(const[h,b]of l){if(!h||"none"===h.type||h.width<=0)continue;const[n,o,r,i]="top"===b?[p,a,g,a]:"bottom"===b?[p,f,g,f]:"left"===b?[p,a,p,f]:[g,a,g,f];e.drawLine(t,{x1:Po(n),y1:Po(o),x2:Po(r),y2:Po(i),stroke:h.color,lineWidth:h.width,dashArray:Af(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:Po(p),y1:Po(a),x2:Po(p),y2:Po(f),stroke:m.color,lineWidth:m.width,dashArray:Af(m.type)})}async function Jf(e,t,n,o,r,a,i,l,s,c){for(const d of o){qf(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await Yf(e,t,n,d,o,r,a,i,l,c)}}function Qf(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:Po(o),y1:Po(r),x2:Po(a),y2:Po(i),stroke:n.color,lineWidth:Po(n.width),dashArray:Af(n.type)})}function em(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;Qf(e,t,n.borders.top,a,i,l,i),Qf(e,t,n.borders.right,l,i,l,s),Qf(e,t,n.borders.bottom,a,s,l,s),Qf(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&Qf(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&Qf(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function tm(e,t,n,o,r,a,i,l,s,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?qt(d,n.tableSegment):d;if(0===u.rows.length)return;const p=zn({table:u,state:{document:o},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:n.estimatedHeight});for(const g of p.cells)g.shading&&e.drawRect(t,{x:Po(r+g.left),y:Po(a+g.top),width:Po(g.width),height:Po(g.height),fill:g.shading});for(const g of p.cells)if(em(e,t,g,r,a),g.revision){const n="insert"===g.revision.type?"#059669":"delete"===g.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:Po(r+g.left+1),y:Po(a+g.top+1),width:Po(Math.max(0,g.width-2)),height:Po(Math.max(0,g.height-2)),stroke:n,lineWidth:Po(2)})}for(const g of p.cells)for(const n of g.paragraphs)await Jf(e,t,n.paragraph,n.lines,o,r+n.originX,a+n.originY,l,s,c)}var nm={drawParagraph:Jf,drawTableBlock:tm};async function om(e,t,n,o,r,a,i,l,s,c,d){if(!n||0===n.length)return;const u=a;let p=a;for(let g=0;g<n.length;g+=1){const f=n[g];switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const n=Re(f.sourceBlock.style,o.styles),g=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0);d?.(f.sourceBlock.id,g);const m=g+Te(n).top;Zf(e,t,n,f.layout.lines,r,g,i),c&&(await Xf({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await Df({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:nm,layer:"behind"})),await Jf(e,t,f.sourceBlock,f.layout.lines,o,r,m,l,s,nm),c&&(await Xf({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await Df({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:nm,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Pr(f.sourceBlock,i),a=No({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 tm(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,l,s,nm);break}await tm(e,t,f,o,r,p,i,l,s,nm);break;default:Qe(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const l=n[g+1];if("paragraph"===l?.sourceBlock.type&&l.layout&&l.sourceBlock.id!==f.sourceBlock.id){const n=Re(f.sourceBlock.style,o.styles),s=Re(l.sourceBlock.style,o.styles);if(lt(n,s)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+Te(n).top;let l=0;for(const e of f.layout.lines)l=Math.max(l,e.top+e.height);const s=o+l,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:Po(c),y1:Po(s),x2:Po(d),y2:Po(s),stroke:u.color,lineWidth:u.width,dashArray:Af(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function rm(e,t,n,o,r,a,i){if(e.drawRect(t,{x:0,y:0,width:n,height:o,fill:r?.pageColor||"#ffffff"}),a){const r=a.distance??12,i="dashed"===a.style?[6,4]:"dotted"===a.style?[1,3]:void 0;if(e.drawRect(t,{x:r,y:r,width:n-2*r,height:o-2*r,fill:void 0,stroke:a.color,lineWidth:a.width,...i?{dashArray:i}:{}}),"double"===a.style){const i=r+2*a.width;e.drawRect(t,{x:i,y:i,width:n-2*i,height:o-2*i,stroke:a.color,lineWidth:a.width})}}const l=r?.watermark;if("text"===l?.kind&&l.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:l.text,fontSize:l.fontSize??48,color:l.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===l?.kind&&l.src&&i){const r={src:l.src,width:360,height:180},a=await $f(e,i,r);if(a){const i=l.scale??1,s=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-s)/2,y:(o-c)/2,width:s,height:c}),e.restoreGraphicsState(t)}}}var am=[{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 im(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function lm(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var sm=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of am)this.registerFontFace(e)}registerFontFace(e){this.faces.set(im(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=X(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(im(t,n,o))??this.faces.get(im(this.fallbackFamily,n,o))??this.faces.get(im(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(X).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(Pt)){const e=await zt(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 s(e.families);for(const n of t){const e=`Remote${lm(n.postscriptName||n.family)}`;this.registerFontFace({key:im(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 ee){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 zt(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${lm(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,s={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:n.family,fontData:o}};this.registerFontFace(s),r.push(s)}for(const e of n.aliases)for(const t of r)this.registerFontFace({...t,key:`${e.toLowerCase()}:${t.key.split(":")[1]}`,family:e})}return t}},cm="%PDF-1.4\n% Oasis PDF\n",dm=[{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 um(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function pm(e){return(new TextEncoder).encode(e).byteLength}function gm(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function fm(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function mm(e,t){if(!e)return t;const n=Gt(e);return n?[n[0]/255,n[1]/255,n[2]/255]:t}function hm(e,t,n){const[o,r,a]=mm(e,n);return`${um(o)} ${um(r)} ${um(a)} ${t}`}function bm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var ym=/* @__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 vm(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:ym.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function xm(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(fm).join("")}function wm(e){return fm(e)}function Sm(e){return`% OasisText ${xm(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function Im(e){return e&&0!==e.length?`[${e.map(e=>um(e)).join(" ")}] 0 d`:null}var Cm=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(hm(e.fill,"rg",[1,1,1])),e.stroke){n.push(hm(e.stroke,"RG",[0,0,0])),n.push(`${um(e.lineWidth??1)} w`);const t=Im(e.dashArray);t&&n.push(t)}n.push([um(e.x),um(t.height-e.y-e.height),um(e.width),um(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=Im(e.dashArray),o=["q",hm(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${um(e.lineWidth??1)} w`,`${um(e.x1)} ${um(t.height-e.y1)} m`,`${um(e.x2)} ${um(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(hm(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(hm(e.stroke,"RG",[0,0,0])),o.push(`${um(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${um(r.x)} ${um(n(r.y))} m`);break;case"line":o.push(`${um(r.x)} ${um(n(r.y))} l`);break;case"cubic":o.push(`${um(r.x1)} ${um(n(r.y1))} ${um(r.x2)} ${um(n(r.y2))} ${um(r.x)} ${um(n(r.y))} c`);break;case"close":o.push("h")}e.fill&&e.stroke?o.push("B"):e.fill?o.push("f"):o.push("S"),o.push("Q"),t.commands.push(o.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}setOpacity(e){const t=Math.max(0,Math.min(1,e)),n=`GSOpacity${Math.round(100*t)}`;(this.page.graphicsStateOpacities??=/* @__PURE__ */new Map).set(n,t),this.page.commands.push(`/${n} gs`)}rotateAbout(e,t,n){const o=this.page;if(!n)return;const r=o.height-t,a=-n*Math.PI/180,i=Math.cos(a),l=Math.sin(a),s=e-e*i+r*l,c=r-e*l-r*i;o.commands.push(`${um(i)} ${um(l)} ${um(-l)} ${um(i)} ${um(s)} ${um(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${um(e)} ${um(r.height-t-o)} ${um(n)} ${um(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(`${um(r.x)} ${um(n(r.y))} m`);break;case"line":o.push(`${um(r.x)} ${um(n(r.y))} l`);break;case"cubic":o.push(`${um(r.x1)} ${um(n(r.y1))} ${um(r.x2)} ${um(n(r.y2))} ${um(r.x)} ${um(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):`<${vm(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${um(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${um(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${um(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([Sm(n.text),"BT",hm(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[hm(n.strokeColor??n.color,"RG",[0,0,0]),`${um(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${um(n.x)} ${um(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([Sm(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${um(n.x)} ${um(r.height-n.y)} Td`,t,"ET",`/${o} sh`,"Q"].join("\n"))}drawImage(e){const t=this.page;if(e.width<=0||e.height<=0||!this.images.has(e.resourceName))return;t.imageResourceNames.add(e.resourceName);const n=t.height-e.y-e.height,o=Number.isFinite(e.rotation)?e.rotation??0:0,r=e.crop,a=r?.left??0,i=r?.top??0,l=r?.right??0,s=r?.bottom??0;if(r&&(a>0||i>0||l>0||s>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:l,bottom:s});if(0===o)return void t.commands.push(["q",[um(e.width),"0","0",um(e.height),um(e.x),um(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",[um(p),um(g),um(f),um(m),um(h),um(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,l=a/Math.max(1e-4,1-o.left-o.right),s=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*l,d=-o.bottom*s,u=-n*Math.PI/180,p=Math.cos(u),g=Math.sin(u),f=a/2,m=i/2,h=p,b=g,y=-g,v=p,x=e.x+a/2-(h*f+y*m),w=t+i/2-(b*f+v*m);r.commands.push(["q",[um(h),um(b),um(y),um(v),um(x),um(w),"cm"].join(" "),`0 0 ${um(a)} ${um(i)} re W n`,[um(l),"0","0",um(s),um(c),um(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function Tm(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function Pm(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function km(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function Rm(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 Bm(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=Pm(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 Mm(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:Pm(e,e.u16())}))}(e,n),a=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let c=0;c<n;c+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}if(0===o.length)return[];const r=o.find(e=>"latn"===e.tag)??o.find(e=>"DFLT"===e.tag)??o[0];e.seek(r.offset);const a=e.u16();if(0===a)return[];e.seek(r.offset+a),e.skip(2);const i=e.u16(),l=e.u16(),s=[];65535!==i&&s.push(i);for(let c=0;c<l;c+=1)s.push(e.u16());return s}(e,t),i=/* @__PURE__ */new Map;for(const l of a){const e=r[l];if(!e)continue;const t=i.get(e.tag)??[];for(const n of e.lookupIndices)t.includes(n)||t.push(n);i.set(e.tag,t)}return{featureToLookups:i,lookupListOffset:o}}function Fm(e,t,n){return e.seek(t),km(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=km(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 Am(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 Om(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=km(e,o,t).map(t=>(e.seek(t),Pm(e,e.u16())));return{coverage:Rm(e,n),sets:r}}function Dm(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 Em(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function Lm(e,t){e.seek(t);const n=e.u16();return km(e,n,t).map(t=>(e.seek(t),{backtrack:Pm(e,e.u16()),input:Pm(e,Math.max(0,e.u16()-1)),lookahead:Pm(e,e.u16()),records:Dm(e,e.u16())}))}function Nm(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 Em(t,n,i.records,o),e}}}return null}function $m(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=Rm(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=Pm(e,t),r=Rm(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=Om(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];if(0===i.length)return null;const l=n.codePoints,s=i.map((e,t)=>({id:e,codePoints:0===t?l:[]}));return e.splice(t,1,...s),i.length}}}(e,t);case 3:return function(e,t){const n=Om(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=km(e,o,t).map(t=>(e.seek(t),km(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:Pm(e,Math.max(0,o-1))}}))),a=Rm(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=km(e,e.u16(),t),o=km(e,e.u16(),t),r=km(e,e.u16(),t),a=Dm(e,e.u16()),i=n.map(t=>Rm(e,t)),l=o.map(t=>Rm(e,t)),s=r.map(t=>Rm(e,t));return{apply(e,t,n){if(0===l.length)return null;if(t+l.length>e.length)return null;for(let o=0;o<l.length;o+=1)if(l[o](e[t+o].id)<0)return null;for(let o=0;o<i.length;o+=1){const n=e[t-1-o];if(!n||i[o](n.id)<0)return null}for(let o=0;o<s.length;o+=1){const n=e[t+l.length+o];if(!n||s[o](n.id)<0)return null}return Em(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=km(e,o,t),a=Rm(e,n),i=r.map(t=>Lm(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:Nm(i[r],e,t,n,null)}}}if(2===n){const n=t+e.u16(),o=t+e.u16(),r=t+e.u16(),a=t+e.u16(),i=e.u16(),l=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();l[g]=0===n?0:t+n}const s=Rm(e,n),c=Bm(e,o),d=Bm(e,r),u=Bm(e,a),p=l.map(t=>0===t?[]:Lm(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(s(o.id)<0)return null;const r=d(o.id),a=p[r];return a?Nm(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return Tm(e,t,$m);default:return null}}var zm=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Ne(t),{featureToLookups:o,lookupListOffset:r}=Mm(n),a=Fm(n,r,$m);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return Am(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 Hm(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 Wm(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function Um(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=Hm(e,e.u16()),n=Rm(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=Wm(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=Hm(e,t);const l=Rm(e,o);return{apply(e,t,o){const r=l(e[o]);if(r<0||r>=n)return null;const a=i[r];return 0===a?null:(t[o]+=a,1)}}}return null}(e,t);case 2:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16(),r=e.u16(),a=e.u16(),i=!!(4&a);if(1===n){const n=e.u16(),l=km(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=Hm(e,r),i=Hm(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=Rm(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=s(e[n]);if(r<0||r>=l.length)return null;const a=l[r].get(o);return a?(t[n]+=a.value1XAdvance,t[n+1]+=a.value2XAdvance,i?2:1):null}}}if(2===n){const n=t+e.u16(),l=t+e.u16(),s=e.u16(),c=e.u16(),d=Wm(r),u=d+Wm(a),p=e.tell(),g=new Array(s*c),f=new Array(s*c);for(let t=0;t<s;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=Hm(e,r),e.seek(p+o+d),f[t*c+n]=Hm(e,a)}const m=Rm(e,o),h=Bm(e,n),b=Bm(e,l);return{apply(e,t,n){const o=e[n],r=e[n+1];if(void 0===r)return null;if(m(o)<0)return null;const a=h(o),l=b(r);if(a>=s||l>=c)return null;const d=a*c+l,u=g[d],p=f[d];return 0===u&&0===p?null:(t[n]+=u,t[n+1]+=p,i?2:1)}}}return null}(e,t);case 9:return Tm(e,t,Um);default:return null}}var jm=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Ne(t),{featureToLookups:o,lookupListOffset:r}=Mm(n),a=Fm(n,r,Um);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=Am(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}}}},Vm=/* @__PURE__ */new Set(["kern"]),Km=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?zm.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?jm.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=>!Vm.has(e))??[],r=t?.filter(e=>Vm.has(e))??[];this.gsub&&o.length>0&&this.gsub.shape(n,o);const a=n.map(e=>this.font.advanceWidthForGlyph(e.id));this.gpos&&r.length>0&&this.gpos.position(n.map(e=>e.id),a,r);const i=[],l=[];let s=0;for(let c=0;c<n.length;c+=1){const e=n[c],t=this.font.advanceWidthForGlyph(e.id),o=a[c];i.push({id:e.id,codePoints:e.codePoints,advanceWidth:t}),l.push({xAdvance:o}),s+=o}return{glyphs:i,positions:l,advanceWidth:s}}},_m=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 Xm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Gm(e,t){return Xm(e).getUint16(t)}function Ym(e,t,n){Xm(e).setUint16(t,n,!1)}function qm(e,t,n){Xm(e).setUint32(t,n,!1)}function Zm(e){return e+3&-4}function Jm(e){const t=e.reduce((e,t)=>e+Zm(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=Zm(r.byteLength);return n}function Qm(e,t){const n=[],o=Xm(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 eh(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function th(e,t){if(e.byteLength<10||function(e,t){return Xm(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=Gm(e,n),t(Gm(e,n+2)),n+=4,n+=1&o?4:2,8&o?n+=2:64&o?n+=4:128&o&&(n+=8)}while(32&o)}function nh(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>qm(t,4*n,e)),t}function oh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)Ym(n,4*o,e.advanceWidthForGlyph(o)),Ym(n,4*o+2,0);return n}var rh=class{createSubset(e,t){const n=/* @__PURE__ */new Map,o=[];for(const d of t)o.push(d.id),n.has(d.id)||n.set(d.id,d.codePoints);const r=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head");if(!n||!o||!r)return Array.from(/* @__PURE__ */new Set([0,...t])).sort((e,t)=>e-t);const a=Qm(o,Gm(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=eh(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||th(n.slice(e.start,e.end),e=>{i.has(e)||(i.add(e),l.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head"),a=e.getRawTableData("hhea"),i=e.getRawTableData("maxp"),l=e.getRawTableData("cmap");if(!(n&&o&&r&&a&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...t),c=new Set(t),d=Qm(o,Gm(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=eh(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=Zm(t.byteLength)}}u.push(g);const f=r.slice();qm(f,8,0),Ym(f,50,1);const m=a.slice();Ym(m,34,s+1);const h=i.slice();Ym(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:oh(e,s),loca:nh(u),maxp:h,glyf:Jm(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=sr(65536,new Map(Object.entries(a).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,l=Math.max(0,...r),s=[],c=[];for(let d=0;d<=l;d+=1)s[d]=e.advanceWidthForGlyph(d)/e.unitsPerEm*1e3,c[d]=n.get(d)??[0];return{fontFile:i,widths:s,unicode:c,encodeGlyph:e=>e}}};var ah=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 Km(e);return{program:e,layouter:t.hasShaping?t:new _m(e),subsetter:new rh}}(function(e){const t=ye.decodeSync(e);return Ae.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?`<${wm(e.glyphId)}>`:`<${wm(e.glyphId)}> ${um(t)}`}).join(" ")}] TJ`:`<${r.map(e=>wm(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>"base14"===e.kind||this.usedFontResourceNames.has(e.resourceName)),n=t.map(t=>{if("unicode"===t.kind){const n=this.unicodeFontStates.get(t.resourceName);if(n)return this.addUnicodeFontObjects(n,e)}return e(function(e){switch(e.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${e.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))});return{resourceXml:t.map((e,t)=>`/${e.resourceName} ${n[t]} 0 R`).join(" ")}}layoutUnicodeText(e,t,n){const o=`${n?.join(",")??""}\0${t}`,r=e.layoutCache.get(o);if(r)return r;const a=e.font.layouter.layout(t,n);return e.layoutCache.set(o,a),a}encodeUnicodeGlyphRun(e,t){return t.glyphs.map((n,o)=>{e.usedGlyphs.has(n.id)||e.usedGlyphs.set(n.id,n);const r=t.positions[o],a=n.advanceWidth*e.scale,i=(r?.xAdvance??n.advanceWidth)*e.scale;return{glyphId:n.id,nominalWidth:a,desiredAdvance:i}})}addUnicodeFontObjects(e,t){const n=e.font.subsetter.createSubset(e.font.program,e.usedGlyphs.values()),o=t(function(e,t=""){const n=`${gm(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${pm(n)} /Filter /ASCIIHexDecode${o} >>\nstream\n${n}\nendstream`}(n.fontFile)),r=e.font.program.metadata,a=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),a>=1&&a<=7&&(i|=2),10===a&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${bm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${bm(r.postscriptName,e.resource.family)}`,s=r.bbox,c=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*e.scale,s.minY*e.scale,s.maxX*e.scale,s.maxY*e.scale].map(um).join(" ")}]`,`/ItalicAngle ${um(r.italicAngle)}`,`/Ascent ${um(r.ascent*e.scale)}`,`/Descent ${um(r.descent*e.scale)}`,`/CapHeight ${um(r.capHeight*e.scale)}`,`/XHeight ${um(r.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${o} 0 R`,">>"].join("\n")),d=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${c} 0 R`,`/W [0 [${n.widths.map(e=>um(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${pm(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${xm(e)}>`).filter(e=>"<>"!==e);0===t.length&&t.push("<0000>");const n=[];for(let o=0;o<t.length;o+=256){const e=Math.min(o+256,t.length);n.push(`<${fm(o)}> <${fm(e-1)}> [${t.slice(o,e).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${n.length} beginbfrange`,n.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(n.unicode)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${d} 0 R]`,`/ToUnicode ${u} 0 R`,">>"].join("\n"))}},ih=class{imageResources=/* @__PURE__ */new Map;registerImageResource(e){const t=e.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(t)||this.imageResources.set(t,{resourceName:t,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height)),data:e.data,filter:e.filter}),t}has(e){return this.imageResources.has(e)}buildImageObjects(e){const t=/* @__PURE__ */new Map;for(const n of this.imageResources.values())t.set(n.resourceName,this.addImageObject(n,e));return t}addImageObject(e,t){return t(function(e,t){const n=`${gm(e)}>`;return[`<< /Length ${pm(n)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${t.join(" ")}`," >>","stream",n,"endstream"].join("\n")}(e.data,["/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},lh=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 sh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(sh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>um(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:mm(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(um).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function sh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(um).join(" ")}]`,`/C1 [${t.map(um).join(" ")}]`,"/N 1",">>"].join("\n")}var ch=new TextEncoder;function dh(e){return"string"==typeof e?pm(e):e.length}function uh(e){const t=e.reduce((e,t)=>e+dh(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?ch.encode(r):r;n.set(e,o),o+=e.length}return n}function ph(e){const t=pe(ch.encode(e));return uh([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function gh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function fh(e){return`<FEFF${xm(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function mh(e){const t=[];if(e.title&&t.push(`/Title ${fh(e.title)}`),e.author&&t.push(`/Author ${fh(e.author)}`),e.subject&&t.push(`/Subject ${fh(e.subject)}`),e.keywords&&t.push(`/Keywords ${fh(e.keywords)}`),e.producer&&t.push(`/Producer (${gh(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 hh(e){return e.children.reduce((e,t)=>e+1+hh(t),0)}function bh(e,t,n,o,r=[],a=[],i){const l=[],s=e=>{const t=l.length+1;return l.push({id:t,body:e}),t},c=s(""),d=s(""),{resourceXml:u}=t.buildFontObjects(s),p=n.buildImageObjects(s),g=o.buildShadingObjects(s),f=/* @__PURE__ */new Map;for(const B of e)for(const[e,t]of B.graphicsStateOpacities??[])f.has(e)||f.set(e,s(`<< /Type /ExtGState /ca ${um(t)} /CA ${um(t)} >>`));const m=[];for(const B of e){const e=s(ph(`${B.commands.join("\n")}\n`)),t=Array.from(B.imageResourceNames).map(e=>{const t=p.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),n=t?` /XObject << ${t} >>`:"",o=Array.from(B.shadingResourceNames).map(e=>{const t=g.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),r=o?` /Shading << ${o} >>`:"",a=Array.from(B.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${f.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",l=B.annotations.map(e=>{const t=e.x,n=e.x+e.width,o=B.height-e.y-e.height,r=B.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${gh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${gh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${um(t)} ${um(o)} ${um(n)} ${um(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=l.length>0?`\n/Annots [${l.map(e=>`${e} 0 R`).join(" ")}]`:"",h=s(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${um(B.width)} ${um(B.height)}]`,`/Resources << /Font << ${u} >>${n}${r}${i} >>`,`/Contents ${e} 0 R${c}`,">>"].join("\n"));m.push(h)}let h;const b=r.filter(e=>void 0!==m[e.pageIndex]).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0);let y;b.length>0&&(h=s(`<< /Dests ${s(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${gh(t.name)}) [${n} 0 R /XYZ ${um(t.x)} ${um(o)} null]`}).join(" ")}] >>`)} 0 R >>`));const v=new Set(b.map(e=>e.name)),x=function(e){const t=[],n=[];for(const o of e){const e={title:o.title,destName:o.destName,children:[]};for(;n.length>0&&n[n.length-1].level>=o.level;)n.pop();0===n.length?t.push(e):n[n.length-1].node.children.push(e),n.push({node:e,level:o.level})}return t}(a.filter(e=>v.has(e.destName)));if(x.length>0){y=s("");const e=t=>t.map(t=>{const n=s("");return t.id=n,t.childIds=e(t.children),n}),t=e(x),n=(e,t)=>{e.forEach((o,r)=>{const a=o,i=r>0?e[r-1]:void 0,s=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+fh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${gh(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 ${hh(o)}`)),c.push(">>"),l[a.id-1].body=c.filter(Boolean).join("\n"),n(o.children,a.id)})};n(x,y);const o=a.filter(e=>v.has(e.destName)).length;l[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(l[c-1].body=["<< /Type /Catalog",`/Pages ${d} 0 R`,void 0!==h?`/Names ${h} 0 R`:"",void 0!==y?`/Outlines ${y} 0 R`:"",void 0!==y?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=mh(i);e&&(w=s(e))}const S=[cm];let I=dh(cm);const C=[0],T=e=>{S.push(e),I+=dh(e)};for(const B of l)C[B.id]=I,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const P=I;let k=`xref\n0 ${l.length+1}\n`;k+="0000000000 65535 f \n";for(const B of l)k+=`${String(C[B.id]??0).padStart(10,"0")} 00000 n \n`;T(k);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${l.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(P),"%%EOF",""].join("\n")),uh(S)}var yh=class{pages=[];streams=[];fonts;images=new ih;shadings=new lh;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=dm){this.fonts=new ah(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 Cm(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}),bh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function vh(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=Po(i),s=Po(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:s,y:l});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:s,y:l}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function xh(e){e=ge(e);const t=new sm,n=pa(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new yh(t.getPdfFontResources());o.setDocumentInfo(function(e){const t=e.metadata??{},n=e=>"string"==typeof e&&""!==e.trim()?e:void 0;return{title:n(t.title),author:n(t.author),subject:n(t.subject),keywords:n(t.keywords),producer:"Oasis Editor",creationDate:/* @__PURE__ */new Date}}(e));const r=go(e),a=function(e){return Dr(e)}(e),i=function(e){const t=/* @__PURE__ */new Map,n=e.bookmarks;if(!n)return t;for(const o of n.order){const e=n.items[o],r=e?.start?.paragraphId;if(!e||!r)continue;const a=t.get(r)??[];a.push(e.name),t.set(r,a)}return t}(e),l=new Map(an(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,Po(s.pageSettings.width)),r=Math.max(1,Po(s.pageSettings.height)),c=o.addPage({width:n,height:r});await rm(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=Lt(s.pageSettings);await om(o,c,s.headerBlocks,e,d,s.headerTop??j(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??q(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=St(s.pageSettings),r=/* @__PURE__ */new Map;for(const e of s.blocks){const t=e.columnIndex??0,n=r.get(t)??[];n.push(e),r.set(t,n)}for(const[d,u]of r){const r=n[d]??n[0];await om(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,vh(o,c,r.left,i,l))}}else await om(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,vh(o,c,d,i,l));await om(o,c,s.footerBlocks,e,d,s.footerTop??s.bodyBottom??s.pageSettings.height,u,t,a,s.pageSettings),s.footnoteBlocks&&s.footnoteBlocks.length>0&&void 0!==s.footnoteTop&&(void 0!==s.footnoteSeparatorTop&&o.drawLine(c,{x1:Po(d),y1:Po(s.footnoteSeparatorTop+.5),x2:Po(d+Math.min(180,.35*u)),y2:Po(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:Po(1)}),await Sh(o,c,s.footnoteBlocks,s.footnoteReferenceIds??[],e,d,s.footnoteTop,u,t,a))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await rm(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function wh(e){const t=await xh(e);return new Blob([t],{type:"application/pdf"})}async function Sh(e,t,n,o,r,a,i,l,s,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,mn(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=De(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:Po(a),y:Po(d+12),text:o,fontSize:kr(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await om(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function Ih(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Ch(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 Th(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 Ph(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 kh(e){return function(e){const t=b(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=Re(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=De(o.styles,i.style?.styleId,e.styles),l=t.fontFamily??"<null>";n.set(l,(n.get(l)??0)+1),null!==t.characterSpacing&&(r+=1),null!==t.characterScale&&(a+=1)}}return{paragraphCount:t.length,alignCounts:Array.from(o.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:r,characterScaleRuns:a,firstParagraphs:t.slice(0,30).map((t,n)=>{const o=Re(t.style,e.styles),r=t.runs[0],a=De(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:we(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 Rh(e,t){const n=hr(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=Oo(e)[n.startIndex];if(!o)return null;let r=0;for(let a=0;a<o.runs.length;a+=1){const e=o.runs[a],i=r;if(r+=e.text.length,t(e)&&1===e.text.length&&i===n.startParagraphOffset)return{paragraph:o,paragraphIndex:n.startIndex,run:e,runIndex:a,offset:i}}return null}function Bh(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 Mh(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function Fh(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function Ah(e){return"page"===e?.positionV?.relativeFrom}function Oh(e){return Rh(e,e=>"image"===e.kind)}function Dh(e,t,n){return jh(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function Eh(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function Lh(e,t){return jh(e,e=>{const n={...e},o=function(e){if(!e)return;const t=Eh(e.left),n=Eh(e.top),o=Eh(e.right),r=Eh(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 Nh(e,t){const n=Oh(e),o=n&&Ut(n.run);return o?Lh(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=Eh(a.left),l=Eh(a.top),s=Eh(a.right),c=Eh(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-s);return{crop:{...a,left:i+t/2,right:s+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-l-c);return{crop:{...a,top:l+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function $h(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 zh(e){return jh(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function Hh(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function Wh(e,t,n=90){const o=Oh(e);if(!o||!Ut(o.run))return e;const r="right"===t?-n:n,a=Hh(function(e){const t=Oh(e);return(t&&Ut(t.run))?.rotation??0}(e)+r);return jh(e,e=>({...e,rotation:a}))}function Uh(e,t){const n=function(e){const t=Oh(e),n=t&&Ut(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?jh(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function jh(e,t){const n=Oh(e);if(!n||!Ut(n.run))return e;const r=Oo(e),{paragraphIndex:a,run:i}=n,l=r.map((e,n)=>n!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id===i.id&&"image"===e.kind?{...e,image:t(e.image)}:o(e))});return la(e,l,xe(l,hr(e)))}function Vh(e,t){return jh(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function Kh(e,t){const n=Oh(e);if(!n)return e;const o=Oo(e),{paragraphIndex:r,offset:a,run:i}=n,l=pn(o,t.paragraphId);if(l<0)return e;const s=o[l],c=sa(s,t),d=l===r&&c>a?c-1:c;if(l===r&&d===a)return e;const u=e=>fe(e,[...U(e,0,a),...U(e,a+1,oe(e))]),p=(e,t)=>Y(e,Math.max(0,Math.min(t,oe(e))),[Kn("",Et(e,t),Ut(i))]),g=o.map((e,t)=>t===r&&t===l?p(u(e),d):t===r?u(e):t===l?p(e,d):tt([e])[0]),f=g[l],m=Math.max(0,Math.min(d+1,oe(f)));return la(e,g,nt(ot(f,m)))}function _h(e,t,n,o=0){const r=Lt(Bt(t));if(!n)return r;const a=Fr(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function Xh(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await Th(t),r=`data:${t.type};base64,${function(e){return btoa(new Uint8Array(e).reduce((e,t)=>e+String.fromCharCode(t),""))}(o)}`,a=new Image;a.src=r,await new Promise(e=>{a.onload=e,a.onerror=e});const i=a.naturalWidth||300,l=a.naturalHeight||300,s=e.state(),c=n?.paragraphId??s.selection.focus.paragraphId,d=_h(e.surfaceRef(),s.document,c,s.activeSectionIndex??0),u=i>d?d/i:1,p=Math.max(24,Math.round(i*u)),g=Math.max(24,Math.round(l*u));e.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${g} maxWidth=${d}`),e.applyTransactionalState(e=>function(e,t){const n=_o(e.selection)?e:Ke(e),{paragraph:o,index:r,offset:a}=E(n),i=Kn("",Et(o,a),t),l=Y(o,a,[i]),s=Oo(n).map((e,t)=>t===r?l:Kt(e));return la(n,s,nt(ot(l,a+1)))}(n?Cs(e,{anchor:n,focus:n}):e,{src:r,width:p,height:g,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:Pa})}}}var Gh={"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 Yh(e){return function(e){const[t,n]=Tt(null),o=(e,t)=>{const[n,o]=Gh[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=ga(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 Th(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:vo(e.now()-a,2)});let l=null,s=-1,c=0;const d=await n.import(i,(t,n)=>{const o=e.now(),r=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==l;if(!(a||void 0!==r&&(s<0||r-s>=1)||o-c>=40))return;l=t,s=r??s,c=o,e.setImportPhase(t,n);const i={phase:t,subProgress:n};a||void 0===n||1===n?e.logger.info("import:phase",i):e.logger.debug("import:phase",i)});e.logger.debug("import:document-diagnostics",kh(d));const u=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(d),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:vo(e.now()-u,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(Ln(d));const p=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:vo(e.now()-p,2)});const g=wo(d).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),f=Wr(d).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:g,paragraphs:f,durationMs:vo(e.now()-o,2)}),e.focusInput()}catch(a){e.setImportPhase("error"),e.logger.error("import:error",a)}finally{e.clearImportProgressSoon()}}}}({applyState:e.applyState,stabilizeLayoutAfterImport:e.stabilizeLayoutAfterImport,resetEditorChromeState:e.resetEditorChromeState,focusInput:e.focusInput,requestLocalFontAccess:e.requestLocalFontAccess,prepareDocumentFonts:e.prepareDocumentFonts,setImportPhase:r,clearImportProgressSoon:a,now:()=>performance.now(),logger:e.logger}),l=Xh({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),s=function(e){const t=e.download??Ih,n=e.print??Ch;let o=!1;return{handleExportDocx:async()=>{const n=await Ff(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await wh(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await wh(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>Ff(e.document()),exportPdfBlob:()=>wh(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),c=async t=>{e.isReadOnly()||await i.handleImportFile(t)},d=async(e,t)=>{await l.insertImageFromFile(e,t)},u=async t=>{e.isReadOnly()||t&&(await d(t),e.focusInput())};return{importProgress:t,handleImportFile:c,handleExportDocx:async()=>s.handleExportDocx(),handleExportPdf:async()=>s.handleExportPdf(),handlePrint:async()=>s.handlePrint(),exportDocxBlob:s.exportDocxBlob,exportPdfBlob:s.exportPdfBlob,insertImageFromFile:d,handleInsertImage:u}}(e)}function qh(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Zh(e){return" "===e||"\t"===e||"\n"===e}function Jh(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 Qh(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=Qh(n.blocks,t);if(e)return e}}return null}function eb(e,t){const n=hr(t),o=[],r=e.surfaceRect,a=new Map(Oo(t).map((e,t)=>[e.id,t]));let i=null,l=null;if(!n.isCollapsed&&n.startIndex===n.endIndex&&n.endParagraphOffset-n.startParagraphOffset===1){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.inlineImages.find(t)??e.floatingImages.find(t);if(o&&(i={paragraphId:o.paragraphId,startOffset:o.startOffset,endOffset:o.endOffset,left:o.left-r.left,top:o.top-r.top,width:o.width,height:o.height,rotation:o.rotation??0}),!i){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.floatingTextBoxes.find(t),a=o?void 0:e.inlineTextBoxes.find(t),i=o??a;i&&(l={paragraphId:i.paragraphId,startOffset:i.startOffset,endOffset:i.endOffset,left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height,rotation:i.rotation??0,floating:Boolean(o)})}}const s=(e.paragraphsById.get(t.selection.anchor.paragraphId)??[]).find(e=>e.tableCell)?.tableCell,c=(e.paragraphsById.get(t.selection.focus.paragraphId)??[]).find(e=>e.tableCell)?.tableCell;let d=!1;if(s&&c&&s.tableId===c.tableId&&(s.rowIndex!==c.rowIndex||s.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of He(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Qh(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Qh(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=Vt(n),a=t.find(e=>e.rowIndex===s.rowIndex&&e.cellIndex===s.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const l=Math.min(a.visualRowIndex,i.visualRowIndex),s=Math.max(a.visualRowIndex+a.rowSpan-1,i.visualRowIndex+i.rowSpan-1),c=Math.min(a.visualColumnIndex,i.visualColumnIndex),u=Math.max(a.visualColumnIndex+a.colSpan-1,i.visualColumnIndex+i.colSpan-1),p=/* @__PURE__ */new Set;for(const a of e.paragraphs)if(a.tableCell&&a.tableCell.tableId===n.id){const e=t.find(e=>e.rowIndex===a.tableCell.rowIndex&&e.cellIndex===a.tableCell.cellIndex);if(e){const t=e.visualRowIndex<=s&&e.visualRowIndex+e.rowSpan-1>=l,n=e.visualColumnIndex<=u&&e.visualColumnIndex+e.colSpan-1>=c;if(t&&n){const t=`${e.rowIndex}:${e.cellIndex}`;p.has(t)||(p.add(t),o.push({left:a.tableCell.left-r.left,top:a.tableCell.top-r.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(d||n.isCollapsed||i||l))for(const w of e.paragraphs){const e=Jh(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&&Zh(qh(w,e));)e+=1;for(;a>e&&Zh(qh(w,a-1));)a-=1;if(e>=a)continue;const l=n.slots.find(t=>t.offset===e),s=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!l||!s)continue;const c=0===w.startOffset&&n.startOffset===w.startOffset&&n.top>w.top,d=c?w.top:n.top,u=c?n.top+n.height-w.top:n.height;o.push({left:l.left-r.left+1,top:d-r.top,width:Math.max(1,s.left-l.left+1-1),height:u})}}const u=t.selection.focus.paragraphId,p=e.paragraphsById.get(u)??[],g=p[0]?.paragraph,f=function(e,t){if(0===e.length)return null;const n=e.find(e=>t>=e.startOffset&&t<=e.endOffset)??e[e.length-1],o=n.lines.flatMap(e=>e.slots);if(0===o.length)return{left:n.left,top:n.top,height:Math.max(18,n.height)};let r=o[0],a=Math.abs(t-r.offset);for(const l of o){const e=Math.abs(t-l.offset);e<a&&(r=l,a=e)}const i=n.lines[0];return 0===n.startOffset&&void 0!==i&&t>=i.startOffset&&t<=i.endOffset&&r.top>n.top?{left:r.left,top:n.top,height:r.top+r.height-n.top}:{left:r.left,top:r.top,height:r.height}}(p,g?sa(g,t.selection.focus):t.selection.focus.offset),m=(f?.left??r.left)-r.left,h=(f?.top??r.top)-r.top,b=Math.max(18,f?.height??28),y={left:m,top:h,height:b,visible:p.length>0&&!d&&!i&&!l};let v=null;const x=(e.paragraphsById.get(u)??[])[0]?.tableCell?.tableId??null;if(x){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of e.paragraphs){const e=r.tableCell;e&&e.tableId===x&&(t=Math.min(t,e.left),n=Math.min(n,e.top),o=Math.max(o,e.left+e.width),a=Math.max(a,e.top+e.height))}Number.isFinite(t)&&o>t&&a>n&&(v={tableId:x,left:t-r.left,top:n-r.top,width:o-t,height:a-n})}return{selectionBoxes:o,inputBox:{left:m,top:h,height:b},caretBox:y,selectedImageBox:i,selectedTextBoxBox:l,selectedTableBox:v}}var tb={composeMeasuredParagraphLines:e=>Jr.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>Jr.resolveRenderedLineHeightPx(e,t)};function nb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function ob(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 rb(){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&&nb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&nb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&ob(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&ob(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 ab(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 ib(e){return function(e){const[t,n]=Tt({}),[o,r]=Tt({}),[a,i]=Tt({left:0,top:0,height:28}),[l,s]=Tt([]),[c,d]=Tt([]),[u,p]=Tt(null),[f,m]=Tt(null),[h,b]=Tt(null),[y,v]=Tt({left:0,top:0,height:28,visible:!1}),[x,w]=Tt(null),S=rb(),I=At(()=>(fr(),S(go(e.state.document,void 0,t(),o(),{measurer:tb})))),C=$e();let T=0;const P=(t="selection")=>{const n=e.surfaceRef();if(!n)return s([]),d([]),p(null),m(null),b(null),void v(e=>({...e,visible:!1}));const o=C.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:I(),zoomFactor:e.zoomFactor?.()});if(!o)return s([]),d([]),p(null),m(null),b(null),void v(e=>({...e,visible:!1}));const r=eb(o,e.state);s(r.selectionBoxes),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length)return[];const o=e.surfaceRect,r=new Map(Oo(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const t=n.items[i];if(!t?.start||!t?.end)continue;const l=r.get(t.start.paragraphId),s=r.get(t.end.paragraphId);if(void 0!==l&&void 0!==s)for(const n of e.paragraphs){const e=r.get(n.paragraphId);if(void 0===e||e<l||e>s)continue;const c=e===l?t.start.offset:0,d=e===s?t.end.offset:Number.POSITIVE_INFINITY,u=Math.max(c,n.startOffset),p=Math.min(d,n.endOffset);if(!(u>=p))for(const t of n.lines){const e=Math.max(u,t.startOffset),n=Math.min(p,t.endOffset);if(e>=n)continue;const r=t.slots.find(t=>t.offset===e),l=t.slots.find(e=>e.offset===n)??t.slots[t.slots.length-1];r&&l&&a.push({commentId:i,left:r.left-o.left,top:t.top-o.top,width:Math.max(1,l.left-r.left),height:t.height})}}}return a}(o,e.state)),p(r.selectedImageBox),m(r.selectedTextBoxBox),b(r.selectedTableBox),i(r.inputBox),v(r.caretBox)},k=(e="selection")=>{const t=++T;queueMicrotask(()=>{t===T&&P(e)})},R=(e="content-change")=>(k(e),!1),B=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(r(e=>ab(e,t.paragraphIds??[])),jo()),k(e),t.resolveWhenDone?Promise.resolve():null),M=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),r({}),jo();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];r(t=>ab(t,e)),jo()}k("content-change")}},F=async()=>{n({}),r({}),jo(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),k("import")};g(()=>{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,k("selection")}),g(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||k("content-change")}),g(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{k("scroll")},o=()=>{k("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),be(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const A=()=>w(null),O=()=>{T+=1,C.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:o,documentLayout:I,canvasSnapshotProvider:C,inputBox:a,selectionBoxes:l,commentHighlights:c,selectedImageBox:u,selectedTextBoxBox:f,selectedTableBox:h,caretBox:y,preferredColumnX:x,setPreferredColumnX:w,clearPreferredColumn:A,requestInputBoxSync:k,scheduleDeferredLayoutMeasurement:B,stabilizeLayoutAfterImport:F,syncMeasuredLayoutMetrics:R,syncInputBox:P,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:r,applyInvalidation:M,onCleanupHook:O}}(e)}function lb(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function sb(e){return function(e){const t=(e,t)=>{const n=wo(e.document),o=Math.max(0,Math.min(Fn(e),n.length-1)),r=Un(e),a=n[o];if(!a)return e;const i=[...n],l={...a},s=Bo("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(s):e.push(s),l.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(s):e.push(s),l.footer=e}else{const e=[...a.blocks];t<0?e.unshift(s):e.push(s),l.blocks=e}return i[o]=l,{...e,document:{...e.document,sections:i}}},n=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:lb(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:lb(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=Oo(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=Oo(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=ot(i,n<0?oe(i):0);return e.applyTransactionalState(()=>Kh(r,l),{mergeKey:Ra}),e.focusInput(),!0}const l=r[i],s=n<0?oe(l):0;return e.applyTransactionalState(e=>Kh(e,ot(l,s)),{mergeKey:Ra}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(qo)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function cb(e={}){const t=e.dbName??"oasis-editor-db",n=e.storeName??"documents",o=e.key??"current-document";let r=null;async function a(){return r||(r=await function(e){return new Promise((t,n)=>{const o=indexedDB.open(e.name,e.version);o.onerror=()=>{n(/* @__PURE__ */new Error(`Failed to open IndexedDB: ${o.error?.message}`))},o.onsuccess=()=>{t(o.result)},o.onupgradeneeded=t=>{const n=o.result;e.onUpgrade(n,t.oldVersion,t.newVersion)}})}({name:t,version:1,onUpgrade:e=>{e.objectStoreNames.contains(n)||e.createObjectStore(n)}}),r)}return{async saveDocument(e){await function(e,t,n,o){return new Promise((r,a)=>{try{const i=e.transaction([t],"readwrite"),l=i.objectStore(t).put(o,n);l.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${l.error?.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{a(/* @__PURE__ */new Error(`Transaction failed putting item in ${t}: ${i.error?.message}`))}}catch(i){a(i)}})}(await a(),n,o,e)},loadDocument:async()=>function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readonly").objectStore(t).get(n);a.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to get item from ${t}: ${a.error?.message}`))},a.onsuccess=()=>{o(a.result??null)}}catch(a){r(a)}})}(await a(),n,o),async clearDocument(){await function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readwrite"),i=a.objectStore(t).delete(n);i.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to delete item from ${t}: ${i.error?.message}`))},a.oncomplete=()=>{o()},a.onabort=a.onerror=()=>{r(/* @__PURE__ */new Error(`Transaction failed deleting item from ${t}: ${a.error?.message}`))}}catch(a){r(a)}})}(await a(),n,o)},close(){r&&(r.close(),r=null)}}}function db(e){return function(e){const[t,n]=Tt([]),[o,r]=Tt([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},l=t=>{e.commitState(e.cloneState(t))},s=(t,n)=>{const o=e.stateSnapshot(),r=$r("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:lb(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const l=$r("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>wo(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=Oo(e),r=Oo(t),a=/* @__PURE__ */new Map;for(const l of o)a.set(l.id,l);const i=[];for(const l of r){const e=a.get(l.id);if(!e){i.push(l.id);continue}if(e===l)continue;if(e.runs.length!==l.runs.length){i.push(l.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=l.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=Ut(o),i=Ut(r);if(Boolean(a)!==Boolean(i)||(a?.width??-1)!==(i?.width??-1)||(a?.height??-1)!==(i?.height??-1)||(a?.floating?.wrap??"")!==(i?.floating?.wrap??"")||Boolean(a?.floating?.behindDoc)!==Boolean(i?.floating?.behindDoc)||(a?.wrapPolygon?.length??-1)!==(i?.wrapPolygon?.length??-1)){t=!0;break}}t&&i.push(l.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(l),$r("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:s,applyHistoryState:l,resetTransactionGrouping:()=>{var e;e=a,a={...e,lastTransactionMeta:null}},updateHistoryState:e=>{a=e(a),i()},getHistoryState:()=>a,clearHistory:()=>{a={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}(e)}function ub(e){g(()=>{var t;if(e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone,t=e.state,fa&&(ba={anchor:{paragraphId:t.selection.anchor.paragraphId,runId:t.selection.anchor.runId,offset:t.selection.anchor.offset},focus:{paragraphId:t.selection.focus.paragraphId,runId:t.selection.focus.runId,offset:t.selection.focus.offset},activeZone:t.activeZone??"main",activeSectionIndex:t.activeSectionIndex??0}),e.isImportInProgress())return;const n=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(n),e.emit("change",n),e.emit("documentChange",n.document),e.emit("selectionChange",n.selection)})}function pb(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:f,getImageOps:m}=e,h=Yh({state:()=>r,applyState:l,applyTransactionalState:(e,t)=>W(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await A()},resetEditorChromeState:()=>Y(),focusInput:d,requestLocalFontAccess:at,prepareDocumentFonts:async e=>{await ae(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),b=()=>"done"!==h.importProgress()?.phase&&"error"!==h.importProgress()?.phase&&null!==h.importProgress(),{measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:k,caretBox:R,preferredColumnX:B,setPreferredColumnX:M,clearPreferredColumn:F,stabilizeLayoutAfterImport:A,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyInvalidation:E,onCleanupHook:L}=ib({state:r,surfaceRef:u,viewportRef:p,isImporting:b,zoomFactor:f}),N=cb({key:t().persistenceKey}),{status:$}=function(e,t,n){const[o,r]=Tt("Initial"),[a,i]=Tt(!1),l=()=>n.enabled??!1,s=n.persistence,c=oo(async e=>{if(l()&&a()){r("Saving...");try{const t=JSON.parse(JSON.stringify(So(e)));await s.saveDocument(t),r("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),r("Error")}}},1e3);return g(_(()=>e.document,e=>{l()&&a()&&c(e)},{defer:!0})),lr(async()=>{if(!l())return i(!0),void r("Saved");try{const e=await s.loadDocument();e&&t(e)}catch(e){n.logger?.error("persistence:load failed",e)}finally{i(!0),r("Saved")}}),{status:o}}(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=Ln(e);a(t),Y()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??N,logger:n}),{undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:X}=db({stateSnapshot:i,commitState:a,cloneState:s,applyLayoutInvalidation:E}),G=sb({state:()=>r,stateSnapshot:i,applyHistoryState:U,applyTransactionalState:W,focusInput:d,clearPreferredColumn:F,imageOps:m,updateHistoryState:V,getHistoryState:K}),Y=()=>{F(),O({}),D({}),jo(),w.clear(),X()};return ub({state:r,isImportInProgress:b,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:h,isImportInProgress:b,measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:k,caretBox:R,preferredColumnX:B,setPreferredColumnX:M,clearPreferredColumn:F,stabilizeLayoutAfterImport:A,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyLayoutInvalidation:E,onCleanupHook:L,fallbackPersistence:N,persistenceStatus:$,undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:X,historyActions:G,resetEditorChromeState:Y}}(e)}function gb(e){return Rh(e,e=>"textBox"===e.kind)}function fb(e,t){const n=gb(e);if(!n||!Qt(n.run))return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:a,run:i}=n,l=Oo(e).map((e,t)=>t!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id===i.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:o(e))});return la(e,l,xe(l,hr(e)))}function mb(e,t){const n=gb(e);if(!n||!Qt(n.run))return e;const{paragraphIndex:r,run:a}=n,i=Oo(e).map((e,n)=>n!==r?Kt(e):{...Kt(e),runs:e.runs.map(e=>{if(e.id!==a.id||"textBox"!==e.kind)return o(e);const n=t(e.textBox.floating),r={...e.textBox};return n?r.floating=n:delete r.floating,{...e,textBox:r}})});return la(e,i,xe(i,hr(e)))}function hb(e,t,n,r={}){const a=gb(e),i=a&&Qt(a.run);if(!a||!i)return e;const l=r.handleDirection??"se",s=l.includes("n")||l.includes("s"),c=l.includes("w"),d=l.includes("n"),u=Math.max(24,Math.round(t)),p=Math.max(24,Math.round(n)),{paragraphIndex:g,run:f}=a,m=u-i.width,h=p-i.height,b=Oo(e).map((e,t)=>t!==g?Kt(e):{...Kt(e),runs:e.runs.map(e=>{if(e.id!==f.id||"textBox"!==e.kind)return o(e);const t=e.textBox,n={...t,width:u,height:p};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*Tr}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*Tr}})}return a}(t.floating,m,h,c,d)),{...e,textBox:n}})});return la(e,b,xe(b,hr(e)))}var bb=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),yb=e=>e.rows.reduce((e,t)=>Math.max(e,bb(t)),0),vb=(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 xb(e){if(!e)return null;for(const t of e.blocks){const e=C(t)[0];if(e)return e}return null}var wb=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=xb(e);if(t)return t}return null};function Sb(e,t){return e.some(e=>C(e).some(e=>e.id===t))}var Ib=(e,t,n)=>{const o=yn(e,t);if(!o)return null;const r=dt(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!Sb(o,n))continue;const e=M(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=yn(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=He(e)[n.sectionIndex];return o?"main"===n.zone?[o.blocks]:"header"===n.zone?[o.header,o.firstPageHeader,o.evenPageHeader].filter(e=>Boolean(e)):[o.footer,o.firstPageFooter,o.evenPageFooter].filter(e=>Boolean(e)):[]}(e,t),r.tablePath,t);if(!a)return null;const i=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),l=i.findIndex(e=>function(e,t){return e.blocks.some(e=>C(e).some(e=>e.id===t))}(e,t));if(-1===l)return null;const s=xb(i[l+n]);return s?ot(s,0):null};function Cb(e,t){return Boolean(e?.some(e=>C(e).some(e=>e.id===t)))}function Tb(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])=>Cb(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>Cb(e,o))?.[0]??"footer":"blocks"}function Pb(e){const t=yn(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function kb(e,t){if("footnote"===t){const t=Pb(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=wo(e.document),o=Fn(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=Tb(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var Rb=(e,t,n="main")=>{if("footnote"===n){const n=Pb(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=Fn(e),r=wo(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const l=Tb(e,i,n),s=[...r];return s[a]="blocks"===l?{...i,blocks:t}:{...i,[l]:t},{...e,document:{...e.document,sections:s}}};function Bb(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Mb(e,t){const n=M(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:Bb(t),targetBlocks:e}:null}function Fb(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]=fo(a),Mb(i,n)}var Ab=(e,t,n)=>{const o=dt(e.document,e.selection.focus.paragraphId,Fn(e));if(!o||e.selection.anchor.paragraphId!==e.selection.focus.paragraphId)return n(e);const r=function(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];return a&&"table"===a.type?Mb(function(e,t){const n=[...e];let o=n;for(let r=0;r<t.length;r+=1){const e=t[r];if(!e)break;const n=o[e.tableBlockIndex];if(!n||"table"!==n.type)break;const a={...n,rows:[...n.rows]};o[e.tableBlockIndex]=a;const i=a.rows[e.rowIndex];if(!i)break;const l={...i,cells:[...i.cells]};a.rows[e.rowIndex]=l;const s=l.cells[e.cellIndex];if(!s)break;const c={...s,blocks:[...s.blocks]};l.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,o);if(!r)return n(e);const a=n({...e,document:Tn(r.targetCell.blocks.map(e=>"paragraph"===e.type?Kt(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),i=wo(a.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...i),{...Rb(e,r.targetBlocks,o.zone),selection:a.selection}};function Ob(e,t){const n=dt(e.document,e.selection.focus.paragraphId,Fn(e));return n?Fb(e,t,n):null}function Db(e,t,n,o){const r=Rb(e,t,n);return o?{...r,selection:{anchor:ot(o,0),focus:ot(o,0)}}:r}function Eb(e,t,n,o){const r=t.getTargetBlocks(e,n),a=M(r,o);return a?.[a.length-1]?.table??null}function Lb(e,t){const n=dt(e.document,e.selection.focus.paragraphId,Fn(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Eb(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function Nb(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Lb(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=Eb(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=Lb(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.rowSpan??1)>1&&"restart"===o?.vMerge)},i=e=>n(e)||a(e),l=t=>null!==Lb(t,e),s=t=>{const n=Lb(t,e);return Boolean(n&&yb(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function $b(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function zb(e){return e.blocks.flatMap(C)}function Hb(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Wb(e,t){return function(e,t){const n=e.selection,o=Fn(e),r=dt(e.document,n.anchor.paragraphId,o),a=dt(e.document,n.focus.paragraphId,o);if(!r||!a||r.zone!==a.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(r.tablePath,a.tablePath))return null;const i=t.getTargetBlocks(e,r.zone),l=M(i,r.tablePath),s=M(i,a.tablePath),c=l?.[l.length-1],d=s?.[s.length-1];if(!c||!d||c.table!==d.table)return null;const u=Hb(r),p=Hb(a),g=c.table,f=Vt(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 Ub(e){return function(e){const t=t=>{const n=t.selection,o=Wb(t,e);if(!o||o.anchorLocation.rowIndex===o.focusLocation.rowIndex&&o.anchorLocation.cellIndex===o.focusLocation.cellIndex)return e.logger?.debug(`resolveTableCellRangeSelection: no expansion (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId})`),null;const r=Math.min(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),a=Math.max(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),i=Math.min(o.anchorLocation.cellIndex,o.focusLocation.cellIndex),l=Math.max(o.anchorLocation.cellIndex,o.focusLocation.cellIndex);e.logger?.info(`resolveTableCellRangeSelection: expanding r${o.anchorLocation.rowIndex}:c${o.anchorLocation.cellIndex}->r${o.focusLocation.rowIndex}:c${o.focusLocation.cellIndex} (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId}) range=[rows ${r}..${a}, cells ${i}..${l}]`);const s=$b(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=$b(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[s.rowIndex]?.cells[s.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?zb(d)[0]:void 0,g=u?zb(u):[],f=g[g.length-1];return p&&f?{anchor:ot(p,0),focus:ot(f,we(f).length)}:null},n=t=>{const n=Wb(t,e);if(!n)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex+n.anchorCell.rowSpan-1,n.focusCell.visualRowIndex+n.focusCell.rowSpan-1),a=Math.min(n.anchorCell.visualColumnIndex,n.focusCell.visualColumnIndex),i=Math.max(n.anchorCell.visualColumnIndex+n.anchorCell.colSpan-1,n.focusCell.visualColumnIndex+n.focusCell.colSpan-1),l=n.tableLayout.filter(e=>e.visualRowIndex<=r&&e.visualRowIndex+e.rowSpan-1>=o&&e.visualColumnIndex<=i&&e.visualColumnIndex+e.colSpan-1>=a);return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),cells:l,zone:n.anchorLocation.zone}},o=t=>{const n=Wb(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=$b(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=Wb(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 jb(e){if(e)for(const t of e.blocks){const e=C(t)[0];if(e)return e}}function Vb(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Fb(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Kb(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=>fo(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Vb(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=a.rows[o.rowIndex];if(!l)return n;const s=l.cells.slice(o.startCellIndex,o.endCellIndex+1);if(s.length<2)return n;const c=n.trackChangesEnabled?ul():void 0,d={...s[0],colSpan:s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:s.flatMap(e=>e.blocks.map(e=>fo(e))),...c?{style:{...s[0].style??{},revision:{...c,type:"merge",previous:{colSpan:s[0].colSpan,rowSpan:s[0].rowSpan,vMerge:s[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"horizontal",currentCellCount:1,previousCells:s.map(t)}}:{}};l.cells.splice(o.startCellIndex,s.length,d);const u=jb(d);return u?Db(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Vb(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=[];for(let e=o.startRowIndex;e<=o.endRowIndex;e+=1){const t=a.rows[e],r=t?.cells[o.cellIndex];if(!t||!r||"continue"===r.vMerge||1!==r.blocks.length||"paragraph"!==r.blocks[0]?.type)return n;l.push(r)}if(l.length<2)return n;const s=Math.max(1,l[0].colSpan??1);if(!l.every(e=>Math.max(1,e.colSpan??1)===s))return n;const c=n.trackChangesEnabled?ul():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>fo(e))),...c?{style:{...l[0].style??{},revision:{...c,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"vertical",currentCellCount:1,previousCells:l.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=Lo([Bo("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=jb(d);return u?Db(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Ob(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex]?.cells[a.cellIndex],s=Math.max(1,l?.rowSpan??1);if(!l||s<=1||"restart"!==l.vMerge)return n;const c=t(l),d=n.trackChangesEnabled?ul():void 0,u=Math.max(1,l.colSpan??1);l.rowSpan=void 0,l.vMerge=void 0,d&&(l.style={...l.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},l.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:s-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):Lo([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=Lo([Bo("")],u);t.cells[a.cellIndex]=n}const p=jb(l);return p?Db(n,i,a.zone,p):n},i=n=>{const o=Ob(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex],s=l?.cells[a.cellIndex],c=Math.max(1,s?.colSpan??1);if(!l||!s||c<=1)return n;const d=t(s),u=n.trackChangesEnabled?ul():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>fo(e)),...u?{style:{...s.style??{},revision:{...u,type:"merge",previous:{colSpan:d.colSpan,rowSpan:d.rowSpan,vMerge:d.vMerge}}},mergeRevisionState:{revisionId:u.id,orientation:"horizontal",currentCellCount:c,previousCells:[d]}}:{}},...Array.from({length:c-1},()=>Lo([Bo("")]))];l.cells.splice(a.cellIndex,1,...p);const g=jb(p[0]);return g?Db(n,i,a.zone,g):n},l=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:l}}(e)}function _b(e,t){e.style={...e.style??{},revision:{...ul(),type:t}}}function Xb(e){if(!e)return null;for(const t of e.blocks){const e=C(t)[0];if(e)return e}return null}function Gb(e,t,n){const o=Xb(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=Xb(r);if(e)return e}return wb(e)}function Yb(e){return function(e){const t=(t,n)=>{const o=Ob(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex];if(!l)return t;const s=Math.max(0,Math.min(r.rows.length,a.rowIndex+(n>0?1:0)));let c;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge))){const e=Vt(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),l=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=ao(l.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<s&&e.visualRowIndex+e.rowSpan>s);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=Lo([Bo("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return Lo([Bo("")],t.colSpan)})),t.trackChangesEnabled&&_b(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=Gb(r,vb(c,d),c);return Db(t,i,a.zone,u)}c=ao(l.cells.map(e=>Lo([Bo("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&_b(c,"insert"),r.rows.splice(s,0,c);const d=Gb(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return Db(t,i,a.zone,d)},n=t=>{const n=Ob(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 _b(i,"delete"),Db(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const l=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),s=l?Vt(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=Vt(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=Gb(o,c?vb(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,bb(c)-1))):null);return Db(t,a,r.zone,d)},o=(t,n)=>{const o=Ob(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=Vt(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=Lo([Bo("")]);t.trackChangesEnabled&&_b(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:{...ul(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=Lo([Bo("")]);t.trackChangesEnabled&&_b(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=Gb(r,l?vb(l,o):null);return Db(t,i,a.zone,s)}const l=Math.max(0,Math.min(r.rows[0]?.cells.length??0,a.cellIndex+(n>0?1:0)));for(const e of r.rows){const n=Lo([Bo("")]);t.trackChangesEnabled&&_b(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=Gb(r,s);return Db(t,i,a.zone,c)},r=t=>{const n=Ob(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(yb(o)<=1)return t;if(t.trackChangesEnabled){const e=Vt(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=vb(t,e);n&&_b(n,"delete")}return Db(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Vt(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=Gb(o,n&&vb(n,Math.min(e,Math.max(0,bb(n)-1))));return Db(t,a,r.zone,i)}if(o.rows[0]?.cells.length<=1)return t;for(const e of o.rows)e.cells.splice(r.cellIndex,1);const i=o.rows[r.rowIndex],l=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],s=Gb(o,l);return Db(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function qb(e){return function(e){const t=t=>{const n=e.resolveTableCellRangeSelection(t);return n?e.applySelectionToStatePreservingStructure(t,n):t},n=(n,o)=>{e.applyTransactionalState(r=>{const a=e.resolveSelectedTableCells(r);if(!a||a.cells.length<=1){const a=t(r);return a!==r&&e.logger?.info(`${o}: expanded selection to ${a.selection.anchor.paragraphId}[${a.selection.anchor.offset}]..${a.selection.focus.paragraphId}[${a.selection.focus.offset}]`),n(a)}const{blockIndex:i,tablePath:l,cells:s,zone:d}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${l.length} (${s.length} cells) in zone ${d}`);const u=[],p=[];for(const e of s){const t=e.cell.blocks.flatMap(C);u.push(...t),p.push(t.length)}if(0===u.length)return r;const g=n({...r,document:Tn(u,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:ot(u[0],0),focus:ot(u[u.length-1],we(u[u.length-1]).length)}}),f=Oo(g),m=l[l.length-1];if(!m)return r;const h=Fb(r,e.getTargetBlocks,{blockIndex:i,rowIndex:m.rowIndex,cellIndex:m.cellIndex,paragraphIndex:0,tablePath:l,zone:d});if(!h)return r;let b=0;for(let e=0;e<s.length;e+=1){const t=s[e],n=p[e]??0,o=f.slice(b,b+n);b+=n;const r=h.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=c(r.blocks,o))}return Rb(r,h.targetBlocks,d)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function Zb(e){return function(e){const t=kb,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Ub({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=Nb({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Kb({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I}=Yb({getTargetBlocks:t}),T=(e,n)=>Ab(e,t,n),{withExpandedTableCellSelection:P,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:R}=qb({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?ul():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...Lo([Bo("")]),style:{width:o}});const t=ao(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...tr(a),style:{width:"100%"}},l=Ho(e,e.selection.focus),s=He(e.document),c=Fn(e),d=Un(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&C(e).some(e=>e.id===l.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=s[c];if(!p)return e;const g={...p};let f=!1;if("header"===d){const e=u(p.header??[]);g.header=e.nextBlocks,f=e.found}else if("footer"===d){const e=u(p.footer??[]);g.footer=e.nextBlocks,f=e.found}else{const e=u(p.blocks);g.blocks=e.nextBlocks,f=e.found}if(!f)return e;const m=[...s];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:nt(ot(h,0))}}(e,t,n),{mergeKey:ka}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I,getRowVisualWidth:bb,getTableVisualWidth:yb,findCellAtVisualColumn:vb,findFirstNavigableParagraphInTable:wb,updateBlocksInCurrentSection:Rb,resolveAdjacentTableCellPosition:Ib,applyTableAwareParagraphEdit:T,withExpandedTableCellSelection:P,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:R,insertTableCommand:B}}(e)}function Jb(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function Qb(e,t){let n=null;const o=(e,t,n)=>{const o=Oo(e).find(e=>e.id===t);return o?{anchor:ot(o,n),focus:ot(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=Jb(),i=i=>{if(!a.owns(i))return;const l=n;if(!l)return;const s=t.zoomFactor?.()??1,c=(i.clientX-l.startClientX)/s,d=(i.clientY-l.startClientY)/s,u=e.getMaxWidth(t.state,l.paragraphId),{width:p,height:g}=st(l,c,d,i.shiftKey,u),f=o(t.state,l.paragraphId,l.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,l.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,l)},l=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:lb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),s(),t.focusInput()},s=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)};return{start:(s,c,d,u,p)=>{const g=o(p,s,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:s,paragraphOffset:c,handleDirection:d,startClientX:u.clientX,startClientY:u.clientY,startWidth:f.width,startHeight:f.height,aspectRatio:f.width/f.height,initialState:t.cloneState(p)},a.claim(u),window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l))},stop:s}}function ey(e,t){let n=null;const o=Jb(),r=r=>{if(!o.owns(r))return;const a=n;if(!a)return;let i=((180*Math.atan2(r.clientY-a.centerY,r.clientX-a.centerX)/Math.PI+90)%360+360)%360;r.shiftKey&&(i=15*Math.round(i/15)%360);const l=((e,t,n)=>{const o=Oo(e).find(e=>e.id===t);return o?{anchor:ot(o,n),focus:ot(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);l?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,l),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:lb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),i(),t.focusInput()},i=()=>{n=null,o.release(),window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)};return{start:(e,i,l,s)=>{const c=l.currentTarget.closest(".oasis-editor-selection-overlay");if(!c)return;const d=c.getBoundingClientRect();n={paragraphId:e,paragraphOffset:i,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:t.cloneState(s)},o.claim(l),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function ty(e,t){return Math.max(1e-4,1-e-t)}function ny(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 oy(e){let t=null;const n=(e,t,n)=>{const o=Oo(e).find(e=>e.id===t);return o?{anchor:ot(o,n),focus:ot(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=Jb(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const l=e.zoomFactor?.()??1,s=(a.clientX-i.startClientX)/l,c=(a.clientY-i.startClientY)/l,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=ty(a,l)/o,d=ty(i,s)/r,u=1-a-l,p=1-i-s,g=Math.max(0,Math.min(1-u,a-t*c)),f=Math.max(0,Math.min(1-p,i-n*d));return{crop:{left:g,right:Math.max(0,1-u-g),top:f,bottom:Math.max(0,1-p-f)},width:Math.round(o),height:Math.round(r)}}(i,s,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=ty(a,l)/o,d=ty(i,s)/r,u=se(e.handleDirection,"x"),p=se(e.handleDirection,"y");let g=a,f=l,m=o;if(0!==u)if(u<0){m=Pe(o-t,24,o+a/c);const e=ny(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=Pe(o+t,24,o+l/c);const e=ny(a,l,a,l-(m-o)*c);g=e.near,f=e.far}let h=i,b=s,y=r;if(0!==p)if(p<0){y=Pe(r-n,24,r+i/d);const e=ny(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=Pe(r+n,24,r+s/d);const e=ny(i,s,i,s-(y-r)*d);h=e.near,b=e.far}return{crop:{left:g,top:h,right:f,bottom:b},width:Math.round(m),height:Math.round(y)}}(i,s,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(Lh(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:lb(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),l(),e.focusInput()},l=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},s=(l,s,c,d,u,p)=>{const g=n(u,l,s);if(!g)return;const f=Oh(o(u,g)),m=f&&Ut(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:l,paragraphOffset:s,handleDirection:c,startClientX:d.clientX,startClientY:d.clientY,startWidth:m.width,startHeight:m.height,startCrop:h,initialState:e.cloneState(u),mode:p},r.claim(d),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)};return{start:(e,t,n,o,r)=>s(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>s(e,t,"se",n,o,"move"),stop:l}}function ry(e){return function(e){const[t,n]=Tt(!1),[o,r]=Tt(!1),[i,l]=Tt(null);g(()=>{o()&&!y(e.state)&&r(!1)});const s=()=>{y(e.state)?r(e=>!e):r(!1)},[c,d]=Tt({x:0,y:0}),[u,p]=Tt(null);let f=null,m=null,h=null;const y=e=>{const t=hr(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=Oo(e)[t.startIndex];if(!n)return null;let o=0;for(const r of n.runs){const i=o;if(o+=r.text.length,"image"===r.kind&&1===r.text.length&&i===t.startParagraphOffset)return{paragraph:n,run:r,startOffset:i,width:r.image.width,height:r.image.height,src:a(e.document,r.image.src)}}return null},v=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),x=()=>{h||(h=document.createElement("style"),h.setAttribute("data-oasis-image-drag-cursor",""),h.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(h))},w=()=>{h&&(h.remove(),h=null),document.body.style.cursor=""},S=Jb(),I=()=>{w(),m=null,f=null,n(!1),l(null),p(null),S.release(),window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B)},C=()=>{I()},T=Qb({label:"image",getSelected:e=>y(e),applyResize:(e,t,n)=>Dh(e,t,n),getMaxWidth:(t,n)=>_h(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}),P=ey({label:"image",applyRotate:(e,t)=>function(e,t){const n=Hh(t);return jh(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}),k=oy({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),R=t=>{if(!S.owns(t))return;let o=f;if(!o){const r=m;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},f=o,m=null,n(!0),x(),e.logger.info(`image drag:start ${o.paragraphId}@${o.paragraphOffset} client=(${t.clientX},${t.clientY})`)}d({x:t.clientX,y:t.clientY}),l({...o}),p(v(t.clientX,t.clientY))},B=t=>{if(!S.owns(t))return;const n=f;if(n||m){if(n){const o=v(t.clientX,t.clientY);o?(e.logger.info(`image drag:done ${n.paragraphId} -> ${o.paragraphId}:${o.runId}[${o.offset}]`),e.applyTransactionalState(e=>Kh(e,o),{mergeKey:Ra})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}I(),e.focusInput()}else e.focusInput()},M=(t,o,r,a)=>{const i=r.currentTarget,s=a?{left:a.left,top:a.top,width:a.width,height:a.height}:i?.getBoundingClientRect();if(!s)return;const c=y(e.state);m={paragraphId:t,paragraphOffset:o,startClientX:r.clientX,startClientY:r.clientY,src:c?.src??"",width:c?.width??s.width,height:c?.height??s.height,offsetX:r.clientX-s.left,offsetY:r.clientY-s.top},f=null,d({x:r.clientX,y:r.clientY}),n(!1),l(null),p(null),S.claim(r),window.addEventListener("pointermove",R),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",B)},F=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=b(e.state.document).find(e=>e.id===t);r&&e.applyState(Cs(e.state,{anchor:ot(r,n),focus:ot(r,n+1)})),M(t,n,o),e.focusInputAfterPointerSelection()},A=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),T.start(t,n,o,r,e.state)},O=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),P.start(t,n,o,e.state)},D=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),k.start(t,n,o,r,e.state)},E=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),k.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:s,draggedImageInfo:i,mousePos:c,dropTargetPos:u,getSelectedImageInfo:y,startImageDrag:M,stopImageDrag:C,stopImageResize:T.stop,stopImageRotate:P.stop,stopImageCrop:k.stop,handleImagePointerDown:F,handleImageResizeHandlePointerDown:A,handleImageRotateHandlePointerDown:O,handleImageCropHandlePointerDown:D,handleImageCropBodyPointerDown:E}}(e)}function ay(e){return function(e){const t=e=>{const t=gb(e),n=t&&Qt(t.run);return n?{width:n.width,height:et(n,e,0)}:null},n=Qb({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>hb(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=_h(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=ey({label:"text box",applyRotate:(e,t)=>fb(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 iy(e){return function(e){const[t,n]=Tt(void 0),o=()=>{n(void 0)};g(()=>{_o(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=$(e.state()),o=t();return _o(e.state().selection)&&o?{...n,bold:o.bold??n.bold,italic:o.italic??n.italic,underline:o.underline??n.underline,underlineStyle:void 0!==o.underlineStyle?String(o.underlineStyle??""):n.underlineStyle,strike:o.strike??n.strike,superscript:o.superscript??n.superscript,subscript:o.subscript??n.subscript,fontFamily:o.fontFamily??n.fontFamily,fontSize:void 0!==o.fontSize&&null!==o.fontSize?String(o.fontSize):n.fontSize,color:o.color??n.color,highlight:o.highlight??n.highlight,textShading:o.shading??n.textShading,link:o.link??n.link,characterStyleId:void 0!==o.styleId&&null!==o.styleId?String(o.styleId):n.characterStyleId}:n},l=(t,n)=>{if(_o(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),r(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},s=t=>{if(_o(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(_o(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),n(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:o,toolbarStyleState:i,applyToolbarValueStyleCommand:l,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:s}}(e)}function ly(e,t,n={}){if(!t)return[];const o=[],r=b(e),{matchCase:a=!1,wholeWord:i=!1}=n,l=a?"g":"gi";let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const c=new RegExp(s,l);return r.forEach((e,t)=>{const n=we(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:ot(e,n),focus:ot(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function sy(e,t,n,o={}){const r=ly(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=Cs(a,{anchor:e.anchor,focus:e.focus}),a=Zi(a,n)}return a}function cy(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*H+(r<e?e-r:r>i?r-i:0)}function dy(e,t,n){if(0===e.slots.length)return{offset:e.startOffset,score:Number.POSITIVE_INFINITY};let o=e.slots[0].offset,r=Number.POSITIVE_INFINITY,a=e.slots[0].left,i=e.slots[0].top,l=e.slots[0].height;for(const s of e.slots){const e=n<s.top?s.top-n:n>s.top+s.height?n-(s.top+s.height):0,c=Math.abs(t-s.left),d=e*H+c;d<r&&(r=d,o=s.offset,a=s.left,i=s.top,l=s.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:l}}function uy(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=dy(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function py(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function gy(e){const{snapshot:t,state:n}=e,o=e.pierce??!1,r=e.zoomFactor&&e.zoomFactor>0?e.zoomFactor:1,a=t.surfaceRect,i=a.left+(e.clientX-a.left)/r,l=a.top+(e.clientY-a.top)/r,s=function(e,t,n){if(0===e.length)return null;let o=e[0],r=Number.POSITIVE_INFINITY;for(const a of e){const e=cy(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,l);if(!s)return null;const c=function(e,t){const n=t-e.top;return n<e.bodyTop?"header":void 0!==e.footnoteSeparatorTop&&n>=e.footnoteSeparatorTop&&n<(e.footerTop??e.height)?"footnote":n>=e.bodyBottom?"footer":"main"}(s,l),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const l=e.floatingTextBoxes[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&o>=l.left&&o<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(t,s.index,c,i,l,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&d.startOffset>=e.startOffset&&d.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(d.startOffset,n.endOffset)),t=ot(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:d.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:d.left,top:d.top,height:d.height},textBox:{paragraphId:d.paragraphId,paragraphOffset:e,startOffset:d.startOffset,endOffset:d.endOffset,left:d.left,top:d.top,width:d.width,height:d.height}}}}const u=function(e,t,n,o,r,a){for(let i=e.floatingImages.length-1;i>=0;i-=1){const l=e.floatingImages[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&py(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&py(o,r,i))return i;return null}(t,s.index,c,i,l,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&u.startOffset>=e.startOffset&&u.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(u.startOffset,n.endOffset)),t=ot(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:u.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},image:{paragraphId:u.paragraphId,paragraphOffset:e,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const p=function(e,t,n){if(0===e.length)return null;let o=null;for(const i of e)for(const e of i.lines){const r=e.top-2,a=e.top+e.height+2;if(n<r||n>a)continue;const{offset:l,score:s,slotLeft:c,slotTop:d,slotHeight:u}=dy(e,t,n);(!o||s<o.score)&&(o={paragraph:i,offset:l,score:s,caretViewport:void 0!==c&&void 0!==d&&void 0!==u?{left:c,top:d,height:u}:void 0})}if(o)return{paragraph:o.paragraph,offset:o.offset,caretViewport:o.caretViewport};let r=null,a=Number.POSITIVE_INFINITY;for(const i of e){const e=cy(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:uy(r,t,n),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(t.paragraphs.filter(e=>e.pageIndex===s.index&&e.zone===c),i,l);if(!p){const e=n.selection.focus.paragraphId,o=n.selection.focus.offset,r=function(e,t,n,o,r){return e.unsupportedRegions.find(e=>e.pageIndex===t&&e.zone===n&&o>=e.left&&o<=e.left+e.width&&r>=e.top&&r<=e.top+e.height)?.reason??null}(t,s.index,c,i,l);return{zone:c,paragraphId:e,paragraphOffset:o,position:{...n.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:r??"zone-without-paragraph"}}const g=p.paragraph,f=Math.max(0,Math.min(p.offset,g.textLength)),m=ot(g.paragraph,f);return{zone:c,footnoteId:g.footnoteId,paragraphId:g.paragraphId,paragraphOffset:f,position:m,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:g.tableCell?.anchorPosition,caretViewport:p.caretViewport}}function fy(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),l=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){fa&&(ha=e?function(e){return{surfaceRect:{left:e.surfaceRect.left,top:e.surfaceRect.top,width:e.surfaceRect.width,height:e.surfaceRect.height},pages:(t=e.pages,t.map(e=>({index:e.index,left:e.left,top:e.top,width:e.width,height:e.height,bodyTop:e.bodyTop,bodyBottom:e.bodyBottom}))),paragraphs:e.paragraphs.map(e=>{return{paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,textLength:e.textLength,left:e.left,top:e.top,width:e.width,height:e.height,lines:(t=e.lines,t.map(e=>{return{startOffset:e.startOffset,endOffset:e.endOffset,top:e.top,height:e.height,slots:(t=e.slots,t.map(e=>({offset:e.offset,left:e.left,top:e.top,height:e.height})))};var t})),tableCell:e.tableCell?{tableId:e.tableCell.tableId,rowIndex:e.tableCell.rowIndex,cellIndex:e.tableCell.cellIndex,left:e.tableCell.left,top:e.tableCell.top,width:e.tableCell.width,height:e.tableCell.height}:void 0,verticalMode:e.verticalMode};var t}),inlineImages:e.inlineImages.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height})),inlineTextBoxes:e.inlineTextBoxes.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height,rotation:e.rotation})),unsupportedRegions:e.unsupportedRegions.map(e=>({...e}))};var t}(e):null)}(l),!l)return xa(null),null;const s=gy({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return xa(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var my=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],hy=/* @__PURE__ */new Map;function by(){return my.map(e=>({...e}))}var yy=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function vy(e,t,n){const[o,r]=e,[a,i]=t,[l,s]=n,c=l-a,d=s-i,u=c*c+d*d;return 0===u?Math.hypot(o-a,r-i):Math.abs(c*(i-r)-d*(a-o))/Math.sqrt(u)}function xy(e,t){if(e.length<3)return e.slice();let n=0,o=0;const r=e[0],a=e[e.length-1];for(let s=1;s<e.length-1;s+=1){const t=vy(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=xy(e.slice(0,o+1),t),l=xy(e.slice(o),t);return[...i.slice(0,-1),...l]}function wy(e,t,n){let o=0;for(let s=0;s<e.length;s+=1)1===e[s]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return by();const r=function(e,t,n){const o=(o,r)=>o>=0&&o<t&&r>=0&&r<n&&1===e[r*t+o];let r=-1,a=-1;for(let u=0;u<n&&a<0;u+=1)for(let n=0;n<t;n+=1)if(1===e[u*t+n]){r=n,a=u;break}if(r<0)return[];const i=[];let l=r,s=a,c=6;const d=t*n*4;for(let u=0;u<d;u+=1){let e=!1;for(let t=1;t<=8;t+=1){const n=(c+t)%8,[r,a]=yy[n],d=l+r,u=s+a;if(o(d,u)){i.push([l,s]),c=(n+4)%8,l=d,s=u,e=!0;break}}if(!e){i.push([l,s]);break}if(l===r&&s===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return by();const a=.012*Math.max(t,n);let i=xy(r,a),l=a;for(;i.length>40;)l*=1.6,i=xy(r,l);return i.length<3?by():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function Sy(e){const t=e.src,n=hy.get(t);if(n)return n.map(e=>({...e}));const o=function(e){const t=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(!t||!n)return null;const o=Math.min(1,256/Math.max(t,n)),r=Math.max(1,Math.round(t*o)),a=Math.max(1,Math.round(n*o)),i=document.createElement("canvas");i.width=r,i.height=a;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(e,0,0,r,a);try{s=l.getImageData(0,0,r,a).data}catch{return null}const c=new Uint8Array(r*a);let d=0;for(let u=0;u<c.length;u+=1)s[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return by();const r=wy(o.mask,o.width,o.height);return hy.set(t,r),r.map(e=>({...e}))}function Iy(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:r,focusInput:i}=e,l=()=>Oh(t())?"image":gb(t())?"textBox":null,s=(e,t)=>{const o=l();o&&(n(),r(e=>t(e,o),{mergeKey:e}),i())},c=(e,n)=>{const i=a(t().document,n),l=t=>{const n=Sy(t);r(t=>function(e,t,n){const r=Oo(e);let a=!1;const i=r.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...Kt(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return o(e);a=!0;const r={...e.image};return n&&n.length>0?r.wrapPolygon=n:delete r.wrapPolygon,{...e,image:r}})}:Kt(e));return a?la(e,i,xe(i,hr(e))):e}(t,e,n),{mergeKey:za})},s=en(i,()=>{s.naturalWidth>0&&l(s)});s.complete&&s.naturalWidth>0&&l(s)};return{target:l,preset:()=>{const e=l();return"image"===e?function(e){const t=Oh(e),n=t&&Ut(t.run);return n?Mh(n.floating):null}(t()):"textBox"===e?function(e){const t=gb(e),n=t&&Qt(t.run);return n?Mh(n.floating):null}(t()):null},fixedPosition:()=>{const e=l();return"image"===e?function(e){const t=Oh(e),n=t&&Ut(t.run);return Ah(n?.floating)}(t()):"textBox"===e&&function(e){const t=gb(e),n=t&&Qt(t.run);return Ah(n?.floating)}(t())},setPreset:e=>{if(s(ki,(t,n)=>"image"===n?function(e,t){return Vh(e,e=>Bh(e,t))}(t,e):function(e,t){return mb(e,e=>Bh(e,t))}(t,e)),"tight"===e||"through"===e){const e=Oh(t()),n=e&&Ut(e.run);n&&!n.wrapPolygon&&c(e.run.id,n.src)}},setFixedPosition:e=>s(Ri,(t,n)=>"image"===n?function(e,t){return Vh(e,e=>e?Fh(e,t):e)}(t,e):function(e,t){return mb(e,e=>e?Fh(e,t):e)}(t,e))}}function Cy(e){return function(e){const t=t=>{const n=Is(e.state());0!==n.length&&(t.preventDefault(),t.clipboardData?.setData("text/plain",n),t.clipboardData?.setData("text/html",bs(e.state())))},n=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Is(e.state());0!==n.length&&(t.preventDefault(),t.clipboardData?.setData("text/plain",n),t.clipboardData?.setData("text/html",bs(e.state())),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>el(e))),e.focusInput())},o=t=>{if(e.isReadOnly())return void t.preventDefault();if(e.forcePlainTextPaste()){e.setForcePlainTextPaste(!1);const n=t.clipboardData?.getData("text/plain")??"";return 0===n.length?void t.preventDefault():(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qi(e,n))),t.currentTarget.value="",void e.focusInput())}const n=Ph(t.clipboardData);if(n)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(n),t.currentTarget.value="",void e.focusInput();const o=Ds(t.clipboardData?.getData("text/html")??"");if(o.length>0)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ys(e,o))),t.currentTarget.value="",void e.focusInput();const r=t.clipboardData?.getData("text/plain")??"";0!==r.length&&(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Qi(e,r))),t.currentTarget.value="",e.focusInput())},r=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Ph(t.dataTransfer);if(!n)return;t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??e.state().selection.focus;e.insertImageFromFile(n,o),e.focusInput()};return{handleCopy:t,handleCut:n,handlePaste:o,handleDrop:r}}(e)}var Ty=/* @__PURE__ */new WeakMap;function Py(e,t){return function(e){return wo(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function ky(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=Ty.get(a);if(i)return i;const l=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(const d of a.paragraphs){const e=d.tableCell;if(!e)continue;const t=`${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,n=l.get(e.tableId)??/* @__PURE__ */new Map;let o=n.get(t);o||(o={tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,pageIndex:d.pageIndex,left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height,width:e.width,height:e.height,contentMinWidth:0,contentMinHeight:0},n.set(t,o),l.set(e.tableId,n));const r=d.lines.flatMap(e=>e.slots.map(e=>e.left)),a=d.lines.map(e=>e.top+e.height),i=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,u=d.lines.length>0?d.lines[0].top:d.top,p=a.length>0?Math.max(...a):d.top+d.height,g=`${e.tableId}:${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,f=s.get(g);f?(f.left=Math.min(f.left,i),f.top=Math.min(f.top,u),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):s.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of l.entries())for(const e of u.values()){const t=s.get(`${d}:${e.pageIndex}:${e.rowIndex}:${e.cellIndex}`);t&&(e.contentMinWidth=Math.max(0,t.right-t.left),e.contentMinHeight=Math.max(0,t.bottom-t.top))}const c=[];for(const[d,u]of l.entries()){const e=Array.from(u.values());if(0===e.length)continue;const t=Math.min(...e.map(e=>e.left)),n=Math.min(...e.map(e=>e.top)),o=Math.max(...e.map(e=>e.right)),r=Math.max(...e.map(e=>e.bottom));c.push({tableId:d,cells:e,bounds:{left:t,top:n,right:o,bottom:r,width:Math.max(1,o-t),height:Math.max(1,r-n)}})}return Ty.set(a,c),c}function Ry(e,t,n,o,r,a){const i=ky(t,n,o,r,a);if(0===i.length)return null;let l=null;for(const d of i)if(!(e.clientX<d.bounds.left-4||e.clientX>d.bounds.right+4||e.clientY<d.bounds.top-4||e.clientY>d.bounds.bottom+4))for(const t of d.cells){const n=e.clientY>=t.top-4&&e.clientY<=t.bottom+4,o=e.clientX>=t.left-4&&e.clientX<=t.right+4;if(n){const n=Math.abs(e.clientX-t.left);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"bottom",distance:o})}}if(!l)return null;const s=Py(n,l.geometry.tableId);if(!s)return null;const c=Vt(s).find(e=>e.rowIndex===l.cell.rowIndex&&e.cellIndex===l.cell.cellIndex);return c?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:c,tableGeometry:l.geometry}:null}var By=1/.75;function My(e){return.75*e}function Fy(e){return e*By}var Ay=zl;function Oy(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Fy(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Fy(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Fy(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Fy(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Fy(e.style.borderRight.width)):1)}function Dy(e,t,n){const o=Math.max(1,e.rows.length),r=n.bounds.height/o,a=Array(o).fill(r),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(let l=0;l<o;l+=1){const n=Ay(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Fy(n));continue}const o=t.find(e=>e.rowIndex===l&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[l]=Math.max(1,e.height))}}return a}function Ey(e,t,n){const o=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),r=o-1,a=Array(o).fill(n.bounds.width/o),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));if(e.gridCols&&e.gridCols.length>=o)for(let s=0;s<o;s+=1)a[s]=Math.max(1,Fy(e.gridCols[s]));else for(const s of t){if(1!==s.colSpan)continue;const e=i.get(`${s.rowIndex}:${s.cellIndex}`);e&&(a[s.visualColumnIndex]=Math.max(1,e.width))}const l={};for(let s=0;s<o;s+=1)l[s]=Math.max(10,My(a[s]));return{widthsPt:l,maxColumnIndex:r}}function Ly(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Fy(10),r=Math.max(Fy(10),t.minRowHeightPx??Fy(10)),a=Math.max(10,My(Math.max(r,o+n)));return function(e,t,n,o){return $l(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Ny(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 $y=null;function zy(e,t){$y=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 Hy(e){e&&$y!==e||($y=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Wy(e,t){zy(e,t)}function Uy(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function jy(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Vy(e){const[t,n]=Tt(null);let o=null,r=null,a=null,i=null;const l={},s=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Hy();const i=Ry(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?zy("left"===i.side||"right"===i.side,l):Hy()},c=Jb(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Uy(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:Ny(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(jy(o),o=null),null!==a&&(jy(a),a=null),n(null),Hy(l),c.release(),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)},g=n=>{if(!c.owns(n))return;const o=t();if(!o)return;const r=e.zoomFactor?.()??1,a=(("column"===o.type?n.clientX:n.clientY)-o.initialPos)/r;Math.abs(a)>=2&&e.applyTransactionalState(e=>"row"===o.type?Ly(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=My(n),r=t.maxColumnIndex??t.index,a={...t.columnWidthsPt??{}};for(let m=0;m<=r;m+=1)void 0===a[m]&&(a[m]=10);const i=t.minColumnWidthsPx??{},l=a[t.index]??10,s=Math.max(10,My(i[t.index]??Fy(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(s,l-o),i=l-r;n+i<0&&(i=-n,r=l-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Hl(e,t.tableId,a,c,d)}let c=Math.max(s,l+o);const d=t.index===r;if(d)a[t.index]=c;else{const e=t.index+1,n=a[e]??10,o=Math.max(10,My(i[e]??Fy(10)));let r=n-(c-l);r<o&&(r=o,c=l+(n-o),c=Math.max(s,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=Py(e,t.tableId),g=Ay(p?.style?.width),f=d?u:null!==g?g:void 0;return Hl(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=Uy(s))))},handlePointerDown:t=>{r=null,null!==o&&(jy(o),o=null),Hy();const a=e.surfaceRef();if(!a)return!1;const i=Ry(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=Vt(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}=Ey(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Fy(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const l of n){if(1!==l.colSpan)continue;if(!i.get(`${l.rowIndex}:${l.cellIndex}`))continue;const n=t.rows[l.rowIndex]?.cells[l.cellIndex];if(!n)continue;const o=l.visualColumnIndex,s=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,ft(n,e.document.styles)),1);a[o]=Math.max(s,c+Oy(n)+12,r)}return a}(s,i.tableNode,u,i.tableGeometry);return n({type:"column",tableId:i.tableId,index:r,initialPos:a,currentPos:a,columnWidthsPt:p,maxColumnIndex:f,minColumnWidthsPx:m,resizeFromLeftEdge:o,initialTableIndentLeftPt:Ay(i.tableNode.style?.indentLeft)??0,guideBounds:Ny(e.viewportRef)}),Wy(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=Dy(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 Fy(10);const a=Fy(10);let i=a;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===l);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===l);a&&(i=Math.max(i,a.contentMinHeight+4))}return Math.max(a,i)}(i.tableNode,u,i.tableGeometry,f);return n({type:"row",tableId:i.tableId,index:f,initialPos:m,currentPos:m,initialRowHeightPx:p[f],minRowHeightPx:h,guideBounds:Ny(e.viewportRef)}),Wy(!1,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var Ky=null;function _y(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=Fy(10),l=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,s=l>0?i/l:0;return{scaleX:Math.max(a,t),scaleY:Math.max(s,n)}}function Xy(e){const[t,n]=Tt(null);let o=null,r=null;const a={},i=Jb(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Uy(s)))},s=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(jy(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Ky===a&&(Ky=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}=_y(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const s of Object.keys(t.widthsPt)){const e=Number(s);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=Hl(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,My(e*o))}),$l(i,t.tableId,l)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=_y(e);return{left:e.bounds.left,top:e.bounds.top,width:e.bounds.width*n,height:e.bounds.height*o}},handlePointerDown:(t,o)=>{const r=e.surfaceRef();if(!r)return;const s=ky(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=Py(e.state(),t);if(!s||!c)return;const u=Vt(c),{widthsPt:p}=Ey(c,u,s),g=Dy(c,u,s),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:s.bounds.left,top:s.bounds.top,width:Math.max(1,s.bounds.width),height:Math.max(1,s.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),Ky=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var Gy=null;function Yy(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=Yy(n.blocks,t,!0,!1);if(e)return e}}return null}function qy(e,t){for(const n of He(e)){for(const e of[n.blocks,n.header,n.footer]){const n=Yy(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=Yy(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=Yy(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=Yy(n.blocks,t,!1,!1);if(e)return e}return null}function Zy(e){return function(e){const[t,n]=Tt(!1),[o,r]=Tt(null),[a,i]=Tt(null),[l,s]=Tt(0),[c,d]=Tt(0),[u,p]=Tt({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=Jb(),v=()=>{f=null,null!==g&&(jy(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),Gy===m&&(Gy=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=qy(e,n);return Boolean(o?.table&&C(o.table).some(e=>e.id===t))}(e.state().document,r.paragraphId,a)?b(null):b(r)},w=e=>{if(y.owns(e)){if(!t()){if(Math.abs(e.clientY-l())<=4)return;n(!0),Gy=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Uy(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=qy(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return El(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*Uo,y:(t.y??0)+(n.clientY-l())*Uo,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?ze(e,o,t):e})}v(),e.focusInput()};return{dragging:t,draggedTableInfo:o,mousePos:u,dropTargetPos:a,handlePointerDown:(e,t)=>{t.preventDefault(),t.stopPropagation();const o=t.currentTarget.getBoundingClientRect(),a=o;r({tableId:e,width:a.width,height:a.height,offsetX:t.clientX-o.left,offsetY:t.clientY-o.top}),s(t.clientY),d(t.clientX),p({x:t.clientX,y:t.clientY}),n(!1),i(null),y.claim(t),window.addEventListener("pointermove",w),window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)},stop:v}}(e)}var Jy=e=>"touch"===e.pointerType;function Qy(e,t){if(!e||0===e.length){const e=sn(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:C(n)[0]??null,blocks:e}}function ev(e,t,n){const o=b(e.document).filter(t=>{const o=yn(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:ot(t,0),end:a?ot(a,0):ot(t,we(t).length)}}function tv(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,l=0,s=0,c=null,u=0,p=0,g=0,f=null,m=null;const h=e=>"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16),b=e=>{"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)},y=(t,n,o,r)=>{const a=n!==(t.activeZone??"main"),i="footnote"===n&&r?yn(o.document,r.paragraphId)?.footnoteId:void 0,l="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!l)return void e.applyState(o);let s=o.document,c=t.activeSectionIndex??0;if(!s.sections||0===s.sections.length){const e=sn("header"),t=sn("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:me(s.pageSettings??d),header:[e],footer:[t]}]},c=0}const u=s.sections,p=u[c];let g=p.header,f=p.footer,m=null;if("header"===n){const e=Qy(g,"header");m=e.paragraph,g=e.blocks}else if("footer"===n){const e=Qy(f,"footer");m=e.paragraph,f=e.blocks}if(g!==p.header||f!==p.footer){const e=[...u];e[c]={...p,header:g,footer:f},s={...s,sections:e}}const h=r||(m?ot(m,0):o.selection.anchor);e.applyState({...o,document:s,selection:{anchor:h,focus:h},activeSectionIndex:c,activeZone:n,activeFootnoteId:"footnote"===n?i:void 0})},v=t=>{const n=e.state(),o=n.selection,r=Fn(n),a=Gr(n.document,o.anchor.paragraphId,r),i=Gr(n.document,o.focus.paragraphId,r),l=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";e.logger.debug(`${t} ${o.anchor.paragraphId}[${o.anchor.offset}]→${o.focus.paragraphId}[${o.focus.offset}] [${l}→${s}]`)},x=()=>{m?.longPressHandle&&clearTimeout(m.longPressHandle),m=null},w=()=>{t=null,o=null,f=null,x(),null!==n&&(b(n),n=null),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",k)},S=e=>{f=e,window.addEventListener("pointermove",T),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",k)},I=()=>{if(n=null,!t)return;const r=o;if(o=null,!r)return;const a=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(yn(i.document,t.paragraphId)?.sectionIndex!==yn(i.document,a.paragraphId)?.sectionIndex)return;const l=Cs(i,{anchor:t,focus:a.position});y(i,a.zone,l,a.position),v("selection:drag")},C=()=>{o&&(null!==n&&(b(n),n=null),I())},T=e=>{null!==f&&e.pointerId!==f||(!m||m.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=h(I))):Math.hypot(e.clientX-m.clientX,e.clientY-m.clientY)>20&&w())},P=t=>{if(null===f||t.pointerId===f){if(m&&!m.longPressFired){const n=m,o=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return x(),w(),void(o&&(E(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}C(),v("selection:end"),w(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},k=e=>{null!==f&&e.pointerId!==f||w()},R=(n,o,r)=>{if(r<2)return t=null,w(),void e.focusInputAfterPointerSelection();t=null,o.resolvedFromParagraph?y(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position):y(n,o.zone,n),w(),e.focusInputAfterPointerSelection()},B=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=ot(r,o.textBox.startOffset),i=ot(r,o.textBox.endOffset);y(n,o.zone,Cs(n,{anchor:a,focus:i}),a),w(),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=ot(a,o.image.startOffset),l=ot(a,o.image.endOffset);y(n,o.zone,Cs(n,{anchor:i,focus:l}),i),w(),Jy(r)||e.imageOps.startImageDrag(o.image.paragraphId,o.image.startOffset,r,{left:o.image.left,top:o.image.top,width:o.image.width,height:o.image.height}),e.focusInputAfterPointerSelection()},F=(n,o,r)=>{t=n.selection.anchor,y(n,o.zone,Cs(n,{anchor:n.selection.anchor,focus:o.position}),o.position),S(r),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=null;const a=ev(n,r,o.zone);y(n,o.zone,Cs(n,{anchor:a.start,focus:a.end}),a.start),w(),e.focusInputAfterPointerSelection()},O=(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=ot(r,o.paragraphOffset);return y(n,o.zone,Cs(n,{anchor:t,focus:t}),t),w(),void e.openEquationDialog(i.math,i.id)}const l=Me(we(r),o.paragraphOffset),s=ot(r,l.start),c=ot(r,l.end);y(n,o.zone,Cs(n,{anchor:s,focus:c}),s),w(),e.focusInputAfterPointerSelection()},D=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!Jy(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,w(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?B(n,o):o.image?M(n,o,a):a.shiftKey&&o.resolvedFromParagraph?F(n,o,a.pointerId):r>=3&&i?A(n,o,i):2===r&&i?O(n,o,i):o.resolvedFromParagraph?(t=o.position,y(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),Jy(a)||S(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():R(n,o,r)},E=(t,n,o)=>{D(e.state(),t,n,o),e.focusInputSync()},L=()=>{const n=m;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=Me(we(a),o.paragraphOffset),l=ot(a,i.start),s=ot(a,i.end);y(r,o.zone,Cs(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},N=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-l);r=n-a<=450&&o<=((e,t)=>Jy(e)?20:t)(t,6)&&t.button===s?r+1:1,a=n,i=t.clientX,l=t.clientY,s=t.button;const d=Math.max(t.detail,r),f=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,u=n,p=t.clientX,g=t.clientY,Jy(t))return x(),m={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:d,longPressHandle:setTimeout(L,500),longPressFired:!1},void S(t.pointerId);t.preventDefault(),D(f,h,d,t)},$=n=>{if(n.detail<3)return;n.preventDefault();const o=e.state(),r=Math.hypot(n.clientX-p,n.clientY-g),a=Date.now()-u<=600&&r<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(o.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const l=ev(o,i,a.zone);y(o,a.zone,Cs(o,{anchor:l.start,focus:l.end}),l.start),w(),e.focusInputAfterPointerSelection()},z=(e,t)=>{0===t.button&&(Jy(t)||t.preventDefault(),N(t))};return{handleSurfacePointerDown:N,handleSurfaceClick:$,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:z,stopDragging:w}}(e)}function nv(e){return function(e){const[t,n]=Tt(!1);let o,r=0,a="",i=null;const l=()=>{r=0,a="",o=void 0},s=(t,n)=>{if(!n&&t===a)return;if(0===r&&0===t.length)return void(n&&l());const s=r,c=Cr(o);e.clearPreferredColumn(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>{const n=function(e,t){if(t<=0)return e;const{paragraph:n,index:o,offset:r}=E(e);if(r<t)return e;const a=Oo(e),i=r-t,l=fe(n,[...U(n,0,i),...U(n,r,oe(n))],Et(n,i)),s=a.map((e,t)=>t===o?l:e);return la(e,s,nt(ot(l,i)))}(e,s);return t.length>0?Zi(n,t,c):n}),{mergeKey:Ta}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(cn("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(n.currentTarget.value)}`),n.currentTarget.value="",void l();const o=n.currentTarget.value;if(0===o.length)return;if(t())return e.logger.debug(`input:composing buffer=${JSON.stringify(o)}`),void s(o,!1);if(null!==i){const t=o===i;if(i=null,t)return e.logger.debug(`input:suppressed text=${JSON.stringify(o)}`),void(n.currentTarget.value="")}const r=e.state(),a=r.selection,c=Oo(r).find(e=>e.id===a.anchor.paragraphId)?.runs.find(e=>e.id===a.anchor.runId),d=c?{bold:c.styles?.bold,italic:c.styles?.italic,underline:c.styles?.underline}:null;e.logger.info(`input:text ${JSON.stringify(o)} (len=${o.length}) at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const u=Cr(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Zi(e,o,u)),{mergeKey:Ca}),n.currentTarget.value="",e.focusInput(),Qn("input:text")},d=()=>{e.logger.debug("input:composition start"),l(),i=null,o=Cr(e.pendingCaretTextStyle()),n(!0)},u=t=>{e.isReadOnly()||s(t.data??"",!1)},p=t=>{if(n(!1),e.isReadOnly())return t.currentTarget.value="",void l();const o=t.data??t.currentTarget.value,r=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(o)} (len=${o.length}) at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}]`),s(o,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:c,handleCompositionStart:d,handleCompositionUpdate:u,handleCompositionEnd:p,composing:t}}(e)}var ov="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 rv(e,t){const n=hr(e);if(n.isCollapsed)return!1;const o=Oo(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=sa(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function av(e){return function(e){const[t,n]=Tt(!1),[o,r]=Tt(null),[a,i]=Tt(!1),[l,s]=Tt(null),[c,d]=Tt(null);let u=null,p=null,g=null;const f=()=>{p&&(p.remove(),p=null)},m=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${ov} !important; }`,document.head.appendChild(p))},h=Jb(),b=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,n(!1),r(null),i(!1),s(null),d(null),f(),h.release(),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)},y=o=>{if(!h.owns(o))return;if(!u)return;const a=o.ctrlKey||o.metaKey;if(i(a),!t()){const t=Math.abs(o.clientX-u.x),r=Math.abs(o.clientY-u.y);if(t+r<4)return;e.logger?.info("text-drag:activate",{start:u,at:{x:o.clientX,y:o.clientY},deltaX:t,deltaY:r}),n(!0),m()}s({x:o.clientX,y:o.clientY});const l=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY);if(!l?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=l.tableCellAnchorPosition??l.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${l.zone}|src=${l.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:l.zone,resolvedFromParagraph:l.resolvedFromParagraph,paragraphId:l.paragraphId,paragraphOffset:l.paragraphOffset,hitPosition:`${l.position.paragraphId}:${l.position.runId}[${l.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:l.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(l.caretViewport??null)},v=n=>{if(h.owns(n)){if(e.logger?.info("text-drag:mouseup",{x:n.clientX,y:n.clientY,dragging:t(),copyMode:a(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null}),t()&&o()){const t=o(),n=a();e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>qi(e,t,{copy:n})),{mergeKey:n?Ya:qa}),e.logger?.info("text-drag:apply",{mode:n?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position;e.applyTransactionalState(e=>rv(e,t)?Cs(e,{anchor:t,focus:t}):e,{mergeKey:Za}),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}b(),e.focusInputAfterPointerSelection()}},x=(t,o)=>e.isReadOnly()||!o?.resolvedFromParagraph?(e.logger?.debug("text-drag:skip-start",{reason:e.isReadOnly()?"readonly":"no-hit",x:t.clientX,y:t.clientY}),!1):rv(e.state(),o.position)?(e.logger?.info("text-drag:start-pending",{x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`,zone:o.zone}),u={x:t.clientX,y:t.clientY,position:o.position},s({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),d(o.caretViewport??null),n(!1),h.claim(t),window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),!0):(e.logger?.debug("text-drag:skip-start",{reason:"outside-selection",x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`}),!1);return{dragging:t,dropTargetPos:o,copyMode:a,pointerPos:l,caretViewport:c,tryStartTextDrag:x,stopDrag:b}}(e)}function iv(e){return e.blocks.flatMap(C)}function lv(e,t){if(!e)return;const n=iv(e);return"start"===t?n[0]:n[n.length-1]}function sv(e){return function(e){const t=(t,n)=>{const o=e.state(),r=Oo(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:we(r).length,i=ot(r,a);return e.clearPreferredColumn(),e.applyState(Cs(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=Oo(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:we(a).length,l=ot(a,i);return e.clearPreferredColumn(),e.applyState(Cs(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=Oo(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const s=we(i),c=o.selection.focus.offset,d=s.length;if(!n&&!_o(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ts(o):Ps(o)),!0;let u=i,p=c;"left"===t?0===c&&a>0?(u=r[a-1],p=we(u).length):p=bo(s,c):c===d&&a<r.length-1?(u=r[a+1],p=0):p=l(s,c);const g=ot(u,p);return e.clearPreferredColumn(),e.applyState(Cs(o,{anchor:n?o.selection.anchor:g,focus:g})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=Oo(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const i=e.surfaceRef(),l=i?.getBoundingClientRect()??null,s=e.preferredColumnX(),c=null===s?e.caretBox().left+(l?.left??0):s,d=i?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:i,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let u=a+t;const p=dt(o.document,o.selection.focus.paragraphId,Fn(o)),g=p?.tablePath[p.tablePath.length-1];if(p&&g){const e=kb(o,p.zone),n=M(e,p.tablePath),a=n?.[n.length-1]?.table;if(a){const e=Vt(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&&iv(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=lv(e.cell,"start")?.id,n=t?d?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??c,r=n?n.left+n.width:c;return{entry:e,distance:c<o?o-c:c>r?c-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=lv(i.cell,t<0?"end":"start");u=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=lv(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=lv(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?Qo(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(sa(f,o.selection.focus),we(f).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Cs(e,{anchor:n?e.selection.anchor:ot(f,m),focus:ot(f,m)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function cv(e){return function(e){const[t,n]=Tt(null),o=(t,o)=>{const r=Oo(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 He(e.state().document)){for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter])if(e&&(a=i(e),a))break;if(a)break}if(!a)return;const l=o.currentTarget.getBoundingClientRect(),s=e.surfaceRef()?.getBoundingClientRect();if(!s)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(l.left-s.left)/c,top:(l.top-s.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function dv(e){const t=Oo(e);if(!t.length)return null;const n=hr(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:U(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:oe(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Cr(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(r?r.styles:Et(o,n.startParagraphOffset)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===oe(o));return{text:a,paragraph:i?Nn(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function uv(e,t){const n=Oo(e);if(!n.length)return e;const o=hr(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:oe(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===oe(e))}(e,n,o),s=l?Nn(t.paragraph):e.style,c=l?t.list?{...t.list}:void 0:e.list,d=l&&(JSON.stringify(s)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),u=a<i&&U(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Cr(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!uo(e.styles,o)});if(!d&&!u)return e;r=!0;let p=u?ne(e,a,i,e=>{if("text"!==e.kind)return e;const n=Cr(t.text)??{};return void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(n).length?n:void 0}}):e;return l&&(p={...p,style:s,list:c}),p});return r?la(e,a,xe(a,o)):e}function pv(e){const t=Oo(e);if(!t.length)return"";const n=hr(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function gv(e){const[t,n]=Tt(null);let o=null,r=null,a="";const i=()=>{o=null,r=null,a="",n(null)},l=()=>!e.isReadOnly()&&Oo(e.state()).length>0,s=t=>{if(!l())return!1;const i=e.state(),s=dv(i);return!!s&&(o=s,r=i.document,a=pv(i),n(t),e.focusInput(),!0)};return{mode:t,canCapture:l,armOnce:()=>s("once"),armContinuous:()=>s("continuous"),cancel:i,applyToSelection:n=>{if(!o||!t())return!1;if(e.isReadOnly()||e.state().document!==r)return i(),!1;const l=e.state();if(pv(l)===a)return!1;const s=function(e,t){const n=Oo(e);if(0===n.length)return null;const o=hr(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=Me(we(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:ot(r,a.start),focus:ot(r,a.end)}}}(l,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==r)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>uv(e,o));return c=n.document!==t.document,n}),"once"===t()?i():c&&(r=e.state().document),c&&e.focusInput(),c}}}function fv(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:f,setForcePlainTextPaste:m,getCommandsController:h,applyTransactionalState:b,clearPreferredColumn:y,resetTransactionGrouping:v,updateHistoryState:x,caretBox:w,preferredColumnX:S,setPreferredColumnX:I,documentLayout:C,canvasSnapshotProvider:T}=e,P=()=>Oh(t),k=()=>gb(t),R=Iy({state:()=>t,resetTransactionGrouping:v,applyTransactionalState:b,focusInput:i}),B=fy({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:C,canvasSnapshotProvider:T,zoomFactor:u}).resolveSurfaceHitAtPoint,M=function(e){const[t,n]=Tt(""),[o,r]=Tt(""),[a,i]=Tt({matchCase:!1,wholeWord:!1}),[l,s]=Tt([]),[c,d]=Tt(-1),[u,p]=Tt(!1);g(_([()=>e.state.document,t,a],([e,t,n])=>{const o=ly(e,t,n);s(o),0===o.length?d(-1):(c()>=o.length||-1===c())&&d(0)}));const f=t=>{const n=l()[t];n&&e.applyState(Cs(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:o,setReplaceTerm:r,findOptions:a,setFindOptions:i,matches:l,currentIndex:c,findNext:()=>{const e=l().length;if(0===e)return;const t=(c()+1)%e;d(t),f(t)},findPrevious:()=>{const e=l().length;if(0===e)return;const t=(c()-1+e)%e;d(t),f(t)},replace:()=>{if(0===l().length||-1===c())return;const t=l()[c()];e.applyTransactionalState(e=>Zi(Cs(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:Va})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>sy(e,n,o(),a()),{mergeKey:Ka}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:b,focusInput:i}),F=Zb({applyTransactionalState:b,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:hn(e).document,selection:t}),focusInput:i,logger:n}),A=gv({state:()=>t,isReadOnly:o,applyTransactionalState:b,applyTableAwareParagraphEdit:F.applyTableAwareParagraphEdit,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:i}),O=(e,t)=>B(e,t)?.position??null,D=ry({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:O,applyState:r,applyTransactionalState:b,updateHistoryState:x,focusInput:i,focusInputAfterPointerSelection:l,cloneState:a,logger:n,zoomFactor:u}),E=ay({state:t,surfaceRef:c,applyState:r,updateHistoryState:x,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),L=iy({state:()=>t,commandsController:h,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:i,logger:n}),N=function(e){const t=()=>e.state,n=Vy({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=Xy({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=Zy({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=cv({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=av({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),l=tv({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:bt,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),s=nv({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=sv({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}=Cy({state:t,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,setForcePlainTextPaste:e.setForcePlainTextPaste,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,insertImageFromFile:e.insertImageFromFile,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint});return{tableResize:n,tableCornerResize:o,tableDrag:r,revisionController:a,textDrag:i,surfaceEvents:l,textInput:s,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,applyState:r,applyTransactionalState:b,isReadOnly:o,logger:n,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,clearPreferredColumn:y,resetTransactionGrouping:v,surfaceRef:c,viewportRef:d,caretBox:()=>w(),preferredColumnX:()=>S(),setPreferredColumnX:I,zoomFactor:u,documentLayout:C,canvasSnapshotProvider:T,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:F,imageOps:D,styleController:L,formatPainter:A,getForcePlainTextPaste:f,setForcePlainTextPaste:m,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),$=e=>{0===e.button&&(L.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:P,selectedTextBoxRun:k,layoutOptionsOverlay:R,fr:M,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:F,imageOps:D,textBoxOps:E,styleController:L,formatPainter:A,onEditorPointerDown:$,tableResize:N.tableResize,tableCornerResize:N.tableCornerResize,tableDrag:N.tableDrag,revisionController:N.revisionController,textDrag:N.textDrag,surfaceEventsWithTextDrag:N.surfaceEvents,textInput:N.textInput,navigation:N.navigation,handleCopy:N.handleCopy,handleCut:N.handleCut,handlePaste:N.handlePaste,handleDrop:N.handleDrop}}(e)}function mv(e){if("main"!==(e.activeZone??"main"))return e;const t=_o(e.selection)?e:Ke(e),{paragraph:n,index:o,offset:r}=E(t),a=yr(),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 vr(e)){const e=Xt(a);e&&!e.customMark&&(r.has(e.footnoteId)||(r.add(e.footnoteId),o+=1))}return Yo(o+1,n)}(t.document),l=Jn(a.id,i),s=Y(n,r,[l]),c=Oo(t).map((e,t)=>t===o?s:e),d=ot(s,r+i.length),u=la(t,c,co(d)),p=function(e){return e||{items:{}}}(u.document.footnotes),g={...u.document,footnotes:{...p,items:{...p.items,[a.id]:a}}},f=Rn(g),m=a.blocks.flatMap(C).find(Boolean);return m?{...u,document:f,selection:co(ot(m,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...u,document:f}}function hv(e,t,n){return e.flatMap(e=>{if("paragraph"===e.type)return[e];let o=e.style;if(o?.revision?.id===t)if(n){const{revision:e,...t}=o;o=t}else o={...o.revision.previous};let r=e.gridCols,a=e.gridRevision;a?.id===t&&(r=n?r:[...a.previous],a=void 0);const i=e.rows.map(e=>({...e,cells:[...e.cells]}));for(let s=0;s<i.length;s+=1){const e=i[s];for(let o=0;o<e.cells.length;o+=1){const r=e.cells[o],a=r.mergeRevisionState;if(a&&a.revisionId===t){if(n){const{mergeRevisionState:t,...n}=r;e.cells[o]=n;continue}"horizontal"===a.orientation?e.cells.splice(o,a.currentCellCount,...a.previousCells):a.previousCells.forEach((e,t)=>{const n=i[s+t];n&&(n.cells[o]=e)})}}}const l=i.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};if(o?.revision?.id===t){const{revision:e,...t}=o;o=t}const r=e.cells.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};let r={...e,style:o,blocks:hv(e.blocks,t,n)};if(o?.revision?.id===t&&e.mergeRevisionState?.revisionId!==t){const e=o.revision,{revision:t,...a}=o;r={...r,...n||"merge"!==e.type?{}:e.previous,style:a}}return[r]});return[{...e,isHeader:o&&"isHeader"in o?o.isHeader:e.isHeader,style:o,cells:r}]});return 0===l.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:l}]})}function bv(e,t,n){const o=He(e.document).map(e=>({...e,blocks:hv(e.blocks,t,n),header:e.header?hv(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?hv(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?hv(e.evenPageHeader,t,n):void 0,footer:e.footer?hv(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?hv(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?hv(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function yv(e,t){const n=Oo(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"delete"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"insert"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:fe(e,n)});return bv(la(e,n,xe(n,hr(e))),t,!0)}function vv(e,t){const n=Oo(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"insert"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"delete"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:fe(e,n)});return bv(la(e,n,xe(n,hr(e))),t,!1)}function xv(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>xv(e,t))))}function wv(e,t,n){for(const o of e)if("paragraph"!==o.type){xv(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=>xv(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),wv(e.blocks,t,n)}}}function Sv(e){const t=hr(e),n=Oo(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:oe(e),l=U(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of He(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&wv(e,r,o);return o}function Iv(e){return function(e){const t=/* @__PURE__ */new Set,n=e=>{for(const n of e)n.revision?.id&&t.add(n.revision.id),n.revisionRangeMarker?.id&&t.add(n.revisionRangeMarker.id)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){r.style?.revision&&t.add(r.style.revision.id),r.gridRevision&&t.add(r.gridRevision.id);for(const e of r.rows){e.style?.revision&&t.add(e.style.revision.id),e.style?.propertyRevision&&t.add(e.style.propertyRevision.id);for(const n of e.cells)n.style?.revision&&t.add(n.style.revision.id),n.style?.propertyRevision&&t.add(n.style.propertyRevision.id),n.mergeRevisionState?.revisionId&&t.add(n.mergeRevisionState.revisionId),o(n.blocks)}}else n(r.runs)};for(const i of He(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}(e).size>0}function Cv(e,t){if(!Iv(e))return e;const n=Vo(e.document,t);if(!n.changed)return e;const o=Oo({...e,document:n.document}),r=xe(o,hr(e));return{...e,document:n.document,selection:r}}function Tv(e){const t=hr(e),n=Oo(e);if(t.isCollapsed){const e=n[t.startIndex];return e?wt(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:oe(e);return U(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 Pv(e){const t=hr(e),n=Oo(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return Kt(e);if(!e.list)return Kt(e);const o=e.list.level??0;return o<=0?rr(e):ce(e,o-1)});return la(e,n,xe(n,t))}function kv(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:a,applySelectionAwareTextCommand:i,applySelectionAwareParagraphCommand:l,applyTableAwareParagraphEdit:s,focusInput:c,clearPreferredColumn:d,resetTransactionGrouping:u,toolbarStyleState:p,selectionCollapsed:g,selectedImageRun:f}=e,m=e=>{d(),u(),o(e),c()},h=e=>{d(),u(),i(e),c()},b=e=>{d(),u(),l(e),c()},y=(e,t)=>{d(),u(),a(e,t),c()},v=()=>{const e=hr(t);return Oo(t).slice(e.startIndex,e.endIndex+1)},x=()=>v().some(e=>Boolean(e.list)),w=()=>{const e=t.selection.focus.paragraphId;return Oo(t).find(t=>t.id===e)??null},S=()=>{const e=w();return!!e?.list&&(d(),u(),g()&&0===we(e).length?l(e=>function(e){const t=hr(e),n=Oo(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Kt(e):rr(e));return la(e,n,xe(n,t))}(e)):a(e=>s(e,e=>function(e){const t=_o(e.selection)?e:Ke(e),{paragraph:n,index:o,offset:r}=E(t),a=fe(n,U(n,0,r),Et(n,r)),i=U(n,r,oe(n)),l=i.length>0?Wt(n,i.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=Bo("");return e.style=n.style?{...n.style}:void 0,e.list=nn(n.list),e})(),s=Oo(t),c=[...tt(s.slice(0,o)),a,l,...tt(s.slice(o+1))];return la(t,c,nt(ot(l,0)))}(e)),{mergeKey:Ba}),c(),!0)},C=()=>{const e=t.selection,n=Fn(t),o=Gr(t.document,e.anchor.paragraphId,n),r=Gr(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}]`:""},T=e=>{if(g())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${C()}`),h(t=>nl(t,e))},P=e=>{g()||h(t=>function(e,t){const n=hr(e);if(n.isCollapsed)return e;const o=Oo(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:oe(e);return ne(e,r,a,e=>({...e,styles:pr(Wo(e.styles,"underline",null!==t),"underlineStyle","single"===t?null:t)}))});return la(e,o,xe(o,n))}(t,e))},k=(e,o)=>{if(g())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}]${C()}`),h(t=>ol(t,e,o))},R=(e,t)=>{b(n=>r(n,e,t))},M=e=>{const t=!p()[e];R(e,"widowControl"===e?t:!!t||null)},F=()=>{y(e=>s(e,e=>B(e)))},A=()=>"main"===(t.activeZone??"main"),O=()=>{A()&&y(e=>mv(e))},D=e=>{const n=Tv(t);g()&&!n||y(t=>function(e,t){const n=hr(e);if(!n.isCollapsed)return ol(e,"link",t);const o=Oo(e)[n.startIndex];if(!o)return e;const r=wt(o,n.startParagraphOffset);if(!r)return e;const a=ol(Cs(e,{anchor:ot(o,r.startOffset),focus:ot(o,r.endOffset)}),"link",t),i=Oo(a)[n.startIndex];return i?{...a,selection:{anchor:ot(i,r.startOffset),focus:ot(i,r.endOffset)}}:a}(t,e),{mergeKey:Ma})},L=()=>{const n=Tv(t)??"";g()&&!n||e.openLinkDialog(n)},N=()=>{D(null)},$=()=>{const t=f();if(!t)return;const n=Ut(t.run)?.alt??"";e.openImageAltDialog(n)},z=t=>{f()&&y(n=>function(e,t,n){const o=Oh(e);if(!o||!Ut(o.run))return e;const r=Oo(e),a=o.paragraphIndex+1,i=a<r.length&&ve(r[a])?Zt(r[a],t,n):kt(t,n,1),l=a<r.length&&ve(r[a])?[...tt(r.slice(0,a)),i,...tt(r.slice(a+1))]:[...tt(r.slice(0,a)),i,...tt(r.slice(a))],s=cr(l),c=s[a]??i;return la(e,s,nt(ot(c,Ht(c))))}(n,t,e.imageCaptionLabel()),{mergeKey:Aa})},H=()=>{f()&&e.openImageCaptionDialog(function(e){const t=Oh(e);if(!t||!Ut(t.run))return null;const n=Oo(e);return G(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:T,applyToggleCharacterBorderCommand:()=>{g()||h(e=>function(e){const t=hr(e);if(t.isCollapsed)return e;const n=Oo(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:oe(e);return U(e,r,a)}).filter(e=>e.text.length>0);if(0===o.length)return e;const r=!o.every(e=>Boolean(e.styles?.textBorder)),a=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,a=n===t.endIndex?t.endParagraphOffset:oe(e);return ne(e,o,a,e=>({...e,styles:il(e.styles,r)}))});return la(e,a,xe(a,t))}(e))},applyValueStyleCommand:k,applyUnderlineStyleCommand:P,applyChangeTextCaseCommand:e=>{g()||h(t=>cl(t,e))},applyClearFormattingCommand:()=>{g()||h(e=>function(e){const t=hr(e);if(t.isCollapsed)return e;const n=Oo(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,r=n===t.endIndex?t.endParagraphOffset:oe(e);return ne(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return la(e,n,xe(n,t))}(e))},applyParagraphStyleCommand:R,toggleParagraphFlagCommand:M,applyParagraphListCommand:e=>{b(t=>function(e,t){const n=hr(e),o=Oo(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),l=i.length>0&&i.every(e=>e.list?.kind===t),s=o.map((e,n)=>{if(n<r||n>a)return Kt(e);const o=Kt(e);return l?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return la(e,s,xe(s,n))}(t,e))},handleListFormatChange:e=>{b(t=>function(e,t){const n=hr(e),o=Oo(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Kt(e):e.list?{...Kt(e),list:{...e.list,format:t||void 0}}:Kt(e));return la(e,o,xe(o,n))}(t,e))},handleListStartAtChange:e=>{b(t=>function(e,t){const n=hr(e),o=Oo(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Kt(e):e.list?{...Kt(e),list:{...e.list,startAt:null!==t?t:void 0}}:Kt(e));return la(e,o,xe(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{m(I(t,e))},applyInsertPageBreakCommand:F,canInsertFootnoteCommand:A,applyInsertFootnoteCommand:O,handleStyleChange:e=>{b(t=>xo(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{m(ke(t,e,n))},applyToggleTrackChangesCommand:()=>{m(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),c()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),c()},applyAcceptRevisionsCommand:()=>{m(function(e){let t=e;for(const n of Sv(e))t=yv(t,n);return t}(t))},applyRejectRevisionsCommand:()=>{m(function(e){let t=e;for(const n of Sv(e))t=vv(t,n);return t}(t))},applyAcceptAllRevisionsCommand:()=>{m(function(e){return Cv(e,"accept")}(t))},applyRejectAllRevisionsCommand:()=>{m(function(e){return Cv(e,"reject")}(t))},applyLinkCommand:D,promptForLink:L,removeLinkCommand:N,applyImageAltCommand:e=>{f()&&y(t=>function(e,t){return jh(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:Fa})},promptForImageAlt:$,applyImageCaptionCommand:z,promptForImageCaption:H,applyImageWidthCmCommand:e=>{!f()||!Number.isFinite(e)||e<=0||y(t=>function(e,t){const n=Oh(e),o=n&&Ut(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*gr));return Dh(e,r,r*(o.height/o.width))}(t,e),{mergeKey:Oa})},applyImageHeightCmCommand:e=>{!f()||!Number.isFinite(e)||e<=0||y(t=>function(e,t){const n=Oh(e),o=n&&Ut(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*gr));return Dh(e,r*(o.width/o.height),r)}(t,e),{mergeKey:Oa})},applyImageCropAspectCommand:e=>{if(!f())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&&y(e=>"reset"===t?zh(e):Nh(e,t),{mergeKey:Da})},applyImageCropShapeCommand:e=>{f()&&y(t=>function(e,t){const n=t?.trim();return jh(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:Da})},applyImageCropFillCommand:()=>{f()&&y(e=>function(e){const t=Oh(e),n=t&&Ut(t.run);return n?jh(Lh(e,{crop:$h(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Da})},applyImageCropFitCommand:()=>{f()&&y(e=>function(e){return jh(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Da})},resetImageCropCommand:()=>{f()&&y(e=>zh(e),{mergeKey:Da})},applyImageBorderCommand:e=>{f()&&y(t=>function(e,t){return jh(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=>{f()&&y(t=>Uh(t,e),{mergeKey:Ea})},rotateImageCommand:e=>{f()&&y(t=>Wh(t,e),{mergeKey:La})},applyImageTransparencyCommand:e=>{f()&&y(t=>function(e,t){return null===Oh(e)?e:jh(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:Na})},resetImageCommand:()=>{f()&&y(e=>function(e){return null===Oh(e)?e:jh(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:$a})},handleListTab:e=>!Gr(t.document,t.selection.focus.paragraphId,Fn(t))&&(!!x()&&(b(t=>"indent"===e?function(e){const t=hr(e),n=Oo(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Kt(e):e.list?ce(e,(e.list.level??0)+1):Kt(e));return la(e,n,xe(n,t))}(t):Pv(t)),!0)),handleListEnter:S,handleListBoundaryBackspace:e=>{const n=w();return!(!n?.list||!g())&&(0===sa(n,t.selection.focus)&&(d(),u(),l(e=>Pv(e)),e.currentTarget.value="",c(),!0))}}}(e)}function Rv(e){return function(e){const t=kv({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:()=>_o(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}),imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Bv(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Mv=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&&(n.canExecuteCommand?.(a.command)??!0))return n.executeCommand(a.command),e.preventDefault(),!0;if(!1!==a.execute(t,e))return e.preventDefault(),!0}return!1}},Fv=[{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=Oo(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Cs(t,{anchor:ot(o,0),focus:ot(r,we(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:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:e=>(e.toggleFindReplace(!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=>B(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=>Zi(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=>Ji(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=>mo(e))),e.focusInput()),!0)}];function Av(e){return function(e){const t=new Mv;Fv.forEach(e=>t.register(e));const n=n=>{const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="ArrowLeft"===e||"ArrowRight"===e||"ArrowUp"===e||"ArrowDown"===e||"Home"===e||"End"===e||"PageUp"===e||"PageDown"===e,r="Shift"===e||"Control"===e||"Meta"===e||"Alt"===e,a=(n.ctrlKey||n.metaKey)&&("a"===t||"c"===t);return void(o||r||a||n.preventDefault())}if(n.isComposing||229===n.keyCode)return;const r=e.executeCommand?{executeCommand:(t,n)=>e.executeCommand?.(t,n),canExecuteCommand:(t,n)=>e.canExecuteCommand?.(t,n)}:void 0;if(!t.execute(n,e,r)){if((n.ctrlKey||n.metaKey)&&!n.altKey){if(("ArrowLeft"===n.key||"ArrowRight"===n.key)&&(n.preventDefault(),e.resetTransactionGrouping(),e.moveSelectionByWord("ArrowLeft"===n.key?"left":"right",n.shiftKey)))return void e.focusInput();if("Backspace"===n.key||"Delete"===n.key){if(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!_o(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>el(e))),n.currentTarget.value="",void e.focusInput();const t=Oo(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===sa(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>Pv(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=we(r),l=Me(i,a);return"Backspace"===n.key?0===a||l.start===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>el(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Cs(t,{anchor:ot(r,l.start),focus:ot(r,a)}),e=>el(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>tl(e))):l.end>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Cs(t,{anchor:ot(r,a),focus:ot(r,l.end)}),e=>el(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>tl(e))),n.currentTarget.value="",void e.focusInput()}}if("Home"===n.key||"End"===n.key){n.preventDefault(),e.resetTransactionGrouping();const t="Home"===n.key?"start":"end";return n.ctrlKey||n.metaKey?e.moveSelectionToDocumentBoundary(t,n.shiftKey):e.moveSelectionToParagraphBoundary(t,n.shiftKey),void e.focusInput()}if(!n.altKey||n.ctrlKey||n.metaKey||"ArrowUp"!==n.key&&"ArrowDown"!==n.key||(n.preventDefault(),e.resetTransactionGrouping(),e.clearPreferredColumn(),!e.moveSelectedImageByParagraph("ArrowUp"===n.key?-1:1)))switch(n.key){case"Backspace":return e.commandsController.handleListBoundaryBackspace(n)?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>el(e))),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>tl(e))),n.currentTarget.value="",void e.focusInput();case"Tab":{if(e.commandsController.handleListTab(n.shiftKey?"outdent":"indent"))return void n.preventDefault();const t=e.resolveAdjacentTableCellPosition(o.document,o.selection.focus.paragraphId,n.shiftKey?-1:1);if(t)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applySelectionPreservingStructure({anchor:t,focus:t}),void e.focusInput();break}case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(ws(o,-1))):(e.clearPreferredColumn(),e.applyState(Ts(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return ws(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Ps(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return Ss(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return xs(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return Ss(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return xs(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var Ov=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var Dv={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"}},Ev={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},Lv={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 Nv(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function $v(e,t){return function(e,t){const n=Dv[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 zv(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Hv(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function Wv(e){return null!=e&&""!==e?Number(e):null}function Uv({gate:e,style:t,selection:n,history:o,formatting:r,link:a,command:i,valueCommand:l,actionCommand:s}){const c=t.state;return{selectAll:i("selectAll",r.selectAll),selectWord:i("selectWord",r.selectWord),selectSentence:i("selectSentence",r.selectSentence),selectParagraph:i("selectParagraph",r.selectParagraph),selectCollapse:s("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:s("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:i("insertFootnote",r.insertFootnote),setNoteOptions:s("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:Wv(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:i("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:i("updateTableOfContents",r.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&r.hasTableOfContents()})),insertText:s("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:s("insertEquation",e=>{r.insertEquation(e)}),updateEquation:s("updateEquation",e=>{const t=e;r.updateEquation(t.runId,t.expression)}),pastePlainText:i("pastePlainText",r.pastePlainText),formatPainter:i("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:i("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:i("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:i("bold",r.bold,()=>({isActive:Boolean(c().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(c().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(c().underline)})),doubleUnderline:i("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===c().underlineStyle})),wordUnderline:i("wordUnderline",r.wordUnderline,()=>({isActive:"words"===c().underlineStyle})),strike:i("strike",r.strike,()=>({isActive:Boolean(c().strike)})),doubleStrike:i("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(c().doubleStrike)})),smallCaps:i("smallCaps",r.smallCaps,()=>({isActive:Boolean(c().smallCaps)})),allCaps:i("allCaps",r.allCaps,()=>({isActive:Boolean(c().allCaps)})),hidden:i("hidden",r.hidden,()=>({isActive:Boolean(c().hidden)})),noProof:i("noProof",r.noProof,()=>({isActive:Boolean(c().noProof)})),webHidden:i("webHidden",r.webHidden,()=>({isActive:Boolean(c().webHidden)})),specVanish:i("specVanish",r.specVanish,()=>({isActive:Boolean(c().specVanish)})),contextualAlternates:i("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(c().contextualAlternates)})),characterBorder:i("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(c().characterBorder)})),shadow:i("shadow",r.shadow,()=>({isActive:Boolean(c().shadow)})),emboss:i("emboss",r.emboss,()=>({isActive:Boolean(c().emboss)})),engrave:i("engrave",r.engrave,()=>({isActive:Boolean(c().imprint)})),outline:i("outline",r.outline,()=>({isActive:Boolean(c().outline)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(c().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(c().subscript)})),link:i("link",()=>(a.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&a.canPrompt(),isActive:Boolean(c().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===c().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===c().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===c().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===c().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===c().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===c().listKind})),find:i("find",r.find),replace:i("replace",r.replace),replaceAll:s("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),acceptRevisions:i("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:i("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:i("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:i("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:i("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:i("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:i("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:i("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:i("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:i("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:i("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:i("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:i("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:i("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:i("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(Ot(),{isActive:f()})),undo:i("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:i("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),columnBreak:i("columnBreak",r.columnBreak),splitBlock:i("splitBlock",r.splitBlock),insertNonBreakingSpace:i("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:i("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:i("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:i("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:i("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:i("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:i("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:i("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:l("setFontFamily",e=>r.setFontFamily(e||null),()=>c().fontFamily),setFontSize:l("setFontSize",e=>{const t=e&&"object"==typeof e&&"size"in e?e.size:e;return r.setFontSize(null!=t&&""!==t?mr(t):null),!0},()=>un(c().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),growFont1:i("growFont1",r.growFont1),shrinkFont1:i("shrinkFont1",r.shrinkFont1),changeTextCase:s("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",e=>r.setColor(e??null),()=>c().color||null),setHighlight:l("setHighlight",e=>r.setHighlight(e??null),()=>c().highlight||null),setTextShading:l("setTextShading",e=>r.setTextShading(e??null),()=>c().textShading||null),setStyleId:l("setStyleId",e=>r.setStyleId(String(e)),()=>c().styleId||"normal"),setCharacterStyleId:l("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>c().characterStyleId||""),applyUnderlineStyle:l("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>c().underlineStyle),setUnderlineStyle:l("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>c().underlineStyle),setUnderlineColor:l("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>c().underlineColor),setCharacterScale:l("setCharacterScale",e=>r.setCharacterScale(Wv(e)),()=>c().characterScale),setCharacterSpacing:l("setCharacterSpacing",e=>r.setCharacterSpacing(Wv(e)),()=>c().characterSpacing),setRunSnapToGrid:l("setRunSnapToGrid",e=>r.setRunSnapToGrid(zv(e)),()=>c().snapToGrid),setFitText:l("setFitText",e=>r.setFitText(Wv(e)),()=>c().fitText),setBaselineShift:l("setBaselineShift",e=>r.setBaselineShift(Wv(e)),()=>c().baselineShift),setEmphasisMark:l("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>c().emphasisMark),setTextEffect:l("setTextEffect",e=>r.setTextEffect(e||null),()=>c().textEffect),setKerning:l("setKerning",e=>r.setKerning(Wv(e)),()=>c().kerningThreshold),setLigatures:l("setLigatures",e=>r.setLigatures(e||null),()=>c().ligatures),setNumberSpacing:l("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>c().numberSpacing),setNumberForm:l("setNumberForm",e=>r.setNumberForm(e||null),()=>c().numberForm),setStylisticSet:l("setStylisticSet",e=>r.setStylisticSet(Wv(e)),()=>c().stylisticSet)}}function jv({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const l=t.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:n.documentStyles()})),print:i("print",()=>n.printDocument(),()=>({isEnabled:!0})),paste:i("paste",()=>a.paste(),()=>({isEnabled:e.isCommandEnabled("paste")&&a.canPaste()})),pasteAsPlainText:i("pasteAsPlainText",()=>a.pasteAsPlainText(),()=>({isEnabled:e.isCommandEnabled("pasteAsPlainText")&&a.canPaste()})),cut:i("cut",()=>a.cut(),()=>({isEnabled:e.isCommandEnabled("cut")&&a.hasSelection()&&a.canCut()})),pasteMergeFormatting:i("pasteMergeFormatting",()=>a.pasteMergeFormatting(),()=>({isEnabled:e.isCommandEnabled("pasteMergeFormatting")&&a.canPaste()})),copy:i("copy",()=>a.copy(),()=>({isEnabled:e.isCommandEnabled("copy")&&a.hasSelection()})),newDocument:i("newDocument",()=>n.newDocument()),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()),openEquationDialog:i("openEquationDialog",()=>n.openEquationDialog()),tableProperties:i("tableProperties",e=>n.openTableProperties(e?.activeTab??"table"),()=>({isEnabled:n.hasActiveTable()})),unlink:i("unlink",()=>o.remove(),()=>({isEnabled:e.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),imageContext:i("imageContext",()=>{},()=>({isEnabled:r.isSelected(),isActive:r.isSelected(),value:null})),imageWidthCm:i("imageWidthCm",e=>r.setWidthCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.width??null})),imageHeightCm:i("imageHeightCm",e=>r.setHeightCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.height??null})),imageCrop:i("imageCrop",()=>r.toggleCrop(),()=>({isEnabled:r.isSelected(),isActive:r.isCropActive()})),imageCropAspect:i("imageCropAspect",e=>r.applyCropAspect(String(e)),()=>({isEnabled:r.isSelected()})),imageCropShape:i("imageCropShape",e=>r.applyCropShape(String(e)),()=>({isEnabled:r.isSelected(),value:r.getCropShape()})),imageCropFill:i("imageCropFill",()=>r.applyCropFill(),()=>({isEnabled:r.isSelected()})),imageCropFit:i("imageCropFit",()=>r.applyCropFit(),()=>({isEnabled:r.isSelected()})),imageCropReset:i("imageCropReset",()=>r.resetCrop(),()=>({isEnabled:r.isSelected()})),imageFlip:i("imageFlip",e=>r.flip(e??"horizontal"),()=>({isEnabled:r.isSelected()})),imageRotate:i("imageRotate",e=>r.rotate(e??"left"),()=>({isEnabled:r.isSelected()})),imageBorder:i("imageBorder",e=>r.setBorder(e),()=>({isEnabled:r.isSelected(),value:r.getBorder()})),imageTransparency:i("imageTransparency",e=>r.setTransparency("number"==typeof e?e:null==e?0:Number(e)),()=>({isEnabled:r.isSelected(),value:r.getTransparency()})),resetImage:i("resetImage",()=>r.reset(),()=>({isEnabled:r.canReset()}))}}function Vv({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(zv(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(Wv(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(Wv(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(zv(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Hv(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Hv(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(zv(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(zv(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(zv(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(zv(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(zv(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(zv(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(zv(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(zv(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(zv(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(zv(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(zv(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(zv(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(zv(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(zv(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(Wv(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(Wv(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(Wv(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(Wv(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",Wv(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(Wv(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(Wv(e))),setListLevel:r("setListLevel",e=>t.setListLevel(Wv(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=on(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 Kv({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 _v({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 Xv({fields:e,actionCommand:t}){return{insertDateField:t("insertDateField",()=>{e.insertDate()}),insertDateTime:t("insertDateTime",t=>{const n=t??{};e.insertDateTime(n.dateFormat)}),insertCrossReference:t("insertCrossReference",t=>{const n=t??{};if("string"!=typeof n.bookmark||0===n.bookmark.length)return;const o="PAGEREF"===n.type?"PAGEREF":"REF";e.insertCrossReference({type:o,bookmark:n.bookmark})})}}function Gv({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()),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(zv(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(zv(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(zv(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(zv(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(Wv(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(Wv(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Hv(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 Yv({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())}}var qv=/* @__PURE__ */new Set(["copy","selectAll","selectWord","selectSentence","selectParagraph","selectCollapse","nextRevision","previousRevision","nextComment","previousComment","toggleCommentsPanel","find","replace","print","exportDocx","exportPdf","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts"]);function Zv(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||(qv.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))}}function Jv(e){return{state:()=>e.styleController.toolbarStyleState()}}function Qv(e){return{isCollapsed:()=>_o(e.state().selection)}}function ex(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var tx={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function nx(e){return/\p{L}|\p{N}/u.test(e)}function ox(e){return"."===e||"!"===e||"?"===e}function rx(e,t){return ot(e,t)}function ax(e,t,n,o){return e-n||t-o}function ix(e,t){const n=Oo(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:rx(o,t.startOffset),focus:rx(r,t.endOffset)}}:e}function lx(e,t,n){if(!t.length)return null;const o=Oo(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?hr(e,o).end:hr(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=sa(l,a);return("next"===n?t.find(e=>ax(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>ax(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function sx(e){const t=Oo(e),n=[],o=/* @__PURE__ */new Set;return t.forEach((e,t)=>{let r=0;for(const a of e.runs){const e=a.revision?.id;e&&!o.has(e)&&(o.add(e),n.push({id:e,startIndex:t,startOffset:r,endIndex:t,endOffset:r+a.text.length})),r+=a.text.length}}),n}function cx(e,t){const n=lx(e,sx(e),t);return n?ix(e,n):e}function dx(e){const t=Oo(e),n=new Map(t.map((e,t)=>[e.id,t])),o=e.document.comments;if(!o)return[];const r=[];for(const a of o.order){const e=o.items[a];if(!e?.start||!e.end)continue;const i=n.get(e.start.paragraphId),l=n.get(e.end.paragraphId);if(void 0===i||void 0===l)continue;const s=t[i],c=t[l],d=Math.max(0,Math.min(e.start.offset,s.runs.reduce((e,t)=>e+t.text.length,0))),u=Math.max(0,Math.min(e.end.offset,c.runs.reduce((e,t)=>e+t.text.length,0)));ax(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>ax(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function ux(e,t){const n=lx(e,dx(e),t);return n?ix(e,n):e}function px(e){const t=dx(e);if(!t.length)return null;const n=hr(e),o=t.find(e=>0===ax(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===ax(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>ax(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&ax(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}var gx=e=>Math.round(e/fn*96);function fx(e,t=3){const n=[];for(const o of b(e.document)){const e=qn(o.style?.styleId);if(null===e||e>t)continue;const r=we(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function mx(e){const t=On(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 hx(e,t){const n=Bo("");return n.runs=e,t&&(n.style=t),n}function bx(e,t,n){const o=void 0!==t?String(t):"";return hx([mx({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:gx(40),indentLeft:gx(397*(e.level-1))})}function yx(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return vo(o*Uo,2)}function vx(e,t,n,o){const r=He(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:nt(ot(o,0))}}function xx(e,t=()=>{},n=3){if("main"!==Un(e))return e;const o=Fn(e),r=He(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>bx(e,t(e.id),n));return[hx([mx({text:"",fieldChar:{kind:"begin"}}),mx({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),mx({text:"",fieldChar:{kind:"separate"}})]),...o,hx([mx({text:"",fieldChar:{kind:"end"}})])]}(fx(e,n),t,yx(r)),i=Ho(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&C(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return vx(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function wx(e){let t=0,n="",o=-1,r=-1,a=!1;for(let i=0;i<e.length;i+=1){const l=e[i];if("paragraph"===l.type)for(const e of l.runs){const l=ar(e),s=de(e);if("begin"===l?.kind)t+=1,1===t&&(r=i,n="",a=!1,o=-1);else if(1===t&&void 0!==s)n+=s,/\bTOC\b/i.test(n)&&(a=!0);else if("separate"===l?.kind)1===t&&(o=i);else if("end"===l?.kind){if(1===t&&a)return{startBlockIndex:o>=0?o:r,endBlockIndex:i};t=Math.max(0,t-1)}}}return null}function Sx(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?so(n):11,r="increase"===t?Ko(o):Cn(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",dr(r)),!0},n=e=>{const t=go(e.document),n=/* @__PURE__ */new Map;for(const o of t.pages)for(const e of o.blocks){const t=e.paragraphId;t&&!n.has(t)&&n.set(t,o.index+1)}return e=>n.get(e)};return{formatPainterOnce:e.formatPainter.armOnce,formatPainterContinuous:e.formatPainter.armContinuous,cancelFormatPainter:()=>(e.formatPainter.cancel(),!0),formatPainterMode:e.formatPainter.mode,canCaptureFormatPainter:e.formatPainter.canCapture,selectAll:()=>{const t=b(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:ot(n,0),focus:ot(o,we(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=E(e),o=we(t);let r=n,a=n;for(;r>0&&nx(o[r-1]);)r-=1;for(;a<o.length&&nx(o[a]);)a+=1;return Cs(e,{anchor:ot(t,r),focus:ot(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=E(e),o=we(t);let r=n;for(;r>0&&!ox(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!ox(o[a]);)a+=1;return a<o.length&&(a+=1),Cs(e,{anchor:ot(t,r),focus:ot(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=Oo(e),n=hr(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Cs(e,{anchor:ot(o,0),focus:ot(r,oe(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=Oo(e),a=ur(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Cs(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=ly(e.document,t)[Math.max(1,n)-1];return o?Cs(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 Cs(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=>Zi(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){const n=_o(e.selection)?e:Ke(e),{paragraph:o,index:r,offset:a}=E(n),i=Et(o,a),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},s=Y(o,a,[l]),c=Oo(n).map((e,t)=>t===r?s:e);return la(n,c,nt(ot(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=Oo(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?la(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=He(e.document)[Fn(e)];return!!t&&null!==wx(t.blocks)}(e.state()),hasRevisionsInSelection:()=>Sv(e.state()).size>0,hasRevisionsInDocument:()=>Iv(e.state()),hasNavigableRevisions:()=>sx(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),dx(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=cx(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=cx(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=ux(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=ux(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==px(e.state()),isSelectedCommentResolved:()=>Boolean(px(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=>xx(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=Fn(e),r=He(e.document)[o];if(!r)return e;const a=wx(r.blocks);if(!a)return e;const i=fx(e,n).map(e=>bx(e,t(e.id),yx(r)));return vx(e,o,[...r.blocks.slice(0,a.startBlockIndex+1),...i,...r.blocks.slice(a.endBlockIndex)],i[0]??r.blocks[a.startBlockIndex])}(e,n(e))),e.focusInput(),!0),pastePlainText:()=>(e.forcePlainTextPaste.set(!0),e.focusInput(),!0),bold:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),doubleUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"double"===e.styleController.toolbarStyleState().underlineStyle?null:"double"),!0),wordUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"words"===e.styleController.toolbarStyleState().underlineStyle?null:"words"),!0),strike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),doubleStrike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("doubleStrike"),!0),smallCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("smallCaps"),!0),allCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("allCaps"),!0),hidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("hidden"),!0),noProof:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("noProof"),!0),webHidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("webHidden"),!0),specVanish:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("specVanish"),!0),contextualAlternates:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("contextualAlternates"),!0),toggleCharacterBorder:()=>(e.keyboardCommandsController.applyToggleCharacterBorderCommand(),!0),shadow:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("shadow"),!0),emboss:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("emboss"),!0),engrave:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("imprint"),!0),outline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("outline"),!0),superscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(e.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(e.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(e.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(e.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(e.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(e.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(e.findReplace.setIsOpen(!0),!0),replace:()=>(e.findReplace.setIsOpen(!0),!0),replaceAll:t=>(e.isReadOnly()||(e.applyTransactionalState(e=>sy(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:Ka}),e.focusInput()),!0),isTrackChangesEnabled:()=>Boolean(e.state().trackChangesEnabled),areMarginsVisible:()=>Boolean(e.state().showMargins),areParagraphMarksVisible:()=>Boolean(e.state().showParagraphMarks),toggleTrackChanges:()=>(e.commandsController.applyToggleTrackChangesCommand(),!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:()=>(Ft(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>B(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Zi(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Ji(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>mo(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return Zi(e,tx[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=>rl(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>rl(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>_o(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 Ix(e,t){const n=gb(e),r=n&&Qt(n.run);if(!n||!r)return e;const{paragraphIndex:a,run:i}=n,l=Oo(e).map((e,n)=>n!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id===i.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:o(e))});return la(e,l,xe(l,hr(e)))}function Cx(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 Tx(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*Tr),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*Tr)}}}function Px(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:a,run:i}=n,l=Oo(e).map((e,t)=>t!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,rotation:r}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:o(e))});return la(e,l,xe(l,hr(e)))}function kx(e,t,n=90){return Rx(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 Rx(e,t){const n=gb(e);if(!n||!Qt(n.run))return e;const{paragraphIndex:r,run:a}=n,i=Oo(e).map((e,n)=>n!==r?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:o(e))});return la(e,i,xe(i,hr(e)))}function Bx(e,t){return Rx(e,e=>({...e,body:t(e.body??{})}))}function Mx(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of b(t)){e.style?.styleId&&o.add(e.style.styleId);for(const t of e.runs)t.styles?.styleId&&o.add(t.styles.styleId)}return Object.values(n).map(e=>{const t=L(e.id,n),r="table"===e.type?Rr(e.id,n).tableStyle:void 0,a=r?.conditionalFormats?.wholeTable,i=r?.conditionalFormats?.firstRow,l=r?.conditionalFormats?.band1Horz,s=a?.borders?.borderBottom??r?.borders?.borderBottom;return{id:e.id,name:e.name,type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:t.fontFamily?.trim()||void 0,fontSize:"number"==typeof t.fontSize?t.fontSize:void 0,color:t.color??void 0,bold:t.bold??void 0,italic:t.italic??void 0,tablePreview:r?{wholeFill:a?.shading,headerFill:i?.shading,bandFill:l?.shading,borderColor:s?.color,headerColor:i?.textStyle?.color??void 0}:void 0}})},newDocument:()=>e.newDocument(),openSymbolDialog:()=>e.openSymbolDialog(),openEquationDialog:()=>e.openEquationDialog(),hasActiveTable:()=>fs(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=Mt(t),o=wo(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return ys(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=_o(e.selection)?e:Ke(e),{paragraph:a,offset:i}=E(r),l=U(a,0,i),s=U(a,i,oe(a)),c=Bo(""),d={...a,runs:l.length?l:Bo("").runs},u={...a,id:c.id,runs:s.length?s:c.runs},p=[...i>0?[d]:[],...o,...s.length||"table"===o[o.length-1]?.type?[u]:[]];let g=!1;const f=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===a.id)return g=!0,t=!0,p;if("table"!==e.type)return[e];let n=!1;const o=e.rows.map(e=>{let t=!1;const o=e.cells.map(e=>{const n=f(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:o}):e});return n?(t=!0,[{...e,rows:o}]):[e]});return t?n:e},m=r.activeZone??"main";let h=r.document;if("footnote"===m&&r.activeFootnoteId&&r.document.footnotes?.items[r.activeFootnoteId]){const e=r.document.footnotes,t=e.items[r.activeFootnoteId],n=f(t.blocks);g&&(h={...r.document,footnotes:{...e,items:{...e.items,[r.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=wo(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const a="header"===m?"header":"footer"===m?"footer":"blocks",i=f(o[a]??[]);if(g){const e=[...t];e[n]={...o,[a]:i},h={...r.document,sections:e}}}if(!g)return e;const b=o[o.length-1],y="paragraph"!==b.type||s.length?ot(u,0):ot(b,oe(b));return{...r,document:h,selection:nt(y)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=_o(e.selection)?e:Ke(e),{paragraph:o,index:r,offset:a}=E(n),i=function(e){switch(e.document.design?.effectsId){case"flat":return{fill:"#e2e8f0",border:"#64748b"};case"intense":return{fill:"#0f766e",border:"#115e59"};case"moderate":return{fill:"#5b9bd5",border:"#2f75b5"};default:return{fill:"#4472C4",border:"#2F528F"}}}(n),l={width:150,height:100,blocks:[Bo("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:Bh(void 0,"front")},s=Kn("",Et(o,a),void 0,l),c=Y(o,a,[s]),d=Oo(n).map((e,t)=>t===r?c:Kt(e));return la(n,d,nt(ot(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Ix(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:Bi}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Ix(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Mi}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Ix(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:Fi}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=Oo(e).map((e,n)=>n!==r?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id!==a.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:Cx(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Cx(e.textBox.floating,t)}}:o(e))});return la(e,i,xe(i,hr(e)))}(e,t),{mergeKey:Ai}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=e=>({...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none",behindDoc:"back"===t}),l=Oo(e).map((e,t)=>t!==r?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id!==a.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:i(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:i(e.textBox.floating)}}:o(e))});return la(e,l,xe(l,hr(e)))}(e,t),{mergeKey:Oi}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const r=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!r)return e;const{paragraphIndex:a,run:i}=r,l=Oo(e).map((e,r)=>r!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:Tx(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Tx(e.textBox.floating,t,n)}}:o(e))});return la(e,l,xe(l,hr(e)))}(e,t,n),{mergeKey:Di}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=Oo(e).map((e,n)=>n!==r?Kt(e):{...Kt(e),runs:e.runs.map(e=>{if(e.id!==a.id)return o(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?Fh(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?Fh(n,t):n}}}return o(e)})});return la(e,i,xe(i,hr(e)))}(e,t),{mergeKey:Ei}),setFloatingRotation:t=>e.applyTransactionalState(e=>Px(e,t),{mergeKey:Li}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>Bh(e,t),{paragraphIndex:a,run:i}=n,l=Oo(e).map((e,t)=>t!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>{if(e.id!==i.id)return o(e);if("image"===e.kind){const t=r(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=r(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return o(e)})});return la(e,l,xe(l,hr(e)))}(e,t),{mergeKey:Ni}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:a,run:i}=n,l=Oo(e).map((e,t)=>t!==a?Kt(e):{...Kt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:r(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:r(e.textBox.floating)}}:o(e))});return la(e,l,xe(l,hr(e)))}(e,t),{mergeKey:$i}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Rh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:r,v:a}=function(e){return{h:e.endsWith("Left")?"left":e.endsWith("Right")?"right":"center",v:e.startsWith("top")?"top":e.startsWith("bottom")?"bottom":"ctr"}}(t),i={relativeFrom:"margin",align:r,offset:0},l={relativeFrom:"margin",align:a,offset:0},{paragraphIndex:s,run:c}=n,d=Oo(e).map((e,t)=>t!==s?Kt(e):{...Kt(e),runs:e.runs.map(e=>{if(e.id!==c.id)return o(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:i,positionV:l};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:i,positionV:l};return{...e,textBox:{...e.textBox,floating:t}}}return o(e)})});return la(e,d,xe(d,hr(e)))}(e,t),{mergeKey:zi}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Ix(e,e=>({...e,preset:t}))}(e,t),{mergeKey:Hi}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Bx(e,e=>({...e,vert:n}))}(e,t),{mergeKey:Wi}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Bx(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:Ui}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:ji}),rotateTextBox:t=>e.applyTransactionalState(e=>kx(e,t),{mergeKey:Vi}),getTextBoxSizeCm:()=>function(e){const t=gb(e),n=t&&Qt(t.run);return n?{width:n.width/gr,height:n.height/gr}:null}(e.state()),isTextBoxSelected:()=>null!==gb(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,width:Math.max(24,Math.round(t*gr))}))}(e,t),{mergeKey:Ki}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,height:Math.max(24,Math.round(t*gr))}))}(e,t),{mergeKey:_i})}}function Fx(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!_o(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function Ax(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=Oh(e),n=t&&Ut(t.run);return n?{width:n.width/gr,height:n.height/gr}: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=Oh(e);return(t&&Ut(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=Oh(e);return(t&&Ut(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=Oh(e),n=t&&Ut(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==Oh(e.state())}}function Ox(e){const t=e.state,n={state:t,isReadOnly:e.isReadOnly,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput};return{canCut:ks,cut:()=>{Fs(n)},canPaste:Es,paste:()=>{Ls(n,"rich")},pasteAsPlainText:()=>{Ls(n,"text")},pasteMergeFormatting:()=>{Ls(n,"merge")},hasSelection:()=>Is(t()).length>0,copy:()=>{Ms(t())}}}function Dx(e,t){const n=Un(e),o=He(e.document);if("header"===n||"footer"===n){const r=Fn(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=rn(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=Fn(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 Ex(e,t){return null!==Nx(e,t)}function Lx(e,t){const n=Nx(e,t);if(!n)return e;const{nextBlocks:o}=n,r=Dx(e,o),a=o.flatMap(C);return{...r,selection:$x(e.selection,a)}}function Nx(e,t){const n=Un(e);if("footnote"===n)return null;const o=Jo(e,n);if(0===o.length)return null;const r=hr(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let l=n;l<=o;l+=1){const e=t[l];if(void 0===e)return null;r.add(e)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==e[l].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{C(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:l}=a,s=o.slice(i,l+1);let c;if("up"===t){if(0===i)return null;const e=o[i-1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i-1),...s,e,...o.slice(l+1)]}else{if(l===o.length-1)return null;const e=o[l+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...s,...o.slice(l+2)]}return{nextBlocks:c}}function $x(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 ot(r,Math.min(e.offset,oe(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function zx(e,t){const n=function(e){const t=Un(e);if("footnote"===t)return null;const n=Jo(e,t);if(0===n.length)return null;const o=hr(e),r=/* @__PURE__ */new Set;for(let l=o.startIndex;l<=o.endIndex;l+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=C(n[o]).length;if(l<e+r){t=o;break}e+=r}if(t<0)return null;r.add(t)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==n[l].type)return null;return{blocks:n,lo:a,hi:i}}(e);if(!n)return e;if(n.hi-n.lo<1)return e;const{lo:o,hi:r,blocks:a}=n,i=a.slice(o,r+1).map((e,t)=>({block:e,index:t,key:Hx(we(e))}));i.sort((e,n)=>{const o=function(e,t){const n=function(e,t){return void 0!==e&&void 0!==t?e===t?0:e<t?-1:1:void 0!==e?-1:void 0!==t?1:0}(e.num,t.num);return 0!==n?n:e.text.localeCompare(t.text,void 0,{sensitivity:"base"})}(e.key,n.key);return 0!==o?t?-o:o:e.index-n.index});const l=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],s=Dx(e,l),c=l.flatMap(C);return{...s,selection:Wx(e.selection,c)}}function Hx(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function Wx(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 ot(r,Math.min(e.offset,oe(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Ux(e,t){const n=hr(e),o=Oo(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=qn(o[l]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return Kt(e);const i=qn(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?Kt(e):(a=!0,ce(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return Kt(e);a=!0;const o=Kt(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return Kt(e);a=!0;const l=Kt(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?la(e,i,xe(i,n)):e}var jx=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function Vx(e,t){return Math.abs(e-t)<1e-6}function Kx(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var _x=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var Xx=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var Gx={width:1.5,type:"solid",color:"#000000"};function Yx(e,t){const n=t.text??we(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 qx(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=hr(e),o=Oo(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 _x.has(t)?t:a})();if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(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:Xx.has(t)?t:a;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressAutoHyphens,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressLineNumbers,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.kinsoku,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.overflowPunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.wordWrap,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDE,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDN,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.adjustRightInd,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.topLinePunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.pageBreakBefore,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepWithNext,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepLinesTogether,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.widowControl,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.contextualSpacing,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...Kt(e),style:l}});return r?la(e,a,xe(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.mirrorIndents,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...Kt(e),style:l}});return r?la(e,a,xe(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=r(e,"indentFirstLine",null);return n=r(n,"indentHanging",null),"firstLine"===t?n=r(n,"indentFirstLine",o):"hanging"===t&&(n=r(n,"indentHanging",o)),n},{mergeKey:Ha}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=r(e,"borderTop",t);return n=r(n,"borderRight",t),n=r(n,"borderBottom",t),n=r(n,"borderLeft",t),n},{mergeKey:Wa}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>r(e,"borderBottom",Gx),{mergeKey:Wa}),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=hr(e),o=Math.min(8,Math.max(0,Math.round(t))),r=Oo(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,ce(e,o)):e);return a?la(e,i,xe(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Ex(e.state(),"up")?(e.applyTransactionalState(e=>Lx(e,"up"),{mergeKey:Ua}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Ex(e.state(),"down")?(e.applyTransactionalState(e=>Lx(e,"down"),{mergeKey:ja}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Ex(e.state(),"up"),canMoveParagraphsDown:()=>Ex(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>Ux(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>Ux(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=hr(e),n=Oo(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||jx.every(e=>!(e in r)))return e;o=!0;const a=Kt(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?la(e,r,xe(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(e),r=e.document.styles,a=t.set??[],i=t.clear??[],l=Boolean(t.clearAll),s=void 0!==t.tabs||a.length>0||i.length>0||l;let c=!1;const d=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;if(!s)return e;const d=_e(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!Vx(e.position,t));return d.some(e=>Vx(e.position,t))&&n.push({position:t,type:"clear"}),n};let p=[...void 0!==t.tabs?(t.tabs??[]).map(e=>({...e})):(e.style?.tabs??[]).map(e=>({...e}))];if(l){p=[];for(const e of d)p=u(p,e.position)}for(const t of i)p=u(p,t);for(const t of a)p=p.filter(e=>!Vx(e.position,t.position)),p.push(Kx(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=Kt(e);return g.style={...e.style??{},tabs:p.length>0?p:null},c=!0,g});let u=c;const p=void 0!==t.default&&null!==t.default,g=e.document.settings?.defaultTabStop,f=p&&void 0!==t.default&&null!==t.default?Math.min(1584,Math.max(1,t.default)):void 0;if((p||null===t.default)&&(null===t.default?void 0!==g:void 0!==t.default&&g!==f)&&(u=!0),!u)return e;let m=la(e,d,xe(d,n));if(p||null===t.default){const n={...e.document.settings??{}};null===t.default?delete n.defaultTabStop:void 0!==t.default&&(n.defaultTabStop=f),m={...m,document:{...m.document,settings:n}}}return m}(e,t),{mergeKey:Xa}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=hr(e),o=Oo(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=Kt(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?la(e,i,xe(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return r(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>zx(e,t)),hasDropCap:()=>function(e){const t=hr(e);return Oo(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=hr(e),o=Oo(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,l=o.map((e,n)=>n<r||n>a?Kt(e):i?{...Kt(e),dropCap:void 0}:{...Kt(e),dropCap:Yx(e,{...t,type:"margin"===t.type?"margin":"drop"})});return la(e,l,xe(l,n))}(e,t)),e.focusInput()}}}function Zx(e){const t=He(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Fn(e),t.length-1))}}function Jx(e,t){const{sections:n,sectionIndex:o}=Zx(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 Qx(e,t,n="default"){const o=Yn(t,n);return Jx(e,e=>e[o]?e:{...e,[o]:[sn(t)]})}function ew(e,t,n="default"){const o=Yn(t,n),r=Jx(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:Un(r)===t?rw(r):r}function tw(e,t,n="default"){const o=Qx(e,t,n),{sections:r,sectionIndex:a}=Zx(o),i=(r[a][Yn(t,n)]??[]).flatMap(C).find(Boolean);return i?{...o,selection:co(ot(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function nw(e){const{sections:t,sectionIndex:n}=Zx(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function ow(e){const{sections:t,sectionIndex:n}=Zx(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function rw(e){const{sections:t,sectionIndex:n}=Zx(e),o=(t[n]?.blocks??[]).flatMap(C).find(Boolean);return o?{...e,selection:co(ot(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function aw(e){return function(e,t){const n=_o(e.selection)?e:Ke(e),{paragraph:o,index:r,offset:a}=E(n),i=U(o,0,a),l=U(o,a,oe(o)),s={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Et(o,a)},c=fe(o,[...i,s,...l]),d=Oo(n),u=[...tt(d.slice(0,r)),c,...tt(d.slice(r+1))];return la(n,u,nt(ot(c,a+s.text.length)))}(e,"PAGE")}function iw(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function lw(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},iw("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},iw("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[iw("PAGE",void 0,`run:page-field:${n}`,t)]}function sw(e,t="page",n){return function(e,t){const n=_o(e.selection)?e:Ke(e),{paragraph:o,index:r,offset:a}=E(n),i=Et(o,a),l=t.map((e,t)=>e.styles?e:{...e,styles:i,id:`${e.id}:${t}`}),s=fe(o,[...U(o,0,a),...l,...U(o,a,oe(o))]),c=Oo(n),d=[...tt(c.slice(0,r)),s,...tt(c.slice(r+1))],u=l.reduce((e,t)=>e+t.text.length,0);return la(n,d,nt(ot(s,a+u)))}(e,lw(t,n))}function cw(e){const t=He(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Fn(e),t.length-1))}}function dw(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return sw(e,o,r);const i="top"===t?"header":"footer",l=Yn(i,"default"),{sections:s,sectionIndex:c}=cw(e);if(0===s.length)return e;const d={id:kn("paragraph"),type:"paragraph",runs:lw(o,r),style:{styleId:i,align:a}},u={...s[c],[l]:[d]},p=[...s];return p[c]=u,{...e,document:{...e.document,sections:p},selection:co(ot(d,0)),activeSectionIndex:c,activeZone:i}}function uw(e){const t={isLandscape:()=>{const t=Fn(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=Fn(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=Fn(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=Fn(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=Fn(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=>ct(e,t)),e.focusInput()},getPageNumbering:()=>{const t=Fn(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=cw(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 ke(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>Gn(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>h(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>Hr(e,t)),e.focusInput()},getColumns:()=>to(e.state()),setColumns:t=>{e.applyTransactionalState(e=>Xr(e,t)),e.focusInput()},getVerticalAlign:()=>ea(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>ht(e,t)),e.focusInput()},getSectionStart:()=>{const t=Fn(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=Fn(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>Or(e.state()),setBidi:t=>{e.applyTransactionalState(e=>bn(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 pw(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>tw(e,"header")),editFooter:()=>t(e=>tw(e,"footer")),editFirstPageHeader:()=>t(e=>tw(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>tw(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>tw(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>tw(e,"footer","evenPage")),insertPageNumber:()=>t(e=>aw(e)),insertPageNumberXOfY:()=>t(e=>sw(e,"xOfY")),placePageNumberTop:()=>t(e=>dw(e,"top")),placePageNumberBottom:()=>t(e=>dw(e,"bottom")),exit:()=>t(e=>function(e){return rw(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>nw(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(nw(e)===t)return e;let n=e;return t?(n=Qx(n,"header","firstPage"),n=Qx(n,"footer","firstPage"),n):(n=ew(n,"header","firstPage"),ew(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>ow(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(ow(e)===t)return e;let n=e;return t?(n=Qx(n,"header","evenPage"),n=Qx(n,"footer","evenPage"),n):(n=ew(n,"header","evenPage"),ew(n,"footer","evenPage"))}(t,e))}}function gw(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function fw(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=hr(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:Go(),name:l,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[s.id]:s},order:[...i,s.id]},d={...e.document,bookmarks:c};return{...e,document:d}}(e,t)),e.focusInput()},remove:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.bookmarks;if(!n||!n.items[t])return e;const o={...n.items};delete o[t];const r={items:o,order:n.order.filter(e=>e!==t)};return{...e,document:{...e.document,bookmarks:r}}}(e,t)),e.focusInput()},list:()=>gw(e.state()).map(e=>({id:e.id,name:e.name}))}}var mw=["January","February","March","April","May","June","July","August","September","October","November","December"],hw=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function bw(e,t){let n="";const o=e=>String(e).padStart(2,"0");let r=0;const a=t;for(;r<a.length;){const t=a[r];let i=t;for(;r+i.length<a.length&&a[r+i.length]===t;)i+=t;const l=e.getHours();switch(t){case"d":n+=i.length>=4?hw[e.getDay()]:3===i.length?hw[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?mw[e.getMonth()]:3===i.length?mw[e.getMonth()].slice(0,3):2===i.length?o(e.getMonth()+1):String(e.getMonth()+1);break;case"y":n+=i.length>=3?String(e.getFullYear()):String(e.getFullYear()).slice(-2);break;case"H":n+=o(l);break;case"h":n+=i.length>=2?o(l%12==0?12:l%12):String(l%12==0?12:l%12);break;case"m":n+=i.length>=2?o(e.getMinutes()):String(e.getMinutes());break;case"s":n+=i.length>=2?o(e.getSeconds()):String(e.getSeconds());break;default:if(a.slice(r).toLowerCase().startsWith("am/pm")){n+=l<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}function yw(e,t){const n=t.type??"REF";if(!function(e,t){return gw(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=_o(e.selection)?e:Ke(e),{paragraph:r,index:a,offset:i}=E(o),l=Et(r,i),s={type:n,bookmark:t.bookmark},c={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:s,styles:l},d=fe(r,[...U(r,0,i),c,...U(r,i,oe(r))]),u=Oo(o),p=[...tt(u.slice(0,a)),d,...tt(u.slice(a+1))];return la(o,p,nt(ot(d,i+c.text.length)))}function vw(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,r=_o(e.selection)?e:Ke(e),{paragraph:a,index:i,offset:l}=E(r),s=Et(a,l),c=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},d={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:bw(o,n),kind:"field",field:c,styles:s},u=fe(a,[...U(a,0,l),d,...U(a,l,oe(a))]),p=Oo(r),g=[...tt(p.slice(0,i)),u,...tt(p.slice(i+1))],f=d.text.length;return la(r,g,nt(ot(u,l+f)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=bw(n,t);return 0===o.length?e:Zi(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>yw(e,t)),e.focusInput()}}}function xw(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=Fn(e),n=dt(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=He(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=M(o,n.tablePath);return r?.[r.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=ko(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(dt(e.state().document,e.state().selection.focus.paragraphId,Fn(e.state()))),selectionLabel:()=>{const t=e.state();if(hr(t).isCollapsed)return null;const n=Fn(t),o=dt(t.document,t.selection.anchor.paragraphId,n),r=dt(t.document,t.selection.focus.paragraphId,n),a=o?.tablePath[o.tablePath.length-1],i=r?.tablePath[r.tablePath.length-1];if(!o||!r||!a||!i||o.zone!==r.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(o.tablePath,r.tablePath)||a.rowIndex===i.rowIndex&&a.cellIndex===i.cellIndex)return null;const l=e.selectionBoxes().length;return 0===l?null:`Table selection: ${l} cell${1===l?"":"s"}`},getTblLook:()=>{const t=i(e.state());return t?{firstRow:t.firstRow,lastRow:t.lastRow,firstCol:t.firstCol,lastCol:t.lastCol,bandedRows:!t.noHBand,bandedCols:!t.noVBand}:null},toggleTblLook:e=>o(t=>{const n=i(t);if(!n)return t;const o={...n};switch(e){case"firstRow":o.firstRow=!n.firstRow;break;case"lastRow":o.lastRow=!n.lastRow;break;case"firstCol":o.firstCol=!n.firstCol;break;case"lastCol":o.lastCol=!n.lastCol;break;case"bandedRows":o.noHBand=!n.noHBand;break;case"bandedCols":o.noVBand=!n.noVBand}return Dl(t,"tblLook",o)},Ci),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Dl(t,"styleId",e||null),Ti),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Dl(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Pi),canSetAutoFit:()=>null!==bl(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Rl(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...ul(),type:"property",previous:{...r??{}}}});let a=pl(r,"layout",n);return"window"===t?a=pl(a,"width","100%"):"contents"===t&&(a=pl(a,"width",null)),{...o,style:a}})}(t,e),vi),distributeColumns:()=>o(e=>Rl(e,e=>{const t=Vt(e),n=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),o=(e.gridCols??[]).reduce((e,t)=>e+("number"==typeof t&&t>0?t:0),0),r=o>0?o:120*n,a=r/n,i=Array.from({length:n},()=>a),l=e.rows.map((e,n)=>({...e,cells:e.cells.map((e,o)=>{const r=t.find(e=>e.rowIndex===n&&e.cellIndex===o);return r?{...e,style:{...e.style??{},width:a*Math.max(1,r.colSpan)}}:e})}));return{...e,gridCols:i,rows:l,style:{...e.style??{},width:r}}}),Pi),distributeRows:()=>o(e=>Rl(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}}),Pi),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!==bl(e.state()),convertToText:()=>o(e=>Wl(e),pi),canConvertToTable:()=>{return!bl(t=e.state())&&null!==Tl(t);var t},convertToTable:()=>o(e=>Ul(e),gi),canSplitTableAtRow:()=>function(e){const t=bl(e);if(!t)return!1;const n=Cl(e);if(!n)return!1;const o=Sl(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=bl(e);if(!t)return e;const n=Cl(e);if(!n)return e;const o=Sl(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex;if(r<=0||r>=o.rows.length)return e;const a=o.rows.slice(0,r),i=o.rows.slice(r),l={...o,rows:a},s=tr(i),c=kl(e,[l,Bo(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:nt(ot(d,0))}:e}(e),fi),canSortTable:()=>function(e){const t=bl(e);if(!t)return!1;const n=Cl(e);if(!n)return!1;const o=Sl(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=>Vl(t,e),"ascending"===e?mi:hi),canDeleteTable:()=>null!==bl(e.state()),deleteTable:()=>o(e=>function(e){const t=bl(e);if(!t)return e;const n=Cl(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=Bo(""),n=kl(e,[t]);return n===e?e:{...n,selection:nt(ot(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=kl(e,[]);if(a===e)return e;if(r){const e=Oo(a).find(e=>e.id===r);if(e)return{...a,selection:nt(ot(e,0))}}return a}(e),bi),canToggleRepeatHeaderRows:()=>function(e){const t=bl(e);if(!t)return!1;const n=Cl(e);if(!n)return!1;const o=Sl(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=bl(e);if(!t)return!1;const n=Cl(e);if(!n)return!1;const o=Sl(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&_l(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=bl(e);if(!t)return e;const n=Cl(e);if(!n)return e;const o=Sl(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=_l(o.rows[0]);return Rl(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),xi),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),Ja),split:()=>o(t=>e.tableOps.splitSelectedTable(t),Qa),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),ei),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),ei),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),ti),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),ni),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),ni),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),oi),canDeleteCell:()=>is(e.state()),deleteCell:()=>o(e=>ls(e),yi),cellShading:e=>o(t=>Al(t,"shading",e||null),ri),cellBorders:()=>o(e=>Ol(e,{width:1,type:"solid",color:"#64748b"}),ai),cellNoBorders:()=>o(e=>Ol(e,{width:0,type:"none",color:"transparent"}),ai),applyBorderPreset:e=>o(t=>function(e,t,n=Bl){const o=Fl(e);if(!o)return e;const r=/* @__PURE__ */new Map,a=new Set(o.selectedEntries.map(e=>e.cell.id)),i=/* @__PURE__ */new Map;for(const m of o.entries)for(let e=m.visualRowIndex;e<m.visualRowIndex+m.rowSpan;e+=1)for(let t=m.visualColumnIndex;t<m.visualColumnIndex+m.colSpan;t+=1)i.set(`${e}:${t}`,m);const l=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},s=(e,t,o,r,a=n)=>{l(e,t,a),o&&o.cell.id!==e?.cell.id&&l(o,r,a)},c=(e,t=n)=>{if("top"===e||"bottom"===e){const n="top"===e?o.startRow:o.endRow,r=n+("top"===e?-1:1);for(let l=o.startCol;l<=o.endCol;l+=1){const o=i.get(`${n}:${l}`);o&&a.has(o.cell.id)&&s(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${l}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,l=r+("left"===e?-1:1);for(let n=o.startRow;n<=o.endRow;n+=1){const o=i.get(`${n}:${r}`);o&&a.has(o.cell.id)&&s(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${l}`),"left"===e?"borderRight":"borderLeft",t)}},d=()=>{for(let e=o.startRow+1;e<=o.endRow;e+=1)for(let t=o.startCol;t<=o.endCol;t+=1){const n=i.get(`${e-1}:${t}`),o=i.get(`${e}:${t}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderBottom",o,"borderTop")}},u=()=>{for(let e=o.startCol+1;e<=o.endCol;e+=1)for(let t=o.startRow;t<=o.endRow;t+=1){const n=i.get(`${t}:${e-1}`),o=i.get(`${t}:${e}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderRight",o,"borderLeft")}};switch(t){case"none":for(const e of o.selectedEntries)for(const t of["borderTop","borderRight","borderBottom","borderLeft","borderStart","borderEnd","borderTopLeftToBottomRight","borderTopRightToBottomLeft"])l(e,t,Ml);c("top",Ml),c("right",Ml),c("bottom",Ml),c("left",Ml);break;case"top":c("top");break;case"right":c("right");break;case"bottom":c("bottom");break;case"left":c("left");break;case"outside":c("top"),c("right"),c("bottom"),c("left");break;case"insideHorizontal":d();break;case"insideVertical":u();break;case"inside":d(),u();break;case"all":c("top"),c("right"),c("bottom"),c("left"),d(),u();break;case"diagonalDown":for(const e of o.selectedEntries)l(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)l(e,"borderTopRightToBottomLeft")}if(0===r.size)return e;const p=/* @__PURE__ */new Set;for(const m of o.entries)if(r.has(m.cell.id))for(const e of m.cell.blocks)for(const t of C(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:{...ul(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=pl(o,e,r);return{...t,style:o}},f=He(e.document).map(e=>({...e,blocks:Rt(e.blocks,p,g),header:e.header?Rt(e.header,p,g):void 0,footer:e.footer?Rt(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),ai),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Dl(e,"width","100%"),ii),alignLeft:()=>o(e=>Al(e,"horizontalAlign","left"),li),alignCenter:()=>o(e=>Al(e,"horizontalAlign","center"),li),alignRight:()=>o(e=>Al(e,"horizontalAlign","right"),li),setCellVerticalAlign:e=>o(t=>Al(t,"verticalAlign",e),si),setCellTextDirection:e=>o(t=>Al(t,"textDirection",e),ci),setCellWidth:e=>o(t=>function(e,t){return Al(e,"width",t)}(t,e),di),setCellNoWrap:e=>o(t=>function(e,t){return Al(e,"noWrap",t)}(t,e),di),setCellFitText:e=>o(t=>function(e,t){return Al(e,"fitText",t)}(t,e),di),canSetCellMargins:()=>null!==bl(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Al(n,"paddingTop",t.top)),void 0!==t.right&&(n=Al(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Al(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Al(n,"paddingLeft",t.left)),n}(t,e),wi),canSetCellSpacing:()=>Xl(e.state()),setCellSpacing:e=>o(t=>function(e,t){return Xl(e)?Dl(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),wi),canSetTableIndent:()=>Gl(e.state()),setTableIndent:e=>o(t=>function(e,t){return Gl(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Dl(e,"indentLeft",null):Dl(e,"indentLeft",Math.round(2*t)/2):e}(t,e),wi),canSetTableAlignment:()=>null!==bl(e.state()),setTableAlignment:e=>o(t=>ql(t,e),wi),canEvaluateTableFormula:()=>null!==bl(e.state()),evaluateTableFormula:e=>o(t=>Ql(t,e),Si),canSelectTable:()=>null!==bl(e.state()),selectTablePart:t=>e.applyState(rs(e.state(),t)),canSetActiveTableRowHeight:()=>null!==bl(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=Ll(n,"height",t.height),void 0!==t.heightRule&&(n=Ll(n,"heightRule",t.heightRule)),n}(t,e),Ii),canSetActiveTableRowBreakAcrossPages:()=>Zl(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Zl(e)?Ll(e,"cantSplit",null===t?null:!t):e}(t,e),Ii),canSetActiveTableRowHeader:()=>null!==bl(e.state()),setActiveTableRowHeader:e=>o(t=>Nl(t,e),xi),canSetActiveTableColumnWidth:()=>null!==bl(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=bl(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Sl(ml(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=Vt(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:Hl(e,a.id,{[l]:t})}(t,e),ui),canSetActiveTableWidth:()=>null!==bl(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=bl(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Sl(ml(e.document,o,r.zone),r.tablePath);return a?El(e,a.id,"width",t):e}(t,e),ii),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function ww(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>$v(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Ev[t]??Ev.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]=Lv[t]??Lv.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=>Nv(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return Nv(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return Nv(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 Sw(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,o)=>({execute:t,refresh:()=>({isEnabled:n(e),...o?.()})}));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:()=>({isEnabled:e(t),...o?.()})})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...Uv({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,link:e.link,command:t,valueCommand:o,actionCommand:r}),...jv({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...Vv({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...Kv({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...Gv({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...Yv({design:e.design,actionCommand:r}),..._v({bookmark:e.bookmark,actionCommand:r}),...Xv({fields:e.fields,actionCommand:r})}}}({gate:Zv(e),style:Jv(e),selection:Qv(e),history:ex(e),formatting:Sx(e),document:Mx(e),link:Fx(e),image:Ax(e),browser:Ox(e),paragraph:qx(e),section:uw(e),headerFooter:pw(e),table:xw(e),design:ww(e),bookmark:fw(e),fields:vw(e)})}var Iw=[{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",hidden:!0,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_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_comments_panel",path:"Review/Comments Panel",labelKey:"review.commentsPanel",command:"toggleCommentsPanel",icon:"list-filter"},{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",hidden:!0},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:e=>e.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:e=>e.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:e=>e.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_header",path:"Insert/Header",labelKey:"headerFooter.header",command:"editHeader",icon:"panel-top"},{id:"insert_footer",path:"Insert/Footer",labelKey:"headerFooter.footer",command:"editFooter",icon:"panel-bottom"},{id:"insert_page_number",path:"Insert/Page Number",labelKey:"headerFooter.pageNumber",icon:"hash"},{id:"insert_page_number_current",path:"Insert/Page Number/Current Position",labelKey:"headerFooter.pageNumberCurrent",command:"insertPageNumber"},{id:"insert_page_number_xofy",path:"Insert/Page Number/Page X of Y",labelKey:"headerFooter.pageNumberXOfY",command:"insertPageNumberXOfY"},{id:"insert_page_number_top",path:"Insert/Page Number/Top of Page",labelKey:"headerFooter.pageNumberTop",command:"placePageNumberTop"},{id:"insert_page_number_bottom",path:"Insert/Page Number/Bottom of Page",labelKey:"headerFooter.pageNumberBottom",command:"placePageNumberBottom"},{id:"insert_bookmark",path:"Insert/Bookmark",labelKey:"toolbar.bookmark",command:"insertBookmark",icon:"bookmark"},{id:"insert_date",path:"Insert/Date",labelKey:"toolbar.date",command:"insertDateField",icon:"calendar"},{id:"insert_specialChar",path:"Insert/Special Character",hidden:!0},{id:"insert_comment",path:"Insert/Comment",hidden:!0},{id:"format_text",path:"Format/Text",labelKey:"menu.format.text",icon:"type"},{id:"format_text_bold",path:"Format/Text/Bold",labelKey:"toolbar.bold",shortcut:"Ctrl+B",command:"bold",icon:"bold"},{id:"format_text_italic",path:"Format/Text/Italic",labelKey:"toolbar.italic",shortcut:"Ctrl+I",command:"italic",icon:"italic"},{id:"format_text_underline",path:"Format/Text/Underline",labelKey:"toolbar.underline",shortcut:"Ctrl+U",command:"underline",icon:"underline"},{id:"format_text_strike",path:"Format/Text/Strikethrough",labelKey:"toolbar.strike",command:"strike",icon:"strikethrough"},{id:"format_paragraphStyles",path:"Format/Paragraph styles",labelKey:"toolbar.style",hidden:!0},{id:"format_align",path:"Format/Align",labelKey:"menu.format.align",icon:"align-left"},{id:"format_align_left",path:"Format/Align/Left",labelKey:"toolbar.alignLeft",command:"alignLeft",icon:"align-left"},{id:"format_align_center",path:"Format/Align/Center",labelKey:"toolbar.alignCenter",command:"alignCenter",icon:"align-center"},{id:"format_align_right",path:"Format/Align/Right",labelKey:"toolbar.alignRight",command:"alignRight",icon:"align-right"},{id:"format_align_justify",path:"Format/Align/Justify",labelKey:"toolbar.justify",command:"alignJustify",icon:"align-justify"},{id:"format_lineSpacing",path:"Format/Line spacing",hidden:!0},{id:"format_lists",path:"Format/Lists",labelKey:"menu.format.lists",icon:"list"},{id:"format_lists_bullet",path:"Format/Lists/Bullet List",labelKey:"toolbar.bulletList",command:"bulletList",icon:"list"},{id:"format_lists_numbered",path:"Format/Lists/Numbered List",labelKey:"toolbar.numberedList",command:"orderedList",icon:"list-ordered"},{id:"format_clear",path:"Format/Clear formatting",hidden:!0},{id:"layout_orientation",path:"Layout/Orientation",labelKey:"section.orientation",icon:"layout"},{id:"layout_orientation_portrait",path:"Layout/Orientation/Portrait",labelKey:"section.portrait",command:{name:"setOrientation",payload:"portrait"},icon:e=>e.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:e=>e.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_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 Cw(t){const n=Sw(t.essentials),{runtimePlugins:o,toolbarRegistry:r,menuRegistry:a,dispose:i}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=Hn(),i=new e;for(const e of wr(t.t))a.register(e);for(const e of Iw)i.register(e);for(const e of n){for(const t of e.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",groupLabel:t.groupLabel,row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,ribbonGroupLayout:t.ribbonGroupLayout,order:t.order};a.register(e),o.push(t.id)}for(const t of e.menubar??[])i.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),r.push(t.id)}return t.customizeToolbar?.(a),t.customizeMenubar?.(i),{runtimePlugins:n,toolbarRegistry:a,menuRegistry:i,dispose:()=>{for(const e of o)a.remove(e);for(const e of r)i.unregister(e)}}}({essentialsPlugin:n,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),l=function(e){const[t,n]=Tt(!1),[o,r]=Tt(new Ur({doc:e.initialDocument}));let a=!1;const i=e=>{const t=Nr(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=ra(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=ra(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await Ur.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(a)return void(await t.destroy());const i=o();r(t),await i.destroy(),n(!0),requestAnimationFrame(()=>{e.onSettled?.(),e.onReady?.(t)})}catch(t){e.logger.error("runtime:init failed",t),e.onError?.(t),e.onSettled?.()}},dispose:async()=>{a=!0,await o().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:o,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return lr(()=>{l.initialize()}),be(()=>{l.dispose(),i()}),{toolbarRegistry:r,menuRegistry:a,runtimeReady:l.runtimeReady,runtimeEditor:l.runtimeEditor,commandStateOf:l.commandStateOf,toolbarHost:l.toolbarHost}}function Tw(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Rv({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}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:c,toolbarRegistry:d,menuRegistry:u}=Cw({essentials:{state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:r,keyboardCommandsController:a,historyActions:t.historyActions,styleController:n.styleController,formatPainter:n.formatPainter,commentComposer:e.commentComposer,tableOps:n.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:n.selectedImageRun,imageCropMode:{isActive:n.imageOps.cropMode,toggle:n.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:n.fr.setIsOpen},newDocument:Bv({isDirty:()=>o.isDirty(),resetDocument:()=>o.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openTablePropertiesDialog:t=>{const n=ms(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=b(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})}},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,onReady:t=>{o.resolveReady(t),e.runtimeOptions().onReady?.(o)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>o.rejectReady(e)});(function(e,t){const n=()=>t.cloneState(t.getStateSnapshot());e.connectHost({getRuntimeEditor:()=>t.runtimeReady()?t.runtimeEditor():null,getState:()=>n(),getDocument:()=>n().document,setDocument:e=>{t.applyState(Ln(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=Sr();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=$v(e,n.themeId)),e=Nv(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({...n(),selection:e}),t.focusInput()},focus:()=>t.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.setFocused(!1)},clearHistory:()=>t.clearHistory(),importDocx:e=>t.docIO.handleImportFile(e),exportDocx:()=>Promise.resolve(t.docIO.handleExportDocx()),exportPdf:()=>Promise.resolve(t.docIO.handleExportPdf()),exportDocxBlob:()=>t.docIO.exportDocxBlob(),exportPdfBlob:()=>t.docIO.exportPdfBlob(),getUiState:t.getUiState,updateUiState:t.updateUiState,getZoom:t.getZoom,setZoom:t.setZoom,adjustZoom:t.adjustZoom,toolbarRegistry:t.toolbarRegistry,menuRegistry:t.menuRegistry})})(o,{runtimeReady:i,runtimeEditor:l,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:d,menuRegistry:u}),g(()=>{if(!i())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());l().dispatch(()=>t)});const{handleKeyDown:p}=function(e){const{state:t,isReadOnly:n,logger:o,focusInput:r,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:g,historyActions:f,styleController:m,findReplace:h,runtimeEditor:b}=e,{handleKeyDown:y}=Av({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:u,selectedImageRun:d,setForcePlainTextPaste:c,moveSelectionByWord:g.moveSelectionByWord,moveSelectionToDocumentBoundary:g.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:g.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:g.moveVerticalSelection,moveVerticalByBlock:g.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleReplace:e=>{h.setIsOpen(e??!h.isOpen())},executeCommand:(e,t)=>b().commands.execute(e,t),canExecuteCommand:e=>b().commands.canExecute(e)});return{handleKeyDown:e=>{Ov.includes(e.key)&&m.clearPendingCaretTextStyle();const n=[e.ctrlKey?"Ctrl":null,e.metaKey?"Meta":null,e.altKey?"Alt":null,e.shiftKey?"Shift":null].filter(Boolean).join("+"),r=n?`${n}+${e.key}`:e.key,a=t().selection;o.debug(`key:down ${r} at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}]`),cn("input-to-layout"),y(e),Qn("input-to-layout")}}}({state:()=>e.state,isReadOnly:e.isReadOnly,logger:e.logger,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,setForcePlainTextPaste:e.setForcePlainTextPaste,selectedImageRun:n.selectedImageRun,commandsController:a,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:c,toolbarRegistry:d,menuRegistry:u,handleKeyDown:p}}(e)}function Pw(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 kw(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=Pw(e,n.commentId)??Pw(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 Rw(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 Bw(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!Rw(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),!Rw(e,t.items[i]))return!1;r.push(i)}}return!0}function Mw(e){const[t,n]=Tt(null),[o,r]=Tt(""),[a,i]=Tt(!1),l=()=>e.access?.(),s=()=>{const e=l()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},c=()=>!(e.isReadOnly()||l()&&null===s()),d=()=>c()&&null!==P(e.state()),u=t=>c()&&Boolean(e.state().document.comments?.items[t]),p=()=>c()&&null!==px(e.state()),g=t=>!e.isReadOnly()&&Rw(l(),e.state().document.comments?.items[t]),f=()=>{const t=px(e.state());return null!==t&&g(t.id)},m=t=>!e.isReadOnly()&&Bw(l(),e.state().document.comments,t),h=g,b=(e="Local editor")=>{const t=s();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},y=(e,t,n,o,r,a)=>kw(e,t,{id:kn("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||!Bw(l(),r.document.comments,t))return r;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const o=/* @__PURE__ */new Set([t]),r=[t],a=/* @__PURE__ */new Map;for(const l of Object.values(n.items)){if(!l.parentId)continue;const e=a.get(l.parentId)??[];e.push(l.id),a.set(l.parentId,e)}for(;r.length>0;){const e=r.pop();for(const t of a.get(e)??[])o.has(t)||(o.add(t),r.push(t))}const i=Object.fromEntries(Object.entries(n.items).filter(([e])=>!o.has(e)));return{...e,document:{...e.document,comments:{...n,items:i,order:n.order.filter(e=>!o.has(e))}}}}(r,t);return o=a.document!==r.document,o?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||!Rw(l(),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=px(e.state());return null!==t&&m(t.id)},deleteSelected:()=>{const t=px(e.state());return!!t&&S(t.id)},deleteById:S,canResolveId:h,canResolveSelected:()=>{const t=px(e.state());return null!==t&&h(t.id)},resolveSelected:t=>{const n=px(e.state());return!!n&&I(n.id,t)},resolveById:I,authorName:()=>s()?.displayName??o(),authorLocked:()=>void 0!==l(),openNew:()=>!!d()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!p())return!1;const t=px(e.state());return!!t&&v(t.id)},openReplyToId:v,openEdit:()=>{if(!f())return!1;const t=px(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()??"":s()?.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:kn("comment"),author:i,...s()?{authorId:s().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&&!Rw(l(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!c())return t;const n="edit"===a.mode?F(t,a.commentId,d):"reply"===a.mode?Io(t,a.parentId,u):Ue({...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 Fw=/*#__PURE__*/z("<div class=oasis-review-comments-filters role=group>"),Aw=/*#__PURE__*/z("<div class=oasis-review-comments-list>"),Ow=/*#__PURE__*/z("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),Dw=/*#__PURE__*/z("<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>"),Ew=/*#__PURE__*/z("<div class=oasis-review-thread-replies>"),Lw=/*#__PURE__*/z("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),Nw=/*#__PURE__*/z("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),$w=/*#__PURE__*/z("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function zw(e){const t=x(),[n,o]=Tt("all"),[r,a]=Tt(!1),[i,l]=Tt(""),[s,c]=Tt(null),[d,u]=Tt(null),p=()=>e.state().document.comments,g=At(()=>{const e=p();if(!e)return[];const t=i().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(o=>("open"!==n()||!o.resolved)&&(!("resolved"===n()&&!o.resolved)&&(!t||[o,...yt(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),f=e=>yt(p()?.items??{},e),m=At(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),h=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",b=t=>{d()===t?e.composer.deleteById(t)&&(u(null),s()===t&&c(null)):u(t)};return y=Dw(),v=y.firstChild,w=v.nextSibling,je(v,ua(Er,{as:"strong",get children(){return t("review.commentsPanel")}}),null),je(v,ua(Le,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),je(w,ua(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),je(w,ua(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return r()},onClick:()=>{a(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),je(y,ua(Er,{as:"p",get children(){return Co(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${p()?.order.length??0}`}}),null),je(y,ua(eo,{get label(){return Co(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),je(y,ua(it,{get when(){return!r()},get children(){return[(a=Fw(),je(a,ua(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),je(a,ua(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),je(a,ua(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),Q(()=>yo(a,"aria-label",t("review.filterComments"))),a),(r=Aw(),je(r,ua(it,{get when(){return 0===g().length},get children(){return ua(Er,{as:"p",get children(){return t("review.noComments")}})}}),null),je(r,ua(Ce,{get each(){return g()},children:n=>{return o=Lw(),r=o.firstChild,a=r.nextSibling,je(r,ua(Er,{as:"strong",get children(){return n.author||"—"}}),null),je(r,ua(Er,{as:"span",get children(){return Co(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),je(o,ua(Er,{as:"p",get children(){return n.text}}),a),je(a,ua(Le,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),je(a,ua(it,{get when(){return e.composer.canEditId(n.id)},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),je(a,ua(it,{get when(){return e.composer.canResolveId(n.id)},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return Co(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),je(a,ua(it,{get when(){return e.composer.canReplyId(n.id)},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),je(a,ua(it,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[ua(Le,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-comment-delete",get children(){return Co(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),ua(it,{get when(){return d()===n.id},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),je(o,ua(it,{get when(){return f(n.id).length>0},get children(){return ua(Le,{size:"sm",variant:"ghost",get"aria-expanded"(){return s()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{c(s()===n.id?null:n.id)},get children(){return Co(()=>s()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${f(n.id).length})`}})}}),null),je(o,ua(it,{get when(){return s()===n.id},get children(){var o=Ew();return je(o,ua(Ce,{get each(){return f(n.id)},children:n=>{return o=Nw(),r=o.firstChild,je(o,ua(Er,{as:"strong",get children(){return n.author||"—"}}),r),je(o,ua(Er,{as:"p",get children(){return n.text}}),r),je(r,ua(it,{get when(){return e.composer.canEditId(n.id)},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),je(r,ua(it,{get when(){return e.composer.canReplyId(n.id)},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),je(r,ua(it,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[ua(Le,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-reply-delete",get children(){return Co(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),ua(it,{get when(){return d()===n.id},get children(){return ua(Le,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),Q(()=>yo(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),Q(()=>yo(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),je(y,ua(it,{get when(){return r()},get children(){var n=Ow();return je(n,ua(it,{get when(){return 0===m().length},get children(){return ua(Er,{as:"p",get children(){return t("review.activity.empty")}})}}),null),je(n,ua(Ce,{get each(){return m()},children:n=>{return o=$w(),r=o.firstChild,je(r,ua(Er,{as:"strong",get children(){return n.actorName}}),null),je(r,ua(Er,{as:"span",get children(){return h(n.timestamp)}}),null),je(o,ua(Er,{as:"p",get children(){return[Co(()=>(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))," — ",Co(()=>n.targetAuthor),Co(()=>Co(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),je(o,ua(it,{get when(){return Boolean(p()?.items[n.commentId])},get children(){return ua(Le,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),Q(()=>yo(o,"data-activity-kind",n.kind)),o;var o,r}}),null),Q(()=>yo(n,"aria-label",t("review.activity.title"))),n}}),null),Q(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&yo(y,"aria-label",e.e=n),o!==e.t&&yo(w,"aria-label",e.t=o),e},{e:void 0,t:void 0}),y;var y,v,w}var Hw=/*#__PURE__*/z('<div class="oasis-editor-shell oasis-editor-app">');function Ww(e={}){const t=e.runtime?.client??i(),[n,o]=Tt({}),r=()=>({...e.ui??{},...n(),toolbar:{...e.ui?.toolbar??{},...n().toolbar??{}}}),a=()=>({...e.document??{},...void 0===n().readOnly?{}:{readOnly:n().readOnly}}),l=()=>({...r(),readOnly:a().readOnly}),s=()=>e.runtime??{};va();const c=Vr(()=>r().locale??"pt-BR"),d=y("app"),{state:u,commitState:p,getStateSnapshot:g}=function(e){const t=e.initialState?hn(e.initialState):e.initialDocument?Ln(e.initialDocument):Sr();let n=t;const[o,r]=Tt(t);return{state:new Proxy({},{get(e,t){const n=o();if(null!==n&&("object"==typeof n||"function"==typeof n))return Reflect.get(n,t)},has(e,t){const n=o();return null!==n&&("object"==typeof n||"function"==typeof n)&&Reflect.has(n,t)},ownKeys(e){const t=o();return null===t||"object"!=typeof t&&"function"!=typeof t?[]:Reflect.ownKeys(t)},getOwnPropertyDescriptor(e,t){const n=o();return null===n||"object"!=typeof n&&"function"!=typeof n?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(n,t),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:e=>{const t=no(e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),f=e=>{p(e)},m=hn;let h=!1;const{showChrome:b,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,toolbarView:C,toolbarLayout:T,isReadOnly:P,useComposedShell:k,loadingOptions:R,loadingLabel:B,shellComponent:M}=function(e){const{ui:t,documentOptions:n}=e,o=()=>{const e=t().loading;return"object"==typeof e&&null!==e?e:void 0};return{showChrome:()=>t().showChrome??!0,showTitleBar:()=>t().showTitleBar??!0,showMenubar:()=>t().showMenubar??!0,showToolbar:()=>t().showToolbar??!0,showOutline:()=>t().showOutline??!0,toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>n().readOnly??!1,useComposedShell:()=>"docs"===t().uiVariant||"document"!==(t().shell??"document"),loadingOptions:o,loadingLabel:()=>o()?.label??"Loading oasis-editor...",shellComponent:()=>{const e=t().shell??"document";return"inline"===e?_r:"balloon"===e?S:xt}}}({ui:r,documentOptions:a}),F=function(){const[e,t]=Tt(!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}}}(),A=F.focused,O=F.setFocused,D=F.focusInput,E=F.focusInputAfterPointerSelection,L=F.focusInputSync,[N,$]=Tt(!1!==r().loading),z=W(),{linkDialog:H,setLinkDialog:U,imageAltDialog:j,setImageAltDialog:V,imageCaptionDialog:K,setImageCaptionDialog:_,contextMenu:X,setContextMenu:G,fontDialog:Y,setFontDialog:q,paragraphDialog:Z,setParagraphDialog:ee,tablePropertiesDialog:te,setTablePropertiesDialog:ne,newDocumentDialog:oe,setNewDocumentDialog:re,symbolDialog:ae,setSymbolDialog:ie,equationDialog:le,setEquationDialog:se}=function(){const[e,t]=Tt({isOpen:!1}),[n,o]=Tt({isOpen:!1}),[r,a]=Tt({isOpen:!1}),[i,l]=Tt({isOpen:!1,initialHref:""}),[s,c]=Tt({isOpen:!1,initialAlt:""}),[d,u]=Tt({isOpen:!1,initialCaption:""}),[p,g]=Tt({isOpen:!1,x:0,y:0}),[f,m]=Tt({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]=Tt({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]=Tt({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""}});return{newDocumentDialog:e,setNewDocumentDialog:t,symbolDialog:n,setSymbolDialog:o,equationDialog:r,setEquationDialog:a,linkDialog:i,setLinkDialog:l,imageAltDialog:s,setImageAltDialog:c,imageCaptionDialog:d,setImageCaptionDialog:u,contextMenu:p,setContextMenu:g,fontDialog:f,setFontDialog:m,paragraphDialog:h,setParagraphDialog:b,tablePropertiesDialog:y,setTablePropertiesDialog:v}}(),[ce,de]=Tt(!1),ue=()=>F.viewportRef,pe=()=>F.surfaceRef,ge=pb({documentOptions:a,logger:d,runtimeClient:t,state:u,commitState:p,getStateSnapshot:g,applyState:f,cloneState:m,isReadOnly:P,focusInput:D,surfaceRef:pe,viewportRef:ue,zoomFactor:z.zoomFactor,getImageOps:()=>Ne.imageOps}),{docIO:fe,measuredBlockHeights:me,measuredParagraphLayouts:he,documentLayout:ye,canvasSnapshotProvider:ve,inputBox:xe,selectionBoxes:we,commentHighlights:Se,selectedImageBox:Ce,selectedTextBoxBox:Te,selectedTableBox:Pe,caretBox:ke,preferredColumnX:Re,setPreferredColumnX:Be,clearPreferredColumn:Me,onCleanupHook:Ae,persistenceStatus:Oe,applyTransactionalState:De,resetTransactionGrouping:Ee,updateHistoryState:Le}=ge,Ne=fv({state:u,logger:d,isReadOnly:P,applyState:f,cloneState:m,focusInput:D,focusInputAfterPointerSelection:E,focusInputSync:L,surfaceRef:pe,viewportRef:ue,zoomFactor:z.zoomFactor,insertImageFromFile:fe.insertImageFromFile,getForcePlainTextPaste:()=>h,setForcePlainTextPaste:e=>{h=e},getCommandsController:()=>at.commandsController,applyTransactionalState:De,clearPreferredColumn:Me,resetTransactionGrouping:Ee,updateHistoryState:Le,caretBox:ke,preferredColumnX:Re,setPreferredColumnX:Be,measuredBlockHeights:me,measuredParagraphLayouts:he,documentLayout:ye,canvasSnapshotProvider:ve,openEquationDialog:(e,t)=>{se({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:$e,fr:ze,tableOps:He,imageOps:We,textBoxOps:Ue,styleController:Ve,onEditorPointerDown:Ke,tableResize:_e,tableCornerResize:Xe,tableDrag:Ge,revisionController:Ye,textDrag:qe,surfaceEventsWithTextDrag:Ze,textInput:Je,handleCopy:Qe,handleCut:et,handlePaste:tt,handleDrop:nt}=Ne,rt=Mw({state:()=>u,isReadOnly:P,applyTransactionalState:De,focusInput:D,access:()=>s().review}),at=Tw({document:ge,interaction:Ne,commentComposer:rt,state:u,logger:d,isReadOnly:P,focusInput:D,applyState:f,getStateSnapshot:g,cloneState:m,setFocused:O,setInitialLoading:$,getForcePlainTextPaste:()=>h,setForcePlainTextPaste:e=>{h=e},locale:()=>r().locale??"pt-BR",translator:c,runtimeClient:t,runtimeOptions:s,documentOptions:a,getUiState:l,updateUiState:e=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...l(),...e}),zoom:z,importInputRef:()=>F.importInputRef,imageInputRef:()=>F.imageInputRef,setLinkDialog:U,setImageAltDialog:V,setImageCaptionDialog:_,setNewDocumentDialog:re,setSymbolDialog:ie,setEquationDialog:se,setTablePropertiesDialog:ne}),{commandsController:lt,runtimeReady:st,runtimeEditor:ct,toolbarHost:dt,toolbarRegistry:pt,menuRegistry:ft,handleKeyDown:mt}=at,{computeFontFamilyOptions:ht,computeFontSizeOptions:bt,applyFontDialogValues:yt,applyParagraphDialogValues:vt,setParagraphDialogDefault:wt,applyTablePropertiesDialogValues:St,buildContextMenuItems:It,handleEditorContextMenu:Ct,closeContextMenu:Pt}=zs({state:()=>u,selection:()=>u.selection,toolbarStyleState:Ve.toolbarStyleState,isReadOnly:P,t:c,logger:d,setFontDialog:q,setParagraphDialog:ee,setTablePropertiesDialog:ne,setContextMenu:G,clearPreferredColumn:Me,resetTransactionGrouping:Ee,applyTransactionalState:De,applyTableAwareParagraphEdit:He.applyTableAwareParagraphEdit,focusInput:D,promptForLink:lt.promptForLink,tableOps:He}),{layout:kt,overlays:Rt,refs:Bt,surfaceHandlers:Mt,inputHandlers:Ft,fileHandlers:At}=function(e){const{layout:t,overlays:n,refs:o,surface:r,input:a,files:i}=e;return{layout:{documentLayout:t.documentLayout,remoteWebFonts:t.remoteWebFonts,viewportHeight:t.viewportHeight,class:t.className,style:t.style,zoomPercent:t.zoomPercent,setZoomPercent:t.setZoomPercent,zoomFactor:t.zoomFactor},overlays:{selectionBoxes:n.selectionBoxes,commentHighlights:n.commentHighlights,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:ye,remoteWebFonts:a().remoteWebFonts,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:z.zoomPercent,setZoomPercent:z.setZoomPercent,zoomFactor:z.zoomFactor},overlays:{selectionBoxes:we,commentHighlights:Se,onReplyToComment:e=>{rt.openReplyToId(e)},onEditComment:e=>{rt.openEditToId(e)},canEditComment:rt.canEditId,canReplyComment:rt.canReplyId,selectedImageBox:Ce,selectedTextBoxBox:Te,selectedTableBox:Pe,layoutOptions:$e,caretBox:ke,inputBox:xe,hoveredRevision:Ye.hoveredRevision,focused:A,showCaret:()=>function(e,t){if(!t.visible||!_o(e.selection))return!1;const n=Fn(e),o=Gr(e.document,e.selection.anchor.paragraphId,n),r=Gr(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(u,ke()),importProgress:fe.importProgress,imageCropMode:We.cropMode},refs:{focusController:F},files:{handleImportFile:fe.handleImportFile,handleInsertImage:fe.handleInsertImage},surface:{surfaceEvents:Ze,tableResize:_e,tableCornerResize:Xe,tableDrag:Ge,revisionController:Ye,handleDrop:nt,onEditorPointerDown:Ke,handleImagePointerDown:We.handleImagePointerDown,handleImageResizeHandlePointerDown:We.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:Ue.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:We.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:We.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:We.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:Ue.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:Ct},input:{textInput:Je,setFocused:O,handleCopy:Qe,handleCut:et,handlePaste:tt,handleKeyDown:e=>{if("Escape"===e.key&&Ne.formatPainter.mode())return Ne.formatPainter.cancel(),void e.preventDefault();mt(e)},handleKeyUp:e=>{Ne.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Ne.formatPainter.applyToSelection("keyboard")}}});return lr(()=>{Yr(),Sn(),io(),aa(()=>pe()??null),Ie(),!J()&&da()&&de(!0)}),be(()=>{Ae(),Ze.stopDragging(),qe.stopDrag(),_e.stop(),Xe.stop(),Ge.stop(),We.stopImageDrag(),We.stopImageResize(),We.stopImageCrop(),Ue.stopTextBoxResize(),ut()}),ua(gt,{translator:c,get children(){var e=Hw();return Fe(e,"--oasis-editor-gutter-x","34px"),je(e,ua(it,{get when(){return Co(()=>!(k()||!b()))()&&w()},get children(){return ua(tn,{host:dt,registry:pt,get view(){return C()},get layout(){return T()}})}}),null),je(e,ua(it,{get when(){return rt.panelOpen()},get children(){return ua(zw,{state:()=>u,composer:rt,locale:()=>r().locale??"pt-BR",get onClose(){return rt.closePanel},onNavigate:e=>{const t=function(e,t){const n=e.document.comments?.items;if(!n?.[t])return e;let o=n[t];const r=/* @__PURE__ */new Set;for(;o&&!o.start&&o.parentId&&!r.has(o.id);)r.add(o.id),o=n[o.parentId];const a=o?.start,i=o?.end;if(!a||!i)return e;const l=Oo(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:ot(s,a.offset),focus:ot(c,i.offset)}}:e}(u,e);t!==u&&(f(t),D())}})}}),null),je(e,ua(bd,{commentComposer:rt,dialogs:{linkDialog:H,setLinkDialog:U,imageAltDialog:j,setImageAltDialog:V,imageCaptionDialog:K,setImageCaptionDialog:_,contextMenu:X,setContextMenu:G,fontDialog:Y,setFontDialog:q,paragraphDialog:Z,setParagraphDialog:ee,tablePropertiesDialog:te,setTablePropertiesDialog:ne,newDocumentDialog:oe,setNewDocumentDialog:re,symbolDialog:ae,setSymbolDialog:ie,equationDialog:le,setEquationDialog:se},findReplace:ze,fontFamilyOptions:ht,fontSizeOptions:bt,contextMenuItems:It,focusInput:D,get applyLinkCommand(){return lt.applyLinkCommand},get applyImageAltCommand(){return lt.applyImageAltCommand},get applyImageCaptionCommand(){return lt.applyImageCaptionCommand},applyFontDialogValues:yt,applyParagraphDialogValues:vt,setParagraphDialogDefault:wt,applyTablePropertiesDialogValues:St,confirmNewDocument:()=>t.resetDocument(),insertSymbol:(e,t)=>{ct().commands.execute("insertText",{text:e,fontFamily:t}),D()},applyEquation:(e,t)=>{t?ct().commands.execute("updateEquation",{runId:t,expression:e}):ct().commands.execute("insertEquation",e),D()},closeContextMenu:Pt}),null),je(e,ua(vd,{useComposedShell:k,shellComponent:M,runtime:{state:()=>u,toolbarHost:dt,runtimeEditor:ct,persistenceStatus:Oe,toolbarRegistry:pt,menuRegistry:ft},chrome:{showChrome:b,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,toolbarView:C,toolbarLayout:T},view:{isReadOnly:P,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:me,measuredParagraphLayouts:he,documentLayout:ye,layout:kt,overlays:Rt,refs:Bt,surfaceHandlers:Mt,inputHandlers:Ft,fileHandlers:At}}),null),je(e,ua(Ks,{state:u,get surfaceRef(){return pe()},documentLayout:ye,snapshotProvider:ve,get zoomFactor(){return z.zoomFactor},tableResize:_e,tableCornerResize:Xe,imageOps:We,tableDrag:Ge,textDrag:qe}),null),je(e,ua(it,{get when(){return N()||!st()},get children(){return ua(wn,{get label(){return B()},get class(){return R()?.class},get style(){return R()?.style}})}}),null),je(e,ua(wd,{get isOpen(){return Co(()=>!(!ce()||N()))()&&st()},onClose:()=>de(!1)}),null),Q(t=>{var n=r().theme??"light",o=!!k(),a=!!P(),i=!(null===Ne.formatPainter.mode());return n!==t.e&&yo(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-format-painter-active",t.o=i),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e}})}export{Ww as OasisEditorApp};
|