oasis-editor 0.0.119 → 0.0.121
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-1pwk-3zw.js → OasisEditorApp-XzK_1rLE.js} +3 -3
- package/dist/adapters/vue.d.ts +2 -1
- package/dist/app/controllers/useEditorLayout.d.ts +2 -2
- package/dist/{index-rlmjHSGT.js → index-DF_Uf74V.js} +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/ui/OasisEditorApp.d.ts +2 -1
- package/dist/ui/OasisEditorAppLazy.d.ts +2 -1
- package/dist/ui/app/EditorDialogsLayer.d.ts +2 -2
- package/dist/ui/app/EditorDragLayers.d.ts +2 -1
- package/dist/ui/app/EditorWorkspace.d.ts +2 -2
- package/dist/ui/app/createEditorEssentialsPlugin.d.ts +2 -1
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +3 -2
- package/dist/ui/app/useEditorUiOptions.d.ts +3 -3
- package/dist/ui/components/CanvasEditorSurface.d.ts +2 -1
- package/dist/ui/components/CommentHighlightOverlay.d.ts +2 -2
- package/dist/ui/components/ContextMenu/ContextMenu.d.ts +2 -1
- package/dist/ui/components/Dialogs/LineSpacingDialog.d.ts +3 -1
- package/dist/ui/components/Dialogs/ParagraphDialog.d.ts +2 -1
- package/dist/ui/components/Dialogs/TextInputDialog.d.ts +3 -1
- package/dist/ui/components/Dialogs/table-properties/CellTabPanel.d.ts +2 -1
- package/dist/ui/components/Dialogs/table-properties/TableTabPanel.d.ts +2 -1
- package/dist/ui/components/DropCaret.d.ts +2 -1
- package/dist/ui/components/FindReplace/FindReplaceDialog.d.ts +2 -1
- package/dist/ui/components/Menubar/Menubar.d.ts +2 -1
- package/dist/ui/components/Outline/OutlinePanel.d.ts +2 -1
- package/dist/ui/components/Ruler/HorizontalRuler.d.ts +2 -2
- package/dist/ui/components/SelectionOverlay.d.ts +3 -1
- package/dist/ui/components/Toolbar/LineSpacingButton.d.ts +2 -1
- package/dist/ui/components/Toolbar/groups/TableGroup.d.ts +2 -1
- package/dist/ui/components/Toolbar/ribbon/RibbonRow.d.ts +2 -1
- package/dist/ui/components/Toolbar/ribbon/RibbonTabs.d.ts +2 -2
- package/dist/ui/components/WelcomeOverlay.d.ts +3 -1
- package/dist/ui/overlays/ResizeHandlesOverlay.d.ts +2 -1
- package/dist/ui/shells/DocumentShell.d.ts +2 -2
- package/dist/ui/shells/InlineShell.d.ts +2 -1
- package/dist/vue.d.ts +2 -1
- package/package.json +1 -1
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This source code is licensed under the ISC license.
|
|
23
23
|
* See the LICENSE file in the root directory of this source tree.
|
|
24
|
-
*/let tV=null;const eV={DEV:!1,MODE:"lib"};let aV=!1,nV=null,rV=null,oV=null,iV=[];function lV(){"undefined"!=typeof window&&(!function(){var t;const e=eV??{},a=(null==(t=globalThis.process)?void 0:t.env)??{};return!0===e.DEV||"test"===e.MODE||"test"===a.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?aV&&(delete window.__oasisCanvasDebug,aV=!1):aV||(window.__oasisCanvasDebug={getLastHit:()=>nV?{...nV}:null,getLayoutSnapshot:()=>rV?{...rV,surfaceRect:{...rV.surfaceRect},pages:rV.pages.map(t=>({...t})),paragraphs:rV.paragraphs.map(t=>({...t,lines:t.lines.map(t=>({...t,slots:t.slots.map(t=>({...t}))})),tableCell:t.tableCell?{...t.tableCell}:void 0})),inlineImages:rV.inlineImages.map(t=>({...t})),inlineTextBoxes:rV.inlineTextBoxes.map(t=>({...t})),unsupportedRegions:rV.unsupportedRegions.map(t=>({...t}))}:null,getSelection:()=>oV?{anchor:{...oV.anchor},focus:{...oV.focus},activeZone:oV.activeZone,activeSectionIndex:oV.activeSectionIndex}:null,getMissEvents:()=>iV.map(t=>({...t})),clearMissEvents:()=>{iV=[]}},aV=!0))}function sV(t){aV&&t&&(nV={timestamp:Date.now(),zone:t.zone,paragraphId:t.paragraphId,paragraphOffset:t.paragraphOffset,source:t.source,missReason:t.missReason,resolvedFromParagraph:t.resolvedFromParagraph})}const dV=["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 cV(t,e,a){const n=null==a?void 0:a.trim();if(!n)return;const r=n.toLowerCase();e.has(r)||(e.add(r),t.push(n))}function hV(t){const[e,a]=y([]);return{computeFontFamilyOptions:()=>function(t,e,a=[]){var n;const r=new Set,o=[],i=[];for(const l of Object.values((null==t?void 0:t.styles)??{}))cV(o,r,null==(n=l.textStyle)?void 0:n.fontFamily);cV(o,r,e.fontFamily);for(const l of a)cV(i,r,l);for(const l of dV)cV(i,r,l);return[...o.sort((t,e)=>t.localeCompare(e)),...i.sort((t,e)=>t.localeCompare(e))]}(t.state().document,t.toolbarStyleState(),e()),computeFontSizeOptions:()=>function(t,e){var a;const n=new Set(Xw);for(const o of Object.values((null==t?void 0:t.styles)??{})){const t=null==(a=o.textStyle)?void 0:a.fontSize;"number"==typeof t&&Number.isFinite(t)&&n.add(Yw(t))}const r=Yw(Number(e.fontSize));return Number.isFinite(r)&&r>0&&n.add(r),Array.from(n).sort((t,e)=>t-e)}(t.state().document,t.toolbarStyleState()),loadLocalFontFamilyOptions:async()=>{if(e().length>0)return;const t=await Xs();t.length>0&&a(t)}}}const pV="insertText",uV="insertImage",fV="insertTable",gV="moveImage",mV="splitListItem",vV="link",bV="imageAlt",yV="imageCaption",MV="layoutWrapPolygon",xV="specialIndent",wV="paraBorders",SV="findReplace",AV="findReplaceAll",CV="tableProperties",IV="paragraph-dialog",TV="font-dialog",kV="copyTextByDrag",VV="moveTextByDrag",RV="collapseSelectionByClick",EV="mergeTable",LV="splitTable",zV="insertTableColumn",NV="deleteTableColumn",OV="insertTableRow",qV="deleteTableRow",PV="tableShading",WV="tableBorders",BV="tableWidth",FV="tableAlign",HV="tableCellWidth",UV="layoutWrapPreset",GV="layoutFixedPosition";function DV(t,e){const a=[];for(const n of t){if(0===n.text.length)continue;const t=a[a.length-1];!t||be(n)||be(t)||!gA(t.styles,n.styles)?a.push({...n,styles:fA(n.styles)}):t.text+=n.text}return a.length>0?a:[Ya("",e)]}function jV(t,e,a){return{...t,runs:DV(e,a),style:t.style?{...t.style}:void 0}}function ZV(t){return Qa(t)}function KV(t,e){const a=ZV(e);return a.style=t.style?{...t.style}:void 0,a.list=xA(t.list),a}function XV(t,e){const a=MA(t);return a.list?(a.list={...a.list,level:Math.max(0,e)},a):a}function YV(t){const e=MA(t);return delete e.list,e}function JV(t,e){var a;if(0===t.runs.length)return;let n=0;for(let r=0;r<t.runs.length;r+=1){const a=t.runs[r],o=n+a.text.length;if(e<o)return fA(a.styles);if(e===o){if(a.text.length>0)return fA(a.styles);const e=t.runs[r+1];return fA((null==e?void 0:e.styles)??a.styles)}n=o}return fA(null==(a=t.runs[t.runs.length-1])?void 0:a.styles)}function QV(t,e){var a,n,r;const o=function(t,e){let a=0;for(let n=0;n<t.runs.length;n+=1){const r=t.runs[n],o=a,i=a+r.text.length;if(e<i)return{run:r,startOffset:o,endOffset:i};if(e===i){if(r.text.length>0)return{run:r,startOffset:o,endOffset:i};const e=t.runs[n+1];return e?{run:e,startOffset:i,endOffset:i+e.text.length}:{run:r,startOffset:o,endOffset:i}}a=i}return null}(t,e),i=null==(a=null==o?void 0:o.run.styles)?void 0:a.link;if(!o||!i||"image"===o.run.kind)return null;let l=o.startOffset,s=o.endOffset,d=0;const c=t.runs,h=c.findIndex(t=>t.id===o.run.id);if(-1===h)return null;for(let p=0;p<h;p+=1)d+=c[p].text.length;l=d,s=d+o.run.text.length;for(let p=h-1;p>=0;p-=1){const t=c[p];if("image"===t.kind||(null==(n=t.styles)?void 0:n.link)!==i)break;l-=t.text.length}for(let p=h+1;p<c.length;p+=1){const t=c[p];if("image"===t.kind||(null==(r=t.styles)?void 0:r.link)!==i)break;s+=t.text.length}return{href:i,startOffset:l,endOffset:s}}function _V(t,e,a){const n=Math.max(0,Math.min(e,Qe(t))),r=Math.max(n,Math.min(a,Qe(t))),o=[];let i=0;for(const l of t.runs){const t=i,e=i+l.text.length,a=Math.max(n,t),s=Math.min(r,e);if(a<s){const e=yA(l);e.id=`run:${Math.random().toString(36).slice(2,9)}`,be(l)||(e.text=l.text.slice(a-t,s-t)),o.push(e)}i=e}return o}function $V(t,e,a){const n=_V(t,0,e),r=_V(t,e,Qe(t)),o=JV(t,e);return jV(t,[...n,...a.map(t=>({...t,styles:fA(t.styles??o)})),...r],o)}function tR(t){const e=[],a=new Map,n=[];let r=0;for(const o of t){const t=Je(o);e.push({id:o.id,base:r,length:t.length}),a.has(o.id)||a.set(o.id,r),n.push(t),r+=t.length+1}return{text:n.join("\n"),spans:e,baseById:a}}function eR(t,e,a){return t<e?e:t>a?a:t}function aR(t,e,a){const n=tR(e);let r=!1;for(const f of t.order){const e=t.items[f];if(e&&(e.start&&n.baseById.has(e.start.paragraphId)||e.end&&n.baseById.has(e.end.paragraphId))){r=!0;break}}if(!r)return t;const o=tR(a);if(n.text===o.text)return t;const i=n.text.length,l=o.text.length,s=Math.min(i,l),d=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(t.length-1-n)===e.charCodeAt(e.length-1-n);)n+=1;return n}(n.text,o.text,s),c=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(n)===e.charCodeAt(n);)n+=1;return n}(n.text,o.text,s-d),h=t=>{const e=n.baseById.get(t.paragraphId);if(void 0===e)return t;const a=e+eR(t.offset,0,i-e),r=eR(function(t,e,a,n,r){return t<=n?t:t>=e-r?t+(a-e):n}(a,i,l,c,d),0,l),s=function(t,e){for(const n of e)if(t<=n.base+n.length)return{paragraphId:n.id,offset:Math.max(0,t-n.base)};const a=e[e.length-1];return{paragraphId:a.id,offset:a.length}}(r,o.spans);return s.paragraphId===t.paragraphId&&s.offset===t.offset?t:{...t,paragraphId:s.paragraphId,offset:s.offset}};let p=!1;const u={...t.items};for(const f of t.order){const e=t.items[f];if(!e)continue;let a=e;if(e.start&&n.baseById.has(e.start.paragraphId)){const t=h(e.start);t!==e.start&&(a={...a,start:t})}if(e.end&&n.baseById.has(e.end.paragraphId)){const t=h(e.end);t!==e.end&&(a={...a,end:t})}a!==e&&(u[f]=a,p=!0)}return p?{...t,items:u}:t}function nR(t,e){if(!function(t){for(const e of t)if("table"===e.type)return!0;return!1}(t))return e;let a=0;const n=t=>{let r=!1;const o=t.map(t=>{if("paragraph"===t.type){const n=e[a++]??t;return n!==t&&(r=!0),n}let o=!1;const i=t.rows.map(t=>{let e=!1;const a=t.cells.map(t=>{const a=n(t.blocks);return a===t.blocks?t:(e=!0,{...t,blocks:a})});return e?(o=!0,{...t,cells:a}):t});return o?(r=!0,{...t,rows:i}):t});return r?o:t};return n(t)}function rR(t,e,a){const n=La(t);if("footnote"===n){const n=t.activeFootnoteId,r=t.document.footnotes;if(!n||!r||!r.items[n])return{...t,selection:a};const o=r.items[n],i=nR(o.blocks,e);return{...t,document:{...t.document,footnotes:{...r,items:{...r.items,[n]:{...o,blocks:i}}}},selection:a}}const r=ha(t.document),o=Math.max(0,Math.min(Ea(t),r.length-1)),i=r[o];if(!i)return{...t,selection:a};const l=function(t,e,a){return"header"===a?{...t,header:nR(t.header??[],e)}:"footer"===a?{...t,footer:nR(t.footer??[],e)}:{...t,blocks:nR(t.blocks,e)}}(i,e,n),s=[...r];s[o]=l;const d=t.document.bookmarks,c=d&&d.order.length>0?aR(d,Na(t),e):d;return{...t,document:{...t.document,sections:s,...c!==d?{bookmarks:c}:{}},selection:a}}function oR(t,e,a){let n=!1;const r=t.map(t=>{if("paragraph"===t.type)return t;let r=!1;const o=t.rows.map(t=>{let n=!1;const o=t.cells.map(t=>{if(!t.blocks.some(t=>e.has(t.id)))return t;const r=a(t);return r!==t&&(n=!0),r});return n?(r=!0,{...t,cells:o}):t});return r?(n=!0,{...t,rows:o}):t});return n?r:t}function iR(t){return Ua(t)}function lR(t){const e=Na(t),a=Fa(t,t.selection.focus),n=Ba(e,a.paragraphId),r=e[n];return{paragraph:r,index:n,offset:$e(r,a)}}function sR(t){const e=Da(t);if(e.isCollapsed)return t;const a=Na(t);if(t.trackChangesEnabled){const n=`rev:${Math.random().toString(36).slice(2,9)}`,r="User",o=Date.now();return rR(t,a.map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return MA(t);return dR(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:Qe(t),t=>{var e;return"insert"===(null==(e=t.revision)?void 0:e.type)?{...t,text:""}:{...t,revision:{id:n,type:"delete",author:r,date:o}}})}),iR(e.start))}const n=a[e.startIndex],r=a[e.endIndex],o=$e(n,e.start),i=$e(r,e.end),l=jV(n,[..._V(n,0,o),..._V(r,i,Qe(r))]);return rR(t,[...wA(a.slice(0,e.startIndex)),l,...wA(a.slice(e.endIndex+1))],iR(_e(l,o)))}function dR(t,e,a,n){return jV(t,[..._V(t,0,e),..._V(t,e,a).map(n),..._V(t,a,Qe(t))])}function cR(t,e){const a=t[e.startIndex],n=t[e.endIndex];return{anchor:_e(a,e.startParagraphOffset),focus:_e(n,e.endParagraphOffset)}}function hR(t,e){const a=Da(t);return a.isCollapsed?t:{document:t.document,selection:iR("start"===e?a.start:a.end)}}function pR(t){return t.map(yA)}function uR(t){return t.reduce((t,e)=>t+e.text.length,0)}function fR(t,e,a){if(0===a.length)return t;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return t;const o=n[r],i=$e(o,e),l=pR(a[0].runs);if(1===a.length){const e=$V(o,i,l),a=n.map((t,a)=>a===r?e:t),s=uR(l);return rR(t,a,{anchor:_e(e,i),focus:_e(e,i+s)})}const s=_V(o,0,i),d=_V(o,i,Qe(o)),c=a[a.length-1],h=a.slice(1,-1),p=jV(MA(a[0].paragraphTemplate),[...s,...l],JV(o,i)),u=h.map(t=>jV(MA(t.paragraphTemplate),pR(t.runs))),f=jV(MA(c.paragraphTemplate),[...pR(c.runs),...d],JV(o,i));return rR(t,[...n.slice(0,r),p,...u,f,...n.slice(r+1)],{anchor:_e(p,uR(s)),focus:_e(f,uR(c.runs))})}function gR(t,e,a={}){if(Da(t).isCollapsed)return t;if(function(t,e){const a=Da(t);if(a.isCollapsed)return!1;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return!1;if(r<a.startIndex||r>a.endIndex)return!1;const o=$e(n[r],e);return!(r===a.startIndex&&o<a.startParagraphOffset||r===a.endIndex&&o>a.endParagraphOffset)}(t,e))return t;const n=function(t){const e=Da(t);if(e.isCollapsed)return[];const a=Na(t),n=[];for(let r=e.startIndex;r<=e.endIndex;r+=1){const t=a[r],o=_V(t,r===e.startIndex?e.startParagraphOffset:0,r===e.endIndex?e.endParagraphOffset:Qe(t));n.push({paragraphTemplate:MA(t),runs:o})}return n}(t);if(0===n.length)return t;if(a.copy)return fR(t,e,n);const r=function(t,e){const a=Da(t),n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return e;const o=$e(n[r],e);if(a.startIndex===a.endIndex)return r!==a.startIndex||o<=a.endParagraphOffset?e:_e(n[a.startIndex],o-(a.endParagraphOffset-a.startParagraphOffset));return e}(t,e);return fR(sR(t),r,n)}function mR(t,e,a){if(0===e.length)return t;const n=Ga(t.selection)?t:sR(t),{paragraph:r,index:o,offset:i}=lR(n),l=a?{...a}:JV(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e,styles:l,kind:"text"};n.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const d=$V(r,i,[s]);return rR(n,Na(n).map((t,e)=>e===o?d:t),iR(_e(d,i+e.length)))}function vR(t,e,a){if(0===e.length)return t;const n=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!n.includes("\n"))return mR(t,n,a);const r=Ga(t.selection)?t:sR(t),{paragraph:o,index:i,offset:l}=lR(r),s=n.split("\n"),d=JV(o,l),c=jV(o,[..._V(o,0,l),Ya(s[0],d)],d),h=_V(o,l,Qe(o)),p=s.slice(1,-1).map(t=>ZV([{text:t,styles:d}])),u=ZV([{text:s[s.length-1],styles:d},...h.map(t=>({text:t.text,styles:t.styles}))]),f=Na(r);return rR(r,[...f.slice(0,i),c,...p,u,...f.slice(i+1)],iR(_e(u,s[s.length-1].length)))}function bR(t){var e;if(!Ga(t.selection))return sR(t);const{paragraph:a,index:n,offset:r}=lR(t),o=Na(t);if(r>0){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<=e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=jV(a,[..._V(a,0,r-1),..._V(a,r,Qe(a))]);return rR(t,o.map((t,a)=>a===n?e:t),iR(_e(e,r-1)))}const c=l.text[d-1],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=jV(a,[..._V(a,0,r-1),h,..._V(a,r,Qe(a))]);return rR(t,o.map((t,e)=>e===n?p:t),iR(_e(p,r-1)))}}const i=jV(a,[..._V(a,0,r-1),..._V(a,r,Qe(a))],JV(a,r-1));return rR(t,o.map((t,e)=>e===n?i:t),iR(_e(i,r-1)))}if(0===n)return t;const i=o[n-1],l=jV(i,[...i.runs.map(yA),...a.runs.map(yA)]);return rR(t,[...o.slice(0,n-1),l,...o.slice(n+1)],iR(_e(l,Qe(i))))}function yR(t){var e;if(!Ga(t.selection))return sR(t);const{paragraph:a,index:n,offset:r}=lR(t),o=Na(t);if(r<Qe(a)){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=jV(a,[..._V(a,0,r),..._V(a,r+1,Qe(a))]);return rR(t,o.map((t,a)=>a===n?e:t),iR(_e(e,r)))}const c=l.text[d],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=jV(a,[..._V(a,0,r),h,..._V(a,r+1,Qe(a))]);return rR(t,o.map((t,e)=>e===n?p:t),iR(_e(p,r)))}}const i=jV(a,[..._V(a,0,r),..._V(a,r+1,Qe(a))],JV(a,r));return rR(t,o.map((t,e)=>e===n?i:t),iR(_e(i,r)))}if(n>=o.length-1)return t;const i=o[n+1],l=jV(a,[...a.runs.map(yA),...i.runs.map(yA)]);return rR(t,[...o.slice(0,n),l,...o.slice(n+2)],iR(_e(l,r)))}function MR(t,e){const a=Da(t);if(a.isCollapsed)return t;const n=Na(t),r=n.slice(a.startIndex,a.endIndex+1).flatMap((t,e)=>{const n=a.startIndex+e;return _V(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:Qe(t))}).filter(t=>t.text.length>0);if(0===r.length)return t;const o=!r.every(t=>{var a;return Boolean(null==(a=t.styles)?void 0:a[e])}),i=n.map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;return dR(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:Qe(t),t=>({...t,styles:mA(t.styles,e,o)}))});return rR(t,i,cR(i,a))}function xR(t,e,a){const n=Da(t);if(n.isCollapsed)return t;const r=Na(t).map((t,r)=>{if(r<n.startIndex||r>n.endIndex)return t;return dR(t,r===n.startIndex?n.startParagraphOffset:0,r===n.endIndex?n.endParagraphOffset:Qe(t),t=>({...t,styles:vA(t.styles,e,a)}))});return rR(t,r,cR(r,n))}function wR(t){return new RegExp("\\p{L}","u").test(t)}function SR(t,e){switch(e){case"lower":return t.toLowerCase();case"upper":return t.toUpperCase();case"capitalize":return function(t){let e="",a=!1;for(const n of t){const t=wR(n);e+=t&&!a?n.toUpperCase():n,a=t}return e}(t);case"toggle":return function(t){let e="";for(const a of t){const t=a.toUpperCase(),n=a.toLowerCase();e+=a===n&&a!==t?t:a===t&&a!==n?n:a}return e}(t);default:return function(t){let e="",a=!0;for(const n of t.toLowerCase())a&&wR(n)?(e+=n.toUpperCase(),a=!1):(e+=n,"."!==n&&"!"!==n&&"?"!==n||(a=!0));return e}(t)}}function AR(t,e){return function(t,e){const a=Da(t);if(a.isCollapsed)return t;const n=Na(t).map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;const r=n===a.startIndex?a.startParagraphOffset:0,o=n===a.endIndex?a.endParagraphOffset:Qe(t),i=_V(t,r,o).map(t=>t.text).join(""),l=e(i);let s=0;return dR(t,r,o,t=>{const e=t.text.length,a=l.slice(s,s+e);return s+=e,{...t,text:a}})});return rR(t,n,cR(n,a))}(t,t=>SR(t,e))}function CR(t,e,a){var n;let r;const o=t=>{const a=t.findIndex(t=>t.id===e);return a>=0?(r=t[a],[...t.slice(0,a),...t.slice(a+1)]):t},i={...t.document};if(i.sections&&i.sections.length>0&&(i.sections=i.sections.map(t=>({...t,blocks:o(t.blocks),header:t.header?o(t.header):void 0,footer:t.footer?o(t.footer):void 0}))),!r)return t;const l=a.paragraphId;if("table"===r.type){if(pa(r).some(t=>t.id===l))return t}const s=t=>{const e=t.findIndex(t=>t.id===l||"table"===t.type&&pa(t).some(t=>t.id===l));if(e<0)return{nextBlocks:t,found:!1};return{nextBlocks:[...t.slice(0,e),r,...t.slice(e)],found:!0}},d=Ea(t),c=La(t),h={...null==(n=i.sections)?void 0:n[d]};let p=!1;if("header"===c){const t=s(h.header??[]);h.header=t.nextBlocks,p=t.found}else if("footer"===c){const t=s(h.footer??[]);h.footer=t.nextBlocks,p=t.found}else{const t=s(h.blocks);h.blocks=t.nextBlocks,p=t.found}return p||(h.blocks=[...h.blocks,r]),i.sections=[...i.sections??[]],i.sections[d]=h,{...t,document:i}}function IR(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})(),s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}function TR(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})();l.style={...a.style??{},pageBreakBefore:!0};const s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}function kR(t,e,a){const n=Da(t),r=Na(t),o=n.startIndex,i=n.endIndex,l=r.map((t,n)=>n<o||n>i?MA(t):{...MA(t),style:bA(t.style,e,a)});return rR(t,l,cR(l,n))}function VR(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function RR(t,e,a){const n={...t??{}};return null===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function ER(t,e){const a=ha(t.document).map(t=>({...t,blocks:e(t.blocks),header:t.header?e(t.header):void 0,footer:t.footer?e(t.footer):void 0}));return{...t,document:{...t.document,sections:a}}}function LR(t,e){return t.map(t=>"table"===t.type?e(t):t)}function zR(t,e){return t.map(t=>"paragraph"===t.type?t:{...e(t),rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:zR(t.blocks,e)}))}))})}function NR(t){const e=Ea(t),a=xa(t.document,t.selection.focus.paragraphId,e);return a?{activeSectionIndex:e,loc:a}:null}function OR(t,e){const a=NR(t);if(!a)return t;const{activeSectionIndex:n,loc:r}=a,o=La(t),i=(t,a)=>t.map((t,n)=>"table"===t.type&&n===r.blockIndex&&a===r.zone?e(t):t),l=ha(t.document).map((t,e)=>e!==n?t:{...t,blocks:"main"===o?i(t.blocks,"main"):t.blocks,header:"header"===o&&t.header?i(t.header,"header"):t.header,footer:"footer"===o&&t.footer?i(t.footer,"footer"):t.footer});return{...t,document:{...t.document,sections:l}}}function qR(t){const e=new Set,a=Ea(t),n=xa(t.document,t.selection.anchor.paragraphId,a),r=xa(t.document,t.selection.focus.paragraphId,a);if(!n||!r||n.blockIndex!==r.blockIndex||n.zone!==r.zone)return e;const o=function(t,e,a){const n=ha(t)[e];if(n)return"header"===a?n.header:"footer"===a?n.footer:n.blocks}(t.document,a,n.zone),i=null==o?void 0:o[n.blockIndex];if(!i||"table"!==i.type)return e;const l=Io(i),s=l.find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),d=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex);if(!s||!d)return e;const c=Math.min(s.visualRowIndex,d.visualRowIndex),h=Math.max(s.visualRowIndex+s.rowSpan-1,d.visualRowIndex+d.rowSpan-1),p=Math.min(s.visualColumnIndex,d.visualColumnIndex),u=Math.max(s.visualColumnIndex+s.colSpan-1,d.visualColumnIndex+d.colSpan-1),f=l.filter(t=>t.visualRowIndex<=h&&t.visualRowIndex+t.rowSpan-1>=c&&t.visualColumnIndex<=u&&t.visualColumnIndex+t.colSpan-1>=p);for(const g of f)for(const t of g.cell.blocks)e.add(t.id);return e}function PR(t,e,a){const n=qR(t);if(0===n.size)for(const i of function(t){const e=new Set,a=Da(t),n=Na(t);for(let r=a.startIndex;r<=a.endIndex;r+=1)e.add(n[r].id);return e}(t))n.add(i);const r=n=>{let r=n.style;return t.trackChangesEnabled&&"revision"!==e&&"propertyRevision"!==e&&!(null==r?void 0:r.propertyRevision)&&(r={...r??{},propertyRevision:{...VR(),type:"property",previous:{...r??{}}}}),{...n,style:RR(r,e,a)}},o=ha(t.document).map(t=>({...t,blocks:oR(t.blocks,n,r),header:t.header?oR(t.header,n,r):void 0,footer:t.footer?oR(t.footer,n,r):void 0}));return{...t,document:{...t.document,sections:o}}}function WR(t,e){let a=PR(t,"borderTop",e);return a=PR(a,"borderRight",e),a=PR(a,"borderBottom",e),a=PR(a,"borderLeft",e),a}function BR(t,e,a){const n=function(t){const e=Da(t),a=Na(t),n=new Set;for(let r=e.startIndex;r<=e.endIndex;r+=1)n.add(a[r].id);return n}(t),r=o=>o.map(o=>{if("paragraph"===o.type)return o;const i=pa(o).some(t=>n.has(t.id)),l=o.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:r(t.blocks)}))})),s={...o,rows:l};return i?(n=>{let r=n.style;return t.trackChangesEnabled&&"revision"!==e&&!(null==r?void 0:r.revision)&&(r={...r??{},revision:{...VR(),type:"property",previous:{...r??{}}}}),{...n,style:RR(r,e,a)}})(s):s});return ER(t,r)}function FR(t,e,a,n){const r=r=>{if(r.id!==e)return r;let o=r.style;return t.trackChangesEnabled&&"revision"!==a&&!(null==o?void 0:o.revision)&&(o={...o??{},revision:{...VR(),type:"property",previous:{...o??{}}}}),{...r,style:RR(o,a,n)}};return ER(t,t=>zR(t,r))}function HR(t,e,a){const n=NR(t);if(!n)return t;return OR(t,r=>{const o=r.rows.map((r,o)=>o===n.loc.rowIndex?(()=>{let n=r.style;return t.trackChangesEnabled&&"revision"!==e&&"propertyRevision"!==e&&!(null==n?void 0:n.propertyRevision)&&(n={...n??{},propertyRevision:{...VR(),type:"property",previous:{...n??{}}}}),{...r,style:RR(n,e,a)}})():r);return{...r,rows:o}})}function UR(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e||e.includes("%"))return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t*Re:null}if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function GR(t,e,a,n,r){const o=o=>{var i;if(o.id!==e)return o;const l=Io(o),s=Math.max(1,...l.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),d=Array(s);let c=!1,h=!0;for(let t=0;t<s;t+=1){const e=UR(a[t]);if(null!==e){d[t]=Math.max(1,e),c=!0;continue}const n=null==(i=o.gridCols)?void 0:i[t];if(!("number"==typeof n&&Number.isFinite(n)&&n>0)){h=!1;break}d[t]=n}const p=o.rows.map((e,n)=>{const r=e.cells.map((e,r)=>{var o,i;const s=l.find(t=>t.rowIndex===n&&t.cellIndex===r);if(!s)return e;const d=s.visualColumnIndex+s.colSpan-1,c=a[d];if(void 0!==c&&1===s.colSpan){const a=t.trackChangesEnabled&&!(null==(o=e.style)?void 0:o.propertyRevision)?{...VR(),type:"property",previous:{...e.style??{}}}:null==(i=e.style)?void 0:i.propertyRevision;return{...e,style:{...e.style??{},width:c,...a?{propertyRevision:a}:{}}}}return e});return{...e,cells:r}}),u={...o.style??{}};return!t.trackChangesEnabled||u.revision||void 0===n&&void 0===r||(u.revision={...VR(),type:"property",previous:{...o.style??{}}}),void 0!==n&&(u.width=n),void 0!==r&&(u.indentLeft="number"==typeof r?r:Number(r)),{...o,rows:p,gridCols:c&&h?d:o.gridCols,gridRevision:t.trackChangesEnabled&&c&&h&&!o.gridRevision?{...VR(),type:"grid",previous:[...o.gridCols??[]]}:o.gridRevision,style:Object.keys(u).length>0?u:void 0}};return ER(t,t=>LR(t,o))}const DR={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 jR(t){const e=Ea(t),a=xa(t.document,t.selection.focus.paragraphId,e);if(!a)return null;const n=function(t,e){const a=ha(t.document)[Ea(t)];return a?"header"===e?a.header??[]:"footer"===e?a.footer??[]:a.blocks:[]}(t,a.zone)[a.blockIndex];if(!n||"table"!==n.type)return null;const r=Io(n).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex);return{table:n,tableId:n.id,rowIndex:a.rowIndex,cellIndex:a.cellIndex,visualColumnIndex:(null==r?void 0:r.visualColumnIndex)??a.cellIndex}}function ZR(t){if("number"==typeof t&&Number.isFinite(t))return{value:String(t),unit:"points"};if("string"==typeof t){const e=t.trim();if(e.endsWith("%"))return{value:e.slice(0,-1),unit:"percent"};const a=e.match(/^([0-9.]+)(pt)?$/i);if(null==a?void 0:a[1])return{value:a[1],unit:"points"}}return{value:"",unit:"points"}}function KR(t){return!!t&&"none"!==t.type&&t.width>0}function XR(t,e="table"){var a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v,b,y,M,x,w,S,A,C,I,T,k,V,R,E,L,z;const N=ZR(null==(a=t.table.style)?void 0:a.width),O=t.table.rows[t.rowIndex],q=null==O?void 0:O.cells[t.cellIndex],P=ZR(null==(n=null==O?void 0:O.style)?void 0:n.height),W=ZR(null==(r=null==q?void 0:q.style)?void 0:r.width),B=ZR(null==(o=t.table.gridCols)?void 0:o[t.visualColumnIndex]),F=(null==q?void 0:q.style)??{},H=[F.borderTop,F.borderRight,F.borderBottom,F.borderLeft,F.borderStart,F.borderEnd,F.borderTopLeftToBottomRight,F.borderTopRightToBottomLeft].filter(KR)[0],U=function(t){var e;const a=null==(e=t.style)?void 0:e.floating;return a&&0!==Object.keys(a).length?Object.entries(a).map(([t,e])=>`${t}=${e}`).join(", "):""}(t.table);return{...DR,activeTab:e,tableWidth:N.value,tableWidthUnit:N.unit,tableAlign:(null==(i=t.table.style)?void 0:i.align)??"",tableIndentLeft:ZR(null==(l=t.table.style)?void 0:l.indentLeft).value,tableWrapping:U?"around":"none",floatingSummary:U,floatingHorizontalAnchor:(null==(d=null==(s=t.table.style)?void 0:s.floating)?void 0:d.horizontalAnchor)??"margin",floatingVerticalAnchor:(null==(h=null==(c=t.table.style)?void 0:c.floating)?void 0:h.verticalAnchor)??"text",floatingX:null!=(null==(u=null==(p=t.table.style)?void 0:p.floating)?void 0:u.x)?String(t.table.style.floating.x):"0",floatingY:null!=(null==(g=null==(f=t.table.style)?void 0:f.floating)?void 0:g.y)?String(t.table.style.floating.y):"0",floatingXAlign:(null==(v=null==(m=t.table.style)?void 0:m.floating)?void 0:v.xAlign)??"",floatingYAlign:(null==(y=null==(b=t.table.style)?void 0:b.floating)?void 0:y.yAlign)??"",floatingDistanceTop:String((null==(x=null==(M=t.table.style)?void 0:M.floating)?void 0:x.distanceTop)??0),floatingDistanceRight:String((null==(S=null==(w=t.table.style)?void 0:w.floating)?void 0:S.distanceRight)??0),floatingDistanceBottom:String((null==(C=null==(A=t.table.style)?void 0:A.floating)?void 0:C.distanceBottom)??0),floatingDistanceLeft:String((null==(T=null==(I=t.table.style)?void 0:I.floating)?void 0:T.distanceLeft)??0),floatingOverlap:(null==(k=t.table.style)?void 0:k.tblOverlap)??"overlap",rowHeight:P.value,rowHeightRule:(null==(V=null==O?void 0:O.style)?void 0:V.heightRule)??"",repeatHeader:Boolean(null==O?void 0:O.isHeader),allowBreakAcrossPages:!0!==(null==(R=null==O?void 0:O.style)?void 0:R.cantSplit),hiddenRow:!0===(null==(E=null==O?void 0:O.style)?void 0:E.hidden),columnWidth:B.value,cellWidth:W.value,cellVerticalAlign:F.verticalAlign??"",cellTextDirection:F.textDirection??"",cellNoWrap:!0===F.noWrap,cellFitText:!0===F.fitText,cellHideMark:!0===F.hideMark,marginTop:null!=F.paddingTop?String(F.paddingTop):"",marginRight:null!=F.paddingRight?String(F.paddingRight):"",marginBottom:null!=F.paddingBottom?String(F.paddingBottom):"",marginLeft:null!=F.paddingLeft?String(F.paddingLeft):"",borderStyle:(null==H?void 0:H.type)??"none",borderWidth:H?String(H.width):"",borderColor:(null==H?void 0:H.color)??"",borderTop:KR(F.borderTop),borderRight:KR(F.borderRight),borderBottom:KR(F.borderBottom),borderLeft:KR(F.borderLeft),borderStart:KR(F.borderStart),borderEnd:KR(F.borderEnd),borderTopLeftToBottomRight:KR(F.borderTopLeftToBottomRight),borderTopRightToBottomLeft:KR(F.borderTopRightToBottomLeft),shading:F.shading??"",altTitle:(null==(L=t.table.style)?void 0:L.altTitle)??"",altDescription:(null==(z=t.table.style)?void 0:z.altDescription)??""}}function YR(t,e,a){return PR(t,e,a)}function JR(t,e){const a=jR(t);if(!a)return t;let n=t;return n=FR(n,a.tableId,"width",e.tableWidth),n=FR(n,a.tableId,"align",e.tableAlign),n=FR(n,a.tableId,"indentLeft",e.tableIndentLeft),n=FR(n,a.tableId,"floating",e.tableFloating),n=FR(n,a.tableId,"tblOverlap",e.tableOverlap),n=FR(n,a.tableId,"altTitle",e.altTitle),n=FR(n,a.tableId,"altDescription",e.altDescription),n=function(t,e){const a=NR(t);return a?OR(t,n=>({...n,rows:n.rows.map((n,r)=>{if(r!==a.loc.rowIndex)return n;let o=n.style;t.trackChangesEnabled&&!(null==o?void 0:o.propertyRevision)&&(o={...o??{},propertyRevision:{...VR(),type:"property",previous:{...o??{},isHeader:n.isHeader}}});const i=null===e?void 0:e;return{...n,isHeader:i,style:RR(o,"isHeader",i??null)}})})):t}(n,e.repeatHeader),n=HR(n,"height",e.rowHeight),n=HR(n,"heightRule",e.rowHeightRule),n=HR(n,"cantSplit",e.cantSplit),n=HR(n,"hidden",e.hiddenRow),null!==e.columnWidth&&(n=GR(n,a.tableId,{[a.visualColumnIndex]:e.columnWidth})),n=YR(n,"width",e.cellWidth),n=YR(n,"verticalAlign",e.cellVerticalAlign),n=YR(n,"textDirection",e.cellTextDirection),n=YR(n,"noWrap",e.cellNoWrap),n=YR(n,"fitText",e.cellFitText),n=YR(n,"hideMark",e.cellHideMark),n=YR(n,"paddingTop",e.margins.top),n=YR(n,"paddingRight",e.margins.right),n=YR(n,"paddingBottom",e.margins.bottom),n=YR(n,"paddingLeft",e.margins.left),n=YR(n,"borderTop",e.borders.top),n=YR(n,"borderRight",e.borders.right),n=YR(n,"borderBottom",e.borders.bottom),n=YR(n,"borderLeft",e.borders.left),n=YR(n,"borderStart",e.borders.start),n=YR(n,"borderEnd",e.borders.end),n=YR(n,"borderTopLeftToBottomRight",e.borders.topLeftToBottomRight),n=YR(n,"borderTopRightToBottomLeft",e.borders.topRightToBottomLeft),n=YR(n,"shading",e.shading),n}function QR(t){const e=()=>{return e=t.state(),Boolean(jR(e));var e};return{isInsideTable:e,openTablePropertiesDialog:(e="table")=>{const a=function(t,e="table"){const a=jR(t);return a?XR(a,e):null}(t.state(),e);a&&(t.setContextMenu({isOpen:!1,x:0,y:0}),t.setTablePropertiesDialog({isOpen:!0,initial:a}))},applyTablePropertiesDialogValues:a=>{t.isReadOnly()||e()&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>JR(t,a),{mergeKey:CV}),t.focusInput())}}}function _R(t){if(!t)return"";const e=[];t.fontFamily&&e.push(`font-family:${t.fontFamily}`),void 0!==t.fontSize&&null!==t.fontSize&&e.push(`font-size:${t.fontSize}px`),t.color&&e.push(`color:${t.color}`),t.highlight?e.push(`background-color:${t.highlight}`):t.shading&&e.push(`background-color:${t.shading}`),t.superscript?(e.push("vertical-align:super"),e.push("font-size:0.75em")):t.subscript&&(e.push("vertical-align:sub"),e.push("font-size:0.75em")),t.bold&&e.push("font-weight:700"),t.italic&&e.push("font-style:italic"),t.hidden&&e.push("display:none"),t.allCaps&&e.push("text-transform:uppercase"),t.smallCaps&&e.push("font-variant:small-caps"),void 0!==t.characterScale&&null!==t.characterScale&&e.push(`font-stretch:${t.characterScale}%`),void 0!==t.characterSpacing&&null!==t.characterSpacing&&e.push(`letter-spacing:${t.characterSpacing}pt`),$R(t.language)&&e.push("hyphens:auto"),void 0!==t.baselineShift&&null!==t.baselineShift&&e.push(`vertical-align:${t.baselineShift}pt`);const a=function(t){switch(t){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 null}}(t.ligatures);a&&e.push(`font-variant-ligatures:${a}`);const n=function(t,e){const a=[];"proportional"===t&&a.push("proportional-nums");"tabular"===t&&a.push("tabular-nums");"lining"===e&&a.push("lining-nums");"oldStyle"===e&&a.push("oldstyle-nums");return a.join(" ")||null}(t.numberSpacing,t.numberForm);n&&e.push(`font-variant-numeric:${n}`);const r=function(t,e){const a=[];"number"==typeof t&&t>=1&&t<=20&&a.push(`"ss${String(t).padStart(2,"0")}" 1`);e&&a.push('"calt" 1');return a.join(", ")||null}(t.stylisticSet,t.contextualAlternates);if(r&&e.push(`font-feature-settings:${r}`),t.textFill)if("solid"===t.textFill.type)e.push(`color:${t.textFill.color}`);else if("gradient"===t.textFill.type&&t.textFill.stops.length>=2){const a=((90-(t.textFill.angle??0))%360+360)%360,n=t.textFill.stops.map(t=>`${t.color} ${Math.round(100*t.position)}%`).join(",");e.push(`background:linear-gradient(${a}deg,${n})`),e.push("-webkit-background-clip:text"),e.push("background-clip:text"),e.push("color:transparent")}if(t.textOutline){const a=t.textOutline.widthPt*Ve,n=t.textOutline.color??"#000000";e.push(`-webkit-text-stroke:${a.toFixed(2)}px ${n}`)}if(t.textShadow){const a=t.textShadow.dirDeg*Math.PI/180,n=t=>(t*Ve).toFixed(2),r=(Math.cos(a)*t.textShadow.distPt*Ve).toFixed(2),o=(Math.sin(a)*t.textShadow.distPt*Ve).toFixed(2),i=n(t.textShadow.blurPt),l=t.textShadow.alpha??1,s=parseInt(t.textShadow.color.slice(1,3),16),d=parseInt(t.textShadow.color.slice(3,5),16),c=parseInt(t.textShadow.color.slice(5,7),16);e.push(`text-shadow:${r}px ${o}px ${i}px rgba(${s},${d},${c},${l})`)}else if(t.glow){const a=(t.glow.radiusPt*Ve).toFixed(2),n=t.glow.alpha??.7,r=parseInt(t.glow.color.slice(1,3),16),o=parseInt(t.glow.color.slice(3,5),16),i=parseInt(t.glow.color.slice(5,7),16);e.push(`text-shadow:0 0 ${a}px rgba(${r},${o},${i},${n})`)}const o=[];if((t.underline||t.link)&&o.push("underline"),t.strike&&o.push("line-through"),t.doubleStrike&&o.push("line-through"),o.length>0&&(e.push(`text-decoration:${o.join(" ")}`),t.underline||t.link)){const a=function(t){switch(t){case"double":case"wavyDouble":return"double";case"dotted":case"dottedHeavy":return"dotted";case"dash":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dashDotHeavy":case"dotDotDash":case"dashDotDotHeavy":return"dashed";case"wave":case"wavyHeavy":return"wavy";default:return null}}(t.underlineStyle);a&&e.push(`text-decoration-style:${a}`),t.underlineColor&&e.push(`text-decoration-color:${t.underlineColor}`)}return e.join(";")}function $R(t){return(null==t?void 0:t.value)??(null==t?void 0:t.bidi)??(null==t?void 0:t.eastAsia)??null}function tE(t){if(!t)return"";const e=[];if(t.align&&e.push(`text-align:${t.align}`),void 0!==t.lineHeight&&null!==t.lineHeight){const a="exact"===t.lineRule||"atLeast"===t.lineRule;e.push(`line-height:${t.lineHeight}${a?"px":""}`)}return void 0!==t.spacingBefore&&null!==t.spacingBefore&&e.push(`padding-top:${t.spacingBefore}px`),void 0!==t.spacingAfter&&null!==t.spacingAfter&&e.push(`padding-bottom:${t.spacingAfter}px`),void 0!==t.indentLeft&&null!==t.indentLeft&&e.push(`padding-left:${t.indentLeft}px`),void 0!==t.indentRight&&null!==t.indentRight&&e.push(`padding-right:${t.indentRight}px`),void 0!==t.indentFirstLine&&null!==t.indentFirstLine&&e.push(`text-indent:${t.indentFirstLine}px`),e.join(";")}function eE(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function aE(t,e){if("image"===t.kind)return function(t,e){var a;if("image"!==t.kind)return"";const n=da(e,t.image.src),r=void 0!==t.image.alt?` alt="${eE(t.image.alt)}"`:"",o=`<img src="${eE(n)}" width="${Math.max(1,Math.round(t.image.width))}" height="${Math.max(1,Math.round(t.image.height))}"${r}>`;return(null==(a=t.styles)?void 0:a.link)?`<a href="${eE(t.styles.link)}">${o}</a>`:o}(t,e);let a=eE(t.text).replace(/\n/g,"<br>");const n=t.styles??void 0;(null==n?void 0:n.strike)&&(a=`<s>${a}</s>`),(null==n?void 0:n.underline)&&(a=`<u>${a}</u>`),(null==n?void 0:n.italic)&&(a=`<em>${a}</em>`),(null==n?void 0:n.bold)&&(a=`<strong>${a}</strong>`),(null==n?void 0:n.superscript)?a=`<sup>${a}</sup>`:(null==n?void 0:n.subscript)&&(a=`<sub>${a}</sub>`);const r=_R(n),o=function(t){if(!t)return"";const e=[],a=$R(t);return a&&e.push(`lang="${eE(a)}"`),t.value&&e.push(`data-oasis-lang-value="${eE(t.value)}"`),t.eastAsia&&e.push(`data-oasis-lang-east-asia="${eE(t.eastAsia)}"`),t.bidi&&e.push(`data-oasis-lang-bidi="${eE(t.bidi)}"`),e.length>0?` ${e.join(" ")}`:""}(null==n?void 0:n.language);if(r.length>0||o.length>0){a=`<span${r.length>0?` style="${r}"`:""}${o}>${a}</span>`}return(null==n?void 0:n.link)&&(a=`<a href="${eE(n.link)}">${a}</a>`),a}function nE(t,e){return t.map(t=>aE(t,e)).join("")||"<br>"}function rE(t){var e;const a=Da(t);if(a.isCollapsed)return"";const n=Na(t),r=[];let o=null;const i=()=>{o&&(r.push("bullet"===o?"</ul>":"</ol>"),o=null)};for(let l=a.startIndex;l<=a.endIndex;l+=1){const s=n[l];if(!s)continue;const d=_V(s,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(s)),c=tE(s.style),h=c.length>0?` style="${c}"`:"",p=nE(d,t.document);if(null==(e=s.list)?void 0:e.kind){const t="bullet"===s.list.kind?"ul":"ol";o!==s.list.kind&&(i(),r.push(`<${t}>`),o=s.list.kind),r.push(`<li${h}>${p}</li>`);continue}i(),r.push(`<p${h}>${p}</p>`)}return i(),r.join("")}function oE(t,e){if(0===e.length)return t;const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i=Na(a),l=_V(n,0,o),s=_V(n,o,Qe(n)),d=e.map(t=>{const e=Qa(t.runs.map(t=>({text:t.text,styles:fA(t.styles),image:t.image?{...t.image}:void 0})));return e.style=t.style?{...t.style}:void 0,e.list=t.list?{...t.list}:void 0,e});let c,h=iR(_e(n,o));if(1===d.length){const t=d[0],e=t.runs.reduce((t,e)=>t+e.text.length,0),a=jV(n,[...l,...t.runs.map(yA),...s],JV(n,o));a.style=n.style?{...n.style}:t.style?{...t.style}:void 0,a.list=n.list?{...n.list}:t.list?{...t.list}:void 0,c=[...wA(i.slice(0,r)),a,...wA(i.slice(r+1))],h=iR(_e(a,l.reduce((t,e)=>t+e.text.length,0)+e))}else{const t=d[0],e=d[d.length-1],a=e.runs.reduce((t,e)=>t+e.text.length,0),p=jV(n,[...l,...t.runs.map(yA)],JV(n,o));p.style=n.style?{...n.style}:t.style?{...t.style}:void 0,p.list=n.list?{...n.list}:t.list?{...t.list}:void 0;const u=d.slice(1,-1).map(MA),f=jV(e,[...e.runs.map(yA),...s],void 0);f.list=e.list?{...e.list}:void 0,c=[...wA(i.slice(0,r)),p,...u,f,...wA(i.slice(r+1))],h=iR(_e(f,a))}return rR(a,c,h)}function iE(t,e){return{document:t.document,selection:e}}function lE(t,e){if(!Ga(t.selection))return hR(t,e<0?"start":"end");const{index:a,offset:n}=lR(t),r=Na(t),o=a+e;if(o<0||o>=r.length)return t;const i=r[o];return iE(t,iR(_e(i,Math.min(n,Qe(i)))))}function sE(t,e){const a=Fa(t,t.selection.focus),n=Na(t),r=Ba(n,a.paragraphId),o=n[r],i=$e(o,a),l=Qe(o);if(e<0&&i>0)return iE(t,{anchor:t.selection.anchor,focus:_e(o,i-1)});if(e>0&&i<l)return iE(t,{anchor:t.selection.anchor,focus:_e(o,i+1)});if(e<0&&r>0){const e=n[r-1];return iE(t,{anchor:t.selection.anchor,focus:_e(e,Qe(e))})}if(e>0&&r<n.length-1){const e=n[r+1];return iE(t,{anchor:t.selection.anchor,focus:_e(e,0)})}return t}function dE(t,e){const a=Fa(t,t.selection.focus),n=Na(t),r=Ba(n,a.paragraphId),o=$e(n[r],a),i=r+e;if(i<0||i>=n.length)return t;const l=n[i];return iE(t,{anchor:t.selection.anchor,focus:_e(l,Math.min(o,Qe(l)))})}function cE(t){const e=Da(t);if(e.isCollapsed)return"";const a=Na(t);if(e.startIndex===e.endIndex){return Je(a[e.startIndex]).slice(e.startParagraphOffset,e.endParagraphOffset)}const n=[],r=a[e.startIndex],o=a[e.endIndex];n.push(Je(r).slice(e.startParagraphOffset));for(let i=e.startIndex+1;i<e.endIndex;i+=1)n.push(Je(a[i]));return n.push(Je(o).slice(0,e.endParagraphOffset)),n.join("\n")}function hE(t,e){return{...t,selection:{anchor:Fa(t,e.anchor),focus:Fa(t,e.focus)}}}function pE(t){if(!Ga(t.selection))return hR(t,"start");const{paragraph:e,index:a,offset:n}=lR(t),r=Na(t);if(n>0)return{document:t.document,selection:iR(_e(e,n-1))};if(0===a)return t;const o=r[a-1];return{document:t.document,selection:iR(_e(o,Qe(o)))}}function uE(t){if(!Ga(t.selection))return hR(t,"end");const{paragraph:e,index:a,offset:n}=lR(t),r=Na(t);if(n<Qe(e))return{document:t.document,selection:iR(_e(e,n+1))};if(a>=r.length-1)return t;const o=r[a+1];return{document:t.document,selection:iR(_e(o,0))}}function fE(t){if("undefined"==typeof document||0===t.trim().length)return[];const e=document.createElement("template");e.innerHTML=t;const a=[],n=Array.from(e.content.childNodes),r=(t,e,n)=>{const r=e.length>0?e:[Ya("")];a.push({runs:r.map(t=>{const e=ye(t);return{text:t.text,styles:fA(t.styles),image:e?{...e}:void 0}}),style:t?OM(t):void 0,list:n})},o=(t,e)=>{for(const a of Array.from(t.children))"LI"===a.tagName&&r(a,LM(a,void 0),{kind:e,level:0})};for(const i of n){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent??"";t.trim().length>0&&r(null,[Ya(t)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const t=i,e=NM(t.tagName);if(e){o(t,e);continue}if(zM(t.tagName)){r(t,LM(t,void 0),"LI"===t.tagName?{kind:"bullet",level:0}:void 0);continue}const a=LM(t,void 0);a.length>0&&r(null,a)}return a}function gE(t){const{state:e,tableOps:a,applyTableContextCommand:n}=t;return{isInsideTable:t.isInsideTable,canMerge:()=>a.canMergeSelectedTable(e()),canSplit:()=>a.canSplitSelectedTable(e()),canEditColumn:()=>a.canEditSelectedTableColumn(e()),canEditRow:()=>a.canEditSelectedTableRow(e()),openProperties:()=>t.openTablePropertiesDialog("table"),openBordersAndShading:()=>t.openTablePropertiesDialog("cell"),merge:()=>n(t=>a.mergeSelectedTable(t),EV),split:()=>n(t=>a.splitSelectedTable(t),LV),insertColumnBefore:()=>n(t=>a.insertSelectedTableColumn(t,-1),zV),insertColumnAfter:()=>n(t=>a.insertSelectedTableColumn(t,1),zV),deleteColumn:()=>n(t=>a.deleteSelectedTableColumn(t),NV),insertRowBefore:()=>n(t=>a.insertSelectedTableRow(t,-1),OV),insertRowAfter:()=>n(t=>a.insertSelectedTableRow(t,1),OV),deleteRow:()=>n(t=>a.deleteSelectedTableRow(t),qV)}}function mE(t){const{computeFontFamilyOptions:e,computeFontSizeOptions:a,loadLocalFontFamilyOptions:n}=hV({state:t.state,toolbarStyleState:t.toolbarStyleState}),r=function(t){return{openFontDialog:()=>{var e;t.loadLocalFontFamilyOptions(),t.setFontDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{fontFamily:e.fontFamily??"",fontSize:Qw(e.fontSize),color:e.color??"",colorMode:e.color?"custom":"automatic",highlight:e.highlight??"",shading:e.textShading??"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underlineStyle?e.underlineStyle:null,underlineColor:e.underlineColor??"",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden),characterScale:e.characterScale??"",characterSpacing:e.characterSpacing??"",baselineShift:e.baselineShift??"",kerningThreshold:e.kerningThreshold??"",ligatures:e.ligatures??"",numberSpacing:e.numberSpacing??"",numberForm:e.numberForm??"",stylisticSet:e.stylisticSet??"",contextualAlternates:Boolean(e.contextualAlternates)})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(e,a)=>{t.isReadOnly()||(Ga(t.selection())||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>{let n=t;e.fontFamily!==(a.fontFamily||null)&&(n=xR(n,"fontFamily",e.fontFamily)),e.fontSize!==(a.fontSize?Number(a.fontSize):null)&&(n=xR(n,"fontSize",_w(e.fontSize)));const r="automatic"===a.colorMode?null:a.color||null;e.color!==r&&(n=xR(n,"color",e.color)),(e.highlight??"")!==(a.highlight??"")&&(n=xR(n,"highlight",e.highlight)),(e.shading??"")!==(a.shading??"")&&(n=xR(n,"shading",e.shading)),e.bold!==Boolean(a.bold)&&(n=MR(n,"bold")),e.italic!==Boolean(a.italic)&&(n=MR(n,"italic"));const o=a.underline?a.underlineStyle??"single":null;(e.underlineStyle??null)!==(o??null)&&(n=xR(n,"underlineStyle",e.underlineStyle));const i=a.underline&&a.underlineColor||null;(e.underlineColor??null)!==(i??null)&&(n=xR(n,"underlineColor",e.underlineColor)),e.underline!==Boolean(a.underline)&&(n=MR(n,"underline")),e.strike!==Boolean(a.strike)&&(n=MR(n,"strike")),e.doubleStrike!==Boolean(a.doubleStrike)&&(n=MR(n,"doubleStrike")),e.superscript!==Boolean(a.superscript)&&(n=MR(n,"superscript")),e.subscript!==Boolean(a.subscript)&&(n=MR(n,"subscript")),e.superscript&&e.subscript&&(n=MR(n,"subscript")),e.strike&&e.doubleStrike&&(n=MR(n,"doubleStrike")),e.smallCaps!==Boolean(a.smallCaps)&&(n=MR(n,"smallCaps")),e.allCaps!==Boolean(a.allCaps)&&(n=MR(n,"allCaps")),e.hidden!==Boolean(a.hidden)&&(n=MR(n,"hidden"));const l=a.characterScale?Number(a.characterScale):null;(e.characterScale??null)!==(l??null)&&(n=xR(n,"characterScale",e.characterScale));const s=a.characterSpacing?Number(a.characterSpacing):null;(e.characterSpacing??null)!==(s??null)&&(n=xR(n,"characterSpacing",e.characterSpacing));const d=a.baselineShift?Number(a.baselineShift):null;(e.baselineShift??null)!==(d??null)&&(n=xR(n,"baselineShift",e.baselineShift));const c=a.kerningThreshold?Number(a.kerningThreshold):null;(e.kerningThreshold??null)!==(c??null)&&(n=xR(n,"kerningThreshold",e.kerningThreshold)),(e.ligatures??null)!==(a.ligatures||null)&&(n=xR(n,"ligatures",e.ligatures)),(e.numberSpacing??null)!==(a.numberSpacing||null)&&(n=xR(n,"numberSpacing",e.numberSpacing)),(e.numberForm??null)!==(a.numberForm||null)&&(n=xR(n,"numberForm",e.numberForm));const h=a.stylisticSet?Number(a.stylisticSet):null;return(e.stylisticSet??null)!==(h??null)&&(n=xR(n,"stylisticSet",e.stylisticSet)),e.contextualAlternates!==Boolean(a.contextualAlternates)&&(n=MR(n,"contextualAlternates")),n},{mergeKey:TV})),t.focusInput())}}}({toolbarStyleState:t.toolbarStyleState,selection:t.selection,isReadOnly:t.isReadOnly,loadLocalFontFamilyOptions:n,setFontDialog:t.setFontDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),o=r.openFontDialog,i=function(t){return{openParagraphDialog:()=>{var e;t.setParagraphDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",shading:e.shading??"",borderStyle:e.borderStyle??"",borderWidth:e.borderWidth??"",borderColor:e.borderColor??"",borderSideTop:e.borderSideTop??!1,borderSideRight:e.borderSideRight??!1,borderSideBottom:e.borderSideBottom??!1,borderSideLeft:e.borderSideLeft??!1})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(e,a)=>{if(t.isReadOnly())return;t.clearPreferredColumn(),t.resetTransactionGrouping();const n=t=>{if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null};t.applyTransactionalState(t=>{let r=t;e.align!==(a.align||null)&&(r=kR(r,"align",e.align)),e.indentLeft!==n(a.indentLeft)&&(r=kR(r,"indentLeft",e.indentLeft)),e.indentRight!==n(a.indentRight)&&(r=kR(r,"indentRight",e.indentRight)),e.indentFirstLine!==n(a.indentFirstLine)&&(r=kR(r,"indentFirstLine",e.indentFirstLine)),e.indentHanging!==n(a.indentHanging)&&(r=kR(r,"indentHanging",e.indentHanging)),e.spacingBefore!==n(a.spacingBefore)&&(r=kR(r,"spacingBefore",e.spacingBefore)),e.spacingAfter!==n(a.spacingAfter)&&(r=kR(r,"spacingAfter",e.spacingAfter)),e.lineHeight!==n(a.lineHeight)&&(r=kR(r,"lineHeight",e.lineHeight)),e.shading!==(a.shading||null)&&(r=kR(r,"shading",e.shading));const o="solid"===a.borderStyle||"dashed"===a.borderStyle||"dotted"===a.borderStyle?{type:a.borderStyle,width:Number(a.borderWidth)||0,color:a.borderColor||"#000000"}:null,i={borderTop:a.borderSideTop?o:null,borderRight:a.borderSideRight?o:null,borderBottom:a.borderSideBottom?o:null,borderLeft:a.borderSideLeft?o:null},l={borderTop:e.borders.top,borderRight:e.borders.right,borderBottom:e.borders.bottom,borderLeft:e.borders.left};for(const e of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(l[e])!==JSON.stringify(i[e])&&(r=kR(r,e,l[e]));return r},{mergeKey:IV}),t.focusInput()}}}({toolbarStyleState:t.toolbarStyleState,isReadOnly:t.isReadOnly,setParagraphDialog:t.setParagraphDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),l=i.openParagraphDialog,s=QR({state:t.state,isReadOnly:t.isReadOnly,setTablePropertiesDialog:t.setTablePropertiesDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),d=s.openTablePropertiesDialog,c=function(t){const e=t.t,a=async()=>{var e;const a=t.state(),n=cE(a);if(!n)return;const r=rE(a);try{"undefined"!=typeof ClipboardItem&&(null==(e=navigator.clipboard)?void 0:e.write)?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([r],{type:"text/html"})})]):await navigator.clipboard.writeText(n)}catch(o){t.logger.warn("contextMenu:copy:failed",{error:String(o)});try{await navigator.clipboard.writeText(n)}catch{}}},n=async()=>{t.isReadOnly()||cE(t.state())&&(await a(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),t.focusInput())},r=async()=>{var e,a;if(t.isReadOnly())return;let n="",r="";try{if(null==(e=navigator.clipboard)?void 0:e.read){const t=await navigator.clipboard.read();for(const e of t){if(e.types.includes("text/html")){const t=await e.getType("text/html");n=await t.text()}if(e.types.includes("text/plain")){const t=await e.getType("text/plain");r=await t.text()}}}else(null==(a=navigator.clipboard)?void 0:a.readText)&&(r=await navigator.clipboard.readText())}catch(i){t.logger.warn("contextMenu:paste:failed",{error:String(i)});try{r=await navigator.clipboard.readText()}catch{return}}const o=fE(n);if(o.length>0)return t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oE(t,o))),void t.focusInput();r&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>vR(t,r))),t.focusInput())};return{buildContextMenuItems:()=>{const o=!Ga(t.state().selection),i=t.isReadOnly(),l=[{id:"cut",label:e("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!o,testId:"editor-context-menu-cut",onSelect:()=>{n()}},{id:"copy",label:e("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!o,testId:"editor-context-menu-copy",onSelect:()=>{a()}},{id:"paste",label:e("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{r()}},{id:"sep1",type:"separator"},{id:"link",label:e("contextmenu.link"),icon:"link",disabled:i||!o,testId:"editor-context-menu-link",onSelect:t.promptForLink},{id:"font",label:e("contextmenu.font"),icon:"type",disabled:i||!o,testId:"editor-context-menu-font",onSelect:t.openFontDialog},{id:"paragraph",label:e("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:t.openParagraphDialog}],s=t.table;return(null==s?void 0:s.isInsideTable())&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:e("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:e("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:e("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:e("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:e("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:e("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:e("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:e("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:e("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:e("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},closeContextMenu:()=>{t.setContextMenu({isOpen:!1,x:0,y:0})},handleEditorContextMenu:e=>{e.preventDefault(),t.setContextMenu({isOpen:!0,x:e.clientX,y:e.clientY})},programmaticCopy:a,programmaticCut:n,programmaticPaste:r}}({state:t.state,isReadOnly:t.isReadOnly,t:t.t,logger:t.logger,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.applyTableAwareParagraphEdit,focusInput:t.focusInput,promptForLink:t.promptForLink,openFontDialog:o,openParagraphDialog:l,table:gE({state:t.state,tableOps:t.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()}})});return{computeFontFamilyOptions:e,computeFontSizeOptions:a,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:c.buildContextMenuItems,handleEditorContextMenu:c.handleEditorContextMenu,closeContextMenu:c.closeContextMenu}}function vE(t){const e=w(()=>{var e,a,n;const r=t.targetPos(),o=t.surfaceRef;if(!o)return null;const i=t.snapshotProvider.getCanvasLayoutSnapshot({surface:o,state:t.state,documentLayout:t.documentLayout(),zoomFactor:null==(e=t.zoomFactor)?void 0:e.call(t)});let l=0,s=0,d=28;if(i){const e=Na(t.state).find(t=>t.id===r.paragraphId),a=e?$e(e,r):0,n=function(t,e,a){const n=Pn(t,e.paragraphId);if(0===n.length)return null;const r=function(t,e){if(0===t.length)return null;for(const a of t)if(e>=a.startOffset&&e<=a.endOffset)return a;return t[t.length-1]??null}(n,a);if(!r)return null;const o=function(t,e){if(0===t.lines.length)return null;for(const a of t.lines)if(e>=a.startOffset&&e<=a.endOffset)return a;return t.lines[t.lines.length-1]??null}(r,a);if(!o||0===o.slots.length)return qn(r.left,r.top,1,Math.max(r.height,16));const i=o.slots.find(t=>t.offset===a)??o.slots.reduce((t,e)=>Math.abs(e.offset-a)<Math.abs(t.offset-a)?e:t,o.slots[0]);return qn(i.left,i.top,1,i.height||o.height)}(i,r,a);if(n)return{viewportLeft:n.left,viewportTop:n.top,height:Math.min(n.height||28,32)};const o=function(t,e,a="start"){const n=Pn(t,e);if(0===n.length)return null;const r="end"===a?n[n.length-1]:n[0];return qn(r.left,r.top,r.width,r.height)}(i,r.paragraphId,"end");if(o)return{viewportLeft:o.left,viewportTop:o.top,height:o.height||28}}const c=(null==(a=t.caretViewport)?void 0:a.call(t))??null;if(c)return l=c.left,s=c.top,d=Math.max(12,Math.min(36,c.height)),{viewportLeft:l,viewportTop:s,height:d};const h=(null==(n=t.pointerPos)?void 0:n.call(t))??null;return h?(l=h.x,s=h.y-12,d=24,{viewportLeft:l,viewportTop:s,height:d}):{viewportLeft:l,viewportTop:s,height:d}});return K(rt,{get when(){return e()},children:t=>K(Uu,{active:!0,fixed:!0,get left(){return t().viewportLeft},get top(){return t().viewportTop},get height(){return t().height}})})}var bE=gt("<div class=oasis-editor-table-resize-guide>"),yE=gt("<img class=oasis-editor-image-ghost>"),ME=gt("<div class=oasis-editor-table-ghost>");function xE(t){return[K(rt,{get when(){return t.tableResize.resizing()},children:t=>{return e=bE(),M(a=>{var n=!("column"!==t().type),r=!("row"!==t().type),o={..."column"===t().type?{left:`${t().currentPos}px`,top:`${t().guideBounds.top}px`,width:"0px",height:`${t().guideBounds.height}px`}:{left:`${t().guideBounds.left}px`,top:`${t().currentPos}px`,width:`${t().guideBounds.width}px`,height:"0px"}};return n!==a.e&&e.classList.toggle("oasis-editor-table-resize-guide-column",a.e=n),r!==a.t&&e.classList.toggle("oasis-editor-table-resize-guide-row",a.t=r),a.a=xt(e,o,a.a),a},{e:void 0,t:void 0,a:void 0}),e;var e}}),K(rt,{get when(){return pt(()=>!!t.imageOps.dragging())()&&t.imageOps.draggedImageInfo()},children:e=>{return a=yE(),M(n=>{var r=e().src,o=`${e().width}px`,i=`${e().height}px`,l=t.imageOps.mousePos().x-e().offsetX+"px",s=t.imageOps.mousePos().y-e().offsetY+"px";return r!==n.e&&vt(a,"src",n.e=r),o!==n.t&&wt(a,"width",n.t=o),i!==n.a&&wt(a,"height",n.a=i),l!==n.o&&wt(a,"left",n.o=l),s!==n.i&&wt(a,"top",n.i=s),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a;var a}}),K(rt,{get when(){return pt(()=>!!t.tableDrag.dragging())()&&t.tableDrag.draggedTableInfo()},children:e=>{return a=ME(),M(n=>{var r=`${e().width}px`,o=`${e().height}px`,i=t.tableDrag.mousePos().x-e().offsetX+"px",l=t.tableDrag.mousePos().y-e().offsetY+"px";return r!==n.e&&wt(a,"width",n.e=r),o!==n.t&&wt(a,"height",n.t=o),i!==n.a&&wt(a,"left",n.a=i),l!==n.o&&wt(a,"top",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a;var a}}),K(rt,{get when(){return pt(()=>!!t.tableDrag.dragging())()&&t.tableDrag.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e})}),K(rt,{get when(){return pt(()=>!!t.imageOps.dragging())()&&t.imageOps.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e})}),K(rt,{get when(){return pt(()=>!!t.textDrag.dragging())()&&t.textDrag.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e,get pointerPos(){return t.textDrag.pointerPos},get caretViewport(){return t.textDrag.caretViewport}})})]}function wE(t){return[K(Kx,{variant:"secondary",get onClick(){return t.onCancel},get"data-testid"(){return t.cancelTestId},get children(){return t.cancelLabel}}),K(Kx,{variant:"primary",get onClick(){return t.onConfirm},get"data-testid"(){return t.confirmTestId},get children(){return t.confirmLabel}})]}function SE(t){const e=Ft(),[a,n]=y(t.initialValue);let r;x(()=>{t.isOpen&&(n(t.initialValue),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return K(Fx,{get isOpen(){return t.isOpen},get title(){return t.title},get onClose(){return t.onClose},get footer(){return K(wE,{get onCancel(){return t.onClose},onConfirm:o,get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return t.confirmLabel},get cancelTestId(){var e;return null==(e=t.testIds)?void 0:e.cancel},get confirmTestId(){var e;return null==(e=t.testIds)?void 0:e.confirm}})},get children(){return K(hw,{ref(t){"function"==typeof r?r(t):r=t},get label(){return t.label},get value(){return a()},onChange:n,onKeyDown:t=>"Enter"===t.key&&o(),get placeholder(){return t.placeholder},get"data-testid"(){var e;return null==(e=t.testIds)?void 0:e.input}})}})}function AE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.link.title")},get label(){return e("dialog.link.label")},get placeholder(){return e("dialog.link.placeholder")},get initialValue(){return t.initialHref},get confirmLabel(){return e("generic.apply")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm},testIds:{input:"editor-link-dialog-input",cancel:"editor-link-dialog-cancel",confirm:"editor-link-dialog-apply"}})}function CE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageAlt.title")},get label(){return e("dialog.imageAlt.label")},get placeholder(){return e("dialog.imageAlt.placeholder")},get initialValue(){return t.initialAlt},get confirmLabel(){return e("generic.save")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm}})}function IE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageCaption.title")},get label(){return e("dialog.imageCaption.label")},get placeholder(){return e("dialog.imageCaption.placeholder")},get initialValue(){return t.initialCaption},get confirmLabel(){return e("generic.save")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm}})}const TE="#111827",kE=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],VE=[33,50,66,75,90,100,105,110,115,120,150,200];function RE(t){const e=Number(t.trim());return Number.isFinite(e)&&e>0?e:null}function EE(t){const e=Number(t.trim());return Number.isFinite(e)&&e>=0?e:null}function LE(t){return null==t||""===t?"":String(t)}function zE(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"expanded":"condensed":"normal"}function NE(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"raised":"lowered":"normal"}function OE(t){if(!t.trim())return null;const e=Number(t);return Number.isInteger(e)&&e>=1&&e<=20?e:null}function qE(t){switch(t){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 PE(t,e){const a=[];return"proportional"===t&&a.push("proportional-nums"),"tabular"===t&&a.push("tabular-nums"),"lining"===e&&a.push("lining-nums"),"oldStyle"===e&&a.push("oldstyle-nums"),a.join(" ")||void 0}function WE(t,e){const a=[],n=OE(t);return null!==n&&a.push(`"ss${String(n).padStart(2,"0")}" 1`),e&&a.push('"calt" 1'),a.join(", ")||void 0}function BE(t){return{familyFilter:"",fontFamily:t.fontFamily??"",fontSize:t.fontSize??"",colorMode:t.colorMode,color:t.color||TE,highlight:t.highlight||"",shading:t.shading||"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underline?t.underlineStyle??"single":"none",underlineColor:t.underlineColor||TE,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)}}function FE(t){return{characterScale:LE(t.characterScale),spacingMode:zE(t.characterSpacing),spacingAmount:t.characterSpacing?String(Math.abs(Number(t.characterSpacing))):"",positionMode:NE(t.baselineShift),positionAmount:t.baselineShift?String(Math.abs(Number(t.baselineShift))):"",kerningEnabled:""!==t.kerningThreshold,kerningThreshold:LE(t.kerningThreshold),ligatures:t.ligatures,numberSpacing:t.numberSpacing,numberForm:t.numberForm,stylisticSet:LE(t.stylisticSet),contextualAlternates:Boolean(t.contextualAlternates)}}function HE(t){const e=Ft(),[a,n]=y("font"),[r,o]=y(BE(t.initial)),[i,l]=y(FE(t.initial));x(()=>{t.isOpen&&(n("font"),o(BE(t.initial)),l(FE(t.initial)))});const s=w(()=>{return t=r().bold,e=r().italic,t&&e?"boldItalic":t?"bold":e?"italic":"regular";var t,e}),d=w(()=>{const e=r().familyFilter.trim().toLowerCase();return e?t.familyOptions.filter(t=>t.toLowerCase().includes(e)):t.familyOptions}),c=w(()=>{const e=new Set(kE);for(const n of t.sizeOptions)e.add(n);const a=Number(r().fontSize);return Number.isFinite(a)&&a>0&&e.add(a),Array.from(e).sort((t,e)=>t-e)}),h=w(()=>{const t=r().fontSize.trim();if(!t)return"";const a=Number(t);return Number.isFinite(a)&&a>0?"":e("dialog.font.sizeInvalid")}),p=w(()=>{const t=i();return t.characterScale.trim()&&null===RE(t.characterScale)?e("dialog.font.advancedScaleInvalid"):"normal"!==t.spacingMode&&null===EE(t.spacingAmount)||"normal"!==t.positionMode&&null===EE(t.positionAmount)?e("dialog.font.advancedAmountInvalid"):t.kerningThreshold.trim()&&null===EE(t.kerningThreshold)?e("dialog.font.advancedKerningInvalid"):t.stylisticSet.trim()&&null===OE(t.stylisticSet)?e("dialog.font.advancedStylisticSetInvalid"):""}),u=w(()=>function(t,e){const a=Number(t.fontSize),n=RE(e.characterScale)??100,r="normal"===e.spacingMode?null:EE(e.spacingAmount),o="normal"===e.positionMode?null:EE(e.positionAmount),i=null===r?void 0:"condensed"===e.spacingMode?`-${r}pt`:`${r}pt`,l=null===o?void 0:"lowered"===e.positionMode?`-${o}pt`:`${o}pt`,s=[];return t.underline&&"none"!==t.underlineStyle&&s.push("underline"),t.strike&&s.push("line-through"),t.doubleStrike&&s.push("line-through"),{"font-family":t.fontFamily||"inherit","font-size":Number.isFinite(a)&&a>0?`${a}pt`:void 0,"font-weight":t.bold?700:400,"font-style":t.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===t.colorMode?"inherit":t.color,"background-color":t.highlight||t.shading||void 0,"vertical-align":l??(t.superscript?"super":t.subscript?"sub":"baseline"),"font-stretch":`${n}%`,"letter-spacing":i,"font-variant-ligatures":qE(e.ligatures),"font-variant-numeric":PE(e.numberSpacing,e.numberForm),"font-feature-settings":WE(e.stylisticSet,e.contextualAlternates)}}(r(),i()));return{activeTab:a,setActiveTab:t=>n(t),fontTabValues:r,setFontTabValues:o,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(t,e)=>{o(a=>({...a,[t]:e}))},updateAdvancedTab:(t,e)=>{l(a=>({...a,[t]:e}))},selectedFontStyle:s,visibleFamilyOptions:d,effectiveSizeOptions:c,customSizeError:h,advancedValidationError:p,previewStyle:u,applyFontStylePreset:t=>{o(e=>({...e,bold:"bold"===t||"boldItalic"===t,italic:"italic"===t||"boldItalic"===t}))},handleApply:()=>{if(p())return;const e=function(t,e){const a=Number(t.fontSize),n=Number.isFinite(a)&&a>0,r="none"===t.underlineStyle?null:t.underlineStyle,o=null!==r,i=e.characterScale.trim()?RE(e.characterScale):null,l="normal"===e.spacingMode?null:EE(e.spacingAmount),s="normal"===e.positionMode?null:EE(e.positionAmount),d=e.kerningEnabled&&e.kerningThreshold.trim()?EE(e.kerningThreshold):null,c=OE(e.stylisticSet);return{fontFamily:t.fontFamily.trim()?t.fontFamily.trim():null,fontSize:n?a:null,colorMode:t.colorMode,color:"automatic"===t.colorMode?null:t.color||null,highlight:t.highlight||null,shading:t.shading||null,bold:t.bold,italic:t.italic,underline:o,underlineStyle:r,underlineColor:o&&t.underlineColor||null,strike:t.strike,doubleStrike:t.doubleStrike,superscript:t.superscript,subscript:t.subscript,smallCaps:t.smallCaps,allCaps:t.allCaps,hidden:t.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===e.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===e.positionMode?-s:s,kerningThreshold:d,ligatures:e.ligatures||null,numberSpacing:e.numberSpacing||null,numberForm:e.numberForm||null,stylisticSet:c,contextualAlternates:e.contextualAlternates}}(r(),i());t.onApply(e,t.initial),t.onClose()}}}var UE=gt("<div>");function GE(t){const e=Ft();return Ct(a=UE(),()=>e("dialog.font.previewText")),M(e=>{var n=t.class??"oasis-editor-dialog-preview",r=t.testId,o=t.style;return n!==e.e&&bt(a,e.e=n),r!==e.t&&vt(a,"data-testid",e.t=r),e.a=xt(a,o,e.a),e},{e:void 0,t:void 0,a:void 0}),a;var a}var DE=gt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function jE(t){const e=Ft(),{ctrl:a}=t;return Ct(n=DE(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:12,get children(){return K(hw,{get label(){return e("dialog.font.familyFilter")},get value(){return a.fontTabValues().familyFilter},onChange:t=>a.updateFontTab("familyFilter",t),"data-testid":"editor-font-dialog-family-filter"})}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.family")},get value(){return a.fontTabValues().fontFamily},onChange:t=>a.updateFontTab("fontFamily",t),"data-testid":"editor-font-dialog-family",get options(){return[{value:"",label:"—"},...a.visibleFamilyOptions().map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{class:"oasis-editor-font-dialog-size-group",get label(){return e("dialog.font.size")},get value(){return a.fontTabValues().fontSize},onChange:t=>a.updateFontTab("fontSize",t),"data-testid":"editor-font-dialog-size",get options(){return[{value:"",label:"—"},...a.effectiveSizeOptions().map(t=>({value:String(t),label:String(t)}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return[K(hw,{class:"oasis-editor-font-dialog-custom-size-group",get label(){return e("dialog.font.customSize")},get value(){return a.fontTabValues().fontSize},onChange:t=>a.updateFontTab("fontSize",t),"data-testid":"editor-font-dialog-custom-size"}),K(Xx,{class:"oasis-editor-dialog-help-text",get children(){return a.customSizeError()}})]}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{class:"oasis-editor-font-dialog-style-list-group",get label(){return e("dialog.font.styleList")},get value(){return a.selectedFontStyle()},onChange:t=>a.applyFontStylePreset(t),"data-testid":"editor-font-dialog-style-list",get options(){return[{value:"regular",label:e("dialog.font.styleRegular")},{value:"italic",label:e("dialog.font.styleItalic")},{value:"bold",label:e("dialog.font.styleBold")},{value:"boldItalic",label:e("dialog.font.styleBoldItalic")}]}})}})]}}),null),Ct(n,K(nw,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{class:"oasis-editor-font-dialog-color-mode-group",get label(){return e("dialog.font.color")},get value(){return a.fontTabValues().colorMode},onChange:t=>a.updateFontTab("colorMode",t),"data-testid":"editor-font-dialog-color-mode",get options(){return[{value:"automatic",label:e("toolbar.colorAutomatic")},{value:"custom",label:e("dialog.font.customColor")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(fw,{get label(){return e("dialog.font.color")},get value(){return a.fontTabValues().color},get disabled(){return"automatic"===a.fontTabValues().colorMode},onChange:t=>a.setFontTabValues(e=>({...e,color:t,colorMode:"custom"})),"data-testid":"editor-font-dialog-color"})}}),K(nw,{size:{xs:12,md:2},get children(){return K(fw,{get label(){return e("dialog.font.highlight")},get value(){return a.fontTabValues().highlight||"#fef08a"},onChange:t=>a.updateFontTab("highlight",t),"data-testid":"editor-font-dialog-highlight"})}}),K(nw,{size:{xs:12,md:2},get children(){return K(fw,{get label(){return e("dialog.font.shading")},get value(){return a.fontTabValues().shading||"#fef3c7"},onChange:t=>a.updateFontTab("shading",t),"data-testid":"editor-font-dialog-shading"})}})]}}),null),Ct(n,K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.underlineStyle")},get value(){return a.fontTabValues().underlineStyle},onChange:t=>a.setFontTabValues(e=>({...e,underlineStyle:t,underline:"none"!==t})),"data-testid":"editor-font-dialog-underline-style",get options(){return[{value:"none",label:e("toolbar.underlineRemove")},...$w.map(t=>({value:t.value,label:e(t.labelKey)}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(fw,{get label(){return e("dialog.font.underlineColor")},get value(){return a.fontTabValues().underlineColor||TE},get disabled(){return"none"===a.fontTabValues().underlineStyle},onChange:t=>a.setFontTabValues(e=>({...e,underlineColor:t,underline:"none"!==e.underlineStyle})),"data-testid":"editor-font-dialog-underline-color"})}})]}}),null),Ct(n,K(iw,{class:"oasis-editor-dialog-input-group-grow",get label(){return e("dialog.font.style")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return K(at,{get each(){return[{testId:"editor-font-dialog-bold",label:e("dialog.font.bold"),labelStyle:{"font-weight":700},checked:()=>a.fontTabValues().bold,onChange:t=>a.updateFontTab("bold",t)},{testId:"editor-font-dialog-italic",label:e("dialog.font.italic"),labelStyle:{"font-style":"italic"},checked:()=>a.fontTabValues().italic,onChange:t=>a.updateFontTab("italic",t)},{testId:"editor-font-dialog-underline",label:e("dialog.font.underline"),labelStyle:{"text-decoration":"underline"},checked:()=>a.fontTabValues().underline,onChange:t=>a.setFontTabValues(e=>({...e,underline:t,underlineStyle:t?"none"===e.underlineStyle?"single":e.underlineStyle:"none"}))},{testId:"editor-font-dialog-strike",label:e("dialog.font.strike"),labelStyle:{"text-decoration":"line-through"},checked:()=>a.fontTabValues().strike,onChange:t=>a.setFontTabValues(e=>({...e,strike:t,doubleStrike:!t&&e.doubleStrike}))},{testId:"editor-font-dialog-double-strike",label:e("dialog.font.doubleStrike"),checked:()=>a.fontTabValues().doubleStrike,onChange:t=>a.setFontTabValues(e=>({...e,doubleStrike:t,strike:!t&&e.strike}))},{testId:"editor-font-dialog-superscript",label:e("toolbar.superscript"),checked:()=>a.fontTabValues().superscript,onChange:t=>a.setFontTabValues(e=>({...e,superscript:t,subscript:!t&&e.subscript}))},{testId:"editor-font-dialog-subscript",label:e("toolbar.subscript"),checked:()=>a.fontTabValues().subscript,onChange:t=>a.setFontTabValues(e=>({...e,subscript:t,superscript:!t&&e.superscript}))},{testId:"editor-font-dialog-small-caps",label:e("dialog.font.smallCaps"),checked:()=>a.fontTabValues().smallCaps,onChange:t=>a.updateFontTab("smallCaps",t)},{testId:"editor-font-dialog-all-caps",label:e("dialog.font.allCaps"),checked:()=>a.fontTabValues().allCaps,onChange:t=>a.updateFontTab("allCaps",t)},{testId:"editor-font-dialog-hidden",label:e("dialog.font.hidden"),checked:()=>a.fontTabValues().hidden,onChange:t=>a.updateFontTab("hidden",t)}]},children:t=>K(Bw,{get label(){return t.label},get labelStyle(){return t.labelStyle},get checked(){return t.checked()},get onChange(){return t.onChange},get"data-testid"(){return t.testId}})})}})}}),null),Ct(n,K(iw,{get label(){return e("dialog.font.preview")},get children(){return K(GE,{testId:"editor-font-dialog-preview",get style(){return a.previewStyle()}})}}),null),n;var n}var ZE=gt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function KE(t){const e=Ft(),{ctrl:a}=t;return Ct(n=ZE(),K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedCharacterSpacingGroup")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("dialog.font.advancedScale")},get value(){return a.advancedTabValues().characterScale||"100"},onChange:t=>a.updateAdvancedTab("characterScale",t),"data-testid":"editor-font-dialog-advanced-scale",get options(){return VE.map(t=>({value:String(t),label:`${t}%`}))}})}}),K(nw,{size:{xs:12,md:8},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.advancedSpacing")},get value(){return a.advancedTabValues().spacingMode},onChange:t=>a.updateAdvancedTab("spacingMode",t),"data-testid":"editor-font-dialog-advanced-spacing-mode",get options(){return[{value:"normal",label:e("dialog.font.advancedNormal")},{value:"expanded",label:e("dialog.font.advancedExpanded")},{value:"condensed",label:e("dialog.font.advancedCondensed")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-small-input",get label(){return e("dialog.font.advancedBy")},get value(){return a.advancedTabValues().spacingAmount},get disabled(){return"normal"===a.advancedTabValues().spacingMode},onChange:t=>a.updateAdvancedTab("spacingAmount",t),"data-testid":"editor-font-dialog-advanced-spacing-amount"})}})]}})}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.advancedPosition")},get value(){return a.advancedTabValues().positionMode},onChange:t=>a.updateAdvancedTab("positionMode",t),"data-testid":"editor-font-dialog-advanced-position-mode",get options(){return[{value:"normal",label:e("dialog.font.advancedNormal")},{value:"raised",label:e("dialog.font.advancedRaised")},{value:"lowered",label:e("dialog.font.advancedLowered")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-small-input",get label(){return e("dialog.font.advancedBy")},get value(){return a.advancedTabValues().positionAmount},get disabled(){return"normal"===a.advancedTabValues().positionMode},onChange:t=>a.updateAdvancedTab("positionAmount",t),"data-testid":"editor-font-dialog-advanced-position-amount"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(bw,{class:"oasis-editor-font-dialog-kerning-toggle",get label(){return e("dialog.font.advancedKerning")},get checked(){return a.advancedTabValues().kerningEnabled},onChange:t=>a.setAdvancedTabValues(e=>({...e,kerningEnabled:t,kerningThreshold:t?e.kerningThreshold||"1":e.kerningThreshold})),"data-testid":"editor-font-dialog-advanced-kerning-enabled"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-kerning-input",get value(){return a.advancedTabValues().kerningThreshold},get disabled(){return!a.advancedTabValues().kerningEnabled},onChange:t=>a.updateAdvancedTab("kerningThreshold",t),"data-testid":"editor-font-dialog-advanced-kerning"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Xx,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return e("dialog.font.advancedKerningAbove")}})}})]}})}}),null),Ct(n,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedOpenTypeGroup")},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedLigatures")},get value(){return a.advancedTabValues().ligatures},onChange:t=>a.updateAdvancedTab("ligatures",t),"data-testid":"editor-font-dialog-advanced-ligatures",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"none",label:e("dialog.font.advancedLigaturesNone")},{value:"standard",label:e("dialog.font.advancedLigaturesStandard")},{value:"contextual",label:e("dialog.font.advancedLigaturesContextual")},{value:"historical",label:e("dialog.font.advancedLigaturesHistorical")},{value:"standardContextual",label:e("dialog.font.advancedLigaturesStandardContextual")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedNumberSpacing")},get value(){return a.advancedTabValues().numberSpacing},onChange:t=>a.updateAdvancedTab("numberSpacing",t),"data-testid":"editor-font-dialog-advanced-number-spacing",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"proportional",label:e("dialog.font.advancedNumberSpacingProportional")},{value:"tabular",label:e("dialog.font.advancedNumberSpacingTabular")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedNumberForm")},get value(){return a.advancedTabValues().numberForm},onChange:t=>a.updateAdvancedTab("numberForm",t),"data-testid":"editor-font-dialog-advanced-number-form",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"lining",label:e("dialog.font.advancedNumberFormLining")},{value:"oldStyle",label:e("dialog.font.advancedNumberFormOldStyle")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedStylisticSet")},get value(){return a.advancedTabValues().stylisticSet},onChange:t=>a.updateAdvancedTab("stylisticSet",t),"data-testid":"editor-font-dialog-advanced-stylistic-set",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},...Array.from({length:20},(t,e)=>e+1).map(t=>({value:String(t),label:String(t)}))]}})}})]}}),K(bw,{class:"oasis-editor-font-dialog-contextual-toggle",get label(){return e("dialog.font.advancedContextualAlternates")},get checked(){return a.advancedTabValues().contextualAlternates},onChange:t=>a.updateAdvancedTab("contextualAlternates",t),"data-testid":"editor-font-dialog-advanced-contextual-alternates"})]}}),null),Ct(n,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedPreviewGroup")},get children(){return K(GE,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return a.previewStyle()}})}}),null),Ct(n,K(Xx,{as:"p",class:"oasis-editor-dialog-help-text","data-testid":"editor-font-dialog-advanced-placeholder",get children(){return a.advancedValidationError()||e("dialog.font.advancedPlaceholder")}}),null),n;var n}function XE(t){const e=Ft(),a=HE(t);return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("dialog.font.title")},get onClose(){return t.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return K(wE,{get onCancel(){return t.onClose},get onConfirm(){return a.handleApply},get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.ok")},cancelTestId:"editor-font-dialog-cancel",confirmTestId:"editor-font-dialog-apply"})},get children(){return K(jx,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return e("dialog.font.title")},get value(){return a.activeTab()},onChange:t=>a.setActiveTab(t),get items(){return[{id:"font",label:e("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:K(jE,{ctrl:a})},{id:"advanced",label:e("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:K(KE,{ctrl:a})}]}})}})}var YE=gt("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>");const JE="#000000";function QE(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function _E(t){const e=Ft(),[a,n]=y(""),[r,o]=y(null),[i,l]=y(null),[s,d]=y("none"),[c,h]=y(null),[p,u]=y(null),[f,g]=y(null),[m,v]=y(null),[b,S]=y(""),[A,C]=y("none"),[I,T]=y(null),[k,V]=y(""),[R,E]=y(!1),[L,z]=y(!1),[N,O]=y(!1),[q,P]=y(!1);x(()=>{if(t.isOpen){n(t.initial.align??""),o(QE(t.initial.indentLeft??"")),l(QE(t.initial.indentRight??"")),u(QE(t.initial.spacingBefore??"")),g(QE(t.initial.spacingAfter??"")),v(QE(t.initial.lineHeight??"")),S(t.initial.shading??"");const e=t.initial.borderStyle;C("solid"===e||"dashed"===e||"dotted"===e?e:"none"),T(QE(t.initial.borderWidth??"")),V(t.initial.borderColor??""),E(t.initial.borderSideTop??!1),z(t.initial.borderSideRight??!1),O(t.initial.borderSideBottom??!1),P(t.initial.borderSideLeft??!1);const a=QE(t.initial.indentFirstLine??""),r=QE(t.initial.indentHanging??"");null!==r&&r>0?(d("hanging"),h(r)):null!==a&&a>0?(d("firstLine"),h(a)):(d("none"),h(null))}});const W=w(()=>{const t=m(),e=r(),n=i(),o="firstLine"===s()?c():null,l="hanging"===s()?c():null,d=null!==o?o:null!==l?-l:null,h="none"!==A()?`${I()??.5}pt ${A()} ${k().trim()||JE}`:void 0;return{"text-align":a()||void 0,"line-height":null!==t&&t>0?String(t):void 0,"padding-left":null!==e?`${e+(l??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==d?`${d}pt`:void 0,"background-color":b().trim()||void 0,"border-top":h&&R()?h:void 0,"border-right":h&&L()?h:void 0,"border-bottom":h&&N()?h:void 0,"border-left":h&&q()?h:void 0}}),B=()=>{const t=A();if("none"===t)return{top:null,right:null,bottom:null,left:null};const e=I(),a={type:t,width:null!==e&&e>0?e:.5,color:k().trim()||JE};return{top:R()?a:null,right:L()?a:null,bottom:N()?a:null,left:q()?a:null}},F=()=>{const e=c();t.onApply({align:a()||null,indentLeft:r(),indentRight:i(),indentFirstLine:"firstLine"===s()?e:null,indentHanging:"hanging"===s()?e:null,spacingBefore:p(),spacingAfter:f(),lineHeight:m(),shading:b().trim()||null,borders:B()},t.initial),t.onClose()};return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("paragraph.title")},get onClose(){return t.onClose},get footer(){return K(wE,{get onCancel(){return t.onClose},onConfirm:F,get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.apply")},cancelTestId:"editor-paragraph-dialog-cancel",confirmTestId:"editor-paragraph-dialog-apply"})},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("paragraph.alignLabel")},get value(){return a()},onChange:n,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:e("paragraph.alignLeft")},{value:"center",label:e("paragraph.alignCenter")},{value:"right",label:e("paragraph.alignRight")},{value:"justify",label:e("paragraph.alignJustify")}]}})}})}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.indentLeftLabel")},step:"1",get value(){return r()??""},onChange:o,"data-testid":"editor-paragraph-dialog-indent-left"})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.indentRightLabel")},step:"1",get value(){return i()??""},onChange:l,"data-testid":"editor-paragraph-dialog-indent-right"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("paragraph.specialLabel")},get value(){return s()},onChange:t=>{const e=t;d(e),"none"===e&&h(null)},"data-testid":"editor-paragraph-dialog-special",get options(){return[{value:"none",label:e("paragraph.specialNone")},{value:"firstLine",label:e("paragraph.specialFirstLine")},{value:"hanging",label:e("paragraph.specialHanging")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===s()},get value(){return c()??""},onChange:h,"data-testid":"editor-paragraph-dialog-special-by"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return p()??""},onChange:u,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return f()??""},onChange:g,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.lineSpacingLabel")},min:"0.5",step:"0.05",get value(){return m()??""},onChange:v,"data-testid":"editor-paragraph-dialog-line-height"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("paragraph.borderStyleLabel")},get value(){return A()},onChange:t=>{const e=t;C(e),"none"===e?(E(!1),z(!1),O(!1),P(!1)):R()||L()||N()||q()||(E(!0),z(!0),O(!0),P(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:e("paragraph.borderNone")},{value:"solid",label:e("paragraph.borderSolid")},{value:"dashed",label:e("paragraph.borderDashed")},{value:"dotted",label:e("paragraph.borderDotted")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return K(Cw,{get label(){return e("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===A()},get value(){return I()??""},onChange:T,"data-testid":"editor-paragraph-dialog-border-width"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.borderColorLabel")},get disabled(){return"none"===A()},get value(){return k()||JE},onChange:V,"data-testid":"editor-paragraph-dialog-border-color"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.shadingLabel")},get value(){return b()||"#ffffff"},onChange:S,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),K(iw,{class:"oasis-editor-dialog-input-group-grow",get label(){return e("paragraph.borderSidesLabel")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("paragraph.borderSideTop")},get disabled(){return"none"===A()},get checked(){return R()},onChange:E,"data-testid":"editor-paragraph-dialog-border-side-top"}),K(bw,{get label(){return e("paragraph.borderSideRight")},get disabled(){return"none"===A()},get checked(){return L()},onChange:z,"data-testid":"editor-paragraph-dialog-border-side-right"}),K(bw,{get label(){return e("paragraph.borderSideBottom")},get disabled(){return"none"===A()},get checked(){return N()},onChange:O,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),K(bw,{get label(){return e("paragraph.borderSideLeft")},get disabled(){return"none"===A()},get checked(){return q()},onChange:P,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}}),K(iw,{get label(){return e("paragraph.preview")},get children(){var t=YE();return Ct(t,()=>e("paragraph.previewText")),M(e=>xt(t,W(),e)),t}})]}})}const $E="#000000";function tL(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function eL(t,e){const a=tL(t);return null===a?null:"percent"===e?`${a}%`:a}function aL(t,e,a){if("none"===t)return null;const n=tL(e);return{type:t,width:null!==n&&n>0?n:.5,color:a.trim()||$E}}function nL(t){const[e,a]=ue({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:""});x(()=>{var e;t.isOpen&&a(me({activeTab:(e=t.initial).activeTab??"table",tableWidth:e.tableWidth,tableWidthUnit:e.tableWidthUnit,tableAlign:e.tableAlign,tableIndentLeft:e.tableIndentLeft,tableWrapping:e.tableWrapping,floatingHorizontalAnchor:e.floatingHorizontalAnchor,floatingVerticalAnchor:e.floatingVerticalAnchor,floatingX:e.floatingX,floatingY:e.floatingY,floatingXAlign:e.floatingXAlign,floatingYAlign:e.floatingYAlign,floatingDistanceTop:e.floatingDistanceTop,floatingDistanceRight:e.floatingDistanceRight,floatingDistanceBottom:e.floatingDistanceBottom,floatingDistanceLeft:e.floatingDistanceLeft,floatingOverlap:e.floatingOverlap,rowHeight:e.rowHeight,rowHeightRule:e.rowHeightRule,repeatHeader:e.repeatHeader,allowBreakAcrossPages:e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:e.columnWidth,cellWidth:e.cellWidth,cellVerticalAlign:e.cellVerticalAlign,cellTextDirection:e.cellTextDirection,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,marginTop:e.marginTop,marginRight:e.marginRight,marginBottom:e.marginBottom,marginLeft:e.marginLeft,borderStyle:e.borderStyle,borderWidth:e.borderWidth,borderColor:e.borderColor,borderTop:e.borderTop,borderRight:e.borderRight,borderBottom:e.borderBottom,borderLeft:e.borderLeft,borderStart:e.borderStart,borderEnd:e.borderEnd,borderTlBr:e.borderTopLeftToBottomRight,borderTrBl:e.borderTopRightToBottomLeft,shading:e.shading,altTitle:e.altTitle,altDescription:e.altDescription}))});return{form:e,set:a,handleApply:()=>{t.onApply(function(t){const e=aL(t.borderStyle,t.borderWidth,t.borderColor);return{tableWidth:eL(t.tableWidth,t.tableWidthUnit),tableAlign:t.tableAlign||null,tableIndentLeft:eL(t.tableIndentLeft,"points"),tableFloating:"around"===t.tableWrapping?{horizontalAnchor:t.floatingHorizontalAnchor,verticalAnchor:t.floatingVerticalAnchor,...t.floatingXAlign?{xAlign:t.floatingXAlign}:{x:tL(t.floatingX)??0},...t.floatingYAlign?{yAlign:t.floatingYAlign}:{y:tL(t.floatingY)??0},distanceTop:tL(t.floatingDistanceTop)??0,distanceRight:tL(t.floatingDistanceRight)??0,distanceBottom:tL(t.floatingDistanceBottom)??0,distanceLeft:tL(t.floatingDistanceLeft)??0}:null,tableOverlap:"around"===t.tableWrapping?t.floatingOverlap:null,rowHeight:eL(t.rowHeight,"points"),rowHeightRule:t.rowHeightRule||null,repeatHeader:t.repeatHeader,cantSplit:!t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:eL(t.columnWidth,"points"),cellWidth:eL(t.cellWidth,"points"),cellVerticalAlign:t.cellVerticalAlign||null,cellTextDirection:t.cellTextDirection||null,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,margins:{top:tL(t.marginTop),right:tL(t.marginRight),bottom:tL(t.marginBottom),left:tL(t.marginLeft)},borders:{top:t.borderTop?e:null,right:t.borderRight?e:null,bottom:t.borderBottom?e:null,left:t.borderLeft?e:null,start:t.borderStart?e:null,end:t.borderEnd?e:null,topLeftToBottomRight:t.borderTlBr?e:null,topRightToBottomLeft:t.borderTrBl?e:null},shading:t.shading.trim()||null,altTitle:t.altTitle.trim()||null,altDescription:t.altDescription.trim()||null}}(e),t.initial),t.onClose()}}}function rL(t,e,a,n,r=!1,o=!1){return K(hw,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:t,min:o?void 0:"0",step:"1",get value(){return e()},disabled:r,onChange:a,"data-testid":n})}var oL=gt("<div class=oasis-editor-table-properties-panel>");function iL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=oL(),K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.sizeSection")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.preferredWidth"),()=>a().tableWidth,t=>n("tableWidth",t),"editor-table-properties-table-width")}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.measureIn")},get value(){return a().tableWidthUnit},onChange:t=>n("tableWidthUnit",t),"data-testid":"editor-table-properties-table-width-unit",get options(){return[{value:"points",label:e("table.points")},{value:"percent",label:e("table.percent")}]}})}})]}})}}),null),Ct(r,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.alignmentSection")},get children(){return[K(Lw,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return a().tableAlign},onChange:t=>n("tableAlign",t),get children(){return["left","center","right"].map(t=>K(Ew,{value:t,get label(){return e(`table.align${t[0].toUpperCase()}${t.slice(1)}`)},"data-testid":`editor-table-properties-align-${t}`}))}}),K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.indentFromLeft"),()=>a().tableIndentLeft,t=>n("tableIndentLeft",t),"editor-table-properties-indent-left")}})}})]}}),null),Ct(r,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.textWrappingSection")},get children(){return[K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.wrapNone")},get checked(){return"none"===a().tableWrapping},onChange:()=>n("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),K(bw,{get label(){return e("table.wrapAround")},get checked(){return"around"===a().tableWrapping},onChange:()=>n("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),K(rt,{get when(){return"around"===a().tableWrapping},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.horizontalAnchor")},get value(){return a().floatingHorizontalAnchor},onChange:t=>n("floatingHorizontalAnchor",t),"data-testid":"editor-table-properties-floating-h-anchor",get options(){return[{value:"margin",label:e("table.anchorMargin")},{value:"page",label:e("table.anchorPage")},{value:"text",label:e("table.anchorText")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.verticalAnchor")},get value(){return a().floatingVerticalAnchor},onChange:t=>n("floatingVerticalAnchor",t),"data-testid":"editor-table-properties-floating-v-anchor",get options(){return[{value:"margin",label:e("table.anchorMargin")},{value:"page",label:e("table.anchorPage")},{value:"text",label:e("table.anchorText")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.positionX"),()=>a().floatingX,t=>n("floatingX",t),"editor-table-properties-floating-x",Boolean(a().floatingXAlign),!0)}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.positionY"),()=>a().floatingY,t=>n("floatingY",t),"editor-table-properties-floating-y",Boolean(a().floatingYAlign),!0)}}),K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("table.horizontalAlignment")},get value(){return a().floatingXAlign},onChange:t=>n("floatingXAlign",t),"data-testid":"editor-table-properties-floating-x-align",get options(){return[{value:"",label:e("table.explicitOffset")},...["left","center","right","inside","outside"].map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("table.verticalAlignment")},get value(){return a().floatingYAlign},onChange:t=>n("floatingYAlign",t),"data-testid":"editor-table-properties-floating-y-align",get options(){return[{value:"",label:e("table.explicitOffset")},...["top","center","bottom","inside","outside"].map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceTop"),()=>a().floatingDistanceTop,t=>n("floatingDistanceTop",t),"editor-table-properties-floating-distance-top")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceRight"),()=>a().floatingDistanceRight,t=>n("floatingDistanceRight",t),"editor-table-properties-floating-distance-right")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceBottom"),()=>a().floatingDistanceBottom,t=>n("floatingDistanceBottom",t),"editor-table-properties-floating-distance-bottom")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceLeft"),()=>a().floatingDistanceLeft,t=>n("floatingDistanceLeft",t),"editor-table-properties-floating-distance-left")}})]}}),K(bw,{get label(){return e("table.allowOverlap")},get checked(){return"overlap"===a().floatingOverlap},onChange:t=>n("floatingOverlap",t?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),r;var r}var lL=gt("<div class=oasis-editor-table-properties-panel>");function sL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=lL(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.rowHeight"),()=>a().rowHeight,t=>n("rowHeight",t),"editor-table-properties-row-height")}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.rowHeightRule")},get value(){return a().rowHeightRule},onChange:t=>n("rowHeightRule",t),"data-testid":"editor-table-properties-row-height-rule",get options(){return[{value:"",label:e("table.rowAuto")},{value:"atLeast",label:e("table.rowAtLeast")},{value:"exact",label:e("table.rowExactly")}]}})}})]}}),null),Ct(r,K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.repeatHeader")},get checked(){return a().repeatHeader},onChange:t=>n("repeatHeader",t),"data-testid":"editor-table-properties-repeat-header"}),K(bw,{get label(){return e("table.allowBreakAcrossPages")},get checked(){return a().allowBreakAcrossPages},onChange:t=>n("allowBreakAcrossPages",t),"data-testid":"editor-table-properties-allow-break"}),K(bw,{get label(){return e("table.hiddenRow")},get checked(){return a().hiddenRow},onChange:t=>n("hiddenRow",t),"data-testid":"editor-table-properties-hidden-row"})]}}),null),r;var r}var dL=gt("<div class=oasis-editor-table-properties-panel>");function cL(t){const e=Ft(),a=t.ctrl.set;return Ct(n=dL(),K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.columnWidth"),()=>t.ctrl.form.columnWidth,t=>a("columnWidth",t),"editor-table-properties-column-width")}})}})),n;var n}var hL=gt("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),pL=gt("<div class=oasis-editor-table-properties-panel>");function uL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set,r=w(()=>{const t=aL(a().borderStyle,a().borderWidth,a().borderColor),e=t?`${t.width}pt ${t.type} ${t.color}`:void 0;return{"background-color":a().shading.trim()||void 0,"border-top":e&&a().borderTop?e:"1px solid #dadce0","border-right":e&&a().borderRight?e:"1px solid #dadce0","border-bottom":e&&a().borderBottom?e:"1px solid #dadce0","border-left":e&&a().borderLeft?e:"1px solid #dadce0"}}),o=()=>"none"===a().borderStyle;return Ct(i=pL(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return rL(e("table.cellWidth"),()=>a().cellWidth,t=>n("cellWidth",t),"editor-table-properties-cell-width")}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("table.verticalAlignment")},get value(){return a().cellVerticalAlign},onChange:t=>n("cellVerticalAlign",t),"data-testid":"editor-table-properties-cell-valign",get options(){return[{value:"",label:e("table.inherit")},{value:"top",label:e("table.valignTop")},{value:"middle",label:e("table.valignMiddle")},{value:"bottom",label:e("table.valignBottom")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("table.textDirection")},get value(){return a().cellTextDirection},onChange:t=>n("cellTextDirection",t),"data-testid":"editor-table-properties-cell-direction",get options(){return[{value:"",label:e("table.inherit")},{value:"lrTb",label:"lrTb"},{value:"tbRl",label:"tbRl"},{value:"btLr",label:"btLr"},{value:"lrTbV",label:"lrTbV"},{value:"tbRlV",label:"tbRlV"}]}})}})]}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.options")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.noWrap")},get checked(){return a().cellNoWrap},onChange:t=>n("cellNoWrap",t),"data-testid":"editor-table-properties-cell-nowrap"}),K(bw,{get label(){return e("table.fitText")},get checked(){return a().cellFitText},onChange:t=>n("cellFitText",t),"data-testid":"editor-table-properties-cell-fit-text"}),K(bw,{get label(){return e("table.hideMark")},get checked(){return a().cellHideMark},onChange:t=>n("cellHideMark",t),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.cellMargins")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideTop"),()=>a().marginTop,t=>n("marginTop",t),"editor-table-properties-margin-top")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideRight"),()=>a().marginRight,t=>n("marginRight",t),"editor-table-properties-margin-right")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideBottom"),()=>a().marginBottom,t=>n("marginBottom",t),"editor-table-properties-margin-bottom")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideLeft"),()=>a().marginLeft,t=>n("marginLeft",t),"editor-table-properties-margin-left")}})]}})}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("paragraph.bordersSection")},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("paragraph.borderStyleLabel")},get value(){return a().borderStyle},onChange:t=>{const e=t;n("borderStyle",e),"none"===e?(n("borderTop",!1),n("borderRight",!1),n("borderBottom",!1),n("borderLeft",!1),n("borderStart",!1),n("borderEnd",!1),n("borderTlBr",!1),n("borderTrBl",!1)):a().borderTop||a().borderRight||a().borderBottom||a().borderLeft||(n("borderTop",!0),n("borderRight",!0),n("borderBottom",!0),n("borderLeft",!0))},"data-testid":"editor-table-properties-border-style",get options(){return[{value:"none",label:e("paragraph.borderNone")},{value:"solid",label:e("paragraph.borderSolid")},{value:"dashed",label:e("paragraph.borderDashed")},{value:"dotted",label:e("paragraph.borderDotted")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderWidthLabel"),()=>a().borderWidth,t=>n("borderWidth",t),"editor-table-properties-border-width",o())}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.borderColorLabel")},get value(){return a().borderColor||$E},get disabled(){return o()},onChange:t=>n("borderColor",t),"data-testid":"editor-table-properties-border-color"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.shadingLabel")},get value(){return a().shading||"#ffffff"},onChange:t=>n("shading",t),"data-testid":"editor-table-properties-shading"})}})]}}),K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("paragraph.borderSideTop")},get checked(){return a().borderTop},get disabled(){return o()},onChange:t=>n("borderTop",t),"data-testid":"editor-table-properties-border-top"}),K(bw,{get label(){return e("paragraph.borderSideRight")},get checked(){return a().borderRight},get disabled(){return o()},onChange:t=>n("borderRight",t),"data-testid":"editor-table-properties-border-right"}),K(bw,{get label(){return e("paragraph.borderSideBottom")},get checked(){return a().borderBottom},get disabled(){return o()},onChange:t=>n("borderBottom",t),"data-testid":"editor-table-properties-border-bottom"}),K(bw,{get label(){return e("paragraph.borderSideLeft")},get checked(){return a().borderLeft},get disabled(){return o()},onChange:t=>n("borderLeft",t),"data-testid":"editor-table-properties-border-left"}),K(bw,{get label(){return e("table.borderStart")},get checked(){return a().borderStart},get disabled(){return o()},onChange:t=>n("borderStart",t),"data-testid":"editor-table-properties-border-start"}),K(bw,{get label(){return e("table.borderEnd")},get checked(){return a().borderEnd},get disabled(){return o()},onChange:t=>n("borderEnd",t),"data-testid":"editor-table-properties-border-end"}),K(bw,{get label(){return e("table.borderTlBr")},get checked(){return a().borderTlBr},get disabled(){return o()},onChange:t=>n("borderTlBr",t),"data-testid":"editor-table-properties-border-tlbr"}),K(bw,{get label(){return e("table.borderTrBl")},get checked(){return a().borderTrBl},get disabled(){return o()},onChange:t=>n("borderTrBl",t),"data-testid":"editor-table-properties-border-trbl"})]}}),(t=hL(),M(e=>xt(t,r(),e)),t)];var t}}),null),i;var i}var fL=gt("<div class=oasis-editor-table-properties-panel>");function gL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=fL(),K(hw,{get label(){return e("table.altTitle")},get value(){return a().altTitle},onChange:t=>n("altTitle",t),"data-testid":"editor-table-properties-alt-title"}),null),Ct(r,K(uw,{class:"oasis-editor-dialog-input-group",get label(){return e("table.altDescription")},controlClass:"oasis-editor-table-properties-textarea",get value(){return a().altDescription},onChange:t=>n("altDescription",t),"data-testid":"editor-table-properties-alt-description"}),null),r;var r}function mL(t){const e=Ft(),a=nL(t);return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("table.propertiesTitle")},get onClose(){return t.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return K(wE,{get onCancel(){return t.onClose},get onConfirm(){return a.handleApply},get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.ok")},cancelTestId:"editor-table-properties-cancel",confirmTestId:"editor-table-properties-apply"})},get children(){return K(jx,{get value(){return a.form.activeTab},onChange:t=>a.set("activeTab",t),get ariaLabel(){return e("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:e("table.tabTable"),testId:"editor-table-properties-tab-table",panel:K(iL,{ctrl:a})},{id:"row",label:e("table.tabRow"),testId:"editor-table-properties-tab-row",panel:K(sL,{ctrl:a})},{id:"column",label:e("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:K(cL,{ctrl:a})},{id:"cell",label:e("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:K(uL,{ctrl:a})},{id:"altText",label:e("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:K(gL,{ctrl:a})}]}})}})}var vL=gt("<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 bL(t){const e=Ft(),{fr:a}=t,n=t=>{"Enter"===t.key?(t.preventDefault(),t.shiftKey?a.findPrevious():a.findNext()):"Escape"===t.key&&a.setIsOpen(!1)};return K(rt,{get when(){return a.isOpen()},get children(){var t=vL(),r=t.firstChild,o=r.nextSibling,i=o.firstChild,l=i.firstChild,s=i.nextSibling;return t.$$keydown=n,Ct(r,K(wn,{get children(){return e("find.title")}}),null),Ct(r,K(xn,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>a.setIsOpen(!1),get label(){return e("generic.close")}}),null),Ct(l,K(hw,{type:"text",get placeholder(){return e("find.placeholder")},get value(){return a.searchTerm()},onChange:t=>a.setSearchTerm(t),autofocus:!0,controlClass:"oasis-editor-fr-input"}),null),Ct(l,K(Xx,{class:"oasis-editor-fr-counter",get children(){return pt(()=>a.matches().length>0)()?`${a.currentIndex()+1} / ${a.matches().length}`:e("find.noMatches")}}),null),Ct(i,K(aw,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[K(xn,{get onClick(){return a.findPrevious},get disabled(){return 0===a.matches().length},icon:"chevron-up",get label(){return e("find.prevTooltip")}}),K(xn,{get onClick(){return a.findNext},get disabled(){return 0===a.matches().length},icon:"chevron-down",get label(){return e("find.nextTooltip")}})]}}),null),Ct(s,K(hw,{type:"text",get placeholder(){return e("replace.placeholder")},get value(){return a.replaceTerm()},onChange:t=>a.setReplaceTerm(t),controlClass:"oasis-editor-fr-input"}),null),Ct(s,K(aw,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[K(xn,{class:"oasis-editor-fr-btn-text",get onClick(){return a.replace},get disabled(){return 0===a.matches().length},get children(){return e("replace.one")}}),K(xn,{class:"oasis-editor-fr-btn-text",get onClick(){return a.replaceAll},get disabled(){return 0===a.matches().length},get children(){return e("replace.allBtn")}})]}}),null),Ct(o,K(aw,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[K(bw,{class:"oasis-editor-fr-checkbox",get label(){return e("find.matchCase")},get checked(){return a.findOptions().matchCase},onChange:t=>a.setFindOptions({...a.findOptions(),matchCase:t})}),K(bw,{class:"oasis-editor-fr-checkbox",get label(){return e("find.wholeWord")},get checked(){return a.findOptions().wholeWord},onChange:t=>a.setFindOptions({...a.findOptions(),wholeWord:t})})]}}),null),t}})}mt(["keydown"]);var yL=gt("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),ML=gt("<i>"),xL=gt("<span class=oasis-editor-context-menu-shortcut>"),wL=gt("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),SL=gt("<div class=oasis-editor-context-menu-separator>"),AL=gt("<i data-lucide=check style=visibility:hidden>");function CL(t){let e;const a=e=>{t.isOpen&&"Escape"===e.key&&(e.preventDefault(),t.onClose())},n=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},r=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},o=()=>{t.isOpen&&t.onClose()};return C(()=>{window.addEventListener("keydown",a,!0),window.addEventListener("mousedown",n,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o,!0)}),I(()=>{window.removeEventListener("keydown",a,!0),window.removeEventListener("mousedown",n,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o,!0)}),x(()=>{if(!t.isOpen||!e)return;const a=e.getBoundingClientRect(),n=Math.max(4,window.innerWidth-a.width-4),r=Math.max(4,window.innerHeight-a.height-4),o=Math.min(t.x,n),i=Math.min(t.y,r);e.style.left=`${o}px`,e.style.top=`${i}px`}),K(rt,{get when(){return t.isOpen},get children(){var a=yL();a.$$contextmenu=t=>t.preventDefault();return"function"==typeof e?At(e,a):e=a,Ct(a,K(at,{get each(){return t.items},children:e=>K(rt,{get when(){return"separator"!==e.type},get fallback(){return SL()},get children(){var a=wL(),n=a.firstChild;return a.$$click=()=>{var a;e.disabled||(null==(a=e.onSelect)||a.call(e),t.onClose())},Ct(a,K(rt,{get when(){return e.icon},get fallback(){return AL()},get children(){var t=ML();return M(()=>vt(t,"data-lucide",e.icon)),t}}),n),Ct(n,()=>e.label),Ct(a,K(rt,{get when(){return e.shortcut},get children(){var t=xL();return Ct(t,()=>e.shortcut),t}}),null),M(t=>{var n=e.disabled,r=e.testId;return n!==t.e&&(a.disabled=t.e=n),r!==t.t&&vt(a,"data-testid",t.t=r),t},{e:void 0,t:void 0}),a}})})),M(e=>{var n=`${t.x}px`,r=`${t.y}px`;return n!==e.e&&wt(a,"left",e.e=n),r!==e.t&&wt(a,"top",e.t=r),e},{e:void 0,t:void 0}),a}})}function IL(t){const{linkDialog:e,setLinkDialog:a,imageAltDialog:n,setImageAltDialog:r,imageCaptionDialog:o,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}=t.dialogs;return[K(AE,{get isOpen(){return e().isOpen},get initialHref(){return e().initialHref},onClose:()=>{a({...e(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyLinkCommand(e.trim()||null)}),K(CE,{get isOpen(){return n().isOpen},get initialAlt(){return n().initialAlt},onClose:()=>{r({...n(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageAltCommand(e.trim())}),K(IE,{get isOpen(){return o().isOpen},get initialCaption(){return o().initialCaption},onClose:()=>{i({...o(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageCaptionCommand(e.trim())}),K(bL,{get fr(){return t.findReplace}}),K(XE,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return t.fontFamilyOptions()},get sizeOptions(){return t.fontSizeOptions()},onClose:()=>{d({...s(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyFontDialogValues}}),K(_E,{get isOpen(){return c().isOpen},get initial(){return c().initial},onClose:()=>{h({...c(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyParagraphDialogValues}}),K(mL,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{u({...p(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyTablePropertiesDialogValues}}),K(CL,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return t.contextMenuItems()},get onClose(){return t.closeContextMenu}})]}mt(["contextmenu","click"]);var TL=gt("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function kL(t){return[K(rt,{get when(){return t.useComposedShell()},get children(){return(()=>{const e=t.shellComponent(),{runtime:a,chrome:n,view:r}=t;return K(e,{get state(){return a.state()},get toolbarHost(){return a.toolbarHost},get runtimeEditor(){return a.runtimeEditor},get persistenceStatus(){return a.persistenceStatus},get toolbarRegistry(){return a.toolbarRegistry},get menuRegistry(){return a.menuRegistry},get showChrome(){return n.showChrome()},get showTitleBar(){return n.showTitleBar()},get showMenubar(){return n.showMenubar()},get showToolbar(){return n.showToolbar()},get showOutline(){return n.showOutline()},get toolbarView(){return n.toolbarView()},get toolbarLayout(){return n.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 showFloatingTableToolbar(){return a.showFloatingTableToolbar},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}})})()}}),K(rt,{get when(){return!t.useComposedShell()},get children(){return K(kx,{get editor(){return t.runtime.runtimeEditor},get children(){var e=TL();return Ct(e.firstChild,K(ix,{get state(){return t.runtime.state},get layout(){return{...t.view.layout,documentLayout:t.view.documentLayout,measuredBlockHeights:t.view.measuredBlockHeights,measuredParagraphLayouts:t.view.measuredParagraphLayouts,readOnly:t.view.isReadOnly()}},get overlays(){return{...t.view.overlays,toolbarHost:t.runtime.toolbarHost,persistenceStatus:t.runtime.persistenceStatus,showFloatingTableToolbar:t.runtime.showFloatingTableToolbar}},get refs(){return t.view.refs},get surfaceHandlers(){return t.view.surfaceHandlers},get inputHandlers(){return t.view.inputHandlers},get fileHandlers(){return t.view.fileHandlers}})),e}})}})]}var VL=gt("<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 RL(t){const e=Ft(),a=()=>{Qs(),Hs(),t.onClose()},n=()=>{Us(!1),Hs(),t.onClose()};return K(rt,{get when(){return t.isOpen},get children(){var t=VL(),r=t.firstChild,o=r.firstChild,i=o.nextSibling,l=i.nextSibling,s=l.nextSibling;return Ct(r,K(Gt,{height:72,class:"oasis-editor-welcome-mark"}),o),Ct(o,()=>e("welcome.title")),Ct(i,()=>e("welcome.body")),Ct(l,()=>e("welcome.note")),Ct(s,K(Kx,{variant:"secondary",onClick:n,"data-testid":"editor-welcome-skip",get children(){return e("welcome.skip")}}),null),Ct(s,K(Kx,{variant:"primary",onClick:a,"data-testid":"editor-welcome-enable",get children(){return e("welcome.enable")}}),null),t}})}const EL="http://schemas.openxmlformats.org/wordprocessingml/2006/main",LL="http://schemas.openxmlformats.org/package/2006/relationships",zL="http://schemas.openxmlformats.org/officeDocument/2006/relationships",NL="http://schemas.microsoft.com/office/word/2010/wordml";function OL(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qL(t,e){return Number.isFinite(t)?Math.max(0,Math.round(t/ke*Ne)):e}function PL(t){return null!=t&&Number.isFinite(t)?Math.round(t/ke*Ne):null}function WL(t){return null!=t&&Number.isFinite(t)?Math.max(0,Math.round(20*t)):null}function BL(t,e="000000"){return Rp(t)??e}function FL(t){if("end"===t.kind)return`<w:bookmarkEnd w:id="${t.wId}"/>`;const e=(void 0!==t.colFirst?` w:colFirst="${t.colFirst}"`:"")+(void 0!==t.colLast?` w:colLast="${t.colLast}"`:"");return`<w:bookmarkStart w:id="${t.wId}" w:name="${OL(t.name??"")}"${e}/>`}function HL(t){switch(t.kind){case"start":return`<w:commentRangeStart w:id="${t.wId}"/>`;case"end":return`<w:commentRangeEnd w:id="${t.wId}"/>`;case"reference":return`<w:r><w:commentReference w:id="${t.wId}"/></w:r>`}}const UL=`xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16du="http://schemas.microsoft.com/office/word/2023/wordml/word16du"`;function GL(t){const e=t.comments.map(({comment:t,wId:e,paraId:a})=>{const n=void 0!==t.date?` w:date="${new Date(t.date).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",r=void 0!==t.dateUtc?` w16du:dateUtc="${new Date(t.dateUtc).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",o=t.initials?` w:initials="${OL(t.initials)}"`:"";return`<w:comment w:id="${e}" w:author="${OL(t.author)}"${n}${r}${o}><w:p w14:paraId="${a}">${i=t.text,`<w:r>${i.split("\n").map((t,e)=>`${e>0?"<w:br/>":""}<w:t xml:space="preserve">${OL(t)}</w:t>`).join("")}</w:r>`}</w:p></w:comment>`;var i}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:comments ${UL}>${e}</w:comments>`}function DL(t,e="000000"){if("none"===t.type||t.width<=0)return'w:val="nil"/>';return`w:val="${"dotted"===t.type?"dotted":"dashed"===t.type?"dashed":"single"}" w:sz="${Math.max(1,Math.round(8*t.width))}" w:space="0" w:color="${BL(t.color,e)}"/>`}function jL(t){const e=[["top",t.borderTop],["left",t.borderLeft],["bottom",t.borderBottom],["right",t.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${DL(e)}`);return e.length>0?`<w:pBdr>${e.join("")}</w:pBdr>`:""}const ZL="6F6F6F";function KL(t){return t?Object.entries(t).map(([t,e])=>` ${t}="${OL(e)}"`).join(""):""}function XL(t){const e=/^\d+$/.test(t.id)?t.id:String(Array.from(t.id).reduce((t,e)=>31*t+e.charCodeAt(0)>>>0,0)),a=Number.isFinite(t.date)?new Date(t.date).toISOString():new Date(0).toISOString();return`w:id="${e}" w:author="${OL(t.author)}" w:date="${a}"`}function YL(t){if(!t||0===Object.keys(t).length)return"";const e=gy.filter(([,e])=>void 0!==t[e]).map(([e,a])=>`w:${e}="${t[a]?"1":"0"}"`).join(" ");return e?`<w:cnfStyle ${e}/>`:""}function JL(t,e){return void 0===e?"":e?`<w:${t}/>`:`<w:${t} w:val="0"/>`}function QL(t,e,a={}){if("number"==typeof e&&Number.isFinite(e))return`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`;if("string"==typeof e){const a=e.trim();if("auto"===a)return`<w:${t} w:w="0" w:type="auto"/>`;if(a.endsWith("%")){const e=Number.parseFloat(a.slice(0,-1));if(Number.isFinite(e))return`<w:${t} w:w="${Math.round(50*e)}" w:type="pct"/>`}const n=Number.parseFloat(a);if(Number.isFinite(n))return`<w:${t} w:w="${Math.round(n)}" w:type="dxa"/>`}return a.fallbackAuto?`<w:${t} w:w="0" w:type="auto"/>`:""}function _L(t,e=!0){return QL("tblW",t,{fallbackAuto:e})}function $L(t){return DL(t??{width:.75,type:"solid",color:`#${ZL}`},ZL)}function tz(t){if(!t)return"";const e=[],a=(t,a)=>{void 0!==a&&Number.isFinite(a)&&e.push(`<w:${t} w:w="${WL(a)??0}" w:type="dxa"/>`)};return a("top",t.top),a("left",t.left),a("bottom",t.bottom),a("right",t.right),a("start",t.start),a("end",t.end),e.length>0?`<w:tblCellMar>${e.join("")}</w:tblCellMar>`:""}function ez(t,e){var a,n,r,o,i,l,s,d,c,h,p;const u=Math.max(1,Math.floor(t.colSpan??1)),f=[],g=YL(t.conditionalStyle);g&&f.push(g);const m=QL("tcW",(null==(a=t.style)?void 0:a.width)??e);m&&f.push(m),u>1&&f.push(`<w:gridSpan w:val="${u}"/>`),"restart"===t.vMerge?f.push('<w:vMerge w:val="restart"/>'):"continue"===t.vMerge&&f.push("<w:vMerge/>"),(null==(n=t.style)?void 0:n.shading)&&f.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.style.shading,"FFFFFF")}"/>`);const v=JL("noWrap",null==(r=t.style)?void 0:r.noWrap);v&&f.push(v);const b=JL("tcFitText",null==(o=t.style)?void 0:o.fitText);if(b&&f.push(b),(null==(i=t.style)?void 0:i.headers)&&f.push(`<w:headers w:val="${OL(t.style.headers)}"/>`),null==(l=t.style)?void 0:l.verticalAlign){const e="middle"===t.style.verticalAlign?"center":t.style.verticalAlign;f.push(`<w:vAlign w:val="${e}"/>`)}(null==(s=t.style)?void 0:s.textDirection)&&f.push(`<w:textDirection w:val="${t.style.textDirection}"/>`),f.push(function(t){const e=t.style,a=null==e?void 0:e.padding,n=WL(a??(null==e?void 0:e.paddingTop)??0),r=WL(a??(null==e?void 0:e.paddingBottom)??0);return`<w:tcMar><w:top w:w="${n??0}" w:type="dxa"/><w:left w:w="${WL(a??(null==e?void 0:e.paddingLeft)??5.4)??0}" w:type="dxa"/><w:bottom w:w="${r??0}" w:type="dxa"/><w:right w:w="${WL(a??(null==e?void 0:e.paddingRight)??5.4)??0}" w:type="dxa"/>${void 0!==(null==e?void 0:e.paddingStart)?`<w:start w:w="${WL(e.paddingStart)??0}" w:type="dxa"/>`:""}${void 0!==(null==e?void 0:e.paddingEnd)?`<w:end w:w="${WL(e.paddingEnd)??0}" w:type="dxa"/>`:""}</w:tcMar>`}(t)),f.push(function(t){var e,a,n,r,o,i,l,s;const d=[`<w:top ${$L(null==(e=t.style)?void 0:e.borderTop)}`,`<w:left ${$L(null==(a=t.style)?void 0:a.borderLeft)}`,`<w:bottom ${$L(null==(n=t.style)?void 0:n.borderBottom)}`,`<w:right ${$L(null==(r=t.style)?void 0:r.borderRight)}`];return(null==(o=t.style)?void 0:o.borderStart)&&d.push(`<w:start ${$L(t.style.borderStart)}`),(null==(i=t.style)?void 0:i.borderEnd)&&d.push(`<w:end ${$L(t.style.borderEnd)}`),(null==(l=t.style)?void 0:l.borderTopLeftToBottomRight)&&d.push(`<w:tl2br ${$L(t.style.borderTopLeftToBottomRight)}`),(null==(s=t.style)?void 0:s.borderTopRightToBottomLeft)&&d.push(`<w:tr2bl ${$L(t.style.borderTopRightToBottomLeft)}`),`<w:tcBorders>${d.join("")}</w:tcBorders>`}(t));const y=JL("hideMark",null==(d=t.style)?void 0:d.hideMark);if(y&&f.push(y),null==(c=t.style)?void 0:c.propertyRevision){const e=t.style.propertyRevision,a=ez({...t,style:e.previous});f.push(`<w:tcPrChange ${XL(e)}>${a}</w:tcPrChange>`)}if(null==(h=t.style)?void 0:h.revision){const e=t.style.revision,a="insert"===e.type?"cellIns":"delete"===e.type?"cellDel":"cellMerge",n="merge"===e.type?`${(null==(p=e.previous)?void 0:p.vMerge)?` w:vMergeOrig="${"restart"===e.previous.vMerge?"rest":"cont"}"`:""}${t.vMerge?` w:vMerge="${"restart"===t.vMerge?"rest":"cont"}"`:""}`:"";f.push(`<w:${a} ${XL(e)}${n}/>`)}return f.length>0?`<w:tcPr>${f.join("")}</w:tcPr>`:""}function az(t,e){if(void 0===e||!Number.isFinite(e))return"";const a=Math.floor(e);return a>0?`<w:${t} w:val="${a}"/>`:""}function nz(t,e){const a="number"==typeof t?WL(t):"string"==typeof t?Number.parseFloat(t):null,n=null!==a&&Number.isFinite(a);if(!n&&!e)return"";const r=[];return n&&r.push(`w:val="${Math.round(a)}"`),r.push(`w:hRule="${e??"atLeast"}"`),`<w:trHeight ${r.join(" ")}/>`}function rz(t){if(!t)return"";const e=[],a=az("gridBefore",t.gridBefore);a&&e.push(a);const n=az("gridAfter",t.gridAfter);n&&e.push(n);const r=QL("wBefore",t.widthBefore);r&&e.push(r);const o=QL("wAfter",t.widthAfter);o&&e.push(o);const i=QL("tblCellSpacing",t.cellSpacing);i&&e.push(i);const l=nz(t.height,t.heightRule);l&&e.push(l);const s=JL("cantSplit",t.cantSplit);s&&e.push(s);const d=JL("hidden",t.hidden);d&&e.push(d);const c=JL("tblHeader",t.isHeader);return c&&e.push(c),t.align&&e.push(`<w:jc w:val="${t.align}"/>`),e.length>0?`<w:trPr>${e.join("")}</w:trPr>`:""}function oz(t){var e,a,n,r,o,i,l,s,d,c,h;const p=[],u=YL(t.conditionalStyle);u&&p.push(u);const f=az("gridBefore",null==(e=t.style)?void 0:e.gridBefore);f&&p.push(f);const g=az("gridAfter",null==(a=t.style)?void 0:a.gridAfter);g&&p.push(g);const m=QL("wBefore",null==(n=t.style)?void 0:n.widthBefore);m&&p.push(m);const v=QL("wAfter",null==(r=t.style)?void 0:r.widthAfter);v&&p.push(v);const b=QL("tblCellSpacing",null==(o=t.style)?void 0:o.cellSpacing);b&&p.push(b);const y=function(t){var e,a;return nz(null==(e=t.style)?void 0:e.height,null==(a=t.style)?void 0:a.heightRule)}(t);y&&p.push(y);const M=JL("cantSplit",null==(i=t.style)?void 0:i.cantSplit);M&&p.push(M),((null==(l=t.style)?void 0:l.isHeader)??t.isHeader)&&p.push("<w:tblHeader/>");const x=JL("hidden",null==(s=t.style)?void 0:s.hidden);if(x&&p.push(x),(null==(d=t.style)?void 0:d.align)&&p.push(`<w:jc w:val="${t.style.align}"/>`),null==(c=t.style)?void 0:c.propertyRevision){const e=t.style.propertyRevision;p.push(`<w:trPrChange ${XL(e)}>${rz(e.previous)}</w:trPrChange>`)}if((null==(h=t.style)?void 0:h.revision)&&"merge"!==t.style.revision.type){const e=t.style.revision,a="insert"===e.type?"ins":"del";p.push(`<w:${a} ${XL(e)}/>`)}return p.length>0?`<w:trPr>${p.join("")}</w:trPr>`:""}function iz(t){const e=null==t?void 0:t.borders;if(!e)return"";const a=my.map(([t,a])=>[t,e[a]]).filter(t=>!!t[1]).map(([t,e])=>`<w:${t} ${DL(e)}`).join("");return a?`<w:tblBorders>${a}</w:tblBorders>`:""}function lz(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f;const g=[];if((null==(e=t.style)?void 0:e.styleId)&&g.push(`<w:tblStyle w:val="${OL(t.style.styleId)}"/>`),null==(a=t.style)?void 0:a.tblLook){const e=t.style.tblLook;g.push(`<w:tblLook w:firstRow="${e.firstRow?"1":"0"}" w:lastRow="${e.lastRow?"1":"0"}" w:firstColumn="${e.firstCol?"1":"0"}" w:lastColumn="${e.lastCol?"1":"0"}" w:noHBand="${e.noHBand?"1":"0"}" w:noVBand="${e.noVBand?"1":"0"}"/>`)}(null==(n=t.style)?void 0:n.altTitle)&&g.push(`<w:tblCaption w:val="${OL(t.style.altTitle)}"/>`),(null==(r=t.style)?void 0:r.altDescription)&&g.push(`<w:tblDescription w:val="${OL(t.style.altDescription)}"/>`);const m=function(t){if(!t||0===Object.keys(t).length)return"";const e=t=>{const e=WL(t);return null===e?void 0:String(e)},a={horzAnchor:t.horizontalAnchor,vertAnchor:t.verticalAnchor,tblpX:e(t.x),tblpY:e(t.y),tblpXSpec:t.xAlign,tblpYSpec:t.yAlign,topFromText:e(t.distanceTop),rightFromText:e(t.distanceRight),bottomFromText:e(t.distanceBottom),leftFromText:e(t.distanceLeft)};return`<w:tblpPr ${Object.entries(a).filter(t=>void 0!==t[1]).map(([t,e])=>`w:${t}="${OL(e)}"`).join(" ")}/>`}(null==(o=t.style)?void 0:o.floating);m&&g.push(m);const v=t.gridCols&&t.gridCols.length>0?t.gridCols.reduce((t,e)=>t+e,0):void 0;g.push(_L((null==(i=t.style)?void 0:i.width)??v)),(null==(l=t.style)?void 0:l.align)&&g.push(`<w:jc w:val="${t.style.align}"/>`);const b=QL("tblCellSpacing",null==(s=t.style)?void 0:s.cellSpacing);b&&g.push(b);const y=tz(null==(d=t.style)?void 0:d.defaultCellMargins);y&&g.push(y);const M=iz(t.style);M&&g.push(M);const x=QL("tblInd",null==(c=t.style)?void 0:c.indentLeft);x&&g.push(x),g.push(`<w:tblLayout w:type="${(null==(h=t.style)?void 0:h.layout)??"fixed"}"/>`);const w=JL("bidiVisual",null==(p=t.style)?void 0:p.bidiVisual);if(w&&g.push(w),(null==(u=t.style)?void 0:u.tblOverlap)&&g.push(`<w:tblOverlap w:val="${OL(t.style.tblOverlap)}"/>`),null==(f=t.style)?void 0:f.revision){const e=t.style.revision,a=lz({...t,style:e.previous});g.push(`<w:tblPrChange ${XL(e)}>${a}</w:tblPrChange>`)}return`<w:tblPr>${g.join("")}</w:tblPr>`}function sz(t,e){const a=Io(t),n=new Map(a.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t])),r=t.rows.map((a,r)=>{const o=a.cells.map((a,o)=>{const i=n.get(`${r}:${o}`),l=i&&t.gridCols?t.gridCols.slice(i.visualColumnIndex,i.visualColumnIndex+Math.max(1,i.colSpan)).reduce((t,e)=>t+e,0):void 0,s=(a.blocks.length>0?a.blocks:[{id:"",type:"paragraph",runs:[{id:"",text:"",kind:"text"}]}]).map(t=>e(t,a)).join(""),d="continue"===a.vMerge?"<w:p/>":s;return`<w:tc${KL(a.extAttributes)}>${ez(a,l)}${d}</w:tc>`}).join("");return`<w:tr${KL(a.extAttributes)}>${function(t,e){if(!t&&!e)return"";const a=[];void 0!==(null==t?void 0:t.width)&&a.push(_L(t.width)),(null==t?void 0:t.align)&&a.push(`<w:jc w:val="${t.align}"/>`);const n=QL("tblCellSpacing",null==t?void 0:t.cellSpacing);n&&a.push(n);const r=QL("tblInd",null==t?void 0:t.indentLeft);r&&a.push(r);const o=t?iz(t):"";o&&a.push(o),(null==t?void 0:t.layout)&&a.push(`<w:tblLayout w:type="${t.layout}"/>`);const i=tz(null==t?void 0:t.defaultCellMargins);return i&&a.push(i),e&&a.push(e),a.length>0?`<w:tblPrEx>${a.join("")}</w:tblPrEx>`:""}(a.propertyExceptions,a.tblPrExChangeXml)}${oz(a)}${o}</w:tr>`}).join(""),o=t.gridCols?`<w:tblGrid>${t.gridCols.map(t=>`<w:gridCol w:w="${WL(t)??0}"/>`).join("")}${t.gridRevision?`<w:tblGridChange ${XL(t.gridRevision)}><w:tblGrid>${t.gridRevision.previous.map(t=>`<w:gridCol w:w="${WL(t)??0}"/>`).join("")}</w:tblGrid></w:tblGridChange>`:""}</w:tblGrid>`:"";return`<w:tbl>${lz(t)}${o}${r}</w:tbl>`}function dz(t){if(!t||0===t.length)return"";const e=t.map(t=>{const e=WL(t.position);if(null===e)return"";const a=[`w:val="${t.type}"`,`w:pos="${e}"`];return t.leader&&"none"!==t.leader?a.push(`w:leader="${t.leader}"`):"none"===t.leader&&a.push('w:leader="none"'),`<w:tab ${a.join(" ")}/>`}).filter(Boolean);return e.length>0?`<w:tabs>${e.join("")}</w:tabs>`:""}function cz(t){const e=[];if(t.align&&e.push(`<w:jc w:val="${t.align}"/>`),void 0!==t.spacingBefore||void 0!==t.spacingAfter||void 0!==t.lineHeight){const a=[],n=PL(t.spacingBefore),r=PL(t.spacingAfter),o=void 0!==t.lineHeight&&null!==t.lineHeight&&Number.isFinite(t.lineHeight),i="exact"===t.lineRule||"atLeast"===t.lineRule,l=o?i?qL(t.lineHeight,0):Math.round(240*t.lineHeight):null;null!==n&&a.push(`w:before="${n}"`),null!==r&&a.push(`w:after="${r}"`),null!==l&&a.push(`w:line="${l}"`),null!==l&&i&&a.push(`w:lineRule="${t.lineRule}"`),a.length>0&&e.push(`<w:spacing ${a.join(" ")}/>`)}if(void 0!==t.indentLeft||void 0!==t.indentRight||void 0!==t.indentFirstLine||void 0!==t.indentHanging){const a=[],n=PL(t.indentLeft),r=PL(t.indentRight),o=PL(t.indentFirstLine),i=PL(t.indentHanging);null!==n&&a.push(`w:left="${n}"`),null!==r&&a.push(`w:right="${r}"`),null!==o&&a.push(`w:firstLine="${o}"`),null!==i&&a.push(`w:hanging="${i}"`),a.length>0&&e.push(`<w:ind ${a.join(" ")}/>`)}const a=dz(t.tabs);a&&e.push(a),t.pageBreakBefore&&e.push("<w:pageBreakBefore/>"),t.keepWithNext&&e.push("<w:keepNext/>"),t.keepLinesTogether&&e.push("<w:keepLines/>"),!1===t.widowControl&&e.push('<w:widowControl w:val="0"/>'),t.contextualSpacing&&e.push("<w:contextualSpacing/>");const n=jL(t);return n&&e.push(n),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.shading,"FFFFFF")}"/>`),t.textDirection&&e.push(`<w:textDirection w:val="${t.textDirection}"/>`),null!=t.outlineLevel&&e.push(`<w:outlineLvl w:val="${t.outlineLevel}"/>`),e.length>0?`<w:pPr>${e.join("")}</w:pPr>`:""}function hz(t,e,a,n){var r,o;const i=[],l=function(t,e){const a=sa(t.style,e);return{align:a.align,spacingBefore:a.spacingBefore,spacingAfter:a.spacingAfter,contextualSpacing:a.contextualSpacing,lineHeight:a.lineHeight,lineRule:a.lineRule,indentLeft:a.indentLeft,indentRight:a.indentRight,indentFirstLine:a.indentFirstLine,indentHanging:a.indentHanging,pageBreakBefore:a.pageBreakBefore,keepWithNext:a.keepWithNext,keepLinesTogether:a.keepLinesTogether,widowControl:a.widowControl,shading:a.shading,borderTop:a.borderTop,borderRight:a.borderRight,borderBottom:a.borderBottom,borderLeft:a.borderLeft,tabs:a.tabs,textDirection:a.textDirection,outlineLevel:a.outlineLevel}}(t,a),s=(null==(r=t.style)?void 0:r.align)??(null==n?void 0:n.align)??l.align;if((null==(o=t.style)?void 0:o.styleId)&&i.push(`<w:pStyle w:val="${OL(t.style.styleId)}"/>`),s&&i.push(`<w:jc w:val="${s}"/>`),void 0!==l.spacingBefore||void 0!==l.spacingAfter||void 0!==l.lineHeight){const t=[],e=PL(l.spacingBefore),a=PL(l.spacingAfter),n=void 0!==l.lineHeight&&null!==l.lineHeight&&Number.isFinite(l.lineHeight),r="exact"===l.lineRule||"atLeast"===l.lineRule,o=n?r?qL(l.lineHeight,0):Math.round(240*l.lineHeight):null;null!==e&&t.push(`w:before="${e}"`),null!==a&&t.push(`w:after="${a}"`),null!==o&&t.push(`w:line="${o}"`),null!==o&&r&&t.push(`w:lineRule="${l.lineRule}"`),t.length>0&&i.push(`<w:spacing ${t.join(" ")}/>`)}if(void 0!==l.indentLeft||void 0!==l.indentRight||void 0!==l.indentFirstLine||void 0!==l.indentHanging){const t=[],e=PL(l.indentLeft),a=PL(l.indentRight),n=PL(l.indentFirstLine),r=PL(l.indentHanging);null!==e&&t.push(`w:left="${e}"`),null!==a&&t.push(`w:right="${a}"`),null!==n&&t.push(`w:firstLine="${n}"`),null!==r&&t.push(`w:hanging="${r}"`),t.length>0&&i.push(`<w:ind ${t.join(" ")}/>`)}const d=dz(l.tabs);d&&i.push(d),l.pageBreakBefore&&i.push("<w:pageBreakBefore/>"),l.keepWithNext&&i.push("<w:keepNext/>"),l.keepLinesTogether&&i.push("<w:keepLines/>"),!1===l.widowControl&&i.push('<w:widowControl w:val="0"/>'),l.contextualSpacing&&i.push("<w:contextualSpacing/>");const c=jL(l);c&&i.push(c),l.shading&&i.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(l.shading,"FFFFFF")}"/>`),l.textDirection&&i.push(`<w:textDirection w:val="${l.textDirection}"/>`),null!=l.outlineLevel&&i.push(`<w:outlineLvl w:val="${l.outlineLevel}"/>`);const h=e.get(t.id);return h&&i.push(`<w:numPr><w:ilvl w:val="${h.level}"/><w:numId w:val="${h.numId}"/></w:numPr>`),i.length>0?`<w:pPr>${i.join("")}</w:pPr>`:""}const pz={black:[0,0,0],blue:[0,0,255],cyan:[0,255,255],green:[0,128,0],magenta:[255,0,255],red:[255,0,0],yellow:[255,255,0],white:[255,255,255],darkBlue:[0,0,139],darkCyan:[0,139,139],darkGreen:[0,100,0],darkMagenta:[139,0,139],darkRed:[139,0,0],darkYellow:[184,134,11],darkGray:[169,169,169],lightGray:[211,211,211]},uz={ffff00:"yellow",fef08a:"yellow",ff0000:"red","00ff00":"green","0000ff":"blue","00ffff":"cyan",ff00ff:"magenta","000000":"black",ffffff:"white"},fz="http://schemas.openxmlformats.org/markup-compatibility/2006";function gz(t){return`<w14:solidFill><w14:srgbClr w14:val="${BL(t)}"/></w14:solidFill>`}function mz(t){if("solid"===t.type)return gz(t.color);return`<w14:gradFill><w14:gsLst>${t.stops.map(t=>{const e=BL(t.color);return`<w14:gs w14:pos="${Math.round(t.position*Oe)}"><w14:srgbClr w14:val="${e}">${void 0!==t.alpha?`<w14:alpha w14:val="${Math.round(t.alpha*Oe)}"/>`:""}</w14:srgbClr></w14:gs>`}).join("")}</w14:gsLst><w14:lin w14:ang="${Math.round((t.angle??0)*qe)}" w14:scaled="0"/></w14:gradFill>`}function vz(t,e){return`<w14:srgbClr w14:val="${BL(t)}">${void 0!==e?`<w14:alpha w14:val="${Math.round(e*Oe)}"/>`:""}</w14:srgbClr>`}function bz(t){return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14">${t}</mc:Choice><mc:Fallback/></mc:AlternateContent>`}function yz(t){return null!=t&&Number.isFinite(t)?Math.round(20*t):null}const Mz=Ep;function xz(t){if(!t)return"";const e=[];if(t.bold&&e.push("<w:b/>","<w:bCs/>"),t.italic&&e.push("<w:i/>","<w:iCs/>"),t.underline){const a=t.underlineStyle??"single",n=t.underlineColor?` w:color="${OL(t.underlineColor.replace(/^#/,""))}"`:"";e.push(`<w:u w:val="${OL(a)}"${n}/>`)}if(t.strike&&e.push("<w:strike/>"),t.doubleStrike&&e.push("<w:dstrike/>"),t.outline&&e.push("<w:outline/>"),t.shadow&&e.push("<w:shadow/>"),t.emboss&&e.push("<w:emboss/>"),t.imprint&&e.push("<w:imprint/>"),t.smallCaps&&e.push("<w:smallCaps/>"),t.allCaps&&e.push("<w:caps/>"),t.hidden&&e.push("<w:vanish/>"),t.noProof&&e.push("<w:noProof/>"),t.webHidden&&e.push("<w:webHidden/>"),t.specVanish&&e.push("<w:specVanish/>"),!1===t.snapToGrid&&e.push('<w:snapToGrid w:val="0"/>'),t.textEffect&&e.push(`<w:effect w:val="${OL(t.textEffect)}"/>`),t.textBorder&&e.push(`<w:bdr ${DL(t.textBorder)}`),void 0!==t.characterScale&&null!==t.characterScale&&Number.isFinite(t.characterScale)&&e.push(`<w:w w:val="${Math.max(1,Math.round(t.characterScale))}"/>`),void 0!==t.characterSpacing&&null!==t.characterSpacing){const a=yz(t.characterSpacing);null!==a&&e.push(`<w:spacing w:val="${a}"/>`)}void 0!==t.baselineShift&&null!==t.baselineShift&&Number.isFinite(t.baselineShift)&&e.push(`<w:position w:val="${Math.round(2*t.baselineShift)}"/>`),void 0!==t.kerningThreshold&&null!==t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e.push(`<w:kern w:val="${Math.max(0,Math.round(2*t.kerningThreshold))}"/>`);const a=function(t){switch(t){case"none":return"none";case"standard":return"standard";case"contextual":return"contextual";case"historical":return"historical";case"standardContextual":return"standardContextual";default:return null}}(t.ligatures);a&&e.push(`<w14:ligatures w14:val="${a}"/>`);const n=function(t){switch(t){case"proportional":return"proportional";case"tabular":return"tabular";default:return null}}(t.numberSpacing);n&&e.push(`<w14:numSpacing w14:val="${n}"/>`);const r=function(t){switch(t){case"lining":return"lining";case"oldStyle":return"oldStyle";default:return null}}(t.numberForm);r&&e.push(`<w14:numForm w14:val="${r}"/>`);const o="number"!=typeof(i=t.stylisticSet)||i<1||i>20?null:(1<<i-1).toString(16).toUpperCase().padStart(8,"0");var i;if(o&&e.push(`<w14:stylisticSets w14:val="${o}"/>`),t.contextualAlternates&&e.push('<w14:cntxtAlts w14:val="1"/>'),t.superscript?e.push('<w:vertAlign w:val="superscript"/>'):t.subscript&&e.push('<w:vertAlign w:val="subscript"/>'),t.fontFamily&&e.push(`<w:rFonts w:ascii="${OL(t.fontFamily)}" w:hAnsi="${OL(t.fontFamily)}" w:cs="${OL(t.fontFamily)}"/>`),void 0!==t.fontSize&&null!==t.fontSize){const a=function(t){return null!=t&&Number.isFinite(t)?Math.round(t/ke*72*2):null}(t.fontSize);null!==a&&e.push(`<w:sz w:val="${a}"/>`,`<w:szCs w:val="${a}"/>`)}if(t.textFill){const a="solid"===t.textFill.type?t.textFill.color:t.color;e.push(function(t,e){const a=mz(t),n=BL(e??"000000");return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:textFill>${a}</w14:textFill></mc:Choice><mc:Fallback><w:color w:val="${n}"/></mc:Fallback></mc:AlternateContent>`}(t.textFill,a??null))}else t.color&&e.push(`<w:color w:val="${OL(t.color.replace(/^#/,""))}"/>`);if(t.textOutline&&e.push(function(t){const e=Math.round(Math.max(0,t.widthPt)*ze),a=t.fill?mz(t.fill):t.color?gz(t.color):"";return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:textOutline w14:w="${e}" w14:cap="flat" w14:cmpd="sng" w14:algn="ctr">`+a+"</w14:textOutline></mc:Choice><mc:Fallback><w:outline/></mc:Fallback></mc:AlternateContent>"}(t.textOutline)),t.textShadow&&e.push(function(t){const e=Math.round(Math.max(0,t.blurPt)*ze),a=Math.round(Math.max(0,t.distPt)*ze),n=Math.round(t.dirDeg*qe),r=vz(t.color,t.alpha);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:shadow w14:blurRad="${e}" w14:dist="${a}" w14:dir="${n}" w14:sx="100000" w14:sy="100000" w14:kx="0" w14:ky="0" w14:algn="ctr">`+r+"</w14:shadow></mc:Choice><mc:Fallback><w:shadow/></mc:Fallback></mc:AlternateContent>"}(t.textShadow)),t.glow&&e.push(function(t){const e=Math.round(Math.max(0,t.radiusPt)*ze),a=vz(t.color,t.alpha);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:glow w14:rad="${e}">${a}</w14:glow></mc:Choice><mc:Fallback/></mc:AlternateContent>`}(t.glow)),t.reflection&&e.push(function(t){const e=Math.round(Math.max(0,t.blurPt)*ze),a=Math.round(t.startAlpha*Oe),n=Math.round(t.startPos*Oe),r=Math.round(t.endAlpha*Oe),o=Math.round(t.endPos*Oe),i=Math.round(Math.max(0,t.distPt)*ze);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:reflection w14:blurRad="${e}" w14:stA="${a}" w14:stPos="${n}" w14:endA="${r}" w14:endPos="${o}" w14:dist="${i}" w14:dir="5400000" w14:fadeDir="5400000" w14:sx="100000" w14:sy="-100000" w14:kx="0" w14:ky="0" w14:algn="bl"/></mc:Choice><mc:Fallback/></mc:AlternateContent>`}(t.reflection)),t.scene3dXml&&e.push(bz(t.scene3dXml)),t.props3dXml&&e.push(bz(t.props3dXml)),t.highlight&&e.push(`<w:highlight w:val="${OL(function(t){if(t in pz)return t;const e=t.trim().replace(/^#/,"").toLowerCase(),a=uz[e];if(a)return a;const n=Mz(t);if(!n)return"yellow";let r="yellow",o=Number.POSITIVE_INFINITY;for(const[i,l]of Object.entries(pz)){const t=(l[0]-n[0])**2+(l[1]-n[1])**2+(l[2]-n[2])**2;t<o&&(o=t,r=i)}return r}(t.highlight))}"/>`),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.shading,"FFFFFF")}"/>`),void 0!==t.fitText&&null!==t.fitText&&Number.isFinite(t.fitText)){const a=yz(t.fitText);null!==a&&a>0&&e.push(`<w:fitText w:val="${a}"/>`)}if(t.rtl&&e.push("<w:rtl/>"),t.complexScript&&e.push("<w:cs/>"),t.emphasisMark&&e.push(`<w:em w:val="${OL(t.emphasisMark)}"/>`),t.language){const a=[];t.language.value&&a.push(`w:val="${OL(t.language.value)}"`),t.language.eastAsia&&a.push(`w:eastAsia="${OL(t.language.eastAsia)}"`),t.language.bidi&&a.push(`w:bidi="${OL(t.language.bidi)}"`),a.length>0&&e.push(`<w:lang ${a.join(" ")}/>`)}return e.length>0?`<w:rPr>${e.join("")}</w:rPr>`:""}function wz(t){if(0===t.length)return"";var e;return`<w:t${/^\s|\s$/.test(e=t)||e.includes(" ")?' xml:space="preserve"':""}>${OL(t)}</w:t>`}function Sz(t){if(0===t.length)return"<w:t></w:t>";let e="",a="";for(const n of t)"\n"!==n?"\t"!==n?"‑"!==n?""!==n?a+=n:(e+=wz(a),a="",e+="<w:softHyphen/>"):(e+=wz(a),a="",e+="<w:noBreakHyphen/>"):(e+=wz(a),a="",e+="<w:tab/>"):(e+=wz(a),a="",e+="<w:br/>");return e+=wz(a),e||"<w:t></w:t>"}function Az(t,e){return t??e?"1":"0"}function Cz(t,e,a){const n=OL((null==e?void 0:e.relativeFrom)??a);if(null==e?void 0:e.align)return`<wp:${t} relativeFrom="${n}"><wp:align>${OL(e.align)}</wp:align></wp:${t}>`;return`<wp:${t} relativeFrom="${n}"><wp:posOffset>${(null==e?void 0:e.offset)??0}</wp:posOffset></wp:${t}>`}function Iz(t){if(!t||t.length<3)return"";const e=t=>Math.round(21600*Math.min(1,Math.max(0,t))),a=(t,a)=>`<wp:${a} x="${e(t.x)}" y="${e(t.y)}"/>`,n=t[0];return`<wp:wrapPolygon edited="0">${[a(n,"start"),...t.slice(1).map(t=>a(t,"lineTo")),a(n,"lineTo")].join("")}</wp:wrapPolygon>`}function Tz(t){const{cx:e,cy:a,floating:n,docPrId:r,docPrName:o,altAttr:i,graphicXml:l}=t,s=OL(o);if(!n)return`<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:inline></w:drawing>`;const d=n.distT??0,c=n.distB??0,h=n.distL??0,p=n.distR??0,u=Cz("positionH",n.positionH,"column"),f=Cz("positionV",n.positionV,"paragraph"),g=function(t,e){switch(t){case"square":return'<wp:wrapSquare wrapText="bothSides"/>';case"tight":{const t=Iz(e);return t?`<wp:wrapTight wrapText="bothSides">${t}</wp:wrapTight>`:'<wp:wrapTight wrapText="bothSides"/>'}case"through":{const t=Iz(e);return t?`<wp:wrapThrough wrapText="bothSides">${t}</wp:wrapThrough>`:'<wp:wrapThrough wrapText="bothSides"/>'}case"topAndBottom":return"<wp:wrapTopAndBottom/>";default:return"<wp:wrapNone/>"}}(n.wrap,t.wrapPolygon);return`<w:drawing><wp:anchor distT="${d}" distB="${c}" distL="${h}" distR="${p}" simplePos="${Az(n.simplePos,!1)}" relativeHeight="${n.relativeHeight??0}" behindDoc="${Az(n.behindDoc,!1)}" locked="${Az(n.locked,!1)}" layoutInCell="${Az(n.layoutInCell,!0)}" allowOverlap="${Az(n.allowOverlap,!0)}"><wp:simplePos x="0" y="0"/>${u}${f}<wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/>${g}<wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:anchor></w:drawing>`}function kz(t,e,a,n){const r=a.images.find(t=>t.rId===e);if(!r)return null;const o=(parseInt(e.replace(/\D+/g,""),10)||0)+1,i=void 0!==r.alt?` descr="${OL(r.alt)}" title="${OL(r.alt)}"`:"",l=function(t){let e="";if(t.rotation){const a=Math.round(t.rotation*qe);0!==a&&(e+=` rot="${a}"`)}return t.flipH&&(e+=' flipH="1"'),t.flipV&&(e+=' flipV="1"'),e}(r),s=function(t){if(!t)return"";const e=t=>t?Math.round(t*Oe):0,a=e(t.left),n=e(t.top),r=e(t.right),o=e(t.bottom);return 0===a&&0===n&&0===r&&0===o?"":`<a:srcRect l="${a}" t="${n}" r="${r}" b="${o}"/>`}(r.crop),d="tile"===r.fillMode?"<a:tile/>":"<a:stretch><a:fillRect/></a:stretch>",c=function(t,e,a,n){return Tz({cx:t.cx,cy:t.cy,floating:t.floating,docPrId:e,docPrName:"Picture",altAttr:a,graphicXml:n,wrapPolygon:t.wrapPolygon})}(r,o,i,`<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="0" name="Picture"${i}/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip ${"linked"===r.kind?`r:link="${e}"`:`r:embed="${e}"`} xmlns:r="${zL}"/>${s}${d}</pic:blipFill><pic:spPr><a:xfrm${l}><a:off x="0" y="0"/><a:ext cx="${r.cx}" cy="${r.cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic>`);return`<w:r>${n}${c}</w:r>`}function Vz(t,e,a,n,r,o){const i=Math.round(e.width*Le),l=Math.round(e.height*Le),s=a.textBoxDocPrIds.get(t.id)??1,d=e.name??"Text Box",c=void 0!==e.alt?` descr="${OL(e.alt)}" title="${OL(e.alt)}"`:"",h=function(t,e,a,n,r,o){const i=t.shape,l=OL((null==i?void 0:i.preset)??"rect"),s=t.rotation?Math.round(t.rotation*qe):0,d=0!==s?` rot="${s}"`:"",c=(null==i?void 0:i.fill)?`<a:solidFill><a:srgbClr val="${OL(i.fill.replace(/^#/,""))}"/></a:solidFill>`:"";let h="";((null==i?void 0:i.borderColor)||void 0!==(null==i?void 0:i.borderWidthPt))&&(h=`<a:ln${void 0!==(null==i?void 0:i.borderWidthPt)?` w="${Math.round(i.borderWidthPt*ze)}"`:""}>${(null==i?void 0:i.borderColor)?`<a:solidFill><a:srgbClr val="${OL(i.borderColor.replace(/^#/,""))}"/></a:solidFill>`:""}<a:miter lim="800000"/></a:ln>`);const p=t.body,u=['rot="0"',`vert="${OL((null==p?void 0:p.vert)??"horz")}"`];u.push(`wrap="${OL((null==p?void 0:p.wrap)??"square")}"`),void 0!==(null==p?void 0:p.paddingLeft)&&u.push(`lIns="${Math.round(p.paddingLeft*Le)}"`),void 0!==(null==p?void 0:p.paddingTop)&&u.push(`tIns="${Math.round(p.paddingTop*Le)}"`),void 0!==(null==p?void 0:p.paddingRight)&&u.push(`rIns="${Math.round(p.paddingRight*Le)}"`),void 0!==(null==p?void 0:p.paddingBottom)&&u.push(`bIns="${Math.round(p.paddingBottom*Le)}"`),u.push(`anchor="${OL((null==p?void 0:p.anchor)??"t")}"`),u.push('anchorCtr="0"');const f=(null==p?void 0:p.autoFit)?"<a:spAutoFit/>":"",g=t.blocks.length>0,m=g?o(t.blocks,n,r):"";return'<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"><wps:wsp>'+(g?'<wps:cNvSpPr txBox="1"><a:spLocks noChangeArrowheads="1"/></wps:cNvSpPr>':"<wps:cNvSpPr/>")+`<wps:spPr bwMode="auto"><a:xfrm${d}><a:off x="0" y="0"/><a:ext cx="${e}" cy="${a}"/></a:xfrm><a:prstGeom prst="${l}"><a:avLst/></a:prstGeom>`+c+h+"</wps:spPr>"+(g?`<wps:txbx><w:txbxContent>${m}</w:txbxContent></wps:txbx>`:"")+`<wps:bodyPr ${u.join(" ")}>${f}</wps:bodyPr></wps:wsp></a:graphicData></a:graphic>`}(e,i,l,a,n,o);return`<w:r>${r}${Tz({cx:i,cy:l,floating:e.floating,docPrId:s,docPrName:d,altAttr:c,graphicXml:h})}</w:r>`}const Rz={footnote:"FootnoteReference",endnote:"EndnoteReference"};function Ez(t){return`<w:r><w:rPr><w:rStyle w:val="${Rz[t]}"/><w:vertAlign w:val="superscript"/></w:rPr><w:${t}Ref/></w:r>`}function Lz(t,e,a,n){if(!e)return null;const r="footnote"===t?n.footnoteIdMap:n.endnoteIdMap,o=null==r?void 0:r.get(e.noteId);if(void 0===o)return null;const i={...a??{},superscript:!0},l=e.customMark?' w:customMarkFollows="1"':"",s=e.customMark?`<w:t xml:space="preserve">${OL(e.customMark)}</w:t>`:"";return`<w:r>${xz(i)}<w:${t}Reference${l} w:id="${o}"/>${s}</w:r>`}function zz(t,e,a,n,r){if(t.__isFootnoteRefMarker)return Ez("footnote");if(t.__isEndnoteRefMarker)return Ez("endnote");const o=function(t,e,a){var n;const r=la(t.styles,e,a),o={bold:r.bold,italic:r.italic,underline:r.underline,underlineStyle:r.underlineStyle,underlineColor:r.underlineColor,strike:r.strike,doubleStrike:r.doubleStrike,superscript:r.superscript,subscript:r.subscript,smallCaps:r.smallCaps,allCaps:r.allCaps,hidden:r.hidden,noProof:r.noProof,webHidden:r.webHidden,specVanish:r.specVanish,rtl:r.rtl,complexScript:r.complexScript,snapToGrid:r.snapToGrid,fitText:r.fitText,emphasisMark:r.emphasisMark,textBorder:r.textBorder,outline:r.outline,shadow:r.shadow,emboss:r.emboss,imprint:r.imprint,textEffect:r.textEffect,characterScale:r.characterScale,characterSpacing:r.characterSpacing,baselineShift:r.baselineShift,kerningThreshold:r.kerningThreshold,ligatures:r.ligatures,numberSpacing:r.numberSpacing,numberForm:r.numberForm,stylisticSet:r.stylisticSet,contextualAlternates:r.contextualAlternates,fontFamily:r.fontFamily,fontSize:r.fontSize,color:r.color,textFill:r.textFill,textOutline:r.textOutline,textShadow:r.textShadow,glow:r.glow,reflection:r.reflection,scene3dXml:r.scene3dXml,props3dXml:r.props3dXml,highlight:r.highlight,shading:r.shading,language:r.language};return(null==(n=t.styles)?void 0:n.link)&&(o.link=t.styles.link),o}(t,a,n),i=()=>xz(o),l=()=>`<w:r>${i()}${Sz(t.text)}</w:r>`;return Ie(t,{footnoteReference:t=>function(t,e,a){const n=Ae(t);return Lz("footnote",n?{noteId:n.footnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e)??l(),endnoteReference:t=>function(t,e,a){const n=Ce(t);return Lz("endnote",n?{noteId:n.endnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e)??l(),fieldChar:t=>function(t,e){const a=(t.fieldLock?' w:fldLock="true"':"")+(t.dirty?' w:dirty="true"':"");return`<w:r>${e}<w:fldChar w:fldCharType="${t.kind}"${a}/></w:r>`}(t.fieldChar,i()),fieldInstruction:t=>{return e=t.fieldInstruction,`<w:r>${i()}<w:instrText xml:space="preserve">${OL(e)}</w:instrText></w:r>`;var e},field:t=>{return e=t.field.type,a=i(),`<w:fldSimple w:instr="${"PAGE"===e?" PAGE ":" NUMPAGES "}"><w:r>${a}<w:t>1</w:t></w:r></w:fldSimple>`;var e,a},textBox:t=>Vz(t,t.textBox,e,n,i(),r),image:t=>{const a=e.imageMap.get(t.id);if(a){const n=kz(t.id,a,e,i());if(null!==n)return n}return l()},sym:t=>`<w:r>${i()}<w:sym w:font="${OL(t.sym.font)}" w:char="${t.sym.char}"/></w:r>`,text:()=>l()})}function Nz(t,e,a,n,r){var o;const i=zz(t,e,a,n,r),l=null==(o=t.styles)?void 0:o.link;return l?function(t,e,a){if(e.startsWith("#"))return`<w:hyperlink w:anchor="${OL(e.slice(1))}">${t}</w:hyperlink>`;const n=a.hyperlinkMap.get(e);return n?`<w:hyperlink r:id="${n}">${t}</w:hyperlink>`:t}(i,l,e):i}function Oz(t){return"text"===t.kind||"sym"===t.kind}function qz(t,e,a){var n;switch(t.type){case"paragraph":return Wz(t,e,a);case"table":return((null==(n=t.style)?void 0:n.pageBreakBefore)?'<w:p><w:r><w:br w:type="page"/></w:r></w:p>':"")+sz(t,(t,n)=>{var r;return Wz(t,e,a,{align:null==(r=n.style)?void 0:r.horizontalAlign})});default:return ve(t,"block")}}function Pz(t,e,a){var n,r,o;let i="",l=0;for(;l<t.length;){const s=t[l],d=null==(n=s.sdtWrappers)?void 0:n[0];if(!d){i+=qz(s,e,a),l+=1;continue}const c=[];let h=l;for(;h<t.length&&(null==(o=null==(r=t[h].sdtWrappers)?void 0:r[0])?void 0:o.groupId)===d.groupId;){const e=t[h].sdtWrappers.slice(1);c.push({...t[h],sdtWrappers:e.length>0?e:void 0}),h+=1}const p=Pz(c,e,a);i+=`<w:sdt>${d.sdtPrXml}${d.sdtEndPrXml??""}<w:sdtContent>${p}</w:sdtContent></w:sdt>`,l=h}return i}function Wz(t,e,a,n){var r,o,i;const l=t.runs.length>0?t.runs:[{id:"",text:"",kind:"text"}],s=t.dropCap?function(t){const e=xz(t.style);var a;return`<w:p><w:pPr><w:keepNext/><w:framePr w:dropCap="${t.type}" w:lines="${t.lines}" w:wrap="around" w:vAnchor="text" w:hAnchor="text"/><w:spacing w:after="0"/>${e?`<w:rPr>${a=e,a.replace(/^<w:rPr>/,"").replace(/<\/w:rPr>$/,"")}</w:rPr>`:""}</w:pPr><w:r>${e}${Sz(t.text)}</w:r></w:p>`}(t.dropCap):"",d=null==(r=e.bookmarkEventsByParagraph)?void 0:r.get(t.id),c=null==(o=e.commentEventsByParagraph)?void 0:o.get(t.id),h=[...(d??[]).map(t=>({offset:t.offset,seq:t.seq,xml:FL(t)})),...(c??[]).map(t=>({offset:t.offset,seq:t.seq,xml:HL(t)}))],p=h.length>0?function(t,e,a,n,r){const o=[...e].sort((t,e)=>t.offset-e.offset||t.seq-e.seq);let i=0,l=0,s="";const d=t=>{for(;i<o.length&&o[i].offset<=t;)s+=o[i].xml,i+=1};for(const c of t){const t=l,e=t+c.text.length;if(d(t),Oz(c)&&c.text.length>0){let l=t;for(;i<o.length&&o[i].offset<e;){const e=o[i];e.offset>l&&(s+=Nz({...c,text:c.text.slice(l-t,e.offset-t)},a,n,r,Pz)),s+=e.xml,i+=1,l=e.offset}l<e&&(s+=Nz({...c,text:c.text.slice(l-t)},a,n,r,Pz))}else s+=Nz(c,a,n,r,Pz);l=e}return d(Number.POSITIVE_INFINITY),s}(l,h,e,null==(i=t.style)?void 0:i.styleId,a):l.map(n=>{var r;return Nz(n,e,null==(r=t.style)?void 0:r.styleId,a,Pz)}).join("");return`${s}<w:p>${hz(t,e.numberingInfo,a,n)}${p}</w:p>`}function Bz(t){if(0===t.length)return[Fz()];const[e,...a]=t;return"paragraph"!==e.type?[Fz(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:footnoteRef",text:"",kind:"text",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"FootnoteText"}}),...a];var n,r}function Fz(t=!0){return{id:"synthetic:footnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:footnoteRef",text:"",kind:"text",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0}]:[],{id:"synthetic:footnote-body-empty-text",text:"",kind:"text"}],style:{styleId:"FootnoteText"}}}function Hz(t){var e;const a=null==(e=t.endnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of function(t){return Pc(t,"endnoteReference")}(t)){const t=Ce(o);if(!t)continue;if(n.has(t.endnoteId))continue;const e=a[t.endnoteId];e&&(n.set(t.endnoteId,{endnoteId:t.endnoteId,docxId:r,endnote:e}),r+=1)}return Array.from(n.values())}function Uz(t){if(0===t.length)return[Gz()];const[e,...a]=t;return"paragraph"!==e.type?[Gz(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:endnoteRef",text:"",kind:"text",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"EndnoteText"}}),...a];var n,r}function Gz(t=!0){return{id:"synthetic:endnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:endnoteRef",text:"",kind:"text",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0}]:[],{id:"synthetic:endnote-body-empty-text",text:"",kind:"text"}],style:{styleId:"EndnoteText"}}}const Dz=["wholeTable","band1Horz","band2Horz","band1Vert","band2Vert","firstCol","lastCol","firstRow","lastRow","nwCell","neCell","swCell","seCell"];function jz(t){const e={...t.borders?{...t.borders.borderTop?{borderTop:t.borders.borderTop}:{},...t.borders.borderLeft?{borderLeft:t.borders.borderLeft}:{},...t.borders.borderBottom?{borderBottom:t.borders.borderBottom}:{},...t.borders.borderRight?{borderRight:t.borders.borderRight}:{}}:{},...t.shading?{shading:t.shading}:{},...t.cellStyle};return Object.keys(e).length>0?ez({id:"table-style-cell",blocks:[],style:e}):""}function Zz(t,e){if("number"==typeof e)return`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`;if("string"==typeof e&&e.endsWith("%")){const a=Number.parseFloat(e);return Number.isFinite(a)?`<w:${t} w:w="${Math.round(50*a)}" w:type="pct"/>`:""}return"auto"===e?`<w:${t} w:w="0" w:type="auto"/>`:""}function Kz(t){if(!t)return"";const e=[];void 0!==t.rowBandSize&&e.push(`<w:tblStyleRowBandSize w:val="${t.rowBandSize}"/>`),void 0!==t.colBandSize&&e.push(`<w:tblStyleColBandSize w:val="${t.colBandSize}"/>`);const a=Zz("tblW",t.width);a&&e.push(a);const n=Zz("tblInd",t.indentLeft);n&&e.push(n);const r=Zz("tblCellSpacing",t.cellSpacing);if(r&&e.push(r),t.align&&e.push(`<w:jc w:val="${t.align}"/>`),t.layout&&e.push(`<w:tblLayout w:type="${t.layout}"/>`),void 0!==t.bidiVisual&&e.push(`<w:bidiVisual w:val="${t.bidiVisual?"1":"0"}"/>`),t.defaultCellMargins){const a=Object.entries(t.defaultCellMargins).map(([t,e])=>`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`).join("");a&&e.push(`<w:tblCellMar>${a}</w:tblCellMar>`)}if(t.borders){const{borders:a}=t,n=my.filter(([,t])=>!!a[t]).map(([t,e])=>`<w:${t} ${DL(a[e])}`).join("");n&&e.push(`<w:tblBorders>${n}</w:tblBorders>`)}return e.length>0?`<w:tblPr>${e.join("")}</w:tblPr>`:""}function Xz(t,e){const a=[],n=e.paragraphStyle?cz(e.paragraphStyle):"";n&&a.push(n);const r=e.textStyle?xz(e.textStyle):"";r&&a.push(r);const o=Kz(e.tableStyle);o&&a.push(o);const i=e.rowStyle?rz(e.rowStyle):"";i&&a.push(i);const l=jz(e);return l&&a.push(l),0===a.length?"":`<w:tblStylePr w:type="${OL(t)}">${a.join("")}</w:tblStylePr>`}function Yz(t){const e=[];if(e.push(`<w:name w:val="${OL(t.name)}"/>`),t.basedOn&&e.push(`<w:basedOn w:val="${OL(t.basedOn)}"/>`),t.nextStyle&&e.push(`<w:next w:val="${OL(t.nextStyle)}"/>`),void 0!==t.uiPriority&&e.push(`<w:uiPriority w:val="${Math.max(0,Math.floor(t.uiPriority))}"/>`),void 0!==t.qFormat&&e.push(`<w:qFormat w:val="${t.qFormat?"1":"0"}"/>`),void 0!==t.semiHidden&&e.push(`<w:semiHidden w:val="${t.semiHidden?"1":"0"}"/>`),void 0!==t.unhideWhenUsed&&e.push(`<w:unhideWhenUsed w:val="${t.unhideWhenUsed?"1":"0"}"/>`),("paragraph"===t.type||"table"===t.type)&&t.paragraphStyle){const a=cz(t.paragraphStyle);a&&e.push(a)}if(t.textStyle){const a=xz(t.textStyle);a&&e.push(a)}if("table"===t.type&&t.tableStyle){const a=t.tableStyle,n=Kz(a);if(n&&e.push(n),a.conditionalFormats){const t=[...Dz.filter(t=>t in a.conditionalFormats),...Object.keys(a.conditionalFormats).filter(t=>!Dz.includes(t))];for(const n of t){const t=a.conditionalFormats[n];if(t){const a=Xz(n,t);a&&e.push(a)}}}}return`<w:style w:type="${"character"===t.type?"character":"table"===t.type?"table":"paragraph"}" w:styleId="${OL(t.id)}"${t.isDefault?' w:default="1"':""}>${e.join("")}</w:style>`}function Jz(t,e,a,n,r,o,i,l,s){const d=n.map(t=>{const e="header"===t.kind?"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";return`<Override PartName="/word/${t.path}" ContentType="${e}"/>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${function(t){const e=new Set;let a="";for(const n of t){const t=n.toLowerCase();if(e.has(t))continue;const r=By[t];r&&(e.add(t),a+=`<Default Extension="${t}" ContentType="${r}"/>`)}return a}(e)}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${i?'<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>':""}${t?'<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>':""}${a?'<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>':""}${r?'<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>':""}${o?'<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>':""}${l?'<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>':""}${s?'<Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>':""}${d}</Types>`}const Qz={decimal:"decimal",lowerRoman:"lowerRoman",upperRoman:"upperRoman",lowerLetter:"lowerLetter",upperLetter:"upperLetter",symbol:"symbol"},_z={continuous:"continuous",eachSection:"eachSect"};function $z(t,e){if(!e)return null;const a=[];return e.numberFormat&&a.push(`<w:numFmt w:val="${Qz[e.numberFormat]}"/>`),void 0!==e.startAt&&a.push(`<w:numStart w:val="${Math.max(1,e.startAt)}"/>`),e.restart&&a.push(`<w:numRestart w:val="${_z[e.restart]}"/>`),a.length>0?`<w:${t}>${a.join("")}</w:${t}>`:null}function tN(t,e){let a="";for(const n of e)a+=`<Relationship Id="${n.rId}" Type="${zL}/hyperlink" Target="${OL(n.href)}" TargetMode="External"/>`;for(const n of t){const t="linked"===n.kind?' TargetMode="External"':"";a+=`<Relationship Id="${n.rId}" Type="${zL}/image" Target="${OL(n.target)}"${t}/>`}return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}">${a}</Relationships>`}function eN(t,e){e(t);for(const a of t.runs)"textBox"===a.kind&&aN(a.textBox.blocks,e)}function aN(t,e){for(const a of t)switch(a.type){case"paragraph":eN(a,e);break;case"table":for(const t of a.rows)for(const a of t.cells)for(const t of a.blocks)eN(t,e);break;default:ve(a,"block")}}const nN=`xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${zL}"`;function rN(t,e,a){const n=ha(t).map((n,r)=>Pz(n.blocks,e,t.styles)+function(t,e){var a,n,r,o,i,l,s,d,c;const h=qL(t.width,12240),p=qL(t.height,15840),u=t.margins,f="landscape"===t.orientation?' w:orient="landscape"':"",g=[(null==(a=null==e?void 0:e.header)?void 0:a.first)?`<w:headerReference w:type="first" r:id="${e.header.first.relId}"/>`:"",(null==(n=null==e?void 0:e.header)?void 0:n.even)?`<w:headerReference w:type="even" r:id="${e.header.even.relId}"/>`:"",(null==(r=null==e?void 0:e.header)?void 0:r.default)?`<w:headerReference w:type="default" r:id="${e.header.default.relId}"/>`:"",(null==(o=null==e?void 0:e.footer)?void 0:o.first)?`<w:footerReference w:type="first" r:id="${e.footer.first.relId}"/>`:"",(null==(i=null==e?void 0:e.footer)?void 0:i.even)?`<w:footerReference w:type="even" r:id="${e.footer.even.relId}"/>`:"",(null==(l=null==e?void 0:e.footer)?void 0:l.default)?`<w:footerReference w:type="default" r:id="${e.footer.default.relId}"/>`:""].join(""),m=(null==(s=null==e?void 0:e.header)?void 0:s.first)||(null==(d=null==e?void 0:e.footer)?void 0:d.first)?"<w:titlePg/>":"",v=t.columns;let b="";if(v&&v.count>1){const t=qL(v.space,0),e=v.separator?' w:sep="1"':"";if(!1===v.equalWidth&&(null==(c=v.columns)?void 0:c.length)){const a=v.columns.map(t=>`<w:col w:w="${qL(t.width,0)}" w:space="${qL(t.space,0)}"/>`).join("");b=`<w:cols w:num="${v.count}" w:space="${t}" w:equalWidth="0"${e}>${a}</w:cols>`}else b=`<w:cols w:num="${v.count}" w:space="${t}"${e}/>`}return`<w:sectPr>${g}${m}<w:pgSz w:w="${h}" w:h="${p}"${f}/><w:pgMar w:top="${qL(u.top,1440)}" w:right="${qL(u.right,1440)}" w:bottom="${qL(u.bottom,1440)}" w:left="${qL(u.left,1440)}" w:header="${qL(u.header,720)}" w:footer="${qL(u.footer,720)}" w:gutter="${qL(u.gutter,0)}"/>${b}</w:sectPr>`}(n.pageSettings,a[r])).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document ${nN}><w:body>${n}</w:body></w:document>`}function oN(t,e,a,n){const r="header"===t?"hdr":"ftr";return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${r} ${nN}>${Pz(e,a,n)}</w:${r}>`}function iN(t){return{id:Xa("").id,text:"",kind:"fieldChar",fieldChar:{kind:t}}}function lN(t,e,a){const n=Qa([{text:`${e} `},{text:String(a)},{text:t?`: ${t}`:""}]);var r;return n.style={styleId:"Caption",align:"center"},n.runs=[n.runs[0],iN("begin"),(r=" SEQ Figure \\* ARABIC ",{id:Xa("").id,text:"",kind:"fieldInstruction",fieldInstruction:r}),iN("separate"),n.runs[1],iN("end"),n.runs[2]],n}function sN(t){var e,a;if(!t)return!1;return"caption"===(null==(a=null==(e=t.style)?void 0:e.styleId)?void 0:a.toLowerCase())&&t.runs.some(t=>{const e=Se(t);return void 0!==e&&new RegExp("\\bSEQ\\s+Figure\\b","i").test(e)})}function dN(t,e){if(!sN(t))return MA(t);let a=!1,n=!1;const r=t.runs.map(t=>"fieldChar"===t.kind&&"separate"===t.fieldChar.kind?(a=!0,{...t,fieldChar:{...t.fieldChar}}):"fieldChar"===t.kind&&"end"===t.fieldChar.kind?(a=!1,{...t,fieldChar:{...t.fieldChar}}):a&&""!==t.text?t.text===String(e)?{...t}:(n=!0,{...t,text:String(e)}):{...t});return n?{...MA(t),runs:r}:MA(t)}function cN(t,e){return t.map(t=>{switch(t.type){case"paragraph":return sN(t)?dN(t,e.next++):MA(t);case"table":return{...t,rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:cN(t.blocks,e)}))}))};default:return ve(t,"block")}})}function hN(t){const e={next:1},a=ha(t).map(t=>({...t,blocks:cN(t.blocks,e),header:t.header?SA(t.header):void 0,footer:t.footer?SA(t.footer):void 0}));return{...t,sections:a}}function pN(t,e,a,n){const r=[],o=new Map,i=new Map,l=[],s=new Map;return aN(t,t=>{var e;for(const d of t.runs){const t=null==(e=d.styles)?void 0:e.link;if(t&&!t.startsWith("#")&&!s.has(t)){const e=`rIdLink${l.length+1}`;s.set(t,e),l.push({rId:e,href:t})}if("textBox"!==d.kind||i.has(d.id)||(i.set(d.id,a.nextTextBoxDocPrId),a.nextTextBoxDocPrId+=1),"image"!==d.kind)continue;const c=a.nextImageId,h=`rIdImg${c}`,p={rId:h,runId:d.id,cx:Math.round(d.image.width*Le),cy:Math.round(d.image.height*Le),alt:d.image.alt,crop:d.image.crop,fillMode:d.image.fillMode,rotation:d.image.rotation,flipH:d.image.flipH,flipV:d.image.flipV,floating:d.image.floating,wrapPolygon:d.image.wrapPolygon};if(d.image.linkedSrc){r.push({...p,kind:"linked",target:d.image.linkedSrc}),o.set(d.id,h),a.nextImageId+=1;continue}const u=da(n,d.image.src).match(/^data:([^;,]+);base64,(.*)$/);if(!u)continue;const f=Hy(u[1]);if(!f)continue;const g=u[2],m=`media/image${c}.${f}`;r.push({...p,kind:"embedded",target:m,base64:g}),o.set(d.id,h),a.nextImageId+=1}}),{numberingInfo:e.numberingInfo,definitions:e.definitions,images:r,imageMap:o,textBoxDocPrIds:i,hyperlinks:l,hyperlinkMap:s}}function uN(t,e,a){a&&(t.file(`word/${e}.xml`,a.xml),(a.partContext.images.length>0||a.partContext.hyperlinks.length>0)&&t.file(`word/_rels/${e}.xml.rels`,tN(a.partContext.images,a.partContext.hyperlinks)))}async function fN(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v;t=hN(t);const b=new bf,y=function(t){const e=new Map,a=new Map,n=[];let r=1,o=1;const i=t=>{if(!t.list)return;const i=Math.max(0,t.list.level??0),l=t.list.bulletGlyph??"",s=t.list.instanceId?`instance:${t.list.instanceId}`:`legacy:${t.list.kind}:${i}:${l}`;let d=a.get(s);d||(d={abstractNumId:r++,numId:o++,levels:[]},a.set(s,d),n.push(d)),d.levels.some(t=>t.level===i)||d.levels.push({kind:t.list.kind,level:i,format:t.list.format,startAt:t.list.startAt,levelText:t.list.levelText,suffix:t.list.suffix,alignment:t.list.alignment,legal:t.list.legal,bulletGlyph:t.list.bulletGlyph,bulletFont:t.list.bulletFont}),e.set(t.id,{numId:d.numId,level:i})};for(const l of ha(t))aN(l.blocks,i),l.header&&aN(l.header,i),l.firstPageHeader&&aN(l.firstPageHeader,i),l.evenPageHeader&&aN(l.evenPageHeader,i),l.footer&&aN(l.footer,i),l.firstPageFooter&&aN(l.firstPageFooter,i),l.evenPageFooter&&aN(l.evenPageFooter,i);return{numberingInfo:e,definitions:n}}(t),M={nextImageId:1,nextTextBoxDocPrId:1000001},x=ha(t),w=function(t){var e;const a=null==(e=t.footnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of Fc(t)){const t=Ae(o);if(!t)continue;if(n.has(t.footnoteId))continue;const e=a[t.footnoteId];e&&(n.set(t.footnoteId,{footnoteId:t.footnoteId,docxId:r,footnote:e}),r+=1)}return Array.from(n.values())}(t),S=function(t){const e=new Map;for(const a of t)e.set(a.footnoteId,a.docxId);return e}(w),A=w.length>0,C=Hz(t),I=function(t){const e=new Map;for(const a of t)e.set(a.endnoteId,a.docxId);return e}(C),T=C.length>0,k=function(t){const e=t.bookmarks;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const l of e.order){const t=e.items[l];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(l,r),n.add(r))}let r=0;for(const l of e.order)if(!a.has(l)){for(;n.has(r);)r+=1;a.set(l,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])};for(const l of e.order){const t=e.items[l];if(!t)continue;const n=a.get(l);t.start&&i(t.start.paragraphId,{kind:"start",offset:t.start.offset,seq:t.start.seq??0,wId:n,name:t.name,...void 0!==t.colFirst?{colFirst:t.colFirst}:{},...void 0!==t.colLast?{colLast:t.colLast}:{}}),t.end&&i(t.end.paragraphId,{kind:"end",offset:t.end.offset,seq:t.end.seq??0,wId:n})}return o}(t),V=function(t){const e=t.comments;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const s of e.order){const t=e.items[s];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(s,r),n.add(r))}let r=0;for(const s of e.order)if(!a.has(s)){for(;n.has(r);)r+=1;a.set(s,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])},l=[];return e.order.forEach((t,n)=>{const r=e.items[t];if(!r)return;const o=a.get(t),s=(1073741824+n).toString(16).toUpperCase();l.push({comment:r,wId:o,paraId:s}),r.start&&i(r.start.paragraphId,{kind:"start",offset:r.start.offset,seq:r.start.seq??0,wId:o}),r.end&&(i(r.end.paragraphId,{kind:"end",offset:r.end.offset,seq:r.end.seq??0,wId:o}),i(r.end.paragraphId,{kind:"reference",offset:r.end.offset,seq:(r.end.seq??0)+.5,wId:o}))}),{eventsByParagraph:o,comments:l}}(t),R=t=>(t.footnoteIdMap=S,t.endnoteIdMap=I,t.bookmarkEventsByParagraph=k,t.commentEventsByParagraph=null==V?void 0:V.eventsByParagraph,t),E=R(pN(x.flatMap(t=>t.blocks),y,M,t)),L=void 0!==V,z=[],N=x.map(()=>({}));let O=1,q=1;x.forEach((e,a)=>{const n=(e,n,r)=>{var o;if(!r||0===r.length)return;const i="header"===e?O:q,l=`${e}${i}.xml`,s=`rId${"header"===e?"Header":"Footer"}${i}`,d=R(pN(r,y,M,t));z.push({kind:e,type:n,path:l,relId:s,blocks:r,context:d});const c="header"===e?"header":"footer";((o=N[a])[c]??(o[c]={}))[n]={relId:s},"header"===e?O+=1:q+=1};n("header","first",e.firstPageHeader),n("header","even",e.evenPageHeader),n("header","default",e.header),n("footer","first",e.firstPageFooter),n("footer","even",e.evenPageFooter),n("footer","default",e.footer)});const P=y.definitions.length>0,W=x.some(t=>{var e,a;return((null==(e=t.evenPageHeader)?void 0:e.length)??0)>0||((null==(a=t.evenPageFooter)?void 0:a.length)??0)>0}),B=W||void 0!==(null==(e=t.settings)?void 0:e.defaultTabStop)||void 0!==(null==(a=t.settings)?void 0:a.allowSpaceOfSameStyleInTable)||void 0!==(null==(n=t.settings)?void 0:n.autoHyphenation)||void 0!==(null==(r=t.settings)?void 0:r.consecutiveHyphenLimit)||void 0!==(null==(o=t.settings)?void 0:o.hyphenationZone)||void 0!==(null==(i=t.settings)?void 0:i.doNotHyphenateCaps)||void 0!==(null==(l=t.footnotes)?void 0:l.settings)||void 0!==(null==(s=t.endnotes)?void 0:s.settings),F=[...E.images,...z.flatMap(t=>t.context.images)],H=A?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>Bz(t.footnote.blocks)));l.footnoteIdMap=i;const s=e.map(t=>{const e=Bz(t.footnote.blocks).map(t=>"paragraph"===t.type?Wz(t,l,o):sz(t,(t,e)=>{var a;return Wz(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:footnote w:id="${t.docxId}">${e}</w:footnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:footnotes xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${zL}"><w:footnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:footnote>${s}</w:footnotes>`,partContext:l}}(0,w,0,0,e=>pN(e,y,M,t),t.styles,S):null;H&&F.push(...H.partContext.images);const U=T?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>Uz(t.endnote.blocks)));l.endnoteIdMap=i;const s=e.map(t=>{const e=Uz(t.endnote.blocks).map(t=>"paragraph"===t.type?Wz(t,l,o):sz(t,(t,e)=>{var a;return Wz(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:endnote w:id="${t.docxId}">${e}</w:endnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:endnotes xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${zL}"><w:endnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:endnote><w:endnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:endnote>${s}</w:endnotes>`,partContext:l}}(0,C,0,0,e=>pN(e,y,M,t),t.styles,I):null;U&&F.push(...U.partContext.images);const G=F.filter(t=>"embedded"===t.kind).map(t=>{var e;return null==(e=t.target.split(".").pop())?void 0:e.toLowerCase()}).filter(t=>Boolean(t)),D=null!=t.styles&&Object.keys(t.styles).length>0,j=((null==(d=t.fontTable)?void 0:d.length)??0)>0;b.file("[Content_Types].xml",Jz(P,G,B,z,A,T,D,L,j)),b.file("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}"><Relationship Id="rId1" Type="${zL}/officeDocument" Target="word/document.xml"/></Relationships>`),b.file("word/document.xml",rN(t,E,N)),D&&b.file("word/styles.xml",function(t){const e=Object.values(t).map(Yz).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="${NL}">${e}</w:styles>`}(t.styles)),P&&b.file("word/numbering.xml",function(t){const e=t.map(({abstractNumId:t,levels:e})=>`<w:abstractNum w:abstractNumId="${t}">${e.sort((t,e)=>t.level-e.level).map(({kind:t,level:e,format:a,startAt:n,levelText:r,suffix:o,alignment:i,legal:l,bulletGlyph:s,bulletFont:d})=>{const c="bullet"===t?"bullet":a??"decimal",h=r??("bullet"===t?s??"":`%${e+1}.`),p=n??1,u="bullet"===t?d??"Symbol":void 0,f=u?`<w:rPr><w:rFonts w:ascii="${OL(u)}" w:hAnsi="${OL(u)}" w:hint="default"/></w:rPr>`:"",g=o&&"tab"!==o?`<w:suff w:val="${o}"/>`:"",m=l?"<w:isLgl/>":"";return`<w:lvl w:ilvl="${e}"><w:start w:val="${p}"/><w:numFmt w:val="${c}"/><w:lvlText w:val="${OL(h)}"/><w:lvlJc w:val="${i??"left"}"/>${g}${m}${f}</w:lvl>`}).join("")}</w:abstractNum>`).join(""),a=t.map(({abstractNumId:t,numId:e})=>`<w:num w:numId="${e}"><w:abstractNumId w:val="${t}"/></w:num>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${EL}">${e}${a}</w:numbering>`}(y.definitions)),(D||P||B||E.images.length>0||E.hyperlinks.length>0||z.length>0||A||T||L||j)&&b.file("word/_rels/document.xml.rels",function(t,e,a,n,r,o,i,l,s,d){let c="";l&&(c+=`<Relationship Id="rIdStyles" Type="${zL}/styles" Target="styles.xml"/>`),t&&(c+=`<Relationship Id="rIdNum" Type="${zL}/numbering" Target="numbering.xml"/>`),e&&(c+=`<Relationship Id="rIdSettings" Type="${zL}/settings" Target="settings.xml"/>`);for(const h of n)c+=`<Relationship Id="${h.rId}" Type="${zL}/hyperlink" Target="${OL(h.href)}" TargetMode="External"/>`;for(const h of a){const t="linked"===h.kind?' TargetMode="External"':"";c+=`<Relationship Id="${h.rId}" Type="${zL}/image" Target="${OL(h.target)}"${t}/>`}for(const h of r){const t="header"===h.kind?"header":"footer";c+=`<Relationship Id="${h.relId}" Type="${zL}/${t}" Target="${h.path}"/>`}return o&&(c+=`<Relationship Id="rIdFootnotes" Type="${zL}/footnotes" Target="footnotes.xml"/>`),i&&(c+=`<Relationship Id="rIdEndnotes" Type="${zL}/endnotes" Target="endnotes.xml"/>`),s&&(c+=`<Relationship Id="rIdComments" Type="${zL}/comments" Target="comments.xml"/>`,c+='<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>'),d&&(c+=`<Relationship Id="rIdFontTable" Type="${zL}/fontTable" Target="fontTable.xml"/>`),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}">${c}</Relationships>`}(P,B,E.images,E.hyperlinks,z,A,T,D,L,j)),j&&b.file("word/fontTable.xml",function(t){const e=t.map(t=>{const e=[];if(t.altName&&e.push(`<w:altName w:val="${OL(t.altName)}"/>`),t.panose1&&e.push(`<w:panose1 w:val="${OL(t.panose1)}"/>`),t.charset&&e.push(`<w:charset w:val="${OL(t.charset)}"/>`),t.family&&e.push(`<w:family w:val="${OL(t.family)}"/>`),t.pitch&&e.push(`<w:pitch w:val="${OL(t.pitch)}"/>`),t.sig){const a=Object.entries(t.sig).map(([t,e])=>`w:${t}="${OL(e)}"`).join(" ");a&&e.push(`<w:sig ${a}/>`)}return`<w:font w:name="${OL(t.name)}">${e.join("")}</w:font>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:fonts xmlns:w="${EL}">${e}</w:fonts>`}(t.fontTable)),B&&b.file("word/settings.xml",function(t,e,a,n,r,o){const i=[],l=WL(e);null!==l&&i.push(`<w:defaultTabStop w:val="${l}"/>`),(null==o?void 0:o.autoHyphenation)&&i.push("<w:autoHyphenation/>"),void 0!==(null==o?void 0:o.consecutiveHyphenLimit)&&o.consecutiveHyphenLimit>=0&&i.push(`<w:consecutiveHyphenLimit w:val="${o.consecutiveHyphenLimit}"/>`);const s=WL(null==o?void 0:o.hyphenationZone);null!==s&&i.push(`<w:hyphenationZone w:val="${s}"/>`),(null==o?void 0:o.doNotHyphenateCaps)&&i.push("<w:doNotHyphenateCaps/>");const d=$z("footnotePr",a);d&&i.push(d);const c=$z("endnotePr",n);return c&&i.push(c),t&&i.push("<w:evenAndOddHeaders/>"),r&&i.push("<w:compat><w:allowSpaceOfSameStyleInTable/></w:compat>"),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${EL}">${i.join("")}</w:settings>`}(W,null==(c=t.settings)?void 0:c.defaultTabStop,null==(h=t.footnotes)?void 0:h.settings,null==(p=t.endnotes)?void 0:p.settings,null==(u=t.settings)?void 0:u.allowSpaceOfSameStyleInTable,{autoHyphenation:null==(f=t.settings)?void 0:f.autoHyphenation,consecutiveHyphenLimit:null==(g=t.settings)?void 0:g.consecutiveHyphenLimit,hyphenationZone:null==(m=t.settings)?void 0:m.hyphenationZone,doNotHyphenateCaps:null==(v=t.settings)?void 0:v.doNotHyphenateCaps}));for(const Z of z)b.file(`word/${Z.path}`,oN(Z.kind,Z.blocks,Z.context,t.styles)),(Z.context.images.length>0||Z.context.hyperlinks.length>0)&&b.file(`word/_rels/${Z.path}.rels`,tN(Z.context.images,Z.context.hyperlinks));uN(b,"footnotes",H),uN(b,"endnotes",U),V&&(b.file("word/comments.xml",GL(V)),b.file("word/commentsExtended.xml",function(t){const e=t.comments.map(({comment:t,paraId:e})=>`<w15:commentEx w15:paraId="${e}" w15:done="${t.resolved?"1":"0"}"/>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w15:commentsEx ${UL}>${e}</w15:commentsEx>`}(V)));for(const Z of F)"embedded"===Z.kind&&Z.base64&&b.file(`word/${Z.target}`,Z.base64,{base64:!0});return b.generateAsync({type:"arraybuffer"})}function gN(t){switch(t){case"dashed":return[Zw(5),Zw(3)];case"dotted":return[Zw(1),Zw(3)];default:return}}async function mN(t,e,a,n,r,o,i,l){const s=e.rotation;s&&(t.saveGraphicsState(a.pageIndex),t.rotateAbout(a.pageIndex,Zw(n+o/2),Zw(r+i/2),s)),function(t,e,a,n,r,o,i){var l,s,d,c;const h=ip(null==(l=a.shape)?void 0:l.preset,Zw(n),Zw(r),Zw(o),Zw(i)),p=null==(s=a.shape)?void 0:s.fill,u=null==(d=a.shape)?void 0:d.borderColor,f=(null==(c=a.shape)?void 0:c.borderWidthPt)??(u?.75:0);t.drawPath(e,{segments:h,fill:p,stroke:u&&f>0?u:void 0,lineWidth:f})}(t,a.pageIndex,e,n,r,o,i),await async function(t,e,a,n,r,o,i,l){var s;if(0===e.blocks.length)return;const d=function(t){var e,a,n,r;return{left:(null==(e=t.body)?void 0:e.paddingLeft)??0,top:(null==(a=t.body)?void 0:a.paddingTop)??0,right:(null==(n=t.body)?void 0:n.paddingRight)??0,bottom:(null==(r=t.body)?void 0:r.paddingBottom)??0}}(e),c=n+d.left,h=r+d.top,p=Math.max(1,o-d.left-d.right),u=Math.max(1,i-d.top-d.bottom),f=(null==(s=Mc({blocks:e.blocks,pageSettings:{width:p,height:u,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:u,styles:a.document.styles,pageOffset:a.pageIndex})[0])?void 0:s.blocks)??[];if(0===f.length)return;const g=Va(a.document);t.saveGraphicsState(a.pageIndex),t.clipRect(a.pageIndex,Zw(c),Zw(h),Zw(p),Zw(u));let m=h;for(const v of f){switch(v.sourceBlock.type){case"paragraph":v.layout&&await l.drawParagraph(t,a.pageIndex,v.sourceBlock,v.layout.lines,a.document,c,m,a.fontRegistry,g,l);break;case"table":await l.drawTableBlock(t,a.pageIndex,v,a.document,c,m,p,a.fontRegistry,g,l);break;default:ve(v.sourceBlock,"block")}m+=Math.max(0,v.estimatedHeight)}t.restoreGraphicsState(a.pageIndex)}(t,e,a,n,r,o,i,l),s&&t.restoreGraphicsState(a.pageIndex)}async function vN(t){const{writer:e,document:a,fontRegistry:n,pageIndex:r,lines:o,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,drawers:h}=t;for(const p of o){const o=new Map(p.slots.map(t=>[t.offset,t]));for(const u of p.fragments){const f=u.textBox;if(!(null==f?void 0:f.floating))continue;const g=Boolean(f.floating.behindDoc);if(t.layer&&"behind"===t.layer!==g)continue;const m=o.get(u.startOffset),v=l+((null==m?void 0:m.left)??0),b=c+p.top,y=Cd({object:xd(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,lineTop:b,anchorLeft:v});await mN(e,f,{document:a,fontRegistry:n,pageIndex:r},y.x,y.y,y.width,y.height,h)}}}const bN=new WeakMap;function yN(t){const e=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(t);if(!e)return null;const a=e[1].toLowerCase(),n=Boolean(e[2]),r=e[3]??"";if(!n)return{mediaType:a,data:(new TextEncoder).encode(decodeURIComponent(r))};const o="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:a,data:Uint8Array.from(o,t=>t.charCodeAt(0))}}async function MN(t,e,a){let n=t;n.startsWith("data:")||(n=await async function(t){if("function"!=typeof fetch)return null;const e=await fetch(t);if(!e.ok)return null;const a=await e.blob(),n=new Uint8Array(await a.arrayBuffer()),r=Array.from(n,t=>String.fromCharCode(t)).join(""),o="function"==typeof btoa?btoa(r):Buffer.from(n).toString("base64");return`data:${a.type||"application/octet-stream"};base64,${o}`}(n)??n);let r=yN(n);if(!r)return null;const o="undefined"!=typeof Image?await async function(t){return"undefined"==typeof Image?null:await new Promise(e=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>e(a),a.onerror=()=>e(null),a.src=t})}(n):null,i=null!=o&&o.naturalWidth>0&&o.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const t=function(t){if("undefined"==typeof document)return null;const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const a=e.getContext("2d");return a?(a.fillStyle="#ffffff",a.fillRect(0,0,e.width,e.height),a.drawImage(t,0,0),e.toDataURL("image/jpeg",.92)):null}(o);if(r=t?yN(t):null,!r)return null}const l=i?o.naturalWidth:e,s=i?o.naturalHeight:a;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function xN(t,e,a){const n=da(e,a.src);if(!n)return null;let r=bN.get(t);r||(r=new Map,bN.set(t,r));const o=r.get(n);if(o)return o;const i=MN(n,a.width,a.height).then(e=>e?t.registerImageResource({width:e.width,height:e.height,data:e.data,filter:"DCTDecode"}):null);return r.set(n,i),i}function wN(t,e){const a=new Map(t.slots.map(t=>[t.offset,t])),n=[];for(const r of e.chars){if("\n"===r.char||"\t"===r.char)continue;const t=a.get(r.paragraphOffset);t&&n.push({char:r.char,left:t.left,offset:r.paragraphOffset})}return n}function SN(t,e,a){const n=wN(t,e);if(0===n.length)return null;const r=new Map(t.slots.map(t=>[t.offset,t])),o=n[0],i=n[n.length-1],l=r.get(i.offset+1);return{left:o.left,right:(null==l?void 0:l.left)??i.left+.55*a}}function AN(t,e,a,n,r,o,i){const l=SN(t,e,a.fontSize??Pe);return l?{x:Zw(n+l.left),y:Zw(r+t.top+o),width:Zw(Math.max(0,l.right-l.left)),height:Zw(Math.max(2,t.height-i))}:null}function CN(t,e,a,n,r,o,i){const l=Gp(i),s=(r,i)=>{t.drawLine(e,{x1:Zw(a),y1:Zw(r),x2:Zw(n),y2:Zw(r),stroke:o,lineWidth:Zw(l),dashArray:i})};if(Fp(i))return s(r-Kp),void s(r+Kp);Hp(i)?function(t,e,a,n,r,o,i){let l=a,s=r;for(let d=a;d<=n;d+=1){const n=r+Math.sin((d-a)/4*Math.PI)*Up;t.drawLine(e,{x1:Zw(l),y1:Zw(s),x2:Zw(d),y2:Zw(n),stroke:o,lineWidth:Zw(i)}),l=d,s=n}}(t,e,a,n,r,o,l):s(r,jp(i))}function IN(t,e){const a=Ep(t);if(!a)return t;const n=Math.max(0,Math.min(1,e));return function(t,e,a){const n=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${n(t)}${n(e)}${n(a)}`}(255+(a[0]-255)*n,255+(a[1]-255)*n,255+(a[2]-255)*n)}function TN(t,e,a){const{writer:n,pageIndex:r,baselineY:o,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:d,baseTextOptions:c}=t,h=Zw(1);if(d.emboss||d.imprint){const t=d.imprint?1:-1;n.drawText(r,{...c,x:Zw(e)+h*t,y:Zw(o)+h*t,text:a,color:"#BFBFBF"})}if(d.glow){const t=d.glow,i=.5*Zw(t.radiusPt*Ve),l=IN(t.color,.4*(t.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[d,h]of s)n.drawText(r,{...c,x:Zw(e)+d,y:Zw(o)+h,text:a,color:l})}if(d.textShadow){const t=d.textShadow,i=t.dirDeg*Math.PI/180,l=Zw(t.distPt*Ve);n.drawText(r,{...c,x:Zw(e)+Math.cos(i)*l,y:Zw(o)+Math.sin(i)*l,text:a,color:t.color})}else d.shadow&&n.drawText(r,{...c,x:Zw(e)+h,y:Zw(o)+h,text:a,color:"#808080"});if(d.reflection){const t=d.reflection,s=IN(l,.6*((t.startAlpha+t.endAlpha)/2));n.drawText(r,{...c,x:Zw(e),y:Zw(o)+Zw(t.distPt*Ve)+i,text:a,color:s})}const p=d.textOutline;n.drawText(r,{...c,x:Zw(e),y:Zw(o),text:a,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:d.outline?1:0}})}async function kN(t){for(const e of t.lines){const a=new Map(e.slots.map(t=>[t.offset,t]));for(const n of e.fragments){const r=n.image;if(!(null==r?void 0:r.floating))continue;const o=Boolean(r.floating.behindDoc);if("behind"===t.layer!==o)continue;const i=a.get(n.startOffset),l=Cd({object:wd(r),pageSettings:t.pageSettings,contentLeft:t.contentLeft,contentTop:t.contentTop,contentWidth:t.contentWidth,paragraphTop:t.paragraphTop,lineTop:t.paragraphTop+e.top,anchorLeft:t.contentLeft+((null==i?void 0:i.left)??0)}),s=await xN(t.writer,t.document,r);s&&t.writer.drawImage(t.pageIndex,{resourceName:s,x:Zw(l.x),y:Zw(l.y),width:Zw(l.width),height:Zw(l.height),rotation:r.rotation})}}}function VN(t,e,a,n,r,o,i,l){const s=SN(a,n,i.fontSize??Pe);if(!s)return;const d=o+Xp(l,a.top,a.height),c=r+s.left,h=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(t.drawLine(e,{x1:Zw(c),y1:Zw(d-Zp),x2:Zw(h),y2:Zw(d-Zp),stroke:p,lineWidth:Zw(1)}),void t.drawLine(e,{x1:Zw(c),y1:Zw(d+Zp),x2:Zw(h),y2:Zw(d+Zp),stroke:p,lineWidth:Zw(1)})):void CN(t,e,c,h,d,p,i.underlineStyle);t.drawLine(e,{x1:Zw(c),y1:Zw(d),x2:Zw(h),y2:Zw(d),stroke:p,lineWidth:Zw(1)})}async function RN(t,e,a,n,r,o,i,l,s,d){var c,h,p;if(r.image){if(r.image.floating)return;const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;const s=await xN(t,o,r.image);if(!s)return;return void t.drawImage(e,{resourceName:s,x:Zw(i+a.left),y:Zw(l+n.top+n.height-r.image.height),width:Zw(r.image.width),height:Zw(r.image.height),rotation:r.image.rotation})}if(r.textBox){if(r.textBox.floating)return;const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;return void(await mN(t,r.textBox,{document:o,fontRegistry:s,pageIndex:e},i+a.left,l+n.top+n.height-r.textBox.height,r.textBox.width,r.textBox.height,d))}const u=la(r.styles,null==(c=a.style)?void 0:c.styleId,o.styles);if(u.hidden)return;const f=s.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=u.smallCaps?.8*Kw(u):Kw(u),m=(u.baselineShift??0)*Ve,v=l+n.top+n.height*rd-m,b=wN(n,r),y=b.map(t=>u.allCaps?t.char.toUpperCase():t.char).join("");if(!b[0]||0===y.length)return;!function(t,e,a,n,r,o,i){if(!i.link)return;const l=SN(a,n,i.fontSize??Pe);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");t.addLinkAnnotation(e,{x:Zw(r+l.left),y:Zw(o+a.top),width:Zw(l.right-l.left),height:Zw(a.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){if(!i.shading)return;const l=AN(a,n,i,r,o,2,4);l&&t.drawRect(e,{...l,fill:i.shading})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){if(!i.highlight)return;const l=AN(a,n,i,r,o,2,4);l&&t.drawRect(e,{...l,fill:i.highlight})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=AN(a,n,i,r,o,1,2);s&&t.drawRect(e,{...s,stroke:l.color,lineWidth:Zw(Math.max(.5,l.width*Ve))})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i,l,s){var d;const c=new Map(n.slots.map(t=>[t.offset,t])),h=sa(a.style,o.styles).tabs??[];for(const p of r.chars){if("\t"!==p.char)continue;const a=c.get(p.paragraphOffset),r=c.get(p.paragraphOffset+1);if(!a||!r)continue;const o=(null==(d=n.slots[0])?void 0:d.left)??0,u=a.left-o,f=h.filter(t=>"clear"!==t.type).map(t=>({...t,positionPx:t.position*Ve})).filter(t=>t.positionPx>u+.01).sort((t,e)=>t.positionPx-e.positionPx)[0],g=(null==f?void 0:f.leader)&&"none"!==f.leader?f.leader:void 0;if(!g)continue;const m="underscore"===g?l+2:l;t.drawLine(e,{x1:Zw(i+a.left),y1:Zw(m),x2:Zw(i+r.left),y2:Zw(m),stroke:s,lineWidth:Zw("heavy"===g?1.5:1),dashArray:"dot"===g||"middleDot"===g?[1,3]:"hyphen"===g?[5,3]:void 0})}}(t,e,a,n,r,o,i,v,u.color??"#000000");const M=sa(a.style,o.styles).align??"left",x=function(t,e){const a=new Set;switch(t.ligatures){case"standard":a.add("liga");break;case"contextual":a.add("calt");break;case"historical":a.add("hlig");break;case"standardContextual":a.add("liga"),a.add("calt")}return"lining"===t.numberForm&&a.add("lnum"),"oldStyle"===t.numberForm&&a.add("onum"),"proportional"===t.numberSpacing&&a.add("pnum"),"tabular"===t.numberSpacing&&a.add("tnum"),"number"==typeof t.stylisticSet&&t.stylisticSet>=1&&t.stylisticSet<=20&&a.add(`ss${String(t.stylisticSet).padStart(2,"0")}`),t.contextualAlternates&&a.add("calt"),"number"==typeof e&&"number"==typeof t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e>=t.kerningThreshold&&a.add("kern"),Array.from(a).sort()}(u,Kw(u)),w={fontSize:g,bold:u.bold,italic:u.italic,fontResourceName:f.writerResourceName,characterSpacing:u.characterSpacing??0,horizontalScale:u.characterScale??100,fontFeatures:x},S="solid"===(null==(h=u.textFill)?void 0:h.type)?u.textFill.color:"gradient"===(null==(p=u.textFill)?void 0:p.type)&&u.textFill.stops[0]?u.textFill.stops[0].color:u.color??"#000000",A=function(t,e,a,n,r,o,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=SN(a,n,i.fontSize??Pe);if(!s)return;const d=r+s.left,c=r+s.right,h=zp(d,o+a.top,c,o+a.top+a.height,l.angle??0);return t.registerAxialGradient(e,{x0:Zw(h.x0),y0:Zw(h.y0),x1:Zw(h.x1),y1:Zw(h.y1),stops:l.stops.map(t=>({offset:t.position,color:t.color}))})??void 0}(t,e,n,r,i,l,u);!function(t,e,a,n,r,o,i){const l="justify"===i?function(t){const e=[];let a=[];for(const n of t)" "!==n.char?a.push(n):a.length>0&&(e.push(a),a=[]);return a.length>0&&e.push(a),e}(e):function(t){const e=[];let a=[];for(const n of t){const t=a[a.length-1];t&&n.offset>t.offset+1&&(e.push(a),a=[]),a.push(n)}return a.length>0&&e.push(a),e}(e);for(const s of l){const e=s.map(t=>n.allCaps?t.char.toUpperCase():t.char).join("");0!==e.length&&TN(t,a+s[0].left,e)}if(r.trailingHyphen&&o.endOffset>=r.endOffset){const e=r.slots.find(t=>t.offset===r.endOffset)??r.slots[r.slots.length-1];e&&TN(t,a+e.left,"-")}}({writer:t,pageIndex:e,baselineY:v,fontSizePt:g,mainColor:S,gradientShadingName:A,styles:u,baseTextOptions:w},b,i,u,n,r,M),u.underline&&VN(t,e,n,r,i,l,u,"underline"),u.strike&&VN(t,e,n,r,i,l,u,"strike"),u.doubleStrike&&VN(t,e,n,r,i,l,u,"doubleStrike"),u.emphasisMark&&function(t,e,a,n,r,o,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=Dp[l];if(!s)return;const d=wN(a,n),c="underDot"===l,h=Math.max(4,.35*a.height),p=c?o+a.top+a.height+h:o+a.top+h;for(let u=0;u<d.length;u+=1){const n=d[u];if(" "===n.char||"\t"===n.char||"\n"===n.char)continue;const o=d[u+1],l=o?(n.left+o.left)/2:n.left+.25*a.height;t.drawText(e,{x:Zw(r+l-.25*h),y:Zw(p),text:s,fontSize:Zw(h),color:i.color??"#000000"})}}(t,e,n,r,i,l,u)}function EN(t,e,a,n,r,o,i,l,s){var d;if(0!==n.index)return;const c=Ra(a,s);if(!c)return;const h=n.slots[0];if(!h)return;const p=la(void 0,null==(d=a.style)?void 0:d.styleId,r.styles),u=l.resolveFontFace({fontFamily:p.fontFamily,bold:p.bold,italic:p.italic}),f=is(a,r.styles),g=Kw(p),m=c.length*g*.62*Ve,v=ls(a,r.styles,h.left,m);t.drawText(e,{x:Zw(o+Math.max(0,v||f)),y:Zw(i+n.top+n.height*rd),text:c,fontSize:g,color:p.color??"#000000",bold:p.bold,italic:p.italic,fontResourceName:u.writerResourceName})}function LN(t,e,a,n,r,o,i){const l=[[a.borderTop,"top"],[a.borderRight,"right"],[a.borderBottom,"bottom"],[a.borderLeft,"left"]],s=l.some(([t])=>t&&"none"!==t.type&&t.width>0);if(!a.shading&&!s)return;let d=0;for(const g of n)d=Math.max(d,g.top+g.height);if(d<=0)return;const c=nd(a),h=c.top+d+c.bottom,p=r+(a.indentLeft??0),u=r+i-(a.indentRight??0),f=o+h;a.shading&&t.drawRect(e,{x:Zw(p),y:Zw(o),width:Zw(Math.max(0,u-p)),height:Zw(h),fill:a.shading});for(const[g,m]of l){if(!g||"none"===g.type||g.width<=0)continue;const[a,n,r,i]="top"===m?[p,o,u,o]:"bottom"===m?[p,f,u,f]:"left"===m?[p,o,p,f]:[u,o,u,f];t.drawLine(e,{x1:Zw(a),y1:Zw(n),x2:Zw(r),y2:Zw(i),stroke:g.color,lineWidth:g.width,dashArray:gN(g.type)})}}async function zN(t,e,a,n,r,o,i,l,s,d){for(const c of n){EN(t,e,a,c,r,o,i,l,s);for(const n of c.fragments)await RN(t,e,a,c,n,r,o,i,l,d)}}function NN(t,e,a,n,r,o,i){"none"===a.type||a.width<=0||t.drawLine(e,{x1:Zw(n),y1:Zw(r),x2:Zw(o),y2:Zw(i),stroke:a.color,lineWidth:Zw(a.width),dashArray:gN(a.type)})}function ON(t,e,a,n,r){const o=n+a.left,i=r+a.top,l=o+a.width,s=i+a.height;NN(t,e,a.borders.top,o,i,l,i),NN(t,e,a.borders.right,l,i,l,s),NN(t,e,a.borders.bottom,o,s,l,s),NN(t,e,a.borders.left,o,i,o,s),a.borders.topLeftToBottomRight&&NN(t,e,a.borders.topLeftToBottomRight,o,i,l,s),a.borders.topRightToBottomLeft&&NN(t,e,a.borders.topRightToBottomLeft,l,i,o,s)}async function qN(t,e,a,n,r,o,i,l,s,d){if("table"!==a.sourceBlock.type)return;const c=a.sourceBlock,h=a.tableSegment?To(c,a.tableSegment):c;if(0===h.rows.length)return;const p=Lh({table:h,state:{document:n},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:a.estimatedHeight});for(const u of p.cells)u.shading&&t.drawRect(e,{x:Zw(r+u.left),y:Zw(o+u.top),width:Zw(u.width),height:Zw(u.height),fill:u.shading});for(const u of p.cells)if(ON(t,e,u,r,o),u.revision){const a="insert"===u.revision.type?"#059669":"delete"===u.revision.type?"#dc2626":"#d97706";t.drawRect(e,{x:Zw(r+u.left+1),y:Zw(o+u.top+1),width:Zw(Math.max(0,u.width-2)),height:Zw(Math.max(0,u.height-2)),stroke:a,lineWidth:Zw(2)})}for(const u of p.cells)for(const a of u.paragraphs)await zN(t,e,a.paragraph,a.lines,n,r+a.originX,o+a.originY,l,s,d)}const PN={drawParagraph:zN,drawTableBlock:qN};async function WN(t,e,a,n,r,o,i,l,s,d,c){var h;if(!a||0===a.length)return;const p=o;let u=o;for(const f of a){switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const a=sa(f.sourceBlock.style,n.styles),h=u+(0===f.layout.startOffset&&u>o?a.spacingBefore??0:0);null==c||c(f.sourceBlock.id,h);const g=h+nd(a).top;LN(t,e,a,f.layout.lines,r,h,i),d&&(await kN({writer:t,pageIndex:e,lines:f.layout.lines,document:n,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:g,layer:"behind"}),await vN({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:f.layout.lines,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:h,drawers:PN,layer:"behind"})),await zN(t,e,f.sourceBlock,f.layout.lines,n,r,g,l,s,PN),d&&(await kN({writer:t,pageIndex:e,lines:f.layout.lines,document:n,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:g,layer:"front"}),await vN({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:f.layout.lines,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:h,drawers:PN,layer:"front"}));break}case"table":if((null==(h=f.sourceBlock.style)?void 0:h.floating)&&d){const a=kh(f.sourceBlock,i),o=Md({floating:f.sourceBlock.style.floating,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,anchorTop:u,width:a,height:f.floatingTableHeight??1,pageIndex:e});o.y+=f.floatingTableOffsetY??0,await qN(t,e,{...f,estimatedHeight:o.height},n,o.x,o.y,i,l,s,PN);break}await qN(t,e,f,n,r,u,i,l,s,PN);break;default:ve(f.sourceBlock,"block")}u+=Math.max(0,f.estimatedHeight)}}function BN(t,e,a,n){t.drawRect(e,{x:0,y:0,width:a,height:n,fill:"#ffffff"})}const FN=[{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 HN(t,e,a){return`${t.toLowerCase()}:${e?"bold":"regular"}${a?"italic":""}`}function UN(t){return t.replace(/[^A-Za-z0-9_]/g,"")}class GN{constructor(){a(this,"faces",new Map),a(this,"fallbackFamily","Helvetica");for(const t of FN)this.registerFontFace(t)}registerFontFace(t){this.faces.set(HN(t.family,t.bold,t.italic),t)}resolveFontFace(t){const e=ol(t.fontFamily),a=Boolean(t.bold),n=Boolean(t.italic);return this.faces.get(HN(e,a,n))??this.faces.get(HN(this.fallbackFamily,a,n))??this.faces.get(HN(this.fallbackFamily,!1,!1))}getPdfFontResources(){const t=new Map;for(const e of this.faces.values())t.set(e.pdfResource.resourceName,e.pdfResource);return Array.from(t.values())}async loadBundledUnicodeFaces(t={}){const e=t.families?new Set(Array.from(t.families).map(ol).map(t=>t.toLowerCase())):null,a=await this.registerOfficeCompatibleFaces(e);if(!e||e.has("roboto")||Array.from(e).some(t=>"helvetica"!==t&&!a.has(t)))for(const[n,r]of Object.entries(nl)){const t=await ul(r);if(!t)continue;const e="bold"===n||"bolditalic"===n,a="italic"===n||"bolditalic"===n,o=`Roboto${n[0].toUpperCase()}${n.slice(1)}`;this.registerFontFace({key:`roboto:${n}`,family:"Roboto",bold:e,italic:a,writerResourceName:o,pdfResource:{kind:"unicode",resourceName:o,family:"Roboto",fontData:t}}),this.fallbackFamily="Roboto"}}async registerOfficeCompatibleFaces(t){const e=new Set;for(const a of rl){const n=[a.family,...a.aliases].map(t=>t.toLowerCase());if(!(!t||n.some(e=>t.has(e))))continue;for(const t of n)e.add(t);const r=[];for(const[t,e]of Object.entries(a.files)){const n=await ul(e);if(!n)continue;const o="bold"===t||"bolditalic"===t,i="italic"===t||"bolditalic"===t,l=`${UN(a.family)}${t[0].toUpperCase()}${t.slice(1)}`,s={key:`${a.family.toLowerCase()}:${t}`,family:a.family,bold:o,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:a.family,fontData:n}};this.registerFontFace(s),r.push(s)}for(const t of a.aliases)for(const e of r)this.registerFontFace({...e,key:`${t.toLowerCase()}:${e.key.split(":")[1]}`,family:t})}return e}}const DN="%PDF-1.4\n% Oasis PDF\n",jN=[{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 ZN(t){return Number.isFinite(t)?Number(t.toFixed(3)).toString():"0"}function KN(t){return(new TextEncoder).encode(t).byteLength}function XN(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0").toUpperCase()).join("")}function YN(t){return Math.max(0,t).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function JN(t,e){if(!t)return e;const a=Ep(t);return a?[a[0]/255,a[1]/255,a[2]/255]:e}function QN(t,e,a){const[n,r,o]=JN(t,a);return`${ZN(n)} ${ZN(r)} ${ZN(o)} ${e}`}function _N(t,e){return(t&&t.trim().length>0?t:e).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}const $N=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 tO(t){return Array.from(t).map(t=>function(t){const e=t.codePointAt(0)??63;return e>=32&&e<=126||e>=160&&e<=255?e:$N.get(e)??63}(t).toString(16).padStart(2,"0").toUpperCase()).join("")}function eO(t){const e=[];for(let a of t)a>65535?(a-=65536,e.push(a>>>10&1023|55296),e.push(1023&a|56320)):e.push(a);return e.map(YN).join("")}function aO(t){return YN(t)}function nO(t){return`% OasisText ${eO(Array.from(t).map(t=>t.codePointAt(0)??65533))}`}class rO{constructor(t,e,a,n){this.page=t,this.fonts=e,this.images=a,this.shadings=n}registerAxialGradient(t){const e=this.shadings.register({x0:t.x0,y0:this.page.height-t.y0,x1:t.x1,y1:this.page.height-t.y1,stops:t.stops});return this.page.shadingResourceNames.add(e),e}drawRect(t){const e=this.page;if(t.width<=0||t.height<=0)return;const a=["q"];t.fill&&a.push(QN(t.fill,"rg",[1,1,1])),t.stroke&&(a.push(QN(t.stroke,"RG",[0,0,0])),a.push(`${ZN(t.lineWidth??1)} w`)),a.push([ZN(t.x),ZN(e.height-t.y-t.height),ZN(t.width),ZN(t.height),"re"].join(" ")),t.fill&&t.stroke?a.push("B"):t.fill?a.push("f"):t.stroke&&a.push("S"),a.push("Q"),e.commands.push(a.join("\n"))}drawLine(t){const e=this.page,a=t.dashArray&&t.dashArray.length>0?`[${t.dashArray.map(t=>ZN(t)).join(" ")}] 0 d`:null,n=["q",QN(t.stroke,"RG",[0,0,0])];a&&n.push(a),n.push(`${ZN(t.lineWidth??1)} w`,`${ZN(t.x1)} ${ZN(e.height-t.y1)} m`,`${ZN(t.x2)} ${ZN(e.height-t.y2)} l`,"S","Q"),e.commands.push(n.join("\n"))}drawPath(t){const e=this.page;if(0===t.segments.length)return;if(!t.fill&&!t.stroke)return;const a=t=>e.height-t,n=["q"];t.fill&&n.push(QN(t.fill,"rg",[1,1,1])),t.stroke&&(n.push(QN(t.stroke,"RG",[0,0,0])),n.push(`${ZN(t.lineWidth??1)} w`));for(const r of t.segments)switch(r.type){case"move":n.push(`${ZN(r.x)} ${ZN(a(r.y))} m`);break;case"line":n.push(`${ZN(r.x)} ${ZN(a(r.y))} l`);break;case"cubic":n.push(`${ZN(r.x1)} ${ZN(a(r.y1))} ${ZN(r.x2)} ${ZN(a(r.y2))} ${ZN(r.x)} ${ZN(a(r.y))} c`);break;case"close":n.push("h")}t.fill&&t.stroke?n.push("B"):t.fill?n.push("f"):n.push("S"),n.push("Q"),e.commands.push(n.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}rotateAbout(t,e,a){const n=this.page;if(!a)return;const r=n.height-e,o=-a*Math.PI/180,i=Math.cos(o),l=Math.sin(o),s=t-t*i+r*l,d=r-t*l-r*i;n.commands.push(`${ZN(i)} ${ZN(l)} ${ZN(-l)} ${ZN(i)} ${ZN(s)} ${ZN(d)} cm`)}clipRect(t,e,a,n){const r=this.page;a<=0||n<=0||r.commands.push(`${ZN(t)} ${ZN(r.height-e-n)} ${ZN(a)} ${ZN(n)} re`,"W","n")}drawText(t){if(0===t.text.length)return;const e=this.fonts.resolveAndMarkFontName(t),a=this.fonts.getUnicodeState(e),n=a?this.fonts.buildUnicodeShowCommand(a,t.text,t.fontFeatures):`<${tO(t.text)}> Tj`;null!==n&&(t.gradientShadingName?this.emitGradientTextBlock(e,n,t,t.gradientShadingName):this.emitTextBlock(e,n,t))}textSetupCommands(t,e){return[`/${t} ${ZN(e.fontSize??12)} Tf`,...e.horizontalScale&&e.horizontalScale>0&&100!==e.horizontalScale?[`${ZN(e.horizontalScale)} Tz`]:[],...e.characterSpacing&&0!==e.characterSpacing?[`${ZN(e.characterSpacing)} Tc`]:[]]}emitTextBlock(t,e,a){const n=this.page;n.commands.push([nO(a.text),"BT",QN(a.color,"rg",[0,0,0]),...a.renderMode&&0!==a.renderMode?[QN(a.strokeColor??a.color,"RG",[0,0,0]),`${ZN(a.strokeWidth??Math.max(.3,.03*(a.fontSize??12)))} w`,`${a.renderMode} Tr`]:[],...this.textSetupCommands(t,a),`${ZN(a.x)} ${ZN(n.height-a.y)} Td`,e,"ET"].join("\n"))}emitGradientTextBlock(t,e,a,n){const r=this.page;r.commands.push([nO(a.text),"q","BT",...this.textSetupCommands(t,a),"7 Tr",`${ZN(a.x)} ${ZN(r.height-a.y)} Td`,e,"ET",`/${n} sh`,"Q"].join("\n"))}drawImage(t){const e=this.page;if(t.width<=0||t.height<=0||!this.images.has(t.resourceName))return;e.imageResourceNames.add(t.resourceName);const a=e.height-t.y-t.height,n=Number.isFinite(t.rotation)?t.rotation??0:0;if(0===n)return void e.commands.push(["q",[ZN(t.width),"0","0",ZN(t.height),ZN(t.x),ZN(a),"cm"].join(" "),`/${t.resourceName} Do`,"Q"].join("\n"));const r=-n*Math.PI/180,o=Math.cos(r),i=Math.sin(r),l=t.width*o,s=t.width*i,d=-t.height*i,c=t.height*o,h=t.x+t.width/2-.5*l-.5*d,p=a+t.height/2-.5*s-.5*c;e.commands.push(["q",[ZN(l),ZN(s),ZN(d),ZN(c),ZN(h),ZN(p),"cm"].join(" "),`/${t.resourceName} Do`,"Q"].join("\n"))}}function oO(t,e){const a=new Array(e);for(let n=0;n<e;n+=1)a[n]=t.u16();return a}function iO(t,e,a){const n=new Array(e);for(let r=0;r<e;r+=1)n[r]=a+t.u16();return n}function lO(t,e){t.seek(e);const a=t.u16();if(1===a){const e=t.u16(),a=new Map;for(let n=0;n<e;n+=1)a.set(t.u16(),n);return t=>a.get(t)??-1}if(2===a){const e=t.u16(),a=[];for(let n=0;n<e;n+=1){const e=t.u16(),n=t.u16(),r=t.u16();a.push({start:e,end:n,startIndex:r})}return t=>{for(const e of a)if(t>=e.start&&t<=e.end)return e.startIndex+(t-e.start);return-1}}return()=>-1}function sO(t,e){t.seek(e);const a=t.u16();if(1===a){const e=t.u16(),a=t.u16(),n=oO(t,a);return t=>{const r=t-e;return r>=0&&r<a?n[r]:0}}if(2===a){const e=t.u16(),a=[];for(let n=0;n<e;n+=1){const e=t.u16(),n=t.u16(),r=t.u16();a.push({start:e,end:n,classValue:r})}return t=>{for(const e of a)if(t>=e.start&&t<=e.end)return e.classValue;return 0}}return()=>0}function dO(t){t.seek(0),t.skip(2),t.skip(2);const e=t.u16(),a=t.u16(),n=t.u16(),r=function(t,e){t.seek(e);const a=t.u16(),n=[];for(let r=0;r<a;r+=1){const a=t.tag(),r=e+t.u16();n.push({tag:a,offset:r})}return n.map(({tag:e,offset:a})=>{t.seek(a),t.skip(2);const n=t.u16();return{tag:e,lookupIndices:oO(t,n)}})}(t,a),o=function(t,e){t.seek(e);const a=t.u16(),n=[];for(let d=0;d<a;d+=1){const a=t.tag(),r=e+t.u16();n.push({tag:a,offset:r})}if(0===n.length)return[];const r=n.find(t=>"latn"===t.tag)??n.find(t=>"DFLT"===t.tag)??n[0];t.seek(r.offset);const o=t.u16();if(0===o)return[];t.seek(r.offset+o),t.skip(2);const i=t.u16(),l=t.u16(),s=[];65535!==i&&s.push(i);for(let d=0;d<l;d+=1)s.push(t.u16());return s}(t,e),i=new Map;for(const l of o){const t=r[l];if(!t)continue;const e=i.get(t.tag)??[];for(const a of t.lookupIndices)e.includes(a)||e.push(a);i.set(t.tag,e)}return{featureToLookups:i,lookupListOffset:n}}function cO(t,e,a){t.seek(e);const n=t.u16();return iO(t,n,e).map(e=>{t.seek(e);const n=t.u16();t.skip(2);const r=iO(t,t.u16(),e),o=[];for(const i of r)try{const e=a(t,i,n);e&&o.push(e)}catch{}return{lookupType:n,subtables:o}})}function hO(t,e){const a=new Set;for(const n of e)for(const e of t.get(n)??[])a.add(e);return Array.from(a).sort((t,e)=>t-e)}function pO(t,e){if(t.seek(e),1!==t.u16())return null;const a=e+t.u16(),n=t.u16(),r=iO(t,n,e).map(e=>(t.seek(e),oO(t,t.u16())));return{coverage:lO(t,a),sets:r}}function uO(t,e){const a=new Array(e);for(let n=0;n<e;n+=1){const e=t.u16(),r=t.u16();a[n]={sequenceIndex:e,lookupListIndex:r}}return a}function fO(t,e,a,n){for(const r of a)n.applyLookupIndexAt(r.lookupListIndex,t,e+r.sequenceIndex)}function gO(t,e){t.seek(e);const a=t.u16();return iO(t,a,e).map(e=>{t.seek(e);return{backtrack:oO(t,t.u16()),input:oO(t,Math.max(0,t.u16()-1)),lookahead:oO(t,t.u16()),records:uO(t,t.u16())}})}function mO(t,e,a,n,r){const o=(t,a)=>{const n=e[t];return n?r?"b"===a?r.backtrack(n.id):"l"===a?r.lookahead(n.id):r.input(n.id):n.id:null};for(const i of t){const t=i.input.length+1;if(a+t>e.length)continue;let r=!0;for(let e=0;e<i.input.length;e+=1)if(o(a+1+e,"i")!==i.input[e]){r=!1;break}if(r){for(let t=0;t<i.backtrack.length;t+=1)if(o(a-1-t,"b")!==i.backtrack[t]){r=!1;break}if(r){for(let e=0;e<i.lookahead.length;e+=1)if(o(a+t+e,"l")!==i.lookahead[e]){r=!1;break}if(r)return fO(e,a,i.records,n),t}}}return null}function vO(t,e,a){switch(a){case 1:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16();if(1===a){const e=t.i16(),a=lO(t,n);return{apply(t,n){const r=t[n];return!r||a(r.id)<0?null:(r.id=r.id+e&65535,1)}}}if(2===a){const e=t.u16(),a=oO(t,e),r=lO(t,n);return{apply(t,n){const o=t[n];if(!o)return null;const i=r(o.id);return i<0||i>=e?null:(o.id=a[i],1)}}}return null}(t,e);case 2:return function(t,e){const a=pO(t,e);if(!a)return null;const{coverage:n,sets:r}=a;return{apply(t,e){const a=t[e];if(!a)return null;const o=n(a.id);if(o<0||o>=r.length)return null;const i=r[o];if(0===i.length)return null;const l=a.codePoints,s=i.map((t,e)=>({id:t,codePoints:0===e?l:[]}));return t.splice(e,1,...s),i.length}}}(t,e);case 3:return function(t,e){const a=pO(t,e);if(!a)return null;const{coverage:n,sets:r}=a;return{apply(t,e){const a=t[e];if(!a)return null;const o=n(a.id);if(o<0||o>=r.length)return null;const i=r[o];return 0===i.length?null:(a.id=i[0],1)}}}(t,e);case 4:return function(t,e){if(t.seek(e),1!==t.u16())return null;const a=e+t.u16(),n=t.u16(),r=iO(t,n,e).map(e=>(t.seek(e),iO(t,t.u16(),e).map(e=>{t.seek(e);const a=t.u16(),n=t.u16();return{ligatureGlyph:a,components:oO(t,Math.max(0,n-1))}}))),o=lO(t,a);return{apply(t,e){const a=t[e];if(!a)return null;const n=o(a.id);if(n<0||n>=r.length)return null;for(const o of r[n]){const{components:a}=o;if(e+a.length>t.length-1)continue;let n=!0;for(let o=0;o<a.length;o+=1)if(t[e+1+o].id!==a[o]){n=!1;break}if(!n)continue;const r=a.length+1,i=[];for(let o=0;o<r;o+=1)i.push(...t[e+o].codePoints);return t.splice(e,r,{id:o.ligatureGlyph,codePoints:i}),1}return null}}}(t,e);case 6:return function(t,e){t.seek(e);const a=t.u16();if(3===a){const a=iO(t,t.u16(),e),n=iO(t,t.u16(),e),r=iO(t,t.u16(),e),o=t.u16(),i=uO(t,o),l=a.map(e=>lO(t,e)),s=n.map(e=>lO(t,e)),d=r.map(e=>lO(t,e));return{apply(t,e,a){if(0===s.length)return null;if(e+s.length>t.length)return null;for(let n=0;n<s.length;n+=1)if(s[n](t[e+n].id)<0)return null;for(let n=0;n<l.length;n+=1){const a=t[e-1-n];if(!a||l[n](a.id)<0)return null}for(let n=0;n<d.length;n+=1){const a=t[e+s.length+n];if(!a||d[n](a.id)<0)return null}return fO(t,e,i,a),s.length}}}if(1===a){const a=e+t.u16(),n=t.u16(),r=iO(t,n,e),o=lO(t,a),i=r.map(e=>gO(t,e));return{apply(t,e,a){const n=t[e];if(!n)return null;const r=o(n.id);return r<0||r>=i.length?null:mO(i[r],t,e,a,null)}}}if(2===a){const a=e+t.u16(),n=e+t.u16(),r=e+t.u16(),o=e+t.u16(),i=t.u16(),l=new Array(i);for(let u=0;u<i;u+=1){const a=t.u16();l[u]=0===a?0:e+a}const s=lO(t,a),d=sO(t,n),c=sO(t,r),h=sO(t,o),p=l.map(e=>0===e?[]:gO(t,e));return{apply(t,e,a){const n=t[e];if(!n)return null;if(s(n.id)<0)return null;const r=c(n.id),o=p[r];return o?mO(o,t,e,a,{backtrack:d,input:c,lookahead:h}):null}}}return null}(t,e);case 7:{t.seek(e);if(1!==t.u16())return null;const a=t.u16(),n=e+t.u32();return vO(t,n,a)}default:return null}}class bO{constructor(t,e){this.lookups=t,this.featureToLookups=e}static parse(t){try{const e=new Ml(t),{featureToLookups:a,lookupListOffset:n}=dO(e),r=cO(e,n,vO);return new bO(r,a)}catch{return null}}hasAnyFeature(t){return t.some(t=>this.featureToLookups.has(t))}collectLookupIndices(t){return hO(this.featureToLookups,t)}applyLookupIndexAt(t,e,a){const n=this.lookups[t];if(!n||a<0||a>=e.length)return null;for(const r of n.subtables){const t=r.apply(e,a,this);if(null!==t)return t}return null}shape(t,e){const a=this.collectLookupIndices(e);for(const n of a){let e=0;for(;e<t.length;){const a=this.applyLookupIndexAt(n,t,e);e+=a&&a>0?a:1}}}}function yO(t,e){let a=0;return 1&e&&t.i16(),2&e&&t.i16(),4&e&&(a=t.i16()),8&e&&t.i16(),16&e&&t.u16(),32&e&&t.u16(),64&e&&t.u16(),128&e&&t.u16(),a}function MO(t){let e=0;for(let a=0;a<8;a+=1)t&1<<a&&(e+=1);return 2*e}function xO(t,e,a){switch(a){case 1:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16();if(1===a){const e=t.u16(),a=yO(t,e),r=lO(t,n);return 0===a?null:{apply:(t,e,n)=>r(t[n])<0?null:(e[n]+=a,1)}}if(2===a){const e=t.u16(),a=t.u16(),r=MO(e),o=t.tell(),i=new Array(a);for(let n=0;n<a;n+=1)t.seek(o+n*r),i[n]=yO(t,e);const l=lO(t,n);return{apply(t,e,n){const r=l(t[n]);if(r<0||r>=a)return null;const o=i[r];return 0===o?null:(e[n]+=o,1)}}}return null}(t,e);case 2:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16(),r=t.u16(),o=t.u16(),i=!!(4&o);if(1===a){const a=t.u16(),l=iO(t,a,e).map(e=>{t.seek(e);const a=t.u16(),n=new Map;for(let i=0;i<a;i+=1){const e=t.u16(),a=yO(t,r),i=yO(t,o);n.set(e,{secondGlyph:e,value1XAdvance:a,value2XAdvance:i})}return n}),s=lO(t,n);return{apply(t,e,a){const n=t[a+1];if(void 0===n)return null;const r=s(t[a]);if(r<0||r>=l.length)return null;const o=l[r].get(n);return o?(e[a]+=o.value1XAdvance,e[a+1]+=o.value2XAdvance,i?2:1):null}}}if(2===a){const a=e+t.u16(),l=e+t.u16(),s=t.u16(),d=t.u16(),c=MO(r),h=c+MO(o),p=t.tell(),u=new Array(s*d),f=new Array(s*d);for(let e=0;e<s;e+=1)for(let a=0;a<d;a+=1){const n=(e*d+a)*h;t.seek(p+n),u[e*d+a]=yO(t,r),t.seek(p+n+c),f[e*d+a]=yO(t,o)}const g=lO(t,n),m=sO(t,a),v=sO(t,l);return{apply(t,e,a){const n=t[a],r=t[a+1];if(void 0===r)return null;if(g(n)<0)return null;const o=m(n),l=v(r);if(o>=s||l>=d)return null;const c=o*d+l,h=u[c],p=f[c];return 0===h&&0===p?null:(e[a]+=h,e[a+1]+=p,i?2:1)}}}return null}(t,e);case 9:{t.seek(e);if(1!==t.u16())return null;const a=t.u16(),n=e+t.u32();return xO(t,n,a)}default:return null}}class wO{constructor(t,e){this.lookups=t,this.featureToLookups=e}static parse(t){try{const e=new Ml(t),{featureToLookups:a,lookupListOffset:n}=dO(e),r=cO(e,n,xO);return new wO(r,a)}catch{return null}}hasAnyFeature(t){return t.some(t=>this.featureToLookups.has(t))}position(t,e,a){const n=hO(this.featureToLookups,a);for(const r of n){const a=this.lookups[r];if(!a)continue;let n=0;for(;n<t.length;){let r=null;for(const o of a.subtables)if(r=o.apply(t,e,n),null!==r)break;n+=r&&r>0?r:1}}}}const SO=new Set(["kern"]);class AO{constructor(t){a(this,"gsub"),a(this,"gpos"),this.font=t;const e=t.getRawTableData("GSUB");this.gsub=e?bO.parse(e):null;const n=t.getRawTableData("GPOS");this.gpos=n?wO.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(t,e){const a=[];for(const d of t){const t=d.codePointAt(0)??65533,e=this.font.glyphForCodePoint(t);a.push({id:e,codePoints:0===e?[65533]:[t]})}const n=(null==e?void 0:e.filter(t=>!SO.has(t)))??[],r=(null==e?void 0:e.filter(t=>SO.has(t)))??[];this.gsub&&n.length>0&&this.gsub.shape(a,n);const o=a.map(t=>this.font.advanceWidthForGlyph(t.id));this.gpos&&r.length>0&&this.gpos.position(a.map(t=>t.id),o,r);const i=[],l=[];let s=0;for(let d=0;d<a.length;d+=1){const t=a[d],e=this.font.advanceWidthForGlyph(t.id),n=o[d];i.push({id:t.id,codePoints:t.codePoints,advanceWidth:e}),l.push({xAdvance:n}),s+=n}return{glyphs:i,positions:l,advanceWidth:s}}}class CO{constructor(t){this.font=t}layout(t){const e=[],a=[];let n=0;for(const r of t){const t=r.codePointAt(0)??65533,o=this.font.glyphForCodePoint(t),i=this.font.advanceWidthForGlyph(o);e.push({id:o,codePoints:0===o?[65533]:[t],advanceWidth:i}),a.push({xAdvance:i}),n+=i}return{glyphs:e,positions:a,advanceWidth:n}}}function IO(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function TO(t,e){return IO(t).getUint16(e)}function kO(t,e,a){IO(t).setUint16(e,a,!1)}function VO(t,e,a){IO(t).setUint32(e,a,!1)}function RO(t){return t+3&-4}function EO(t){const e=t.reduce((t,e)=>t+RO(e.byteLength),0),a=new Uint8Array(e);let n=0;for(const r of t)a.set(r,n),n+=RO(r.byteLength);return a}function LO(t,e){const a=[],n=IO(t);if(0===e)for(let r=0;r+1<t.byteLength;r+=2)a.push(2*n.getUint16(r));else for(let r=0;r+3<t.byteLength;r+=4)a.push(n.getUint32(r));return a}function zO(t,e){const a=t[e],n=t[e+1];return void 0===a||void 0===n?null:{start:a,end:n}}function NO(t,e){if(t.byteLength<10||function(t,e){return IO(t).getInt16(e)}(t,0)>=0)return;let a=10,n=0;do{if(a+4>t.byteLength)return;n=TO(t,a),e(TO(t,a+2)),a+=4,a+=1&n?4:2,8&n?a+=2:64&n?a+=4:128&n&&(a+=8)}while(32&n)}function OO(t){const e=new Uint8Array(4*t.length);return t.forEach((t,a)=>VO(e,4*a,t)),e}function qO(t,e){const a=new Uint8Array(4*(e+1));for(let n=0;n<=e;n+=1)kO(a,4*n,t.advanceWidthForGlyph(n)),kO(a,4*n+2,0);return a}class PO{createSubset(t,e){const a=new Map,n=[];for(const c of e)n.push(c.id),a.has(c.id)||a.set(c.id,c.codePoints);const r=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head");if(!a||!n||!r)return Array.from(new Set([0,...e])).sort((t,e)=>t-e);const o=LO(n,TO(r,50)),i=new Set([0,...e]),l=Array.from(i);for(;l.length>0;){const t=zO(o,l.pop());!t||t.end<=t.start||t.end>a.byteLength||NO(a.slice(t.start,t.end),t=>{i.has(t)||(i.add(t),l.push(t))})}return Array.from(i).sort((t,e)=>t-e)}(t,n),o=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head"),o=t.getRawTableData("hhea"),i=t.getRawTableData("maxp"),l=t.getRawTableData("cmap");if(!(a&&n&&r&&o&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...e),d=new Set(e),c=LO(n,TO(r,50)),h=[],p=[];let u=0;for(let b=0;b<=s;b+=1){h.push(u);const t=zO(c,b);if(d.has(b)&&t&&t.end>t.start){const e=a.slice(t.start,t.end);p.push(e),u+=RO(e.byteLength)}}h.push(u);const f=r.slice();VO(f,8,0),kO(f,50,1);const g=o.slice();kO(g,34,s+1);const m=i.slice();kO(m,4,s+1);const v={cmap:l,head:f,hhea:g,hmtx:qO(t,s),loca:OO(h),maxp:m,glyf:EO(p)};for(const b of["OS/2","name","post"]){const e=t.getRawTableData(b);e&&(v[b]=e)}return v}(t,r),i=Ni(65536,new Map(Object.entries(o).map(([t,e])=>[t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3),e]))).ttf,l=Math.max(0,...r),s=[],d=[];for(let c=0;c<=l;c+=1)s[c]=t.advanceWidthForGlyph(c)/t.unitsPerEm*1e3,d[c]=a.get(c)??[0];return{fontFile:i,widths:s,unicode:d,encodeGlyph:t=>t}}}class WO{constructor(t){a(this,"fontResources",new Map),a(this,"unicodeFontStates",new Map),a(this,"usedFontResourceNames",new Set);for(const e of t)this.registerFontResource(e)}registerFontResource(t){if(this.fontResources.set(t.resourceName,t),"unicode"===t.kind&&!this.unicodeFontStates.has(t.resourceName)){const e=function(t){const e=new AO(t);return{program:t,layouter:e.hasShaping?e:new CO(t),subsetter:new PO}}(function(t){const e=al.decodeSync(t);return Il.parse(e)}(t.fontData)),a=1e3/e.program.unitsPerEm,n={id:0,codePoints:[0],advanceWidth:e.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(t.resourceName,{resource:t,font:e,usedGlyphs:new Map([[0,n]]),scale:a,layoutCache:new Map})}}resolveAndMarkFontName(t){const e=function(t){return t.fontResourceName?t.fontResourceName:t.bold&&t.italic?"F4":t.bold?"F2":t.italic?"F3":"F1"}(t);return this.usedFontResourceNames.add(e),e}getUnicodeState(t){return this.unicodeFontStates.get(t)}buildUnicodeShowCommand(t,e,a){const n=this.layoutUnicodeText(t,e,a),r=this.encodeUnicodeGlyphRun(t,n);if(0===r.length)return null;return r.some(t=>Math.abs(t.nominalWidth-t.desiredAdvance)>.01)?`[${r.map(t=>{const e=t.nominalWidth-t.desiredAdvance;return 0===e?`<${aO(t.glyphId)}>`:`<${aO(t.glyphId)}> ${ZN(e)}`}).join(" ")}] TJ`:`<${r.map(t=>aO(t.glyphId)).join("")}> Tj`}buildFontObjects(t){const e=Array.from(this.fontResources.values()).filter(t=>"base14"===t.kind||this.usedFontResourceNames.has(t.resourceName)),a=e.map(e=>{if("unicode"===e.kind){const a=this.unicodeFontStates.get(e.resourceName);if(a)return this.addUnicodeFontObjects(a,t)}return t(function(t){switch(t.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${t.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(e))});return{resourceXml:e.map((t,e)=>`/${t.resourceName} ${a[e]} 0 R`).join(" ")}}layoutUnicodeText(t,e,a){const n=`${(null==a?void 0:a.join(","))??""}\0${e}`,r=t.layoutCache.get(n);if(r)return r;const o=t.font.layouter.layout(e,a);return t.layoutCache.set(n,o),o}encodeUnicodeGlyphRun(t,e){return e.glyphs.map((a,n)=>{t.usedGlyphs.has(a.id)||t.usedGlyphs.set(a.id,a);const r=e.positions[n],o=a.advanceWidth*t.scale,i=((null==r?void 0:r.xAdvance)??a.advanceWidth)*t.scale;return{glyphId:a.id,nominalWidth:o,desiredAdvance:i}})}addUnicodeFontObjects(t,e){const a=t.font.subsetter.createSubset(t.font.program,t.usedGlyphs.values()),n=e(function(t,e=""){const a=`${XN(t)}>`,n=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${KN(a)} /Filter /ASCIIHexDecode${n} >>\nstream\n${a}\nendstream`}(a.fontFile)),r=t.font.program.metadata,o=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),o>=1&&o<=7&&(i|=2),10===o&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${_N(`${t.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${_N(r.postscriptName,t.resource.family)}`,s=r.bbox,d=e(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*t.scale,s.minY*t.scale,s.maxX*t.scale,s.maxY*t.scale].map(ZN).join(" ")}]`,`/ItalicAngle ${ZN(r.italicAngle)}`,`/Ascent ${ZN(r.ascent*t.scale)}`,`/Descent ${ZN(r.descent*t.scale)}`,`/CapHeight ${ZN(r.capHeight*t.scale)}`,`/XHeight ${ZN(r.xHeight*t.scale)}`,"/StemV 0",`/FontFile2 ${n} 0 R`,">>"].join("\n")),c=e(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [0 [${a.widths.map(t=>ZN(t??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),h=e(function(t,e=""){const a=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${KN(t)}${a} >>\nstream\n${t}endstream`}(function(t){const e=t.map(t=>`<${eO(t)}>`).filter(t=>"<>"!==t);0===e.length&&e.push("<0000>");const a=[];for(let n=0;n<e.length;n+=256){const t=Math.min(n+256,e.length);a.push(`<${YN(n)}> <${YN(t-1)}> [${e.slice(n,t).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",`${a.length} beginbfrange`,a.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(a.unicode)));return e(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${c} 0 R]`,`/ToUnicode ${h} 0 R`,">>"].join("\n"))}}class BO{constructor(){a(this,"imageResources",new Map)}registerImageResource(t){const e=t.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(e)||this.imageResources.set(e,{resourceName:e,width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height)),data:t.data,filter:t.filter}),e}has(t){return this.imageResources.has(t)}buildImageObjects(t){const e=new Map;for(const a of this.imageResources.values())e.set(a.resourceName,this.addImageObject(a,t));return e}addImageObject(t,e){return e(function(t,e){const a=`${XN(t)}>`;return[`<< /Length ${KN(a)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${e.join(" ")}`," >>","stream",a,"endstream"].join("\n")}(t.data,["/Type /XObject","/Subtype /Image",`/Width ${t.width}`,`/Height ${t.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}}class FO{constructor(){a(this,"shadings",[])}register(t){const e=`Sh${this.shadings.length+1}`;return this.shadings.push({name:e,spec:t}),e}buildShadingObjects(t){const e=new Map;for(const{name:a,spec:n}of this.shadings)e.set(a,this.addShadingObject(n,t));return e}addShadingObject(t,e){const a=e(function(t){if(2===t.length)return HO(t[0].rgb,t[1].rgb);const e=[];for(let r=0;r<t.length-1;r+=1)e.push(HO(t[r].rgb,t[r+1].rgb));const a=t.slice(1,-1).map(t=>ZN(t.offset)),n=t.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${e.join(" ")}]`,`/Bounds [${a.join(" ")}]`,`/Encode [${n}]`,">>"].join("\n")}(function(t){const e=t.map(t=>({offset:Math.min(1,Math.max(0,t.offset)),rgb:JN(t.color,[0,0,0])})).sort((t,e)=>t.offset-e.offset);if(0===e.length)return[{offset:0,rgb:[0,0,0]},{offset:1,rgb:[0,0,0]}];if(1===e.length)return[{offset:0,rgb:e[0].rgb},{offset:1,rgb:e[0].rgb}];e[0].offset=0,e[e.length-1].offset=1;for(let a=1;a<e.length-1;a+=1){const t=e[a-1].offset+1e-4;e[a].offset<=t&&(e[a].offset=Math.min(.9999,t))}return e}(t.stops)));return e(["<< /ShadingType 2","/ColorSpace /DeviceRGB",`/Coords [${[t.x0,t.y0,t.x1,t.y1].map(ZN).join(" ")}]`,"/Domain [0 1]",`/Function ${a} 0 R`,"/Extend [true true]",">>"].join("\n"))}}function HO(t,e){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${t.map(ZN).join(" ")}]`,`/C1 [${e.map(ZN).join(" ")}]`,"/N 1",">>"].join("\n")}var UO=Uint8Array,GO=Uint16Array,DO=Int32Array,jO=new UO([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ZO=new UO([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),KO=new UO([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),XO=function(t,e){for(var a=new GO(31),n=0;n<31;++n)a[n]=e+=1<<t[n-1];var r=new DO(a[30]);for(n=1;n<30;++n)for(var o=a[n];o<a[n+1];++o)r[o]=o-a[n]<<5|n;return{b:a,r:r}},YO=XO(jO,2),JO=YO.b,QO=YO.r;JO[28]=258,QO[258]=28;for(var _O=XO(ZO,0).r,$O=new GO(32768),tq=0;tq<32768;++tq){var eq=(43690&tq)>>1|(21845&tq)<<1;eq=(61680&(eq=(52428&eq)>>2|(13107&eq)<<2))>>4|(3855&eq)<<4,$O[tq]=((65280&eq)>>8|(255&eq)<<8)>>1}var aq=function(t,e,a){for(var n=t.length,r=0,o=new GO(e);r<n;++r)t[r]&&++o[t[r]-1];var i,l=new GO(e);for(r=1;r<e;++r)l[r]=l[r-1]+o[r-1]<<1;if(a){i=new GO(1<<e);var s=15-e;for(r=0;r<n;++r)if(t[r])for(var d=r<<4|t[r],c=e-t[r],h=l[t[r]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)i[$O[h]>>s]=d}else for(i=new GO(n),r=0;r<n;++r)t[r]&&(i[r]=$O[l[t[r]-1]++]>>15-t[r]);return i},nq=new UO(288);for(tq=0;tq<144;++tq)nq[tq]=8;for(tq=144;tq<256;++tq)nq[tq]=9;for(tq=256;tq<280;++tq)nq[tq]=7;for(tq=280;tq<288;++tq)nq[tq]=8;var rq=new UO(32);for(tq=0;tq<32;++tq)rq[tq]=5;var oq=aq(nq,9,0),iq=aq(rq,5,0),lq=function(t){return(t+7)/8|0},sq=function(t,e,a){a<<=7&e;var n=e/8|0;t[n]|=a,t[n+1]|=a>>8},dq=function(t,e,a){a<<=7&e;var n=e/8|0;t[n]|=a,t[n+1]|=a>>8,t[n+2]|=a>>16},cq=function(t,e){for(var a=[],n=0;n<t.length;++n)t[n]&&a.push({s:n,f:t[n]});var r=a.length,o=a.slice();if(!r)return{t:vq,l:0};if(1==r){var i=new UO(a[0].s+1);return i[a[0].s]=1,{t:i,l:1}}a.sort(function(t,e){return t.f-e.f}),a.push({s:-1,f:25001});var l=a[0],s=a[1],d=0,c=1,h=2;for(a[0]={s:-1,f:l.f+s.f,l:l,r:s};c!=r-1;)l=a[a[d].f<a[h].f?d++:h++],s=a[d!=c&&a[d].f<a[h].f?d++:h++],a[c++]={s:-1,f:l.f+s.f,l:l,r:s};var p=o[0].s;for(n=1;n<r;++n)o[n].s>p&&(p=o[n].s);var u=new GO(p+1),f=hq(a[c-1],u,0);if(f>e){n=0;var g=0,m=f-e,v=1<<m;for(o.sort(function(t,e){return u[e.s]-u[t.s]||t.f-e.f});n<r;++n){var b=o[n].s;if(!(u[b]>e))break;g+=v-(1<<f-u[b]),u[b]=e}for(g>>=m;g>0;){var y=o[n].s;u[y]<e?g-=1<<e-u[y]++-1:++n}for(;n>=0&&g;--n){var M=o[n].s;u[M]==e&&(--u[M],++g)}f=e}return{t:new UO(u),l:f}},hq=function(t,e,a){return-1==t.s?Math.max(hq(t.l,e,a+1),hq(t.r,e,a+1)):e[t.s]=a},pq=function(t){for(var e=t.length;e&&!t[--e];);for(var a=new GO(++e),n=0,r=t[0],o=1,i=function(t){a[n++]=t},l=1;l<=e;++l)if(t[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(r),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(r);o=1,r=t[l]}return{c:a.subarray(0,n),n:e}},uq=function(t,e){for(var a=0,n=0;n<e.length;++n)a+=t[n]*e[n];return a},fq=function(t,e,a){var n=a.length,r=lq(e+2);t[r]=255&n,t[r+1]=n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<n;++o)t[r+o+4]=a[o];return 8*(r+4+n)},gq=function(t,e,a,n,r,o,i,l,s,d,c){sq(e,c++,a),++r[256];for(var h=cq(r,15),p=h.t,u=h.l,f=cq(o,15),g=f.t,m=f.l,v=pq(p),b=v.c,y=v.n,M=pq(g),x=M.c,w=M.n,S=new GO(19),A=0;A<b.length;++A)++S[31&b[A]];for(A=0;A<x.length;++A)++S[31&x[A]];for(var C=cq(S,7),I=C.t,T=C.l,k=19;k>4&&!I[KO[k-1]];--k);var V,R,E,L,z=d+5<<3,N=uq(r,nq)+uq(o,rq)+i,O=uq(r,p)+uq(o,g)+i+14+3*k+uq(S,I)+2*S[16]+3*S[17]+7*S[18];if(s>=0&&z<=N&&z<=O)return fq(e,c,t.subarray(s,s+d));if(sq(e,c,1+(O<N)),c+=2,O<N){V=aq(p,u,0),R=p,E=aq(g,m,0),L=g;var q=aq(I,T,0);sq(e,c,y-257),sq(e,c+5,w-1),sq(e,c+10,k-4),c+=14;for(A=0;A<k;++A)sq(e,c+3*A,I[KO[A]]);c+=3*k;for(var P=[b,x],W=0;W<2;++W){var B=P[W];for(A=0;A<B.length;++A){var F=31&B[A];sq(e,c,q[F]),c+=I[F],F>15&&(sq(e,c,B[A]>>5&127),c+=B[A]>>12)}}}else V=oq,R=nq,E=iq,L=rq;for(A=0;A<l;++A){var H=n[A];if(H>255){dq(e,c,V[(F=H>>18&31)+257]),c+=R[F+257],F>7&&(sq(e,c,H>>23&31),c+=jO[F]);var U=31&H;dq(e,c,E[U]),c+=L[U],U>3&&(dq(e,c,H>>5&8191),c+=ZO[U])}else dq(e,c,V[H]),c+=R[H]}return dq(e,c,V[256]),c+R[256]},mq=new DO([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vq=new UO(0),bq=function(t,e,a,n,r,o){var i=o.z||t.length,l=new UO(n+i+5*(1+Math.ceil(i/7e3))+r),s=l.subarray(n,l.length-r),d=o.l,c=7&(o.r||0);if(e){c&&(s[0]=o.r>>3);for(var h=mq[e-1],p=h>>13,u=8191&h,f=(1<<a)-1,g=o.p||new GO(32768),m=o.h||new GO(f+1),v=Math.ceil(a/3),b=2*v,y=function(e){return(t[e]^t[e+1]<<v^t[e+2]<<b)&f},M=new DO(25e3),x=new GO(288),w=new GO(32),S=0,A=0,C=o.i||0,I=0,T=o.w||0,k=0;C+2<i;++C){var V=y(C),R=32767&C,E=m[V];if(g[R]=E,m[V]=R,T<=C){var L=i-C;if((S>7e3||I>24576)&&(L>423||!d)){c=gq(t,s,0,M,x,w,A,I,k,C-k,c),I=S=A=0,k=C;for(var z=0;z<286;++z)x[z]=0;for(z=0;z<30;++z)w[z]=0}var N=2,O=0,q=u,P=R-E&32767;if(L>2&&V==y(C-P))for(var W=Math.min(p,L)-1,B=Math.min(32767,C),F=Math.min(258,L);P<=B&&--q&&R!=E;){if(t[C+N]==t[C+N-P]){for(var H=0;H<F&&t[C+H]==t[C+H-P];++H);if(H>N){if(N=H,O=P,H>W)break;var U=Math.min(P,H-2),G=0;for(z=0;z<U;++z){var D=C-P+z&32767,j=D-g[D]&32767;j>G&&(G=j,E=D)}}}P+=(R=E)-(E=g[R])&32767}if(O){M[I++]=268435456|QO[N]<<18|_O[O];var Z=31&QO[N],K=31&_O[O];A+=jO[Z]+ZO[K],++x[257+Z],++w[K],T=C+N,++S}else M[I++]=t[C],++x[t[C]]}}for(C=Math.max(C,T);C<i;++C)M[I++]=t[C],++x[t[C]];c=gq(t,s,d,M,x,w,A,I,k,C-k,c),d||(o.r=7&c|s[c/8|0]<<3,c-=7,o.h=m,o.p=g,o.i=C,o.w=T)}else{for(C=o.w||0;C<i+d;C+=65535){var X=C+65535;X>=i&&(s[c/8|0]=d,X=i),c=fq(s,c+1,t.subarray(C,X))}o.i=i}return function(t,e,a){return(null==a||a>t.length)&&(a=t.length),new UO(t.subarray(e,a))}(l,0,n+lq(c)+r)},yq=function(){var t=1,e=0;return{p:function(a){for(var n=t,r=e,o=0|a.length,i=0;i!=o;){for(var l=Math.min(i+2655,o);i<l;++i)r+=n+=a[i];n=(65535&n)+15*(n>>16),r=(65535&r)+15*(r>>16)}t=n,e=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(e%=65521))<<8|e>>8}}},Mq=function(t,e,a){for(;a;++e)t[e]=a,a>>>=8};function xq(t,e){e||(e={});var a=yq();a.p(t);var n=function(t,e,a,n,r){if(!r&&(r={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),i=new UO(o.length+t.length);i.set(o),i.set(t,o.length),t=i,r.w=o.length}return bq(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,a,n,r)}(t,e,e.dictionary?6:2,4);return function(t,e){var a=e.level,n=0==a?0:a<6?1:9==a?3:2;if(t[0]=120,t[1]=n<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var r=yq();r.p(e.dictionary),Mq(t,2,r.d())}}(n,e),Mq(n,n.length-4,a.d()),n}var wq="undefined"!=typeof TextDecoder&&new TextDecoder;try{wq.decode(vq,{stream:!0})}catch(eB){}const Sq=new TextEncoder;function Aq(t){return"string"==typeof t?KN(t):t.length}function Cq(t){const e=t.reduce((t,e)=>t+Aq(e),0),a=new Uint8Array(e);let n=0;for(const r of t){const t="string"==typeof r?Sq.encode(r):r;a.set(t,n),n+=t.length}return a}function Iq(t){const e=xq(Sq.encode(t));return Cq([`<< /Length ${e.length} /Filter /FlateDecode >>\nstream\n`,e,"\nendstream"])}function Tq(t){return t.replace(/[\\()]/g,t=>`\\${t}`)}function kq(t){return`<FEFF${eO(Array.from(t).map(t=>t.codePointAt(0)??63))}>`}function Vq(t){const e=[];if(t.title&&e.push(`/Title ${kq(t.title)}`),t.author&&e.push(`/Author ${kq(t.author)}`),t.subject&&e.push(`/Subject ${kq(t.subject)}`),t.keywords&&e.push(`/Keywords ${kq(t.keywords)}`),t.producer&&e.push(`/Producer (${Tq(t.producer)})`),t.creationDate&&e.push(`/CreationDate (${function(t){const e=(t,e=2)=>String(t).padStart(e,"0");return`D:${t.getUTCFullYear()}${e(t.getUTCMonth()+1)}${e(t.getUTCDate())}${e(t.getUTCHours())}${e(t.getUTCMinutes())}${e(t.getUTCSeconds())}+00'00'`}(t.creationDate)})`),0!==e.length)return`<< ${e.join(" ")} >>`}function Rq(t){return t.children.reduce((t,e)=>t+1+Rq(e),0)}function Eq(t,e,a,n,r=[],o=[],i){const l=[],s=t=>{const e=l.length+1;return l.push({id:e,body:t}),e},d=s(""),c=s(""),{resourceXml:h}=e.buildFontObjects(s),p=a.buildImageObjects(s),u=n.buildShadingObjects(s),f=[];for(const k of t){const t=`${k.commands.join("\n")}\n`,e=s(Iq(t)),a=Array.from(k.imageResourceNames).map(t=>{const e=p.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),n=a?` /XObject << ${a} >>`:"",r=Array.from(k.shadingResourceNames).map(t=>{const e=u.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),o=r?` /Shading << ${r} >>`:"",i=k.annotations.map(t=>{const e=t.x,a=t.x+t.width,n=k.height-t.y-t.height,r=k.height-t.y,o=void 0!==t.destName?`/A << /Type /Action /S /GoTo /D (${Tq(t.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Tq(t.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${ZN(e)} ${ZN(n)} ${ZN(a)} ${ZN(r)}]`,"/Border [0 0 0]",o,">>"].join("\n"))}),l=i.length>0?`\n/Annots [${i.map(t=>`${t} 0 R`).join(" ")}]`:"",d=s(["<< /Type /Page",`/Parent ${c} 0 R`,`/MediaBox [0 0 ${ZN(k.width)} ${ZN(k.height)}]`,`/Resources << /Font << ${h} >>${n}${o} >>`,`/Contents ${e} 0 R${l}`,">>"].join("\n"));f.push(d)}let g;const m=r.filter(t=>void 0!==f[t.pageIndex]).sort((t,e)=>t.name<e.name?-1:t.name>e.name?1:0);if(m.length>0){const e=m.map(e=>{const a=f[e.pageIndex],n=t[e.pageIndex].height-e.y;return`(${Tq(e.name)}) [${a} 0 R /XYZ ${ZN(e.x)} ${ZN(n)} null]`}).join(" "),a=s(`<< /Names [${e}] >>`);g=s(`<< /Dests ${a} 0 R >>`)}let v;const b=new Set(m.map(t=>t.name)),y=function(t){const e=[],a=[];for(const n of t){const t={title:n.title,destName:n.destName,children:[]};for(;a.length>0&&a[a.length-1].level>=n.level;)a.pop();0===a.length?e.push(t):a[a.length-1].node.children.push(t),a.push({node:t,level:n.level})}return e}(o.filter(t=>b.has(t.destName)));if(y.length>0){v=s("");const t=e=>e.map(e=>{const a=s("");return e.id=a,e.childIds=t(e.children),a}),e=t(y),a=(t,e)=>{t.forEach((n,r)=>{const o=n,i=r>0?t[r-1]:void 0,s=r<t.length-1?t[r+1]:void 0,d=["<< /Title "+kq(n.title),`/Parent ${e} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${Tq(n.destName)})`];o.childIds.length>0&&(d.push(`/First ${o.childIds[0]} 0 R`),d.push(`/Last ${o.childIds[o.childIds.length-1]} 0 R`),d.push(`/Count ${Rq(n)}`)),d.push(">>"),l[o.id-1].body=d.filter(Boolean).join("\n"),a(n.children,o.id)})};a(y,v);const n=o.filter(t=>b.has(t.destName)).length;l[v-1].body=["<< /Type /Outlines",`/First ${e[0]} 0 R`,`/Last ${e[e.length-1]} 0 R`,`/Count ${n}`,">>"].join("\n")}let M;if(l[d-1].body=["<< /Type /Catalog",`/Pages ${c} 0 R`,void 0!==g?`/Names ${g} 0 R`:"",void 0!==v?`/Outlines ${v} 0 R`:"",void 0!==v?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[c-1].body=["<< /Type /Pages",`/Kids [${f.map(t=>`${t} 0 R`).join(" ")}]`,`/Count ${f.length}`,">>"].join("\n"),i){const t=Vq(i);t&&(M=s(t))}const x=[DN];let w=Aq(DN);const S=[0],A=t=>{x.push(t),w+=Aq(t)};for(const k of l)S[k.id]=w,A(`${k.id} 0 obj\n`),A(k.body),A("\nendobj\n");const C=w;let I=`xref\n0 ${l.length+1}\n`;I+="0000000000 65535 f \n";for(const k of l)I+=`${String(S[k.id]??0).padStart(10,"0")} 00000 n \n`;A(I);const T=void 0!==M?` /Info ${M} 0 R`:"";return A(["trailer",`<< /Size ${l.length+1} /Root ${d} 0 R${T} >>`,"startxref",String(C),"%%EOF",""].join("\n")),Cq(x)}class Lq{constructor(t=jN){a(this,"pages",[]),a(this,"streams",[]),a(this,"fonts"),a(this,"images",new BO),a(this,"shadings",new FO),a(this,"namedDestinations",[]),a(this,"outlineItems",[]),a(this,"documentInfo"),this.fonts=new WO(t)}registerFontResource(t){this.fonts.registerFontResource(t)}addPage(t){const e={width:Math.max(1,t.width),height:Math.max(1,t.height),commands:[],imageResourceNames:new Set,shadingResourceNames:new Set,annotations:[]};return this.pages.push(e),this.streams.push(new rO(e,this.fonts,this.images,this.shadings)),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(t,e){var a;null==(a=this.streams[t])||a.drawRect(e)}drawLine(t,e){var a;null==(a=this.streams[t])||a.drawLine(e)}drawPath(t,e){var a;null==(a=this.streams[t])||a.drawPath(e)}saveGraphicsState(t){var e;null==(e=this.streams[t])||e.saveGraphicsState()}restoreGraphicsState(t){var e;null==(e=this.streams[t])||e.restoreGraphicsState()}rotateAbout(t,e,a,n){var r;null==(r=this.streams[t])||r.rotateAbout(e,a,n)}clipRect(t,e,a,n,r){var o;null==(o=this.streams[t])||o.clipRect(e,a,n,r)}drawText(t,e){var a;null==(a=this.streams[t])||a.drawText(e)}registerAxialGradient(t,e){var a;return(null==(a=this.streams[t])?void 0:a.registerAxialGradient(e))??null}registerImageResource(t){return this.images.registerImageResource(t)}drawImage(t,e){var a;null==(a=this.streams[t])||a.drawImage(e)}addLinkAnnotation(t,e){var a;null==(a=this.pages[t])||a.annotations.push(e)}addNamedDestination(t){this.namedDestinations.some(e=>e.name===t.name)||this.namedDestinations.push(t)}addOutlineItem(t){this.outlineItems.push(t)}setDocumentInfo(t){this.documentInfo=t}toArrayBuffer(){const t=this.toUint8Array();return Uint8Array.from(t).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){return 0===this.pages.length&&this.addPage({width:612,height:792}),Eq(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}}function zq(t,e,a,n,r){if(0!==n.size||0!==r.size)return(o,i)=>{const l=Zw(i),s=Zw(a);for(const a of n.get(o)??[])t.addNamedDestination({name:a,pageIndex:e,x:s,y:l});const d=r.get(o);if(d){const a=`__oasis_heading_${o}`;t.addNamedDestination({name:a,pageIndex:e,x:s,y:l}),t.addOutlineItem({title:d.title,level:d.level,destName:a})}}}async function Nq(t){t=hN(t);const e=new GN;await e.loadBundledUnicodeFaces({families:td(t)});const a=new Lq(e.getPdfFontResources());a.setDocumentInfo(function(t){const e=t.metadata??{},a=t=>"string"==typeof t&&""!==t.trim()?t:void 0;return{title:a(e.title),author:a(e.author),subject:a(e.subject),keywords:a(e.keywords),producer:"Oasis Editor",creationDate:new Date}}(t));const n=nh(t),r=function(t){return Va(t)}(t),o=function(t){var e;const a=new Map,n=t.bookmarks;if(!n)return a;for(const r of n.order){const t=n.items[r],o=null==(e=null==t?void 0:t.start)?void 0:e.paragraphId;if(!t||!o)continue;const i=a.get(o)??[];i.push(t.name),a.set(o,i)}return a}(t),i=new Map(Nn(t).map(t=>[t.id,{level:t.level,title:t.text}]));for(const l of n.pages){const n=Math.max(1,Zw(l.pageSettings.width)),s=Math.max(1,Zw(l.pageSettings.height)),d=a.addPage({width:n,height:s});BN(a,d,n,s);const c=l.pageSettings.margins.left+l.pageSettings.margins.gutter,h=De(l.pageSettings);await WN(a,d,l.headerBlocks,t,c,l.headerTop??Ke(l.pageSettings),h,e,r,l.pageSettings);const p=l.bodyTop??Xe(l.pageSettings);if(l.blocks.some(t=>void 0!==t.columnIndex)){const n=je(l.pageSettings),s=new Map;for(const t of l.blocks){const e=t.columnIndex??0,a=s.get(e)??[];a.push(t),s.set(e,a)}for(const[c,h]of s){const s=n[c]??n[0];await WN(a,d,h,t,s.left,p,s.width,e,r,l.pageSettings,zq(a,d,s.left,o,i))}}else await WN(a,d,l.blocks,t,c,p,h,e,r,l.pageSettings,zq(a,d,c,o,i));await WN(a,d,l.footerBlocks,t,c,l.footerTop??l.bodyBottom??l.pageSettings.height,h,e,r,l.pageSettings),l.footnoteBlocks&&l.footnoteBlocks.length>0&&void 0!==l.footnoteTop&&(void 0!==l.footnoteSeparatorTop&&a.drawLine(d,{x1:Zw(c),y1:Zw(l.footnoteSeparatorTop+.5),x2:Zw(c+Math.min(180,.35*h)),y2:Zw(l.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:Zw(1)}),await Oq(a,d,l.footnoteBlocks,l.footnoteReferenceIds??[],t,c,l.footnoteTop,h,e,r))}if(0===a.getPageCount()){const t=a.addPage({width:612,height:792});BN(a,t,612,792)}return a.toArrayBuffer()}async function Oq(t,e,a,n,r,o,i,l,s,d){var c;let h=i;const p=new Set,u=new Map(n.map(t=>{var e;return[t,(null==(e=Kc(r,t))?void 0:e.run.text)??""]}));for(const f of a){const a=n.find(t=>f.blockId.startsWith(`${t}:`));if(a&&!p.has(a)){const n=u.get(a);if(n){const a="paragraph"===f.sourceBlock.type?f.sourceBlock:void 0,i=la(void 0,null==(c=null==a?void 0:a.style)?void 0:c.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});t.drawText(e,{x:Zw(o),y:Zw(h+12),text:n,fontSize:Kw(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}p.add(a)}await WN(t,e,[f],r,o+ed,h,Math.max(24,l-ed),s,d),h+=Math.max(0,f.estimatedHeight)+2}}function qq(t,e){const a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e,n.click(),URL.revokeObjectURL(a)}function Pq(t){const e=t.download??qq;return{handleExportDocx:async()=>{const a=await async function(t){const e=await fN(t);return new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}(t.document());e(a,"oasis-editor.docx"),t.focusInput()},handleExportPdf:async()=>{const a=await async function(t){const e=await Nq(t);return new Blob([e],{type:"application/pdf"})}(t.document());e(a,"oasis-editor.pdf"),t.focusInput()}}}async function Wq(t){return"function"==typeof t.arrayBuffer?t.arrayBuffer():new Promise((e,a)=>{const n=new FileReader;n.onerror=()=>a(n.error??new Error("Failed to read file.")),n.onload=()=>{const t=n.result;t instanceof ArrayBuffer?e(t):a(new Error("Failed to read file as ArrayBuffer."))},n.readAsArrayBuffer(t)})}function Bq(t){if(!t)return null;for(const e of Array.from(t.items??[])){if("file"!==e.kind)continue;const t=e.getAsFile();if(t&&t.type.startsWith("image/"))return t}for(const e of Array.from(t.files??[]))if(e.type.startsWith("image/"))return e;return null}function Fq(t){return{handleImportFile:async e=>{if(!e)return;const a=function(t){return jM.find(e=>e.matches(t))}(e);if(!a)return t.setImportPhase("error"),t.logger.error("import:unsupported-format",{name:e.name,type:e.type}),void t.clearImportProgressSoon();const n=t.now();t.logger.info("import:start",{format:a.id,name:e.name,size:e.size}),t.setImportPhase("reading-file");try{const r=t.now(),o=await Wq(e);t.logger.info("import:phase",{phase:"reading-file",durationMs:Fl(t.now()-r,2)});let i=null,l=-1,s=0;const d=await a.import(o,(e,a)=>{const n=t.now(),r=void 0!==a&&Number.isFinite(a)?Math.floor(100*a):void 0,o=e!==i;if(!o&&!(void 0!==r&&(l<0||r-l>=1))&&!(n-s>=40))return;i=e,l=r??l,s=n,t.setImportPhase(e,a);const d={phase:e,subProgress:a};o||void 0===a||1===a?t.logger.info("import:phase",d):t.logger.debug("import:phase",d)});t.logger.debug("import:document-diagnostics",function(t){var e;const a=ba(t),n=new Map,r=new Map;let o=0,i=0;for(const l of a){const a=sa(l.style,t.styles);r.set(a.align,(r.get(a.align)??0)+1);for(const r of l.runs){const a=la(r.styles,null==(e=l.style)?void 0:e.styleId,t.styles),s=a.fontFamily??"<null>";n.set(s,(n.get(s)??0)+1),null!==a.characterSpacing&&(o+=1),null!==a.characterScale&&(i+=1)}}return{paragraphCount:a.length,alignCounts:Array.from(r.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:o,characterScaleRuns:i,firstParagraphs:a.slice(0,30).map((e,a)=>{var n;const r=sa(e.style,t.styles),o=e.runs[0],i=la(null==o?void 0:o.styles,null==(n=e.style)?void 0:n.styleId,t.styles);return{index:a,textLength:Je(e).length,runCount:e.runs.length,rawParagraphStyle:e.style,align:r.align,indentFirstLine:r.indentFirstLine,lineGridPitch:r.lineGridPitch,lineGridType:r.lineGridType,fontFamily:i.fontFamily,fontSize:i.fontSize,characterSpacing:i.characterSpacing,characterScale:i.characterScale,firstRunStyle:null==o?void 0:o.styles}})}}(d)),t.setImportPhase("applying-editor-state"),t.resetEditorChromeState(),t.applyState(rn(d));const c=t.now();t.setImportPhase("stabilizing-layout"),await t.stabilizeLayoutAfterImport(),t.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Fl(t.now()-c,2)});const h=ca(d).reduce((t,e)=>{var a,n;return t+((null==(a=e.header)?void 0:a.length)??0)+e.blocks.length+((null==(n=e.footer)?void 0:n.length)??0)},0),p=va(d).length;t.setImportPhase("done"),t.logger.info("import:done",{format:a.id,blocks:h,paragraphs:p,durationMs:Fl(t.now()-n,2)}),t.focusInput()}catch(r){t.setImportPhase("error"),t.logger.error("import:error",r)}finally{t.clearImportProgressSoon()}}}}function Hq(t,e){const a=Da(t);if(a.isCollapsed||a.startIndex!==a.endIndex||a.endParagraphOffset-a.startParagraphOffset!==1)return null;const n=Na(t)[a.startIndex];if(!n)return null;let r=0;for(let o=0;o<n.runs.length;o+=1){const t=n.runs[o],i=r;if(r+=t.text.length,e(t)&&1===t.text.length&&i===a.startParagraphOffset)return{paragraph:n,paragraphIndex:a.startIndex,run:t,runIndex:o,offset:i}}return null}function Uq(t,e){if("inline"===e)return;const a={...t??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(e){case"square":case"tight":case"through":case"topAndBottom":return{...a,wrap:e,behindDoc:!1};case"behind":return{...a,wrap:"none",behindDoc:!0};case"front":return{...a,wrap:"none",behindDoc:!1}}}function Gq(t){return t?t.behindDoc?"behind":t.wrap&&"none"!==t.wrap?t.wrap:"front":"inline"}function Dq(t,e){return{...t,positionV:{...t.positionV??{},relativeFrom:e?"page":"paragraph"}}}function jq(t){var e;return"page"===(null==(e=null==t?void 0:t.positionV)?void 0:e.relativeFrom)}function Zq(t){return Hq(t,t=>"image"===t.kind)}function Kq(t,e){const a=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e);return Xq(t,t=>({...t,rotation:a}))}function Xq(t,e){const a=Zq(t);if(!a||!ye(a.run))return t;const n=Na(t),{paragraphIndex:r,run:o}=a,i=n.map((t,a)=>a!==r?MA(t):{...MA(t),runs:t.runs.map(t=>t.id===o.id&&"image"===t.kind?{...t,image:e(t.image)}:yA(t))});return rR(t,i,cR(i,Da(t)))}function Yq(t,e){return Xq(t,t=>{const a=e(t.floating);if(a)return{...t,floating:a};const{floating:n,...r}=t;return r})}function Jq(t){const e=Zq(t);if(!e||!ye(e.run))return null;return function(t){var e;if(!sN(t))return"";let a=!1,n="";for(const r of t.runs)a?n+=r.text:"end"===(null==(e=we(r))?void 0:e.kind)&&(a=!0);return n.replace(/^[:\-\s]+/,"")}(Na(t)[e.paragraphIndex+1])}function Qq(t,e,a){const n=Zq(t);if(!n||!ye(n.run))return t;const r=Na(t),o=n.paragraphIndex+1,i=o<r.length&&sN(r[o])?function(t,e,a){var n;const r=(null==(n=t.runs.find(t=>/^\d+$/.test(t.text)))?void 0:n.text)??"1",o=lN(e,a,Number.parseInt(r,10)||1);return o.id=t.id,o}(r[o],e,a):lN(e,a,1),l=function(t){let e=1;return t.map(t=>sN(t)?dN(t,e++):MA(t))}(o<r.length&&sN(r[o])?[...wA(r.slice(0,o)),i,...wA(r.slice(o+1))]:[...wA(r.slice(0,o)),i,...wA(r.slice(o))]),s=l[o]??i;return rR(t,l,iR(_e(s,Qe(s))))}function _q(t,e){const a=Zq(t);if(!a)return t;const n=Na(t),{paragraphIndex:r,offset:o,run:i}=a,l=Ba(n,e.paragraphId);if(l<0)return t;const s=$e(n[l],e),d=l===r&&s>o?s-1:s;if(l===r&&d===o)return t;const c=t=>jV(t,[..._V(t,0,o),..._V(t,o+1,Qe(t))]),h=(t,e)=>$V(t,Math.max(0,Math.min(e,Qe(t))),[Ya("",JV(t,e),ye(i))]),p=n.map((t,e)=>e===r&&e===l?h(c(t),d):e===r?c(t):e===l?h(t,d):wA([t])[0]),u=p[l];return rR(t,p,iR(_e(u,Math.max(0,Math.min(d+1,Qe(u))))))}function $q(t,e,a,n=0){const r=De(Ge(e));if(!a)return r;const o=Zd(e,a,n);return null!==o&&Number.isFinite(o)&&o>0?Math.min(r,o):r}function tP(t){return{insertImageFromFile:async(e,a)=>{t.logger.info(`image insert:start name="${e.name}" type=${e.type} size=${e.size}`);const n=await Wq(e),r=`data:${e.type};base64,${function(t){return btoa(new Uint8Array(t).reduce((t,e)=>t+String.fromCharCode(e),""))}(n)}`,o=new Image;o.src=r,await new Promise(t=>{o.onload=t,o.onerror=t});const i=o.naturalWidth||300,l=o.naturalHeight||300,s=t.state(),d=(null==a?void 0:a.paragraphId)??s.selection.focus.paragraphId,c=$q(t.surfaceRef(),s.document,d,s.activeSectionIndex??0),h=i>c?c/i:1,p=Math.max(24,Math.round(i*h)),u=Math.max(24,Math.round(l*h));t.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${u} maxWidth=${c}`),t.applyTransactionalState(t=>function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i=$V(n,o,[Ya("",JV(n,o),e)]);return rR(a,Na(a).map((t,e)=>e===r?i:MA(t)),iR(_e(i,o+1)))}(a?hE(t,{anchor:a,focus:a}):t,{src:r,width:p,height:u}),{mergeKey:uV})}}}const eP={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"applying-editor-state":[78,88],"stabilizing-layout":[88,98],done:[100,100],error:[100,100]};function aP(t,e){return t.paragraph.runs.map(t=>t.text).join("")[e]??""}function nP(t){return" "===t||"\t"===t||"\n"===t}function rP(t,e,a){if(a.isCollapsed)return null;const n=e.get(t);return void 0===n||n<a.startIndex||n>a.endIndex?null:a.startIndex===a.endIndex?{start:a.startParagraphOffset,end:a.endParagraphOffset}:t===a.start.paragraphId?{start:a.startParagraphOffset,end:Number.POSITIVE_INFINITY}:t===a.end.paragraphId?{start:0,end:a.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function oP(t,e){var a,n,r,o;const i=Da(e),l=[],s=t.surfaceRect,d=new Map(Na(e).map((t,e)=>[t.id,e]));let c=null,h=null;if(!i.isCollapsed&&i.startIndex===i.endIndex&&i.endParagraphOffset-i.startParagraphOffset===1){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.inlineImages.find(e)??t.floatingImages.find(e);if(a&&(c={paragraphId:a.paragraphId,startOffset:a.startOffset,endOffset:a.endOffset,left:a.left-s.left,top:a.top-s.top,width:a.width,height:a.height,rotation:a.rotation??0}),!c){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.floatingTextBoxes.find(e),n=a?void 0:t.inlineTextBoxes.find(e),r=a??n;r&&(h={paragraphId:r.paragraphId,startOffset:r.startOffset,endOffset:r.endOffset,left:r.left-s.left,top:r.top-s.top,width:r.width,height:r.height,rotation:r.rotation??0,floating:Boolean(a)})}}const p=Ea(e),u=xa(e.document,e.selection.anchor.paragraphId,p),f=xa(e.document,e.selection.focus.paragraphId,p);let g=!1;if(u&&f&&u.blockIndex===f.blockIndex&&u.zone===f.zone&&(u.rowIndex!==f.rowIndex||u.cellIndex!==f.cellIndex)){const o=ha(e.document)[p];let i;if(i="header"===u.zone?null==(a=null==o?void 0:o.header)?void 0:a[u.blockIndex]:"footer"===u.zone?null==(n=null==o?void 0:o.footer)?void 0:n[u.blockIndex]:null==(r=null==o?void 0:o.blocks)?void 0:r[u.blockIndex],i&&"table"===i.type){g=!0;const e=Io(i),a=e.find(t=>t.rowIndex===u.rowIndex&&t.cellIndex===u.cellIndex),n=e.find(t=>t.rowIndex===f.rowIndex&&t.cellIndex===f.cellIndex);if(a&&n){const r=Math.min(a.visualRowIndex,n.visualRowIndex),o=Math.max(a.visualRowIndex+a.rowSpan-1,n.visualRowIndex+n.rowSpan-1),d=Math.min(a.visualColumnIndex,n.visualColumnIndex),c=Math.max(a.visualColumnIndex+a.colSpan-1,n.visualColumnIndex+n.colSpan-1),h=new Set;for(const a of t.paragraphs)if(a.tableCell&&a.tableCell.tableId===i.id){const t=e.find(t=>t.rowIndex===a.tableCell.rowIndex&&t.cellIndex===a.tableCell.cellIndex);if(t){const e=t.visualRowIndex<=o&&t.visualRowIndex+t.rowSpan-1>=r,n=t.visualColumnIndex<=c&&t.visualColumnIndex+t.colSpan-1>=d;if(e&&n){const e=`${t.rowIndex}:${t.cellIndex}`;h.has(e)||(h.add(e),l.push({left:a.tableCell.left-s.left,top:a.tableCell.top-s.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(g||i.isCollapsed||c||h))for(const S of t.paragraphs){const t=rP(S.paragraphId,d,i);if(!t)continue;const e=Math.max(t.start,S.startOffset),a=Math.min(t.end,S.endOffset);if(!(e>=a))for(const n of S.lines){let t=Math.max(e,n.startOffset),r=Math.min(a,n.endOffset);for(;t<r&&nP(aP(S,t));)t+=1;for(;r>t&&nP(aP(S,r-1));)r-=1;if(t>=r)continue;const o=n.slots.find(e=>e.offset===t),i=n.slots.find(t=>t.offset===r)??n.slots[n.slots.length-1];if(!o||!i)continue;const d=0===S.startOffset&&n.startOffset===S.startOffset&&n.top>S.top,c=d?S.top:n.top,h=d?n.top+n.height-S.top:n.height;l.push({left:o.left-s.left+1,top:c-s.top,width:Math.max(1,i.left-o.left+1-1),height:h})}}const m=e.selection.focus.paragraphId,v=t.paragraphsById.get(m)??[],b=null==(o=v[0])?void 0:o.paragraph,y=function(t,e){if(0===t.length)return null;const a=t.find(t=>e>=t.startOffset&&e<=t.endOffset)??t[t.length-1],n=a.lines.flatMap(t=>t.slots);if(0===n.length)return{left:a.left,top:a.top,height:Math.max(18,a.height)};let r=n[0],o=Math.abs(e-r.offset);for(const l of n){const t=Math.abs(e-l.offset);t<o&&(r=l,o=t)}const i=a.lines[0];return 0===a.startOffset&&void 0!==i&&e>=i.startOffset&&e<=i.endOffset&&r.top>a.top?{left:r.left,top:a.top,height:r.top+r.height-a.top}:{left:r.left,top:r.top,height:r.height}}(v,b?$e(b,e.selection.focus):e.selection.focus.offset),M=((null==y?void 0:y.left)??s.left)-s.left,x=((null==y?void 0:y.top)??s.top)-s.top,w=Math.max(18,(null==y?void 0:y.height)??28);return{selectionBoxes:l,inputBox:{left:M,top:x,height:w},caretBox:{left:M,top:x,height:w,visible:v.length>0&&!g&&!c&&!h},selectedImageBox:c,selectedTextBoxBox:h}}const iP={composeMeasuredParagraphLines:t=>qs.composeMeasuredParagraphLines(t),resolveRenderedLineHeightPx:(t,e)=>qs.resolveRenderedLineHeightPx(t,e)};function lP(t,e){return((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>(null==t?void 0:t[a])===e)}function sP(t,e){return((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>{const n=null==t?void 0:t[a];return(null==n?void 0:n.blockIndex)===e.blockIndex&&(null==n?void 0:n.offset)===e.offset})}function dP(){let t=new Map,e=new Map;return function(a){const n=new Map,r=e=>null==e?void 0:e.map(e=>{const a=t.get(e.blockId),r=function(t,e){var a,n,r,o,i,l,s,d,c,h,p,u,f,g;return Boolean(t&&t.blockId===e.blockId&&t.sourceBlock===e.sourceBlock&&t.estimatedHeight===e.estimatedHeight&&(null==(a=t.tableSegment)?void 0:a.startRowIndex)===(null==(n=e.tableSegment)?void 0:n.startRowIndex)&&(null==(r=t.tableSegment)?void 0:r.endRowIndex)===(null==(o=e.tableSegment)?void 0:o.endRowIndex)&&(null==(i=t.tableSegment)?void 0:i.repeatedHeaderRowCount)===(null==(l=e.tableSegment)?void 0:l.repeatedHeaderRowCount)&&lP(null==(s=t.tableSegment)?void 0:s.startRowCellBlockStarts,null==(d=e.tableSegment)?void 0:d.startRowCellBlockStarts)&&lP(null==(c=t.tableSegment)?void 0:c.endRowCellBlockEnds,null==(h=e.tableSegment)?void 0:h.endRowCellBlockEnds)&&sP(null==(p=t.tableSegment)?void 0:p.startRowCellBlockPositions,null==(u=e.tableSegment)?void 0:u.startRowCellBlockPositions)&&sP(null==(f=t.tableSegment)?void 0:f.endRowCellBlockPositions,null==(g=e.tableSegment)?void 0:g.endRowCellBlockPositions)&&function(t,e){return t===e||!(!t||!e)&&t.text===e.text&&t.startOffset===e.startOffset&&t.endOffset===e.endOffset&&t.lines.length===e.lines.length&&e.lines.every((e,a)=>{const n=t.lines[a];return void 0!==n&&n.startOffset===e.startOffset&&n.endOffset===e.endOffset&&n.top===e.top&&n.height===e.height})}(t.layout,e.layout))}(a,e)?a:e;return n.set(r.blockId,r),r}),o=a.pages.map(t=>{const a={...t,blocks:r(t.blocks)??[],headerBlocks:r(t.headerBlocks),footerBlocks:r(t.footerBlocks),footnoteBlocks:r(t.footnoteBlocks)},n=e.get(a.id);return function(t,e){const a=Boolean(t&&t.pageSettings.width===e.pageSettings.width&&t.pageSettings.height===e.pageSettings.height&&t.pageSettings.orientation===e.pageSettings.orientation&&t.pageSettings.margins.top===e.pageSettings.margins.top&&t.pageSettings.margins.right===e.pageSettings.margins.right&&t.pageSettings.margins.bottom===e.pageSettings.margins.bottom&&t.pageSettings.margins.left===e.pageSettings.margins.left&&t.pageSettings.margins.header===e.pageSettings.margins.header&&t.pageSettings.margins.footer===e.pageSettings.margins.footer&&t.pageSettings.margins.gutter===e.pageSettings.margins.gutter);if(!t||t.id!==e.id||t.index!==e.index||t.height!==e.height||t.maxHeight!==e.maxHeight||!a||t.bodyTop!==e.bodyTop||t.bodyBottom!==e.bodyBottom||t.headerTop!==e.headerTop||t.footerTop!==e.footerTop||t.footnoteTop!==e.footnoteTop||t.footnoteSeparatorTop!==e.footnoteSeparatorTop)return!1;const n=(t,e)=>((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>(null==t?void 0:t[a])===e);return n(t.blocks,e.blocks)&&n(t.headerBlocks,e.headerBlocks)&&n(t.footerBlocks,e.footerBlocks)&&n(t.footnoteBlocks,e.footnoteBlocks)&&(r=t.footnoteReferenceIds,o=e.footnoteReferenceIds,((null==r?void 0:r.length)??0)===((null==o?void 0:o.length)??0)&&(o??[]).every((t,e)=>(null==r?void 0:r[e])===t));var r,o}(n,a)?n:a});return t=n,e=new Map(o.map(t=>[t.id,t])),{pages:o}}}function cP(t,e){if(0===e.length)return t;let a;for(const n of e)Object.prototype.hasOwnProperty.call(t,n)&&(a??(a={...t}),delete a[n]);return a??t}function hP(t){const[e,a]=y({}),[n,r]=y({}),[o,i]=y({left:0,top:0,height:28}),[l,s]=y([]),[d,c]=y([]),[h,p]=y(null),[u,f]=y(null),[g,m]=y({left:0,top:0,height:28,visible:!1}),[v,b]=y(null),M=dP(),S=w(()=>(ih(),M(nh(t.state.document,void 0,e(),n(),{measurer:iP})))),A=ux();let C=0;const T=(e="selection")=>{var a;const n=t.surfaceRef();if(!n)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const r=A.getCanvasLayoutSnapshot({surface:n,state:t.state,documentLayout:S(),zoomFactor:null==(a=t.zoomFactor)?void 0:a.call(t)});if(!r)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const o=oP(r,t.state);s(o.selectionBoxes),c(function(t,e){const a=e.document.comments;if(!a||0===a.order.length)return[];const n=t.surfaceRect,r=new Map(Na(e).map((t,e)=>[t.id,e])),o=[];for(const i of a.order){const e=a.items[i];if(!(null==e?void 0:e.start)||!(null==e?void 0:e.end))continue;const l=r.get(e.start.paragraphId),s=r.get(e.end.paragraphId);if(void 0!==l&&void 0!==s)for(const a of t.paragraphs){const t=r.get(a.paragraphId);if(void 0===t||t<l||t>s)continue;const d=t===l?e.start.offset:0,c=t===s?e.end.offset:Number.POSITIVE_INFINITY,h=Math.max(d,a.startOffset),p=Math.min(c,a.endOffset);if(!(h>=p))for(const e of a.lines){const t=Math.max(h,e.startOffset),a=Math.min(p,e.endOffset);if(t>=a)continue;const r=e.slots.find(e=>e.offset===t),l=e.slots.find(t=>t.offset===a)??e.slots[e.slots.length-1];r&&l&&o.push({commentId:i,left:r.left-n.left,top:e.top-n.top,width:Math.max(1,l.left-r.left),height:e.height})}}}return o}(r,t.state)),p(o.selectedImageBox),f(o.selectedTextBoxBox),i(o.inputBox),m(o.caretBox)},k=(t="selection")=>{const e=++C;queueMicrotask(()=>{e===C&&T(t)})};x(()=>{t.state.selection.anchor.paragraphId,t.state.selection.anchor.runId,t.state.selection.anchor.offset,t.state.selection.focus.paragraphId,t.state.selection.focus.runId,t.state.selection.focus.offset,k("selection")}),x(()=>{var e;t.state.document,t.state.activeSectionIndex,t.state.activeZone,(null==(e=t.isImporting)?void 0:e.call(t))||k("content-change")}),x(()=>{const e=t.viewportRef();if(!e)return;const a=()=>{k("scroll")},n=()=>{k("resize")};e.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",n),I(()=>{e.removeEventListener("scroll",a),window.removeEventListener("resize",n)})});return{measuredBlockHeights:e,measuredParagraphLayouts:n,documentLayout:S,canvasSnapshotProvider:A,inputBox:o,selectionBoxes:l,commentHighlights:d,selectedImageBox:h,selectedTextBoxBox:u,caretBox:g,preferredColumnX:v,setPreferredColumnX:b,clearPreferredColumn:()=>b(null),requestInputBoxSync:k,scheduleDeferredLayoutMeasurement:(t,e={})=>(e.paragraphIds&&e.paragraphIds.length>0&&(r(t=>cP(t,e.paragraphIds??[])),lh()),k(t),e.resolveWhenDone?Promise.resolve():null),stabilizeLayoutAfterImport:async()=>{a({}),r({}),lh(),await new Promise(t=>{var e;e=()=>t(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16)}),k("import")},syncMeasuredLayoutMetrics:(t="content-change")=>(k(t),!1),syncInputBox:T,setMeasuredBlockHeights:a,setMeasuredParagraphLayouts:r,applyInvalidation:e=>{var n,o;if(!(null==(n=t.isImporting)?void 0:n.call(t))){if(e.dirtyAll||e.structureChanged)a({}),r({}),lh();else if(((null==(o=e.dirtyParagraphIds)?void 0:o.length)??0)>0){const t=e.dirtyParagraphIds??[];r(e=>cP(e,t)),lh()}k("content-change")}},onCleanupHook:()=>{C+=1,A.clear()}}}function pP(t){return{performUndo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.undoStack.length?null:{history:{undoStack:a.undoStack.slice(0,-1),redoStack:[...a.redoStack,n],lastTransactionMeta:null},nextState:a.undoStack[a.undoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},performRedo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.redoStack.length?null:{history:{undoStack:[...a.undoStack,n],redoStack:a.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:a.redoStack[a.redoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},moveSelectedImageByParagraph:e=>{const a=t.imageOps().getSelectedImageInfo(t.state());if(!a)return!1;const n=Na(t.state()),r=n.findIndex(t=>t.id===a.paragraph.id);if(r<0)return!1;const o=r+e;if(o<0||o>=n.length){const a=((t,e)=>{const a=ca(t.document),n=Math.max(0,Math.min(Ea(t),a.length-1)),r=La(t),o=a[n];if(!o)return t;const i=[...a],l={...o},s=Ja("");if("header"===r){const t=[...o.header??[]];e<0?t.unshift(s):t.push(s),l.header=t}else if("footer"===r){const t=[...o.footer??[]];e<0?t.unshift(s):t.push(s),l.footer=t}else{const t=[...o.blocks];e<0?t.unshift(s):t.push(s),l.blocks=t}return i[n]=l,{...t,document:{...t.document,sections:i}}})(t.state(),e),n=Na(a),r=e<0?n[0]:n[n.length-1];if(!r)return!1;const o=_e(r,e<0?Qe(r):0);return t.applyTransactionalState(()=>_q(a,o),{mergeKey:gV}),t.focusInput(),!0}const i=n[o],l=e<0?Qe(i):0;return t.applyTransactionalState(t=>_q(t,_e(i,l)),{mergeKey:gV}),t.focusInput(),!0},applySelectionPreservingStructure:e=>{var a;const n=t.stateSnapshot();t.applyHistoryState({...n,document:{...n.document,sections:null==(a=n.document.sections)?void 0:a.map(CA)},selection:{anchor:{...e.anchor},focus:{...e.focus}}})}}}function uP(t={}){const e=t.dbName??"oasis-editor-db",a=t.storeName??"documents",n=t.key??"current-document";let r=null;async function o(){return r||(r=await function(t){return new Promise((e,a)=>{const n=indexedDB.open(t.name,t.version);n.onerror=()=>{var t;a(new Error(`Failed to open IndexedDB: ${null==(t=n.error)?void 0:t.message}`))},n.onsuccess=()=>{e(n.result)},n.onupgradeneeded=e=>{const a=n.result;t.onUpgrade(a,e.oldVersion,e.newVersion)}})}({name:e,version:1,onUpgrade:t=>{t.objectStoreNames.contains(a)||t.createObjectStore(a)}}),r)}return{async saveDocument(t){await function(t,e,a,n){return new Promise((r,o)=>{try{const i=t.transaction([e],"readwrite"),l=i.objectStore(e).put(n,a);l.onerror=()=>{var t;o(new Error(`Failed to put item in ${e}: ${null==(t=l.error)?void 0:t.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{var t;o(new Error(`Transaction failed putting item in ${e}: ${null==(t=i.error)?void 0:t.message}`))}}catch(i){o(i)}})}(await o(),a,n,t)},loadDocument:async()=>function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readonly").objectStore(e).get(a);o.onerror=()=>{var t;r(new Error(`Failed to get item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n(o.result??null)}}catch(o){r(o)}})}(await o(),a,n),async clearDocument(){await function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readwrite"),i=o.objectStore(e).delete(a);i.onerror=()=>{var t;r(new Error(`Failed to delete item from ${e}: ${null==(t=i.error)?void 0:t.message}`))},o.oncomplete=()=>{n()},o.onabort=o.onerror=()=>{var t;r(new Error(`Transaction failed deleting item from ${e}: ${null==(t=o.error)?void 0:t.message}`))}}catch(o){r(o)}})}(await o(),a,n)},close(){r&&(r.close(),r=null)}}}function fP(t){const[e,a]=y([]),[n,r]=y([]);let o={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{a(o.undoStack),r(o.redoStack)};return{undoStack:e,redoStack:n,applyTransactionalState:(e,a)=>{const n=t.stateSnapshot(),r=ud("txn:produce",()=>e(n),0);if(r===n)return;o=function(t,e,a,n,r=Date.now()){var o;return{undoStack:void 0!==(null==n?void 0:n.mergeKey)&&(null==(o=t.lastTransactionMeta)?void 0:o.mergeKey)===n.mergeKey&&r-t.lastTransactionMeta.timestamp<1e3?t.undoStack:[...t.undoStack,e],redoStack:[],lastTransactionMeta:(null==n?void 0:n.mergeKey)?{mergeKey:n.mergeKey,timestamp:r}:null}}(o,n,0,a),i();const l=ud("txn:invalidate",()=>function(t,e){var a,n,r,o,i,l;if(t===e||t.document===e.document)return{};const s=t=>ca(t.document).map(t=>[...(t.header??[]).map(t=>t.id),...t.blocks.map(t=>t.id),...(t.footer??[]).map(t=>t.id)].join("|")).join("||");if(s(t)!==s(e))return{dirtyAll:!0,structureChanged:!0};const d=Na(t),c=Na(e),h=new Map;for(const u of d)h.set(u.id,u);const p=[];for(const u of c){const t=h.get(u.id);if(!t){p.push(u.id);continue}if(t===u)continue;if(t.runs.length!==u.runs.length){p.push(u.id);continue}let e=!1;for(let s=0;s<t.runs.length;s+=1){const d=t.runs[s],c=u.runs[s];if(d===c)continue;if(d.id!==c.id||d.text!==c.text){e=!0;break}const h=ye(d),p=ye(c);if(Boolean(h)!==Boolean(p)||((null==h?void 0:h.width)??-1)!==((null==p?void 0:p.width)??-1)||((null==h?void 0:h.height)??-1)!==((null==p?void 0:p.height)??-1)||((null==(a=null==h?void 0:h.floating)?void 0:a.wrap)??"")!==((null==(n=null==p?void 0:p.floating)?void 0:n.wrap)??"")||Boolean(null==(r=null==h?void 0:h.floating)?void 0:r.behindDoc)!==Boolean(null==(o=null==p?void 0:p.floating)?void 0:o.behindDoc)||((null==(i=null==h?void 0:h.wrapPolygon)?void 0:i.length)??-1)!==((null==(l=null==p?void 0:p.wrapPolygon)?void 0:l.length)??-1)){e=!0;break}}e&&p.push(u.id)}return{dirtyParagraphIds:p}}(n,r),0);t.applyLayoutInvalidation(l),ud("txn:setState",()=>t.commitState(r),0)},applyHistoryState:e=>{t.commitState(t.cloneState(e))},resetTransactionGrouping:()=>{var t;t=o,o={...t,lastTransactionMeta:null}},updateHistoryState:t=>{o=t(o),i()},getHistoryState:()=>o,clearHistory:()=>{o={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}function gP(t){x(()=>{var e,a;if(t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone,a=t.state,aV&&(oV={anchor:{paragraphId:a.selection.anchor.paragraphId,runId:a.selection.anchor.runId,offset:a.selection.anchor.offset},focus:{paragraphId:a.selection.focus.paragraphId,runId:a.selection.focus.runId,offset:a.selection.focus.offset},activeZone:a.activeZone??"main",activeSectionIndex:a.activeSectionIndex??0}),t.isImportInProgress())return;const n=t.cloneState(t.getStateSnapshot());null==(e=t.getOnStateChange())||e(n),t.emit("change",n),t.emit("documentChange",n.document),t.emit("selectionChange",n.selection)})}function mP(t){const{documentOptions:e,logger:a,runtimeClient:n,state:r,commitState:o,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:d,focusInput:c,surfaceRef:h,viewportRef:p,zoomFactor:u,getImageOps:f}=t,g=function(t){const[e,a]=y(null),n=(t,e)=>{const[a,n]=eP[t];return void 0!==e&&Number.isFinite(e)?Math.round(10*(a+(n-a)*Math.min(1,Math.max(0,e))))/10:n},r=Fq({applyState:t.applyState,stabilizeLayoutAfterImport:t.stabilizeLayoutAfterImport,resetEditorChromeState:t.resetEditorChromeState,focusInput:t.focusInput,setImportPhase:(t,e)=>{a({phase:t,progress:n(t,e),subProgress:e})},clearImportProgressSoon:()=>{globalThis.setTimeout(()=>{a(t=>"done"===(null==t?void 0:t.phase)||"error"===(null==t?void 0:t.phase)?null:t)},1200)},now:()=>performance.now(),logger:t.logger}),o=tP({state:t.state,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,logger:t.logger}),i=Pq({document:()=>t.state().document,focusInput:t.focusInput}),l=async(t,e)=>{await o.insertImageFromFile(t,e)};return{importProgress:e,handleImportFile:async e=>{t.isReadOnly()||await r.handleImportFile(e)},handleExportDocx:async()=>{await i.handleExportDocx()},handleExportPdf:async()=>{await i.handleExportPdf()},insertImageFromFile:l,handleInsertImage:async e=>{t.isReadOnly()||e&&(await l(e),t.focusInput())}}}({state:()=>r,applyState:l,applyTransactionalState:(t,e)=>D(t,e),isReadOnly:d,surfaceRef:()=>h()??null,stabilizeLayoutAfterImport:async()=>{await N()},resetEditorChromeState:()=>Q(),focusInput:c,logger:a}),m=()=>{var t,e;return"done"!==(null==(t=g.importProgress())?void 0:t.phase)&&"error"!==(null==(e=g.importProgress())?void 0:e.phase)&&null!==g.importProgress()},{measuredBlockHeights:v,measuredParagraphLayouts:b,documentLayout:M,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:T,selectedImageBox:k,selectedTextBoxBox:V,caretBox:R,preferredColumnX:E,setPreferredColumnX:L,clearPreferredColumn:z,stabilizeLayoutAfterImport:N,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:q,applyInvalidation:P,onCleanupHook:W}=hP({state:r,surfaceRef:h,viewportRef:p,isImporting:m,zoomFactor:u}),B=uP({key:e().persistenceKey}),{status:F}=function(t,e,a){const[n,r]=y("Initial"),[o,i]=y(!1),l=()=>a.enabled??!1,s=a.persistence,d=On(async t=>{var e;if(l()&&o()){r("Saving...");try{const e=JSON.parse(JSON.stringify(oe(t)));await s.saveDocument(e),r("Saved")}catch(n){null==(e=a.logger)||e.error("persistence:autosave failed",n),r("Error")}}},1e3);return x(A(()=>t.document,t=>{l()&&o()&&d(t)},{defer:!0})),C(async()=>{var t;if(!l())return i(!0),void r("Saved");try{const t=await s.loadDocument();t&&e(t)}catch(n){null==(t=a.logger)||t.error("persistence:load failed",n)}finally{i(!0),r("Saved")}}),{status:n}}(r,t=>{a.info("persistence:loaded",{docId:t.id});const e=rn(t);o(e),Q()},{enabled:e().persistenceEnabled??!1,persistence:e().persistence??B,logger:a}),H=fP({stateSnapshot:i,commitState:o,cloneState:s,applyLayoutInvalidation:P}),{undoStack:U,redoStack:G,applyTransactionalState:D,applyHistoryState:j,resetTransactionGrouping:Z,updateHistoryState:K,getHistoryState:X,clearHistory:Y}=H,J=pP({state:()=>r,stateSnapshot:i,applyHistoryState:j,applyTransactionalState:D,focusInput:c,clearPreferredColumn:z,imageOps:f,updateHistoryState:K,getHistoryState:X}),Q=()=>{z(),O({}),q({}),lh(),w.clear(),Y()};return gP({state:r,isImportInProgress:m,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>e().onStateChange,emit:n.emit}),{docIO:g,isImportInProgress:m,measuredBlockHeights:v,measuredParagraphLayouts:b,documentLayout:M,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:T,selectedImageBox:k,selectedTextBoxBox:V,caretBox:R,preferredColumnX:E,setPreferredColumnX:L,clearPreferredColumn:z,stabilizeLayoutAfterImport:N,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:q,applyLayoutInvalidation:P,onCleanupHook:W,fallbackPersistence:B,persistenceStatus:F,undoStack:U,redoStack:G,applyTransactionalState:D,applyHistoryState:j,resetTransactionGrouping:Z,updateHistoryState:K,getHistoryState:X,clearHistory:Y,historyActions:J,resetEditorChromeState:Q}}function vP(t){return Hq(t,t=>"textBox"===t.kind)}function bP(t,e){const a=vP(t);if(!a||!Me(a.run))return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),{paragraphIndex:r,run:o}=a,i=Na(t).map((t,e)=>e!==r?MA(t):{...MA(t),runs:t.runs.map(t=>t.id===o.id&&"textBox"===t.kind?{...t,textBox:{...t.textBox,rotation:n}}:yA(t))});return rR(t,i,cR(i,Da(t)))}function yP(t,e){const a=vP(t);if(!a||!Me(a.run))return t;const{paragraphIndex:n,run:r}=a,o=Na(t).map((t,a)=>a!==n?MA(t):{...MA(t),runs:t.runs.map(t=>{if(t.id!==r.id||"textBox"!==t.kind)return yA(t);const a=e(t.textBox.floating),n={...t.textBox};return a?n.floating=a:delete n.floating,{...t,textBox:n}})});return rR(t,o,cR(o,Da(t)))}function MP(t,e,a,n={}){const r=vP(t),o=r&&Me(r.run);if(!r||!o)return t;const i=n.handleDirection??"se",l=i.includes("n")||i.includes("s"),s=i.includes("w"),d=i.includes("n"),c=Math.max(24,Math.round(e)),h=Math.max(24,Math.round(a)),{paragraphIndex:p,run:u}=r,f=c-o.width,g=h-o.height,m=Na(t).map((t,e)=>e!==p?MA(t):{...MA(t),runs:t.runs.map(t=>{var e;if(t.id!==u.id||"textBox"!==t.kind)return yA(t);const a=t.textBox,n={...a,width:c,height:h};return l&&(null==(e=a.body)?void 0:e.autoFit)&&(n.body={...a.body,autoFit:!1}),a.floating&&(n.floating=function(t,e,a,n,r){let o=t;if(n&&0!==e){const a=t.positionH;(null==a?void 0:a.align)||(o={...o,positionH:{...a??{},offset:((null==a?void 0:a.offset)??0)-e*Le}})}if(r&&0!==a){const t=o.positionV;(null==t?void 0:t.align)||(o={...o,positionV:{...t??{},offset:((null==t?void 0:t.offset)??0)-a*Le}})}return o}(a.floating,f,g,s,d)),{...t,textBox:n}})});return rR(t,m,cR(m,Da(t)))}const xP=t=>t.cells.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),wP=t=>t.rows.reduce((t,e)=>Math.max(t,xP(e)),0),SP=(t,e)=>{let a=0;for(const n of t.cells){const t=Math.max(1,n.colSpan??1);if(e>=a&&e<a+t)return n;a+=t}return null},AP=t=>{for(const e of t.rows)for(const t of e.cells){if("continue"===t.vMerge)continue;const e=t.blocks[0];if(e)return e}return null},CP=(t,e,a)=>{const n=ha(t);for(const r of n){const t=[...r.header||[],...r.blocks,...r.footer||[]];for(const n of t){if("table"!==n.type)continue;const t=n.rows.flatMap(t=>t.cells.filter(t=>"continue"!==t.vMerge&&t.blocks.length>0)),r=t.findIndex(t=>t.blocks.some(t=>t.id===e));if(-1===r)continue;const o=t[r+a],i=null==o?void 0:o.blocks[0];return i?_e(i,0):null}}return null},IP=(t,e,a="main")=>{const n=Ea(t),r=ca(t.document),o=Math.max(0,Math.min(n,r.length-1)),i=r[o];if(!i)return t;const l=[...r];return l[o]="header"===a?{...i,header:e}:"footer"===a?{...i,footer:e}:{...i,blocks:e},{...t,document:{...t.document,sections:l}}};function TP(t,e){const a=xa(t.document,t.selection.focus.paragraphId,Ea(t));if(!a)return null;const n=e(t,a.zone).map(AA),r=n[a.blockIndex];return r&&"table"===r.type?{tableBlock:r,location:a,targetBlocks:n}:null}function kP(t,e,a,n){const r=IP(t,e,a);return n?{...r,selection:{anchor:_e(n,0),focus:_e(n,0)}}:r}function VP(t,e){return t.visualRowIndex!==e.visualRowIndex?t.visualRowIndex-e.visualRowIndex:t.visualColumnIndex!==e.visualColumnIndex?t.visualColumnIndex-e.visualColumnIndex:0}function RP(t,e){const a=t.selection,n=Ea(t),r=xa(t.document,a.anchor.paragraphId,n),o=xa(t.document,a.focus.paragraphId,n);if(!r||!o||r.blockIndex!==o.blockIndex||r.zone!==o.zone)return null;const i=e.getTargetBlocks(t,r.zone)[r.blockIndex];if(!i||"table"!==i.type)return null;const l=Io(i),s=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),d=l.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex);return s&&d?{anchorLocation:r,focusLocation:o,anchorCell:s,focusCell:d,tableBlock:i,tableLayout:l}:null}function EP(t){const e=(t,e)=>{const a=ca(t.document),n=Ea(t),r=a[Math.max(0,Math.min(n,a.length-1))];return r?"header"===e?r.header||[]:"footer"===e?r.footer||[]:r.blocks:[]},{resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}=function(t){return{resolveTableCellRangeSelection:e=>{var a,n,r,o,i;const l=e.selection,s=RP(e,t);if(!s||s.anchorLocation.rowIndex===s.focusLocation.rowIndex&&s.anchorLocation.cellIndex===s.focusLocation.cellIndex)return null==(a=t.logger)||a.debug(`resolveTableCellRangeSelection: no expansion (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId})`),null;const d=Math.min(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),c=Math.max(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),h=Math.min(s.anchorLocation.cellIndex,s.focusLocation.cellIndex),p=Math.max(s.anchorLocation.cellIndex,s.focusLocation.cellIndex);null==(n=t.logger)||n.info(`resolveTableCellRangeSelection: expanding r${s.anchorLocation.rowIndex}:c${s.anchorLocation.cellIndex}->r${s.focusLocation.rowIndex}:c${s.focusLocation.cellIndex} (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId}) range=[rows ${d}..${c}, cells ${h}..${p}]`);const u=VP(s.anchorCell,s.focusCell)<=0?s.anchorLocation:s.focusLocation,f=VP(s.anchorCell,s.focusCell)<=0?s.focusLocation:s.anchorLocation,g=null==(o=null==(r=s.tableBlock.rows[u.rowIndex])?void 0:r.cells[u.cellIndex])?void 0:o.blocks[0],m=null==(i=s.tableBlock.rows[f.rowIndex])?void 0:i.cells[f.cellIndex],v=null==m?void 0:m.blocks[m.blocks.length-1];return g&&v?{anchor:_e(g,0),focus:_e(v,Je(v).length)}:null},resolveSelectedTableCells:e=>{const a=RP(e,t);if(!a)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex+a.anchorCell.rowSpan-1,a.focusCell.visualRowIndex+a.focusCell.rowSpan-1),o=Math.min(a.anchorCell.visualColumnIndex,a.focusCell.visualColumnIndex),i=Math.max(a.anchorCell.visualColumnIndex+a.anchorCell.colSpan-1,a.focusCell.visualColumnIndex+a.focusCell.colSpan-1),l=a.tableLayout.filter(t=>t.visualRowIndex<=r&&t.visualRowIndex+t.rowSpan-1>=n&&t.visualColumnIndex<=i&&t.visualColumnIndex+t.colSpan-1>=o);return{blockIndex:a.anchorLocation.blockIndex,cells:l,zone:a.anchorLocation.zone}},resolveHorizontalTableCellRange:e=>{const a=RP(e,t);if(!a||a.anchorCell.visualRowIndex!==a.focusCell.visualRowIndex)return null;const n=VP(a.anchorCell,a.focusCell);if(0===n)return null;const r=n<=0?a.anchorLocation:a.focusLocation,o=n<=0?a.focusLocation:a.anchorLocation;return{blockIndex:a.anchorLocation.blockIndex,rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:o.cellIndex,zone:a.anchorLocation.zone}},resolveVerticalTableCellRange:e=>{const a=RP(e,t);if(!a||a.anchorLocation.cellIndex!==a.focusLocation.cellIndex)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex);return n===r?null:{blockIndex:a.anchorLocation.blockIndex,startRowIndex:n,endRowIndex:r,cellIndex:a.anchorLocation.cellIndex,zone:a.anchorLocation.zone}}}}({getTargetBlocks:e,logger:t.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);return Boolean(a&&a.endCellIndex>a.startCellIndex)},a=e=>{var a;const n=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.colSpan)??1)>1)},n=e=>{var a;const n=t.resolveVerticalTableCellRange(e);if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=null==(a=r.rows[t])?void 0:a.cells[n.cellIndex];if(!e||"continue"===e.vMerge||1!==e.blocks.length)return!1}return!0},r=e=>{var a;const n=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.rowSpan)??1)>1&&"restart"===(null==o?void 0:o.vMerge))};return{canMergeSelectedTableCells:e,canSplitSelectedTableCell:a,canMergeSelectedTableRows:n,canMergeSelectedTable:t=>e(t)||n(t),canSplitSelectedTableCellVertically:r,canSplitSelectedTable:t=>a(t)||r(t),canEditSelectedTableRow:e=>{const a=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return Boolean(n&&"table"===n.type)},canEditSelectedTableColumn:e=>{const a=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return!(!n||"table"!==n.type)&&wP(n)>1}}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}),{mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y}=function(t){const e=t=>({...t,style:t.style?{...t.style}:void 0,conditionalStyle:t.conditionalStyle?{...t.conditionalStyle}:void 0,mergeRevisionState:void 0,blocks:t.blocks.map(t=>AA(t))}),a=a=>{const n=t.resolveHorizontalTableCellRange(a);if(!n)return a;const r=t.getTargetBlocks(a,n.zone).map(AA),o=r[n.blockIndex];if(!o||"table"!==o.type)return a;const i=o.rows[n.rowIndex];if(!i)return a;const l=i.cells.slice(n.startCellIndex,n.endCellIndex+1);if(l.length<2)return a;const s=a.trackChangesEnabled?VR():void 0,d={...l[0],colSpan:l.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),blocks:l.flatMap(t=>t.blocks.map(t=>AA(t))),...s?{style:{...l[0].style??{},revision:{...s,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:s.id,orientation:"horizontal",currentCellCount:1,previousCells:l.map(e)}}:{}};i.cells.splice(n.startCellIndex,l.length,d);const c=d.blocks[0];return c?kP(a,r,n.zone,c):a},n=a=>{const n=t.resolveVerticalTableCellRange(a);if(!n)return a;const r=t.getTargetBlocks(a,n.zone).map(AA),o=r[n.blockIndex];if(!o||"table"!==o.type)return a;const i=[];for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=o.rows[t],r=null==e?void 0:e.cells[n.cellIndex];if(!e||!r||"continue"===r.vMerge||1!==r.blocks.length)return a;i.push(r)}if(i.length<2)return a;const l=Math.max(1,i[0].colSpan??1);if(!i.every(t=>Math.max(1,t.colSpan??1)===l))return a;const s=a.trackChangesEnabled?VR():void 0,d={...i[0],rowSpan:i.length,vMerge:"restart",blocks:i.flatMap(t=>t.blocks.map(t=>AA(t))),...s?{style:{...i[0].style??{},revision:{...s,type:"merge",previous:{colSpan:i[0].colSpan,rowSpan:i[0].rowSpan,vMerge:i[0].vMerge}}},mergeRevisionState:{revisionId:s.id,orientation:"vertical",currentCellCount:1,previousCells:i.map(e)}}:{}};o.rows[n.startRowIndex].cells[n.cellIndex]=d;for(let t=n.startRowIndex+1;t<=n.endRowIndex;t+=1){const e=_a([Ja("")],l);e.blocks=[],e.vMerge="continue",o.rows[t].cells[n.cellIndex]=e}const c=d.blocks[0];return c?kP(a,r,n.zone,c):a},r=a=>{var n;const r=TP(a,t.getTargetBlocks);if(!r)return a;const{tableBlock:o,location:i,targetBlocks:l}=r,s=null==(n=o.rows[i.rowIndex])?void 0:n.cells[i.cellIndex],d=Math.max(1,(null==s?void 0:s.rowSpan)??1);if(!s||d<=1||"restart"!==s.vMerge)return a;const c=e(s),h=a.trackChangesEnabled?VR():void 0,p=Math.max(1,s.colSpan??1);s.rowSpan=void 0,s.vMerge=void 0,h&&(s.style={...s.style??{},revision:{...h,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},s.mergeRevisionState={revisionId:h.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:d-1},(t,a)=>{var n;const r=null==(n=o.rows[i.rowIndex+a+1])?void 0:n.cells[i.cellIndex];return r?e(r):_a([],p)})]});for(let t=1;t<d;t+=1){const e=o.rows[i.rowIndex+t];if(!e)break;const a=_a([Ja("")],p);e.cells[i.cellIndex]=a}const u=s.blocks[0];return u?kP(a,l,i.zone,u):a},o=a=>{var n;const r=TP(a,t.getTargetBlocks);if(!r)return a;const{tableBlock:o,location:i,targetBlocks:l}=r,s=o.rows[i.rowIndex],d=null==s?void 0:s.cells[i.cellIndex],c=Math.max(1,(null==d?void 0:d.colSpan)??1);if(!s||!d||c<=1)return a;const h=e(d),p=a.trackChangesEnabled?VR():void 0,u=[{...d,colSpan:1,blocks:d.blocks.map(t=>AA(t)),...p?{style:{...d.style??{},revision:{...p,type:"merge",previous:{colSpan:h.colSpan,rowSpan:h.rowSpan,vMerge:h.vMerge}}},mergeRevisionState:{revisionId:p.id,orientation:"horizontal",currentCellCount:c,previousCells:[h]}}:{}},...Array.from({length:c-1},()=>_a([Ja("")]))];s.cells.splice(i.cellIndex,1,...u);const f=null==(n=u[0])?void 0:n.blocks[0];return f?kP(a,l,i.zone,f):a};return{mergeSelectedTableCells:a,mergeSelectedTableRows:n,mergeSelectedTable:e=>t.canMergeSelectedTableCells(e)?a(e):t.canMergeSelectedTableRows(e)?n(e):e,splitSelectedTableCellVertically:r,splitSelectedTableCell:o,splitSelectedTable:e=>t.canSplitSelectedTableCellVertically(e)?r(e):t.canSplitSelectedTableCell(e)?o(e):e}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:c}),{insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S}=function(t){return{insertSelectedTableRow:(e,a)=>{var n,r;const o=TP(e,t.getTargetBlocks);if(!o)return e;const{tableBlock:i,location:l,targetBlocks:s}=o,d=i.rows[l.rowIndex];if(!d)return e;const c=Math.max(0,Math.min(i.rows.length,l.rowIndex+(a>0?1:0)));let h;if(i.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge))){const t=Io(i),a=t.find(t=>t.rowIndex===l.rowIndex&&t.cellIndex===l.cellIndex),r=t.filter(t=>t.rowIndex===l.rowIndex);h=$a((r.length>0?r:t.filter(t=>t.rowIndex===Math.max(0,l.rowIndex-1))).map(e=>{const a=t.find(t=>t.visualColumnIndex===e.visualColumnIndex&&t.visualRowIndex<c&&t.visualRowIndex+t.rowSpan>c);if(a){a.cell.rowSpan=Math.max(1,a.cell.rowSpan??1)+1,a.cell.vMerge="restart";const t=_a([Ja("")],e.colSpan);return t.blocks=[],t.vMerge="continue",t}return _a([Ja("")],e.colSpan)})),e.trackChangesEnabled&&(h.style={...h.style??{},revision:{...VR(),type:"insert"}}),i.rows.splice(c,0,h);const o=(null==a?void 0:a.visualColumnIndex)??l.cellIndex,d=SP(h,o),p=(null==d?void 0:d.blocks[0])??(null==(n=h.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:n.blocks[0])??AP(i);return kP(e,s,l.zone,p)}h=$a(d.cells.map(t=>_a([Ja("")],Math.max(1,t.colSpan??1)))),e.trackChangesEnabled&&(h.style={...h.style??{},revision:{...VR(),type:"insert"}}),i.rows.splice(c,0,h);const p=h.cells[Math.min(l.cellIndex,h.cells.length-1)],u=(null==p?void 0:p.blocks[0])??(null==(r=h.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:r.blocks[0])??AP(i);return kP(e,s,l.zone,u)},deleteSelectedTableRow:e=>{const a=TP(e,t.getTargetBlocks);if(!a)return e;const{tableBlock:n,location:r,targetBlocks:o}=a;if(n.rows.length<=1&&!e.trackChangesEnabled)return e;const i=n.rows[r.rowIndex];if(!i)return e;if(e.trackChangesEnabled)return i.style={...i.style??{},revision:{...VR(),type:"delete"}},kP(e,o,r.zone,null);if(i.cells.some(t=>"continue"!==t.vMerge&&Math.max(1,t.rowSpan??1)>1))return e;const l=n.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge)),s=l?Io(n).find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex):null;if(l){const t=Io(n);for(const e of t)e.visualRowIndex<r.rowIndex&&e.visualRowIndex+e.rowSpan>r.rowIndex&&(e.cell.rowSpan=Math.max(1,e.cell.rowSpan??1)-1,e.cell.rowSpan<=1?(e.cell.rowSpan=void 0,e.cell.vMerge=void 0):e.cell.vMerge="restart")}n.rows.splice(r.rowIndex,1);const d=n.rows[Math.min(r.rowIndex,n.rows.length-1)],c=d?SP(d,Math.min((null==s?void 0:s.visualColumnIndex)??r.cellIndex,Math.max(0,xP(d)-1))):null,h=(null==c?void 0:c.blocks[0])??AP(n);return kP(e,o,r.zone,h)},insertSelectedTableColumn:(e,a)=>{var n;const r=TP(e,t.getTargetBlocks);if(!r)return e;const{tableBlock:o,location:i,targetBlocks:l}=r;if(o.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=Io(o).find(t=>t.rowIndex===i.rowIndex&&t.cellIndex===i.cellIndex),n=((null==t?void 0:t.visualColumnIndex)??i.cellIndex)+(a>0?Math.max(1,(null==t?void 0:t.colSpan)??1):0);for(const a of o.rows){const t=[];let r=0,o=!1;for(const i of a.cells){const a=Math.max(1,i.colSpan??1);if(!o&&n<=r){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.push(a),o=!0}!o&&r<n&&n<r+a?(t.push({...i,colSpan:a+1,...e.trackChangesEnabled?{style:{...i.style??{},revision:{...VR(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),o=!0):t.push(i),r+=a}if(!o){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.push(a)}a.cells=t}const r=o.rows[i.rowIndex],s=r?SP(r,n):null,d=(null==s?void 0:s.blocks[0])??AP(o);return kP(e,l,i.zone,d)}const s=Math.max(0,Math.min((null==(n=o.rows[0])?void 0:n.cells.length)??0,i.cellIndex+(a>0?1:0)));for(const t of o.rows){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.cells.splice(s,0,a)}const d=o.rows[i.rowIndex],c=null==d?void 0:d.cells[s],h=(null==c?void 0:c.blocks[0])??AP(o);return kP(e,l,i.zone,h)},deleteSelectedTableColumn:e=>{var a;const n=TP(e,t.getTargetBlocks);if(!n)return e;const{tableBlock:r,location:o,targetBlocks:i}=n;if(wP(r)<=1)return e;if(e.trackChangesEnabled){const t=Io(r).find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??o.cellIndex;for(const e of r.rows){const t=SP(e,a);t&&(t.style={...t.style??{},revision:{...VR(),type:"delete"}})}return kP(e,i,o.zone,null)}if(r.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=Io(r).find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??o.cellIndex;for(const e of r.rows){const t=[];let n=0;for(const r of e.cells){const e=Math.max(1,r.colSpan??1);a>=n&&a<n+e?e>1&&t.push({...r,colSpan:e-1>1?e-1:void 0}):t.push(r),n+=e}e.cells=t}const n=r.rows[o.rowIndex],l=n&&SP(n,Math.min(a,Math.max(0,xP(n)-1))),s=(null==l?void 0:l.blocks[0])??AP(r);return kP(e,i,o.zone,s)}if((null==(a=r.rows[0])?void 0:a.cells.length)<=1)return e;for(const t of r.rows)t.cells.splice(o.cellIndex,1);const l=r.rows[o.rowIndex],s=null==l?void 0:l.cells[Math.min(o.cellIndex,l.cells.length-1)],d=(null==s?void 0:s.blocks[0])??AP(r);return kP(e,i,o.zone,d)}}}({getTargetBlocks:e}),{withExpandedTableCellSelection:A,applySelectionAwareTextCommand:C,applySelectionAwareParagraphCommand:I}=function(t){const e=e=>{const a=t.resolveTableCellRangeSelection(e);return a?t.applySelectionToStatePreservingStructure(e,a):e},a=(a,n)=>{t.applyTransactionalState(r=>{var o,i,l;const s=t.resolveSelectedTableCells(r);if(!s||s.cells.length<=1){const i=e(r);return i!==r&&(null==(o=t.logger)||o.info(`${n}: expanded selection to ${i.selection.anchor.paragraphId}[${i.selection.anchor.offset}]..${i.selection.focus.paragraphId}[${i.selection.focus.offset}]`)),a(i)}const{blockIndex:d,cells:c,zone:h}=s;null==(i=t.logger)||i.info(`${n}: multi-cell selection in table block ${d} (${c.length} cells) in zone ${h}`);const p=[],u=[];for(const t of c)p.push(...t.cell.blocks),u.push(t.cell.blocks.length);if(0===p.length)return r;const f={...r,document:nn(p,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:_e(p[0],0),focus:_e(p[p.length-1],Je(p[p.length-1]).length)}},g=Na(a(f)),m=t.getTargetBlocks(r,h),v=AA(m[d]);if(!v)return r;const b=m.map((t,e)=>e===d?v:t),y=v;let M=0;for(let t=0;t<c.length;t+=1){const e=c[t],a=u[t],n=g.slice(M,M+a);M+=a;const r=null==(l=y.rows[e.rowIndex])?void 0:l.cells[e.cellIndex];r&&(r.blocks=n)}return IP(r,b,h)})};return{withExpandedTableCellSelection:e,applySelectionAwareTextCommand:t=>{a(t,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:t=>{a(t,"applySelectionAwareParagraphCommand")}}}({applyTransactionalState:t.applyTransactionalState,applySelectionToStatePreservingStructure:t.applySelectionToStatePreservingStructure,getTargetBlocks:e,resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,logger:t.logger});return{resolveTableCellRangeSelection:a,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u,mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y,insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S,getRowVisualWidth:xP,getTableVisualWidth:wP,findCellAtVisualColumn:SP,findFirstNavigableParagraphInTable:AP,updateBlocksInCurrentSection:IP,resolveAdjacentTableCellPosition:CP,applyTableAwareParagraphEdit:(t,a)=>((t,e,a)=>{var n;const r=xa(t.document,t.selection.focus.paragraphId,Ea(t));if(!r||t.selection.anchor.paragraphId!==t.selection.focus.paragraphId)return a(t);const o=r.zone,i=e(t,o),l=AA(i[r.blockIndex]);if(!l||"table"!==l.type)return a(t);const s=i.map((t,e)=>e===r.blockIndex?l:t),d=null==(n=l.rows[r.rowIndex])?void 0:n.cells[r.cellIndex];if(!d)return a(t);const c=a({...t,document:nn(d.blocks,void 0,void 0,void 0,void 0,t.document.assets),selection:{anchor:{...t.selection.anchor},focus:{...t.selection.focus}}}),h=ba(c.document).filter(t=>"paragraph"===t.type);return d.blocks.splice(0,d.blocks.length,...h),{...IP(t,s,o),selection:c.selection}})(t,e,a),withExpandedTableCellSelection:A,applySelectionAwareTextCommand:C,applySelectionAwareParagraphCommand:I,insertTableCommand:(e,a)=>{var n;null==(n=t.logger)||n.info(`insertTableCommand: ${e}x${a}`),t.applyTransactionalState(t=>function(t,e,a){const n=100/Math.max(1,a)+"%",r=t.trackChangesEnabled?VR():void 0,o=[];for(let m=0;m<e;m+=1){const t=[];for(let r=0;r<a;r+=1)t.push({..._a([Ja("")]),style:{width:n}});const e=$a(t);r&&(e.style={revision:{...r,type:"insert"}}),o.push(e)}const i={...tn(o),style:{width:"100%"}},l=Fa(t,t.selection.focus),s=ha(t.document),d=Ea(t),c=La(t),h=t=>{const e=t.findIndex(t=>t.id===l.paragraphId||"paragraph"!==t.type&&pa(t).some(t=>t.id===l.paragraphId));return-1===e?{nextBlocks:t,found:!1}:{nextBlocks:[...t.slice(0,e+1),i,...t.slice(e+1)],found:!0}},p=s[d];if(!p)return t;const u={...p};let f=!1;if("header"===c){const t=h(p.header??[]);u.header=t.nextBlocks,f=t.found}else if("footer"===c){const t=h(p.footer??[]);u.footer=t.nextBlocks,f=t.found}else{const t=h(p.blocks);u.blocks=t.nextBlocks,f=t.found}if(!f)return t;const g=[...s];return g[d]=u,{...t,document:{...t.document,sections:g},selection:iR(_e(i.rows[0].cells[0].blocks[0],0))}}(t,e,a),{mergeKey:fV}),t.focusInput()}}}function LP(t,e){let a=null;const n=(t,e,a)=>{const n=Na(t).find(t=>t.id===e);return n?{anchor:_e(n,a),focus:_e(n,a+1)}:null},r=(t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}),o=o=>{var i;const l=a;if(!l)return;const s=(null==(i=e.zoomFactor)?void 0:i.call(e))??1,d=(o.clientX-l.startClientX)/s,c=(o.clientY-l.startClientY)/s,h=t.getMaxWidth(e.state,l.paragraphId),{width:p,height:u}=function(t,e,a,n,r){const o=YM(t.handleDirection,"x"),i=YM(t.handleDirection,"y"),l=0===o?t.startWidth:t.startWidth+e*o,s=0===i?t.startHeight:t.startHeight+a*i;let d=XM(l,KM,r),c=XM(s,KM);if(!n)return{width:d,height:c};const h=t.aspectRatio||1,p=0!==o;if(p&&0!==i){const e=d/t.startWidth,a=c/t.startHeight,n=Math.abs(e-1)>=Math.abs(a-1)?e:a;return d=XM(t.startWidth*n,KM,r),c=XM(d/h,KM),{width:d,height:c}}return p?(d=XM(d,KM,r),c=XM(d/h,KM),{width:d,height:c}):(c=XM(c,KM),d=XM(c*h,KM,r),c=XM(d/h,KM),{width:d,height:c})}(l,d,c,o.shiftKey,h),f=n(e.state,l.paragraphId,l.paragraphOffset);f?e.applyState(t.applyResize(r(e.state,f),p,u,l.handleDirection)):e.logger.warn(`${t.label} resize:missing paragraph`,l)},i=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),l(),e.focusInput()},l=()=>{a=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",i)};return{start:(l,s,d,c,h)=>{const p=n(h,l,s);if(!p)return;const u=t.getSelected(r(h,p));u&&(a={paragraphId:l,paragraphOffset:s,handleDirection:d,startClientX:c.clientX,startClientY:c.clientY,startWidth:u.width,startHeight:u.height,aspectRatio:u.width/u.height,initialState:e.cloneState(h)},window.addEventListener("mousemove",o),window.addEventListener("mouseup",i))},stop:l}}function zP(t,e){let a=null;const n=n=>{const r=a;if(!r)return;let o=((180*Math.atan2(n.clientY-r.centerY,n.clientX-r.centerX)/Math.PI+90)%360+360)%360;n.shiftKey&&(o=15*Math.round(o/15)%360);const i=((t,e,a)=>{const n=Na(t).find(t=>t.id===e);return n?{anchor:_e(n,a),focus:_e(n,a+1)}:null})(e.state,r.paragraphId,r.paragraphOffset);i?e.applyState(t.applyRotate(((t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}))(e.state,i),o)):e.logger.warn(`${t.label} rotate:missing paragraph`,r)},r=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),o(),e.focusInput()},o=()=>{a=null,window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{start:(t,o,i,l)=>{const s=i.currentTarget.closest(".oasis-editor-selection-overlay");if(!s)return;const d=s.getBoundingClientRect();a={paragraphId:t,paragraphOffset:o,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:e.cloneState(l)},window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)},stop:o}}function NP(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y({x:0,y:0}),[l,s]=y(null);let d=null,c=null,h=null;const p=t=>{const e=Da(t);if(e.isCollapsed||e.startIndex!==e.endIndex||e.endParagraphOffset-e.startParagraphOffset!==1)return null;const a=Na(t)[e.startIndex];if(!a)return null;let n=0;for(const r of a.runs){const o=n;if(n+=r.text.length,"image"===r.kind&&1===r.text.length&&o===e.startParagraphOffset)return{paragraph:a,run:r,startOffset:o,width:r.image.width,height:r.image.height,src:da(t.document,r.image.src)}}return null},u=(e,a)=>t.resolvePositionAtSurfacePoint(e,a),f=()=>{h&&(h.remove(),h=null),document.body.style.cursor="",c=null,d=null,a(!1),r(null),s(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},g=LP({label:"image",getSelected:t=>p(t),applyResize:(t,e,a)=>function(t,e,a){return Xq(t,t=>({...t,width:Math.max(24,Math.round(e)),height:Math.max(24,Math.round(a))}))}(t,e,a),getMaxWidth:(e,a)=>$q(t.surfaceRef(),e.document,a,e.activeSectionIndex??0)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),m=zP({label:"image",applyRotate:(t,e)=>Kq(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger}),v=e=>{let n=d;if(!n){const r=c;if(!r)return;if(Math.abs(e.clientX-r.startClientX)+Math.abs(e.clientY-r.startClientY)<4)return;n={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},d=n,c=null,a(!0),h||(h=document.createElement("style"),h.setAttribute("data-oasis-image-drag-cursor",""),h.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(h)),t.logger.info(`image drag:start ${n.paragraphId}@${n.paragraphOffset} client=(${e.clientX},${e.clientY})`)}i({x:e.clientX,y:e.clientY}),r({...n}),s(u(e.clientX,e.clientY))},b=e=>{const a=d;if(a||c){if(a){const n=u(e.clientX,e.clientY);n?(t.logger.info(`image drag:done ${a.paragraphId} -> ${n.paragraphId}:${n.runId}[${n.offset}]`),t.applyTransactionalState(t=>_q(t,n),{mergeKey:gV})):t.logger.warn(`image drag:cancel ${a.paragraphId} no target at (${e.clientX},${e.clientY})`)}f(),t.focusInput()}else t.focusInput()},M=(e,n,o,l)=>{const h=o.currentTarget,u=l?{left:l.left,top:l.top,width:l.width,height:l.height}:null==h?void 0:h.getBoundingClientRect();if(!u)return;const f=p(t.state);c={paragraphId:e,paragraphOffset:n,startClientX:o.clientX,startClientY:o.clientY,src:(null==f?void 0:f.src)??"",width:(null==f?void 0:f.width)??u.width,height:(null==f?void 0:f.height)??u.height,offsetX:o.clientX-u.left,offsetY:o.clientY-u.top},d=null,i({x:o.clientX,y:o.clientY}),a(!1),r(null),s(null),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)};return{dragging:e,draggedImageInfo:n,mousePos:o,dropTargetPos:l,getSelectedImageInfo:p,startImageDrag:M,stopImageDrag:()=>{f()},stopImageResize:g.stop,stopImageRotate:m.stop,handleImageMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation();const r=ba(t.state.document).find(t=>t.id===e);r&&t.applyState(hE(t.state,{anchor:_e(r,a),focus:_e(r,a+1)})),M(e,a,n),t.focusInputAfterPointerSelection()},handleImageResizeHandleMouseDown:(e,a,n,r)=>{r.preventDefault(),r.stopPropagation(),g.start(e,a,n,r,t.state)},handleImageRotateHandleMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation(),m.start(e,a,n,t.state)}}}function OP(t){const[e,a]=y(void 0),n=()=>{a(void 0)};x(()=>{Ga(t.state().selection)||n()});const r=()=>{const a=zu(t.state()),n=e();return Ga(t.state().selection)&&n?{...a,bold:n.bold??a.bold,italic:n.italic??a.italic,underline:n.underline??a.underline,underlineStyle:void 0!==n.underlineStyle&&null!==n.underlineStyle?String(n.underlineStyle):a.underlineStyle,strike:n.strike??a.strike,superscript:n.superscript??a.superscript,subscript:n.subscript??a.subscript,fontFamily:n.fontFamily??a.fontFamily,fontSize:void 0!==n.fontSize&&null!==n.fontSize?String(n.fontSize):a.fontSize,color:n.color??a.color,highlight:n.highlight??a.highlight,textShading:n.shading??a.textShading,link:n.link??a.link,characterStyleId:void 0!==n.styleId&&null!==n.styleId?String(n.styleId):a.characterStyleId}:a};return{pendingCaretTextStyle:e,clearPendingCaretTextStyle:n,toolbarStyleState:r,applyToolbarValueStyleCommand:(e,n)=>{if(Ga(t.state().selection))return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return null==e||""===e?delete n[t]:n[t]=e,Object.keys(n).length>0?n:void 0})})(e,n),void t.focusInput();t.commandsController().applyValueStyleCommand(e,n)},applyToolbarBooleanStyleCommand:e=>{if(Ga(t.state().selection)){const n=!r()[e];return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return n[t]=e,"superscript"===t&&e&&(n.subscript=!1),"subscript"===t&&e&&(n.superscript=!1),n})})(e,n),void t.focusInput()}t.commandsController().applyBooleanStyleCommand(e)}}}function qP(t){const[e,a]=y(""),[n,r]=y(""),[o,i]=y({matchCase:!1,wholeWord:!1}),[l,s]=y([]),[d,c]=y(-1),[h,p]=y(!1);x(A([()=>t.state.document,e,o],([t,e,a])=>{const n=function(t,e,a={}){if(!e)return[];const n=[],r=ba(t),{matchCase:o=!1,wholeWord:i=!1}=a,l=o?"g":"gi";let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const d=new RegExp(s,l);return r.forEach((t,e)=>{const a=Je(t);let r;for(d.lastIndex=0;null!==(r=d.exec(a));){const a=r.index,o=r.index+r[0].length;n.push({anchor:_e(t,a),focus:_e(t,o),paragraphIndex:e}),r.index===d.lastIndex&&d.lastIndex++}}),n}(t,e,a);s(n),0===n.length?c(-1):(d()>=n.length||-1===d())&&c(0)}));const u=e=>{const a=l()[e];a&&t.applyState(hE(t.state,{anchor:a.anchor,focus:a.focus}))};return{searchTerm:e,setSearchTerm:a,replaceTerm:n,setReplaceTerm:r,findOptions:o,setFindOptions:i,matches:l,currentIndex:d,findNext:()=>{const t=l().length;if(0===t)return;const e=(d()+1)%t;c(e),u(e)},findPrevious:()=>{const t=l().length;if(0===t)return;const e=(d()-1+t)%t;c(e),u(e)},replace:()=>{if(0===l().length||-1===d())return;const e=l()[d()];t.applyTransactionalState(t=>mR(hE(t,{anchor:e.anchor,focus:e.focus}),n()),{mergeKey:SV})},replaceAll:()=>{const e=l();0!==e.length&&(t.applyTransactionalState(t=>{let a=t;for(let r=e.length-1;r>=0;r--){const t=e[r];a=hE(a,{anchor:t.anchor,focus:t.focus}),a=mR(a,n())}return a},{mergeKey:AV}),p(!1),t.focusInput())},isOpen:h,setIsOpen:p}}function PP(t,e,a,n,r,o){const i=t+a,l=e+n;return 1e3*(o<e?e-o:o>l?o-l:0)+(r<t?t-r:r>i?r-i:0)}function WP(t,e,a){if(0===t.slots.length)return{offset:t.startOffset,score:Number.POSITIVE_INFINITY};let n=t.slots[0].offset,r=Number.POSITIVE_INFINITY,o=t.slots[0].left,i=t.slots[0].top,l=t.slots[0].height;for(const s of t.slots){const t=1e3*(a<s.top?s.top-a:a>s.top+s.height?a-(s.top+s.height):0)+Math.abs(e-s.left);t<r&&(r=t,n=s.offset,o=s.left,i=s.top,l=s.height)}return{offset:n,score:r,slotLeft:o,slotTop:i,slotHeight:l}}function BP(t,e,a){let n=t.startOffset,r=Number.POSITIVE_INFINITY;for(const o of t.lines){const{offset:t,score:i}=WP(o,e,a);i<r&&(r=i,n=t)}return Math.max(t.startOffset,Math.min(n,t.endOffset))}function FP(t,e,a){return t>=a.left&&t<=a.left+a.width&&e>=a.top&&e<=a.top+a.height}function HP(t){var e,a,n;const{snapshot:r,state:o}=t,i=t.pierce??!1,l=t.zoomFactor&&t.zoomFactor>0?t.zoomFactor:1,s=r.surfaceRect,d=s.left+(t.clientX-s.left)/l,c=s.top+(t.clientY-s.top)/l,h=function(t,e,a){if(0===t.length)return null;let n=t[0],r=Number.POSITIVE_INFINITY;for(const o of t){const t=PP(o.left,o.top,o.width,o.height,e,a);t<r&&(r=t,n=o)}return n}(r.pages,d,c);if(!h)return null;const p=function(t,e){const a=e-t.top;return a<t.bodyTop?"header":void 0!==t.footnoteSeparatorTop&&a>=t.footnoteSeparatorTop&&a<(t.footerTop??t.height)?"footnote":a>=t.bodyBottom?"footer":"main"}(h,c),u=function(t,e,a,n,r,o){for(let i=t.floatingTextBoxes.length-1;i>=0;i-=1){const l=t.floatingTextBoxes[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&n>=l.left&&n<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(r,h.index,p,d,c,i);if(u){const t=r.paragraphsById.get(u.paragraphId)??[],a=t.find(t=>t.pageIndex===h.index&&t.zone===p&&u.startOffset>=t.startOffset&&u.startOffset<=t.endOffset)??t[0];if(a){const t=Math.max(a.startOffset,Math.min(u.startOffset,a.endOffset)),n=_e(a.paragraph,t);return{zone:p,footnoteId:a.footnoteId,paragraphId:u.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(e=a.tableCell)?void 0:e.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},textBox:{paragraphId:u.paragraphId,paragraphOffset:t,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const f=function(t,e,a,n,r,o){for(let i=t.floatingImages.length-1;i>=0;i-=1){const l=t.floatingImages[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&FP(n,r,l))return l}for(const i of t.inlineImages)if(i.pageIndex===e&&i.zone===a&&FP(n,r,i))return i;return null}(r,h.index,p,d,c,i);if(f){const t=r.paragraphsById.get(f.paragraphId)??[],e=t.find(t=>t.pageIndex===h.index&&t.zone===p&&f.startOffset>=t.startOffset&&f.startOffset<=t.endOffset)??t[0];if(e){const t=Math.max(e.startOffset,Math.min(f.startOffset,e.endOffset)),n=_e(e.paragraph,t);return{zone:p,footnoteId:e.footnoteId,paragraphId:f.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(a=e.tableCell)?void 0:a.anchorPosition,caretViewport:{left:f.left,top:f.top,height:f.height},image:{paragraphId:f.paragraphId,paragraphOffset:t,startOffset:f.startOffset,endOffset:f.endOffset,left:f.left,top:f.top,width:f.width,height:f.height}}}}const g=function(t,e,a){if(0===t.length)return null;let n=null;for(const i of t)for(const t of i.lines){const r=t.top-2,o=t.top+t.height+2;if(a<r||a>o)continue;const{offset:l,score:s,slotLeft:d,slotTop:c,slotHeight:h}=WP(t,e,a);(!n||s<n.score)&&(n={paragraph:i,offset:l,score:s,caretViewport:void 0!==d&&void 0!==c&&void 0!==h?{left:d,top:c,height:h}:void 0})}if(n)return{paragraph:n.paragraph,offset:n.offset,caretViewport:n.caretViewport};let r=null,o=Number.POSITIVE_INFINITY;for(const i of t){const t=PP(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),e,a);t<o&&(o=t,r=i)}return r?{paragraph:r,offset:BP(r,e,a),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(r.paragraphs.filter(t=>t.pageIndex===h.index&&t.zone===p),d,c);if(!g){const t=o.selection.focus.paragraphId,e=o.selection.focus.offset,a=function(t,e,a,n,r){const o=t.unsupportedRegions.find(t=>t.pageIndex===e&&t.zone===a&&n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height);return(null==o?void 0:o.reason)??null}(r,h.index,p,d,c);return{zone:p,paragraphId:t,paragraphOffset:e,position:{...o.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:a??"zone-without-paragraph"}}const m=g.paragraph,v=Math.max(0,Math.min(g.offset,m.textLength)),b=_e(m.paragraph,v);return{zone:p,footnoteId:m.footnoteId,paragraphId:m.paragraphId,paragraphOffset:v,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(n=m.tableCell)?void 0:n.anchorPosition,caretViewport:g.caretViewport}}function UP(t){return{resolveSurfaceHitAtPoint:(e,a,n={})=>{const r=t.surfaceRef();if(!r)return null;const o=t.state(),i=t.zoomFactor(),l=t.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:o,documentLayout:t.documentLayout(),zoomFactor:i});if(function(t){aV&&(rV=t?function(t){return{surfaceRect:{left:t.surfaceRect.left,top:t.surfaceRect.top,width:t.surfaceRect.width,height:t.surfaceRect.height},pages:(e=t.pages,e.map(t=>({index:t.index,left:t.left,top:t.top,width:t.width,height:t.height,bodyTop:t.bodyTop,bodyBottom:t.bodyBottom}))),paragraphs:t.paragraphs.map(t=>{return{paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,textLength:t.textLength,left:t.left,top:t.top,width:t.width,height:t.height,lines:(e=t.lines,e.map(t=>{return{startOffset:t.startOffset,endOffset:t.endOffset,top:t.top,height:t.height,slots:(e=t.slots,e.map(t=>({offset:t.offset,left:t.left,top:t.top,height:t.height})))};var e})),tableCell:t.tableCell?{tableId:t.tableCell.tableId,rowIndex:t.tableCell.rowIndex,cellIndex:t.tableCell.cellIndex,left:t.tableCell.left,top:t.tableCell.top,width:t.tableCell.width,height:t.tableCell.height}:void 0,verticalMode:t.verticalMode};var e}),inlineImages:t.inlineImages.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height})),inlineTextBoxes:t.inlineTextBoxes.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height,rotation:t.rotation})),unsupportedRegions:t.unsupportedRegions.map(t=>({...t}))};var e}(t):null)}(l),!l)return sV(null),null;const s=HP({snapshot:l,state:o,clientX:e,clientY:a,pierce:n.pierce??!1,zoomFactor:i});return sV(s),s}}}const GP=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],DP=new Map;function jP(){return GP.map(t=>({...t}))}const ZP=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function KP(t,e,a){const[n,r]=t,[o,i]=e,[l,s]=a,d=l-o,c=s-i,h=d*d+c*c;if(0===h)return Math.hypot(n-o,r-i);return Math.abs(d*(i-r)-c*(o-n))/Math.sqrt(h)}function XP(t,e){if(t.length<3)return t.slice();let a=0,n=0;const r=t[0],o=t[t.length-1];for(let s=1;s<t.length-1;s+=1){const e=KP(t[s],r,o);e>a&&(a=e,n=s)}if(a<=e)return[r,o];const i=XP(t.slice(0,n+1),e),l=XP(t.slice(n),e);return[...i.slice(0,-1),...l]}function YP(t,e,a){let n=0;for(let s=0;s<t.length;s+=1)1===t[s]&&(n+=1);if(e<=0||a<=0||0===n||n/(e*a)>=.985)return jP();const r=function(t,e,a){const n=(n,r)=>n>=0&&n<e&&r>=0&&r<a&&1===t[r*e+n];let r=-1,o=-1;for(let h=0;h<a&&o<0;h+=1)for(let a=0;a<e;a+=1)if(1===t[h*e+a]){r=a,o=h;break}if(r<0)return[];const i=[];let l=r,s=o,d=6;const c=e*a*4;for(let h=0;h<c;h+=1){let t=!1;for(let e=1;e<=8;e+=1){const a=(d+e)%8,[r,o]=ZP[a],c=l+r,h=s+o;if(n(c,h)){i.push([l,s]),d=(a+4)%8,l=c,s=h,t=!0;break}}if(!t){i.push([l,s]);break}if(l===r&&s===o&&i.length>1)break}return i}(t,e,a);if(r.length<3)return jP();const o=.012*Math.max(e,a);let i=XP(r,o),l=o;for(;i.length>40;)l*=1.6,i=XP(r,l);return i.length<3?jP():i.map(([t,n])=>({x:Math.min(1,Math.max(0,t/e)),y:Math.min(1,Math.max(0,n/a))}))}function JP(t){const e=t.src,a=DP.get(e);if(a)return a.map(t=>({...t}));const n=function(t){const e=t.naturalWidth||t.width,a=t.naturalHeight||t.height;if(!e||!a)return null;const n=Math.min(1,256/Math.max(e,a)),r=Math.max(1,Math.round(e*n)),o=Math.max(1,Math.round(a*n)),i=document.createElement("canvas");i.width=r,i.height=o;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(t,0,0,r,o);try{s=l.getImageData(0,0,r,o).data}catch{return null}const d=new Uint8Array(r*o);let c=0;for(let h=0;h<d.length;h+=1)s[4*h+3]>=128&&(d[h]=1,c+=1);return{mask:d,width:r,height:o,foreground:c}}(t);if(!n)return jP();const r=YP(n.mask,n.width,n.height);return DP.set(e,r),r.map(t=>({...t}))}function QP(t){const{state:e,resetTransactionGrouping:a,applyTransactionalState:n,focusInput:r}=t,o=()=>Zq(e())?"image":vP(e())?"textBox":null,i=(t,e)=>{const i=o();i&&(a(),n(t=>e(t,i),{mergeKey:t}),r())},l=(t,a)=>{const r=da(e().document,a),o=e=>{const a=JP(e);n(e=>function(t,e,a){const n=Na(t);let r=!1;const o=n.map(t=>t.runs.some(t=>t.id===e&&"image"===t.kind)?{...MA(t),runs:t.runs.map(t=>{if(t.id!==e||"image"!==t.kind)return yA(t);r=!0;const n={...t.image};return a&&a.length>0?n.wrapPolygon=a:delete n.wrapPolygon,{...t,image:n}})}:MA(t));return r?rR(t,o,cR(o,Da(t))):t}(e,t,a),{mergeKey:MV})},i=wp(r,()=>{i.naturalWidth>0&&o(i)});i.complete&&i.naturalWidth>0&&o(i)};return{target:o,preset:()=>{const t=o();return"image"===t?function(t){const e=Zq(t),a=e&&ye(e.run);return a?Gq(a.floating):null}(e()):"textBox"===t?function(t){const e=vP(t),a=e&&Me(e.run);return a?Gq(a.floating):null}(e()):null},fixedPosition:()=>{const t=o();return"image"===t?function(t){const e=Zq(t),a=e&&ye(e.run);return jq(null==a?void 0:a.floating)}(e()):"textBox"===t&&function(t){const e=vP(t),a=e&&Me(e.run);return jq(null==a?void 0:a.floating)}(e())},setPreset:t=>{if(i(UV,(e,a)=>"image"===a?function(t,e){return Yq(t,t=>Uq(t,e))}(e,t):function(t,e){return yP(t,t=>Uq(t,e))}(e,t)),"tight"===t||"through"===t){const t=Zq(e()),a=t&&ye(t.run);a&&!a.wrapPolygon&&l(t.run.id,a.src)}},setFixedPosition:t=>i(GV,(e,a)=>"image"===a?function(t,e){return Yq(t,t=>t?Dq(t,e):t)}(e,t):function(t,e){return yP(t,t=>t?Dq(t,e):t)}(e,t))}}function _P(t,e){const a=function(t){return ca(t.document).flatMap(t=>[...t.header??[],...t.blocks,...t.footer??[]])}(t).find(t=>"table"===t.type&&t.id===e);return a??null}function $P(t,e,a,n,r,o){const i=function(t,e,a,n,r){const o=n.getCanvasLayoutSnapshot({surface:t,state:e,documentLayout:a,zoomFactor:r});if(!o)return[];const i=new Map,l=new Map;for(const d of o.paragraphs){const t=d.tableCell;if(!t)continue;const e=`${d.pageIndex}:${t.rowIndex}:${t.cellIndex}`,a=i.get(t.tableId)??new Map;let n=a.get(e);n||(n={tableId:t.tableId,rowIndex:t.rowIndex,cellIndex:t.cellIndex,pageIndex:d.pageIndex,left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height,width:t.width,height:t.height,contentMinWidth:0,contentMinHeight:0},a.set(e,n),i.set(t.tableId,a));const r=d.lines.flatMap(t=>t.slots.map(t=>t.left)),o=d.lines.map(t=>t.top+t.height),s=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,h=d.lines.length>0?d.lines[0].top:d.top,p=o.length>0?Math.max(...o):d.top+d.height,u=`${t.tableId}:${d.pageIndex}:${t.rowIndex}:${t.cellIndex}`,f=l.get(u);f?(f.left=Math.min(f.left,s),f.top=Math.min(f.top,h),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):l.set(u,{left:s,top:h,right:c,bottom:p})}for(const[d,c]of i.entries())for(const t of c.values()){const e=l.get(`${d}:${t.pageIndex}:${t.rowIndex}:${t.cellIndex}`);e&&(t.contentMinWidth=Math.max(0,e.right-e.left),t.contentMinHeight=Math.max(0,e.bottom-e.top))}const s=[];for(const[d,c]of i.entries()){const t=Array.from(c.values());if(0===t.length)continue;const e=Math.min(...t.map(t=>t.left)),a=Math.min(...t.map(t=>t.top)),n=Math.max(...t.map(t=>t.right)),r=Math.max(...t.map(t=>t.bottom));s.push({tableId:d,cells:t,bounds:{left:e,top:a,right:n,bottom:r,width:Math.max(1,n-e),height:Math.max(1,r-a)}})}return s}(e,a,n,r,o);if(0===i.length)return null;let l=null;for(const c of i)for(const e of c.cells){const a=t.clientY>=e.top-4&&t.clientY<=e.bottom+4,n=t.clientX>=e.left-4&&t.clientX<=e.right+4;if(a){const a=Math.abs(t.clientX-e.left);a<=4&&(!l||a<l.distance)&&(l={geometry:c,cell:e,side:"left",distance:a});const n=Math.abs(t.clientX-e.right);n<=4&&(!l||n<l.distance)&&(l={geometry:c,cell:e,side:"right",distance:n})}if(n){const a=Math.abs(t.clientY-e.top);a<=4&&(!l||a<l.distance)&&(l={geometry:c,cell:e,side:"top",distance:a});const n=Math.abs(t.clientY-e.bottom);n<=4&&(!l||n<l.distance)&&(l={geometry:c,cell:e,side:"bottom",distance:n})}}if(!l)return null;const s=_P(a,l.geometry.tableId);if(!s)return null;const d=Io(s).find(t=>t.rowIndex===l.cell.rowIndex&&t.cellIndex===l.cell.cellIndex);return d?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:d,tableGeometry:l.geometry}:null}const tW=1/.75,eW=10;function aW(t){return.75*t}function nW(t){return t*tW}function rW(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e)return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?aW(t):null}if(e.includes("%"))return null;if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function oW(t){var e,a,n,r,o;return("number"==typeof(null==(e=t.style)?void 0:e.padding)&&Number.isFinite(t.style.padding)?2*Math.max(0,nW(t.style.padding)):Math.max(0,(void 0!==(null==(a=t.style)?void 0:a.paddingLeft)?nW(t.style.paddingLeft):7.2)+(void 0!==(null==(n=t.style)?void 0:n.paddingRight)?nW(t.style.paddingRight):7.2)))+((null==(r=t.style)?void 0:r.borderLeft)?Math.max(0,nW(t.style.borderLeft.width)):1)+((null==(o=t.style)?void 0:o.borderRight)?Math.max(0,nW(t.style.borderRight.width)):1)}function iW(t,e,a){if("row"!==e.type)return t;const n=e.initialRowHeightPx??nW(eW),r=Math.max(nW(eW),e.minRowHeightPx??nW(eW)),o=Math.max(eW,aW(Math.max(r,n+a)));return function(t,e,a,n){const r=r=>{if(r.id!==e)return r;const o=[...r.rows],i=o[a];if(i){let e=i.style;t.trackChangesEnabled&&!(null==e?void 0:e.propertyRevision)&&(e={...e??{},propertyRevision:{...VR(),type:"property",previous:{...e??{}}}}),o[a]={...i,style:RR(e,"height",n)}}return{...r,rows:o}};return ER(t,t=>LR(t,r))}(t,e.tableId,e.index,o)}function lW(t){const e=t();if(!e)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const a=e.getBoundingClientRect();return{left:a.left,top:a.top,width:Math.max(0,a.width),height:Math.max(0,a.height)}}function sW(t){t?(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 dW(){document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")}function cW(t){sW(t)}function hW(t){const[e,a]=y(null),n=n=>{const r=e();r&&(a({...r,currentPos:"column"===r.type?n.clientX:n.clientY,guideBounds:lW(t.viewportRef)}),cW("column"===r.type))},r=o=>{var i;const l=e();if(!l)return;const s=(null==(i=t.zoomFactor)?void 0:i.call(t))??1,d=(("column"===l.type?o.clientX:o.clientY)-l.initialPos)/s;Math.abs(d)>=2&&t.applyTransactionalState(t=>"row"===l.type?iW(t,l,d):function(t,e,a){var n;if("column"!==e.type)return t;const r=aW(a),o=e.maxColumnIndex??e.index,i={...e.columnWidthsPt??{}};for(let m=0;m<=o;m+=1)void 0===i[m]&&(i[m]=eW);const l=e.minColumnWidthsPx??{},s=i[e.index]??eW,d=Math.max(eW,aW(l[e.index]??nW(eW)));if(e.resizeFromLeftEdge){const a=Math.max(0,e.initialTableIndentLeftPt??0);let n=Math.max(d,s-r),o=s-n;a+o<0&&(o=-a,n=s-o),i[e.index]=n;const l=Object.values(i).reduce((t,e)=>t+e,0),c=Math.max(0,a+o);return GR(t,e.tableId,i,l,c)}let c=Math.max(d,s+r);const h=e.index===o;if(h)i[e.index]=c;else{const t=e.index+1,a=i[t]??eW,n=Math.max(eW,aW(l[t]??nW(eW)));let r=a-(c-s);r<n&&(r=n,c=s+(a-n),c=Math.max(d,c)),i[e.index]=c,i[t]=r}const p=Object.values(i).reduce((t,e)=>t+e,0),u=_P(t,e.tableId),f=rW(null==(n=null==u?void 0:u.style)?void 0:n.width),g=h?p:null!==f?f:void 0;return GR(t,e.tableId,i,g)}(t,l,d)),a(null),dW(),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{resizing:e,handleMouseMove:a=>{var n;if(e())return void cW("column"===e().type);const r=t.surfaceRef();if(!r)return void dW();const o=$P(a,r,t.state(),t.documentLayout(),t.canvasSnapshotProvider,null==(n=t.zoomFactor)?void 0:n.call(t));o?sW("left"===o.side||"right"===o.side):dW()},handleMouseDown:e=>{var o,i;const l=t.surfaceRef();if(!l)return!1;const s=$P(e,l,t.state(),t.documentLayout(),t.canvasSnapshotProvider,null==(o=t.zoomFactor)?void 0:o.call(t));if(!s)return!1;const d=t.state(),c=Io(s.tableNode);if("left"===s.side||"right"===s.side){const o="left"===s.side&&0===s.layoutEntry.visualColumnIndex,l=o?0:"left"===s.side?s.layoutEntry.visualColumnIndex-1:s.layoutEntry.visualColumnIndex+s.layoutEntry.colSpan-1;if(l<0)return!1;const h="left"===s.side?s.rect.left:s.rect.right,{widthsPt:p,maxColumnIndex:u}=function(t,e,a){const n=Math.max(1,...e.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),r=n-1,o=Array(n).fill(a.bounds.width/n),i=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));if(t.gridCols&&t.gridCols.length>=n)for(let s=0;s<n;s+=1)o[s]=Math.max(1,nW(t.gridCols[s]));else for(const s of e){if(1!==s.colSpan)continue;const t=i.get(`${s.rowIndex}:${s.cellIndex}`);t&&(o[s.visualColumnIndex]=Math.max(1,t.width))}const l={};for(let s=0;s<n;s+=1)l[s]=Math.max(eW,aW(o[s]));return{widthsPt:l,maxColumnIndex:r}}(s.tableNode,c,s.tableGeometry),f=function(t,e,a,n){var r;const o=nW(eW),i={},l=new Map(n.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(const s of a){if(1!==s.colSpan)continue;if(!l.get(`${s.rowIndex}:${s.cellIndex}`))continue;const a=null==(r=e.rows[s.rowIndex])?void 0:r.cells[s.cellIndex];if(!a)continue;const n=s.visualColumnIndex,d=i[n]??o,c=a.blocks.reduce((e,a)=>Math.max(e,Os(a,t.document.styles)),1);i[n]=Math.max(d,c+oW(a)+12,o)}return i}(d,s.tableNode,c,s.tableGeometry);return a({type:"column",tableId:s.tableId,index:l,initialPos:h,currentPos:h,columnWidthsPt:p,maxColumnIndex:u,minColumnWidthsPx:f,resizeFromLeftEdge:o,initialTableIndentLeftPt:rW(null==(i=s.tableNode.style)?void 0:i.indentLeft)??0,guideBounds:lW(t.viewportRef)}),cW(!0),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}const h=function(t,e,a){var n,r;const o=Math.max(1,t.rows.length),i=a.bounds.height/o,l=Array(o).fill(i),s=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(let d=0;d<o;d+=1){const a=rW(null==(r=null==(n=t.rows[d])?void 0:n.style)?void 0:r.height);if(null!==a){l[d]=Math.max(1,nW(a));continue}const o=e.find(t=>t.rowIndex===d&&1===t.rowSpan);if(o){const t=s.get(`${o.rowIndex}:${o.cellIndex}`);t&&(l[d]=Math.max(1,t.height))}}return l}(s.tableNode,c,s.tableGeometry),p="top"===s.side?s.layoutEntry.visualRowIndex-1:s.layoutEntry.visualRowIndex+s.layoutEntry.rowSpan-1;if(p<0||p>=h.length)return!1;const u="top"===s.side?s.rect.top:s.rect.bottom,f=function(t,e,a,n){const r=t.rows[n];if(!r)return nW(eW);const o=nW(eW);let i=o;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const t=e.find(t=>t.rowIndex===n&&t.cellIndex===l);if(!t||1!==t.rowSpan)continue;const o=a.cells.find(t=>t.rowIndex===n&&t.cellIndex===l);o&&(i=Math.max(i,o.contentMinHeight+4))}return Math.max(o,i)}(s.tableNode,c,s.tableGeometry,p);return a({type:"row",tableId:s.tableId,index:p,initialPos:u,currentPos:u,initialRowHeightPx:h[p],minRowHeightPx:f,guideBounds:lW(t.viewportRef)}),cW(!1),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}}}function pW(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(null),[l,s]=y(0),[d,c]=y(0),[h,p]=y({x:0,y:0}),u=r=>{var o;if(p({x:r.clientX,y:r.clientY}),!e()){if(!(Math.abs(r.clientY-l())>4))return;a(!0),document.body.style.cursor="grabbing"}document.body.style.cursor="grabbing";const s=t.resolvePositionAtSurfacePoint(r.clientX,r.clientY),d=null==(o=n())?void 0:o.tableId;if(s&&d){const e=t.state(),a=xa(e.document,s.paragraphId,Ea(e));if(a){const t=za(e,a.zone)[a.blockIndex];if(t&&"table"===t.type&&t.id===d)return void i(null)}}i(s)},f=o=>{const s=n();if(e()){const e=t.resolvePositionAtSurfacePoint(o.clientX,o.clientY),a=null==s?void 0:s.tableId;a&&t.applyTransactionalState(t=>{var n;const r=(()=>{for(const e of["main","header","footer"]){const n=za(t,e).find(t=>"table"===t.type&&t.id===a);if(n)return n}})();if("table"===(null==r?void 0:r.type)&&(null==(n=r.style)?void 0:n.floating)){const e=r.style.floating;return FR(t,a,"floating",{...e,x:(e.x??0)+(o.clientX-d())*Re,y:(e.y??0)+(o.clientY-l())*Re,xAlign:void 0,yAlign:void 0})}return e?CR(t,a,e):t})}a(!1),r(null),i(null),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",f),document.body.style.cursor="",t.focusInput()};return{dragging:e,draggedTableInfo:n,mousePos:h,dropTargetPos:o,handleMouseDown:(t,e)=>{e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect(),o=n;r({tableId:t,width:o.width,height:o.height,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top}),s(e.clientY),c(e.clientX),p({x:e.clientX,y:e.clientY}),a(!1),i(null),window.addEventListener("mousemove",u),window.addEventListener("mouseup",f)}}}function uW(t){return/[\p{L}\p{N}_]/u.test(t)}function fW(t,e){if(0===t.length)return{start:0,end:0};const a=Math.max(0,Math.min(e,t.length)),n=a===t.length?Math.max(0,a-1):a,r=t[n];if(!r||!uW(r))return{start:a,end:Math.min(t.length,a+1)};let o=n,i=n+1;for(;o>0&&uW(t[o-1]);)o-=1;for(;i<t.length&&uW(t[i]);)i+=1;return{start:o,end:i}}function gW(t,e,a){const n=ba(t.document).filter(e=>{const n=Ma(t.document,e.id);return null!==n&&n.zone===a}),r=n.findIndex(t=>t.id===e.id),o=r>=0?n[r+1]:void 0;return{start:_e(e,0),end:o?_e(o,0):_e(e,Je(e).length)}}function mW(t){let e=null,a=null,n=null,r=0,o=0,i=0,l=0,s=0,d=null,c=0,h=0,p=0;const u=(e,a,n,r)=>{var o;const i=a!==(e.activeZone??"main"),l="footnote"===a&&r?null==(o=Ma(n.document,r.paragraphId))?void 0:o.footnoteId:void 0,s="footnote"===a&&l!==e.activeFootnoteId;if(!i&&!s)return void t.applyState(n);let d=n.document,c=e.activeSectionIndex??0;if(!d.sections||0===d.sections.length){const t=on("header"),e=on("footer");d={...d,sections:[{id:"section:1",blocks:[],pageSettings:Ue(d.pageSettings??He),header:[t],footer:[e]}]},c=0}const h=d.sections,p=h[c];let u=p.header,f=p.footer,g=null;if("header"===a)if(u&&0!==u.length){const t=u[0];g="paragraph"===t.type?t:pa(t)[0]??null}else g=on("header"),u=[g];else if("footer"===a)if(f&&0!==f.length){const t=f[0];g="paragraph"===t.type?t:pa(t)[0]??null}else g=on("footer"),f=[g];if(u!==p.header||f!==p.footer){const t=[...h];t[c]={...p,header:u,footer:f},d={...d,sections:t}}const m=r||(g?_e(g,0):n.selection.anchor);t.applyState({...n,document:d,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:a,activeFootnoteId:"footnote"===a?l:void 0})},f=e=>{const a=t.state(),n=a.selection,r=Ea(a),o=xa(a.document,n.anchor.paragraphId,r),i=xa(a.document,n.focus.paragraphId,r),l=o?`b${o.blockIndex}r${o.rowIndex}c${o.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";t.logger.debug(`${e} ${n.anchor.paragraphId}[${n.anchor.offset}]→${n.focus.paragraphId}[${n.focus.offset}] [${l}→${s}]`)},g=()=>{var t;e=null,n=null,null!==a&&(t=a,"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(t):window.cancelAnimationFrame(t),a=null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},m=()=>{if(a=null,!e)return;const r=n;if(n=null,!r)return;const o=t.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!(null==o?void 0:o.resolvedFromParagraph))return;const i=t.state(),l=hE(i,{anchor:e,focus:o.position});u(i,o.zone,l,o.position),f("selection:drag")},v=t=>{var r;e&&(n={clientX:t.clientX,clientY:t.clientY},null===a&&(r=m,a="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>r()):globalThis.setTimeout(r,16)))},b=()=>{f("selection:end"),g(),t.focusInputAfterPointerSelection()},y=a=>{var n;if(0!==a.button)return;const f=Date.now(),m=Math.hypot(a.clientX-i,a.clientY-l),y=f-o<=450&&m<=6&&a.button===s;r=y?r+1:1,o=f,i=a.clientX,l=a.clientY,s=a.button;const M=Math.max(a.detail,r),x=t.state();if(t.clearPendingCaretTextStyle(),t.tableResize.handleMouseDown(a))return;a.preventDefault(),t.imageOps.stopImageDrag(),t.imageOps.stopImageResize(),t.clearPreferredColumn(),t.resetTransactionGrouping();const w=t.resolveSurfaceHitAtPoint(a.clientX,a.clientY,{pierce:a.altKey});if(d=w,c=f,h=a.clientX,p=a.clientY,!w)return void t.focusInputAfterPointerSelection();if(null==(n=t.textDrag)?void 0:n.tryStartTextDrag(a,w))return e=null,g(),void t.focusInputAfterPointerSelection();const S=t.getParagraphById(x.document,w.paragraphId);w.zone!==(x.activeZone??"main")?((a,n,r)=>{if(r<2)return e=null,g(),void t.focusInputAfterPointerSelection();e=null,n.resolvedFromParagraph?u(a,n.zone,{...a,selection:{anchor:{...n.position},focus:{...n.position}}},n.position):u(a,n.zone,a),g(),t.focusInputAfterPointerSelection()})(x,w,M):w.textBox?((a,n)=>{const r=t.getParagraphById(a.document,n.textBox.paragraphId);if(!r)return void t.focusInputAfterPointerSelection();e=null;const o=_e(r,n.textBox.startOffset),i=_e(r,n.textBox.endOffset);u(a,n.zone,hE(a,{anchor:o,focus:i}),o),g(),t.focusInputAfterPointerSelection()})(x,w):w.image?((a,n,r)=>{const o=t.getParagraphById(a.document,n.image.paragraphId);if(!o)return void t.focusInputAfterPointerSelection();e=null;const i=_e(o,n.image.startOffset),l=_e(o,n.image.endOffset);u(a,n.zone,hE(a,{anchor:i,focus:l}),i),g(),t.imageOps.startImageDrag(n.image.paragraphId,n.image.startOffset,r,{left:n.image.left,top:n.image.top,width:n.image.width,height:n.image.height}),t.focusInputAfterPointerSelection()})(x,w,a):a.shiftKey&&w.resolvedFromParagraph?((a,n)=>{e=a.selection.anchor,u(a,n.zone,hE(a,{anchor:a.selection.anchor,focus:n.position}),n.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()})(x,w):M>=3&&S?((a,n,r)=>{e=null;const o=gW(a,r,n.zone);u(a,n.zone,hE(a,{anchor:o.start,focus:o.end}),o.start),g(),t.focusInputAfterPointerSelection()})(x,w,S):2===M&&S?((a,n,r)=>{e=null;const o=fW(Je(r),n.paragraphOffset),i=_e(r,o.start),l=_e(r,o.end);u(a,n.zone,hE(a,{anchor:i,focus:l}),i),g(),t.focusInputAfterPointerSelection()})(x,w,S):w.resolvedFromParagraph?(e=w.position,u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()):t.focusInputAfterPointerSelection()};return{handleSurfaceMouseDown:y,handleSurfaceClick:a=>{if(a.detail<3)return;a.preventDefault();const n=t.state(),r=Math.hypot(a.clientX-h,a.clientY-p),o=Date.now()-c<=600&&r<=8?d:t.resolveSurfaceHitAtPoint(a.clientX,a.clientY);if(!(null==o?void 0:o.resolvedFromParagraph))return void t.focusInputAfterPointerSelection();const i=t.getParagraphById(n.document,o.paragraphId);if(!i)return void t.focusInputAfterPointerSelection();e=null;const l=gW(n,i,o.zone);u(n,o.zone,hE(n,{anchor:l.start,focus:l.end}),l.start),g(),t.focusInputAfterPointerSelection()},handleSurfaceDblClick:t=>{t.preventDefault()},handleParagraphMouseDown:(t,e)=>{0===e.button&&(e.preventDefault(),y(e))},stopDragging:g}}function vW(t,e){const a=Da(t);if(a.isCollapsed)return!1;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(r<a.startIndex||r>a.endIndex)return!1;const o=n[r];if(!o)return!1;const i=$e(o,e);return!(r===a.startIndex&&i<a.startParagraphOffset)&&!(r===a.endIndex&&i>a.endParagraphOffset)}function bW(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(!1),[l,s]=y(null),[d,c]=y(null);let h=null,p=null,u=null;const f=()=>{var l;null==(l=t.logger)||l.info("text-drag:stop",{dragging:e(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null,copyMode:o()}),h=null,u=null,a(!1),r(null),i(!1),s(null),c(null),p&&(p.remove(),p=null),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",m)},g=n=>{var o,l,d;if(!h)return;const f=n.ctrlKey||n.metaKey;if(i(f),!e()){const e=Math.abs(n.clientX-h.x),r=Math.abs(n.clientY-h.y);if(e+r<4)return;null==(o=t.logger)||o.info("text-drag:activate",{start:h,at:{x:n.clientX,y:n.clientY},deltaX:e,deltaY:r}),a(!0),p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent="*, *::before, *::after { cursor: 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 !important; }",document.head.appendChild(p))}s({x:n.clientX,y:n.clientY});const g=t.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!(null==g?void 0:g.resolvedFromParagraph))return null==(l=t.logger)||l.debug("text-drag:hit-miss",{x:n.clientX,y:n.clientY}),r(null),void c(null);const m=g.tableCellAnchorPosition??g.position,v=`${m.paragraphId}:${m.runId}[${m.offset}]|${g.zone}|src=${g.tableCellAnchorPosition?"cell-anchor":"hit"}`;v!==u&&(null==(d=t.logger)||d.info("text-drag:target",{x:n.clientX,y:n.clientY,zone:g.zone,resolvedFromParagraph:g.resolvedFromParagraph,paragraphId:g.paragraphId,paragraphOffset:g.paragraphOffset,hitPosition:`${g.position.paragraphId}:${g.position.runId}[${g.position.offset}]`,target:`${m.paragraphId}:${m.runId}[${m.offset}]`,source:g.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),u=v),r(m),c(g.caretViewport??null)},m=a=>{var r,i,l;if(null==(r=t.logger)||r.info("text-drag:mouseup",{x:a.clientX,y:a.clientY,dragging:e(),copyMode:o(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null}),e()&&n()){const e=n(),a=o();t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(n=>t.applyTableAwareParagraphEdit(n,t=>gR(t,e,{copy:a})),{mergeKey:a?kV:VV}),null==(i=t.logger)||i.info("text-drag:apply",{mode:a?"copy":"move",destination:`${e.paragraphId}:${e.runId}[${e.offset}]`})}else if(h){const e=h.position;t.applyTransactionalState(t=>vW(t,e)?hE(t,{anchor:e,focus:e}):t,{mergeKey:RV}),null==(l=t.logger)||l.info("text-drag:collapse",{at:`${e.paragraphId}:${e.runId}[${e.offset}]`})}f(),t.focusInputAfterPointerSelection()};return{dragging:e,dropTargetPos:n,copyMode:o,pointerPos:l,caretViewport:d,tryStartTextDrag:(e,n)=>{var o,l,d;if(t.isReadOnly()||!(null==n?void 0:n.resolvedFromParagraph))return null==(o=t.logger)||o.debug("text-drag:skip-start",{reason:t.isReadOnly()?"readonly":"no-hit",x:e.clientX,y:e.clientY}),!1;return vW(t.state(),n.position)?(null==(d=t.logger)||d.info("text-drag:start-pending",{x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`,zone:n.zone}),h={x:e.clientX,y:e.clientY,position:n.tableCellAnchorPosition??n.position},s({x:e.clientX,y:e.clientY}),i(e.ctrlKey||e.metaKey),r(null),c(n.caretViewport??null),a(!1),window.addEventListener("mousemove",g),window.addEventListener("mouseup",m),!0):(null==(l=t.logger)||l.debug("text-drag:skip-start",{reason:"outside-selection",x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`}),!1)},stopDrag:f}}function yW(t){const e=(e,a)=>{var n,r,o,i,l,s;const d=t.state(),c=Na(d),h=c.findIndex(t=>t.id===d.selection.focus.paragraphId);if(-1===h)return!1;const p=t.surfaceRef(),u=(null==p?void 0:p.getBoundingClientRect())??null,f=t.preferredColumnX(),g=null===f?t.caretBox().left+((null==u?void 0:u.left)??0):f,m=p?t.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:p,state:d,documentLayout:t.documentLayout(),zoomFactor:null==(n=t.zoomFactor)?void 0:n.call(t)}):null;let v=h+e;const b=xa(d.document,d.selection.focus.paragraphId,Ea(d));if(b){const t=za(d,b.zone)[b.blockIndex];if(t&&"table"===t.type){const a=Io(t),n=a.find(t=>t.rowIndex===b.rowIndex&&t.cellIndex===b.cellIndex);if(n){const o=[];for(let a=n.visualRowIndex+e;a>=0&&a<t.rows.length;a+=e)o.push(a);for(const n of o){const o=a.filter(t=>t.visualRowIndex===n&&t.cell.blocks.length>0&&"continue"!==t.cell.vMerge);if(0===o.length)continue;const i=null==(r=o.map(e=>{var a,n;const r=null==(a=e.cell.blocks[0])?void 0:a.id,o=r?null==(n=null==m?void 0:m.paragraphs.find(e=>e.paragraphId===r&&e.tableCell&&e.tableCell.tableId===t.id))?void 0:n.tableCell:null,i=(null==o?void 0:o.left)??g,l=o?o.left+o.width:g;return{entry:e,distance:g<i?i-g:g>l?g-l:0}}).sort((t,e)=>t.distance-e.distance)[0])?void 0:r.entry;if(!i)continue;const l=e<0?i.cell.blocks[i.cell.blocks.length-1].id:i.cell.blocks[0].id;v=c.findIndex(t=>t.id===l);break}}else if(e<0){const e=null==(l=null==(i=null==(o=t.rows[0])?void 0:o.cells[0])?void 0:i.blocks[0])?void 0:l.id;e&&(v=c.findIndex(t=>t.id===e)-1)}else{const e=t.rows[t.rows.length-1],a=null==e?void 0:e.cells[e.cells.length-1],n=null==(s=null==a?void 0:a.blocks[a.blocks.length-1])?void 0:s.id;n&&(v=c.findIndex(t=>t.id===n)+1)}}}if(v<0||v>=c.length)return!1;const y=c[v];let M=0;const x=m?Pn(m,y.id):[],w=e<0?x[x.length-1]:x[0];if(w&&w.lines.length>0){const t=w.lines,a=e<0?t[t.length-1]:t[0];M=a.slots.length?a.slots.reduce((t,e)=>Math.abs(g-e.left)<Math.abs(g-t.left)?e:t,a.slots[0]).offset:0}else M=Math.min($e(y,d.selection.focus),Je(y).length);return t.setPreferredColumnX(g),t.resetTransactionGrouping(),t.applyTransactionalState(t=>hE(t,{anchor:a?t.selection.anchor:_e(y,M),focus:_e(y,M)})),t.focusInput(),!0};return{moveSelectionToParagraphBoundary:(e,a)=>{const n=t.state(),r=Na(n).find(t=>t.id===n.selection.focus.paragraphId);if(!r)return!1;const o=_e(r,"start"===e?0:Je(r).length);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:o,focus:o})),!0},moveSelectionToDocumentBoundary:(e,a)=>{const n=t.state(),r=Na(n);if(0===r.length)return!1;const o="start"===e?r[0]:r[r.length-1],i=_e(o,"start"===e?0:Je(o).length);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:i,focus:i})),!0},moveSelectionByWord:(e,a)=>{const n=t.state(),r=Na(n),o=r.findIndex(t=>t.id===n.selection.focus.paragraphId),i=r[o];if(!i)return!1;const l=Je(i),s=n.selection.focus.offset,d=l.length;if(!a&&!Ga(n.selection))return t.clearPreferredColumn(),t.applyState("left"===e?pE(n):uE(n)),!0;let c=i,h=s;"left"===e?0===s&&o>0?(c=r[o-1],h=Je(c).length):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(0===a)return 0;if(uW(t[a-1]??"")){for(;a>0&&uW(t[a-1]??"");)a-=1;return a}for(;a>0&&!uW(t[a-1]??"");)a-=1;for(;a>0&&uW(t[a-1]??"");)a-=1;return a}(l,s):s===d&&o<r.length-1?(c=r[o+1],h=0):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(a>=t.length)return t.length;if(uW(t[a]??"")){for(;a<t.length&&uW(t[a]??"");)a+=1;for(;a<t.length&&!uW(t[a]??"");)a+=1;return a}for(;a<t.length&&!uW(t[a]??"");)a+=1;return a}(l,s);const p=_e(c,h);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:p,focus:p})),!0},moveVerticalByBlock:t=>e(t,!1),moveVerticalSelection:e}}function MW(t){const e=()=>t.state,a=hW({state:e,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,viewportRef:t.viewportRef,zoomFactor:t.zoomFactor,documentLayout:t.documentLayout,canvasSnapshotProvider:t.canvasSnapshotProvider}),n=pW({state:e,applyTransactionalState:t.applyTransactionalState,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint,focusInput:t.focusInput}),r=function(t){const[e,a]=y(null);return{hoveredRevision:e,handleRevisionMouseEnter:(e,n)=>{var r,o,i;const l=Na(t.state());let s;for(const t of l){for(const a of t.runs)if((null==(r=a.revision)?void 0:r.id)===e){s=a.revision;break}if(s)break}const d=t=>{var a,n,r,o,i,l,s,c,h,p,u;for(const f of t)if("paragraph"!==f.type){if((null==(n=null==(a=f.style)?void 0:a.revision)?void 0:n.id)===e)return f.style.revision;if((null==(r=f.gridRevision)?void 0:r.id)===e)return f.gridRevision;for(const t of f.rows){if((null==(i=null==(o=t.style)?void 0:o.revision)?void 0:i.id)===e)return t.style.revision;if((null==(s=null==(l=t.style)?void 0:l.propertyRevision)?void 0:s.id)===e)return t.style.propertyRevision;for(const a of t.cells){if((null==(h=null==(c=a.style)?void 0:c.revision)?void 0:h.id)===e)return a.style.revision;if((null==(u=null==(p=a.style)?void 0:p.propertyRevision)?void 0:u.id)===e)return a.style.propertyRevision;const t=d(a.blocks);if(t)return t}}}};if(!s)for(const a of ha(t.state().document)){for(const t of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])if(t&&(s=d(t),s))break;if(s)break}if(!s)return;const c=n.currentTarget.getBoundingClientRect(),h=null==(o=t.surfaceRef())?void 0:o.getBoundingClientRect();if(!h)return;const p=(null==(i=t.zoomFactor)?void 0:i.call(t))??1;a({revisionId:s.id,author:s.author,date:s.date,type:s.type,left:(c.left-h.left)/p,top:(c.top-h.top)/p})},handleRevisionMouseLeave:()=>{a(null)}}}({state:e,surfaceRef:()=>t.surfaceRef()??null,zoomFactor:t.zoomFactor}),o=bW({state:e,isReadOnly:t.isReadOnly,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,logger:t.logger}),i=mW({state:e,applyState:t.applyState,tableResize:a,imageOps:t.imageOps,clearPendingCaretTextStyle:t.styleController.clearPendingCaretTextStyle,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,getParagraphById:ya,textDrag:{tryStartTextDrag:o.tryStartTextDrag},logger:t.logger}),l=function(t){const[e,a]=y(!1);let n=null;return{handleTextInput:a=>{var r,o,i,l;if(hd("input:text"),t.isReadOnly())return t.logger.debug(`input:readonly ignored value=${JSON.stringify(a.currentTarget.value)}`),void(a.currentTarget.value="");const s=a.currentTarget.value;if(0===s.length)return;if(e())return void t.logger.debug(`input:composing buffer=${JSON.stringify(s)}`);if(null!==n&&s===n)return t.logger.debug(`input:suppressed text=${JSON.stringify(s)}`),n=null,void(a.currentTarget.value="");const d=t.state(),c=d.selection,h=null==(r=Na(d).find(t=>t.id===c.anchor.paragraphId))?void 0:r.runs.find(t=>t.id===c.anchor.runId),p=h?{bold:null==(o=h.styles)?void 0:o.bold,italic:null==(i=h.styles)?void 0:i.italic,underline:null==(l=h.styles)?void 0:l.underline}:null;t.logger.info(`input:text ${JSON.stringify(s)} (len=${s.length}) at ${c.anchor.paragraphId}:${c.anchor.runId}[${c.anchor.offset}] run:${JSON.stringify(p)}`),t.clearPreferredColumn();const u=fA(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,s,u)),{mergeKey:pV}),a.currentTarget.value="",t.focusInput(),pd("input:text")},handleCompositionStart:()=>{t.logger.debug("input:composition start"),a(!0)},handleCompositionEnd:e=>{if(t.isReadOnly())return e.currentTarget.value="",void a(!1);const r=e.data??e.currentTarget.value;if(a(!1),0===r.length)return void(e.currentTarget.value="");const o=t.state().selection;t.logger.info(`input:composition end ${JSON.stringify(r)} (len=${r.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),n=r,t.clearPreferredColumn();const i=fA(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,r,i)),{mergeKey:pV}),e.currentTarget.value="",t.focusInput()},composing:e}}({state:e,isReadOnly:t.isReadOnly,logger:t.logger,clearPreferredColumn:t.clearPreferredColumn,pendingCaretTextStyle:t.styleController.pendingCaretTextStyle,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput}),s=yW({state:e,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,surfaceRef:()=>t.surfaceRef()??null,caretBox:t.caretBox,preferredColumnX:t.preferredColumnX,setPreferredColumnX:t.setPreferredColumnX,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:t.focusInput,zoomFactor:t.zoomFactor,documentLayout:t.documentLayout,canvasSnapshotProvider:t.canvasSnapshotProvider}),{handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}=(u={state:e,isReadOnly:t.isReadOnly,forcePlainTextPaste:t.getForcePlainTextPaste,setForcePlainTextPaste:t.setForcePlainTextPaste,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,insertImageFromFile:t.insertImageFromFile,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint},{handleCopy:t=>{var e,a;const n=cE(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",rE(u.state())))},handleCut:t=>{var e,a;if(u.isReadOnly())return void t.preventDefault();const n=cE(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",rE(u.state())),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>bR(t))),u.focusInput())},handlePaste:t=>{var e,a,n;if(u.isReadOnly())return void t.preventDefault();if(u.forcePlainTextPaste()){u.setForcePlainTextPaste(!1);const a=(null==(e=t.clipboardData)?void 0:e.getData("text/plain"))??"";return 0===a.length?void t.preventDefault():(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>vR(t,a))),t.currentTarget.value="",void u.focusInput())}const r=Bq(t.clipboardData);if(r)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.insertImageFromFile(r),t.currentTarget.value="",void u.focusInput();const o=fE((null==(a=t.clipboardData)?void 0:a.getData("text/html"))??"");if(o.length>0)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>oE(t,o))),t.currentTarget.value="",void u.focusInput();const i=(null==(n=t.clipboardData)?void 0:n.getData("text/plain"))??"";0!==i.length&&(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>vR(t,i))),t.currentTarget.value="",u.focusInput())},handleDrop:t=>{if(u.isReadOnly())return void t.preventDefault();const e=Bq(t.dataTransfer);if(!e)return;t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping();const a=u.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??u.state().selection.focus;u.insertImageFromFile(e,a),u.focusInput()}});var u;return{tableResize:a,tableDrag:n,revisionController:r,textDrag:o,surfaceEvents:i,textInput:l,navigation:s,handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}}function xW(t){const{state:e,logger:a,isReadOnly:n,applyState:r,cloneState:o,focusInput:i,focusInputAfterPointerSelection:l,surfaceRef:s,viewportRef:d,zoomFactor:c,insertImageFromFile:h,getForcePlainTextPaste:p,setForcePlainTextPaste:u,getCommandsController:f,applyTransactionalState:g,clearPreferredColumn:m,resetTransactionGrouping:v,updateHistoryState:b,caretBox:y,preferredColumnX:M,setPreferredColumnX:x,documentLayout:w,canvasSnapshotProvider:S}=t,A=QP({state:()=>e,resetTransactionGrouping:v,applyTransactionalState:g,focusInput:i}),C=UP({state:()=>e,surfaceRef:()=>s()??null,viewportRef:()=>d()??null,documentLayout:w,canvasSnapshotProvider:S,zoomFactor:c}).resolveSurfaceHitAtPoint,I=qP({state:e,applyState:r,applyTransactionalState:g,focusInput:i}),T=EP({applyTransactionalState:g,applySelectionToStatePreservingStructure:(t,e)=>({...t,document:RA(t).document,selection:e}),focusInput:i,logger:a}),k=(t,e)=>{var a;return(null==(a=C(t,e))?void 0:a.position)??null},V=NP({state:e,surfaceRef:s,resolvePositionAtSurfacePoint:k,applyState:r,applyTransactionalState:g,updateHistoryState:b,focusInput:i,focusInputAfterPointerSelection:l,cloneState:o,logger:a,zoomFactor:c}),R=function(t){const e=t=>{const e=vP(t),a=e&&Me(e.run);return a?{width:a.width,height:fp(a,t,0)}:null},a=LP({label:"text box",getSelected:e,applyResize:(t,e,a,n)=>MP(t,e,a,{handleDirection:n}),getMaxWidth:(a,n)=>{const r=$q(t.surfaceRef(),a.document,n,a.activeSectionIndex??0),o=e(a);return o?Math.max(r,o.width):r}},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),n=zP({label:"text box",applyRotate:(t,e)=>bP(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger});return{handleTextBoxResizeHandleMouseDown:(e,n,r,o)=>{o.preventDefault(),o.stopPropagation(),a.start(e,n,r,o,t.state)},handleTextBoxRotateHandleMouseDown:(e,a,r)=>{r.preventDefault(),r.stopPropagation(),n.start(e,a,r,t.state)},stopTextBoxResize:a.stop,stopTextBoxRotate:n.stop}}({state:e,surfaceRef:s,applyState:r,updateHistoryState:b,focusInput:i,cloneState:o,logger:a,zoomFactor:c}),E=OP({state:()=>e,commandsController:f,clearPreferredColumn:m,resetTransactionGrouping:v,focusInput:i,logger:a}),L=MW({state:e,applyState:r,applyTransactionalState:g,isReadOnly:n,logger:a,focusInput:i,focusInputAfterPointerSelection:l,clearPreferredColumn:m,resetTransactionGrouping:v,surfaceRef:s,viewportRef:d,caretBox:()=>y(),preferredColumnX:()=>M(),setPreferredColumnX:x,zoomFactor:c,documentLayout:w,canvasSnapshotProvider:S,resolveSurfaceHitAtPoint:C,resolvePositionAtSurfacePoint:k,tableOps:T,imageOps:V,styleController:E,getForcePlainTextPaste:p,setForcePlainTextPaste:u,insertImageFromFile:h});return{selectedImageRun:()=>Zq(e),selectedTextBoxRun:()=>vP(e),layoutOptionsOverlay:A,fr:I,resolveSurfaceHitAtPoint:C,resolvePositionAtSurfacePoint:k,tableOps:T,imageOps:V,textBoxOps:R,styleController:E,onEditorMouseDown:t=>{0===t.button&&(E.clearPendingCaretTextStyle(),t.preventDefault(),i())},tableResize:L.tableResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}function wW(t){if("main"!==(t.activeZone??"main"))return t;const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=function(){const t=[en("",{styleId:"footnoteText"})];return{id:ja("footnote"),blocks:t}}(),i=function(t){var e,a;const n=t.footnotes,r=(null==(e=null==n?void 0:n.settings)?void 0:e.numberFormat)??"decimal";let o=((null==(a=null==n?void 0:n.settings)?void 0:a.startAt)??1)-1;const i=new Set;for(const{run:l}of Fc(t)){const t=Ae(l);t&&!t.customMark&&(i.has(t.footnoteId)||(i.add(t.footnoteId),o+=1))}return jc(o+1,r)}(e.document),l=function(t,e){const a={styleId:"footnoteReference",superscript:!0},n={footnoteId:t};return{id:ja("run"),text:e,styles:a,kind:"footnoteReference",footnoteReference:n}}(o.id,i),s=$V(a,r,[l]),d=rR(e,Na(e).map((t,e)=>e===n?s:t),Ua(_e(s,r+i.length))),c=function(t){return t||{items:{}}}(d.document.footnotes),h=Xc({...d.document,footnotes:{...c,items:{...c.items,[o.id]:o}}}),p=o.blocks.flatMap(pa).find(Boolean);return p?{...d,document:h,selection:Ua(_e(p,0)),activeZone:"footnote",activeFootnoteId:o.id}:{...d,document:h}}function SW(t,e,a){return t.flatMap(t=>{var n;if("paragraph"===t.type)return[t];let r=t.style;if((null==(n=null==r?void 0:r.revision)?void 0:n.id)===e)if(a){const{revision:t,...e}=r;r=e}else r={...r.revision.previous};let o=t.gridCols,i=t.gridRevision;(null==i?void 0:i.id)===e&&(o=a?o:[...i.previous],i=void 0);const l=t.rows.map(t=>({...t,cells:[...t.cells]}));for(let d=0;d<l.length;d+=1){const t=l[d];for(let n=0;n<t.cells.length;n+=1){const r=t.cells[n],o=r.mergeRevisionState;if(o&&o.revisionId===e){if(a){const{mergeRevisionState:e,...a}=r;t.cells[n]=a;continue}"horizontal"===o.orientation?t.cells.splice(n,o.currentCellCount,...o.previousCells):o.previousCells.forEach((t,e)=>{const a=l[d+e];a&&(a.cells[n]=t)})}}}const s=l.flatMap(t=>{var n,r,o,i;if((null==(r=null==(n=t.style)?void 0:n.revision)?void 0:r.id)===e){if(a&&"delete"===t.style.revision.type||!a&&"insert"===t.style.revision.type)return[]}let l=t.style;if((null==(o=null==l?void 0:l.propertyRevision)?void 0:o.id)===e)if(a){const{propertyRevision:t,...e}=l;l=e}else l={...l.propertyRevision.previous,revision:l.revision};if((null==(i=null==l?void 0:l.revision)?void 0:i.id)===e){const{revision:t,...e}=l;l=e}const s=t.cells.flatMap(t=>{var n,r,o,i,l;if((null==(r=null==(n=t.style)?void 0:n.revision)?void 0:r.id)===e){if(a&&"delete"===t.style.revision.type||!a&&"insert"===t.style.revision.type)return[]}let s=t.style;if((null==(o=null==s?void 0:s.propertyRevision)?void 0:o.id)===e)if(a){const{propertyRevision:t,...e}=s;s=e}else s={...s.propertyRevision.previous,revision:s.revision};let d={...t,style:s,blocks:SW(t.blocks,e,a)};if((null==(i=null==s?void 0:s.revision)?void 0:i.id)===e&&(null==(l=t.mergeRevisionState)?void 0:l.revisionId)!==e){const t=s.revision,{revision:e,...n}=s;d={...d,...a||"merge"!==t.type?{}:t.previous,style:n}}return[d]});return[{...t,isHeader:l&&"isHeader"in l?l.isHeader:t.isHeader,style:l,cells:s}]});return 0===s.length?[]:[{...t,style:r,gridCols:o,gridRevision:i,rows:s}]})}function AW(t,e,a){const n=ha(t.document).map(t=>({...t,blocks:SW(t.blocks,e,a),header:t.header?SW(t.header,e,a):void 0,firstPageHeader:t.firstPageHeader?SW(t.firstPageHeader,e,a):void 0,evenPageHeader:t.evenPageHeader?SW(t.evenPageHeader,e,a):void 0,footer:t.footer?SW(t.footer,e,a):void 0,firstPageFooter:t.firstPageFooter?SW(t.firstPageFooter,e,a):void 0,evenPageFooter:t.evenPageFooter?SW(t.evenPageFooter,e,a):void 0}));return{...t,document:{...t.document,sections:n}}}function CW(t,e){const a=Na(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:jV(t,a)});return AW(rR(t,a,cR(a,Da(t))),e,!0)}function IW(t,e){const a=Na(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:jV(t,a)});return AW(rR(t,a,cR(a,Da(t))),e,!1)}function TW(t,e,a){var n,r,o,i,l;for(const s of t){if("paragraph"===s.type)continue;s.rows.some(t=>t.cells.some(t=>t.blocks.some(t=>e.has(t.id))))&&((null==(n=s.style)?void 0:n.revision)&&a.add(s.style.revision.id),s.gridRevision&&a.add(s.gridRevision.id));for(const t of s.rows){const n=t.cells.filter(t=>t.blocks.some(t=>e.has(t.id)));n.length>0&&((null==(r=t.style)?void 0:r.revision)&&a.add(t.style.revision.id),(null==(o=t.style)?void 0:o.propertyRevision)&&a.add(t.style.propertyRevision.id));for(const t of n)(null==(i=t.style)?void 0:i.revision)&&a.add(t.style.revision.id),(null==(l=t.style)?void 0:l.propertyRevision)&&a.add(t.style.propertyRevision.id),TW(t.blocks,e,a)}}}function kW(t){var e,a,n;const r=Da(t),o=Na(t);if(r.isCollapsed){const t=o[r.startIndex];return t?(null==(e=QV(t,r.startParagraphOffset))?void 0:e.href)??null:null}const i=o.slice(r.startIndex,r.endIndex+1).flatMap((t,e)=>{const a=r.startIndex+e;return _V(t,a===r.startIndex?r.startParagraphOffset:0,a===r.endIndex?r.endParagraphOffset:Qe(t))}).filter(t=>t.text.length>0&&"image"!==t.kind);if(0===i.length)return null;const l=null==(n=null==(a=i[0])?void 0:a.styles)?void 0:n.link;return l&&i.every(t=>{var e;return(null==(e=t.styles)?void 0:e.link)===l})?l:null}function VW(t){const e=Da(t),a=Na(t).map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return MA(t);if(!t.list)return MA(t);const n=t.list.level??0;return n<=0?YV(t):XV(t,n-1)});return rR(t,a,cR(a,e))}function RW(t){const{state:e,logger:a,applyState:n,applyTransactionalState:r,applySelectionAwareTextCommand:o,applySelectionAwareParagraphCommand:i,applyTableAwareParagraphEdit:l,focusInput:s,clearPreferredColumn:d,resetTransactionGrouping:c,toolbarStyleState:h,selectionCollapsed:p,selectedImageRun:u}=t,f=t=>{d(),c(),n(t),s()},g=t=>{d(),c(),o(t),s()},m=t=>{d(),c(),i(t),s()},v=(t,e)=>{d(),c(),r(t,e),s()},b=()=>(()=>{const t=Da(e);return Na(e).slice(t.startIndex,t.endIndex+1)})().some(t=>Boolean(t.list)),y=()=>{const t=e.selection.focus.paragraphId;return Na(e).find(e=>e.id===t)??null},M=()=>{const t=e.selection,a=Ea(e),n=xa(e.document,t.anchor.paragraphId,a),r=xa(e.document,t.focus.paragraphId,a);return n&&r&&n.blockIndex===r.blockIndex?` [table b${n.blockIndex} r${n.rowIndex}:c${n.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},x=(t,e)=>{m(a=>kR(a,t,e))},w=()=>"main"===(e.activeZone??"main"),S=t=>{const a=kW(e);p()&&!a||v(e=>function(t,e){const a=Da(t);if(!a.isCollapsed)return xR(t,"link",e);const n=Na(t)[a.startIndex];if(!n)return t;const r=QV(n,a.startParagraphOffset);if(!r)return t;const o=xR(hE(t,{anchor:_e(n,r.startOffset),focus:_e(n,r.endOffset)}),"link",e),i=Na(o)[a.startIndex];return i?{...o,selection:{anchor:_e(i,r.startOffset),focus:_e(i,r.endOffset)}}:o}(e,t),{mergeKey:vV})};return{applyBooleanStyleCommand:t=>{if(p())return;const n=e.selection;a.info(`toggleStyle:${t} at ${n.anchor.paragraphId}:${n.anchor.runId}[${n.anchor.offset}..${n.focus.offset}]${M()}`),g(e=>MR(e,t))},applyValueStyleCommand:(t,n)=>{if(p())return;const r=e.selection;a.info(`setStyle:${t}=${JSON.stringify(n)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${M()}`),g(e=>xR(e,t,n))},applyChangeTextCaseCommand:t=>{p()||g(e=>AR(e,t))},applyClearFormattingCommand:()=>{p()||g(t=>function(t){const e=Da(t);if(e.isCollapsed)return t;const a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?t:dR(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:Qe(t),t=>{var e;const a=null==(e=t.styles)?void 0:e.link,n=null!=a&&""!==a?{link:a}:{};return{...t,styles:n}}));return rR(t,a,cR(a,e))}(t))},applyParagraphStyleCommand:x,toggleParagraphFlagCommand:t=>{const e=!h()[t];x(t,!!e||null)},applyParagraphListCommand:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t),r=a.startIndex,o=a.endIndex,i=n.slice(r,o+1),l=i.length>0&&i.every(t=>{var a;return(null==(a=t.list)?void 0:a.kind)===e}),s=n.map((t,a)=>{var n,i,s;if(a<r||a>o)return MA(t);const d=MA(t);return l?(delete d.list,d):(d.list={kind:e,level:(null==(n=t.list)?void 0:n.level)??0,format:null==(i=t.list)?void 0:i.format,startAt:null==(s=t.list)?void 0:s.startAt},d)});return rR(t,s,cR(s,a))}(e,t))},handleListFormatChange:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t).map((t,n)=>n<a.startIndex||n>a.endIndex?MA(t):t.list?{...MA(t),list:{...t.list,format:e||void 0}}:MA(t));return rR(t,n,cR(n,a))}(e,t))},handleListStartAtChange:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t).map((t,n)=>n<a.startIndex||n>a.endIndex?MA(t):t.list?{...MA(t),list:{...t.list,startAt:null!==e?e:void 0}}:MA(t));return rR(t,n,cR(n,a))}(e,t))},applyInsertSectionBreakCommand:t=>{f(function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,offset:r}=lR(a),o=ha(a.document),i=Ea(a);if("main"!==La(a))return t;const l=o[i];if(!l)return t;const s=l.blocks.findIndex(t=>"paragraph"===t.type&&t.id===n.id);if(-1===s)return t;const d=l.blocks.slice(0,s),c=l.blocks.slice(s+1),h=jV(n,_V(n,0,r),JV(n,r)),p=_V(n,r,Qe(n)),u=p.length>0?KV(n,p.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=n.style?{...n.style}:void 0,t.list=n.list?{...n.list}:void 0,t})(),f={id:`section:${Math.random().toString(36).slice(2,9)}`,blocks:[u,...c],pageSettings:{...l.pageSettings},header:l.header?SA(l.header):void 0,footer:l.footer?SA(l.footer):void 0,breakType:e},g={...l,blocks:[...d,h]},m=[...o.slice(0,i),g,f,...o.slice(i+1)];return{...a,document:{...a.document,sections:m},activeSectionIndex:i+1,selection:iR(_e(u,0))}}(e,t))},applyInsertPageBreakCommand:()=>{v(t=>l(t,t=>TR(t)))},canInsertFootnoteCommand:w,applyInsertFootnoteCommand:()=>{w()&&v(t=>wW(t))},handleStyleChange:t=>{m(e=>function(t,e){return kR(t,"styleId",e)}(e,t||null))},applyUpdateSectionSettingsCommand:(t,a)=>{f(function(t,e,a){var n;const r=ha(t.document);if(e<0||e>=r.length)return t;const o=[...r];return o[e]={...o[e],...a,pageSettings:{...o[e].pageSettings,...a.pageSettings??{},margins:{...o[e].pageSettings.margins,...(null==(n=a.pageSettings)?void 0:n.margins)??{}}}},{...t,document:{...t.document,sections:o}}}(e,t,a))},applyToggleTrackChangesCommand:()=>{f(function(t){return{...t,trackChangesEnabled:!t.trackChangesEnabled}}(e))},applyToggleShowMarginsCommand:()=>{n({...e,showMargins:!e.showMargins}),s()},applyToggleShowParagraphMarksCommand:()=>{n({...e,showParagraphMarks:!e.showParagraphMarks}),s()},applyAcceptRevisionsCommand:()=>{f(function(t){var e;const a=Da(t),n=Na(t),r=new Set;for(let l=a.startIndex;l<=a.endIndex;l+=1){const t=n[l],o=_V(t,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}const o=new Set(n.slice(a.startIndex,a.endIndex+1).map(t=>t.id));for(const l of ha(t.document))for(const t of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])t&&TW(t,o,r);let i=t;for(const l of r)i=CW(i,l);return i}(e))},applyRejectRevisionsCommand:()=>{f(function(t){var e;const a=Da(t),n=Na(t),r=new Set;for(let l=a.startIndex;l<=a.endIndex;l+=1){const t=n[l],o=_V(t,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}const o=new Set(n.slice(a.startIndex,a.endIndex+1).map(t=>t.id));for(const l of ha(t.document))for(const t of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])t&&TW(t,o,r);let i=t;for(const l of r)i=IW(i,l);return i}(e))},applyLinkCommand:S,promptForLink:()=>{const a=kW(e)??"";p()&&!a||t.openLinkDialog(a)},removeLinkCommand:()=>{S(null)},applyImageAltCommand:t=>{u()&&v(e=>function(t,e){return Xq(t,t=>({...t,alt:e??void 0}))}(e,t),{mergeKey:bV})},promptForImageAlt:()=>{var e;const a=u();if(!a)return;const n=(null==(e=ye(a.run))?void 0:e.alt)??"";t.openImageAltDialog(n)},applyImageCaptionCommand:e=>{u()&&v(a=>Qq(a,e,t.imageCaptionLabel()),{mergeKey:yV})},promptForImageCaption:()=>{u()&&t.openImageCaptionDialog(Jq(e)??"")},handleListTab:t=>!xa(e.document,e.selection.focus.paragraphId,Ea(e))&&(!!b()&&(m(e=>"indent"===t?function(t){const e=Da(t),a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?MA(t):t.list?XV(t,(t.list.level??0)+1):MA(t));return rR(t,a,cR(a,e))}(e):VW(e)),!0)),handleListEnter:()=>{const t=y();return!!(null==t?void 0:t.list)&&(d(),c(),p()&&0===Je(t).length?i(t=>function(t){const e=Da(t),a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?MA(t):YV(t));return rR(t,a,cR(a,e))}(t)):r(t=>l(t,t=>function(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=xA(a.list),t})(),s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}(t)),{mergeKey:mV}),s(),!0)},handleListBoundaryBackspace:t=>{const a=y();if(!(null==a?void 0:a.list)||!p())return!1;return 0===$e(a,e.selection.focus)&&(d(),c(),i(t=>VW(t)),t.currentTarget.value="",s(),!0)}}}class EW{constructor(){a(this,"bindings",new Map)}register(t){this.bindings.set(t.id,t)}unregister(t){this.bindings.delete(t)}getBindings(){return Array.from(this.bindings.values())}execute(t,e,a){var n;const r=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();for(const i of this.bindings.values())if(i.key.toLowerCase()===o&&Boolean(i.ctrlOrMeta)===r&&Boolean(i.shift)===t.shiftKey&&Boolean(i.alt)===t.altKey){if(i.command&&a){if((null==(n=a.canExecuteCommand)?void 0:n.call(a,i.command))??!0)return a.executeCommand(i.command),t.preventDefault(),!0}if(!1!==i.execute(e,t))return t.preventDefault(),!0}return!1}}const LW=[{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:t=>{const e=t.state(),a=Na(e);if(0===a.length)return!1;const n=a[0],r=a[a.length-1];return t.clearPreferredColumn(),t.applyState(hE(e,{anchor:_e(n,0),focus:_e(r,Je(r).length)})),t.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:t=>!!t.selectedImageRun()&&(t.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:t=>(t.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:t=>(t.setForcePlainTextPaste(!0),t.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:t=>(t.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:t=>(t.toggleFindReplace(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:t=>(t.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:t=>(t.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:t=>(t.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:t=>(t.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>TR(t))),t.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,"\n"))),t.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:t=>(t.commandsController.handleListEnter()||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>IR(t))),t.focusInput()),!0)}];function zW(t){const e=new EW;LW.forEach(t=>e.register(t));return{handleKeyDown:a=>{const n=t.state();if(t.isReadOnly()){const t=a.key,e=t.toLowerCase(),n="ArrowLeft"===t||"ArrowRight"===t||"ArrowUp"===t||"ArrowDown"===t||"Home"===t||"End"===t||"PageUp"===t||"PageDown"===t,r="Shift"===t||"Control"===t||"Meta"===t||"Alt"===t,o=(a.ctrlKey||a.metaKey)&&("a"===e||"c"===e);return void(n||r||o||a.preventDefault())}const r=t.executeCommand?{executeCommand:(e,a)=>{var n;return null==(n=t.executeCommand)?void 0:n.call(t,e,a)},canExecuteCommand:(e,a)=>{var n;return null==(n=t.canExecuteCommand)?void 0:n.call(t,e,a)}}:void 0;if(!e.execute(a,t,r)){if((a.ctrlKey||a.metaKey)&&!a.altKey){if(("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),t.resetTransactionGrouping(),t.moveSelectionByWord("ArrowLeft"===a.key?"left":"right",a.shiftKey)))return void t.focusInput();if("Backspace"===a.key||"Delete"===a.key){if(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),!Ga(n.selection))return t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),a.currentTarget.value="",void t.focusInput();const e=Na(n),r=e.findIndex(t=>t.id===n.selection.focus.paragraphId),o=e[r];if(!o)return a.currentTarget.value="",void t.focusInput();if("Backspace"===a.key&&o.list){if(0===$e(o,n.selection.focus))return t.applySelectionAwareParagraphCommand(t=>VW(t)),a.currentTarget.value="",void t.focusInput()}const i=n.selection.focus.offset,l=Je(o),s=fW(l,i);return"Backspace"===a.key?0===i||s.start===i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(hE(e,{anchor:_e(o,s.start),focus:_e(o,i)}),t=>bR(t))):i>=l.length?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))):s.end>i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(hE(e,{anchor:_e(o,i),focus:_e(o,s.end)}),t=>bR(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))),a.currentTarget.value="",void t.focusInput()}}if("Home"===a.key||"End"===a.key){a.preventDefault(),t.resetTransactionGrouping();const e="Home"===a.key?"start":"end";return a.ctrlKey||a.metaKey?t.moveSelectionToDocumentBoundary(e,a.shiftKey):t.moveSelectionToParagraphBoundary(e,a.shiftKey),void t.focusInput()}if(!a.altKey||a.ctrlKey||a.metaKey||"ArrowUp"!==a.key&&"ArrowDown"!==a.key||(a.preventDefault(),t.resetTransactionGrouping(),t.clearPreferredColumn(),!t.moveSelectedImageByParagraph("ArrowUp"===a.key?-1:1)))switch(a.key){case"Backspace":return t.commandsController.handleListBoundaryBackspace(a)?void a.preventDefault():(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),a.currentTarget.value="",void t.focusInput());case"Delete":return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))),a.currentTarget.value="",void t.focusInput();case"Tab":{if(t.commandsController.handleListTab(a.shiftKey?"outdent":"indent"))return void a.preventDefault();const e=t.resolveAdjacentTableCellPosition(n.document,n.selection.focus.paragraphId,a.shiftKey?-1:1);if(e)return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applySelectionPreservingStructure({anchor:e,focus:e}),void t.focusInput();break}case"ArrowLeft":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(sE(n,-1))):(t.clearPreferredColumn(),t.applyState(pE(n))),void t.focusInput();case"ArrowRight":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(function(t){return sE(t,1)}(n))):(t.clearPreferredColumn(),t.applyState(uE(n))),void t.focusInput();case"ArrowUp":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(-1,!0)||(t.applyState(function(t){return dE(t,-1)}(n)),t.focusInput()):t.moveVerticalByBlock(-1)||(t.applyState(function(t){return lE(t,-1)}(n)),t.focusInput()));case"ArrowDown":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(1,!0)||(t.applyState(function(t){return dE(t,1)}(n)),t.focusInput()):t.moveVerticalByBlock(1)||(t.applyState(function(t){return lE(t,1)}(n)),t.focusInput()));default:return}}},registry:e}}const NW=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];const OW=t=>Math.round(t/Ne*ke);function qW(t,e=3){var a;const n=[];for(const r of ba(t.document)){const t=zn(null==(a=r.style)?void 0:a.styleId);if(null===t||t>e)continue;const o=Je(r).trim();o&&n.push({id:r.id,level:t,text:o})}return n}function PW(t){const e=Xa(t.text).id;return t.fieldChar?{id:e,text:t.text,kind:"fieldChar",fieldChar:t.fieldChar}:void 0!==t.fieldInstruction?{id:e,text:t.text,kind:"fieldInstruction",fieldInstruction:t.fieldInstruction}:{id:e,text:t.text,kind:"text"}}function WW(t,e){const a=Ja("");return a.runs=t,e&&(a.style=e),a}function BW(t,e,a){const n=void 0!==e?String(e):"";return WW([PW({text:`${t.text}\t${n}`})],{tabs:[{position:a,type:"right",leader:"dot"}],spacingAfter:OW(40),indentLeft:OW(397*(t.level-1))})}function FW(t){const{width:e,margins:a}=t.pageSettings;return Fl(Math.max(0,e-a.left-a.right)*Re,2)}function HW(t,e,a,n){const r=ha(t.document),o=r[e];if(!o)return t;const i=[...r];return i[e]={...o,blocks:a},{...t,document:{...t.document,sections:i},selection:iR(_e(n,0))}}function UW(t,e=()=>{},a=3){if("main"!==La(t))return t;const n=Ea(t),r=ha(t.document)[n];if(!r)return t;const o=function(t,e,a){const n=t.map(t=>BW(t,e(t.id),a));return[WW([PW({text:"",fieldChar:{kind:"begin"}}),PW({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),PW({text:"",fieldChar:{kind:"separate"}})]),...n,WW([PW({text:"",fieldChar:{kind:"end"}})])]}(qW(t,a),e,FW(r)),i=Fa(t,t.selection.focus),l=r.blocks.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&pa(t).some(t=>t.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return HW(t,n,[...r.blocks.slice(0,s),...o,...r.blocks.slice(s)],o[0])}function GW(t,e=()=>{},a=3){const n=Ea(t),r=ha(t.document)[n];if(!r)return t;const o=function(t){let e=0,a="",n=-1,r=-1,o=!1;for(let i=0;i<t.length;i+=1){const l=t[i];if("paragraph"===l.type)for(const t of l.runs){const l=we(t),s=Se(t);if("begin"===(null==l?void 0:l.kind))e+=1,1===e&&(r=i,a="",o=!1,n=-1);else if(1===e&&void 0!==s)a+=s,/\bTOC\b/i.test(a)&&(o=!0);else if("separate"===(null==l?void 0:l.kind))1===e&&(n=i);else if("end"===(null==l?void 0:l.kind)){if(1===e&&o)return{startBlockIndex:n>=0?n:r,endBlockIndex:i};e=Math.max(0,e-1)}}}return null}(r.blocks);if(!o)return t;const i=qW(t,a).map(t=>BW(t,e(t.id),FW(r)));return HW(t,n,[...r.blocks.slice(0,o.startBlockIndex+1),...i,...r.blocks.slice(o.endBlockIndex)],i[0]??r.blocks[o.startBlockIndex])}function DW(t){return null!=t&&""!==t?Number(t):null}function jW({gate:t,style:e,selection:a,history:n,formatting:r,link:o,command:i,valueCommand:l,actionCommand:s}){const d=e.state;return{selectAll:i("selectAll",r.selectAll),insertFootnote:i("insertFootnote",r.insertFootnote),pastePlainText:i("pastePlainText",r.pastePlainText),bold:i("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(d().underline)})),strike:i("strike",r.strike,()=>({isActive:Boolean(d().strike)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:i("link",()=>(o.prompt(),!0),()=>({isEnabled:t.isCommandEnabled("link")&&o.canPrompt(),isActive:Boolean(d().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:i("find",r.find),replace:i("replace",r.replace),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges),acceptRevisions:i("acceptRevisions",r.acceptRevisions),rejectRevisions:i("rejectRevisions",r.rejectRevisions),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(El(),{isActive:Ll()})),undo:i("undo",n.undo,()=>({isEnabled:t.isCommandEnabled("undo")&&n.canUndo()})),redo:i("redo",n.redo,()=>({isEnabled:t.isCommandEnabled("redo")&&n.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),splitBlock:i("splitBlock",r.splitBlock),setFontFamily:l("setFontFamily",t=>r.setFontFamily(t||null),()=>d().fontFamily),setFontSize:l("setFontSize",t=>{const e=t&&"object"==typeof t&&"size"in t?t.size:t;return r.setFontSize(null!=e&&""!==e?_w(e):null),!0},()=>Qw(d().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),changeTextCase:s("changeTextCase",t=>{r.changeTextCase(t??"sentence")},()=>({isEnabled:t.isCommandEnabled("changeTextCase")&&!a.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",t=>r.setColor(t??null),()=>d().color||null),setHighlight:l("setHighlight",t=>r.setHighlight(t??null),()=>d().highlight||null),setTextShading:l("setTextShading",t=>r.setTextShading(t??null),()=>d().textShading||null),setStyleId:l("setStyleId",t=>r.setStyleId(String(t)),()=>d().styleId||"normal"),setCharacterStyleId:l("setCharacterStyleId",t=>r.setCharacterStyleId(String(t)),()=>d().characterStyleId||""),setUnderlineStyle:l("setUnderlineStyle",t=>(r.setUnderlineStyle(t||null),!0),()=>d().underlineStyle)}}function ZW({gate:t,style:e,document:a,link:n,image:r,browser:o,actionCommand:i}){const l=e.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:a.documentStyles()})),print:i("print",()=>o.print(),()=>({isEnabled:!0})),copy:i("copy",()=>o.copy(),()=>({isEnabled:!0})),exportDocx:i("exportDocx",()=>a.exportDocx()),exportPdf:i("exportPdf",()=>a.exportPdf()),importDocument:i("importDocument",()=>a.importDocument()),insertImage:i("insertImage",()=>a.insertImage()),insertShape:i("insertShape",t=>a.insertShape(String(t))),unlink:i("unlink",()=>n.remove(),()=>({isEnabled:t.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()}))}}function KW({style:t,paragraph:e,section:a,valueCommand:n,actionCommand:r}){const o=t.state;return{outdent:r("outdent",()=>e.outdent()),indent:r("indent",()=>e.indent()),togglePageBreakBefore:r("togglePageBreakBefore",()=>e.togglePageBreakBefore(),()=>({isActive:Boolean(o().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>e.toggleKeepWithNext(),()=>({isActive:Boolean(o().keepWithNext)})),setSpacingAfter:n("setSpacingAfter",t=>(e.setSpacingAfter(DW(t)),!0),()=>o().spacingAfter),setSpacingBefore:n("setSpacingBefore",t=>(e.setSpacingBefore(DW(t)),!0),()=>o().spacingBefore),setIndentLeft:n("setIndentLeft",t=>(e.setIndentLeft(DW(t)),!0),()=>o().indentLeft),setIndentRight:n("setIndentRight",t=>(e.setIndentRight(DW(t)),!0),()=>o().indentRight),setIndentFirstLine:n("setIndentFirstLine",t=>(e.setIndentFirstLine(DW(t)),!0),()=>o().indentFirstLine),setIndentHanging:n("setIndentHanging",t=>(e.setIndentHanging(DW(t)),!0),()=>o().indentHanging),setSpecialIndent:r("setSpecialIndent",t=>{const a=t??{};e.setSpecialIndent(a.kind??"none",DW(a.value))},()=>{const t=Number(o().indentFirstLine),e=Number(o().indentHanging),a=Number.isFinite(e)&&e>0?"hanging":Number.isFinite(t)&&t>0?"firstLine":"none";return{isActive:"none"!==a,value:a}}),setParagraphShading:n("setParagraphShading",t=>(e.setShading(t??null),!0),()=>o().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>e.applyBorders()),setLineHeight:n("setLineHeight",t=>(e.setLineHeight(DW(t)),!0),()=>o().lineHeight),setListFormat:r("setListFormat",t=>e.setListFormat(String(t))),setListStartAt:r("setListStartAt",t=>e.setListStartAt(DW(t))),toggleOrientation:r("toggleOrientation",()=>a.toggleOrientation(),()=>({isActive:a.isLandscape()})),setOrientation:r("setOrientation",t=>a.setOrientation(t)),sectionBreakNextPage:r("sectionBreakNextPage",()=>a.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>a.breakContinuous()),setPageMargins:r("setPageMargins",t=>{a.setPageMargins(t??{})},()=>({value:a.getMargins()}))}}function XW({gate:t,table:e,actionCommand:a}){return{tableContext:a("tableContext",()=>{},()=>({isEnabled:e.insideTable(),isActive:e.insideTable(),value:e.selectionLabel()})),tableMerge:a("tableMerge",()=>e.merge(),()=>({isEnabled:t.isCommandEnabled("tableMerge")&&e.canMerge()})),tableSplit:a("tableSplit",()=>e.split(),()=>({isEnabled:t.isCommandEnabled("tableSplit")&&e.canSplit()})),tableInsertColumnBefore:a("tableInsertColumnBefore",()=>e.insertColumnBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnBefore")&&e.canEditColumn()})),tableInsertColumnAfter:a("tableInsertColumnAfter",()=>e.insertColumnAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnAfter")&&e.canEditColumn()})),tableDeleteColumn:a("tableDeleteColumn",()=>e.deleteColumn(),()=>({isEnabled:t.isCommandEnabled("tableDeleteColumn")&&e.canEditColumn()})),tableInsertRowBefore:a("tableInsertRowBefore",()=>e.insertRowBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowBefore")&&e.canEditRow()})),tableInsertRowAfter:a("tableInsertRowAfter",()=>e.insertRowAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowAfter")&&e.canEditRow()})),tableDeleteRow:a("tableDeleteRow",()=>e.deleteRow(),()=>({isEnabled:t.isCommandEnabled("tableDeleteRow")&&e.canEditRow()})),tableCellShading:a("tableCellShading",t=>e.cellShading(t??null)),tableCellBorders:a("tableCellBorders",()=>e.cellBorders()),tableCellNoBorders:a("tableCellNoBorders",()=>e.cellNoBorders()),tableWidth100:a("tableWidth100",()=>e.width100()),tableAlignLeft:a("tableAlignLeft",()=>e.alignLeft()),tableAlignCenter:a("tableAlignCenter",()=>e.alignCenter()),tableAlignRight:a("tableAlignRight",()=>e.alignRight()),tableSetCellWidth:a("tableSetCellWidth",t=>e.setCellWidth(String(t))),insertTable:a("insertTable",t=>{const{rows:a,cols:n,columns:r}=t??{},o=n??r;a&&o&&e.insert(a,o)})}}function YW(t){const e=e=>{const a=Number(t.styleController.toolbarStyleState().fontSize),n=Number.isFinite(a)&&a>0?Yw(a):11,r="increase"===e?function(t){for(const e of Xw)if(e>t+1e-6)return e;return Math.round(t)+10}(n):function(t){for(let e=Xw.length-1;e>=0;e-=1){const a=Xw[e];if(a<t-1e-6)return a}return Math.max(1,Math.round(t)-1)}(n);return t.styleController.applyToolbarValueStyleCommand("fontSize",Jw(r)),!0},a=t=>{const e=nh(t.document),a=new Map;for(const n of e.pages)for(const t of n.blocks){const e=t.paragraphId;e&&!a.has(e)&&a.set(e,n.index+1)}return t=>a.get(t)},n={isLandscape:()=>{var e,a;const n=Ea(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return"landscape"===(null==(a=null==r?void 0:r.pageSettings)?void 0:a.orientation)},setOrientation:e=>{var a;const n=Ea(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;r&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,orientation:e}})},toggleOrientation:()=>{var e,a;const r=Ea(t.state()),o=(null==(e=t.state().document.sections)?void 0:e[r])??t.state().document;if(!o)return;const i=(null==(a=o.pageSettings)?void 0:a.orientation)??"portrait";n.setOrientation("portrait"===i?"landscape":"portrait")},breakNextPage:()=>t.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>t.commandsController.applyInsertSectionBreakCommand("continuous"),getMargins:()=>{var e,a;const n=Ea(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return null==(a=null==r?void 0:r.pageSettings)?void 0:a.margins},setPageMargins:e=>{var a;const n=Ea(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;(null==r?void 0:r.pageSettings)&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,margins:{...r.pageSettings.margins,...e}}})}};return function(t){const e=(a=t.gate.isCommandEnabled,(t,e,n)=>({execute:e,refresh:()=>({isEnabled:a(t),...null==n?void 0:n()})}));var a;const n=function(t){return(e,a,n)=>({execute:a,refresh:()=>({isEnabled:t(e),value:n()})})}(t.gate.isCommandEnabled),r=function(t){return(e,a,n)=>({execute:t=>(a(t),!0),refresh:()=>({isEnabled:t(e),...null==n?void 0:n()})})}(t.gate.isCommandEnabled);return{name:"Essentials",commands:{...jW({gate:t.gate,style:t.style,selection:t.selection,history:t.history,formatting:t.formatting,link:t.link,command:e,valueCommand:n,actionCommand:r}),...ZW({gate:t.gate,style:t.style,document:t.document,link:t.link,image:t.image,browser:t.browser,actionCommand:r}),...KW({style:t.style,paragraph:t.paragraph,section:t.section,valueCommand:n,actionCommand:r}),...XW({gate:t.gate,table:t.table,actionCommand:r})}}}({gate:{isCommandEnabled:e=>!t.isReadOnly()&&("insertFootnote"!==e||t.commandsController.canInsertFootnoteCommand())},style:{state:()=>t.styleController.toolbarStyleState()},selection:{isCollapsed:()=>Ga(t.state().selection)},history:{canUndo:()=>t.undoStack().length>0,canRedo:()=>t.redoStack().length>0,undo:()=>(t.historyActions.performUndo(),!0),redo:()=>(t.historyActions.performRedo(),!0)},formatting:{selectAll:()=>{const e=ba(t.state().document);if(0===e.length)return!1;const a=e[0],n=e[e.length-1];return t.applyState({...t.state(),selection:{anchor:_e(a,0),focus:_e(n,Je(n).length)}}),t.focusInput(),!0},insertFootnote:()=>(t.commandsController.applyInsertFootnoteCommand(),!0),insertTableOfContents:()=>(t.applyTransactionalState(t=>UW(t,a(t))),t.focusInput(),!0),updateTableOfContents:()=>(t.applyTransactionalState(t=>GW(t,a(t))),t.focusInput(),!0),pastePlainText:()=>(t.forcePlainTextPaste.set(!0),t.focusInput(),!0),bold:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),strike:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),superscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(t.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(t.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(t.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(t.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(t.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(t.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(t.findReplace.setIsOpen(!0),!0),replace:()=>(t.findReplace.setIsOpen(!0),!0),toggleTrackChanges:()=>(t.commandsController.applyToggleTrackChangesCommand(),!0),acceptRevisions:()=>(t.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(t.commandsController.applyRejectRevisionsCommand(),!0),toggleShowMargins:()=>(t.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(t.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(_s(),!0),pageBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>TR(t))),t.focusInput(),!0),lineBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>mR(t,"\n"))),t.focusInput(),!0),splitBlock:()=>(t.commandsController.handleListEnter()||(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>IR(t))),t.focusInput()),!0),setFontFamily:e=>(t.styleController.applyToolbarValueStyleCommand("fontFamily",e),!0),setFontSize:e=>(t.styleController.applyToolbarValueStyleCommand("fontSize",e),!0),increaseFontSize:()=>e("increase"),decreaseFontSize:()=>e("decrease"),changeTextCase:e=>(t.commandsController.applyChangeTextCaseCommand(e),!0),clearFormatting:()=>Ga(t.state().selection)?(t.styleController.clearPendingCaretTextStyle(),t.focusInput(),!0):(t.commandsController.applyClearFormattingCommand(),!0),setColor:e=>(t.styleController.applyToolbarValueStyleCommand("color",e),!0),setHighlight:e=>(t.styleController.applyToolbarValueStyleCommand("highlight",e),!0),setTextShading:e=>(t.styleController.applyToolbarValueStyleCommand("shading",e),!0),setStyleId:e=>(t.commandsController.handleStyleChange(e),!0),setCharacterStyleId:e=>(t.styleController.applyToolbarValueStyleCommand("styleId",e||null),!0),setUnderlineStyle:e=>t.styleController.applyToolbarValueStyleCommand("underlineStyle",e)},document:{documentStyles:()=>{var e,a;const n=t.state().document,r=(null==n?void 0:n.styles)??{},o=new Set;for(const t of ba(n)){(null==(e=t.style)?void 0:e.styleId)&&o.add(t.style.styleId);for(const e of t.runs)(null==(a=e.styles)?void 0:a.styleId)&&o.add(e.styles.styleId)}return Object.values(r).map(t=>{var e;const a=oa(t.id,r);return{id:t.id,name:t.name,type:t.type,qFormat:t.qFormat,uiPriority:t.uiPriority,semiHidden:t.semiHidden,unhideWhenUsed:t.unhideWhenUsed,isUsed:o.has(t.id),fontFamily:(null==(e=a.fontFamily)?void 0:e.trim())||void 0,fontSize:"number"==typeof a.fontSize?a.fontSize:void 0,color:a.color??void 0,bold:a.bold??void 0,italic:a.italic??void 0}})},exportDocx:()=>{t.docIO.handleExportDocx()},exportPdf:()=>{t.docIO.handleExportPdf()},importDocument:()=>{var e;return null==(e=t.importInputRef())?void 0:e.click()},insertImage:()=>{var e;return null==(e=t.imageInputRef())?void 0:e.click()},insertShape:e=>t.applyTransactionalState(t=>function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i={width:150,height:100,blocks:[Ja("")],shape:{preset:e,fill:"#4472C4",borderColor:"#2F528F",borderWidthPt:1},floating:Uq(void 0,"front")},l=$V(n,o,[Ya("",JV(n,o),void 0,i)]);return rR(a,Na(a).map((t,e)=>e===r?l:MA(t)),iR(_e(l,o+1)))}(t,e))},link:{prompt:()=>t.commandsController.promptForLink(),remove:()=>t.commandsController.removeLinkCommand(),canPrompt:()=>!Ga(t.state().selection)||Boolean(t.styleController.toolbarStyleState().link)},image:{promptAlt:()=>t.commandsController.promptForImageAlt(),promptCaption:()=>t.commandsController.promptForImageCaption(),isSelected:()=>Boolean(t.selectedImageRun())},browser:{print:()=>window.print(),copy:()=>{document.execCommand("copy")}},paragraph:{togglePageBreakBefore:()=>t.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>t.commandsController.toggleParagraphFlagCommand("keepWithNext"),setSpacingAfter:e=>t.commandsController.applyParagraphStyleCommand("spacingAfter",e),setSpacingBefore:e=>t.commandsController.applyParagraphStyleCommand("spacingBefore",e),setIndentLeft:e=>t.commandsController.applyParagraphStyleCommand("indentLeft",e),setIndentRight:e=>t.commandsController.applyParagraphStyleCommand("indentRight",e),setIndentFirstLine:e=>t.commandsController.applyParagraphStyleCommand("indentFirstLine",e),setIndentHanging:e=>t.commandsController.applyParagraphStyleCommand("indentHanging",e),setSpecialIndent:(e,a)=>{const n=a??48;t.applyTransactionalState(t=>{let a=kR(t,"indentFirstLine",null);return a=kR(a,"indentHanging",null),"firstLine"===e?a=kR(a,"indentFirstLine",n):"hanging"===e&&(a=kR(a,"indentHanging",n)),a},{mergeKey:xV}),t.focusInput()},setShading:e=>t.commandsController.applyParagraphStyleCommand("shading",e),applyBorders:()=>{const e={width:1,type:"solid",color:"#000000"};t.applyTransactionalState(t=>{let a=kR(t,"borderTop",e);return a=kR(a,"borderRight",e),a=kR(a,"borderBottom",e),a=kR(a,"borderLeft",e),a},{mergeKey:wV}),t.focusInput()},setLineHeight:e=>t.commandsController.applyParagraphStyleCommand("lineHeight",e),setListFormat:e=>t.commandsController.handleListFormatChange(e),setListStartAt:e=>t.commandsController.handleListStartAtChange(e),outdent:()=>{t.commandsController.handleListTab("outdent")},indent:()=>{t.commandsController.handleListTab("indent")}},section:n,table:(()=>{const e=(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()};return{insideTable:()=>Boolean(xa(t.state().document,t.state().selection.focus.paragraphId,Ea(t.state()))),selectionLabel:()=>{if(Da(t.state()).isCollapsed)return null;const e=Ea(t.state()),a=xa(t.state().document,t.state().selection.anchor.paragraphId,e),n=xa(t.state().document,t.state().selection.focus.paragraphId,e);if(!a||!n||a.blockIndex!==n.blockIndex||a.rowIndex===n.rowIndex&&a.cellIndex===n.cellIndex)return null;const r=t.selectionBoxes().length;return 0===r?null:`Table selection: ${r} cell${1===r?"":"s"}`},canMerge:()=>t.tableOps.canMergeSelectedTable(t.state()),canSplit:()=>t.tableOps.canSplitSelectedTable(t.state()),canEditColumn:()=>t.tableOps.canEditSelectedTableColumn(t.state()),canEditRow:()=>t.tableOps.canEditSelectedTableRow(t.state()),merge:()=>e(e=>t.tableOps.mergeSelectedTable(e),EV),split:()=>e(e=>t.tableOps.splitSelectedTable(e),LV),insertColumnBefore:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,-1),zV),insertColumnAfter:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,1),zV),deleteColumn:()=>e(e=>t.tableOps.deleteSelectedTableColumn(e),NV),insertRowBefore:()=>e(e=>t.tableOps.insertSelectedTableRow(e,-1),OV),insertRowAfter:()=>e(e=>t.tableOps.insertSelectedTableRow(e,1),OV),deleteRow:()=>e(e=>t.tableOps.deleteSelectedTableRow(e),qV),cellShading:t=>e(e=>PR(e,"shading",t||null),PV),cellBorders:()=>e(t=>WR(t,{width:1,type:"solid",color:"#64748b"}),WV),cellNoBorders:()=>e(t=>WR(t,{width:0,type:"none",color:"transparent"}),WV),width100:()=>e(t=>BR(t,"width","100%"),BV),alignLeft:()=>e(t=>PR(t,"horizontalAlign","left"),FV),alignCenter:()=>e(t=>PR(t,"horizontalAlign","center"),FV),alignRight:()=>e(t=>PR(t,"horizontalAlign","right"),FV),setCellWidth:t=>e(e=>function(t,e){return PR(t,"width",e)}(e,t),HV),insert:(e,a)=>t.tableOps.insertTableCommand(e,a)}})()})}const JW=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",hidden:!0,icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.import",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",hidden:!0},{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",hidden:!0},{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:"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:t=>t.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:t=>t.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:t=>t.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_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:t=>t.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:t=>t.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 QW(t){const e=YW(t.essentials),{runtimePlugins:a,toolbarRegistry:n,menuRegistry:r,dispose:o}=function(t){var e,a;const n=[t.essentialsPlugin,...t.externalPlugins??[]],r=[],o=[],i=Gw(),l=new Dw;for(const s of uA(t.t))i.register(s);for(const s of JW)l.register(s);for(const s of n){for(const t of s.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",row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,order:t.order};i.register(e),r.push(t.id)}for(const t of s.menubar??[])l.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),o.push(t.id)}return null==(e=t.customizeToolbar)||e.call(t,i),null==(a=t.customizeMenubar)||a.call(t,l),{runtimePlugins:n,toolbarRegistry:i,menuRegistry:l,dispose:()=>{for(const t of r)i.remove(t);for(const t of o)l.unregister(t)}}}({essentialsPlugin:e,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),i=function(t){const[e,a]=y(!1),[n,r]=y(new fn({doc:t.initialDocument}));let o=!1;const i=t=>{var e;const a=Yt(t),r=n().commands.get(a);if(!r)return{isEnabled:!1,isActive:!1,value:void 0};const o=(null==(e=r.refresh)?void 0:e.call(r))??{isEnabled:!0};return{isEnabled:!1!==o.isEnabled,isActive:Boolean(o.isActive),value:o.value}};return{runtimeReady:e,runtimeEditor:n,commandStateOf:i,toolbarHost:()=>({commands:{execute:(t,e)=>{const a=Jt(t,e);return n().commands.execute(a.name,a.payload)},canExecute:(t,e)=>{const a=Jt(t,e);return n().commands.canExecute(a.name,a.payload)},state:i},focusEditor:t.focusEditor}),initialize:async()=>{var e,i;try{const e=await fn.create({doc:t.initialDocument,plugins:t.runtimePlugins});if(o)return void(await e.destroy());const i=n();r(e),await i.destroy(),a(!0),requestAnimationFrame(()=>{var a,n;null==(a=t.onSettled)||a.call(t),null==(n=t.onReady)||n.call(t,e)})}catch(l){t.logger.error("runtime:init failed",l),null==(e=t.onError)||e.call(t,l),null==(i=t.onSettled)||i.call(t)}},dispose:async()=>{o=!0,await n().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:a,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return C(()=>{i.initialize()}),I(()=>{i.dispose(),o()}),{toolbarRegistry:n,menuRegistry:r,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}function _W(t){const{document:e,interaction:a,runtimeClient:n}=t,{commandsController:r,keyboardCommandsController:o}=function(t){const e=RW({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,applySelectionAwareTextCommand:t.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:t.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,toolbarStyleState:t.toolbarStyleState,selectionCollapsed:()=>Ga(t.state.selection),selectedImageRun:t.selectedImageRun,openLinkDialog:e=>t.setLinkDialog({isOpen:!0,initialHref:e}),openImageAltDialog:e=>t.setImageAltDialog({isOpen:!0,initialAlt:e}),openImageCaptionDialog:e=>t.setImageCaptionDialog({isOpen:!0,initialCaption:e}),imageCaptionLabel:()=>t.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:e,keyboardCommandsController:{...e,applyBooleanStyleCommand:e=>t.applyBooleanStyleCommand(e)}}}({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:t.focusInput,selectedImageRun:a.selectedImageRun,tableOps:a.tableOps,toolbarStyleState:a.styleController.toolbarStyleState,applyBooleanStyleCommand:t=>a.styleController.applyToolbarBooleanStyleCommand(t),locale:t.locale,setLinkDialog:t.setLinkDialog,setImageAltDialog:t.setImageAltDialog,setImageCaptionDialog:t.setImageCaptionDialog}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h}=QW({essentials:{state:()=>t.state,isReadOnly:t.isReadOnly,forcePlainTextPaste:{get:t.getForcePlainTextPaste,set:t.setForcePlainTextPaste},undoStack:e.undoStack,redoStack:e.redoStack,commandsController:r,keyboardCommandsController:o,historyActions:e.historyActions,styleController:a.styleController,tableOps:a.tableOps,docIO:e.docIO,importInputRef:t.importInputRef,imageInputRef:t.imageInputRef,selectedImageRun:a.selectedImageRun,selectionBoxes:e.selectionBoxes,focusInput:t.focusInput,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,findReplace:{setIsOpen:a.fr.setIsOpen}},externalPlugins:t.runtimeOptions().plugins,t:t.translator,customizeToolbar:t.runtimeOptions().customizeToolbar,customizeMenubar:t.runtimeOptions().customizeMenubar,initialDocument:t.getStateSnapshot().document,focusEditor:t.focusInput,logger:t.logger,onReady:e=>{var a,r;n.resolveReady(e),null==(r=(a=t.runtimeOptions()).onReady)||r.call(a,n)},onSettled:()=>{t.setInitialLoading(!1)},onError:t=>n.rejectReady(t)});!function(t,e){const a=()=>e.cloneState(e.getStateSnapshot());t.connectHost({getRuntimeEditor:()=>e.runtimeReady()?e.runtimeEditor():null,getState:()=>a(),getDocument:()=>a().document,setDocument:t=>{e.applyState(rn(t)),e.resetEditorChromeState(),e.focusInput()},resetDocument:()=>{e.applyState(ln()),e.resetEditorChromeState(),e.focusInput()},saveDocument:async()=>{await e.getPersistence().saveDocument(a().document)},getSelection:()=>a().selection,setSelection:t=>{e.applyState({...a(),selection:t}),e.focusInput()},focus:()=>e.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.setFocused(!1)},clearHistory:()=>e.clearHistory(),importDocx:t=>e.docIO.handleImportFile(t),exportDocx:()=>e.docIO.handleExportDocx(),exportPdf:()=>e.docIO.handleExportPdf()})}(n,{runtimeReady:i,runtimeEditor:l,getStateSnapshot:t.getStateSnapshot,cloneState:t.cloneState,applyState:t.applyState,resetEditorChromeState:e.resetEditorChromeState,focusInput:t.focusInput,setFocused:t.setFocused,clearHistory:e.clearHistory,getPersistence:()=>t.documentOptions().persistence??e.fallbackPersistence,docIO:e.docIO}),x(()=>{if(!i())return;t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone;const e=t.cloneState(t.getStateSnapshot());l().dispatch(()=>e)});const{handleKeyDown:p}=function(t){const{state:e,isReadOnly:a,logger:n,focusInput:r,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:d,selectedImageRun:c,commandsController:h,tableOps:p,navigation:u,historyActions:f,styleController:g,findReplace:m,runtimeEditor:v}=t,{handleKeyDown:b}=zW({state:e,isReadOnly:a,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:h,selectedImageRun:c,setForcePlainTextPaste:d,moveSelectionByWord:u.moveSelectionByWord,moveSelectionToDocumentBoundary:u.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:u.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:u.moveVerticalSelection,moveVerticalByBlock:u.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:t=>{m.setIsOpen(t??!m.isOpen())},toggleReplace:t=>{m.setIsOpen(t??!m.isOpen())},executeCommand:(t,e)=>v().commands.execute(t,e),canExecuteCommand:t=>v().commands.canExecute(t)});return{handleKeyDown:t=>{NW.includes(t.key)&&g.clearPendingCaretTextStyle();const a=[t.ctrlKey?"Ctrl":null,t.metaKey?"Meta":null,t.altKey?"Alt":null,t.shiftKey?"Shift":null].filter(Boolean).join("+"),r=a?`${a}+${t.key}`:t.key,o=e().selection;n.debug(`key:down ${r} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),hd("input-to-layout"),b(t),pd("input-to-layout")}}}({state:()=>t.state,isReadOnly:t.isReadOnly,logger:t.logger,focusInput:t.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,setForcePlainTextPaste:t.setForcePlainTextPaste,selectedImageRun:a.selectedImageRun,commandsController:o,tableOps:a.tableOps,navigation:a.navigation,historyActions:e.historyActions,styleController:a.styleController,findReplace:a.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h,handleKeyDown:p}}var $W=gt('<div class="oasis-editor-shell oasis-editor-app">');const tB=Object.freeze(Object.defineProperty({__proto__:null,OasisEditorApp:function(t={}){var e;const a=(null==(e=t.runtime)?void 0:e.client)??Qt(),n=()=>t.ui??{},r=()=>t.document??{};lV();const o=Wt(()=>n().locale??"pt-BR"),i=bl("app"),{state:l,commitState:s,getStateSnapshot:d}=function(t){const e=t.initialState?RA(t.initialState):t.initialDocument?rn(t.initialDocument):ln();let a=e;const[n,r]=y(e);return{state:new Proxy({},{get(t,e){const a=n();if(null!==a&&("object"==typeof a||"function"==typeof a))return Reflect.get(a,e)},has(t,e){const a=n();return null!==a&&("object"==typeof a||"function"==typeof a)&&Reflect.has(a,e)},ownKeys(t){const e=n();return null===e||"object"!=typeof e&&"function"!=typeof e?[]:Reflect.ownKeys(e)},getOwnPropertyDescriptor(t,e){const a=n();return null===a||"object"!=typeof a&&"function"!=typeof a?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(a,e),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:t=>{a=t,r(t)},getStateSnapshot:()=>a}}({initialDocument:r().initialDocument,initialState:r().initialState}),c=t=>{s(t)},h=RA;let p=!1;const{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x,isReadOnly:S,useComposedShell:A,loadingOptions:T,loadingLabel:k,shellComponent:V}=function(t){const{ui:e,documentOptions:a}=t,n=()=>{const t=e().loading;return"object"==typeof t&&null!==t?t:void 0};return{showChrome:()=>e().showChrome??!0,showTitleBar:()=>e().showTitleBar??!0,showMenubar:()=>e().showMenubar??!0,showToolbar:()=>e().showToolbar??!0,showOutline:()=>e().showOutline??!0,toolbarView:()=>{var t;return(null==(t=e().toolbar)?void 0:t.view)??"ribbon"},toolbarLayout:()=>{var t;return(null==(t=e().toolbar)?void 0:t.layout)??"overflow"},isReadOnly:()=>a().readOnly??!1,useComposedShell:()=>"docs"===e().uiVariant||"document"!==(e().shell??"document"),loadingOptions:n,loadingLabel:()=>{var t;return(null==(t=n())?void 0:t.label)??"Loading oasis-editor..."},shellComponent:()=>{const t=e().shell??"document";return"inline"===t?Nx:"balloon"===t?Px:Ex}}}({ui:n,documentOptions:r}),R=function(){const[t,e]=y(!1);let a,n,r,o,i;return{focused:t,setFocused:e,focusInput:()=>{e(!0),queueMicrotask(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{e(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},get viewportRef(){return a},set viewportRef(t){a=t},get surfaceRef(){return n},set surfaceRef(t){n=t},get textareaRef(){return r},set textareaRef(t){r=t},get importInputRef(){return o},set importInputRef(t){o=t},get imageInputRef(){return i},set imageInputRef(t){i=t}}}(),E=R.focused,L=R.setFocused,z=R.focusInput,N=R.focusInputAfterPointerSelection,[O,q]=y(!1!==n().loading),P=function(t=100){const[e,a]=y(tx(t)),n=w(()=>e()/100);return{zoomPercent:e,setZoomPercent:t=>a(tx(t)),adjustZoom:t=>a(e=>tx(e+t)),zoomFactor:n}}(),{linkDialog:W,setLinkDialog:B,imageAltDialog:F,setImageAltDialog:H,imageCaptionDialog:U,setImageCaptionDialog:G,contextMenu:D,setContextMenu:j,fontDialog:Z,setFontDialog:X,paragraphDialog:Y,setParagraphDialog:J,tablePropertiesDialog:Q,setTablePropertiesDialog:_}=function(){const[t,e]=y({isOpen:!1,initialHref:""}),[a,n]=y({isOpen:!1,initialAlt:""}),[r,o]=y({isOpen:!1,initialCaption:""}),[i,l]=y({isOpen:!1,x:0,y:0}),[s,d]=y({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}}),[c,h]=y({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",spacingBefore:"",spacingAfter:"",lineHeight:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1}}),[p,u]=y({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{linkDialog:t,setLinkDialog:e,imageAltDialog:a,setImageAltDialog:n,imageCaptionDialog:r,setImageCaptionDialog:o,contextMenu:i,setContextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}}(),[$,tt]=y(!1),et=()=>R.viewportRef,at=()=>R.surfaceRef,nt=mP({documentOptions:r,logger:i,runtimeClient:a,state:l,commitState:s,getStateSnapshot:d,applyState:c,cloneState:h,isReadOnly:S,focusInput:z,surfaceRef:at,viewportRef:et,zoomFactor:P.zoomFactor,getImageOps:()=>Tt.imageOps}),{docIO:ot,measuredBlockHeights:it,measuredParagraphLayouts:lt,documentLayout:st,canvasSnapshotProvider:dt,inputBox:ct,selectionBoxes:ht,commentHighlights:ut,selectedImageBox:ft,selectedTextBoxBox:gt,caretBox:mt,preferredColumnX:vt,setPreferredColumnX:bt,clearPreferredColumn:yt,onCleanupHook:Mt,persistenceStatus:xt,applyTransactionalState:St,resetTransactionGrouping:At,updateHistoryState:It}=nt,Tt=xW({state:l,logger:i,isReadOnly:S,applyState:c,cloneState:h,focusInput:z,focusInputAfterPointerSelection:N,surfaceRef:at,viewportRef:et,zoomFactor:P.zoomFactor,insertImageFromFile:ot.insertImageFromFile,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},getCommandsController:()=>Xt.commandsController,applyTransactionalState:St,clearPreferredColumn:yt,resetTransactionGrouping:At,updateHistoryState:It,caretBox:mt,preferredColumnX:vt,setPreferredColumnX:bt,documentLayout:st,canvasSnapshotProvider:dt}),{layoutOptionsOverlay:kt,fr:Vt,tableOps:Rt,imageOps:Et,textBoxOps:Lt,styleController:zt,onEditorMouseDown:Nt,tableResize:Ot,tableDrag:qt,revisionController:Pt,textDrag:Bt,surfaceEventsWithTextDrag:Ft,textInput:Ut,handleCopy:Gt,handleCut:Dt,handlePaste:jt,handleDrop:Zt}=Tt,Xt=_W({document:nt,interaction:Tt,state:l,logger:i,isReadOnly:S,focusInput:z,applyState:c,getStateSnapshot:d,cloneState:h,setFocused:L,setInitialLoading:q,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},locale:()=>n().locale??"pt-BR",translator:o,runtimeClient:a,runtimeOptions:()=>t.runtime??{},documentOptions:r,importInputRef:()=>R.importInputRef,imageInputRef:()=>R.imageInputRef,setLinkDialog:B,setImageAltDialog:H,setImageCaptionDialog:G}),{commandsController:Yt,runtimeReady:Jt,runtimeEditor:_t,commandStateOf:$t,toolbarHost:te,toolbarRegistry:ee,menuRegistry:ae,handleKeyDown:ne}=Xt,{computeFontFamilyOptions:re,computeFontSizeOptions:oe,applyFontDialogValues:ie,applyParagraphDialogValues:le,applyTablePropertiesDialogValues:se,buildContextMenuItems:de,handleEditorContextMenu:ce,closeContextMenu:he}=mE({state:()=>l,selection:()=>l.selection,toolbarStyleState:zt.toolbarStyleState,isReadOnly:S,t:o,logger:i,setFontDialog:X,setParagraphDialog:J,setTablePropertiesDialog:_,setContextMenu:j,clearPreferredColumn:yt,resetTransactionGrouping:At,applyTransactionalState:St,applyTableAwareParagraphEdit:Rt.applyTableAwareParagraphEdit,focusInput:z,promptForLink:Yt.promptForLink,tableOps:Rt}),{layout:pe,overlays:ue,refs:fe,surfaceHandlers:ge,inputHandlers:me,fileHandlers:ve}=function(t){const{layout:e,overlays:a,refs:n,surface:r,input:o,files:i}=t,l={onImportInputChange:t=>{var e;return i.handleImportFile((null==(e=t.currentTarget.files)?void 0:e[0])??null)},onImageInputChange:t=>{var e;return i.handleInsertImage((null==(e=t.currentTarget.files)?void 0:e[0])??null)}};return{layout:{documentLayout:e.documentLayout,viewportHeight:e.viewportHeight,class:e.className,style:e.style,zoomPercent:e.zoomPercent,setZoomPercent:e.setZoomPercent,zoomFactor:e.zoomFactor},overlays:{selectionBoxes:a.selectionBoxes,commentHighlights:a.commentHighlights,selectedImageBox:a.selectedImageBox,selectedTextBoxBox:a.selectedTextBoxBox,layoutOptions:a.layoutOptions,caretBox:a.caretBox,inputBox:a.inputBox,hoveredRevision:a.hoveredRevision,focused:a.focused,showCaret:a.showCaret,importProgress:a.importProgress},refs:{onViewportRef:t=>{n.focusController.viewportRef=t},onSurfaceRef:t=>{n.focusController.surfaceRef=t},onTextareaRef:t=>{n.focusController.textareaRef=t},onImportInputRef:t=>{n.focusController.importInputRef=t},onImageInputRef:t=>{n.focusController.imageInputRef=t}},surfaceHandlers:{onDragOver:t=>t.preventDefault(),onDrop:r.handleDrop,onEditorMouseDown:r.onEditorMouseDown,onSurfaceMouseDown:r.surfaceEvents.handleSurfaceMouseDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfaceMouseMove:r.tableResize.handleMouseMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphMouseDown:r.surfaceEvents.handleParagraphMouseDown,onImageMouseDown:r.handleImageMouseDown,onImageResizeHandleMouseDown:r.handleImageResizeHandleMouseDown,onTextBoxResizeHandleMouseDown:r.handleTextBoxResizeHandleMouseDown,onImageRotateHandleMouseDown:r.handleImageRotateHandleMouseDown,onTextBoxRotateHandleMouseDown:r.handleTextBoxRotateHandleMouseDown,onTableDragHandleMouseDown:r.tableDrag.handleMouseDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:t=>r.handleEditorContextMenu(t)},inputHandlers:{onInputBlur:()=>o.setFocused(!1),onInputFocus:()=>o.setFocused(!0),onCompositionEnd:o.textInput.handleCompositionEnd,onCompositionStart:o.textInput.handleCompositionStart,onCopy:o.handleCopy,onCut:o.handleCut,onInput:o.textInput.handleTextInput,onKeyDown:o.handleKeyDown,onPaste:o.handlePaste},fileHandlers:l}}({layout:{documentLayout:st,viewportHeight:n().viewportHeight,className:n().class,style:n().style,zoomPercent:P.zoomPercent,setZoomPercent:P.setZoomPercent,zoomFactor:P.zoomFactor},overlays:{selectionBoxes:ht,commentHighlights:ut,selectedImageBox:ft,selectedTextBoxBox:gt,layoutOptions:kt,caretBox:mt,inputBox:ct,hoveredRevision:Pt.hoveredRevision,focused:E,showCaret:()=>function(t,e){if(!e.visible||!Ga(t.selection))return!1;const a=Ea(t),n=xa(t.document,t.selection.anchor.paragraphId,a),r=xa(t.document,t.selection.focus.paragraphId,a);return!(n&&r&&n.blockIndex===r.blockIndex&&(n.rowIndex!==r.rowIndex||n.cellIndex!==r.cellIndex))}(l,mt()),importProgress:ot.importProgress},refs:{focusController:R},files:{handleImportFile:ot.handleImportFile,handleInsertImage:ot.handleInsertImage},surface:{surfaceEvents:Ft,tableResize:Ot,tableDrag:qt,revisionController:Pt,handleDrop:Zt,onEditorMouseDown:Nt,handleImageMouseDown:Et.handleImageMouseDown,handleImageResizeHandleMouseDown:Et.handleImageResizeHandleMouseDown,handleTextBoxResizeHandleMouseDown:Lt.handleTextBoxResizeHandleMouseDown,handleImageRotateHandleMouseDown:Et.handleImageRotateHandleMouseDown,handleTextBoxRotateHandleMouseDown:Lt.handleTextBoxRotateHandleMouseDown,handleEditorContextMenu:ce},input:{textInput:Ut,setFocused:L,handleCopy:Gt,handleCut:Dt,handlePaste:jt,handleKeyDown:ne}});return C(()=>{!function(t=document.body){tV||($k({icons:_k,nameAttr:"data-lucide",root:t}),tV=new MutationObserver(e=>{let a=!1;for(const t of e)if(t.addedNodes.length>0||"attributes"===t.type){a=!0;break}a&&tV&&(tV.disconnect(),$k({icons:_k,nameAttr:"data-lucide",root:t}),tV.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}),tV.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}(),function(){if(!dd&&window.PerformanceObserver)try{dd=new PerformanceObserver(t=>{for(const e of t.getEntries())sd.push({duration:Fl(e.duration,2),startTime:Math.round(e.startTime)})}),dd.observe({type:"longtask",buffered:!0})}catch{}}(),window.__OASIS_PERF_REPORT=()=>{const t=ld.filter(t=>t.name.startsWith("layout:")).map(t=>t.duration),e=ld.filter(t=>"input-to-layout"===t.name).map(t=>t.duration),a=ld.filter(t=>"input:text"===t.name).map(t=>t.duration),n=md(t),r=md(e),o=md(a),i=md(sd.map(t=>t.duration));console.group("%c[perf] Summary","color: #f59e0b; font-weight: bold;"),console.info(`input:text → p50=${o.p50}ms p95=${o.p95}ms p99=${o.p99}ms max=${o.max}ms (n=${o.count})`),console.info(`input-to-layout → p50=${r.p50}ms p95=${r.p95}ms p99=${r.p99}ms max=${r.max}ms (n=${r.count})`),console.info(`layout:sync → p50=${n.p50}ms p95=${n.p95}ms p99=${n.p99}ms max=${n.max}ms (n=${n.count})`),console.info(`longtasks → p50=${i.p50}ms p95=${i.p95}ms p99=${i.p99}ms max=${i.max}ms (n=${i.count})`),console.groupEnd()},window.__OASIS_DOM_STATS=()=>{const t=(e=(null==fd?void 0:fd())??null)?{totalNodes:e.querySelectorAll("*").length,pages:e.querySelectorAll('[data-renderer="canvas"][data-page-index]').length,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0}:{totalNodes:0,pages:0,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0};var e;return console.info("%c[perf] DOM stats","color: #f59e0b; font-weight: bold;",t),t},fd=()=>at()??null,$s(),"1"!==Bs(Ps)&&Ks()&&tt(!0)}),I(()=>{Mt(),Ft.stopDragging(),Bt.stopDrag(),Et.stopImageDrag(),Et.stopImageResize(),Lt.stopTextBoxResize(),null==tV||tV.disconnect(),tV=null}),K(Ht,{translator:o,get children(){var t=$W();return wt(t,"--oasis-editor-gutter-x","34px"),Ct(t,K(rt,{get when(){return pt(()=>!(A()||!u()))()&&m()},get children(){return K(Co,{host:te,registry:ee,get view(){return b()},get layout(){return x()}})}}),null),Ct(t,K(IL,{dialogs:{linkDialog:W,setLinkDialog:B,imageAltDialog:F,setImageAltDialog:H,imageCaptionDialog:U,setImageCaptionDialog:G,contextMenu:D,setContextMenu:j,fontDialog:Z,setFontDialog:X,paragraphDialog:Y,setParagraphDialog:J,tablePropertiesDialog:Q,setTablePropertiesDialog:_},findReplace:Vt,fontFamilyOptions:re,fontSizeOptions:oe,contextMenuItems:de,focusInput:z,get applyLinkCommand(){return Yt.applyLinkCommand},get applyImageAltCommand(){return Yt.applyImageAltCommand},get applyImageCaptionCommand(){return Yt.applyImageCaptionCommand},applyFontDialogValues:ie,applyParagraphDialogValues:le,applyTablePropertiesDialogValues:se,closeContextMenu:he}),null),Ct(t,K(kL,{useComposedShell:A,shellComponent:V,runtime:{state:()=>l,toolbarHost:te,runtimeEditor:_t,persistenceStatus:xt,toolbarRegistry:ee,menuRegistry:ae,showFloatingTableToolbar:()=>!S()&&null!==$t("tableContext").value},chrome:{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x},view:{isReadOnly:S,viewportHeight:()=>n().viewportHeight,measuredBlockHeights:it,measuredParagraphLayouts:lt,documentLayout:st,layout:pe,overlays:ue,refs:fe,surfaceHandlers:ge,inputHandlers:me,fileHandlers:ve}}),null),Ct(t,K(xE,{state:l,get surfaceRef(){return at()},documentLayout:st,snapshotProvider:dt,get zoomFactor(){return P.zoomFactor},tableResize:Ot,imageOps:Et,tableDrag:qt,textDrag:Bt}),null),Ct(t,K(rt,{get when(){return O()||!Jt()},get children(){return K(Kt,{get label(){return k()},get class(){var t;return null==(t=T())?void 0:t.class},get style(){var t;return null==(t=T())?void 0:t.style}})}}),null),Ct(t,K(RL,{get isOpen(){return pt(()=>!(!$()||O()))()&&Jt()},onClose:()=>tt(!1)}),null),M(e=>{var a=!!A(),n=!!S();return a!==e.e&&t.classList.toggle("oasis-editor-docs",e.e=a),n!==e.t&&t.classList.toggle("oasis-editor-read-only",e.t=n),e},{e:void 0,t:void 0}),t}})}},Symbol.toStringTag,{value:"Module"}));t.ActionRow=function(t){const[e,a]=$(t,["align","wrap","class","classList","children"]);return St(n=Yx(),_({get class(){return`oasis-editor-ui-action-row ${e.class??""}`},get classList(){return{[`oasis-editor-ui-action-row-${e.align??"start"}`]:!0,"oasis-editor-ui-action-row-nowrap":!1===e.wrap,...e.classList}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.BalloonShell=Px,t.Button=Kx,t.Checkbox=bw,t.ColorField=fw,t.ColorPicker=Tr,t.CommandRegistry=dn,t.DEFAULT_PALETTE=Nr,t.Dialog=Fx,t.DialogFooter=function(t){const[e,a]=$(t,["align","class","classList","children"]);return St(n=Fw(),_({get class(){return`oasis-editor-ui-dialog-footer ${e.class??""}`},get classList(){return{[`oasis-editor-ui-dialog-footer-${e.align??"end"}`]:!0,...e.classList}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.DocumentShell=Ex,t.Editor=fn,t.FieldGroup=Pw,t.FieldRow=function(t){const[e,a]=$(t,["align","class","style","children"]);return St(n=zw(),_({get class(){return`oasis-editor-ui-field-row ${e.class??""}`},get style(){return{"align-items":Nw[e.align??"end"],..."object"==typeof e.style?e.style:{}}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.FloatingActionButton=gx,t.FormField=iw,t.Grid=nw,t.GridPicker=zr,t.Heading=function(t){const[e,a]=$(t,["level","class","classList","children"]),n=e.level??2;return K(Ot,_({component:`h${n}`,get class(){return`oasis-editor-ui-heading ${e.class??""}`},get classList(){return{[`oasis-editor-ui-heading-${n}`]:!0,...e.classList}}},a,{get children(){return e.children}}))},t.IconButton=wx,t.InlineShell=Nx,t.Menu=dr,t.MenuRegistry=Dw,t.NumberField=Cw,t.OASIS_BUILTIN_COMMANDS=["selectAll","insertFootnote","insertTableOfContents","updateTableOfContents","pastePlainText","bold","italic","underline","strike","superscript","subscript","link","unlink","alignLeft","alignCenter","alignRight","alignJustify","orderedList","bulletList","find","replace","toggleTrackChanges","acceptRevisions","rejectRevisions","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","undo","redo","pageBreak","lineBreak","splitBlock","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setStyleId","setCharacterStyleId","setUnderlineStyle","documentStyles","print","copy","exportDocx","exportPdf","importDocument","insertImage","editImageAlt","insertImageCaption","outdent","indent","togglePageBreakBefore","toggleKeepWithNext","setSpacingAfter","setSpacingBefore","setIndentLeft","setIndentRight","setIndentFirstLine","setIndentHanging","setSpecialIndent","setParagraphShading","applyParagraphBorders","setLineHeight","setListFormat","setListStartAt","toggleOrientation","setOrientation","sectionBreakNextPage","sectionBreakContinuous","setPageMargins","tableContext","tableMerge","tableSplit","tableInsertColumnBefore","tableInsertColumnAfter","tableDeleteColumn","tableInsertRowBefore","tableInsertRowAfter","tableDeleteRow","tableCellShading","tableCellBorders","tableCellNoBorders","tableWidth100","tableAlignLeft","tableAlignCenter","tableAlignRight","tableSetCellWidth","insertTable"],t.OASIS_MENU_ITEMS={fileNew:"file_new",fileImport:"file_import",fileSave:"file_save",fileExport:"file_export",fileExportPdf:"file_export_pdf",fileExportDocx:"file_export_docx",filePrint:"file_print",editUndo:"edit_undo",editRedo:"edit_redo",editCopy:"edit_copy",editFind:"edit_find",editSelectAll:"edit_selectAll",viewMargins:"view_margins",viewParagraphMarks:"view_paragraph_marks",viewPreciseFonts:"view_precise_fonts",insertImage:"insert_image",insertImageCaption:"insert_image_caption",insertTable:"insert_table",insertLink:"insert_link",insertFootnote:"insert_footnote",insertPageBreak:"insert_pageBreak",formatText:"format_text",formatTextBold:"format_text_bold",formatTextItalic:"format_text_italic",formatTextUnderline:"format_text_underline",formatTextStrike:"format_text_strike",formatAlign:"format_align",formatAlignLeft:"format_align_left",formatAlignCenter:"format_align_center",formatAlignRight:"format_align_right",formatAlignJustify:"format_align_justify",formatLists:"format_lists",formatListsBullet:"format_lists_bullet",formatListsNumbered:"format_lists_numbered"},t.OASIS_TOOLBAR_ITEMS={fileDropdown:"editor-toolbar-file-dropdown",exportDocx:"editor-toolbar-export-docx",exportPdf:"editor-toolbar-export-pdf",importDocument:"editor-toolbar-import-document",undo:"editor-toolbar-undo",redo:"editor-toolbar-redo",style:"editor-toolbar-style",fontFamily:"editor-toolbar-font-family",fontSize:"editor-toolbar-font-size",color:"editor-toolbar-color",highlight:"editor-toolbar-highlight",textShading:"editor-toolbar-text-shading",bold:"editor-toolbar-bold",italic:"editor-toolbar-italic",underlineControl:"editor-toolbar-underline-control",strike:"editor-toolbar-strike",superscript:"editor-toolbar-superscript",subscript:"editor-toolbar-subscript",insertImage:"editor-toolbar-insert-image",insertTable:"editor-toolbar-insert-table",link:"editor-toolbar-link",unlink:"editor-toolbar-unlink",footnote:"editor-toolbar-footnote",imageAlt:"editor-toolbar-image-alt",imageCaption:"editor-toolbar-image-caption",alignLeft:"editor-toolbar-align-left",alignCenter:"editor-toolbar-align-center",alignRight:"editor-toolbar-align-right",alignJustify:"editor-toolbar-align-justify",bulletList:"editor-toolbar-list-bullet",orderedList:"editor-toolbar-list-ordered",outdent:"editor-toolbar-list-outdent",indent:"editor-toolbar-list-indent",listOptions:"editor-toolbar-list-options",specialIndent:"editor-toolbar-special-indent",lineSpacing:"editor-toolbar-line-spacing-control",metrics:"editor-toolbar-metrics",table:"editor-toolbar-table",margins:"editor-toolbar-margins",section:"editor-toolbar-section"},t.OasisEditorAppLazy=Xt,t.OasisEditorContainer=_t,t.OasisEditorLoading=Kt,t.PluginCollection=sn,t.Popover=ar,t.RIBBON_TABS=Kr,t.Radio=Ew,t.RadioGroup=Lw,t.Select=hr,t.SelectField=Aw,t.Separator=ur,t.SidePanel=bx,t.SidePanelBody=Mx,t.SidePanelFooter=function(t){const[e,a]=$(t,["class","children"]);return St(n=vx(),_({get class(){return`oasis-editor-plugin-side-panel-footer ${e.class??""}`}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.SidePanelHeader=yx,t.SplitButton=gr,t.Stack=aw,t.StatusText=Xx,t.StyleGallery=Br,t.SurfaceButton=xn,t.Tabs=jx,t.Text=wn,t.TextAreaField=uw,t.TextField=hw,t.ToggleChip=Bw,t.Toolbar=Co,t.ToolbarButton=$n,t.ToolbarColorPicker=Tr,t.ToolbarGridPicker=zr,t.ToolbarMenu=dr,t.ToolbarSelect=hr,t.ToolbarSeparator=ur,t.ToolbarSplitButton=gr,t.buildRibbonTabDefinitions=Jr,t.commandRefName=Yt,t.createDefaultToolbarPreset=uA,t.createEditorCommandBus=function(t){return{execute(e,a){const n=Jt(e,a);return t.commands.execute(n.name,n.payload)},canExecute(e,a){const n=Jt(e,a);return t.commands.canExecute(n.name,n.payload)},state(e){const a=Jt(e);return t.commands.state(a.name,a.payload)}}},t.createOasisEditor=function(t,e={}){const a=Qt(),n=ft(()=>Xt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createOasisEditorContainer=function(t,e={}){const a=Qt(),n=ft(()=>_t({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createToolbarRegistry=Gw,t.mount=function(t,e={}){const a=Qt(),n=ft(()=>K(Xt,_(e,{get runtime(){return{...e.runtime,client:a}}})),t);return a.setDispose(()=>{n(),t.innerHTML=""}),Object.assign(a,{unmount:()=>a.dispose()})},t.registerToolbarRenderer=function(t,e){jr.set(t,e)},t.resolveCommandRef=Jt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
24
|
+
*/let tV=null;const eV={DEV:!1,MODE:"lib"};let aV=!1,nV=null,rV=null,oV=null,iV=[];function lV(){"undefined"!=typeof window&&(!function(){var t;const e=eV??{},a=(null==(t=globalThis.process)?void 0:t.env)??{};return!0===e.DEV||"test"===e.MODE||"test"===a.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?aV&&(delete window.__oasisCanvasDebug,aV=!1):aV||(window.__oasisCanvasDebug={getLastHit:()=>nV?{...nV}:null,getLayoutSnapshot:()=>rV?{...rV,surfaceRect:{...rV.surfaceRect},pages:rV.pages.map(t=>({...t})),paragraphs:rV.paragraphs.map(t=>({...t,lines:t.lines.map(t=>({...t,slots:t.slots.map(t=>({...t}))})),tableCell:t.tableCell?{...t.tableCell}:void 0})),inlineImages:rV.inlineImages.map(t=>({...t})),inlineTextBoxes:rV.inlineTextBoxes.map(t=>({...t})),unsupportedRegions:rV.unsupportedRegions.map(t=>({...t}))}:null,getSelection:()=>oV?{anchor:{...oV.anchor},focus:{...oV.focus},activeZone:oV.activeZone,activeSectionIndex:oV.activeSectionIndex}:null,getMissEvents:()=>iV.map(t=>({...t})),clearMissEvents:()=>{iV=[]}},aV=!0))}function sV(t){aV&&t&&(nV={timestamp:Date.now(),zone:t.zone,paragraphId:t.paragraphId,paragraphOffset:t.paragraphOffset,source:t.source,missReason:t.missReason,resolvedFromParagraph:t.resolvedFromParagraph})}const dV=["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 cV(t,e,a){const n=null==a?void 0:a.trim();if(!n)return;const r=n.toLowerCase();e.has(r)||(e.add(r),t.push(n))}function hV(t){const[e,a]=y([]);return{computeFontFamilyOptions:()=>function(t,e,a=[]){var n;const r=new Set,o=[],i=[];for(const l of Object.values((null==t?void 0:t.styles)??{}))cV(o,r,null==(n=l.textStyle)?void 0:n.fontFamily);cV(o,r,e.fontFamily);for(const l of a)cV(i,r,l);for(const l of dV)cV(i,r,l);return[...o.sort((t,e)=>t.localeCompare(e)),...i.sort((t,e)=>t.localeCompare(e))]}(t.state().document,t.toolbarStyleState(),e()),computeFontSizeOptions:()=>function(t,e){var a;const n=new Set(Xw);for(const o of Object.values((null==t?void 0:t.styles)??{})){const t=null==(a=o.textStyle)?void 0:a.fontSize;"number"==typeof t&&Number.isFinite(t)&&n.add(Yw(t))}const r=Yw(Number(e.fontSize));return Number.isFinite(r)&&r>0&&n.add(r),Array.from(n).sort((t,e)=>t-e)}(t.state().document,t.toolbarStyleState()),loadLocalFontFamilyOptions:async()=>{if(e().length>0)return;const t=await Xs();t.length>0&&a(t)}}}const pV="insertText",uV="insertImage",fV="insertTable",gV="moveImage",mV="splitListItem",vV="link",bV="imageAlt",yV="imageCaption",MV="layoutWrapPolygon",xV="specialIndent",wV="paraBorders",SV="findReplace",AV="findReplaceAll",CV="tableProperties",IV="paragraph-dialog",TV="font-dialog",kV="copyTextByDrag",VV="moveTextByDrag",RV="collapseSelectionByClick",EV="mergeTable",LV="splitTable",zV="insertTableColumn",NV="deleteTableColumn",OV="insertTableRow",qV="deleteTableRow",PV="tableShading",WV="tableBorders",BV="tableWidth",FV="tableAlign",HV="tableCellWidth",UV="layoutWrapPreset",GV="layoutFixedPosition";function DV(t,e){const a=[];for(const n of t){if(0===n.text.length)continue;const t=a[a.length-1];!t||be(n)||be(t)||!gA(t.styles,n.styles)?a.push({...n,styles:fA(n.styles)}):t.text+=n.text}return a.length>0?a:[Ya("",e)]}function jV(t,e,a){return{...t,runs:DV(e,a),style:t.style?{...t.style}:void 0}}function ZV(t){return Qa(t)}function KV(t,e){const a=ZV(e);return a.style=t.style?{...t.style}:void 0,a.list=xA(t.list),a}function XV(t,e){const a=MA(t);return a.list?(a.list={...a.list,level:Math.max(0,e)},a):a}function YV(t){const e=MA(t);return delete e.list,e}function JV(t,e){var a;if(0===t.runs.length)return;let n=0;for(let r=0;r<t.runs.length;r+=1){const a=t.runs[r],o=n+a.text.length;if(e<o)return fA(a.styles);if(e===o){if(a.text.length>0)return fA(a.styles);const e=t.runs[r+1];return fA((null==e?void 0:e.styles)??a.styles)}n=o}return fA(null==(a=t.runs[t.runs.length-1])?void 0:a.styles)}function QV(t,e){var a,n,r;const o=function(t,e){let a=0;for(let n=0;n<t.runs.length;n+=1){const r=t.runs[n],o=a,i=a+r.text.length;if(e<i)return{run:r,startOffset:o,endOffset:i};if(e===i){if(r.text.length>0)return{run:r,startOffset:o,endOffset:i};const e=t.runs[n+1];return e?{run:e,startOffset:i,endOffset:i+e.text.length}:{run:r,startOffset:o,endOffset:i}}a=i}return null}(t,e),i=null==(a=null==o?void 0:o.run.styles)?void 0:a.link;if(!o||!i||"image"===o.run.kind)return null;let l=o.startOffset,s=o.endOffset,d=0;const c=t.runs,h=c.findIndex(t=>t.id===o.run.id);if(-1===h)return null;for(let p=0;p<h;p+=1)d+=c[p].text.length;l=d,s=d+o.run.text.length;for(let p=h-1;p>=0;p-=1){const t=c[p];if("image"===t.kind||(null==(n=t.styles)?void 0:n.link)!==i)break;l-=t.text.length}for(let p=h+1;p<c.length;p+=1){const t=c[p];if("image"===t.kind||(null==(r=t.styles)?void 0:r.link)!==i)break;s+=t.text.length}return{href:i,startOffset:l,endOffset:s}}function _V(t,e,a){const n=Math.max(0,Math.min(e,Qe(t))),r=Math.max(n,Math.min(a,Qe(t))),o=[];let i=0;for(const l of t.runs){const t=i,e=i+l.text.length,a=Math.max(n,t),s=Math.min(r,e);if(a<s){const e=yA(l);e.id=`run:${Math.random().toString(36).slice(2,9)}`,be(l)||(e.text=l.text.slice(a-t,s-t)),o.push(e)}i=e}return o}function $V(t,e,a){const n=_V(t,0,e),r=_V(t,e,Qe(t)),o=JV(t,e);return jV(t,[...n,...a.map(t=>({...t,styles:fA(t.styles??o)})),...r],o)}function tR(t){const e=[],a=new Map,n=[];let r=0;for(const o of t){const t=Je(o);e.push({id:o.id,base:r,length:t.length}),a.has(o.id)||a.set(o.id,r),n.push(t),r+=t.length+1}return{text:n.join("\n"),spans:e,baseById:a}}function eR(t,e,a){return t<e?e:t>a?a:t}function aR(t,e,a){const n=tR(e);let r=!1;for(const f of t.order){const e=t.items[f];if(e&&(e.start&&n.baseById.has(e.start.paragraphId)||e.end&&n.baseById.has(e.end.paragraphId))){r=!0;break}}if(!r)return t;const o=tR(a);if(n.text===o.text)return t;const i=n.text.length,l=o.text.length,s=Math.min(i,l),d=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(t.length-1-n)===e.charCodeAt(e.length-1-n);)n+=1;return n}(n.text,o.text,s),c=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(n)===e.charCodeAt(n);)n+=1;return n}(n.text,o.text,s-d),h=t=>{const e=n.baseById.get(t.paragraphId);if(void 0===e)return t;const a=e+eR(t.offset,0,i-e),r=eR(function(t,e,a,n,r){return t<=n?t:t>=e-r?t+(a-e):n}(a,i,l,c,d),0,l),s=function(t,e){for(const n of e)if(t<=n.base+n.length)return{paragraphId:n.id,offset:Math.max(0,t-n.base)};const a=e[e.length-1];return{paragraphId:a.id,offset:a.length}}(r,o.spans);return s.paragraphId===t.paragraphId&&s.offset===t.offset?t:{...t,paragraphId:s.paragraphId,offset:s.offset}};let p=!1;const u={...t.items};for(const f of t.order){const e=t.items[f];if(!e)continue;let a=e;if(e.start&&n.baseById.has(e.start.paragraphId)){const t=h(e.start);t!==e.start&&(a={...a,start:t})}if(e.end&&n.baseById.has(e.end.paragraphId)){const t=h(e.end);t!==e.end&&(a={...a,end:t})}a!==e&&(u[f]=a,p=!0)}return p?{...t,items:u}:t}function nR(t,e){if(!function(t){for(const e of t)if("table"===e.type)return!0;return!1}(t))return e;let a=0;const n=t=>{let r=!1;const o=t.map(t=>{if("paragraph"===t.type){const n=e[a++]??t;return n!==t&&(r=!0),n}let o=!1;const i=t.rows.map(t=>{let e=!1;const a=t.cells.map(t=>{const a=n(t.blocks);return a===t.blocks?t:(e=!0,{...t,blocks:a})});return e?(o=!0,{...t,cells:a}):t});return o?(r=!0,{...t,rows:i}):t});return r?o:t};return n(t)}function rR(t,e,a){const n=La(t);if("footnote"===n){const n=t.activeFootnoteId,r=t.document.footnotes;if(!n||!r||!r.items[n])return{...t,selection:a};const o=r.items[n],i=nR(o.blocks,e);return{...t,document:{...t.document,footnotes:{...r,items:{...r.items,[n]:{...o,blocks:i}}}},selection:a}}const r=ha(t.document),o=Math.max(0,Math.min(Ea(t),r.length-1)),i=r[o];if(!i)return{...t,selection:a};const l=function(t,e,a){return"header"===a?{...t,header:nR(t.header??[],e)}:"footer"===a?{...t,footer:nR(t.footer??[],e)}:{...t,blocks:nR(t.blocks,e)}}(i,e,n),s=[...r];s[o]=l;const d=t.document.bookmarks,c=d&&d.order.length>0?aR(d,Na(t),e):d;return{...t,document:{...t.document,sections:s,...c!==d?{bookmarks:c}:{}},selection:a}}function oR(t,e,a){let n=!1;const r=t.map(t=>{if("paragraph"===t.type)return t;let r=!1;const o=t.rows.map(t=>{let n=!1;const o=t.cells.map(t=>{if(!t.blocks.some(t=>e.has(t.id)))return t;const r=a(t);return r!==t&&(n=!0),r});return n?(r=!0,{...t,cells:o}):t});return r?(n=!0,{...t,rows:o}):t});return n?r:t}function iR(t){return Ua(t)}function lR(t){const e=Na(t),a=Fa(t,t.selection.focus),n=Ba(e,a.paragraphId),r=e[n];return{paragraph:r,index:n,offset:$e(r,a)}}function sR(t){const e=Da(t);if(e.isCollapsed)return t;const a=Na(t);if(t.trackChangesEnabled){const n=`rev:${Math.random().toString(36).slice(2,9)}`,r="User",o=Date.now();return rR(t,a.map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return MA(t);return dR(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:Qe(t),t=>{var e;return"insert"===(null==(e=t.revision)?void 0:e.type)?{...t,text:""}:{...t,revision:{id:n,type:"delete",author:r,date:o}}})}),iR(e.start))}const n=a[e.startIndex],r=a[e.endIndex],o=$e(n,e.start),i=$e(r,e.end),l=jV(n,[..._V(n,0,o),..._V(r,i,Qe(r))]);return rR(t,[...wA(a.slice(0,e.startIndex)),l,...wA(a.slice(e.endIndex+1))],iR(_e(l,o)))}function dR(t,e,a,n){return jV(t,[..._V(t,0,e),..._V(t,e,a).map(n),..._V(t,a,Qe(t))])}function cR(t,e){const a=t[e.startIndex],n=t[e.endIndex];return{anchor:_e(a,e.startParagraphOffset),focus:_e(n,e.endParagraphOffset)}}function hR(t,e){const a=Da(t);return a.isCollapsed?t:{document:t.document,selection:iR("start"===e?a.start:a.end)}}function pR(t){return t.map(yA)}function uR(t){return t.reduce((t,e)=>t+e.text.length,0)}function fR(t,e,a){if(0===a.length)return t;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return t;const o=n[r],i=$e(o,e),l=pR(a[0].runs);if(1===a.length){const e=$V(o,i,l),a=n.map((t,a)=>a===r?e:t),s=uR(l);return rR(t,a,{anchor:_e(e,i),focus:_e(e,i+s)})}const s=_V(o,0,i),d=_V(o,i,Qe(o)),c=a[a.length-1],h=a.slice(1,-1),p=jV(MA(a[0].paragraphTemplate),[...s,...l],JV(o,i)),u=h.map(t=>jV(MA(t.paragraphTemplate),pR(t.runs))),f=jV(MA(c.paragraphTemplate),[...pR(c.runs),...d],JV(o,i));return rR(t,[...n.slice(0,r),p,...u,f,...n.slice(r+1)],{anchor:_e(p,uR(s)),focus:_e(f,uR(c.runs))})}function gR(t,e,a={}){if(Da(t).isCollapsed)return t;if(function(t,e){const a=Da(t);if(a.isCollapsed)return!1;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return!1;if(r<a.startIndex||r>a.endIndex)return!1;const o=$e(n[r],e);return!(r===a.startIndex&&o<a.startParagraphOffset||r===a.endIndex&&o>a.endParagraphOffset)}(t,e))return t;const n=function(t){const e=Da(t);if(e.isCollapsed)return[];const a=Na(t),n=[];for(let r=e.startIndex;r<=e.endIndex;r+=1){const t=a[r],o=_V(t,r===e.startIndex?e.startParagraphOffset:0,r===e.endIndex?e.endParagraphOffset:Qe(t));n.push({paragraphTemplate:MA(t),runs:o})}return n}(t);if(0===n.length)return t;if(a.copy)return fR(t,e,n);const r=function(t,e){const a=Da(t),n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return e;const o=$e(n[r],e);if(a.startIndex===a.endIndex)return r!==a.startIndex||o<=a.endParagraphOffset?e:_e(n[a.startIndex],o-(a.endParagraphOffset-a.startParagraphOffset));return e}(t,e);return fR(sR(t),r,n)}function mR(t,e,a){if(0===e.length)return t;const n=Ga(t.selection)?t:sR(t),{paragraph:r,index:o,offset:i}=lR(n),l=a?{...a}:JV(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e,styles:l,kind:"text"};n.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const d=$V(r,i,[s]);return rR(n,Na(n).map((t,e)=>e===o?d:t),iR(_e(d,i+e.length)))}function vR(t,e,a){if(0===e.length)return t;const n=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!n.includes("\n"))return mR(t,n,a);const r=Ga(t.selection)?t:sR(t),{paragraph:o,index:i,offset:l}=lR(r),s=n.split("\n"),d=JV(o,l),c=jV(o,[..._V(o,0,l),Ya(s[0],d)],d),h=_V(o,l,Qe(o)),p=s.slice(1,-1).map(t=>ZV([{text:t,styles:d}])),u=ZV([{text:s[s.length-1],styles:d},...h.map(t=>({text:t.text,styles:t.styles}))]),f=Na(r);return rR(r,[...f.slice(0,i),c,...p,u,...f.slice(i+1)],iR(_e(u,s[s.length-1].length)))}function bR(t){var e;if(!Ga(t.selection))return sR(t);const{paragraph:a,index:n,offset:r}=lR(t),o=Na(t);if(r>0){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<=e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=jV(a,[..._V(a,0,r-1),..._V(a,r,Qe(a))]);return rR(t,o.map((t,a)=>a===n?e:t),iR(_e(e,r-1)))}const c=l.text[d-1],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=jV(a,[..._V(a,0,r-1),h,..._V(a,r,Qe(a))]);return rR(t,o.map((t,e)=>e===n?p:t),iR(_e(p,r-1)))}}const i=jV(a,[..._V(a,0,r-1),..._V(a,r,Qe(a))],JV(a,r-1));return rR(t,o.map((t,e)=>e===n?i:t),iR(_e(i,r-1)))}if(0===n)return t;const i=o[n-1],l=jV(i,[...i.runs.map(yA),...a.runs.map(yA)]);return rR(t,[...o.slice(0,n-1),l,...o.slice(n+1)],iR(_e(l,Qe(i))))}function yR(t){var e;if(!Ga(t.selection))return sR(t);const{paragraph:a,index:n,offset:r}=lR(t),o=Na(t);if(r<Qe(a)){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=jV(a,[..._V(a,0,r),..._V(a,r+1,Qe(a))]);return rR(t,o.map((t,a)=>a===n?e:t),iR(_e(e,r)))}const c=l.text[d],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=jV(a,[..._V(a,0,r),h,..._V(a,r+1,Qe(a))]);return rR(t,o.map((t,e)=>e===n?p:t),iR(_e(p,r)))}}const i=jV(a,[..._V(a,0,r),..._V(a,r+1,Qe(a))],JV(a,r));return rR(t,o.map((t,e)=>e===n?i:t),iR(_e(i,r)))}if(n>=o.length-1)return t;const i=o[n+1],l=jV(a,[...a.runs.map(yA),...i.runs.map(yA)]);return rR(t,[...o.slice(0,n),l,...o.slice(n+2)],iR(_e(l,r)))}function MR(t,e){const a=Da(t);if(a.isCollapsed)return t;const n=Na(t),r=n.slice(a.startIndex,a.endIndex+1).flatMap((t,e)=>{const n=a.startIndex+e;return _V(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:Qe(t))}).filter(t=>t.text.length>0);if(0===r.length)return t;const o=!r.every(t=>{var a;return Boolean(null==(a=t.styles)?void 0:a[e])}),i=n.map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;return dR(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:Qe(t),t=>({...t,styles:mA(t.styles,e,o)}))});return rR(t,i,cR(i,a))}function xR(t,e,a){const n=Da(t);if(n.isCollapsed)return t;const r=Na(t).map((t,r)=>{if(r<n.startIndex||r>n.endIndex)return t;return dR(t,r===n.startIndex?n.startParagraphOffset:0,r===n.endIndex?n.endParagraphOffset:Qe(t),t=>({...t,styles:vA(t.styles,e,a)}))});return rR(t,r,cR(r,n))}function wR(t){return new RegExp("\\p{L}","u").test(t)}function SR(t,e){switch(e){case"lower":return t.toLowerCase();case"upper":return t.toUpperCase();case"capitalize":return function(t){let e="",a=!1;for(const n of t){const t=wR(n);e+=t&&!a?n.toUpperCase():n,a=t}return e}(t);case"toggle":return function(t){let e="";for(const a of t){const t=a.toUpperCase(),n=a.toLowerCase();e+=a===n&&a!==t?t:a===t&&a!==n?n:a}return e}(t);default:return function(t){let e="",a=!0;for(const n of t.toLowerCase())a&&wR(n)?(e+=n.toUpperCase(),a=!1):(e+=n,"."!==n&&"!"!==n&&"?"!==n||(a=!0));return e}(t)}}function AR(t,e){return function(t,e){const a=Da(t);if(a.isCollapsed)return t;const n=Na(t).map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;const r=n===a.startIndex?a.startParagraphOffset:0,o=n===a.endIndex?a.endParagraphOffset:Qe(t),i=_V(t,r,o).map(t=>t.text).join(""),l=e(i);let s=0;return dR(t,r,o,t=>{const e=t.text.length,a=l.slice(s,s+e);return s+=e,{...t,text:a}})});return rR(t,n,cR(n,a))}(t,t=>SR(t,e))}function CR(t,e,a){var n;let r;const o=t=>{const a=t.findIndex(t=>t.id===e);return a>=0?(r=t[a],[...t.slice(0,a),...t.slice(a+1)]):t},i={...t.document};if(i.sections&&i.sections.length>0&&(i.sections=i.sections.map(t=>({...t,blocks:o(t.blocks),header:t.header?o(t.header):void 0,footer:t.footer?o(t.footer):void 0}))),!r)return t;const l=a.paragraphId;if("table"===r.type){if(pa(r).some(t=>t.id===l))return t}const s=t=>{const e=t.findIndex(t=>t.id===l||"table"===t.type&&pa(t).some(t=>t.id===l));if(e<0)return{nextBlocks:t,found:!1};return{nextBlocks:[...t.slice(0,e),r,...t.slice(e)],found:!0}},d=Ea(t),c=La(t),h={...null==(n=i.sections)?void 0:n[d]};let p=!1;if("header"===c){const t=s(h.header??[]);h.header=t.nextBlocks,p=t.found}else if("footer"===c){const t=s(h.footer??[]);h.footer=t.nextBlocks,p=t.found}else{const t=s(h.blocks);h.blocks=t.nextBlocks,p=t.found}return p||(h.blocks=[...h.blocks,r]),i.sections=[...i.sections??[]],i.sections[d]=h,{...t,document:i}}function IR(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})(),s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}function TR(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})();l.style={...a.style??{},pageBreakBefore:!0};const s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}function kR(t,e,a){const n=Da(t),r=Na(t),o=n.startIndex,i=n.endIndex,l=r.map((t,n)=>n<o||n>i?MA(t):{...MA(t),style:bA(t.style,e,a)});return rR(t,l,cR(l,n))}function VR(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function RR(t,e,a){const n={...t??{}};return null===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function ER(t,e){const a=ha(t.document).map(t=>({...t,blocks:e(t.blocks),header:t.header?e(t.header):void 0,footer:t.footer?e(t.footer):void 0}));return{...t,document:{...t.document,sections:a}}}function LR(t,e){return t.map(t=>"table"===t.type?e(t):t)}function zR(t,e){return t.map(t=>"paragraph"===t.type?t:{...e(t),rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:zR(t.blocks,e)}))}))})}function NR(t){const e=Ea(t),a=xa(t.document,t.selection.focus.paragraphId,e);return a?{activeSectionIndex:e,loc:a}:null}function OR(t,e){const a=NR(t);if(!a)return t;const{activeSectionIndex:n,loc:r}=a,o=La(t),i=(t,a)=>t.map((t,n)=>"table"===t.type&&n===r.blockIndex&&a===r.zone?e(t):t),l=ha(t.document).map((t,e)=>e!==n?t:{...t,blocks:"main"===o?i(t.blocks,"main"):t.blocks,header:"header"===o&&t.header?i(t.header,"header"):t.header,footer:"footer"===o&&t.footer?i(t.footer,"footer"):t.footer});return{...t,document:{...t.document,sections:l}}}function qR(t){const e=new Set,a=Ea(t),n=xa(t.document,t.selection.anchor.paragraphId,a),r=xa(t.document,t.selection.focus.paragraphId,a);if(!n||!r||n.blockIndex!==r.blockIndex||n.zone!==r.zone)return e;const o=function(t,e,a){const n=ha(t)[e];if(n)return"header"===a?n.header:"footer"===a?n.footer:n.blocks}(t.document,a,n.zone),i=null==o?void 0:o[n.blockIndex];if(!i||"table"!==i.type)return e;const l=Io(i),s=l.find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),d=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex);if(!s||!d)return e;const c=Math.min(s.visualRowIndex,d.visualRowIndex),h=Math.max(s.visualRowIndex+s.rowSpan-1,d.visualRowIndex+d.rowSpan-1),p=Math.min(s.visualColumnIndex,d.visualColumnIndex),u=Math.max(s.visualColumnIndex+s.colSpan-1,d.visualColumnIndex+d.colSpan-1),f=l.filter(t=>t.visualRowIndex<=h&&t.visualRowIndex+t.rowSpan-1>=c&&t.visualColumnIndex<=u&&t.visualColumnIndex+t.colSpan-1>=p);for(const g of f)for(const t of g.cell.blocks)e.add(t.id);return e}function PR(t,e,a){const n=qR(t);if(0===n.size)for(const i of function(t){const e=new Set,a=Da(t),n=Na(t);for(let r=a.startIndex;r<=a.endIndex;r+=1)e.add(n[r].id);return e}(t))n.add(i);const r=n=>{let r=n.style;return t.trackChangesEnabled&&"revision"!==e&&"propertyRevision"!==e&&!(null==r?void 0:r.propertyRevision)&&(r={...r??{},propertyRevision:{...VR(),type:"property",previous:{...r??{}}}}),{...n,style:RR(r,e,a)}},o=ha(t.document).map(t=>({...t,blocks:oR(t.blocks,n,r),header:t.header?oR(t.header,n,r):void 0,footer:t.footer?oR(t.footer,n,r):void 0}));return{...t,document:{...t.document,sections:o}}}function WR(t,e){let a=PR(t,"borderTop",e);return a=PR(a,"borderRight",e),a=PR(a,"borderBottom",e),a=PR(a,"borderLeft",e),a}function BR(t,e,a){const n=function(t){const e=Da(t),a=Na(t),n=new Set;for(let r=e.startIndex;r<=e.endIndex;r+=1)n.add(a[r].id);return n}(t),r=o=>o.map(o=>{if("paragraph"===o.type)return o;const i=pa(o).some(t=>n.has(t.id)),l=o.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:r(t.blocks)}))})),s={...o,rows:l};return i?(n=>{let r=n.style;return t.trackChangesEnabled&&"revision"!==e&&!(null==r?void 0:r.revision)&&(r={...r??{},revision:{...VR(),type:"property",previous:{...r??{}}}}),{...n,style:RR(r,e,a)}})(s):s});return ER(t,r)}function FR(t,e,a,n){const r=r=>{if(r.id!==e)return r;let o=r.style;return t.trackChangesEnabled&&"revision"!==a&&!(null==o?void 0:o.revision)&&(o={...o??{},revision:{...VR(),type:"property",previous:{...o??{}}}}),{...r,style:RR(o,a,n)}};return ER(t,t=>zR(t,r))}function HR(t,e,a){const n=NR(t);if(!n)return t;return OR(t,r=>{const o=r.rows.map((r,o)=>o===n.loc.rowIndex?(()=>{let n=r.style;return t.trackChangesEnabled&&"revision"!==e&&"propertyRevision"!==e&&!(null==n?void 0:n.propertyRevision)&&(n={...n??{},propertyRevision:{...VR(),type:"property",previous:{...n??{}}}}),{...r,style:RR(n,e,a)}})():r);return{...r,rows:o}})}function UR(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e||e.includes("%"))return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t*Re:null}if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function GR(t,e,a,n,r){const o=o=>{var i;if(o.id!==e)return o;const l=Io(o),s=Math.max(1,...l.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),d=Array(s);let c=!1,h=!0;for(let t=0;t<s;t+=1){const e=UR(a[t]);if(null!==e){d[t]=Math.max(1,e),c=!0;continue}const n=null==(i=o.gridCols)?void 0:i[t];if(!("number"==typeof n&&Number.isFinite(n)&&n>0)){h=!1;break}d[t]=n}const p=o.rows.map((e,n)=>{const r=e.cells.map((e,r)=>{var o,i;const s=l.find(t=>t.rowIndex===n&&t.cellIndex===r);if(!s)return e;const d=s.visualColumnIndex+s.colSpan-1,c=a[d];if(void 0!==c&&1===s.colSpan){const a=t.trackChangesEnabled&&!(null==(o=e.style)?void 0:o.propertyRevision)?{...VR(),type:"property",previous:{...e.style??{}}}:null==(i=e.style)?void 0:i.propertyRevision;return{...e,style:{...e.style??{},width:c,...a?{propertyRevision:a}:{}}}}return e});return{...e,cells:r}}),u={...o.style??{}};return!t.trackChangesEnabled||u.revision||void 0===n&&void 0===r||(u.revision={...VR(),type:"property",previous:{...o.style??{}}}),void 0!==n&&(u.width=n),void 0!==r&&(u.indentLeft="number"==typeof r?r:Number(r)),{...o,rows:p,gridCols:c&&h?d:o.gridCols,gridRevision:t.trackChangesEnabled&&c&&h&&!o.gridRevision?{...VR(),type:"grid",previous:[...o.gridCols??[]]}:o.gridRevision,style:Object.keys(u).length>0?u:void 0}};return ER(t,t=>LR(t,o))}const DR={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 jR(t){const e=Ea(t),a=xa(t.document,t.selection.focus.paragraphId,e);if(!a)return null;const n=function(t,e){const a=ha(t.document)[Ea(t)];return a?"header"===e?a.header??[]:"footer"===e?a.footer??[]:a.blocks:[]}(t,a.zone)[a.blockIndex];if(!n||"table"!==n.type)return null;const r=Io(n).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex);return{table:n,tableId:n.id,rowIndex:a.rowIndex,cellIndex:a.cellIndex,visualColumnIndex:(null==r?void 0:r.visualColumnIndex)??a.cellIndex}}function ZR(t){if("number"==typeof t&&Number.isFinite(t))return{value:String(t),unit:"points"};if("string"==typeof t){const e=t.trim();if(e.endsWith("%"))return{value:e.slice(0,-1),unit:"percent"};const a=e.match(/^([0-9.]+)(pt)?$/i);if(null==a?void 0:a[1])return{value:a[1],unit:"points"}}return{value:"",unit:"points"}}function KR(t){return!!t&&"none"!==t.type&&t.width>0}function XR(t,e="table"){var a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v,b,y,M,x,w,S,A,C,I,T,k,V,R,E,L,z;const N=ZR(null==(a=t.table.style)?void 0:a.width),O=t.table.rows[t.rowIndex],q=null==O?void 0:O.cells[t.cellIndex],P=ZR(null==(n=null==O?void 0:O.style)?void 0:n.height),W=ZR(null==(r=null==q?void 0:q.style)?void 0:r.width),B=ZR(null==(o=t.table.gridCols)?void 0:o[t.visualColumnIndex]),F=(null==q?void 0:q.style)??{},H=[F.borderTop,F.borderRight,F.borderBottom,F.borderLeft,F.borderStart,F.borderEnd,F.borderTopLeftToBottomRight,F.borderTopRightToBottomLeft].filter(KR)[0],U=function(t){var e;const a=null==(e=t.style)?void 0:e.floating;return a&&0!==Object.keys(a).length?Object.entries(a).map(([t,e])=>`${t}=${e}`).join(", "):""}(t.table);return{...DR,activeTab:e,tableWidth:N.value,tableWidthUnit:N.unit,tableAlign:(null==(i=t.table.style)?void 0:i.align)??"",tableIndentLeft:ZR(null==(l=t.table.style)?void 0:l.indentLeft).value,tableWrapping:U?"around":"none",floatingSummary:U,floatingHorizontalAnchor:(null==(d=null==(s=t.table.style)?void 0:s.floating)?void 0:d.horizontalAnchor)??"margin",floatingVerticalAnchor:(null==(h=null==(c=t.table.style)?void 0:c.floating)?void 0:h.verticalAnchor)??"text",floatingX:null!=(null==(u=null==(p=t.table.style)?void 0:p.floating)?void 0:u.x)?String(t.table.style.floating.x):"0",floatingY:null!=(null==(g=null==(f=t.table.style)?void 0:f.floating)?void 0:g.y)?String(t.table.style.floating.y):"0",floatingXAlign:(null==(v=null==(m=t.table.style)?void 0:m.floating)?void 0:v.xAlign)??"",floatingYAlign:(null==(y=null==(b=t.table.style)?void 0:b.floating)?void 0:y.yAlign)??"",floatingDistanceTop:String((null==(x=null==(M=t.table.style)?void 0:M.floating)?void 0:x.distanceTop)??0),floatingDistanceRight:String((null==(S=null==(w=t.table.style)?void 0:w.floating)?void 0:S.distanceRight)??0),floatingDistanceBottom:String((null==(C=null==(A=t.table.style)?void 0:A.floating)?void 0:C.distanceBottom)??0),floatingDistanceLeft:String((null==(T=null==(I=t.table.style)?void 0:I.floating)?void 0:T.distanceLeft)??0),floatingOverlap:(null==(k=t.table.style)?void 0:k.tblOverlap)??"overlap",rowHeight:P.value,rowHeightRule:(null==(V=null==O?void 0:O.style)?void 0:V.heightRule)??"",repeatHeader:Boolean(null==O?void 0:O.isHeader),allowBreakAcrossPages:!0!==(null==(R=null==O?void 0:O.style)?void 0:R.cantSplit),hiddenRow:!0===(null==(E=null==O?void 0:O.style)?void 0:E.hidden),columnWidth:B.value,cellWidth:W.value,cellVerticalAlign:F.verticalAlign??"",cellTextDirection:F.textDirection??"",cellNoWrap:!0===F.noWrap,cellFitText:!0===F.fitText,cellHideMark:!0===F.hideMark,marginTop:null!=F.paddingTop?String(F.paddingTop):"",marginRight:null!=F.paddingRight?String(F.paddingRight):"",marginBottom:null!=F.paddingBottom?String(F.paddingBottom):"",marginLeft:null!=F.paddingLeft?String(F.paddingLeft):"",borderStyle:(null==H?void 0:H.type)??"none",borderWidth:H?String(H.width):"",borderColor:(null==H?void 0:H.color)??"",borderTop:KR(F.borderTop),borderRight:KR(F.borderRight),borderBottom:KR(F.borderBottom),borderLeft:KR(F.borderLeft),borderStart:KR(F.borderStart),borderEnd:KR(F.borderEnd),borderTopLeftToBottomRight:KR(F.borderTopLeftToBottomRight),borderTopRightToBottomLeft:KR(F.borderTopRightToBottomLeft),shading:F.shading??"",altTitle:(null==(L=t.table.style)?void 0:L.altTitle)??"",altDescription:(null==(z=t.table.style)?void 0:z.altDescription)??""}}function YR(t,e,a){return PR(t,e,a)}function JR(t,e){const a=jR(t);if(!a)return t;let n=t;return n=FR(n,a.tableId,"width",e.tableWidth),n=FR(n,a.tableId,"align",e.tableAlign),n=FR(n,a.tableId,"indentLeft",e.tableIndentLeft),n=FR(n,a.tableId,"floating",e.tableFloating),n=FR(n,a.tableId,"tblOverlap",e.tableOverlap),n=FR(n,a.tableId,"altTitle",e.altTitle),n=FR(n,a.tableId,"altDescription",e.altDescription),n=function(t,e){const a=NR(t);return a?OR(t,n=>({...n,rows:n.rows.map((n,r)=>{if(r!==a.loc.rowIndex)return n;let o=n.style;t.trackChangesEnabled&&!(null==o?void 0:o.propertyRevision)&&(o={...o??{},propertyRevision:{...VR(),type:"property",previous:{...o??{},isHeader:n.isHeader}}});const i=null===e?void 0:e;return{...n,isHeader:i,style:RR(o,"isHeader",i??null)}})})):t}(n,e.repeatHeader),n=HR(n,"height",e.rowHeight),n=HR(n,"heightRule",e.rowHeightRule),n=HR(n,"cantSplit",e.cantSplit),n=HR(n,"hidden",e.hiddenRow),null!==e.columnWidth&&(n=GR(n,a.tableId,{[a.visualColumnIndex]:e.columnWidth})),n=YR(n,"width",e.cellWidth),n=YR(n,"verticalAlign",e.cellVerticalAlign),n=YR(n,"textDirection",e.cellTextDirection),n=YR(n,"noWrap",e.cellNoWrap),n=YR(n,"fitText",e.cellFitText),n=YR(n,"hideMark",e.cellHideMark),n=YR(n,"paddingTop",e.margins.top),n=YR(n,"paddingRight",e.margins.right),n=YR(n,"paddingBottom",e.margins.bottom),n=YR(n,"paddingLeft",e.margins.left),n=YR(n,"borderTop",e.borders.top),n=YR(n,"borderRight",e.borders.right),n=YR(n,"borderBottom",e.borders.bottom),n=YR(n,"borderLeft",e.borders.left),n=YR(n,"borderStart",e.borders.start),n=YR(n,"borderEnd",e.borders.end),n=YR(n,"borderTopLeftToBottomRight",e.borders.topLeftToBottomRight),n=YR(n,"borderTopRightToBottomLeft",e.borders.topRightToBottomLeft),n=YR(n,"shading",e.shading),n}function QR(t){const e=()=>{return e=t.state(),Boolean(jR(e));var e};return{isInsideTable:e,openTablePropertiesDialog:(e="table")=>{const a=function(t,e="table"){const a=jR(t);return a?XR(a,e):null}(t.state(),e);a&&(t.setContextMenu({isOpen:!1,x:0,y:0}),t.setTablePropertiesDialog({isOpen:!0,initial:a}))},applyTablePropertiesDialogValues:a=>{t.isReadOnly()||e()&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>JR(t,a),{mergeKey:CV}),t.focusInput())}}}function _R(t){if(!t)return"";const e=[];t.fontFamily&&e.push(`font-family:${t.fontFamily}`),void 0!==t.fontSize&&null!==t.fontSize&&e.push(`font-size:${t.fontSize}px`),t.color&&e.push(`color:${t.color}`),t.highlight?e.push(`background-color:${t.highlight}`):t.shading&&e.push(`background-color:${t.shading}`),t.superscript?(e.push("vertical-align:super"),e.push("font-size:0.75em")):t.subscript&&(e.push("vertical-align:sub"),e.push("font-size:0.75em")),t.bold&&e.push("font-weight:700"),t.italic&&e.push("font-style:italic"),t.hidden&&e.push("display:none"),t.allCaps&&e.push("text-transform:uppercase"),t.smallCaps&&e.push("font-variant:small-caps"),void 0!==t.characterScale&&null!==t.characterScale&&e.push(`font-stretch:${t.characterScale}%`),void 0!==t.characterSpacing&&null!==t.characterSpacing&&e.push(`letter-spacing:${t.characterSpacing}pt`),$R(t.language)&&e.push("hyphens:auto"),void 0!==t.baselineShift&&null!==t.baselineShift&&e.push(`vertical-align:${t.baselineShift}pt`);const a=function(t){switch(t){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 null}}(t.ligatures);a&&e.push(`font-variant-ligatures:${a}`);const n=function(t,e){const a=[];"proportional"===t&&a.push("proportional-nums");"tabular"===t&&a.push("tabular-nums");"lining"===e&&a.push("lining-nums");"oldStyle"===e&&a.push("oldstyle-nums");return a.join(" ")||null}(t.numberSpacing,t.numberForm);n&&e.push(`font-variant-numeric:${n}`);const r=function(t,e){const a=[];"number"==typeof t&&t>=1&&t<=20&&a.push(`"ss${String(t).padStart(2,"0")}" 1`);e&&a.push('"calt" 1');return a.join(", ")||null}(t.stylisticSet,t.contextualAlternates);if(r&&e.push(`font-feature-settings:${r}`),t.textFill)if("solid"===t.textFill.type)e.push(`color:${t.textFill.color}`);else if("gradient"===t.textFill.type&&t.textFill.stops.length>=2){const a=((90-(t.textFill.angle??0))%360+360)%360,n=t.textFill.stops.map(t=>`${t.color} ${Math.round(100*t.position)}%`).join(",");e.push(`background:linear-gradient(${a}deg,${n})`),e.push("-webkit-background-clip:text"),e.push("background-clip:text"),e.push("color:transparent")}if(t.textOutline){const a=t.textOutline.widthPt*Ve,n=t.textOutline.color??"#000000";e.push(`-webkit-text-stroke:${a.toFixed(2)}px ${n}`)}if(t.textShadow){const a=t.textShadow.dirDeg*Math.PI/180,n=t=>(t*Ve).toFixed(2),r=(Math.cos(a)*t.textShadow.distPt*Ve).toFixed(2),o=(Math.sin(a)*t.textShadow.distPt*Ve).toFixed(2),i=n(t.textShadow.blurPt),l=t.textShadow.alpha??1,s=parseInt(t.textShadow.color.slice(1,3),16),d=parseInt(t.textShadow.color.slice(3,5),16),c=parseInt(t.textShadow.color.slice(5,7),16);e.push(`text-shadow:${r}px ${o}px ${i}px rgba(${s},${d},${c},${l})`)}else if(t.glow){const a=(t.glow.radiusPt*Ve).toFixed(2),n=t.glow.alpha??.7,r=parseInt(t.glow.color.slice(1,3),16),o=parseInt(t.glow.color.slice(3,5),16),i=parseInt(t.glow.color.slice(5,7),16);e.push(`text-shadow:0 0 ${a}px rgba(${r},${o},${i},${n})`)}const o=[];if((t.underline||t.link)&&o.push("underline"),t.strike&&o.push("line-through"),t.doubleStrike&&o.push("line-through"),o.length>0&&(e.push(`text-decoration:${o.join(" ")}`),t.underline||t.link)){const a=function(t){switch(t){case"double":case"wavyDouble":return"double";case"dotted":case"dottedHeavy":return"dotted";case"dash":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dashDotHeavy":case"dotDotDash":case"dashDotDotHeavy":return"dashed";case"wave":case"wavyHeavy":return"wavy";default:return null}}(t.underlineStyle);a&&e.push(`text-decoration-style:${a}`),t.underlineColor&&e.push(`text-decoration-color:${t.underlineColor}`)}return e.join(";")}function $R(t){return(null==t?void 0:t.value)??(null==t?void 0:t.bidi)??(null==t?void 0:t.eastAsia)??null}function tE(t){if(!t)return"";const e=[];if(t.align&&e.push(`text-align:${t.align}`),void 0!==t.lineHeight&&null!==t.lineHeight){const a="exact"===t.lineRule||"atLeast"===t.lineRule;e.push(`line-height:${t.lineHeight}${a?"px":""}`)}return void 0!==t.spacingBefore&&null!==t.spacingBefore&&e.push(`padding-top:${t.spacingBefore}px`),void 0!==t.spacingAfter&&null!==t.spacingAfter&&e.push(`padding-bottom:${t.spacingAfter}px`),void 0!==t.indentLeft&&null!==t.indentLeft&&e.push(`padding-left:${t.indentLeft}px`),void 0!==t.indentRight&&null!==t.indentRight&&e.push(`padding-right:${t.indentRight}px`),void 0!==t.indentFirstLine&&null!==t.indentFirstLine&&e.push(`text-indent:${t.indentFirstLine}px`),e.join(";")}function eE(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function aE(t,e){if("image"===t.kind)return function(t,e){var a;if("image"!==t.kind)return"";const n=da(e,t.image.src),r=void 0!==t.image.alt?` alt="${eE(t.image.alt)}"`:"",o=`<img src="${eE(n)}" width="${Math.max(1,Math.round(t.image.width))}" height="${Math.max(1,Math.round(t.image.height))}"${r}>`;return(null==(a=t.styles)?void 0:a.link)?`<a href="${eE(t.styles.link)}">${o}</a>`:o}(t,e);let a=eE(t.text).replace(/\n/g,"<br>");const n=t.styles??void 0;(null==n?void 0:n.strike)&&(a=`<s>${a}</s>`),(null==n?void 0:n.underline)&&(a=`<u>${a}</u>`),(null==n?void 0:n.italic)&&(a=`<em>${a}</em>`),(null==n?void 0:n.bold)&&(a=`<strong>${a}</strong>`),(null==n?void 0:n.superscript)?a=`<sup>${a}</sup>`:(null==n?void 0:n.subscript)&&(a=`<sub>${a}</sub>`);const r=_R(n),o=function(t){if(!t)return"";const e=[],a=$R(t);return a&&e.push(`lang="${eE(a)}"`),t.value&&e.push(`data-oasis-lang-value="${eE(t.value)}"`),t.eastAsia&&e.push(`data-oasis-lang-east-asia="${eE(t.eastAsia)}"`),t.bidi&&e.push(`data-oasis-lang-bidi="${eE(t.bidi)}"`),e.length>0?` ${e.join(" ")}`:""}(null==n?void 0:n.language);if(r.length>0||o.length>0){a=`<span${r.length>0?` style="${r}"`:""}${o}>${a}</span>`}return(null==n?void 0:n.link)&&(a=`<a href="${eE(n.link)}">${a}</a>`),a}function nE(t,e){return t.map(t=>aE(t,e)).join("")||"<br>"}function rE(t){var e;const a=Da(t);if(a.isCollapsed)return"";const n=Na(t),r=[];let o=null;const i=()=>{o&&(r.push("bullet"===o?"</ul>":"</ol>"),o=null)};for(let l=a.startIndex;l<=a.endIndex;l+=1){const s=n[l];if(!s)continue;const d=_V(s,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(s)),c=tE(s.style),h=c.length>0?` style="${c}"`:"",p=nE(d,t.document);if(null==(e=s.list)?void 0:e.kind){const t="bullet"===s.list.kind?"ul":"ol";o!==s.list.kind&&(i(),r.push(`<${t}>`),o=s.list.kind),r.push(`<li${h}>${p}</li>`);continue}i(),r.push(`<p${h}>${p}</p>`)}return i(),r.join("")}function oE(t,e){if(0===e.length)return t;const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i=Na(a),l=_V(n,0,o),s=_V(n,o,Qe(n)),d=e.map(t=>{const e=Qa(t.runs.map(t=>({text:t.text,styles:fA(t.styles),image:t.image?{...t.image}:void 0})));return e.style=t.style?{...t.style}:void 0,e.list=t.list?{...t.list}:void 0,e});let c,h=iR(_e(n,o));if(1===d.length){const t=d[0],e=t.runs.reduce((t,e)=>t+e.text.length,0),a=jV(n,[...l,...t.runs.map(yA),...s],JV(n,o));a.style=n.style?{...n.style}:t.style?{...t.style}:void 0,a.list=n.list?{...n.list}:t.list?{...t.list}:void 0,c=[...wA(i.slice(0,r)),a,...wA(i.slice(r+1))],h=iR(_e(a,l.reduce((t,e)=>t+e.text.length,0)+e))}else{const t=d[0],e=d[d.length-1],a=e.runs.reduce((t,e)=>t+e.text.length,0),p=jV(n,[...l,...t.runs.map(yA)],JV(n,o));p.style=n.style?{...n.style}:t.style?{...t.style}:void 0,p.list=n.list?{...n.list}:t.list?{...t.list}:void 0;const u=d.slice(1,-1).map(MA),f=jV(e,[...e.runs.map(yA),...s],void 0);f.list=e.list?{...e.list}:void 0,c=[...wA(i.slice(0,r)),p,...u,f,...wA(i.slice(r+1))],h=iR(_e(f,a))}return rR(a,c,h)}function iE(t,e){return{document:t.document,selection:e}}function lE(t,e){if(!Ga(t.selection))return hR(t,e<0?"start":"end");const{index:a,offset:n}=lR(t),r=Na(t),o=a+e;if(o<0||o>=r.length)return t;const i=r[o];return iE(t,iR(_e(i,Math.min(n,Qe(i)))))}function sE(t,e){const a=Fa(t,t.selection.focus),n=Na(t),r=Ba(n,a.paragraphId),o=n[r],i=$e(o,a),l=Qe(o);if(e<0&&i>0)return iE(t,{anchor:t.selection.anchor,focus:_e(o,i-1)});if(e>0&&i<l)return iE(t,{anchor:t.selection.anchor,focus:_e(o,i+1)});if(e<0&&r>0){const e=n[r-1];return iE(t,{anchor:t.selection.anchor,focus:_e(e,Qe(e))})}if(e>0&&r<n.length-1){const e=n[r+1];return iE(t,{anchor:t.selection.anchor,focus:_e(e,0)})}return t}function dE(t,e){const a=Fa(t,t.selection.focus),n=Na(t),r=Ba(n,a.paragraphId),o=$e(n[r],a),i=r+e;if(i<0||i>=n.length)return t;const l=n[i];return iE(t,{anchor:t.selection.anchor,focus:_e(l,Math.min(o,Qe(l)))})}function cE(t){const e=Da(t);if(e.isCollapsed)return"";const a=Na(t);if(e.startIndex===e.endIndex){return Je(a[e.startIndex]).slice(e.startParagraphOffset,e.endParagraphOffset)}const n=[],r=a[e.startIndex],o=a[e.endIndex];n.push(Je(r).slice(e.startParagraphOffset));for(let i=e.startIndex+1;i<e.endIndex;i+=1)n.push(Je(a[i]));return n.push(Je(o).slice(0,e.endParagraphOffset)),n.join("\n")}function hE(t,e){return{...t,selection:{anchor:Fa(t,e.anchor),focus:Fa(t,e.focus)}}}function pE(t){if(!Ga(t.selection))return hR(t,"start");const{paragraph:e,index:a,offset:n}=lR(t),r=Na(t);if(n>0)return{document:t.document,selection:iR(_e(e,n-1))};if(0===a)return t;const o=r[a-1];return{document:t.document,selection:iR(_e(o,Qe(o)))}}function uE(t){if(!Ga(t.selection))return hR(t,"end");const{paragraph:e,index:a,offset:n}=lR(t),r=Na(t);if(n<Qe(e))return{document:t.document,selection:iR(_e(e,n+1))};if(a>=r.length-1)return t;const o=r[a+1];return{document:t.document,selection:iR(_e(o,0))}}function fE(t){if("undefined"==typeof document||0===t.trim().length)return[];const e=document.createElement("template");e.innerHTML=t;const a=[],n=Array.from(e.content.childNodes),r=(t,e,n)=>{const r=e.length>0?e:[Ya("")];a.push({runs:r.map(t=>{const e=ye(t);return{text:t.text,styles:fA(t.styles),image:e?{...e}:void 0}}),style:t?OM(t):void 0,list:n})},o=(t,e)=>{for(const a of Array.from(t.children))"LI"===a.tagName&&r(a,LM(a,void 0),{kind:e,level:0})};for(const i of n){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent??"";t.trim().length>0&&r(null,[Ya(t)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const t=i,e=NM(t.tagName);if(e){o(t,e);continue}if(zM(t.tagName)){r(t,LM(t,void 0),"LI"===t.tagName?{kind:"bullet",level:0}:void 0);continue}const a=LM(t,void 0);a.length>0&&r(null,a)}return a}function gE(t){const{state:e,tableOps:a,applyTableContextCommand:n}=t;return{isInsideTable:t.isInsideTable,canMerge:()=>a.canMergeSelectedTable(e()),canSplit:()=>a.canSplitSelectedTable(e()),canEditColumn:()=>a.canEditSelectedTableColumn(e()),canEditRow:()=>a.canEditSelectedTableRow(e()),openProperties:()=>t.openTablePropertiesDialog("table"),openBordersAndShading:()=>t.openTablePropertiesDialog("cell"),merge:()=>n(t=>a.mergeSelectedTable(t),EV),split:()=>n(t=>a.splitSelectedTable(t),LV),insertColumnBefore:()=>n(t=>a.insertSelectedTableColumn(t,-1),zV),insertColumnAfter:()=>n(t=>a.insertSelectedTableColumn(t,1),zV),deleteColumn:()=>n(t=>a.deleteSelectedTableColumn(t),NV),insertRowBefore:()=>n(t=>a.insertSelectedTableRow(t,-1),OV),insertRowAfter:()=>n(t=>a.insertSelectedTableRow(t,1),OV),deleteRow:()=>n(t=>a.deleteSelectedTableRow(t),qV)}}function mE(t){const{computeFontFamilyOptions:e,computeFontSizeOptions:a,loadLocalFontFamilyOptions:n}=hV({state:t.state,toolbarStyleState:t.toolbarStyleState}),r=function(t){return{openFontDialog:()=>{var e;t.loadLocalFontFamilyOptions(),t.setFontDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{fontFamily:e.fontFamily??"",fontSize:Qw(e.fontSize),color:e.color??"",colorMode:e.color?"custom":"automatic",highlight:e.highlight??"",shading:e.textShading??"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underlineStyle?e.underlineStyle:null,underlineColor:e.underlineColor??"",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden),characterScale:e.characterScale??"",characterSpacing:e.characterSpacing??"",baselineShift:e.baselineShift??"",kerningThreshold:e.kerningThreshold??"",ligatures:e.ligatures??"",numberSpacing:e.numberSpacing??"",numberForm:e.numberForm??"",stylisticSet:e.stylisticSet??"",contextualAlternates:Boolean(e.contextualAlternates)})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(e,a)=>{t.isReadOnly()||(Ga(t.selection())||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>{let n=t;e.fontFamily!==(a.fontFamily||null)&&(n=xR(n,"fontFamily",e.fontFamily)),e.fontSize!==(a.fontSize?Number(a.fontSize):null)&&(n=xR(n,"fontSize",_w(e.fontSize)));const r="automatic"===a.colorMode?null:a.color||null;e.color!==r&&(n=xR(n,"color",e.color)),(e.highlight??"")!==(a.highlight??"")&&(n=xR(n,"highlight",e.highlight)),(e.shading??"")!==(a.shading??"")&&(n=xR(n,"shading",e.shading)),e.bold!==Boolean(a.bold)&&(n=MR(n,"bold")),e.italic!==Boolean(a.italic)&&(n=MR(n,"italic"));const o=a.underline?a.underlineStyle??"single":null;(e.underlineStyle??null)!==(o??null)&&(n=xR(n,"underlineStyle",e.underlineStyle));const i=a.underline&&a.underlineColor||null;(e.underlineColor??null)!==(i??null)&&(n=xR(n,"underlineColor",e.underlineColor)),e.underline!==Boolean(a.underline)&&(n=MR(n,"underline")),e.strike!==Boolean(a.strike)&&(n=MR(n,"strike")),e.doubleStrike!==Boolean(a.doubleStrike)&&(n=MR(n,"doubleStrike")),e.superscript!==Boolean(a.superscript)&&(n=MR(n,"superscript")),e.subscript!==Boolean(a.subscript)&&(n=MR(n,"subscript")),e.superscript&&e.subscript&&(n=MR(n,"subscript")),e.strike&&e.doubleStrike&&(n=MR(n,"doubleStrike")),e.smallCaps!==Boolean(a.smallCaps)&&(n=MR(n,"smallCaps")),e.allCaps!==Boolean(a.allCaps)&&(n=MR(n,"allCaps")),e.hidden!==Boolean(a.hidden)&&(n=MR(n,"hidden"));const l=a.characterScale?Number(a.characterScale):null;(e.characterScale??null)!==(l??null)&&(n=xR(n,"characterScale",e.characterScale));const s=a.characterSpacing?Number(a.characterSpacing):null;(e.characterSpacing??null)!==(s??null)&&(n=xR(n,"characterSpacing",e.characterSpacing));const d=a.baselineShift?Number(a.baselineShift):null;(e.baselineShift??null)!==(d??null)&&(n=xR(n,"baselineShift",e.baselineShift));const c=a.kerningThreshold?Number(a.kerningThreshold):null;(e.kerningThreshold??null)!==(c??null)&&(n=xR(n,"kerningThreshold",e.kerningThreshold)),(e.ligatures??null)!==(a.ligatures||null)&&(n=xR(n,"ligatures",e.ligatures)),(e.numberSpacing??null)!==(a.numberSpacing||null)&&(n=xR(n,"numberSpacing",e.numberSpacing)),(e.numberForm??null)!==(a.numberForm||null)&&(n=xR(n,"numberForm",e.numberForm));const h=a.stylisticSet?Number(a.stylisticSet):null;return(e.stylisticSet??null)!==(h??null)&&(n=xR(n,"stylisticSet",e.stylisticSet)),e.contextualAlternates!==Boolean(a.contextualAlternates)&&(n=MR(n,"contextualAlternates")),n},{mergeKey:TV})),t.focusInput())}}}({toolbarStyleState:t.toolbarStyleState,selection:t.selection,isReadOnly:t.isReadOnly,loadLocalFontFamilyOptions:n,setFontDialog:t.setFontDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),o=r.openFontDialog,i=function(t){return{openParagraphDialog:()=>{var e;t.setParagraphDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",shading:e.shading??"",borderStyle:e.borderStyle??"",borderWidth:e.borderWidth??"",borderColor:e.borderColor??"",borderSideTop:e.borderSideTop??!1,borderSideRight:e.borderSideRight??!1,borderSideBottom:e.borderSideBottom??!1,borderSideLeft:e.borderSideLeft??!1})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(e,a)=>{if(t.isReadOnly())return;t.clearPreferredColumn(),t.resetTransactionGrouping();const n=t=>{if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null};t.applyTransactionalState(t=>{let r=t;e.align!==(a.align||null)&&(r=kR(r,"align",e.align)),e.indentLeft!==n(a.indentLeft)&&(r=kR(r,"indentLeft",e.indentLeft)),e.indentRight!==n(a.indentRight)&&(r=kR(r,"indentRight",e.indentRight)),e.indentFirstLine!==n(a.indentFirstLine)&&(r=kR(r,"indentFirstLine",e.indentFirstLine)),e.indentHanging!==n(a.indentHanging)&&(r=kR(r,"indentHanging",e.indentHanging)),e.spacingBefore!==n(a.spacingBefore)&&(r=kR(r,"spacingBefore",e.spacingBefore)),e.spacingAfter!==n(a.spacingAfter)&&(r=kR(r,"spacingAfter",e.spacingAfter)),e.lineHeight!==n(a.lineHeight)&&(r=kR(r,"lineHeight",e.lineHeight)),e.shading!==(a.shading||null)&&(r=kR(r,"shading",e.shading));const o="solid"===a.borderStyle||"dashed"===a.borderStyle||"dotted"===a.borderStyle?{type:a.borderStyle,width:Number(a.borderWidth)||0,color:a.borderColor||"#000000"}:null,i={borderTop:a.borderSideTop?o:null,borderRight:a.borderSideRight?o:null,borderBottom:a.borderSideBottom?o:null,borderLeft:a.borderSideLeft?o:null},l={borderTop:e.borders.top,borderRight:e.borders.right,borderBottom:e.borders.bottom,borderLeft:e.borders.left};for(const e of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(l[e])!==JSON.stringify(i[e])&&(r=kR(r,e,l[e]));return r},{mergeKey:IV}),t.focusInput()}}}({toolbarStyleState:t.toolbarStyleState,isReadOnly:t.isReadOnly,setParagraphDialog:t.setParagraphDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),l=i.openParagraphDialog,s=QR({state:t.state,isReadOnly:t.isReadOnly,setTablePropertiesDialog:t.setTablePropertiesDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),d=s.openTablePropertiesDialog,c=function(t){const e=t.t,a=async()=>{var e;const a=t.state(),n=cE(a);if(!n)return;const r=rE(a);try{"undefined"!=typeof ClipboardItem&&(null==(e=navigator.clipboard)?void 0:e.write)?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([r],{type:"text/html"})})]):await navigator.clipboard.writeText(n)}catch(o){t.logger.warn("contextMenu:copy:failed",{error:String(o)});try{await navigator.clipboard.writeText(n)}catch{}}},n=async()=>{t.isReadOnly()||cE(t.state())&&(await a(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),t.focusInput())},r=async()=>{var e,a;if(t.isReadOnly())return;let n="",r="";try{if(null==(e=navigator.clipboard)?void 0:e.read){const t=await navigator.clipboard.read();for(const e of t){if(e.types.includes("text/html")){const t=await e.getType("text/html");n=await t.text()}if(e.types.includes("text/plain")){const t=await e.getType("text/plain");r=await t.text()}}}else(null==(a=navigator.clipboard)?void 0:a.readText)&&(r=await navigator.clipboard.readText())}catch(i){t.logger.warn("contextMenu:paste:failed",{error:String(i)});try{r=await navigator.clipboard.readText()}catch{return}}const o=fE(n);if(o.length>0)return t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oE(t,o))),void t.focusInput();r&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>vR(t,r))),t.focusInput())};return{buildContextMenuItems:()=>{const o=!Ga(t.state().selection),i=t.isReadOnly(),l=[{id:"cut",label:e("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!o,testId:"editor-context-menu-cut",onSelect:()=>{n()}},{id:"copy",label:e("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!o,testId:"editor-context-menu-copy",onSelect:()=>{a()}},{id:"paste",label:e("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{r()}},{id:"sep1",type:"separator"},{id:"link",label:e("contextmenu.link"),icon:"link",disabled:i||!o,testId:"editor-context-menu-link",onSelect:t.promptForLink},{id:"font",label:e("contextmenu.font"),icon:"type",disabled:i||!o,testId:"editor-context-menu-font",onSelect:t.openFontDialog},{id:"paragraph",label:e("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:t.openParagraphDialog}],s=t.table;return(null==s?void 0:s.isInsideTable())&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:e("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:e("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:e("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:e("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:e("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:e("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:e("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:e("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:e("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:e("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},closeContextMenu:()=>{t.setContextMenu({isOpen:!1,x:0,y:0})},handleEditorContextMenu:e=>{e.preventDefault(),t.setContextMenu({isOpen:!0,x:e.clientX,y:e.clientY})},programmaticCopy:a,programmaticCut:n,programmaticPaste:r}}({state:t.state,isReadOnly:t.isReadOnly,t:t.t,logger:t.logger,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.applyTableAwareParagraphEdit,focusInput:t.focusInput,promptForLink:t.promptForLink,openFontDialog:o,openParagraphDialog:l,table:gE({state:t.state,tableOps:t.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()}})});return{computeFontFamilyOptions:e,computeFontSizeOptions:a,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:c.buildContextMenuItems,handleEditorContextMenu:c.handleEditorContextMenu,closeContextMenu:c.closeContextMenu}}function vE(t){const e=w(()=>{var e,a,n;const r=t.targetPos(),o=t.surfaceRef;if(!o)return null;const i=t.snapshotProvider.getCanvasLayoutSnapshot({surface:o,state:t.state,documentLayout:t.documentLayout(),zoomFactor:null==(e=t.zoomFactor)?void 0:e.call(t)});let l=0,s=0,d=28;if(i){const e=Na(t.state).find(t=>t.id===r.paragraphId),a=e?$e(e,r):0,n=function(t,e,a){const n=Pn(t,e.paragraphId);if(0===n.length)return null;const r=function(t,e){if(0===t.length)return null;for(const a of t)if(e>=a.startOffset&&e<=a.endOffset)return a;return t[t.length-1]??null}(n,a);if(!r)return null;const o=function(t,e){if(0===t.lines.length)return null;for(const a of t.lines)if(e>=a.startOffset&&e<=a.endOffset)return a;return t.lines[t.lines.length-1]??null}(r,a);if(!o||0===o.slots.length)return qn(r.left,r.top,1,Math.max(r.height,16));const i=o.slots.find(t=>t.offset===a)??o.slots.reduce((t,e)=>Math.abs(e.offset-a)<Math.abs(t.offset-a)?e:t,o.slots[0]);return qn(i.left,i.top,1,i.height||o.height)}(i,r,a);if(n)return{viewportLeft:n.left,viewportTop:n.top,height:Math.min(n.height||28,32)};const o=function(t,e,a="start"){const n=Pn(t,e);if(0===n.length)return null;const r="end"===a?n[n.length-1]:n[0];return qn(r.left,r.top,r.width,r.height)}(i,r.paragraphId,"end");if(o)return{viewportLeft:o.left,viewportTop:o.top,height:o.height||28}}const c=(null==(a=t.caretViewport)?void 0:a.call(t))??null;if(c)return l=c.left,s=c.top,d=Math.max(12,Math.min(36,c.height)),{viewportLeft:l,viewportTop:s,height:d};const h=(null==(n=t.pointerPos)?void 0:n.call(t))??null;return h?(l=h.x,s=h.y-12,d=24,{viewportLeft:l,viewportTop:s,height:d}):{viewportLeft:l,viewportTop:s,height:d}});return K(rt,{get when(){return e()},children:t=>K(Uu,{active:!0,fixed:!0,get left(){return t().viewportLeft},get top(){return t().viewportTop},get height(){return t().height}})})}var bE=gt("<div class=oasis-editor-table-resize-guide>"),yE=gt("<img class=oasis-editor-image-ghost>"),ME=gt("<div class=oasis-editor-table-ghost>");function xE(t){return[K(rt,{get when(){return t.tableResize.resizing()},children:t=>{return e=bE(),M(a=>{var n=!("column"!==t().type),r=!("row"!==t().type),o={..."column"===t().type?{left:`${t().currentPos}px`,top:`${t().guideBounds.top}px`,width:"0px",height:`${t().guideBounds.height}px`}:{left:`${t().guideBounds.left}px`,top:`${t().currentPos}px`,width:`${t().guideBounds.width}px`,height:"0px"}};return n!==a.e&&e.classList.toggle("oasis-editor-table-resize-guide-column",a.e=n),r!==a.t&&e.classList.toggle("oasis-editor-table-resize-guide-row",a.t=r),a.a=xt(e,o,a.a),a},{e:void 0,t:void 0,a:void 0}),e;var e}}),K(rt,{get when(){return pt(()=>!!t.imageOps.dragging())()&&t.imageOps.draggedImageInfo()},children:e=>{return a=yE(),M(n=>{var r=e().src,o=`${e().width}px`,i=`${e().height}px`,l=t.imageOps.mousePos().x-e().offsetX+"px",s=t.imageOps.mousePos().y-e().offsetY+"px";return r!==n.e&&vt(a,"src",n.e=r),o!==n.t&&wt(a,"width",n.t=o),i!==n.a&&wt(a,"height",n.a=i),l!==n.o&&wt(a,"left",n.o=l),s!==n.i&&wt(a,"top",n.i=s),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a;var a}}),K(rt,{get when(){return pt(()=>!!t.tableDrag.dragging())()&&t.tableDrag.draggedTableInfo()},children:e=>{return a=ME(),M(n=>{var r=`${e().width}px`,o=`${e().height}px`,i=t.tableDrag.mousePos().x-e().offsetX+"px",l=t.tableDrag.mousePos().y-e().offsetY+"px";return r!==n.e&&wt(a,"width",n.e=r),o!==n.t&&wt(a,"height",n.t=o),i!==n.a&&wt(a,"left",n.a=i),l!==n.o&&wt(a,"top",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a;var a}}),K(rt,{get when(){return pt(()=>!!t.tableDrag.dragging())()&&t.tableDrag.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e})}),K(rt,{get when(){return pt(()=>!!t.imageOps.dragging())()&&t.imageOps.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e})}),K(rt,{get when(){return pt(()=>!!t.textDrag.dragging())()&&t.textDrag.dropTargetPos()},children:e=>K(vE,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},get documentLayout(){return t.documentLayout},get snapshotProvider(){return t.snapshotProvider},get zoomFactor(){return t.zoomFactor},targetPos:e,get pointerPos(){return t.textDrag.pointerPos},get caretViewport(){return t.textDrag.caretViewport}})})]}function wE(t){return[K(Kx,{variant:"secondary",get onClick(){return t.onCancel},get"data-testid"(){return t.cancelTestId},get children(){return t.cancelLabel}}),K(Kx,{variant:"primary",get onClick(){return t.onConfirm},get"data-testid"(){return t.confirmTestId},get children(){return t.confirmLabel}})]}function SE(t){const e=Ft(),[a,n]=y(t.initialValue);let r;x(()=>{t.isOpen&&(n(t.initialValue),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return K(Fx,{get isOpen(){return t.isOpen},get title(){return t.title},get onClose(){return t.onClose},get footer(){return K(wE,{get onCancel(){return t.onClose},onConfirm:o,get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return t.confirmLabel},get cancelTestId(){var e;return null==(e=t.testIds)?void 0:e.cancel},get confirmTestId(){var e;return null==(e=t.testIds)?void 0:e.confirm}})},get children(){return K(hw,{ref(t){"function"==typeof r?r(t):r=t},get label(){return t.label},get value(){return a()},onChange:n,onKeyDown:t=>"Enter"===t.key&&o(),get placeholder(){return t.placeholder},get"data-testid"(){var e;return null==(e=t.testIds)?void 0:e.input}})}})}function AE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.link.title")},get label(){return e("dialog.link.label")},get placeholder(){return e("dialog.link.placeholder")},get initialValue(){return t.initialHref},get confirmLabel(){return e("generic.apply")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm},testIds:{input:"editor-link-dialog-input",cancel:"editor-link-dialog-cancel",confirm:"editor-link-dialog-apply"}})}function CE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageAlt.title")},get label(){return e("dialog.imageAlt.label")},get placeholder(){return e("dialog.imageAlt.placeholder")},get initialValue(){return t.initialAlt},get confirmLabel(){return e("generic.save")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm}})}function IE(t){const e=Ft();return K(SE,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageCaption.title")},get label(){return e("dialog.imageCaption.label")},get placeholder(){return e("dialog.imageCaption.placeholder")},get initialValue(){return t.initialCaption},get confirmLabel(){return e("generic.save")},get onClose(){return t.onClose},get onConfirm(){return t.onConfirm}})}const TE="#111827",kE=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],VE=[33,50,66,75,90,100,105,110,115,120,150,200];function RE(t){const e=Number(t.trim());return Number.isFinite(e)&&e>0?e:null}function EE(t){const e=Number(t.trim());return Number.isFinite(e)&&e>=0?e:null}function LE(t){return null==t||""===t?"":String(t)}function zE(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"expanded":"condensed":"normal"}function NE(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"raised":"lowered":"normal"}function OE(t){if(!t.trim())return null;const e=Number(t);return Number.isInteger(e)&&e>=1&&e<=20?e:null}function qE(t){switch(t){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 PE(t,e){const a=[];return"proportional"===t&&a.push("proportional-nums"),"tabular"===t&&a.push("tabular-nums"),"lining"===e&&a.push("lining-nums"),"oldStyle"===e&&a.push("oldstyle-nums"),a.join(" ")||void 0}function WE(t,e){const a=[],n=OE(t);return null!==n&&a.push(`"ss${String(n).padStart(2,"0")}" 1`),e&&a.push('"calt" 1'),a.join(", ")||void 0}function BE(t){return{familyFilter:"",fontFamily:t.fontFamily??"",fontSize:t.fontSize??"",colorMode:t.colorMode,color:t.color||TE,highlight:t.highlight||"",shading:t.shading||"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underline?t.underlineStyle??"single":"none",underlineColor:t.underlineColor||TE,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)}}function FE(t){return{characterScale:LE(t.characterScale),spacingMode:zE(t.characterSpacing),spacingAmount:t.characterSpacing?String(Math.abs(Number(t.characterSpacing))):"",positionMode:NE(t.baselineShift),positionAmount:t.baselineShift?String(Math.abs(Number(t.baselineShift))):"",kerningEnabled:""!==t.kerningThreshold,kerningThreshold:LE(t.kerningThreshold),ligatures:t.ligatures,numberSpacing:t.numberSpacing,numberForm:t.numberForm,stylisticSet:LE(t.stylisticSet),contextualAlternates:Boolean(t.contextualAlternates)}}function HE(t){const e=Ft(),[a,n]=y("font"),[r,o]=y(BE(t.initial)),[i,l]=y(FE(t.initial));x(()=>{t.isOpen&&(n("font"),o(BE(t.initial)),l(FE(t.initial)))});const s=w(()=>{return t=r().bold,e=r().italic,t&&e?"boldItalic":t?"bold":e?"italic":"regular";var t,e}),d=w(()=>{const e=r().familyFilter.trim().toLowerCase();return e?t.familyOptions.filter(t=>t.toLowerCase().includes(e)):t.familyOptions}),c=w(()=>{const e=new Set(kE);for(const n of t.sizeOptions)e.add(n);const a=Number(r().fontSize);return Number.isFinite(a)&&a>0&&e.add(a),Array.from(e).sort((t,e)=>t-e)}),h=w(()=>{const t=r().fontSize.trim();if(!t)return"";const a=Number(t);return Number.isFinite(a)&&a>0?"":e("dialog.font.sizeInvalid")}),p=w(()=>{const t=i();return t.characterScale.trim()&&null===RE(t.characterScale)?e("dialog.font.advancedScaleInvalid"):"normal"!==t.spacingMode&&null===EE(t.spacingAmount)||"normal"!==t.positionMode&&null===EE(t.positionAmount)?e("dialog.font.advancedAmountInvalid"):t.kerningThreshold.trim()&&null===EE(t.kerningThreshold)?e("dialog.font.advancedKerningInvalid"):t.stylisticSet.trim()&&null===OE(t.stylisticSet)?e("dialog.font.advancedStylisticSetInvalid"):""}),u=w(()=>function(t,e){const a=Number(t.fontSize),n=RE(e.characterScale)??100,r="normal"===e.spacingMode?null:EE(e.spacingAmount),o="normal"===e.positionMode?null:EE(e.positionAmount),i=null===r?void 0:"condensed"===e.spacingMode?`-${r}pt`:`${r}pt`,l=null===o?void 0:"lowered"===e.positionMode?`-${o}pt`:`${o}pt`,s=[];return t.underline&&"none"!==t.underlineStyle&&s.push("underline"),t.strike&&s.push("line-through"),t.doubleStrike&&s.push("line-through"),{"font-family":t.fontFamily||"inherit","font-size":Number.isFinite(a)&&a>0?`${a}pt`:void 0,"font-weight":t.bold?700:400,"font-style":t.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===t.colorMode?"inherit":t.color,"background-color":t.highlight||t.shading||void 0,"vertical-align":l??(t.superscript?"super":t.subscript?"sub":"baseline"),"font-stretch":`${n}%`,"letter-spacing":i,"font-variant-ligatures":qE(e.ligatures),"font-variant-numeric":PE(e.numberSpacing,e.numberForm),"font-feature-settings":WE(e.stylisticSet,e.contextualAlternates)}}(r(),i()));return{activeTab:a,setActiveTab:t=>n(t),fontTabValues:r,setFontTabValues:o,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(t,e)=>{o(a=>({...a,[t]:e}))},updateAdvancedTab:(t,e)=>{l(a=>({...a,[t]:e}))},selectedFontStyle:s,visibleFamilyOptions:d,effectiveSizeOptions:c,customSizeError:h,advancedValidationError:p,previewStyle:u,applyFontStylePreset:t=>{o(e=>({...e,bold:"bold"===t||"boldItalic"===t,italic:"italic"===t||"boldItalic"===t}))},handleApply:()=>{if(p())return;const e=function(t,e){const a=Number(t.fontSize),n=Number.isFinite(a)&&a>0,r="none"===t.underlineStyle?null:t.underlineStyle,o=null!==r,i=e.characterScale.trim()?RE(e.characterScale):null,l="normal"===e.spacingMode?null:EE(e.spacingAmount),s="normal"===e.positionMode?null:EE(e.positionAmount),d=e.kerningEnabled&&e.kerningThreshold.trim()?EE(e.kerningThreshold):null,c=OE(e.stylisticSet);return{fontFamily:t.fontFamily.trim()?t.fontFamily.trim():null,fontSize:n?a:null,colorMode:t.colorMode,color:"automatic"===t.colorMode?null:t.color||null,highlight:t.highlight||null,shading:t.shading||null,bold:t.bold,italic:t.italic,underline:o,underlineStyle:r,underlineColor:o&&t.underlineColor||null,strike:t.strike,doubleStrike:t.doubleStrike,superscript:t.superscript,subscript:t.subscript,smallCaps:t.smallCaps,allCaps:t.allCaps,hidden:t.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===e.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===e.positionMode?-s:s,kerningThreshold:d,ligatures:e.ligatures||null,numberSpacing:e.numberSpacing||null,numberForm:e.numberForm||null,stylisticSet:c,contextualAlternates:e.contextualAlternates}}(r(),i());t.onApply(e,t.initial),t.onClose()}}}var UE=gt("<div>");function GE(t){const e=Ft();return Ct(a=UE(),()=>e("dialog.font.previewText")),M(e=>{var n=t.class??"oasis-editor-dialog-preview",r=t.testId,o=t.style;return n!==e.e&&bt(a,e.e=n),r!==e.t&&vt(a,"data-testid",e.t=r),e.a=xt(a,o,e.a),e},{e:void 0,t:void 0,a:void 0}),a;var a}var DE=gt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function jE(t){const e=Ft(),{ctrl:a}=t;return Ct(n=DE(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:12,get children(){return K(hw,{get label(){return e("dialog.font.familyFilter")},get value(){return a.fontTabValues().familyFilter},onChange:t=>a.updateFontTab("familyFilter",t),"data-testid":"editor-font-dialog-family-filter"})}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.family")},get value(){return a.fontTabValues().fontFamily},onChange:t=>a.updateFontTab("fontFamily",t),"data-testid":"editor-font-dialog-family",get options(){return[{value:"",label:"—"},...a.visibleFamilyOptions().map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{class:"oasis-editor-font-dialog-size-group",get label(){return e("dialog.font.size")},get value(){return a.fontTabValues().fontSize},onChange:t=>a.updateFontTab("fontSize",t),"data-testid":"editor-font-dialog-size",get options(){return[{value:"",label:"—"},...a.effectiveSizeOptions().map(t=>({value:String(t),label:String(t)}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return[K(hw,{class:"oasis-editor-font-dialog-custom-size-group",get label(){return e("dialog.font.customSize")},get value(){return a.fontTabValues().fontSize},onChange:t=>a.updateFontTab("fontSize",t),"data-testid":"editor-font-dialog-custom-size"}),K(Xx,{class:"oasis-editor-dialog-help-text",get children(){return a.customSizeError()}})]}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{class:"oasis-editor-font-dialog-style-list-group",get label(){return e("dialog.font.styleList")},get value(){return a.selectedFontStyle()},onChange:t=>a.applyFontStylePreset(t),"data-testid":"editor-font-dialog-style-list",get options(){return[{value:"regular",label:e("dialog.font.styleRegular")},{value:"italic",label:e("dialog.font.styleItalic")},{value:"bold",label:e("dialog.font.styleBold")},{value:"boldItalic",label:e("dialog.font.styleBoldItalic")}]}})}})]}}),null),Ct(n,K(nw,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{class:"oasis-editor-font-dialog-color-mode-group",get label(){return e("dialog.font.color")},get value(){return a.fontTabValues().colorMode},onChange:t=>a.updateFontTab("colorMode",t),"data-testid":"editor-font-dialog-color-mode",get options(){return[{value:"automatic",label:e("toolbar.colorAutomatic")},{value:"custom",label:e("dialog.font.customColor")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(fw,{get label(){return e("dialog.font.color")},get value(){return a.fontTabValues().color},get disabled(){return"automatic"===a.fontTabValues().colorMode},onChange:t=>a.setFontTabValues(e=>({...e,color:t,colorMode:"custom"})),"data-testid":"editor-font-dialog-color"})}}),K(nw,{size:{xs:12,md:2},get children(){return K(fw,{get label(){return e("dialog.font.highlight")},get value(){return a.fontTabValues().highlight||"#fef08a"},onChange:t=>a.updateFontTab("highlight",t),"data-testid":"editor-font-dialog-highlight"})}}),K(nw,{size:{xs:12,md:2},get children(){return K(fw,{get label(){return e("dialog.font.shading")},get value(){return a.fontTabValues().shading||"#fef3c7"},onChange:t=>a.updateFontTab("shading",t),"data-testid":"editor-font-dialog-shading"})}})]}}),null),Ct(n,K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.underlineStyle")},get value(){return a.fontTabValues().underlineStyle},onChange:t=>a.setFontTabValues(e=>({...e,underlineStyle:t,underline:"none"!==t})),"data-testid":"editor-font-dialog-underline-style",get options(){return[{value:"none",label:e("toolbar.underlineRemove")},...$w.map(t=>({value:t.value,label:e(t.labelKey)}))]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(fw,{get label(){return e("dialog.font.underlineColor")},get value(){return a.fontTabValues().underlineColor||TE},get disabled(){return"none"===a.fontTabValues().underlineStyle},onChange:t=>a.setFontTabValues(e=>({...e,underlineColor:t,underline:"none"!==e.underlineStyle})),"data-testid":"editor-font-dialog-underline-color"})}})]}}),null),Ct(n,K(iw,{class:"oasis-editor-dialog-input-group-grow",get label(){return e("dialog.font.style")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return K(at,{get each(){return[{testId:"editor-font-dialog-bold",label:e("dialog.font.bold"),labelStyle:{"font-weight":700},checked:()=>a.fontTabValues().bold,onChange:t=>a.updateFontTab("bold",t)},{testId:"editor-font-dialog-italic",label:e("dialog.font.italic"),labelStyle:{"font-style":"italic"},checked:()=>a.fontTabValues().italic,onChange:t=>a.updateFontTab("italic",t)},{testId:"editor-font-dialog-underline",label:e("dialog.font.underline"),labelStyle:{"text-decoration":"underline"},checked:()=>a.fontTabValues().underline,onChange:t=>a.setFontTabValues(e=>({...e,underline:t,underlineStyle:t?"none"===e.underlineStyle?"single":e.underlineStyle:"none"}))},{testId:"editor-font-dialog-strike",label:e("dialog.font.strike"),labelStyle:{"text-decoration":"line-through"},checked:()=>a.fontTabValues().strike,onChange:t=>a.setFontTabValues(e=>({...e,strike:t,doubleStrike:!t&&e.doubleStrike}))},{testId:"editor-font-dialog-double-strike",label:e("dialog.font.doubleStrike"),checked:()=>a.fontTabValues().doubleStrike,onChange:t=>a.setFontTabValues(e=>({...e,doubleStrike:t,strike:!t&&e.strike}))},{testId:"editor-font-dialog-superscript",label:e("toolbar.superscript"),checked:()=>a.fontTabValues().superscript,onChange:t=>a.setFontTabValues(e=>({...e,superscript:t,subscript:!t&&e.subscript}))},{testId:"editor-font-dialog-subscript",label:e("toolbar.subscript"),checked:()=>a.fontTabValues().subscript,onChange:t=>a.setFontTabValues(e=>({...e,subscript:t,superscript:!t&&e.superscript}))},{testId:"editor-font-dialog-small-caps",label:e("dialog.font.smallCaps"),checked:()=>a.fontTabValues().smallCaps,onChange:t=>a.updateFontTab("smallCaps",t)},{testId:"editor-font-dialog-all-caps",label:e("dialog.font.allCaps"),checked:()=>a.fontTabValues().allCaps,onChange:t=>a.updateFontTab("allCaps",t)},{testId:"editor-font-dialog-hidden",label:e("dialog.font.hidden"),checked:()=>a.fontTabValues().hidden,onChange:t=>a.updateFontTab("hidden",t)}]},children:t=>K(Bw,{get label(){return t.label},get labelStyle(){return t.labelStyle},get checked(){return t.checked()},get onChange(){return t.onChange},get"data-testid"(){return t.testId}})})}})}}),null),Ct(n,K(iw,{get label(){return e("dialog.font.preview")},get children(){return K(GE,{testId:"editor-font-dialog-preview",get style(){return a.previewStyle()}})}}),null),n;var n}var ZE=gt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function KE(t){const e=Ft(),{ctrl:a}=t;return Ct(n=ZE(),K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedCharacterSpacingGroup")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("dialog.font.advancedScale")},get value(){return a.advancedTabValues().characterScale||"100"},onChange:t=>a.updateAdvancedTab("characterScale",t),"data-testid":"editor-font-dialog-advanced-scale",get options(){return VE.map(t=>({value:String(t),label:`${t}%`}))}})}}),K(nw,{size:{xs:12,md:8},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.advancedSpacing")},get value(){return a.advancedTabValues().spacingMode},onChange:t=>a.updateAdvancedTab("spacingMode",t),"data-testid":"editor-font-dialog-advanced-spacing-mode",get options(){return[{value:"normal",label:e("dialog.font.advancedNormal")},{value:"expanded",label:e("dialog.font.advancedExpanded")},{value:"condensed",label:e("dialog.font.advancedCondensed")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-small-input",get label(){return e("dialog.font.advancedBy")},get value(){return a.advancedTabValues().spacingAmount},get disabled(){return"normal"===a.advancedTabValues().spacingMode},onChange:t=>a.updateAdvancedTab("spacingAmount",t),"data-testid":"editor-font-dialog-advanced-spacing-amount"})}})]}})}}),K(nw,{size:{xs:12,md:8},get children(){return K(Aw,{get label(){return e("dialog.font.advancedPosition")},get value(){return a.advancedTabValues().positionMode},onChange:t=>a.updateAdvancedTab("positionMode",t),"data-testid":"editor-font-dialog-advanced-position-mode",get options(){return[{value:"normal",label:e("dialog.font.advancedNormal")},{value:"raised",label:e("dialog.font.advancedRaised")},{value:"lowered",label:e("dialog.font.advancedLowered")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-small-input",get label(){return e("dialog.font.advancedBy")},get value(){return a.advancedTabValues().positionAmount},get disabled(){return"normal"===a.advancedTabValues().positionMode},onChange:t=>a.updateAdvancedTab("positionAmount",t),"data-testid":"editor-font-dialog-advanced-position-amount"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(bw,{class:"oasis-editor-font-dialog-kerning-toggle",get label(){return e("dialog.font.advancedKerning")},get checked(){return a.advancedTabValues().kerningEnabled},onChange:t=>a.setAdvancedTabValues(e=>({...e,kerningEnabled:t,kerningThreshold:t?e.kerningThreshold||"1":e.kerningThreshold})),"data-testid":"editor-font-dialog-advanced-kerning-enabled"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(hw,{class:"oasis-editor-font-dialog-kerning-input",get value(){return a.advancedTabValues().kerningThreshold},get disabled(){return!a.advancedTabValues().kerningEnabled},onChange:t=>a.updateAdvancedTab("kerningThreshold",t),"data-testid":"editor-font-dialog-advanced-kerning"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Xx,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return e("dialog.font.advancedKerningAbove")}})}})]}})}}),null),Ct(n,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedOpenTypeGroup")},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedLigatures")},get value(){return a.advancedTabValues().ligatures},onChange:t=>a.updateAdvancedTab("ligatures",t),"data-testid":"editor-font-dialog-advanced-ligatures",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"none",label:e("dialog.font.advancedLigaturesNone")},{value:"standard",label:e("dialog.font.advancedLigaturesStandard")},{value:"contextual",label:e("dialog.font.advancedLigaturesContextual")},{value:"historical",label:e("dialog.font.advancedLigaturesHistorical")},{value:"standardContextual",label:e("dialog.font.advancedLigaturesStandardContextual")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedNumberSpacing")},get value(){return a.advancedTabValues().numberSpacing},onChange:t=>a.updateAdvancedTab("numberSpacing",t),"data-testid":"editor-font-dialog-advanced-number-spacing",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"proportional",label:e("dialog.font.advancedNumberSpacingProportional")},{value:"tabular",label:e("dialog.font.advancedNumberSpacingTabular")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedNumberForm")},get value(){return a.advancedTabValues().numberForm},onChange:t=>a.updateAdvancedTab("numberForm",t),"data-testid":"editor-font-dialog-advanced-number-form",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},{value:"lining",label:e("dialog.font.advancedNumberFormLining")},{value:"oldStyle",label:e("dialog.font.advancedNumberFormOldStyle")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("dialog.font.advancedStylisticSet")},get value(){return a.advancedTabValues().stylisticSet},onChange:t=>a.updateAdvancedTab("stylisticSet",t),"data-testid":"editor-font-dialog-advanced-stylistic-set",get options(){return[{value:"",label:e("dialog.font.advancedDefault")},...Array.from({length:20},(t,e)=>e+1).map(t=>({value:String(t),label:String(t)}))]}})}})]}}),K(bw,{class:"oasis-editor-font-dialog-contextual-toggle",get label(){return e("dialog.font.advancedContextualAlternates")},get checked(){return a.advancedTabValues().contextualAlternates},onChange:t=>a.updateAdvancedTab("contextualAlternates",t),"data-testid":"editor-font-dialog-advanced-contextual-alternates"})]}}),null),Ct(n,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("dialog.font.advancedPreviewGroup")},get children(){return K(GE,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return a.previewStyle()}})}}),null),Ct(n,K(Xx,{as:"p",class:"oasis-editor-dialog-help-text","data-testid":"editor-font-dialog-advanced-placeholder",get children(){return a.advancedValidationError()||e("dialog.font.advancedPlaceholder")}}),null),n;var n}function XE(t){const e=Ft(),a=HE(t);return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("dialog.font.title")},get onClose(){return t.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return K(wE,{get onCancel(){return t.onClose},get onConfirm(){return a.handleApply},get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.ok")},cancelTestId:"editor-font-dialog-cancel",confirmTestId:"editor-font-dialog-apply"})},get children(){return K(jx,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return e("dialog.font.title")},get value(){return a.activeTab()},onChange:t=>a.setActiveTab(t),get items(){return[{id:"font",label:e("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:K(jE,{ctrl:a})},{id:"advanced",label:e("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:K(KE,{ctrl:a})}]}})}})}var YE=gt("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>");const JE="#000000";function QE(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function _E(t){const e=Ft(),[a,n]=y(""),[r,o]=y(null),[i,l]=y(null),[s,d]=y("none"),[c,h]=y(null),[p,u]=y(null),[f,g]=y(null),[m,v]=y(null),[b,S]=y(""),[A,C]=y("none"),[I,T]=y(null),[k,V]=y(""),[R,E]=y(!1),[L,z]=y(!1),[N,O]=y(!1),[q,P]=y(!1);x(()=>{if(t.isOpen){n(t.initial.align??""),o(QE(t.initial.indentLeft??"")),l(QE(t.initial.indentRight??"")),u(QE(t.initial.spacingBefore??"")),g(QE(t.initial.spacingAfter??"")),v(QE(t.initial.lineHeight??"")),S(t.initial.shading??"");const e=t.initial.borderStyle;C("solid"===e||"dashed"===e||"dotted"===e?e:"none"),T(QE(t.initial.borderWidth??"")),V(t.initial.borderColor??""),E(t.initial.borderSideTop??!1),z(t.initial.borderSideRight??!1),O(t.initial.borderSideBottom??!1),P(t.initial.borderSideLeft??!1);const a=QE(t.initial.indentFirstLine??""),r=QE(t.initial.indentHanging??"");null!==r&&r>0?(d("hanging"),h(r)):null!==a&&a>0?(d("firstLine"),h(a)):(d("none"),h(null))}});const W=w(()=>{const t=m(),e=r(),n=i(),o="firstLine"===s()?c():null,l="hanging"===s()?c():null,d=null!==o?o:null!==l?-l:null,h="none"!==A()?`${I()??.5}pt ${A()} ${k().trim()||JE}`:void 0;return{"text-align":a()||void 0,"line-height":null!==t&&t>0?String(t):void 0,"padding-left":null!==e?`${e+(l??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==d?`${d}pt`:void 0,"background-color":b().trim()||void 0,"border-top":h&&R()?h:void 0,"border-right":h&&L()?h:void 0,"border-bottom":h&&N()?h:void 0,"border-left":h&&q()?h:void 0}}),B=()=>{const t=A();if("none"===t)return{top:null,right:null,bottom:null,left:null};const e=I(),a={type:t,width:null!==e&&e>0?e:.5,color:k().trim()||JE};return{top:R()?a:null,right:L()?a:null,bottom:N()?a:null,left:q()?a:null}},F=()=>{const e=c();t.onApply({align:a()||null,indentLeft:r(),indentRight:i(),indentFirstLine:"firstLine"===s()?e:null,indentHanging:"hanging"===s()?e:null,spacingBefore:p(),spacingAfter:f(),lineHeight:m(),shading:b().trim()||null,borders:B()},t.initial),t.onClose()};return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("paragraph.title")},get onClose(){return t.onClose},get footer(){return K(wE,{get onCancel(){return t.onClose},onConfirm:F,get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.apply")},cancelTestId:"editor-paragraph-dialog-cancel",confirmTestId:"editor-paragraph-dialog-apply"})},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("paragraph.alignLabel")},get value(){return a()},onChange:n,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:e("paragraph.alignLeft")},{value:"center",label:e("paragraph.alignCenter")},{value:"right",label:e("paragraph.alignRight")},{value:"justify",label:e("paragraph.alignJustify")}]}})}})}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.indentLeftLabel")},step:"1",get value(){return r()??""},onChange:o,"data-testid":"editor-paragraph-dialog-indent-left"})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.indentRightLabel")},step:"1",get value(){return i()??""},onChange:l,"data-testid":"editor-paragraph-dialog-indent-right"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("paragraph.specialLabel")},get value(){return s()},onChange:t=>{const e=t;d(e),"none"===e&&h(null)},"data-testid":"editor-paragraph-dialog-special",get options(){return[{value:"none",label:e("paragraph.specialNone")},{value:"firstLine",label:e("paragraph.specialFirstLine")},{value:"hanging",label:e("paragraph.specialHanging")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Cw,{get label(){return e("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===s()},get value(){return c()??""},onChange:h,"data-testid":"editor-paragraph-dialog-special-by"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return p()??""},onChange:u,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return f()??""},onChange:g,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Cw,{get label(){return e("paragraph.lineSpacingLabel")},min:"0.5",step:"0.05",get value(){return m()??""},onChange:v,"data-testid":"editor-paragraph-dialog-line-height"})}})]}}),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("paragraph.borderStyleLabel")},get value(){return A()},onChange:t=>{const e=t;C(e),"none"===e?(E(!1),z(!1),O(!1),P(!1)):R()||L()||N()||q()||(E(!0),z(!0),O(!0),P(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:e("paragraph.borderNone")},{value:"solid",label:e("paragraph.borderSolid")},{value:"dashed",label:e("paragraph.borderDashed")},{value:"dotted",label:e("paragraph.borderDotted")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return K(Cw,{get label(){return e("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===A()},get value(){return I()??""},onChange:T,"data-testid":"editor-paragraph-dialog-border-width"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.borderColorLabel")},get disabled(){return"none"===A()},get value(){return k()||JE},onChange:V,"data-testid":"editor-paragraph-dialog-border-color"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.shadingLabel")},get value(){return b()||"#ffffff"},onChange:S,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),K(iw,{class:"oasis-editor-dialog-input-group-grow",get label(){return e("paragraph.borderSidesLabel")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("paragraph.borderSideTop")},get disabled(){return"none"===A()},get checked(){return R()},onChange:E,"data-testid":"editor-paragraph-dialog-border-side-top"}),K(bw,{get label(){return e("paragraph.borderSideRight")},get disabled(){return"none"===A()},get checked(){return L()},onChange:z,"data-testid":"editor-paragraph-dialog-border-side-right"}),K(bw,{get label(){return e("paragraph.borderSideBottom")},get disabled(){return"none"===A()},get checked(){return N()},onChange:O,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),K(bw,{get label(){return e("paragraph.borderSideLeft")},get disabled(){return"none"===A()},get checked(){return q()},onChange:P,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}}),K(iw,{get label(){return e("paragraph.preview")},get children(){var t=YE();return Ct(t,()=>e("paragraph.previewText")),M(e=>xt(t,W(),e)),t}})]}})}const $E="#000000";function tL(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function eL(t,e){const a=tL(t);return null===a?null:"percent"===e?`${a}%`:a}function aL(t,e,a){if("none"===t)return null;const n=tL(e);return{type:t,width:null!==n&&n>0?n:.5,color:a.trim()||$E}}function nL(t){const[e,a]=ue({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:""});x(()=>{var e;t.isOpen&&a(me({activeTab:(e=t.initial).activeTab??"table",tableWidth:e.tableWidth,tableWidthUnit:e.tableWidthUnit,tableAlign:e.tableAlign,tableIndentLeft:e.tableIndentLeft,tableWrapping:e.tableWrapping,floatingHorizontalAnchor:e.floatingHorizontalAnchor,floatingVerticalAnchor:e.floatingVerticalAnchor,floatingX:e.floatingX,floatingY:e.floatingY,floatingXAlign:e.floatingXAlign,floatingYAlign:e.floatingYAlign,floatingDistanceTop:e.floatingDistanceTop,floatingDistanceRight:e.floatingDistanceRight,floatingDistanceBottom:e.floatingDistanceBottom,floatingDistanceLeft:e.floatingDistanceLeft,floatingOverlap:e.floatingOverlap,rowHeight:e.rowHeight,rowHeightRule:e.rowHeightRule,repeatHeader:e.repeatHeader,allowBreakAcrossPages:e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:e.columnWidth,cellWidth:e.cellWidth,cellVerticalAlign:e.cellVerticalAlign,cellTextDirection:e.cellTextDirection,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,marginTop:e.marginTop,marginRight:e.marginRight,marginBottom:e.marginBottom,marginLeft:e.marginLeft,borderStyle:e.borderStyle,borderWidth:e.borderWidth,borderColor:e.borderColor,borderTop:e.borderTop,borderRight:e.borderRight,borderBottom:e.borderBottom,borderLeft:e.borderLeft,borderStart:e.borderStart,borderEnd:e.borderEnd,borderTlBr:e.borderTopLeftToBottomRight,borderTrBl:e.borderTopRightToBottomLeft,shading:e.shading,altTitle:e.altTitle,altDescription:e.altDescription}))});return{form:e,set:a,handleApply:()=>{t.onApply(function(t){const e=aL(t.borderStyle,t.borderWidth,t.borderColor);return{tableWidth:eL(t.tableWidth,t.tableWidthUnit),tableAlign:t.tableAlign||null,tableIndentLeft:eL(t.tableIndentLeft,"points"),tableFloating:"around"===t.tableWrapping?{horizontalAnchor:t.floatingHorizontalAnchor,verticalAnchor:t.floatingVerticalAnchor,...t.floatingXAlign?{xAlign:t.floatingXAlign}:{x:tL(t.floatingX)??0},...t.floatingYAlign?{yAlign:t.floatingYAlign}:{y:tL(t.floatingY)??0},distanceTop:tL(t.floatingDistanceTop)??0,distanceRight:tL(t.floatingDistanceRight)??0,distanceBottom:tL(t.floatingDistanceBottom)??0,distanceLeft:tL(t.floatingDistanceLeft)??0}:null,tableOverlap:"around"===t.tableWrapping?t.floatingOverlap:null,rowHeight:eL(t.rowHeight,"points"),rowHeightRule:t.rowHeightRule||null,repeatHeader:t.repeatHeader,cantSplit:!t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:eL(t.columnWidth,"points"),cellWidth:eL(t.cellWidth,"points"),cellVerticalAlign:t.cellVerticalAlign||null,cellTextDirection:t.cellTextDirection||null,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,margins:{top:tL(t.marginTop),right:tL(t.marginRight),bottom:tL(t.marginBottom),left:tL(t.marginLeft)},borders:{top:t.borderTop?e:null,right:t.borderRight?e:null,bottom:t.borderBottom?e:null,left:t.borderLeft?e:null,start:t.borderStart?e:null,end:t.borderEnd?e:null,topLeftToBottomRight:t.borderTlBr?e:null,topRightToBottomLeft:t.borderTrBl?e:null},shading:t.shading.trim()||null,altTitle:t.altTitle.trim()||null,altDescription:t.altDescription.trim()||null}}(e),t.initial),t.onClose()}}}function rL(t,e,a,n,r=!1,o=!1){return K(hw,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:t,min:o?void 0:"0",step:"1",get value(){return e()},disabled:r,onChange:a,"data-testid":n})}var oL=gt("<div class=oasis-editor-table-properties-panel>");function iL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=oL(),K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.sizeSection")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.preferredWidth"),()=>a().tableWidth,t=>n("tableWidth",t),"editor-table-properties-table-width")}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.measureIn")},get value(){return a().tableWidthUnit},onChange:t=>n("tableWidthUnit",t),"data-testid":"editor-table-properties-table-width-unit",get options(){return[{value:"points",label:e("table.points")},{value:"percent",label:e("table.percent")}]}})}})]}})}}),null),Ct(r,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.alignmentSection")},get children(){return[K(Lw,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return a().tableAlign},onChange:t=>n("tableAlign",t),get children(){return["left","center","right"].map(t=>K(Ew,{value:t,get label(){return e(`table.align${t[0].toUpperCase()}${t.slice(1)}`)},"data-testid":`editor-table-properties-align-${t}`}))}}),K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.indentFromLeft"),()=>a().tableIndentLeft,t=>n("tableIndentLeft",t),"editor-table-properties-indent-left")}})}})]}}),null),Ct(r,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.textWrappingSection")},get children(){return[K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.wrapNone")},get checked(){return"none"===a().tableWrapping},onChange:()=>n("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),K(bw,{get label(){return e("table.wrapAround")},get checked(){return"around"===a().tableWrapping},onChange:()=>n("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),K(rt,{get when(){return"around"===a().tableWrapping},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.horizontalAnchor")},get value(){return a().floatingHorizontalAnchor},onChange:t=>n("floatingHorizontalAnchor",t),"data-testid":"editor-table-properties-floating-h-anchor",get options(){return[{value:"margin",label:e("table.anchorMargin")},{value:"page",label:e("table.anchorPage")},{value:"text",label:e("table.anchorText")}]}})}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.verticalAnchor")},get value(){return a().floatingVerticalAnchor},onChange:t=>n("floatingVerticalAnchor",t),"data-testid":"editor-table-properties-floating-v-anchor",get options(){return[{value:"margin",label:e("table.anchorMargin")},{value:"page",label:e("table.anchorPage")},{value:"text",label:e("table.anchorText")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.positionX"),()=>a().floatingX,t=>n("floatingX",t),"editor-table-properties-floating-x",Boolean(a().floatingXAlign),!0)}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.positionY"),()=>a().floatingY,t=>n("floatingY",t),"editor-table-properties-floating-y",Boolean(a().floatingYAlign),!0)}}),K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("table.horizontalAlignment")},get value(){return a().floatingXAlign},onChange:t=>n("floatingXAlign",t),"data-testid":"editor-table-properties-floating-x-align",get options(){return[{value:"",label:e("table.explicitOffset")},...["left","center","right","inside","outside"].map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("table.verticalAlignment")},get value(){return a().floatingYAlign},onChange:t=>n("floatingYAlign",t),"data-testid":"editor-table-properties-floating-y-align",get options(){return[{value:"",label:e("table.explicitOffset")},...["top","center","bottom","inside","outside"].map(t=>({value:t,label:t}))]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceTop"),()=>a().floatingDistanceTop,t=>n("floatingDistanceTop",t),"editor-table-properties-floating-distance-top")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceRight"),()=>a().floatingDistanceRight,t=>n("floatingDistanceRight",t),"editor-table-properties-floating-distance-right")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceBottom"),()=>a().floatingDistanceBottom,t=>n("floatingDistanceBottom",t),"editor-table-properties-floating-distance-bottom")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("table.distanceLeft"),()=>a().floatingDistanceLeft,t=>n("floatingDistanceLeft",t),"editor-table-properties-floating-distance-left")}})]}}),K(bw,{get label(){return e("table.allowOverlap")},get checked(){return"overlap"===a().floatingOverlap},onChange:t=>n("floatingOverlap",t?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),r;var r}var lL=gt("<div class=oasis-editor-table-properties-panel>");function sL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=lL(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.rowHeight"),()=>a().rowHeight,t=>n("rowHeight",t),"editor-table-properties-row-height")}}),K(nw,{size:{xs:12,md:6},get children(){return K(Aw,{get label(){return e("table.rowHeightRule")},get value(){return a().rowHeightRule},onChange:t=>n("rowHeightRule",t),"data-testid":"editor-table-properties-row-height-rule",get options(){return[{value:"",label:e("table.rowAuto")},{value:"atLeast",label:e("table.rowAtLeast")},{value:"exact",label:e("table.rowExactly")}]}})}})]}}),null),Ct(r,K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.repeatHeader")},get checked(){return a().repeatHeader},onChange:t=>n("repeatHeader",t),"data-testid":"editor-table-properties-repeat-header"}),K(bw,{get label(){return e("table.allowBreakAcrossPages")},get checked(){return a().allowBreakAcrossPages},onChange:t=>n("allowBreakAcrossPages",t),"data-testid":"editor-table-properties-allow-break"}),K(bw,{get label(){return e("table.hiddenRow")},get checked(){return a().hiddenRow},onChange:t=>n("hiddenRow",t),"data-testid":"editor-table-properties-hidden-row"})]}}),null),r;var r}var dL=gt("<div class=oasis-editor-table-properties-panel>");function cL(t){const e=Ft(),a=t.ctrl.set;return Ct(n=dL(),K(nw,{container:!0,spacing:1.5,get children(){return K(nw,{size:{xs:12,md:6},get children(){return rL(e("table.columnWidth"),()=>t.ctrl.form.columnWidth,t=>a("columnWidth",t),"editor-table-properties-column-width")}})}})),n;var n}var hL=gt("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),pL=gt("<div class=oasis-editor-table-properties-panel>");function uL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set,r=w(()=>{const t=aL(a().borderStyle,a().borderWidth,a().borderColor),e=t?`${t.width}pt ${t.type} ${t.color}`:void 0;return{"background-color":a().shading.trim()||void 0,"border-top":e&&a().borderTop?e:"1px solid #dadce0","border-right":e&&a().borderRight?e:"1px solid #dadce0","border-bottom":e&&a().borderBottom?e:"1px solid #dadce0","border-left":e&&a().borderLeft?e:"1px solid #dadce0"}}),o=()=>"none"===a().borderStyle;return Ct(i=pL(),K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:4},get children(){return rL(e("table.cellWidth"),()=>a().cellWidth,t=>n("cellWidth",t),"editor-table-properties-cell-width")}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("table.verticalAlignment")},get value(){return a().cellVerticalAlign},onChange:t=>n("cellVerticalAlign",t),"data-testid":"editor-table-properties-cell-valign",get options(){return[{value:"",label:e("table.inherit")},{value:"top",label:e("table.valignTop")},{value:"middle",label:e("table.valignMiddle")},{value:"bottom",label:e("table.valignBottom")}]}})}}),K(nw,{size:{xs:12,md:4},get children(){return K(Aw,{get label(){return e("table.textDirection")},get value(){return a().cellTextDirection},onChange:t=>n("cellTextDirection",t),"data-testid":"editor-table-properties-cell-direction",get options(){return[{value:"",label:e("table.inherit")},{value:"lrTb",label:"lrTb"},{value:"tbRl",label:"tbRl"},{value:"btLr",label:"btLr"},{value:"lrTbV",label:"lrTbV"},{value:"tbRlV",label:"tbRlV"}]}})}})]}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.options")},get children(){return K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("table.noWrap")},get checked(){return a().cellNoWrap},onChange:t=>n("cellNoWrap",t),"data-testid":"editor-table-properties-cell-nowrap"}),K(bw,{get label(){return e("table.fitText")},get checked(){return a().cellFitText},onChange:t=>n("cellFitText",t),"data-testid":"editor-table-properties-cell-fit-text"}),K(bw,{get label(){return e("table.hideMark")},get checked(){return a().cellHideMark},onChange:t=>n("cellHideMark",t),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("table.cellMargins")},get children(){return K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideTop"),()=>a().marginTop,t=>n("marginTop",t),"editor-table-properties-margin-top")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideRight"),()=>a().marginRight,t=>n("marginRight",t),"editor-table-properties-margin-right")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideBottom"),()=>a().marginBottom,t=>n("marginBottom",t),"editor-table-properties-margin-bottom")}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderSideLeft"),()=>a().marginLeft,t=>n("marginLeft",t),"editor-table-properties-margin-left")}})]}})}}),null),Ct(i,K(Pw,{class:"oasis-editor-font-dialog-fieldset",get legend(){return e("paragraph.bordersSection")},get children(){return[K(nw,{container:!0,spacing:1.5,get children(){return[K(nw,{size:{xs:12,md:3},get children(){return K(Aw,{get label(){return e("paragraph.borderStyleLabel")},get value(){return a().borderStyle},onChange:t=>{const e=t;n("borderStyle",e),"none"===e?(n("borderTop",!1),n("borderRight",!1),n("borderBottom",!1),n("borderLeft",!1),n("borderStart",!1),n("borderEnd",!1),n("borderTlBr",!1),n("borderTrBl",!1)):a().borderTop||a().borderRight||a().borderBottom||a().borderLeft||(n("borderTop",!0),n("borderRight",!0),n("borderBottom",!0),n("borderLeft",!0))},"data-testid":"editor-table-properties-border-style",get options(){return[{value:"none",label:e("paragraph.borderNone")},{value:"solid",label:e("paragraph.borderSolid")},{value:"dashed",label:e("paragraph.borderDashed")},{value:"dotted",label:e("paragraph.borderDotted")}]}})}}),K(nw,{size:{xs:12,md:3},get children(){return rL(e("paragraph.borderWidthLabel"),()=>a().borderWidth,t=>n("borderWidth",t),"editor-table-properties-border-width",o())}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.borderColorLabel")},get value(){return a().borderColor||$E},get disabled(){return o()},onChange:t=>n("borderColor",t),"data-testid":"editor-table-properties-border-color"})}}),K(nw,{size:{xs:12,md:3},get children(){return K(fw,{get label(){return e("paragraph.shadingLabel")},get value(){return a().shading||"#ffffff"},onChange:t=>n("shading",t),"data-testid":"editor-table-properties-shading"})}})]}}),K(aw,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[K(bw,{get label(){return e("paragraph.borderSideTop")},get checked(){return a().borderTop},get disabled(){return o()},onChange:t=>n("borderTop",t),"data-testid":"editor-table-properties-border-top"}),K(bw,{get label(){return e("paragraph.borderSideRight")},get checked(){return a().borderRight},get disabled(){return o()},onChange:t=>n("borderRight",t),"data-testid":"editor-table-properties-border-right"}),K(bw,{get label(){return e("paragraph.borderSideBottom")},get checked(){return a().borderBottom},get disabled(){return o()},onChange:t=>n("borderBottom",t),"data-testid":"editor-table-properties-border-bottom"}),K(bw,{get label(){return e("paragraph.borderSideLeft")},get checked(){return a().borderLeft},get disabled(){return o()},onChange:t=>n("borderLeft",t),"data-testid":"editor-table-properties-border-left"}),K(bw,{get label(){return e("table.borderStart")},get checked(){return a().borderStart},get disabled(){return o()},onChange:t=>n("borderStart",t),"data-testid":"editor-table-properties-border-start"}),K(bw,{get label(){return e("table.borderEnd")},get checked(){return a().borderEnd},get disabled(){return o()},onChange:t=>n("borderEnd",t),"data-testid":"editor-table-properties-border-end"}),K(bw,{get label(){return e("table.borderTlBr")},get checked(){return a().borderTlBr},get disabled(){return o()},onChange:t=>n("borderTlBr",t),"data-testid":"editor-table-properties-border-tlbr"}),K(bw,{get label(){return e("table.borderTrBl")},get checked(){return a().borderTrBl},get disabled(){return o()},onChange:t=>n("borderTrBl",t),"data-testid":"editor-table-properties-border-trbl"})]}}),(t=hL(),M(e=>xt(t,r(),e)),t)];var t}}),null),i;var i}var fL=gt("<div class=oasis-editor-table-properties-panel>");function gL(t){const e=Ft(),a=()=>t.ctrl.form,n=t.ctrl.set;return Ct(r=fL(),K(hw,{get label(){return e("table.altTitle")},get value(){return a().altTitle},onChange:t=>n("altTitle",t),"data-testid":"editor-table-properties-alt-title"}),null),Ct(r,K(uw,{class:"oasis-editor-dialog-input-group",get label(){return e("table.altDescription")},controlClass:"oasis-editor-table-properties-textarea",get value(){return a().altDescription},onChange:t=>n("altDescription",t),"data-testid":"editor-table-properties-alt-description"}),null),r;var r}function mL(t){const e=Ft(),a=nL(t);return K(Fx,{get isOpen(){return t.isOpen},get title(){return e("table.propertiesTitle")},get onClose(){return t.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return K(wE,{get onCancel(){return t.onClose},get onConfirm(){return a.handleApply},get cancelLabel(){return e("generic.cancel")},get confirmLabel(){return e("generic.ok")},cancelTestId:"editor-table-properties-cancel",confirmTestId:"editor-table-properties-apply"})},get children(){return K(jx,{get value(){return a.form.activeTab},onChange:t=>a.set("activeTab",t),get ariaLabel(){return e("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:e("table.tabTable"),testId:"editor-table-properties-tab-table",panel:K(iL,{ctrl:a})},{id:"row",label:e("table.tabRow"),testId:"editor-table-properties-tab-row",panel:K(sL,{ctrl:a})},{id:"column",label:e("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:K(cL,{ctrl:a})},{id:"cell",label:e("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:K(uL,{ctrl:a})},{id:"altText",label:e("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:K(gL,{ctrl:a})}]}})}})}var vL=gt("<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 bL(t){const e=Ft(),{fr:a}=t,n=t=>{"Enter"===t.key?(t.preventDefault(),t.shiftKey?a.findPrevious():a.findNext()):"Escape"===t.key&&a.setIsOpen(!1)};return K(rt,{get when(){return a.isOpen()},get children(){var t=vL(),r=t.firstChild,o=r.nextSibling,i=o.firstChild,l=i.firstChild,s=i.nextSibling;return t.$$keydown=n,Ct(r,K(wn,{get children(){return e("find.title")}}),null),Ct(r,K(xn,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>a.setIsOpen(!1),get label(){return e("generic.close")}}),null),Ct(l,K(hw,{type:"text",get placeholder(){return e("find.placeholder")},get value(){return a.searchTerm()},onChange:t=>a.setSearchTerm(t),autofocus:!0,controlClass:"oasis-editor-fr-input"}),null),Ct(l,K(Xx,{class:"oasis-editor-fr-counter",get children(){return pt(()=>a.matches().length>0)()?`${a.currentIndex()+1} / ${a.matches().length}`:e("find.noMatches")}}),null),Ct(i,K(aw,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[K(xn,{get onClick(){return a.findPrevious},get disabled(){return 0===a.matches().length},icon:"chevron-up",get label(){return e("find.prevTooltip")}}),K(xn,{get onClick(){return a.findNext},get disabled(){return 0===a.matches().length},icon:"chevron-down",get label(){return e("find.nextTooltip")}})]}}),null),Ct(s,K(hw,{type:"text",get placeholder(){return e("replace.placeholder")},get value(){return a.replaceTerm()},onChange:t=>a.setReplaceTerm(t),controlClass:"oasis-editor-fr-input"}),null),Ct(s,K(aw,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[K(xn,{class:"oasis-editor-fr-btn-text",get onClick(){return a.replace},get disabled(){return 0===a.matches().length},get children(){return e("replace.one")}}),K(xn,{class:"oasis-editor-fr-btn-text",get onClick(){return a.replaceAll},get disabled(){return 0===a.matches().length},get children(){return e("replace.allBtn")}})]}}),null),Ct(o,K(aw,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[K(bw,{class:"oasis-editor-fr-checkbox",get label(){return e("find.matchCase")},get checked(){return a.findOptions().matchCase},onChange:t=>a.setFindOptions({...a.findOptions(),matchCase:t})}),K(bw,{class:"oasis-editor-fr-checkbox",get label(){return e("find.wholeWord")},get checked(){return a.findOptions().wholeWord},onChange:t=>a.setFindOptions({...a.findOptions(),wholeWord:t})})]}}),null),t}})}mt(["keydown"]);var yL=gt("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),ML=gt("<i>"),xL=gt("<span class=oasis-editor-context-menu-shortcut>"),wL=gt("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),SL=gt("<div class=oasis-editor-context-menu-separator>"),AL=gt("<i data-lucide=check style=visibility:hidden>");function CL(t){let e;const a=e=>{t.isOpen&&"Escape"===e.key&&(e.preventDefault(),t.onClose())},n=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},r=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},o=()=>{t.isOpen&&t.onClose()};return C(()=>{window.addEventListener("keydown",a,!0),window.addEventListener("mousedown",n,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o,!0)}),I(()=>{window.removeEventListener("keydown",a,!0),window.removeEventListener("mousedown",n,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o,!0)}),x(()=>{if(!t.isOpen||!e)return;const a=e.getBoundingClientRect(),n=Math.max(4,window.innerWidth-a.width-4),r=Math.max(4,window.innerHeight-a.height-4),o=Math.min(t.x,n),i=Math.min(t.y,r);e.style.left=`${o}px`,e.style.top=`${i}px`}),K(rt,{get when(){return t.isOpen},get children(){var a=yL();a.$$contextmenu=t=>t.preventDefault();return"function"==typeof e?At(e,a):e=a,Ct(a,K(at,{get each(){return t.items},children:e=>K(rt,{get when(){return"separator"!==e.type},get fallback(){return SL()},get children(){var a=wL(),n=a.firstChild;return a.$$click=()=>{var a;e.disabled||(null==(a=e.onSelect)||a.call(e),t.onClose())},Ct(a,K(rt,{get when(){return e.icon},get fallback(){return AL()},get children(){var t=ML();return M(()=>vt(t,"data-lucide",e.icon)),t}}),n),Ct(n,()=>e.label),Ct(a,K(rt,{get when(){return e.shortcut},get children(){var t=xL();return Ct(t,()=>e.shortcut),t}}),null),M(t=>{var n=e.disabled,r=e.testId;return n!==t.e&&(a.disabled=t.e=n),r!==t.t&&vt(a,"data-testid",t.t=r),t},{e:void 0,t:void 0}),a}})})),M(e=>{var n=`${t.x}px`,r=`${t.y}px`;return n!==e.e&&wt(a,"left",e.e=n),r!==e.t&&wt(a,"top",e.t=r),e},{e:void 0,t:void 0}),a}})}function IL(t){const{linkDialog:e,setLinkDialog:a,imageAltDialog:n,setImageAltDialog:r,imageCaptionDialog:o,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}=t.dialogs;return[K(AE,{get isOpen(){return e().isOpen},get initialHref(){return e().initialHref},onClose:()=>{a({...e(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyLinkCommand(e.trim()||null)}),K(CE,{get isOpen(){return n().isOpen},get initialAlt(){return n().initialAlt},onClose:()=>{r({...n(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageAltCommand(e.trim())}),K(IE,{get isOpen(){return o().isOpen},get initialCaption(){return o().initialCaption},onClose:()=>{i({...o(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageCaptionCommand(e.trim())}),K(bL,{get fr(){return t.findReplace}}),K(XE,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return t.fontFamilyOptions()},get sizeOptions(){return t.fontSizeOptions()},onClose:()=>{d({...s(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyFontDialogValues}}),K(_E,{get isOpen(){return c().isOpen},get initial(){return c().initial},onClose:()=>{h({...c(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyParagraphDialogValues}}),K(mL,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{u({...p(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyTablePropertiesDialogValues}}),K(CL,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return t.contextMenuItems()},get onClose(){return t.closeContextMenu}})]}mt(["contextmenu","click"]);var TL=gt("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function kL(t){return[K(rt,{get when(){return t.useComposedShell()},get children(){return(()=>{const e=t.shellComponent(),{runtime:a,chrome:n,view:r}=t;return K(e,{get state(){return a.state()},get toolbarHost(){return a.toolbarHost},get runtimeEditor(){return a.runtimeEditor},get persistenceStatus(){return a.persistenceStatus},get toolbarRegistry(){return a.toolbarRegistry},get menuRegistry(){return a.menuRegistry},get showChrome(){return n.showChrome()},get showTitleBar(){return n.showTitleBar()},get showMenubar(){return n.showMenubar()},get showToolbar(){return n.showToolbar()},get showOutline(){return n.showOutline()},get toolbarView(){return n.toolbarView()},get toolbarLayout(){return n.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 showFloatingTableToolbar(){return a.showFloatingTableToolbar},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}})})()}}),K(rt,{get when(){return!t.useComposedShell()},get children(){return K(kx,{get editor(){return t.runtime.runtimeEditor},get children(){var e=TL();return Ct(e.firstChild,K(ix,{get state(){return t.runtime.state},get layout(){return{...t.view.layout,documentLayout:t.view.documentLayout,measuredBlockHeights:t.view.measuredBlockHeights,measuredParagraphLayouts:t.view.measuredParagraphLayouts,readOnly:t.view.isReadOnly()}},get overlays(){return{...t.view.overlays,toolbarHost:t.runtime.toolbarHost,persistenceStatus:t.runtime.persistenceStatus,showFloatingTableToolbar:t.runtime.showFloatingTableToolbar}},get refs(){return t.view.refs},get surfaceHandlers(){return t.view.surfaceHandlers},get inputHandlers(){return t.view.inputHandlers},get fileHandlers(){return t.view.fileHandlers}})),e}})}})]}var VL=gt("<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 RL(t){const e=Ft(),a=()=>{Qs(),Hs(),t.onClose()},n=()=>{Us(!1),Hs(),t.onClose()};return K(rt,{get when(){return t.isOpen},get children(){var t=VL(),r=t.firstChild,o=r.firstChild,i=o.nextSibling,l=i.nextSibling,s=l.nextSibling;return Ct(r,K(Gt,{height:72,class:"oasis-editor-welcome-mark"}),o),Ct(o,()=>e("welcome.title")),Ct(i,()=>e("welcome.body")),Ct(l,()=>e("welcome.note")),Ct(s,K(Kx,{variant:"secondary",onClick:n,"data-testid":"editor-welcome-skip",get children(){return e("welcome.skip")}}),null),Ct(s,K(Kx,{variant:"primary",onClick:a,"data-testid":"editor-welcome-enable",get children(){return e("welcome.enable")}}),null),t}})}const EL="http://schemas.openxmlformats.org/wordprocessingml/2006/main",LL="http://schemas.openxmlformats.org/package/2006/relationships",zL="http://schemas.openxmlformats.org/officeDocument/2006/relationships",NL="http://schemas.microsoft.com/office/word/2010/wordml";function OL(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qL(t,e){return Number.isFinite(t)?Math.max(0,Math.round(t/ke*Ne)):e}function PL(t){return null!=t&&Number.isFinite(t)?Math.round(t/ke*Ne):null}function WL(t){return null!=t&&Number.isFinite(t)?Math.max(0,Math.round(20*t)):null}function BL(t,e="000000"){return Rp(t)??e}function FL(t){if("end"===t.kind)return`<w:bookmarkEnd w:id="${t.wId}"/>`;const e=(void 0!==t.colFirst?` w:colFirst="${t.colFirst}"`:"")+(void 0!==t.colLast?` w:colLast="${t.colLast}"`:"");return`<w:bookmarkStart w:id="${t.wId}" w:name="${OL(t.name??"")}"${e}/>`}function HL(t){switch(t.kind){case"start":return`<w:commentRangeStart w:id="${t.wId}"/>`;case"end":return`<w:commentRangeEnd w:id="${t.wId}"/>`;case"reference":return`<w:r><w:commentReference w:id="${t.wId}"/></w:r>`}}const UL=`xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16du="http://schemas.microsoft.com/office/word/2023/wordml/word16du"`;function GL(t){const e=t.comments.map(({comment:t,wId:e,paraId:a})=>{const n=void 0!==t.date?` w:date="${new Date(t.date).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",r=void 0!==t.dateUtc?` w16du:dateUtc="${new Date(t.dateUtc).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",o=t.initials?` w:initials="${OL(t.initials)}"`:"";return`<w:comment w:id="${e}" w:author="${OL(t.author)}"${n}${r}${o}><w:p w14:paraId="${a}">${i=t.text,`<w:r>${i.split("\n").map((t,e)=>`${e>0?"<w:br/>":""}<w:t xml:space="preserve">${OL(t)}</w:t>`).join("")}</w:r>`}</w:p></w:comment>`;var i}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:comments ${UL}>${e}</w:comments>`}function DL(t,e="000000"){if("none"===t.type||t.width<=0)return'w:val="nil"/>';return`w:val="${"dotted"===t.type?"dotted":"dashed"===t.type?"dashed":"single"}" w:sz="${Math.max(1,Math.round(8*t.width))}" w:space="0" w:color="${BL(t.color,e)}"/>`}function jL(t){const e=[["top",t.borderTop],["left",t.borderLeft],["bottom",t.borderBottom],["right",t.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${DL(e)}`);return e.length>0?`<w:pBdr>${e.join("")}</w:pBdr>`:""}const ZL="6F6F6F";function KL(t){return t?Object.entries(t).map(([t,e])=>` ${t}="${OL(e)}"`).join(""):""}function XL(t){const e=/^\d+$/.test(t.id)?t.id:String(Array.from(t.id).reduce((t,e)=>31*t+e.charCodeAt(0)>>>0,0)),a=Number.isFinite(t.date)?new Date(t.date).toISOString():new Date(0).toISOString();return`w:id="${e}" w:author="${OL(t.author)}" w:date="${a}"`}function YL(t){if(!t||0===Object.keys(t).length)return"";const e=gy.filter(([,e])=>void 0!==t[e]).map(([e,a])=>`w:${e}="${t[a]?"1":"0"}"`).join(" ");return e?`<w:cnfStyle ${e}/>`:""}function JL(t,e){return void 0===e?"":e?`<w:${t}/>`:`<w:${t} w:val="0"/>`}function QL(t,e,a={}){if("number"==typeof e&&Number.isFinite(e))return`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`;if("string"==typeof e){const a=e.trim();if("auto"===a)return`<w:${t} w:w="0" w:type="auto"/>`;if(a.endsWith("%")){const e=Number.parseFloat(a.slice(0,-1));if(Number.isFinite(e))return`<w:${t} w:w="${Math.round(50*e)}" w:type="pct"/>`}const n=Number.parseFloat(a);if(Number.isFinite(n))return`<w:${t} w:w="${Math.round(n)}" w:type="dxa"/>`}return a.fallbackAuto?`<w:${t} w:w="0" w:type="auto"/>`:""}function _L(t,e=!0){return QL("tblW",t,{fallbackAuto:e})}function $L(t){return DL(t??{width:.75,type:"solid",color:`#${ZL}`},ZL)}function tz(t){if(!t)return"";const e=[],a=(t,a)=>{void 0!==a&&Number.isFinite(a)&&e.push(`<w:${t} w:w="${WL(a)??0}" w:type="dxa"/>`)};return a("top",t.top),a("left",t.left),a("bottom",t.bottom),a("right",t.right),a("start",t.start),a("end",t.end),e.length>0?`<w:tblCellMar>${e.join("")}</w:tblCellMar>`:""}function ez(t,e){var a,n,r,o,i,l,s,d,c,h,p;const u=Math.max(1,Math.floor(t.colSpan??1)),f=[],g=YL(t.conditionalStyle);g&&f.push(g);const m=QL("tcW",(null==(a=t.style)?void 0:a.width)??e);m&&f.push(m),u>1&&f.push(`<w:gridSpan w:val="${u}"/>`),"restart"===t.vMerge?f.push('<w:vMerge w:val="restart"/>'):"continue"===t.vMerge&&f.push("<w:vMerge/>"),(null==(n=t.style)?void 0:n.shading)&&f.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.style.shading,"FFFFFF")}"/>`);const v=JL("noWrap",null==(r=t.style)?void 0:r.noWrap);v&&f.push(v);const b=JL("tcFitText",null==(o=t.style)?void 0:o.fitText);if(b&&f.push(b),(null==(i=t.style)?void 0:i.headers)&&f.push(`<w:headers w:val="${OL(t.style.headers)}"/>`),null==(l=t.style)?void 0:l.verticalAlign){const e="middle"===t.style.verticalAlign?"center":t.style.verticalAlign;f.push(`<w:vAlign w:val="${e}"/>`)}(null==(s=t.style)?void 0:s.textDirection)&&f.push(`<w:textDirection w:val="${t.style.textDirection}"/>`),f.push(function(t){const e=t.style,a=null==e?void 0:e.padding,n=WL(a??(null==e?void 0:e.paddingTop)??0),r=WL(a??(null==e?void 0:e.paddingBottom)??0);return`<w:tcMar><w:top w:w="${n??0}" w:type="dxa"/><w:left w:w="${WL(a??(null==e?void 0:e.paddingLeft)??5.4)??0}" w:type="dxa"/><w:bottom w:w="${r??0}" w:type="dxa"/><w:right w:w="${WL(a??(null==e?void 0:e.paddingRight)??5.4)??0}" w:type="dxa"/>${void 0!==(null==e?void 0:e.paddingStart)?`<w:start w:w="${WL(e.paddingStart)??0}" w:type="dxa"/>`:""}${void 0!==(null==e?void 0:e.paddingEnd)?`<w:end w:w="${WL(e.paddingEnd)??0}" w:type="dxa"/>`:""}</w:tcMar>`}(t)),f.push(function(t){var e,a,n,r,o,i,l,s;const d=[`<w:top ${$L(null==(e=t.style)?void 0:e.borderTop)}`,`<w:left ${$L(null==(a=t.style)?void 0:a.borderLeft)}`,`<w:bottom ${$L(null==(n=t.style)?void 0:n.borderBottom)}`,`<w:right ${$L(null==(r=t.style)?void 0:r.borderRight)}`];return(null==(o=t.style)?void 0:o.borderStart)&&d.push(`<w:start ${$L(t.style.borderStart)}`),(null==(i=t.style)?void 0:i.borderEnd)&&d.push(`<w:end ${$L(t.style.borderEnd)}`),(null==(l=t.style)?void 0:l.borderTopLeftToBottomRight)&&d.push(`<w:tl2br ${$L(t.style.borderTopLeftToBottomRight)}`),(null==(s=t.style)?void 0:s.borderTopRightToBottomLeft)&&d.push(`<w:tr2bl ${$L(t.style.borderTopRightToBottomLeft)}`),`<w:tcBorders>${d.join("")}</w:tcBorders>`}(t));const y=JL("hideMark",null==(d=t.style)?void 0:d.hideMark);if(y&&f.push(y),null==(c=t.style)?void 0:c.propertyRevision){const e=t.style.propertyRevision,a=ez({...t,style:e.previous});f.push(`<w:tcPrChange ${XL(e)}>${a}</w:tcPrChange>`)}if(null==(h=t.style)?void 0:h.revision){const e=t.style.revision,a="insert"===e.type?"cellIns":"delete"===e.type?"cellDel":"cellMerge",n="merge"===e.type?`${(null==(p=e.previous)?void 0:p.vMerge)?` w:vMergeOrig="${"restart"===e.previous.vMerge?"rest":"cont"}"`:""}${t.vMerge?` w:vMerge="${"restart"===t.vMerge?"rest":"cont"}"`:""}`:"";f.push(`<w:${a} ${XL(e)}${n}/>`)}return f.length>0?`<w:tcPr>${f.join("")}</w:tcPr>`:""}function az(t,e){if(void 0===e||!Number.isFinite(e))return"";const a=Math.floor(e);return a>0?`<w:${t} w:val="${a}"/>`:""}function nz(t,e){const a="number"==typeof t?WL(t):"string"==typeof t?Number.parseFloat(t):null,n=null!==a&&Number.isFinite(a);if(!n&&!e)return"";const r=[];return n&&r.push(`w:val="${Math.round(a)}"`),r.push(`w:hRule="${e??"atLeast"}"`),`<w:trHeight ${r.join(" ")}/>`}function rz(t){if(!t)return"";const e=[],a=az("gridBefore",t.gridBefore);a&&e.push(a);const n=az("gridAfter",t.gridAfter);n&&e.push(n);const r=QL("wBefore",t.widthBefore);r&&e.push(r);const o=QL("wAfter",t.widthAfter);o&&e.push(o);const i=QL("tblCellSpacing",t.cellSpacing);i&&e.push(i);const l=nz(t.height,t.heightRule);l&&e.push(l);const s=JL("cantSplit",t.cantSplit);s&&e.push(s);const d=JL("hidden",t.hidden);d&&e.push(d);const c=JL("tblHeader",t.isHeader);return c&&e.push(c),t.align&&e.push(`<w:jc w:val="${t.align}"/>`),e.length>0?`<w:trPr>${e.join("")}</w:trPr>`:""}function oz(t){var e,a,n,r,o,i,l,s,d,c,h;const p=[],u=YL(t.conditionalStyle);u&&p.push(u);const f=az("gridBefore",null==(e=t.style)?void 0:e.gridBefore);f&&p.push(f);const g=az("gridAfter",null==(a=t.style)?void 0:a.gridAfter);g&&p.push(g);const m=QL("wBefore",null==(n=t.style)?void 0:n.widthBefore);m&&p.push(m);const v=QL("wAfter",null==(r=t.style)?void 0:r.widthAfter);v&&p.push(v);const b=QL("tblCellSpacing",null==(o=t.style)?void 0:o.cellSpacing);b&&p.push(b);const y=function(t){var e,a;return nz(null==(e=t.style)?void 0:e.height,null==(a=t.style)?void 0:a.heightRule)}(t);y&&p.push(y);const M=JL("cantSplit",null==(i=t.style)?void 0:i.cantSplit);M&&p.push(M),((null==(l=t.style)?void 0:l.isHeader)??t.isHeader)&&p.push("<w:tblHeader/>");const x=JL("hidden",null==(s=t.style)?void 0:s.hidden);if(x&&p.push(x),(null==(d=t.style)?void 0:d.align)&&p.push(`<w:jc w:val="${t.style.align}"/>`),null==(c=t.style)?void 0:c.propertyRevision){const e=t.style.propertyRevision;p.push(`<w:trPrChange ${XL(e)}>${rz(e.previous)}</w:trPrChange>`)}if((null==(h=t.style)?void 0:h.revision)&&"merge"!==t.style.revision.type){const e=t.style.revision,a="insert"===e.type?"ins":"del";p.push(`<w:${a} ${XL(e)}/>`)}return p.length>0?`<w:trPr>${p.join("")}</w:trPr>`:""}function iz(t){const e=null==t?void 0:t.borders;if(!e)return"";const a=my.map(([t,a])=>[t,e[a]]).filter(t=>!!t[1]).map(([t,e])=>`<w:${t} ${DL(e)}`).join("");return a?`<w:tblBorders>${a}</w:tblBorders>`:""}function lz(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f;const g=[];if((null==(e=t.style)?void 0:e.styleId)&&g.push(`<w:tblStyle w:val="${OL(t.style.styleId)}"/>`),null==(a=t.style)?void 0:a.tblLook){const e=t.style.tblLook;g.push(`<w:tblLook w:firstRow="${e.firstRow?"1":"0"}" w:lastRow="${e.lastRow?"1":"0"}" w:firstColumn="${e.firstCol?"1":"0"}" w:lastColumn="${e.lastCol?"1":"0"}" w:noHBand="${e.noHBand?"1":"0"}" w:noVBand="${e.noVBand?"1":"0"}"/>`)}(null==(n=t.style)?void 0:n.altTitle)&&g.push(`<w:tblCaption w:val="${OL(t.style.altTitle)}"/>`),(null==(r=t.style)?void 0:r.altDescription)&&g.push(`<w:tblDescription w:val="${OL(t.style.altDescription)}"/>`);const m=function(t){if(!t||0===Object.keys(t).length)return"";const e=t=>{const e=WL(t);return null===e?void 0:String(e)},a={horzAnchor:t.horizontalAnchor,vertAnchor:t.verticalAnchor,tblpX:e(t.x),tblpY:e(t.y),tblpXSpec:t.xAlign,tblpYSpec:t.yAlign,topFromText:e(t.distanceTop),rightFromText:e(t.distanceRight),bottomFromText:e(t.distanceBottom),leftFromText:e(t.distanceLeft)};return`<w:tblpPr ${Object.entries(a).filter(t=>void 0!==t[1]).map(([t,e])=>`w:${t}="${OL(e)}"`).join(" ")}/>`}(null==(o=t.style)?void 0:o.floating);m&&g.push(m);const v=t.gridCols&&t.gridCols.length>0?t.gridCols.reduce((t,e)=>t+e,0):void 0;g.push(_L((null==(i=t.style)?void 0:i.width)??v)),(null==(l=t.style)?void 0:l.align)&&g.push(`<w:jc w:val="${t.style.align}"/>`);const b=QL("tblCellSpacing",null==(s=t.style)?void 0:s.cellSpacing);b&&g.push(b);const y=tz(null==(d=t.style)?void 0:d.defaultCellMargins);y&&g.push(y);const M=iz(t.style);M&&g.push(M);const x=QL("tblInd",null==(c=t.style)?void 0:c.indentLeft);x&&g.push(x),g.push(`<w:tblLayout w:type="${(null==(h=t.style)?void 0:h.layout)??"fixed"}"/>`);const w=JL("bidiVisual",null==(p=t.style)?void 0:p.bidiVisual);if(w&&g.push(w),(null==(u=t.style)?void 0:u.tblOverlap)&&g.push(`<w:tblOverlap w:val="${OL(t.style.tblOverlap)}"/>`),null==(f=t.style)?void 0:f.revision){const e=t.style.revision,a=lz({...t,style:e.previous});g.push(`<w:tblPrChange ${XL(e)}>${a}</w:tblPrChange>`)}return`<w:tblPr>${g.join("")}</w:tblPr>`}function sz(t,e){const a=Io(t),n=new Map(a.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t])),r=t.rows.map((a,r)=>{const o=a.cells.map((a,o)=>{const i=n.get(`${r}:${o}`),l=i&&t.gridCols?t.gridCols.slice(i.visualColumnIndex,i.visualColumnIndex+Math.max(1,i.colSpan)).reduce((t,e)=>t+e,0):void 0,s=(a.blocks.length>0?a.blocks:[{id:"",type:"paragraph",runs:[{id:"",text:"",kind:"text"}]}]).map(t=>e(t,a)).join(""),d="continue"===a.vMerge?"<w:p/>":s;return`<w:tc${KL(a.extAttributes)}>${ez(a,l)}${d}</w:tc>`}).join("");return`<w:tr${KL(a.extAttributes)}>${function(t,e){if(!t&&!e)return"";const a=[];void 0!==(null==t?void 0:t.width)&&a.push(_L(t.width)),(null==t?void 0:t.align)&&a.push(`<w:jc w:val="${t.align}"/>`);const n=QL("tblCellSpacing",null==t?void 0:t.cellSpacing);n&&a.push(n);const r=QL("tblInd",null==t?void 0:t.indentLeft);r&&a.push(r);const o=t?iz(t):"";o&&a.push(o),(null==t?void 0:t.layout)&&a.push(`<w:tblLayout w:type="${t.layout}"/>`);const i=tz(null==t?void 0:t.defaultCellMargins);return i&&a.push(i),e&&a.push(e),a.length>0?`<w:tblPrEx>${a.join("")}</w:tblPrEx>`:""}(a.propertyExceptions,a.tblPrExChangeXml)}${oz(a)}${o}</w:tr>`}).join(""),o=t.gridCols?`<w:tblGrid>${t.gridCols.map(t=>`<w:gridCol w:w="${WL(t)??0}"/>`).join("")}${t.gridRevision?`<w:tblGridChange ${XL(t.gridRevision)}><w:tblGrid>${t.gridRevision.previous.map(t=>`<w:gridCol w:w="${WL(t)??0}"/>`).join("")}</w:tblGrid></w:tblGridChange>`:""}</w:tblGrid>`:"";return`<w:tbl>${lz(t)}${o}${r}</w:tbl>`}function dz(t){if(!t||0===t.length)return"";const e=t.map(t=>{const e=WL(t.position);if(null===e)return"";const a=[`w:val="${t.type}"`,`w:pos="${e}"`];return t.leader&&"none"!==t.leader?a.push(`w:leader="${t.leader}"`):"none"===t.leader&&a.push('w:leader="none"'),`<w:tab ${a.join(" ")}/>`}).filter(Boolean);return e.length>0?`<w:tabs>${e.join("")}</w:tabs>`:""}function cz(t){const e=[];if(t.align&&e.push(`<w:jc w:val="${t.align}"/>`),void 0!==t.spacingBefore||void 0!==t.spacingAfter||void 0!==t.lineHeight){const a=[],n=PL(t.spacingBefore),r=PL(t.spacingAfter),o=void 0!==t.lineHeight&&null!==t.lineHeight&&Number.isFinite(t.lineHeight),i="exact"===t.lineRule||"atLeast"===t.lineRule,l=o?i?qL(t.lineHeight,0):Math.round(240*t.lineHeight):null;null!==n&&a.push(`w:before="${n}"`),null!==r&&a.push(`w:after="${r}"`),null!==l&&a.push(`w:line="${l}"`),null!==l&&i&&a.push(`w:lineRule="${t.lineRule}"`),a.length>0&&e.push(`<w:spacing ${a.join(" ")}/>`)}if(void 0!==t.indentLeft||void 0!==t.indentRight||void 0!==t.indentFirstLine||void 0!==t.indentHanging){const a=[],n=PL(t.indentLeft),r=PL(t.indentRight),o=PL(t.indentFirstLine),i=PL(t.indentHanging);null!==n&&a.push(`w:left="${n}"`),null!==r&&a.push(`w:right="${r}"`),null!==o&&a.push(`w:firstLine="${o}"`),null!==i&&a.push(`w:hanging="${i}"`),a.length>0&&e.push(`<w:ind ${a.join(" ")}/>`)}const a=dz(t.tabs);a&&e.push(a),t.pageBreakBefore&&e.push("<w:pageBreakBefore/>"),t.keepWithNext&&e.push("<w:keepNext/>"),t.keepLinesTogether&&e.push("<w:keepLines/>"),!1===t.widowControl&&e.push('<w:widowControl w:val="0"/>'),t.contextualSpacing&&e.push("<w:contextualSpacing/>");const n=jL(t);return n&&e.push(n),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.shading,"FFFFFF")}"/>`),t.textDirection&&e.push(`<w:textDirection w:val="${t.textDirection}"/>`),null!=t.outlineLevel&&e.push(`<w:outlineLvl w:val="${t.outlineLevel}"/>`),e.length>0?`<w:pPr>${e.join("")}</w:pPr>`:""}function hz(t,e,a,n){var r,o;const i=[],l=function(t,e){const a=sa(t.style,e);return{align:a.align,spacingBefore:a.spacingBefore,spacingAfter:a.spacingAfter,contextualSpacing:a.contextualSpacing,lineHeight:a.lineHeight,lineRule:a.lineRule,indentLeft:a.indentLeft,indentRight:a.indentRight,indentFirstLine:a.indentFirstLine,indentHanging:a.indentHanging,pageBreakBefore:a.pageBreakBefore,keepWithNext:a.keepWithNext,keepLinesTogether:a.keepLinesTogether,widowControl:a.widowControl,shading:a.shading,borderTop:a.borderTop,borderRight:a.borderRight,borderBottom:a.borderBottom,borderLeft:a.borderLeft,tabs:a.tabs,textDirection:a.textDirection,outlineLevel:a.outlineLevel}}(t,a),s=(null==(r=t.style)?void 0:r.align)??(null==n?void 0:n.align)??l.align;if((null==(o=t.style)?void 0:o.styleId)&&i.push(`<w:pStyle w:val="${OL(t.style.styleId)}"/>`),s&&i.push(`<w:jc w:val="${s}"/>`),void 0!==l.spacingBefore||void 0!==l.spacingAfter||void 0!==l.lineHeight){const t=[],e=PL(l.spacingBefore),a=PL(l.spacingAfter),n=void 0!==l.lineHeight&&null!==l.lineHeight&&Number.isFinite(l.lineHeight),r="exact"===l.lineRule||"atLeast"===l.lineRule,o=n?r?qL(l.lineHeight,0):Math.round(240*l.lineHeight):null;null!==e&&t.push(`w:before="${e}"`),null!==a&&t.push(`w:after="${a}"`),null!==o&&t.push(`w:line="${o}"`),null!==o&&r&&t.push(`w:lineRule="${l.lineRule}"`),t.length>0&&i.push(`<w:spacing ${t.join(" ")}/>`)}if(void 0!==l.indentLeft||void 0!==l.indentRight||void 0!==l.indentFirstLine||void 0!==l.indentHanging){const t=[],e=PL(l.indentLeft),a=PL(l.indentRight),n=PL(l.indentFirstLine),r=PL(l.indentHanging);null!==e&&t.push(`w:left="${e}"`),null!==a&&t.push(`w:right="${a}"`),null!==n&&t.push(`w:firstLine="${n}"`),null!==r&&t.push(`w:hanging="${r}"`),t.length>0&&i.push(`<w:ind ${t.join(" ")}/>`)}const d=dz(l.tabs);d&&i.push(d),l.pageBreakBefore&&i.push("<w:pageBreakBefore/>"),l.keepWithNext&&i.push("<w:keepNext/>"),l.keepLinesTogether&&i.push("<w:keepLines/>"),!1===l.widowControl&&i.push('<w:widowControl w:val="0"/>'),l.contextualSpacing&&i.push("<w:contextualSpacing/>");const c=jL(l);c&&i.push(c),l.shading&&i.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(l.shading,"FFFFFF")}"/>`),l.textDirection&&i.push(`<w:textDirection w:val="${l.textDirection}"/>`),null!=l.outlineLevel&&i.push(`<w:outlineLvl w:val="${l.outlineLevel}"/>`);const h=e.get(t.id);return h&&i.push(`<w:numPr><w:ilvl w:val="${h.level}"/><w:numId w:val="${h.numId}"/></w:numPr>`),i.length>0?`<w:pPr>${i.join("")}</w:pPr>`:""}const pz={black:[0,0,0],blue:[0,0,255],cyan:[0,255,255],green:[0,128,0],magenta:[255,0,255],red:[255,0,0],yellow:[255,255,0],white:[255,255,255],darkBlue:[0,0,139],darkCyan:[0,139,139],darkGreen:[0,100,0],darkMagenta:[139,0,139],darkRed:[139,0,0],darkYellow:[184,134,11],darkGray:[169,169,169],lightGray:[211,211,211]},uz={ffff00:"yellow",fef08a:"yellow",ff0000:"red","00ff00":"green","0000ff":"blue","00ffff":"cyan",ff00ff:"magenta","000000":"black",ffffff:"white"},fz="http://schemas.openxmlformats.org/markup-compatibility/2006";function gz(t){return`<w14:solidFill><w14:srgbClr w14:val="${BL(t)}"/></w14:solidFill>`}function mz(t){if("solid"===t.type)return gz(t.color);return`<w14:gradFill><w14:gsLst>${t.stops.map(t=>{const e=BL(t.color);return`<w14:gs w14:pos="${Math.round(t.position*Oe)}"><w14:srgbClr w14:val="${e}">${void 0!==t.alpha?`<w14:alpha w14:val="${Math.round(t.alpha*Oe)}"/>`:""}</w14:srgbClr></w14:gs>`}).join("")}</w14:gsLst><w14:lin w14:ang="${Math.round((t.angle??0)*qe)}" w14:scaled="0"/></w14:gradFill>`}function vz(t,e){return`<w14:srgbClr w14:val="${BL(t)}">${void 0!==e?`<w14:alpha w14:val="${Math.round(e*Oe)}"/>`:""}</w14:srgbClr>`}function bz(t){return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14">${t}</mc:Choice><mc:Fallback/></mc:AlternateContent>`}function yz(t){return null!=t&&Number.isFinite(t)?Math.round(20*t):null}const Mz=Ep;function xz(t){if(!t)return"";const e=[];if(t.bold&&e.push("<w:b/>","<w:bCs/>"),t.italic&&e.push("<w:i/>","<w:iCs/>"),t.underline){const a=t.underlineStyle??"single",n=t.underlineColor?` w:color="${OL(t.underlineColor.replace(/^#/,""))}"`:"";e.push(`<w:u w:val="${OL(a)}"${n}/>`)}if(t.strike&&e.push("<w:strike/>"),t.doubleStrike&&e.push("<w:dstrike/>"),t.outline&&e.push("<w:outline/>"),t.shadow&&e.push("<w:shadow/>"),t.emboss&&e.push("<w:emboss/>"),t.imprint&&e.push("<w:imprint/>"),t.smallCaps&&e.push("<w:smallCaps/>"),t.allCaps&&e.push("<w:caps/>"),t.hidden&&e.push("<w:vanish/>"),t.noProof&&e.push("<w:noProof/>"),t.webHidden&&e.push("<w:webHidden/>"),t.specVanish&&e.push("<w:specVanish/>"),!1===t.snapToGrid&&e.push('<w:snapToGrid w:val="0"/>'),t.textEffect&&e.push(`<w:effect w:val="${OL(t.textEffect)}"/>`),t.textBorder&&e.push(`<w:bdr ${DL(t.textBorder)}`),void 0!==t.characterScale&&null!==t.characterScale&&Number.isFinite(t.characterScale)&&e.push(`<w:w w:val="${Math.max(1,Math.round(t.characterScale))}"/>`),void 0!==t.characterSpacing&&null!==t.characterSpacing){const a=yz(t.characterSpacing);null!==a&&e.push(`<w:spacing w:val="${a}"/>`)}void 0!==t.baselineShift&&null!==t.baselineShift&&Number.isFinite(t.baselineShift)&&e.push(`<w:position w:val="${Math.round(2*t.baselineShift)}"/>`),void 0!==t.kerningThreshold&&null!==t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e.push(`<w:kern w:val="${Math.max(0,Math.round(2*t.kerningThreshold))}"/>`);const a=function(t){switch(t){case"none":return"none";case"standard":return"standard";case"contextual":return"contextual";case"historical":return"historical";case"standardContextual":return"standardContextual";default:return null}}(t.ligatures);a&&e.push(`<w14:ligatures w14:val="${a}"/>`);const n=function(t){switch(t){case"proportional":return"proportional";case"tabular":return"tabular";default:return null}}(t.numberSpacing);n&&e.push(`<w14:numSpacing w14:val="${n}"/>`);const r=function(t){switch(t){case"lining":return"lining";case"oldStyle":return"oldStyle";default:return null}}(t.numberForm);r&&e.push(`<w14:numForm w14:val="${r}"/>`);const o="number"!=typeof(i=t.stylisticSet)||i<1||i>20?null:(1<<i-1).toString(16).toUpperCase().padStart(8,"0");var i;if(o&&e.push(`<w14:stylisticSets w14:val="${o}"/>`),t.contextualAlternates&&e.push('<w14:cntxtAlts w14:val="1"/>'),t.superscript?e.push('<w:vertAlign w:val="superscript"/>'):t.subscript&&e.push('<w:vertAlign w:val="subscript"/>'),t.fontFamily&&e.push(`<w:rFonts w:ascii="${OL(t.fontFamily)}" w:hAnsi="${OL(t.fontFamily)}" w:cs="${OL(t.fontFamily)}"/>`),void 0!==t.fontSize&&null!==t.fontSize){const a=function(t){return null!=t&&Number.isFinite(t)?Math.round(t/ke*72*2):null}(t.fontSize);null!==a&&e.push(`<w:sz w:val="${a}"/>`,`<w:szCs w:val="${a}"/>`)}if(t.textFill){const a="solid"===t.textFill.type?t.textFill.color:t.color;e.push(function(t,e){const a=mz(t),n=BL(e??"000000");return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:textFill>${a}</w14:textFill></mc:Choice><mc:Fallback><w:color w:val="${n}"/></mc:Fallback></mc:AlternateContent>`}(t.textFill,a??null))}else t.color&&e.push(`<w:color w:val="${OL(t.color.replace(/^#/,""))}"/>`);if(t.textOutline&&e.push(function(t){const e=Math.round(Math.max(0,t.widthPt)*ze),a=t.fill?mz(t.fill):t.color?gz(t.color):"";return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:textOutline w14:w="${e}" w14:cap="flat" w14:cmpd="sng" w14:algn="ctr">`+a+"</w14:textOutline></mc:Choice><mc:Fallback><w:outline/></mc:Fallback></mc:AlternateContent>"}(t.textOutline)),t.textShadow&&e.push(function(t){const e=Math.round(Math.max(0,t.blurPt)*ze),a=Math.round(Math.max(0,t.distPt)*ze),n=Math.round(t.dirDeg*qe),r=vz(t.color,t.alpha);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:shadow w14:blurRad="${e}" w14:dist="${a}" w14:dir="${n}" w14:sx="100000" w14:sy="100000" w14:kx="0" w14:ky="0" w14:algn="ctr">`+r+"</w14:shadow></mc:Choice><mc:Fallback><w:shadow/></mc:Fallback></mc:AlternateContent>"}(t.textShadow)),t.glow&&e.push(function(t){const e=Math.round(Math.max(0,t.radiusPt)*ze),a=vz(t.color,t.alpha);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:glow w14:rad="${e}">${a}</w14:glow></mc:Choice><mc:Fallback/></mc:AlternateContent>`}(t.glow)),t.reflection&&e.push(function(t){const e=Math.round(Math.max(0,t.blurPt)*ze),a=Math.round(t.startAlpha*Oe),n=Math.round(t.startPos*Oe),r=Math.round(t.endAlpha*Oe),o=Math.round(t.endPos*Oe),i=Math.round(Math.max(0,t.distPt)*ze);return`<mc:AlternateContent xmlns:mc="${fz}"><mc:Choice Requires="w14"><w14:reflection w14:blurRad="${e}" w14:stA="${a}" w14:stPos="${n}" w14:endA="${r}" w14:endPos="${o}" w14:dist="${i}" w14:dir="5400000" w14:fadeDir="5400000" w14:sx="100000" w14:sy="-100000" w14:kx="0" w14:ky="0" w14:algn="bl"/></mc:Choice><mc:Fallback/></mc:AlternateContent>`}(t.reflection)),t.scene3dXml&&e.push(bz(t.scene3dXml)),t.props3dXml&&e.push(bz(t.props3dXml)),t.highlight&&e.push(`<w:highlight w:val="${OL(function(t){if(t in pz)return t;const e=t.trim().replace(/^#/,"").toLowerCase(),a=uz[e];if(a)return a;const n=Mz(t);if(!n)return"yellow";let r="yellow",o=Number.POSITIVE_INFINITY;for(const[i,l]of Object.entries(pz)){const t=(l[0]-n[0])**2+(l[1]-n[1])**2+(l[2]-n[2])**2;t<o&&(o=t,r=i)}return r}(t.highlight))}"/>`),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${BL(t.shading,"FFFFFF")}"/>`),void 0!==t.fitText&&null!==t.fitText&&Number.isFinite(t.fitText)){const a=yz(t.fitText);null!==a&&a>0&&e.push(`<w:fitText w:val="${a}"/>`)}if(t.rtl&&e.push("<w:rtl/>"),t.complexScript&&e.push("<w:cs/>"),t.emphasisMark&&e.push(`<w:em w:val="${OL(t.emphasisMark)}"/>`),t.language){const a=[];t.language.value&&a.push(`w:val="${OL(t.language.value)}"`),t.language.eastAsia&&a.push(`w:eastAsia="${OL(t.language.eastAsia)}"`),t.language.bidi&&a.push(`w:bidi="${OL(t.language.bidi)}"`),a.length>0&&e.push(`<w:lang ${a.join(" ")}/>`)}return e.length>0?`<w:rPr>${e.join("")}</w:rPr>`:""}function wz(t){if(0===t.length)return"";var e;return`<w:t${/^\s|\s$/.test(e=t)||e.includes(" ")?' xml:space="preserve"':""}>${OL(t)}</w:t>`}function Sz(t){if(0===t.length)return"<w:t></w:t>";let e="",a="";for(const n of t)"\n"!==n?"\t"!==n?"‑"!==n?""!==n?a+=n:(e+=wz(a),a="",e+="<w:softHyphen/>"):(e+=wz(a),a="",e+="<w:noBreakHyphen/>"):(e+=wz(a),a="",e+="<w:tab/>"):(e+=wz(a),a="",e+="<w:br/>");return e+=wz(a),e||"<w:t></w:t>"}function Az(t,e){return t??e?"1":"0"}function Cz(t,e,a){const n=OL((null==e?void 0:e.relativeFrom)??a);if(null==e?void 0:e.align)return`<wp:${t} relativeFrom="${n}"><wp:align>${OL(e.align)}</wp:align></wp:${t}>`;return`<wp:${t} relativeFrom="${n}"><wp:posOffset>${(null==e?void 0:e.offset)??0}</wp:posOffset></wp:${t}>`}function Iz(t){if(!t||t.length<3)return"";const e=t=>Math.round(21600*Math.min(1,Math.max(0,t))),a=(t,a)=>`<wp:${a} x="${e(t.x)}" y="${e(t.y)}"/>`,n=t[0];return`<wp:wrapPolygon edited="0">${[a(n,"start"),...t.slice(1).map(t=>a(t,"lineTo")),a(n,"lineTo")].join("")}</wp:wrapPolygon>`}function Tz(t){const{cx:e,cy:a,floating:n,docPrId:r,docPrName:o,altAttr:i,graphicXml:l}=t,s=OL(o);if(!n)return`<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:inline></w:drawing>`;const d=n.distT??0,c=n.distB??0,h=n.distL??0,p=n.distR??0,u=Cz("positionH",n.positionH,"column"),f=Cz("positionV",n.positionV,"paragraph"),g=function(t,e){switch(t){case"square":return'<wp:wrapSquare wrapText="bothSides"/>';case"tight":{const t=Iz(e);return t?`<wp:wrapTight wrapText="bothSides">${t}</wp:wrapTight>`:'<wp:wrapTight wrapText="bothSides"/>'}case"through":{const t=Iz(e);return t?`<wp:wrapThrough wrapText="bothSides">${t}</wp:wrapThrough>`:'<wp:wrapThrough wrapText="bothSides"/>'}case"topAndBottom":return"<wp:wrapTopAndBottom/>";default:return"<wp:wrapNone/>"}}(n.wrap,t.wrapPolygon);return`<w:drawing><wp:anchor distT="${d}" distB="${c}" distL="${h}" distR="${p}" simplePos="${Az(n.simplePos,!1)}" relativeHeight="${n.relativeHeight??0}" behindDoc="${Az(n.behindDoc,!1)}" locked="${Az(n.locked,!1)}" layoutInCell="${Az(n.layoutInCell,!0)}" allowOverlap="${Az(n.allowOverlap,!0)}"><wp:simplePos x="0" y="0"/>${u}${f}<wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/>${g}<wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:anchor></w:drawing>`}function kz(t,e,a,n){const r=a.images.find(t=>t.rId===e);if(!r)return null;const o=(parseInt(e.replace(/\D+/g,""),10)||0)+1,i=void 0!==r.alt?` descr="${OL(r.alt)}" title="${OL(r.alt)}"`:"",l=function(t){let e="";if(t.rotation){const a=Math.round(t.rotation*qe);0!==a&&(e+=` rot="${a}"`)}return t.flipH&&(e+=' flipH="1"'),t.flipV&&(e+=' flipV="1"'),e}(r),s=function(t){if(!t)return"";const e=t=>t?Math.round(t*Oe):0,a=e(t.left),n=e(t.top),r=e(t.right),o=e(t.bottom);return 0===a&&0===n&&0===r&&0===o?"":`<a:srcRect l="${a}" t="${n}" r="${r}" b="${o}"/>`}(r.crop),d="tile"===r.fillMode?"<a:tile/>":"<a:stretch><a:fillRect/></a:stretch>",c=function(t,e,a,n){return Tz({cx:t.cx,cy:t.cy,floating:t.floating,docPrId:e,docPrName:"Picture",altAttr:a,graphicXml:n,wrapPolygon:t.wrapPolygon})}(r,o,i,`<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="0" name="Picture"${i}/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip ${"linked"===r.kind?`r:link="${e}"`:`r:embed="${e}"`} xmlns:r="${zL}"/>${s}${d}</pic:blipFill><pic:spPr><a:xfrm${l}><a:off x="0" y="0"/><a:ext cx="${r.cx}" cy="${r.cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic>`);return`<w:r>${n}${c}</w:r>`}function Vz(t,e,a,n,r,o){const i=Math.round(e.width*Le),l=Math.round(e.height*Le),s=a.textBoxDocPrIds.get(t.id)??1,d=e.name??"Text Box",c=void 0!==e.alt?` descr="${OL(e.alt)}" title="${OL(e.alt)}"`:"",h=function(t,e,a,n,r,o){const i=t.shape,l=OL((null==i?void 0:i.preset)??"rect"),s=t.rotation?Math.round(t.rotation*qe):0,d=0!==s?` rot="${s}"`:"",c=(null==i?void 0:i.fill)?`<a:solidFill><a:srgbClr val="${OL(i.fill.replace(/^#/,""))}"/></a:solidFill>`:"";let h="";((null==i?void 0:i.borderColor)||void 0!==(null==i?void 0:i.borderWidthPt))&&(h=`<a:ln${void 0!==(null==i?void 0:i.borderWidthPt)?` w="${Math.round(i.borderWidthPt*ze)}"`:""}>${(null==i?void 0:i.borderColor)?`<a:solidFill><a:srgbClr val="${OL(i.borderColor.replace(/^#/,""))}"/></a:solidFill>`:""}<a:miter lim="800000"/></a:ln>`);const p=t.body,u=['rot="0"',`vert="${OL((null==p?void 0:p.vert)??"horz")}"`];u.push(`wrap="${OL((null==p?void 0:p.wrap)??"square")}"`),void 0!==(null==p?void 0:p.paddingLeft)&&u.push(`lIns="${Math.round(p.paddingLeft*Le)}"`),void 0!==(null==p?void 0:p.paddingTop)&&u.push(`tIns="${Math.round(p.paddingTop*Le)}"`),void 0!==(null==p?void 0:p.paddingRight)&&u.push(`rIns="${Math.round(p.paddingRight*Le)}"`),void 0!==(null==p?void 0:p.paddingBottom)&&u.push(`bIns="${Math.round(p.paddingBottom*Le)}"`),u.push(`anchor="${OL((null==p?void 0:p.anchor)??"t")}"`),u.push('anchorCtr="0"');const f=(null==p?void 0:p.autoFit)?"<a:spAutoFit/>":"",g=t.blocks.length>0,m=g?o(t.blocks,n,r):"";return'<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"><wps:wsp>'+(g?'<wps:cNvSpPr txBox="1"><a:spLocks noChangeArrowheads="1"/></wps:cNvSpPr>':"<wps:cNvSpPr/>")+`<wps:spPr bwMode="auto"><a:xfrm${d}><a:off x="0" y="0"/><a:ext cx="${e}" cy="${a}"/></a:xfrm><a:prstGeom prst="${l}"><a:avLst/></a:prstGeom>`+c+h+"</wps:spPr>"+(g?`<wps:txbx><w:txbxContent>${m}</w:txbxContent></wps:txbx>`:"")+`<wps:bodyPr ${u.join(" ")}>${f}</wps:bodyPr></wps:wsp></a:graphicData></a:graphic>`}(e,i,l,a,n,o);return`<w:r>${r}${Tz({cx:i,cy:l,floating:e.floating,docPrId:s,docPrName:d,altAttr:c,graphicXml:h})}</w:r>`}const Rz={footnote:"FootnoteReference",endnote:"EndnoteReference"};function Ez(t){return`<w:r><w:rPr><w:rStyle w:val="${Rz[t]}"/><w:vertAlign w:val="superscript"/></w:rPr><w:${t}Ref/></w:r>`}function Lz(t,e,a,n){if(!e)return null;const r="footnote"===t?n.footnoteIdMap:n.endnoteIdMap,o=null==r?void 0:r.get(e.noteId);if(void 0===o)return null;const i={...a??{},superscript:!0},l=e.customMark?' w:customMarkFollows="1"':"",s=e.customMark?`<w:t xml:space="preserve">${OL(e.customMark)}</w:t>`:"";return`<w:r>${xz(i)}<w:${t}Reference${l} w:id="${o}"/>${s}</w:r>`}function zz(t,e,a,n,r){if(t.__isFootnoteRefMarker)return Ez("footnote");if(t.__isEndnoteRefMarker)return Ez("endnote");const o=function(t,e,a){var n;const r=la(t.styles,e,a),o={bold:r.bold,italic:r.italic,underline:r.underline,underlineStyle:r.underlineStyle,underlineColor:r.underlineColor,strike:r.strike,doubleStrike:r.doubleStrike,superscript:r.superscript,subscript:r.subscript,smallCaps:r.smallCaps,allCaps:r.allCaps,hidden:r.hidden,noProof:r.noProof,webHidden:r.webHidden,specVanish:r.specVanish,rtl:r.rtl,complexScript:r.complexScript,snapToGrid:r.snapToGrid,fitText:r.fitText,emphasisMark:r.emphasisMark,textBorder:r.textBorder,outline:r.outline,shadow:r.shadow,emboss:r.emboss,imprint:r.imprint,textEffect:r.textEffect,characterScale:r.characterScale,characterSpacing:r.characterSpacing,baselineShift:r.baselineShift,kerningThreshold:r.kerningThreshold,ligatures:r.ligatures,numberSpacing:r.numberSpacing,numberForm:r.numberForm,stylisticSet:r.stylisticSet,contextualAlternates:r.contextualAlternates,fontFamily:r.fontFamily,fontSize:r.fontSize,color:r.color,textFill:r.textFill,textOutline:r.textOutline,textShadow:r.textShadow,glow:r.glow,reflection:r.reflection,scene3dXml:r.scene3dXml,props3dXml:r.props3dXml,highlight:r.highlight,shading:r.shading,language:r.language};return(null==(n=t.styles)?void 0:n.link)&&(o.link=t.styles.link),o}(t,a,n),i=()=>xz(o),l=()=>`<w:r>${i()}${Sz(t.text)}</w:r>`;return Ie(t,{footnoteReference:t=>function(t,e,a){const n=Ae(t);return Lz("footnote",n?{noteId:n.footnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e)??l(),endnoteReference:t=>function(t,e,a){const n=Ce(t);return Lz("endnote",n?{noteId:n.endnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e)??l(),fieldChar:t=>function(t,e){const a=(t.fieldLock?' w:fldLock="true"':"")+(t.dirty?' w:dirty="true"':"");return`<w:r>${e}<w:fldChar w:fldCharType="${t.kind}"${a}/></w:r>`}(t.fieldChar,i()),fieldInstruction:t=>{return e=t.fieldInstruction,`<w:r>${i()}<w:instrText xml:space="preserve">${OL(e)}</w:instrText></w:r>`;var e},field:t=>{return e=t.field.type,a=i(),`<w:fldSimple w:instr="${"PAGE"===e?" PAGE ":" NUMPAGES "}"><w:r>${a}<w:t>1</w:t></w:r></w:fldSimple>`;var e,a},textBox:t=>Vz(t,t.textBox,e,n,i(),r),image:t=>{const a=e.imageMap.get(t.id);if(a){const n=kz(t.id,a,e,i());if(null!==n)return n}return l()},sym:t=>`<w:r>${i()}<w:sym w:font="${OL(t.sym.font)}" w:char="${t.sym.char}"/></w:r>`,text:()=>l()})}function Nz(t,e,a,n,r){var o;const i=zz(t,e,a,n,r),l=null==(o=t.styles)?void 0:o.link;return l?function(t,e,a){if(e.startsWith("#"))return`<w:hyperlink w:anchor="${OL(e.slice(1))}">${t}</w:hyperlink>`;const n=a.hyperlinkMap.get(e);return n?`<w:hyperlink r:id="${n}">${t}</w:hyperlink>`:t}(i,l,e):i}function Oz(t){return"text"===t.kind||"sym"===t.kind}function qz(t,e,a){var n;switch(t.type){case"paragraph":return Wz(t,e,a);case"table":return((null==(n=t.style)?void 0:n.pageBreakBefore)?'<w:p><w:r><w:br w:type="page"/></w:r></w:p>':"")+sz(t,(t,n)=>{var r;return Wz(t,e,a,{align:null==(r=n.style)?void 0:r.horizontalAlign})});default:return ve(t,"block")}}function Pz(t,e,a){var n,r,o;let i="",l=0;for(;l<t.length;){const s=t[l],d=null==(n=s.sdtWrappers)?void 0:n[0];if(!d){i+=qz(s,e,a),l+=1;continue}const c=[];let h=l;for(;h<t.length&&(null==(o=null==(r=t[h].sdtWrappers)?void 0:r[0])?void 0:o.groupId)===d.groupId;){const e=t[h].sdtWrappers.slice(1);c.push({...t[h],sdtWrappers:e.length>0?e:void 0}),h+=1}const p=Pz(c,e,a);i+=`<w:sdt>${d.sdtPrXml}${d.sdtEndPrXml??""}<w:sdtContent>${p}</w:sdtContent></w:sdt>`,l=h}return i}function Wz(t,e,a,n){var r,o,i;const l=t.runs.length>0?t.runs:[{id:"",text:"",kind:"text"}],s=t.dropCap?function(t){const e=xz(t.style);var a;return`<w:p><w:pPr><w:keepNext/><w:framePr w:dropCap="${t.type}" w:lines="${t.lines}" w:wrap="around" w:vAnchor="text" w:hAnchor="text"/><w:spacing w:after="0"/>${e?`<w:rPr>${a=e,a.replace(/^<w:rPr>/,"").replace(/<\/w:rPr>$/,"")}</w:rPr>`:""}</w:pPr><w:r>${e}${Sz(t.text)}</w:r></w:p>`}(t.dropCap):"",d=null==(r=e.bookmarkEventsByParagraph)?void 0:r.get(t.id),c=null==(o=e.commentEventsByParagraph)?void 0:o.get(t.id),h=[...(d??[]).map(t=>({offset:t.offset,seq:t.seq,xml:FL(t)})),...(c??[]).map(t=>({offset:t.offset,seq:t.seq,xml:HL(t)}))],p=h.length>0?function(t,e,a,n,r){const o=[...e].sort((t,e)=>t.offset-e.offset||t.seq-e.seq);let i=0,l=0,s="";const d=t=>{for(;i<o.length&&o[i].offset<=t;)s+=o[i].xml,i+=1};for(const c of t){const t=l,e=t+c.text.length;if(d(t),Oz(c)&&c.text.length>0){let l=t;for(;i<o.length&&o[i].offset<e;){const e=o[i];e.offset>l&&(s+=Nz({...c,text:c.text.slice(l-t,e.offset-t)},a,n,r,Pz)),s+=e.xml,i+=1,l=e.offset}l<e&&(s+=Nz({...c,text:c.text.slice(l-t)},a,n,r,Pz))}else s+=Nz(c,a,n,r,Pz);l=e}return d(Number.POSITIVE_INFINITY),s}(l,h,e,null==(i=t.style)?void 0:i.styleId,a):l.map(n=>{var r;return Nz(n,e,null==(r=t.style)?void 0:r.styleId,a,Pz)}).join("");return`${s}<w:p>${hz(t,e.numberingInfo,a,n)}${p}</w:p>`}function Bz(t){if(0===t.length)return[Fz()];const[e,...a]=t;return"paragraph"!==e.type?[Fz(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:footnoteRef",text:"",kind:"text",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"FootnoteText"}}),...a];var n,r}function Fz(t=!0){return{id:"synthetic:footnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:footnoteRef",text:"",kind:"text",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0}]:[],{id:"synthetic:footnote-body-empty-text",text:"",kind:"text"}],style:{styleId:"FootnoteText"}}}function Hz(t){var e;const a=null==(e=t.endnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of function(t){return Pc(t,"endnoteReference")}(t)){const t=Ce(o);if(!t)continue;if(n.has(t.endnoteId))continue;const e=a[t.endnoteId];e&&(n.set(t.endnoteId,{endnoteId:t.endnoteId,docxId:r,endnote:e}),r+=1)}return Array.from(n.values())}function Uz(t){if(0===t.length)return[Gz()];const[e,...a]=t;return"paragraph"!==e.type?[Gz(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:endnoteRef",text:"",kind:"text",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"EndnoteText"}}),...a];var n,r}function Gz(t=!0){return{id:"synthetic:endnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:endnoteRef",text:"",kind:"text",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0}]:[],{id:"synthetic:endnote-body-empty-text",text:"",kind:"text"}],style:{styleId:"EndnoteText"}}}const Dz=["wholeTable","band1Horz","band2Horz","band1Vert","band2Vert","firstCol","lastCol","firstRow","lastRow","nwCell","neCell","swCell","seCell"];function jz(t){const e={...t.borders?{...t.borders.borderTop?{borderTop:t.borders.borderTop}:{},...t.borders.borderLeft?{borderLeft:t.borders.borderLeft}:{},...t.borders.borderBottom?{borderBottom:t.borders.borderBottom}:{},...t.borders.borderRight?{borderRight:t.borders.borderRight}:{}}:{},...t.shading?{shading:t.shading}:{},...t.cellStyle};return Object.keys(e).length>0?ez({id:"table-style-cell",blocks:[],style:e}):""}function Zz(t,e){if("number"==typeof e)return`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`;if("string"==typeof e&&e.endsWith("%")){const a=Number.parseFloat(e);return Number.isFinite(a)?`<w:${t} w:w="${Math.round(50*a)}" w:type="pct"/>`:""}return"auto"===e?`<w:${t} w:w="0" w:type="auto"/>`:""}function Kz(t){if(!t)return"";const e=[];void 0!==t.rowBandSize&&e.push(`<w:tblStyleRowBandSize w:val="${t.rowBandSize}"/>`),void 0!==t.colBandSize&&e.push(`<w:tblStyleColBandSize w:val="${t.colBandSize}"/>`);const a=Zz("tblW",t.width);a&&e.push(a);const n=Zz("tblInd",t.indentLeft);n&&e.push(n);const r=Zz("tblCellSpacing",t.cellSpacing);if(r&&e.push(r),t.align&&e.push(`<w:jc w:val="${t.align}"/>`),t.layout&&e.push(`<w:tblLayout w:type="${t.layout}"/>`),void 0!==t.bidiVisual&&e.push(`<w:bidiVisual w:val="${t.bidiVisual?"1":"0"}"/>`),t.defaultCellMargins){const a=Object.entries(t.defaultCellMargins).map(([t,e])=>`<w:${t} w:w="${WL(e)??0}" w:type="dxa"/>`).join("");a&&e.push(`<w:tblCellMar>${a}</w:tblCellMar>`)}if(t.borders){const{borders:a}=t,n=my.filter(([,t])=>!!a[t]).map(([t,e])=>`<w:${t} ${DL(a[e])}`).join("");n&&e.push(`<w:tblBorders>${n}</w:tblBorders>`)}return e.length>0?`<w:tblPr>${e.join("")}</w:tblPr>`:""}function Xz(t,e){const a=[],n=e.paragraphStyle?cz(e.paragraphStyle):"";n&&a.push(n);const r=e.textStyle?xz(e.textStyle):"";r&&a.push(r);const o=Kz(e.tableStyle);o&&a.push(o);const i=e.rowStyle?rz(e.rowStyle):"";i&&a.push(i);const l=jz(e);return l&&a.push(l),0===a.length?"":`<w:tblStylePr w:type="${OL(t)}">${a.join("")}</w:tblStylePr>`}function Yz(t){const e=[];if(e.push(`<w:name w:val="${OL(t.name)}"/>`),t.basedOn&&e.push(`<w:basedOn w:val="${OL(t.basedOn)}"/>`),t.nextStyle&&e.push(`<w:next w:val="${OL(t.nextStyle)}"/>`),void 0!==t.uiPriority&&e.push(`<w:uiPriority w:val="${Math.max(0,Math.floor(t.uiPriority))}"/>`),void 0!==t.qFormat&&e.push(`<w:qFormat w:val="${t.qFormat?"1":"0"}"/>`),void 0!==t.semiHidden&&e.push(`<w:semiHidden w:val="${t.semiHidden?"1":"0"}"/>`),void 0!==t.unhideWhenUsed&&e.push(`<w:unhideWhenUsed w:val="${t.unhideWhenUsed?"1":"0"}"/>`),("paragraph"===t.type||"table"===t.type)&&t.paragraphStyle){const a=cz(t.paragraphStyle);a&&e.push(a)}if(t.textStyle){const a=xz(t.textStyle);a&&e.push(a)}if("table"===t.type&&t.tableStyle){const a=t.tableStyle,n=Kz(a);if(n&&e.push(n),a.conditionalFormats){const t=[...Dz.filter(t=>t in a.conditionalFormats),...Object.keys(a.conditionalFormats).filter(t=>!Dz.includes(t))];for(const n of t){const t=a.conditionalFormats[n];if(t){const a=Xz(n,t);a&&e.push(a)}}}}return`<w:style w:type="${"character"===t.type?"character":"table"===t.type?"table":"paragraph"}" w:styleId="${OL(t.id)}"${t.isDefault?' w:default="1"':""}>${e.join("")}</w:style>`}function Jz(t,e,a,n,r,o,i,l,s){const d=n.map(t=>{const e="header"===t.kind?"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";return`<Override PartName="/word/${t.path}" ContentType="${e}"/>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${function(t){const e=new Set;let a="";for(const n of t){const t=n.toLowerCase();if(e.has(t))continue;const r=By[t];r&&(e.add(t),a+=`<Default Extension="${t}" ContentType="${r}"/>`)}return a}(e)}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${i?'<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>':""}${t?'<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>':""}${a?'<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>':""}${r?'<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>':""}${o?'<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>':""}${l?'<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>':""}${s?'<Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>':""}${d}</Types>`}const Qz={decimal:"decimal",lowerRoman:"lowerRoman",upperRoman:"upperRoman",lowerLetter:"lowerLetter",upperLetter:"upperLetter",symbol:"symbol"},_z={continuous:"continuous",eachSection:"eachSect"};function $z(t,e){if(!e)return null;const a=[];return e.numberFormat&&a.push(`<w:numFmt w:val="${Qz[e.numberFormat]}"/>`),void 0!==e.startAt&&a.push(`<w:numStart w:val="${Math.max(1,e.startAt)}"/>`),e.restart&&a.push(`<w:numRestart w:val="${_z[e.restart]}"/>`),a.length>0?`<w:${t}>${a.join("")}</w:${t}>`:null}function tN(t,e){let a="";for(const n of e)a+=`<Relationship Id="${n.rId}" Type="${zL}/hyperlink" Target="${OL(n.href)}" TargetMode="External"/>`;for(const n of t){const t="linked"===n.kind?' TargetMode="External"':"";a+=`<Relationship Id="${n.rId}" Type="${zL}/image" Target="${OL(n.target)}"${t}/>`}return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}">${a}</Relationships>`}function eN(t,e){e(t);for(const a of t.runs)"textBox"===a.kind&&aN(a.textBox.blocks,e)}function aN(t,e){for(const a of t)switch(a.type){case"paragraph":eN(a,e);break;case"table":for(const t of a.rows)for(const a of t.cells)for(const t of a.blocks)eN(t,e);break;default:ve(a,"block")}}const nN=`xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${zL}"`;function rN(t,e,a){const n=ha(t).map((n,r)=>Pz(n.blocks,e,t.styles)+function(t,e){var a,n,r,o,i,l,s,d,c;const h=qL(t.width,12240),p=qL(t.height,15840),u=t.margins,f="landscape"===t.orientation?' w:orient="landscape"':"",g=[(null==(a=null==e?void 0:e.header)?void 0:a.first)?`<w:headerReference w:type="first" r:id="${e.header.first.relId}"/>`:"",(null==(n=null==e?void 0:e.header)?void 0:n.even)?`<w:headerReference w:type="even" r:id="${e.header.even.relId}"/>`:"",(null==(r=null==e?void 0:e.header)?void 0:r.default)?`<w:headerReference w:type="default" r:id="${e.header.default.relId}"/>`:"",(null==(o=null==e?void 0:e.footer)?void 0:o.first)?`<w:footerReference w:type="first" r:id="${e.footer.first.relId}"/>`:"",(null==(i=null==e?void 0:e.footer)?void 0:i.even)?`<w:footerReference w:type="even" r:id="${e.footer.even.relId}"/>`:"",(null==(l=null==e?void 0:e.footer)?void 0:l.default)?`<w:footerReference w:type="default" r:id="${e.footer.default.relId}"/>`:""].join(""),m=(null==(s=null==e?void 0:e.header)?void 0:s.first)||(null==(d=null==e?void 0:e.footer)?void 0:d.first)?"<w:titlePg/>":"",v=t.columns;let b="";if(v&&v.count>1){const t=qL(v.space,0),e=v.separator?' w:sep="1"':"";if(!1===v.equalWidth&&(null==(c=v.columns)?void 0:c.length)){const a=v.columns.map(t=>`<w:col w:w="${qL(t.width,0)}" w:space="${qL(t.space,0)}"/>`).join("");b=`<w:cols w:num="${v.count}" w:space="${t}" w:equalWidth="0"${e}>${a}</w:cols>`}else b=`<w:cols w:num="${v.count}" w:space="${t}"${e}/>`}return`<w:sectPr>${g}${m}<w:pgSz w:w="${h}" w:h="${p}"${f}/><w:pgMar w:top="${qL(u.top,1440)}" w:right="${qL(u.right,1440)}" w:bottom="${qL(u.bottom,1440)}" w:left="${qL(u.left,1440)}" w:header="${qL(u.header,720)}" w:footer="${qL(u.footer,720)}" w:gutter="${qL(u.gutter,0)}"/>${b}</w:sectPr>`}(n.pageSettings,a[r])).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document ${nN}><w:body>${n}</w:body></w:document>`}function oN(t,e,a,n){const r="header"===t?"hdr":"ftr";return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${r} ${nN}>${Pz(e,a,n)}</w:${r}>`}function iN(t){return{id:Xa("").id,text:"",kind:"fieldChar",fieldChar:{kind:t}}}function lN(t,e,a){const n=Qa([{text:`${e} `},{text:String(a)},{text:t?`: ${t}`:""}]);var r;return n.style={styleId:"Caption",align:"center"},n.runs=[n.runs[0],iN("begin"),(r=" SEQ Figure \\* ARABIC ",{id:Xa("").id,text:"",kind:"fieldInstruction",fieldInstruction:r}),iN("separate"),n.runs[1],iN("end"),n.runs[2]],n}function sN(t){var e,a;if(!t)return!1;return"caption"===(null==(a=null==(e=t.style)?void 0:e.styleId)?void 0:a.toLowerCase())&&t.runs.some(t=>{const e=Se(t);return void 0!==e&&new RegExp("\\bSEQ\\s+Figure\\b","i").test(e)})}function dN(t,e){if(!sN(t))return MA(t);let a=!1,n=!1;const r=t.runs.map(t=>"fieldChar"===t.kind&&"separate"===t.fieldChar.kind?(a=!0,{...t,fieldChar:{...t.fieldChar}}):"fieldChar"===t.kind&&"end"===t.fieldChar.kind?(a=!1,{...t,fieldChar:{...t.fieldChar}}):a&&""!==t.text?t.text===String(e)?{...t}:(n=!0,{...t,text:String(e)}):{...t});return n?{...MA(t),runs:r}:MA(t)}function cN(t,e){return t.map(t=>{switch(t.type){case"paragraph":return sN(t)?dN(t,e.next++):MA(t);case"table":return{...t,rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:cN(t.blocks,e)}))}))};default:return ve(t,"block")}})}function hN(t){const e={next:1},a=ha(t).map(t=>({...t,blocks:cN(t.blocks,e),header:t.header?SA(t.header):void 0,footer:t.footer?SA(t.footer):void 0}));return{...t,sections:a}}function pN(t,e,a,n){const r=[],o=new Map,i=new Map,l=[],s=new Map;return aN(t,t=>{var e;for(const d of t.runs){const t=null==(e=d.styles)?void 0:e.link;if(t&&!t.startsWith("#")&&!s.has(t)){const e=`rIdLink${l.length+1}`;s.set(t,e),l.push({rId:e,href:t})}if("textBox"!==d.kind||i.has(d.id)||(i.set(d.id,a.nextTextBoxDocPrId),a.nextTextBoxDocPrId+=1),"image"!==d.kind)continue;const c=a.nextImageId,h=`rIdImg${c}`,p={rId:h,runId:d.id,cx:Math.round(d.image.width*Le),cy:Math.round(d.image.height*Le),alt:d.image.alt,crop:d.image.crop,fillMode:d.image.fillMode,rotation:d.image.rotation,flipH:d.image.flipH,flipV:d.image.flipV,floating:d.image.floating,wrapPolygon:d.image.wrapPolygon};if(d.image.linkedSrc){r.push({...p,kind:"linked",target:d.image.linkedSrc}),o.set(d.id,h),a.nextImageId+=1;continue}const u=da(n,d.image.src).match(/^data:([^;,]+);base64,(.*)$/);if(!u)continue;const f=Hy(u[1]);if(!f)continue;const g=u[2],m=`media/image${c}.${f}`;r.push({...p,kind:"embedded",target:m,base64:g}),o.set(d.id,h),a.nextImageId+=1}}),{numberingInfo:e.numberingInfo,definitions:e.definitions,images:r,imageMap:o,textBoxDocPrIds:i,hyperlinks:l,hyperlinkMap:s}}function uN(t,e,a){a&&(t.file(`word/${e}.xml`,a.xml),(a.partContext.images.length>0||a.partContext.hyperlinks.length>0)&&t.file(`word/_rels/${e}.xml.rels`,tN(a.partContext.images,a.partContext.hyperlinks)))}async function fN(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v;t=hN(t);const b=new bf,y=function(t){const e=new Map,a=new Map,n=[];let r=1,o=1;const i=t=>{if(!t.list)return;const i=Math.max(0,t.list.level??0),l=t.list.bulletGlyph??"",s=t.list.instanceId?`instance:${t.list.instanceId}`:`legacy:${t.list.kind}:${i}:${l}`;let d=a.get(s);d||(d={abstractNumId:r++,numId:o++,levels:[]},a.set(s,d),n.push(d)),d.levels.some(t=>t.level===i)||d.levels.push({kind:t.list.kind,level:i,format:t.list.format,startAt:t.list.startAt,levelText:t.list.levelText,suffix:t.list.suffix,alignment:t.list.alignment,legal:t.list.legal,bulletGlyph:t.list.bulletGlyph,bulletFont:t.list.bulletFont}),e.set(t.id,{numId:d.numId,level:i})};for(const l of ha(t))aN(l.blocks,i),l.header&&aN(l.header,i),l.firstPageHeader&&aN(l.firstPageHeader,i),l.evenPageHeader&&aN(l.evenPageHeader,i),l.footer&&aN(l.footer,i),l.firstPageFooter&&aN(l.firstPageFooter,i),l.evenPageFooter&&aN(l.evenPageFooter,i);return{numberingInfo:e,definitions:n}}(t),M={nextImageId:1,nextTextBoxDocPrId:1000001},x=ha(t),w=function(t){var e;const a=null==(e=t.footnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of Fc(t)){const t=Ae(o);if(!t)continue;if(n.has(t.footnoteId))continue;const e=a[t.footnoteId];e&&(n.set(t.footnoteId,{footnoteId:t.footnoteId,docxId:r,footnote:e}),r+=1)}return Array.from(n.values())}(t),S=function(t){const e=new Map;for(const a of t)e.set(a.footnoteId,a.docxId);return e}(w),A=w.length>0,C=Hz(t),I=function(t){const e=new Map;for(const a of t)e.set(a.endnoteId,a.docxId);return e}(C),T=C.length>0,k=function(t){const e=t.bookmarks;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const l of e.order){const t=e.items[l];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(l,r),n.add(r))}let r=0;for(const l of e.order)if(!a.has(l)){for(;n.has(r);)r+=1;a.set(l,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])};for(const l of e.order){const t=e.items[l];if(!t)continue;const n=a.get(l);t.start&&i(t.start.paragraphId,{kind:"start",offset:t.start.offset,seq:t.start.seq??0,wId:n,name:t.name,...void 0!==t.colFirst?{colFirst:t.colFirst}:{},...void 0!==t.colLast?{colLast:t.colLast}:{}}),t.end&&i(t.end.paragraphId,{kind:"end",offset:t.end.offset,seq:t.end.seq??0,wId:n})}return o}(t),V=function(t){const e=t.comments;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const s of e.order){const t=e.items[s];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(s,r),n.add(r))}let r=0;for(const s of e.order)if(!a.has(s)){for(;n.has(r);)r+=1;a.set(s,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])},l=[];return e.order.forEach((t,n)=>{const r=e.items[t];if(!r)return;const o=a.get(t),s=(1073741824+n).toString(16).toUpperCase();l.push({comment:r,wId:o,paraId:s}),r.start&&i(r.start.paragraphId,{kind:"start",offset:r.start.offset,seq:r.start.seq??0,wId:o}),r.end&&(i(r.end.paragraphId,{kind:"end",offset:r.end.offset,seq:r.end.seq??0,wId:o}),i(r.end.paragraphId,{kind:"reference",offset:r.end.offset,seq:(r.end.seq??0)+.5,wId:o}))}),{eventsByParagraph:o,comments:l}}(t),R=t=>(t.footnoteIdMap=S,t.endnoteIdMap=I,t.bookmarkEventsByParagraph=k,t.commentEventsByParagraph=null==V?void 0:V.eventsByParagraph,t),E=R(pN(x.flatMap(t=>t.blocks),y,M,t)),L=void 0!==V,z=[],N=x.map(()=>({}));let O=1,q=1;x.forEach((e,a)=>{const n=(e,n,r)=>{var o;if(!r||0===r.length)return;const i="header"===e?O:q,l=`${e}${i}.xml`,s=`rId${"header"===e?"Header":"Footer"}${i}`,d=R(pN(r,y,M,t));z.push({kind:e,type:n,path:l,relId:s,blocks:r,context:d});const c="header"===e?"header":"footer";((o=N[a])[c]??(o[c]={}))[n]={relId:s},"header"===e?O+=1:q+=1};n("header","first",e.firstPageHeader),n("header","even",e.evenPageHeader),n("header","default",e.header),n("footer","first",e.firstPageFooter),n("footer","even",e.evenPageFooter),n("footer","default",e.footer)});const P=y.definitions.length>0,W=x.some(t=>{var e,a;return((null==(e=t.evenPageHeader)?void 0:e.length)??0)>0||((null==(a=t.evenPageFooter)?void 0:a.length)??0)>0}),B=W||void 0!==(null==(e=t.settings)?void 0:e.defaultTabStop)||void 0!==(null==(a=t.settings)?void 0:a.allowSpaceOfSameStyleInTable)||void 0!==(null==(n=t.settings)?void 0:n.autoHyphenation)||void 0!==(null==(r=t.settings)?void 0:r.consecutiveHyphenLimit)||void 0!==(null==(o=t.settings)?void 0:o.hyphenationZone)||void 0!==(null==(i=t.settings)?void 0:i.doNotHyphenateCaps)||void 0!==(null==(l=t.footnotes)?void 0:l.settings)||void 0!==(null==(s=t.endnotes)?void 0:s.settings),F=[...E.images,...z.flatMap(t=>t.context.images)],H=A?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>Bz(t.footnote.blocks)));l.footnoteIdMap=i;const s=e.map(t=>{const e=Bz(t.footnote.blocks).map(t=>"paragraph"===t.type?Wz(t,l,o):sz(t,(t,e)=>{var a;return Wz(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:footnote w:id="${t.docxId}">${e}</w:footnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:footnotes xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${zL}"><w:footnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:footnote>${s}</w:footnotes>`,partContext:l}}(0,w,0,0,e=>pN(e,y,M,t),t.styles,S):null;H&&F.push(...H.partContext.images);const U=T?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>Uz(t.endnote.blocks)));l.endnoteIdMap=i;const s=e.map(t=>{const e=Uz(t.endnote.blocks).map(t=>"paragraph"===t.type?Wz(t,l,o):sz(t,(t,e)=>{var a;return Wz(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:endnote w:id="${t.docxId}">${e}</w:endnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:endnotes xmlns:w="${EL}" xmlns:w14="${NL}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${zL}"><w:endnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:endnote><w:endnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:endnote>${s}</w:endnotes>`,partContext:l}}(0,C,0,0,e=>pN(e,y,M,t),t.styles,I):null;U&&F.push(...U.partContext.images);const G=F.filter(t=>"embedded"===t.kind).map(t=>{var e;return null==(e=t.target.split(".").pop())?void 0:e.toLowerCase()}).filter(t=>Boolean(t)),D=null!=t.styles&&Object.keys(t.styles).length>0,j=((null==(d=t.fontTable)?void 0:d.length)??0)>0;b.file("[Content_Types].xml",Jz(P,G,B,z,A,T,D,L,j)),b.file("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}"><Relationship Id="rId1" Type="${zL}/officeDocument" Target="word/document.xml"/></Relationships>`),b.file("word/document.xml",rN(t,E,N)),D&&b.file("word/styles.xml",function(t){const e=Object.values(t).map(Yz).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="${NL}">${e}</w:styles>`}(t.styles)),P&&b.file("word/numbering.xml",function(t){const e=t.map(({abstractNumId:t,levels:e})=>`<w:abstractNum w:abstractNumId="${t}">${e.sort((t,e)=>t.level-e.level).map(({kind:t,level:e,format:a,startAt:n,levelText:r,suffix:o,alignment:i,legal:l,bulletGlyph:s,bulletFont:d})=>{const c="bullet"===t?"bullet":a??"decimal",h=r??("bullet"===t?s??"":`%${e+1}.`),p=n??1,u="bullet"===t?d??"Symbol":void 0,f=u?`<w:rPr><w:rFonts w:ascii="${OL(u)}" w:hAnsi="${OL(u)}" w:hint="default"/></w:rPr>`:"",g=o&&"tab"!==o?`<w:suff w:val="${o}"/>`:"",m=l?"<w:isLgl/>":"";return`<w:lvl w:ilvl="${e}"><w:start w:val="${p}"/><w:numFmt w:val="${c}"/><w:lvlText w:val="${OL(h)}"/><w:lvlJc w:val="${i??"left"}"/>${g}${m}${f}</w:lvl>`}).join("")}</w:abstractNum>`).join(""),a=t.map(({abstractNumId:t,numId:e})=>`<w:num w:numId="${e}"><w:abstractNumId w:val="${t}"/></w:num>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${EL}">${e}${a}</w:numbering>`}(y.definitions)),(D||P||B||E.images.length>0||E.hyperlinks.length>0||z.length>0||A||T||L||j)&&b.file("word/_rels/document.xml.rels",function(t,e,a,n,r,o,i,l,s,d){let c="";l&&(c+=`<Relationship Id="rIdStyles" Type="${zL}/styles" Target="styles.xml"/>`),t&&(c+=`<Relationship Id="rIdNum" Type="${zL}/numbering" Target="numbering.xml"/>`),e&&(c+=`<Relationship Id="rIdSettings" Type="${zL}/settings" Target="settings.xml"/>`);for(const h of n)c+=`<Relationship Id="${h.rId}" Type="${zL}/hyperlink" Target="${OL(h.href)}" TargetMode="External"/>`;for(const h of a){const t="linked"===h.kind?' TargetMode="External"':"";c+=`<Relationship Id="${h.rId}" Type="${zL}/image" Target="${OL(h.target)}"${t}/>`}for(const h of r){const t="header"===h.kind?"header":"footer";c+=`<Relationship Id="${h.relId}" Type="${zL}/${t}" Target="${h.path}"/>`}return o&&(c+=`<Relationship Id="rIdFootnotes" Type="${zL}/footnotes" Target="footnotes.xml"/>`),i&&(c+=`<Relationship Id="rIdEndnotes" Type="${zL}/endnotes" Target="endnotes.xml"/>`),s&&(c+=`<Relationship Id="rIdComments" Type="${zL}/comments" Target="comments.xml"/>`,c+='<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>'),d&&(c+=`<Relationship Id="rIdFontTable" Type="${zL}/fontTable" Target="fontTable.xml"/>`),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${LL}">${c}</Relationships>`}(P,B,E.images,E.hyperlinks,z,A,T,D,L,j)),j&&b.file("word/fontTable.xml",function(t){const e=t.map(t=>{const e=[];if(t.altName&&e.push(`<w:altName w:val="${OL(t.altName)}"/>`),t.panose1&&e.push(`<w:panose1 w:val="${OL(t.panose1)}"/>`),t.charset&&e.push(`<w:charset w:val="${OL(t.charset)}"/>`),t.family&&e.push(`<w:family w:val="${OL(t.family)}"/>`),t.pitch&&e.push(`<w:pitch w:val="${OL(t.pitch)}"/>`),t.sig){const a=Object.entries(t.sig).map(([t,e])=>`w:${t}="${OL(e)}"`).join(" ");a&&e.push(`<w:sig ${a}/>`)}return`<w:font w:name="${OL(t.name)}">${e.join("")}</w:font>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:fonts xmlns:w="${EL}">${e}</w:fonts>`}(t.fontTable)),B&&b.file("word/settings.xml",function(t,e,a,n,r,o){const i=[],l=WL(e);null!==l&&i.push(`<w:defaultTabStop w:val="${l}"/>`),(null==o?void 0:o.autoHyphenation)&&i.push("<w:autoHyphenation/>"),void 0!==(null==o?void 0:o.consecutiveHyphenLimit)&&o.consecutiveHyphenLimit>=0&&i.push(`<w:consecutiveHyphenLimit w:val="${o.consecutiveHyphenLimit}"/>`);const s=WL(null==o?void 0:o.hyphenationZone);null!==s&&i.push(`<w:hyphenationZone w:val="${s}"/>`),(null==o?void 0:o.doNotHyphenateCaps)&&i.push("<w:doNotHyphenateCaps/>");const d=$z("footnotePr",a);d&&i.push(d);const c=$z("endnotePr",n);return c&&i.push(c),t&&i.push("<w:evenAndOddHeaders/>"),r&&i.push("<w:compat><w:allowSpaceOfSameStyleInTable/></w:compat>"),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${EL}">${i.join("")}</w:settings>`}(W,null==(c=t.settings)?void 0:c.defaultTabStop,null==(h=t.footnotes)?void 0:h.settings,null==(p=t.endnotes)?void 0:p.settings,null==(u=t.settings)?void 0:u.allowSpaceOfSameStyleInTable,{autoHyphenation:null==(f=t.settings)?void 0:f.autoHyphenation,consecutiveHyphenLimit:null==(g=t.settings)?void 0:g.consecutiveHyphenLimit,hyphenationZone:null==(m=t.settings)?void 0:m.hyphenationZone,doNotHyphenateCaps:null==(v=t.settings)?void 0:v.doNotHyphenateCaps}));for(const Z of z)b.file(`word/${Z.path}`,oN(Z.kind,Z.blocks,Z.context,t.styles)),(Z.context.images.length>0||Z.context.hyperlinks.length>0)&&b.file(`word/_rels/${Z.path}.rels`,tN(Z.context.images,Z.context.hyperlinks));uN(b,"footnotes",H),uN(b,"endnotes",U),V&&(b.file("word/comments.xml",GL(V)),b.file("word/commentsExtended.xml",function(t){const e=t.comments.map(({comment:t,paraId:e})=>`<w15:commentEx w15:paraId="${e}" w15:done="${t.resolved?"1":"0"}"/>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w15:commentsEx ${UL}>${e}</w15:commentsEx>`}(V)));for(const Z of F)"embedded"===Z.kind&&Z.base64&&b.file(`word/${Z.target}`,Z.base64,{base64:!0});return b.generateAsync({type:"arraybuffer"})}function gN(t){switch(t){case"dashed":return[Zw(5),Zw(3)];case"dotted":return[Zw(1),Zw(3)];default:return}}async function mN(t,e,a,n,r,o,i,l){const s=e.rotation;s&&(t.saveGraphicsState(a.pageIndex),t.rotateAbout(a.pageIndex,Zw(n+o/2),Zw(r+i/2),s)),function(t,e,a,n,r,o,i){var l,s,d,c;const h=ip(null==(l=a.shape)?void 0:l.preset,Zw(n),Zw(r),Zw(o),Zw(i)),p=null==(s=a.shape)?void 0:s.fill,u=null==(d=a.shape)?void 0:d.borderColor,f=(null==(c=a.shape)?void 0:c.borderWidthPt)??(u?.75:0);t.drawPath(e,{segments:h,fill:p,stroke:u&&f>0?u:void 0,lineWidth:f})}(t,a.pageIndex,e,n,r,o,i),await async function(t,e,a,n,r,o,i,l){var s;if(0===e.blocks.length)return;const d=function(t){var e,a,n,r;return{left:(null==(e=t.body)?void 0:e.paddingLeft)??0,top:(null==(a=t.body)?void 0:a.paddingTop)??0,right:(null==(n=t.body)?void 0:n.paddingRight)??0,bottom:(null==(r=t.body)?void 0:r.paddingBottom)??0}}(e),c=n+d.left,h=r+d.top,p=Math.max(1,o-d.left-d.right),u=Math.max(1,i-d.top-d.bottom),f=(null==(s=Mc({blocks:e.blocks,pageSettings:{width:p,height:u,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:u,styles:a.document.styles,pageOffset:a.pageIndex})[0])?void 0:s.blocks)??[];if(0===f.length)return;const g=Va(a.document);t.saveGraphicsState(a.pageIndex),t.clipRect(a.pageIndex,Zw(c),Zw(h),Zw(p),Zw(u));let m=h;for(const v of f){switch(v.sourceBlock.type){case"paragraph":v.layout&&await l.drawParagraph(t,a.pageIndex,v.sourceBlock,v.layout.lines,a.document,c,m,a.fontRegistry,g,l);break;case"table":await l.drawTableBlock(t,a.pageIndex,v,a.document,c,m,p,a.fontRegistry,g,l);break;default:ve(v.sourceBlock,"block")}m+=Math.max(0,v.estimatedHeight)}t.restoreGraphicsState(a.pageIndex)}(t,e,a,n,r,o,i,l),s&&t.restoreGraphicsState(a.pageIndex)}async function vN(t){const{writer:e,document:a,fontRegistry:n,pageIndex:r,lines:o,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,drawers:h}=t;for(const p of o){const o=new Map(p.slots.map(t=>[t.offset,t]));for(const u of p.fragments){const f=u.textBox;if(!(null==f?void 0:f.floating))continue;const g=Boolean(f.floating.behindDoc);if(t.layer&&"behind"===t.layer!==g)continue;const m=o.get(u.startOffset),v=l+((null==m?void 0:m.left)??0),b=c+p.top,y=Cd({object:xd(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,lineTop:b,anchorLeft:v});await mN(e,f,{document:a,fontRegistry:n,pageIndex:r},y.x,y.y,y.width,y.height,h)}}}const bN=new WeakMap;function yN(t){const e=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(t);if(!e)return null;const a=e[1].toLowerCase(),n=Boolean(e[2]),r=e[3]??"";if(!n)return{mediaType:a,data:(new TextEncoder).encode(decodeURIComponent(r))};const o="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:a,data:Uint8Array.from(o,t=>t.charCodeAt(0))}}async function MN(t,e,a){let n=t;n.startsWith("data:")||(n=await async function(t){if("function"!=typeof fetch)return null;const e=await fetch(t);if(!e.ok)return null;const a=await e.blob(),n=new Uint8Array(await a.arrayBuffer()),r=Array.from(n,t=>String.fromCharCode(t)).join(""),o="function"==typeof btoa?btoa(r):Buffer.from(n).toString("base64");return`data:${a.type||"application/octet-stream"};base64,${o}`}(n)??n);let r=yN(n);if(!r)return null;const o="undefined"!=typeof Image?await async function(t){return"undefined"==typeof Image?null:await new Promise(e=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>e(a),a.onerror=()=>e(null),a.src=t})}(n):null,i=null!=o&&o.naturalWidth>0&&o.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const t=function(t){if("undefined"==typeof document)return null;const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const a=e.getContext("2d");return a?(a.fillStyle="#ffffff",a.fillRect(0,0,e.width,e.height),a.drawImage(t,0,0),e.toDataURL("image/jpeg",.92)):null}(o);if(r=t?yN(t):null,!r)return null}const l=i?o.naturalWidth:e,s=i?o.naturalHeight:a;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function xN(t,e,a){const n=da(e,a.src);if(!n)return null;let r=bN.get(t);r||(r=new Map,bN.set(t,r));const o=r.get(n);if(o)return o;const i=MN(n,a.width,a.height).then(e=>e?t.registerImageResource({width:e.width,height:e.height,data:e.data,filter:"DCTDecode"}):null);return r.set(n,i),i}function wN(t,e){const a=new Map(t.slots.map(t=>[t.offset,t])),n=[];for(const r of e.chars){if("\n"===r.char||"\t"===r.char)continue;const t=a.get(r.paragraphOffset);t&&n.push({char:r.char,left:t.left,offset:r.paragraphOffset})}return n}function SN(t,e,a){const n=wN(t,e);if(0===n.length)return null;const r=new Map(t.slots.map(t=>[t.offset,t])),o=n[0],i=n[n.length-1],l=r.get(i.offset+1);return{left:o.left,right:(null==l?void 0:l.left)??i.left+.55*a}}function AN(t,e,a,n,r,o,i){const l=SN(t,e,a.fontSize??Pe);return l?{x:Zw(n+l.left),y:Zw(r+t.top+o),width:Zw(Math.max(0,l.right-l.left)),height:Zw(Math.max(2,t.height-i))}:null}function CN(t,e,a,n,r,o,i){const l=Gp(i),s=(r,i)=>{t.drawLine(e,{x1:Zw(a),y1:Zw(r),x2:Zw(n),y2:Zw(r),stroke:o,lineWidth:Zw(l),dashArray:i})};if(Fp(i))return s(r-Kp),void s(r+Kp);Hp(i)?function(t,e,a,n,r,o,i){let l=a,s=r;for(let d=a;d<=n;d+=1){const n=r+Math.sin((d-a)/4*Math.PI)*Up;t.drawLine(e,{x1:Zw(l),y1:Zw(s),x2:Zw(d),y2:Zw(n),stroke:o,lineWidth:Zw(i)}),l=d,s=n}}(t,e,a,n,r,o,l):s(r,jp(i))}function IN(t,e){const a=Ep(t);if(!a)return t;const n=Math.max(0,Math.min(1,e));return function(t,e,a){const n=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${n(t)}${n(e)}${n(a)}`}(255+(a[0]-255)*n,255+(a[1]-255)*n,255+(a[2]-255)*n)}function TN(t,e,a){const{writer:n,pageIndex:r,baselineY:o,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:d,baseTextOptions:c}=t,h=Zw(1);if(d.emboss||d.imprint){const t=d.imprint?1:-1;n.drawText(r,{...c,x:Zw(e)+h*t,y:Zw(o)+h*t,text:a,color:"#BFBFBF"})}if(d.glow){const t=d.glow,i=.5*Zw(t.radiusPt*Ve),l=IN(t.color,.4*(t.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[d,h]of s)n.drawText(r,{...c,x:Zw(e)+d,y:Zw(o)+h,text:a,color:l})}if(d.textShadow){const t=d.textShadow,i=t.dirDeg*Math.PI/180,l=Zw(t.distPt*Ve);n.drawText(r,{...c,x:Zw(e)+Math.cos(i)*l,y:Zw(o)+Math.sin(i)*l,text:a,color:t.color})}else d.shadow&&n.drawText(r,{...c,x:Zw(e)+h,y:Zw(o)+h,text:a,color:"#808080"});if(d.reflection){const t=d.reflection,s=IN(l,.6*((t.startAlpha+t.endAlpha)/2));n.drawText(r,{...c,x:Zw(e),y:Zw(o)+Zw(t.distPt*Ve)+i,text:a,color:s})}const p=d.textOutline;n.drawText(r,{...c,x:Zw(e),y:Zw(o),text:a,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:d.outline?1:0}})}async function kN(t){for(const e of t.lines){const a=new Map(e.slots.map(t=>[t.offset,t]));for(const n of e.fragments){const r=n.image;if(!(null==r?void 0:r.floating))continue;const o=Boolean(r.floating.behindDoc);if("behind"===t.layer!==o)continue;const i=a.get(n.startOffset),l=Cd({object:wd(r),pageSettings:t.pageSettings,contentLeft:t.contentLeft,contentTop:t.contentTop,contentWidth:t.contentWidth,paragraphTop:t.paragraphTop,lineTop:t.paragraphTop+e.top,anchorLeft:t.contentLeft+((null==i?void 0:i.left)??0)}),s=await xN(t.writer,t.document,r);s&&t.writer.drawImage(t.pageIndex,{resourceName:s,x:Zw(l.x),y:Zw(l.y),width:Zw(l.width),height:Zw(l.height),rotation:r.rotation})}}}function VN(t,e,a,n,r,o,i,l){const s=SN(a,n,i.fontSize??Pe);if(!s)return;const d=o+Xp(l,a.top,a.height),c=r+s.left,h=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(t.drawLine(e,{x1:Zw(c),y1:Zw(d-Zp),x2:Zw(h),y2:Zw(d-Zp),stroke:p,lineWidth:Zw(1)}),void t.drawLine(e,{x1:Zw(c),y1:Zw(d+Zp),x2:Zw(h),y2:Zw(d+Zp),stroke:p,lineWidth:Zw(1)})):void CN(t,e,c,h,d,p,i.underlineStyle);t.drawLine(e,{x1:Zw(c),y1:Zw(d),x2:Zw(h),y2:Zw(d),stroke:p,lineWidth:Zw(1)})}async function RN(t,e,a,n,r,o,i,l,s,d){var c,h,p;if(r.image){if(r.image.floating)return;const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;const s=await xN(t,o,r.image);if(!s)return;return void t.drawImage(e,{resourceName:s,x:Zw(i+a.left),y:Zw(l+n.top+n.height-r.image.height),width:Zw(r.image.width),height:Zw(r.image.height),rotation:r.image.rotation})}if(r.textBox){if(r.textBox.floating)return;const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;return void(await mN(t,r.textBox,{document:o,fontRegistry:s,pageIndex:e},i+a.left,l+n.top+n.height-r.textBox.height,r.textBox.width,r.textBox.height,d))}const u=la(r.styles,null==(c=a.style)?void 0:c.styleId,o.styles);if(u.hidden)return;const f=s.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=u.smallCaps?.8*Kw(u):Kw(u),m=(u.baselineShift??0)*Ve,v=l+n.top+n.height*rd-m,b=wN(n,r),y=b.map(t=>u.allCaps?t.char.toUpperCase():t.char).join("");if(!b[0]||0===y.length)return;!function(t,e,a,n,r,o,i){if(!i.link)return;const l=SN(a,n,i.fontSize??Pe);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");t.addLinkAnnotation(e,{x:Zw(r+l.left),y:Zw(o+a.top),width:Zw(l.right-l.left),height:Zw(a.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){if(!i.shading)return;const l=AN(a,n,i,r,o,2,4);l&&t.drawRect(e,{...l,fill:i.shading})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){if(!i.highlight)return;const l=AN(a,n,i,r,o,2,4);l&&t.drawRect(e,{...l,fill:i.highlight})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=AN(a,n,i,r,o,1,2);s&&t.drawRect(e,{...s,stroke:l.color,lineWidth:Zw(Math.max(.5,l.width*Ve))})}(t,e,n,r,i,l,u),function(t,e,a,n,r,o,i,l,s){var d;const c=new Map(n.slots.map(t=>[t.offset,t])),h=sa(a.style,o.styles).tabs??[];for(const p of r.chars){if("\t"!==p.char)continue;const a=c.get(p.paragraphOffset),r=c.get(p.paragraphOffset+1);if(!a||!r)continue;const o=(null==(d=n.slots[0])?void 0:d.left)??0,u=a.left-o,f=h.filter(t=>"clear"!==t.type).map(t=>({...t,positionPx:t.position*Ve})).filter(t=>t.positionPx>u+.01).sort((t,e)=>t.positionPx-e.positionPx)[0],g=(null==f?void 0:f.leader)&&"none"!==f.leader?f.leader:void 0;if(!g)continue;const m="underscore"===g?l+2:l;t.drawLine(e,{x1:Zw(i+a.left),y1:Zw(m),x2:Zw(i+r.left),y2:Zw(m),stroke:s,lineWidth:Zw("heavy"===g?1.5:1),dashArray:"dot"===g||"middleDot"===g?[1,3]:"hyphen"===g?[5,3]:void 0})}}(t,e,a,n,r,o,i,v,u.color??"#000000");const M=sa(a.style,o.styles).align??"left",x=function(t,e){const a=new Set;switch(t.ligatures){case"standard":a.add("liga");break;case"contextual":a.add("calt");break;case"historical":a.add("hlig");break;case"standardContextual":a.add("liga"),a.add("calt")}return"lining"===t.numberForm&&a.add("lnum"),"oldStyle"===t.numberForm&&a.add("onum"),"proportional"===t.numberSpacing&&a.add("pnum"),"tabular"===t.numberSpacing&&a.add("tnum"),"number"==typeof t.stylisticSet&&t.stylisticSet>=1&&t.stylisticSet<=20&&a.add(`ss${String(t.stylisticSet).padStart(2,"0")}`),t.contextualAlternates&&a.add("calt"),"number"==typeof e&&"number"==typeof t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e>=t.kerningThreshold&&a.add("kern"),Array.from(a).sort()}(u,Kw(u)),w={fontSize:g,bold:u.bold,italic:u.italic,fontResourceName:f.writerResourceName,characterSpacing:u.characterSpacing??0,horizontalScale:u.characterScale??100,fontFeatures:x},S="solid"===(null==(h=u.textFill)?void 0:h.type)?u.textFill.color:"gradient"===(null==(p=u.textFill)?void 0:p.type)&&u.textFill.stops[0]?u.textFill.stops[0].color:u.color??"#000000",A=function(t,e,a,n,r,o,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=SN(a,n,i.fontSize??Pe);if(!s)return;const d=r+s.left,c=r+s.right,h=zp(d,o+a.top,c,o+a.top+a.height,l.angle??0);return t.registerAxialGradient(e,{x0:Zw(h.x0),y0:Zw(h.y0),x1:Zw(h.x1),y1:Zw(h.y1),stops:l.stops.map(t=>({offset:t.position,color:t.color}))})??void 0}(t,e,n,r,i,l,u);!function(t,e,a,n,r,o,i){const l="justify"===i?function(t){const e=[];let a=[];for(const n of t)" "!==n.char?a.push(n):a.length>0&&(e.push(a),a=[]);return a.length>0&&e.push(a),e}(e):function(t){const e=[];let a=[];for(const n of t){const t=a[a.length-1];t&&n.offset>t.offset+1&&(e.push(a),a=[]),a.push(n)}return a.length>0&&e.push(a),e}(e);for(const s of l){const e=s.map(t=>n.allCaps?t.char.toUpperCase():t.char).join("");0!==e.length&&TN(t,a+s[0].left,e)}if(r.trailingHyphen&&o.endOffset>=r.endOffset){const e=r.slots.find(t=>t.offset===r.endOffset)??r.slots[r.slots.length-1];e&&TN(t,a+e.left,"-")}}({writer:t,pageIndex:e,baselineY:v,fontSizePt:g,mainColor:S,gradientShadingName:A,styles:u,baseTextOptions:w},b,i,u,n,r,M),u.underline&&VN(t,e,n,r,i,l,u,"underline"),u.strike&&VN(t,e,n,r,i,l,u,"strike"),u.doubleStrike&&VN(t,e,n,r,i,l,u,"doubleStrike"),u.emphasisMark&&function(t,e,a,n,r,o,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=Dp[l];if(!s)return;const d=wN(a,n),c="underDot"===l,h=Math.max(4,.35*a.height),p=c?o+a.top+a.height+h:o+a.top+h;for(let u=0;u<d.length;u+=1){const n=d[u];if(" "===n.char||"\t"===n.char||"\n"===n.char)continue;const o=d[u+1],l=o?(n.left+o.left)/2:n.left+.25*a.height;t.drawText(e,{x:Zw(r+l-.25*h),y:Zw(p),text:s,fontSize:Zw(h),color:i.color??"#000000"})}}(t,e,n,r,i,l,u)}function EN(t,e,a,n,r,o,i,l,s){var d;if(0!==n.index)return;const c=Ra(a,s);if(!c)return;const h=n.slots[0];if(!h)return;const p=la(void 0,null==(d=a.style)?void 0:d.styleId,r.styles),u=l.resolveFontFace({fontFamily:p.fontFamily,bold:p.bold,italic:p.italic}),f=is(a,r.styles),g=Kw(p),m=c.length*g*.62*Ve,v=ls(a,r.styles,h.left,m);t.drawText(e,{x:Zw(o+Math.max(0,v||f)),y:Zw(i+n.top+n.height*rd),text:c,fontSize:g,color:p.color??"#000000",bold:p.bold,italic:p.italic,fontResourceName:u.writerResourceName})}function LN(t,e,a,n,r,o,i){const l=[[a.borderTop,"top"],[a.borderRight,"right"],[a.borderBottom,"bottom"],[a.borderLeft,"left"]],s=l.some(([t])=>t&&"none"!==t.type&&t.width>0);if(!a.shading&&!s)return;let d=0;for(const g of n)d=Math.max(d,g.top+g.height);if(d<=0)return;const c=nd(a),h=c.top+d+c.bottom,p=r+(a.indentLeft??0),u=r+i-(a.indentRight??0),f=o+h;a.shading&&t.drawRect(e,{x:Zw(p),y:Zw(o),width:Zw(Math.max(0,u-p)),height:Zw(h),fill:a.shading});for(const[g,m]of l){if(!g||"none"===g.type||g.width<=0)continue;const[a,n,r,i]="top"===m?[p,o,u,o]:"bottom"===m?[p,f,u,f]:"left"===m?[p,o,p,f]:[u,o,u,f];t.drawLine(e,{x1:Zw(a),y1:Zw(n),x2:Zw(r),y2:Zw(i),stroke:g.color,lineWidth:g.width,dashArray:gN(g.type)})}}async function zN(t,e,a,n,r,o,i,l,s,d){for(const c of n){EN(t,e,a,c,r,o,i,l,s);for(const n of c.fragments)await RN(t,e,a,c,n,r,o,i,l,d)}}function NN(t,e,a,n,r,o,i){"none"===a.type||a.width<=0||t.drawLine(e,{x1:Zw(n),y1:Zw(r),x2:Zw(o),y2:Zw(i),stroke:a.color,lineWidth:Zw(a.width),dashArray:gN(a.type)})}function ON(t,e,a,n,r){const o=n+a.left,i=r+a.top,l=o+a.width,s=i+a.height;NN(t,e,a.borders.top,o,i,l,i),NN(t,e,a.borders.right,l,i,l,s),NN(t,e,a.borders.bottom,o,s,l,s),NN(t,e,a.borders.left,o,i,o,s),a.borders.topLeftToBottomRight&&NN(t,e,a.borders.topLeftToBottomRight,o,i,l,s),a.borders.topRightToBottomLeft&&NN(t,e,a.borders.topRightToBottomLeft,l,i,o,s)}async function qN(t,e,a,n,r,o,i,l,s,d){if("table"!==a.sourceBlock.type)return;const c=a.sourceBlock,h=a.tableSegment?To(c,a.tableSegment):c;if(0===h.rows.length)return;const p=Lh({table:h,state:{document:n},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:a.estimatedHeight});for(const u of p.cells)u.shading&&t.drawRect(e,{x:Zw(r+u.left),y:Zw(o+u.top),width:Zw(u.width),height:Zw(u.height),fill:u.shading});for(const u of p.cells)if(ON(t,e,u,r,o),u.revision){const a="insert"===u.revision.type?"#059669":"delete"===u.revision.type?"#dc2626":"#d97706";t.drawRect(e,{x:Zw(r+u.left+1),y:Zw(o+u.top+1),width:Zw(Math.max(0,u.width-2)),height:Zw(Math.max(0,u.height-2)),stroke:a,lineWidth:Zw(2)})}for(const u of p.cells)for(const a of u.paragraphs)await zN(t,e,a.paragraph,a.lines,n,r+a.originX,o+a.originY,l,s,d)}const PN={drawParagraph:zN,drawTableBlock:qN};async function WN(t,e,a,n,r,o,i,l,s,d,c){var h;if(!a||0===a.length)return;const p=o;let u=o;for(const f of a){switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const a=sa(f.sourceBlock.style,n.styles),h=u+(0===f.layout.startOffset&&u>o?a.spacingBefore??0:0);null==c||c(f.sourceBlock.id,h);const g=h+nd(a).top;LN(t,e,a,f.layout.lines,r,h,i),d&&(await kN({writer:t,pageIndex:e,lines:f.layout.lines,document:n,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:g,layer:"behind"}),await vN({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:f.layout.lines,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:h,drawers:PN,layer:"behind"})),await zN(t,e,f.sourceBlock,f.layout.lines,n,r,g,l,s,PN),d&&(await kN({writer:t,pageIndex:e,lines:f.layout.lines,document:n,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:g,layer:"front"}),await vN({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:f.layout.lines,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,paragraphTop:h,drawers:PN,layer:"front"}));break}case"table":if((null==(h=f.sourceBlock.style)?void 0:h.floating)&&d){const a=kh(f.sourceBlock,i),o=Md({floating:f.sourceBlock.style.floating,pageSettings:d,contentLeft:r,contentTop:p,contentWidth:i,anchorTop:u,width:a,height:f.floatingTableHeight??1,pageIndex:e});o.y+=f.floatingTableOffsetY??0,await qN(t,e,{...f,estimatedHeight:o.height},n,o.x,o.y,i,l,s,PN);break}await qN(t,e,f,n,r,u,i,l,s,PN);break;default:ve(f.sourceBlock,"block")}u+=Math.max(0,f.estimatedHeight)}}function BN(t,e,a,n){t.drawRect(e,{x:0,y:0,width:a,height:n,fill:"#ffffff"})}const FN=[{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 HN(t,e,a){return`${t.toLowerCase()}:${e?"bold":"regular"}${a?"italic":""}`}function UN(t){return t.replace(/[^A-Za-z0-9_]/g,"")}class GN{constructor(){a(this,"faces",new Map),a(this,"fallbackFamily","Helvetica");for(const t of FN)this.registerFontFace(t)}registerFontFace(t){this.faces.set(HN(t.family,t.bold,t.italic),t)}resolveFontFace(t){const e=ol(t.fontFamily),a=Boolean(t.bold),n=Boolean(t.italic);return this.faces.get(HN(e,a,n))??this.faces.get(HN(this.fallbackFamily,a,n))??this.faces.get(HN(this.fallbackFamily,!1,!1))}getPdfFontResources(){const t=new Map;for(const e of this.faces.values())t.set(e.pdfResource.resourceName,e.pdfResource);return Array.from(t.values())}async loadBundledUnicodeFaces(t={}){const e=t.families?new Set(Array.from(t.families).map(ol).map(t=>t.toLowerCase())):null,a=await this.registerOfficeCompatibleFaces(e);if(!e||e.has("roboto")||Array.from(e).some(t=>"helvetica"!==t&&!a.has(t)))for(const[n,r]of Object.entries(nl)){const t=await ul(r);if(!t)continue;const e="bold"===n||"bolditalic"===n,a="italic"===n||"bolditalic"===n,o=`Roboto${n[0].toUpperCase()}${n.slice(1)}`;this.registerFontFace({key:`roboto:${n}`,family:"Roboto",bold:e,italic:a,writerResourceName:o,pdfResource:{kind:"unicode",resourceName:o,family:"Roboto",fontData:t}}),this.fallbackFamily="Roboto"}}async registerOfficeCompatibleFaces(t){const e=new Set;for(const a of rl){const n=[a.family,...a.aliases].map(t=>t.toLowerCase());if(!(!t||n.some(e=>t.has(e))))continue;for(const t of n)e.add(t);const r=[];for(const[t,e]of Object.entries(a.files)){const n=await ul(e);if(!n)continue;const o="bold"===t||"bolditalic"===t,i="italic"===t||"bolditalic"===t,l=`${UN(a.family)}${t[0].toUpperCase()}${t.slice(1)}`,s={key:`${a.family.toLowerCase()}:${t}`,family:a.family,bold:o,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:a.family,fontData:n}};this.registerFontFace(s),r.push(s)}for(const t of a.aliases)for(const e of r)this.registerFontFace({...e,key:`${t.toLowerCase()}:${e.key.split(":")[1]}`,family:t})}return e}}const DN="%PDF-1.4\n% Oasis PDF\n",jN=[{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 ZN(t){return Number.isFinite(t)?Number(t.toFixed(3)).toString():"0"}function KN(t){return(new TextEncoder).encode(t).byteLength}function XN(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0").toUpperCase()).join("")}function YN(t){return Math.max(0,t).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function JN(t,e){if(!t)return e;const a=Ep(t);return a?[a[0]/255,a[1]/255,a[2]/255]:e}function QN(t,e,a){const[n,r,o]=JN(t,a);return`${ZN(n)} ${ZN(r)} ${ZN(o)} ${e}`}function _N(t,e){return(t&&t.trim().length>0?t:e).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}const $N=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 tO(t){return Array.from(t).map(t=>function(t){const e=t.codePointAt(0)??63;return e>=32&&e<=126||e>=160&&e<=255?e:$N.get(e)??63}(t).toString(16).padStart(2,"0").toUpperCase()).join("")}function eO(t){const e=[];for(let a of t)a>65535?(a-=65536,e.push(a>>>10&1023|55296),e.push(1023&a|56320)):e.push(a);return e.map(YN).join("")}function aO(t){return YN(t)}function nO(t){return`% OasisText ${eO(Array.from(t).map(t=>t.codePointAt(0)??65533))}`}class rO{constructor(t,e,a,n){this.page=t,this.fonts=e,this.images=a,this.shadings=n}registerAxialGradient(t){const e=this.shadings.register({x0:t.x0,y0:this.page.height-t.y0,x1:t.x1,y1:this.page.height-t.y1,stops:t.stops});return this.page.shadingResourceNames.add(e),e}drawRect(t){const e=this.page;if(t.width<=0||t.height<=0)return;const a=["q"];t.fill&&a.push(QN(t.fill,"rg",[1,1,1])),t.stroke&&(a.push(QN(t.stroke,"RG",[0,0,0])),a.push(`${ZN(t.lineWidth??1)} w`)),a.push([ZN(t.x),ZN(e.height-t.y-t.height),ZN(t.width),ZN(t.height),"re"].join(" ")),t.fill&&t.stroke?a.push("B"):t.fill?a.push("f"):t.stroke&&a.push("S"),a.push("Q"),e.commands.push(a.join("\n"))}drawLine(t){const e=this.page,a=t.dashArray&&t.dashArray.length>0?`[${t.dashArray.map(t=>ZN(t)).join(" ")}] 0 d`:null,n=["q",QN(t.stroke,"RG",[0,0,0])];a&&n.push(a),n.push(`${ZN(t.lineWidth??1)} w`,`${ZN(t.x1)} ${ZN(e.height-t.y1)} m`,`${ZN(t.x2)} ${ZN(e.height-t.y2)} l`,"S","Q"),e.commands.push(n.join("\n"))}drawPath(t){const e=this.page;if(0===t.segments.length)return;if(!t.fill&&!t.stroke)return;const a=t=>e.height-t,n=["q"];t.fill&&n.push(QN(t.fill,"rg",[1,1,1])),t.stroke&&(n.push(QN(t.stroke,"RG",[0,0,0])),n.push(`${ZN(t.lineWidth??1)} w`));for(const r of t.segments)switch(r.type){case"move":n.push(`${ZN(r.x)} ${ZN(a(r.y))} m`);break;case"line":n.push(`${ZN(r.x)} ${ZN(a(r.y))} l`);break;case"cubic":n.push(`${ZN(r.x1)} ${ZN(a(r.y1))} ${ZN(r.x2)} ${ZN(a(r.y2))} ${ZN(r.x)} ${ZN(a(r.y))} c`);break;case"close":n.push("h")}t.fill&&t.stroke?n.push("B"):t.fill?n.push("f"):n.push("S"),n.push("Q"),e.commands.push(n.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}rotateAbout(t,e,a){const n=this.page;if(!a)return;const r=n.height-e,o=-a*Math.PI/180,i=Math.cos(o),l=Math.sin(o),s=t-t*i+r*l,d=r-t*l-r*i;n.commands.push(`${ZN(i)} ${ZN(l)} ${ZN(-l)} ${ZN(i)} ${ZN(s)} ${ZN(d)} cm`)}clipRect(t,e,a,n){const r=this.page;a<=0||n<=0||r.commands.push(`${ZN(t)} ${ZN(r.height-e-n)} ${ZN(a)} ${ZN(n)} re`,"W","n")}drawText(t){if(0===t.text.length)return;const e=this.fonts.resolveAndMarkFontName(t),a=this.fonts.getUnicodeState(e),n=a?this.fonts.buildUnicodeShowCommand(a,t.text,t.fontFeatures):`<${tO(t.text)}> Tj`;null!==n&&(t.gradientShadingName?this.emitGradientTextBlock(e,n,t,t.gradientShadingName):this.emitTextBlock(e,n,t))}textSetupCommands(t,e){return[`/${t} ${ZN(e.fontSize??12)} Tf`,...e.horizontalScale&&e.horizontalScale>0&&100!==e.horizontalScale?[`${ZN(e.horizontalScale)} Tz`]:[],...e.characterSpacing&&0!==e.characterSpacing?[`${ZN(e.characterSpacing)} Tc`]:[]]}emitTextBlock(t,e,a){const n=this.page;n.commands.push([nO(a.text),"BT",QN(a.color,"rg",[0,0,0]),...a.renderMode&&0!==a.renderMode?[QN(a.strokeColor??a.color,"RG",[0,0,0]),`${ZN(a.strokeWidth??Math.max(.3,.03*(a.fontSize??12)))} w`,`${a.renderMode} Tr`]:[],...this.textSetupCommands(t,a),`${ZN(a.x)} ${ZN(n.height-a.y)} Td`,e,"ET"].join("\n"))}emitGradientTextBlock(t,e,a,n){const r=this.page;r.commands.push([nO(a.text),"q","BT",...this.textSetupCommands(t,a),"7 Tr",`${ZN(a.x)} ${ZN(r.height-a.y)} Td`,e,"ET",`/${n} sh`,"Q"].join("\n"))}drawImage(t){const e=this.page;if(t.width<=0||t.height<=0||!this.images.has(t.resourceName))return;e.imageResourceNames.add(t.resourceName);const a=e.height-t.y-t.height,n=Number.isFinite(t.rotation)?t.rotation??0:0;if(0===n)return void e.commands.push(["q",[ZN(t.width),"0","0",ZN(t.height),ZN(t.x),ZN(a),"cm"].join(" "),`/${t.resourceName} Do`,"Q"].join("\n"));const r=-n*Math.PI/180,o=Math.cos(r),i=Math.sin(r),l=t.width*o,s=t.width*i,d=-t.height*i,c=t.height*o,h=t.x+t.width/2-.5*l-.5*d,p=a+t.height/2-.5*s-.5*c;e.commands.push(["q",[ZN(l),ZN(s),ZN(d),ZN(c),ZN(h),ZN(p),"cm"].join(" "),`/${t.resourceName} Do`,"Q"].join("\n"))}}function oO(t,e){const a=new Array(e);for(let n=0;n<e;n+=1)a[n]=t.u16();return a}function iO(t,e,a){const n=new Array(e);for(let r=0;r<e;r+=1)n[r]=a+t.u16();return n}function lO(t,e){t.seek(e);const a=t.u16();if(1===a){const e=t.u16(),a=new Map;for(let n=0;n<e;n+=1)a.set(t.u16(),n);return t=>a.get(t)??-1}if(2===a){const e=t.u16(),a=[];for(let n=0;n<e;n+=1){const e=t.u16(),n=t.u16(),r=t.u16();a.push({start:e,end:n,startIndex:r})}return t=>{for(const e of a)if(t>=e.start&&t<=e.end)return e.startIndex+(t-e.start);return-1}}return()=>-1}function sO(t,e){t.seek(e);const a=t.u16();if(1===a){const e=t.u16(),a=t.u16(),n=oO(t,a);return t=>{const r=t-e;return r>=0&&r<a?n[r]:0}}if(2===a){const e=t.u16(),a=[];for(let n=0;n<e;n+=1){const e=t.u16(),n=t.u16(),r=t.u16();a.push({start:e,end:n,classValue:r})}return t=>{for(const e of a)if(t>=e.start&&t<=e.end)return e.classValue;return 0}}return()=>0}function dO(t){t.seek(0),t.skip(2),t.skip(2);const e=t.u16(),a=t.u16(),n=t.u16(),r=function(t,e){t.seek(e);const a=t.u16(),n=[];for(let r=0;r<a;r+=1){const a=t.tag(),r=e+t.u16();n.push({tag:a,offset:r})}return n.map(({tag:e,offset:a})=>{t.seek(a),t.skip(2);const n=t.u16();return{tag:e,lookupIndices:oO(t,n)}})}(t,a),o=function(t,e){t.seek(e);const a=t.u16(),n=[];for(let d=0;d<a;d+=1){const a=t.tag(),r=e+t.u16();n.push({tag:a,offset:r})}if(0===n.length)return[];const r=n.find(t=>"latn"===t.tag)??n.find(t=>"DFLT"===t.tag)??n[0];t.seek(r.offset);const o=t.u16();if(0===o)return[];t.seek(r.offset+o),t.skip(2);const i=t.u16(),l=t.u16(),s=[];65535!==i&&s.push(i);for(let d=0;d<l;d+=1)s.push(t.u16());return s}(t,e),i=new Map;for(const l of o){const t=r[l];if(!t)continue;const e=i.get(t.tag)??[];for(const a of t.lookupIndices)e.includes(a)||e.push(a);i.set(t.tag,e)}return{featureToLookups:i,lookupListOffset:n}}function cO(t,e,a){t.seek(e);const n=t.u16();return iO(t,n,e).map(e=>{t.seek(e);const n=t.u16();t.skip(2);const r=iO(t,t.u16(),e),o=[];for(const i of r)try{const e=a(t,i,n);e&&o.push(e)}catch{}return{lookupType:n,subtables:o}})}function hO(t,e){const a=new Set;for(const n of e)for(const e of t.get(n)??[])a.add(e);return Array.from(a).sort((t,e)=>t-e)}function pO(t,e){if(t.seek(e),1!==t.u16())return null;const a=e+t.u16(),n=t.u16(),r=iO(t,n,e).map(e=>(t.seek(e),oO(t,t.u16())));return{coverage:lO(t,a),sets:r}}function uO(t,e){const a=new Array(e);for(let n=0;n<e;n+=1){const e=t.u16(),r=t.u16();a[n]={sequenceIndex:e,lookupListIndex:r}}return a}function fO(t,e,a,n){for(const r of a)n.applyLookupIndexAt(r.lookupListIndex,t,e+r.sequenceIndex)}function gO(t,e){t.seek(e);const a=t.u16();return iO(t,a,e).map(e=>{t.seek(e);return{backtrack:oO(t,t.u16()),input:oO(t,Math.max(0,t.u16()-1)),lookahead:oO(t,t.u16()),records:uO(t,t.u16())}})}function mO(t,e,a,n,r){const o=(t,a)=>{const n=e[t];return n?r?"b"===a?r.backtrack(n.id):"l"===a?r.lookahead(n.id):r.input(n.id):n.id:null};for(const i of t){const t=i.input.length+1;if(a+t>e.length)continue;let r=!0;for(let e=0;e<i.input.length;e+=1)if(o(a+1+e,"i")!==i.input[e]){r=!1;break}if(r){for(let t=0;t<i.backtrack.length;t+=1)if(o(a-1-t,"b")!==i.backtrack[t]){r=!1;break}if(r){for(let e=0;e<i.lookahead.length;e+=1)if(o(a+t+e,"l")!==i.lookahead[e]){r=!1;break}if(r)return fO(e,a,i.records,n),t}}}return null}function vO(t,e,a){switch(a){case 1:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16();if(1===a){const e=t.i16(),a=lO(t,n);return{apply(t,n){const r=t[n];return!r||a(r.id)<0?null:(r.id=r.id+e&65535,1)}}}if(2===a){const e=t.u16(),a=oO(t,e),r=lO(t,n);return{apply(t,n){const o=t[n];if(!o)return null;const i=r(o.id);return i<0||i>=e?null:(o.id=a[i],1)}}}return null}(t,e);case 2:return function(t,e){const a=pO(t,e);if(!a)return null;const{coverage:n,sets:r}=a;return{apply(t,e){const a=t[e];if(!a)return null;const o=n(a.id);if(o<0||o>=r.length)return null;const i=r[o];if(0===i.length)return null;const l=a.codePoints,s=i.map((t,e)=>({id:t,codePoints:0===e?l:[]}));return t.splice(e,1,...s),i.length}}}(t,e);case 3:return function(t,e){const a=pO(t,e);if(!a)return null;const{coverage:n,sets:r}=a;return{apply(t,e){const a=t[e];if(!a)return null;const o=n(a.id);if(o<0||o>=r.length)return null;const i=r[o];return 0===i.length?null:(a.id=i[0],1)}}}(t,e);case 4:return function(t,e){if(t.seek(e),1!==t.u16())return null;const a=e+t.u16(),n=t.u16(),r=iO(t,n,e).map(e=>(t.seek(e),iO(t,t.u16(),e).map(e=>{t.seek(e);const a=t.u16(),n=t.u16();return{ligatureGlyph:a,components:oO(t,Math.max(0,n-1))}}))),o=lO(t,a);return{apply(t,e){const a=t[e];if(!a)return null;const n=o(a.id);if(n<0||n>=r.length)return null;for(const o of r[n]){const{components:a}=o;if(e+a.length>t.length-1)continue;let n=!0;for(let o=0;o<a.length;o+=1)if(t[e+1+o].id!==a[o]){n=!1;break}if(!n)continue;const r=a.length+1,i=[];for(let o=0;o<r;o+=1)i.push(...t[e+o].codePoints);return t.splice(e,r,{id:o.ligatureGlyph,codePoints:i}),1}return null}}}(t,e);case 6:return function(t,e){t.seek(e);const a=t.u16();if(3===a){const a=iO(t,t.u16(),e),n=iO(t,t.u16(),e),r=iO(t,t.u16(),e),o=t.u16(),i=uO(t,o),l=a.map(e=>lO(t,e)),s=n.map(e=>lO(t,e)),d=r.map(e=>lO(t,e));return{apply(t,e,a){if(0===s.length)return null;if(e+s.length>t.length)return null;for(let n=0;n<s.length;n+=1)if(s[n](t[e+n].id)<0)return null;for(let n=0;n<l.length;n+=1){const a=t[e-1-n];if(!a||l[n](a.id)<0)return null}for(let n=0;n<d.length;n+=1){const a=t[e+s.length+n];if(!a||d[n](a.id)<0)return null}return fO(t,e,i,a),s.length}}}if(1===a){const a=e+t.u16(),n=t.u16(),r=iO(t,n,e),o=lO(t,a),i=r.map(e=>gO(t,e));return{apply(t,e,a){const n=t[e];if(!n)return null;const r=o(n.id);return r<0||r>=i.length?null:mO(i[r],t,e,a,null)}}}if(2===a){const a=e+t.u16(),n=e+t.u16(),r=e+t.u16(),o=e+t.u16(),i=t.u16(),l=new Array(i);for(let u=0;u<i;u+=1){const a=t.u16();l[u]=0===a?0:e+a}const s=lO(t,a),d=sO(t,n),c=sO(t,r),h=sO(t,o),p=l.map(e=>0===e?[]:gO(t,e));return{apply(t,e,a){const n=t[e];if(!n)return null;if(s(n.id)<0)return null;const r=c(n.id),o=p[r];return o?mO(o,t,e,a,{backtrack:d,input:c,lookahead:h}):null}}}return null}(t,e);case 7:{t.seek(e);if(1!==t.u16())return null;const a=t.u16(),n=e+t.u32();return vO(t,n,a)}default:return null}}class bO{constructor(t,e){this.lookups=t,this.featureToLookups=e}static parse(t){try{const e=new Ml(t),{featureToLookups:a,lookupListOffset:n}=dO(e),r=cO(e,n,vO);return new bO(r,a)}catch{return null}}hasAnyFeature(t){return t.some(t=>this.featureToLookups.has(t))}collectLookupIndices(t){return hO(this.featureToLookups,t)}applyLookupIndexAt(t,e,a){const n=this.lookups[t];if(!n||a<0||a>=e.length)return null;for(const r of n.subtables){const t=r.apply(e,a,this);if(null!==t)return t}return null}shape(t,e){const a=this.collectLookupIndices(e);for(const n of a){let e=0;for(;e<t.length;){const a=this.applyLookupIndexAt(n,t,e);e+=a&&a>0?a:1}}}}function yO(t,e){let a=0;return 1&e&&t.i16(),2&e&&t.i16(),4&e&&(a=t.i16()),8&e&&t.i16(),16&e&&t.u16(),32&e&&t.u16(),64&e&&t.u16(),128&e&&t.u16(),a}function MO(t){let e=0;for(let a=0;a<8;a+=1)t&1<<a&&(e+=1);return 2*e}function xO(t,e,a){switch(a){case 1:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16();if(1===a){const e=t.u16(),a=yO(t,e),r=lO(t,n);return 0===a?null:{apply:(t,e,n)=>r(t[n])<0?null:(e[n]+=a,1)}}if(2===a){const e=t.u16(),a=t.u16(),r=MO(e),o=t.tell(),i=new Array(a);for(let n=0;n<a;n+=1)t.seek(o+n*r),i[n]=yO(t,e);const l=lO(t,n);return{apply(t,e,n){const r=l(t[n]);if(r<0||r>=a)return null;const o=i[r];return 0===o?null:(e[n]+=o,1)}}}return null}(t,e);case 2:return function(t,e){t.seek(e);const a=t.u16(),n=e+t.u16(),r=t.u16(),o=t.u16(),i=!!(4&o);if(1===a){const a=t.u16(),l=iO(t,a,e).map(e=>{t.seek(e);const a=t.u16(),n=new Map;for(let i=0;i<a;i+=1){const e=t.u16(),a=yO(t,r),i=yO(t,o);n.set(e,{secondGlyph:e,value1XAdvance:a,value2XAdvance:i})}return n}),s=lO(t,n);return{apply(t,e,a){const n=t[a+1];if(void 0===n)return null;const r=s(t[a]);if(r<0||r>=l.length)return null;const o=l[r].get(n);return o?(e[a]+=o.value1XAdvance,e[a+1]+=o.value2XAdvance,i?2:1):null}}}if(2===a){const a=e+t.u16(),l=e+t.u16(),s=t.u16(),d=t.u16(),c=MO(r),h=c+MO(o),p=t.tell(),u=new Array(s*d),f=new Array(s*d);for(let e=0;e<s;e+=1)for(let a=0;a<d;a+=1){const n=(e*d+a)*h;t.seek(p+n),u[e*d+a]=yO(t,r),t.seek(p+n+c),f[e*d+a]=yO(t,o)}const g=lO(t,n),m=sO(t,a),v=sO(t,l);return{apply(t,e,a){const n=t[a],r=t[a+1];if(void 0===r)return null;if(g(n)<0)return null;const o=m(n),l=v(r);if(o>=s||l>=d)return null;const c=o*d+l,h=u[c],p=f[c];return 0===h&&0===p?null:(e[a]+=h,e[a+1]+=p,i?2:1)}}}return null}(t,e);case 9:{t.seek(e);if(1!==t.u16())return null;const a=t.u16(),n=e+t.u32();return xO(t,n,a)}default:return null}}class wO{constructor(t,e){this.lookups=t,this.featureToLookups=e}static parse(t){try{const e=new Ml(t),{featureToLookups:a,lookupListOffset:n}=dO(e),r=cO(e,n,xO);return new wO(r,a)}catch{return null}}hasAnyFeature(t){return t.some(t=>this.featureToLookups.has(t))}position(t,e,a){const n=hO(this.featureToLookups,a);for(const r of n){const a=this.lookups[r];if(!a)continue;let n=0;for(;n<t.length;){let r=null;for(const o of a.subtables)if(r=o.apply(t,e,n),null!==r)break;n+=r&&r>0?r:1}}}}const SO=new Set(["kern"]);class AO{constructor(t){a(this,"gsub"),a(this,"gpos"),this.font=t;const e=t.getRawTableData("GSUB");this.gsub=e?bO.parse(e):null;const n=t.getRawTableData("GPOS");this.gpos=n?wO.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(t,e){const a=[];for(const d of t){const t=d.codePointAt(0)??65533,e=this.font.glyphForCodePoint(t);a.push({id:e,codePoints:0===e?[65533]:[t]})}const n=(null==e?void 0:e.filter(t=>!SO.has(t)))??[],r=(null==e?void 0:e.filter(t=>SO.has(t)))??[];this.gsub&&n.length>0&&this.gsub.shape(a,n);const o=a.map(t=>this.font.advanceWidthForGlyph(t.id));this.gpos&&r.length>0&&this.gpos.position(a.map(t=>t.id),o,r);const i=[],l=[];let s=0;for(let d=0;d<a.length;d+=1){const t=a[d],e=this.font.advanceWidthForGlyph(t.id),n=o[d];i.push({id:t.id,codePoints:t.codePoints,advanceWidth:e}),l.push({xAdvance:n}),s+=n}return{glyphs:i,positions:l,advanceWidth:s}}}class CO{constructor(t){this.font=t}layout(t){const e=[],a=[];let n=0;for(const r of t){const t=r.codePointAt(0)??65533,o=this.font.glyphForCodePoint(t),i=this.font.advanceWidthForGlyph(o);e.push({id:o,codePoints:0===o?[65533]:[t],advanceWidth:i}),a.push({xAdvance:i}),n+=i}return{glyphs:e,positions:a,advanceWidth:n}}}function IO(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function TO(t,e){return IO(t).getUint16(e)}function kO(t,e,a){IO(t).setUint16(e,a,!1)}function VO(t,e,a){IO(t).setUint32(e,a,!1)}function RO(t){return t+3&-4}function EO(t){const e=t.reduce((t,e)=>t+RO(e.byteLength),0),a=new Uint8Array(e);let n=0;for(const r of t)a.set(r,n),n+=RO(r.byteLength);return a}function LO(t,e){const a=[],n=IO(t);if(0===e)for(let r=0;r+1<t.byteLength;r+=2)a.push(2*n.getUint16(r));else for(let r=0;r+3<t.byteLength;r+=4)a.push(n.getUint32(r));return a}function zO(t,e){const a=t[e],n=t[e+1];return void 0===a||void 0===n?null:{start:a,end:n}}function NO(t,e){if(t.byteLength<10||function(t,e){return IO(t).getInt16(e)}(t,0)>=0)return;let a=10,n=0;do{if(a+4>t.byteLength)return;n=TO(t,a),e(TO(t,a+2)),a+=4,a+=1&n?4:2,8&n?a+=2:64&n?a+=4:128&n&&(a+=8)}while(32&n)}function OO(t){const e=new Uint8Array(4*t.length);return t.forEach((t,a)=>VO(e,4*a,t)),e}function qO(t,e){const a=new Uint8Array(4*(e+1));for(let n=0;n<=e;n+=1)kO(a,4*n,t.advanceWidthForGlyph(n)),kO(a,4*n+2,0);return a}class PO{createSubset(t,e){const a=new Map,n=[];for(const c of e)n.push(c.id),a.has(c.id)||a.set(c.id,c.codePoints);const r=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head");if(!a||!n||!r)return Array.from(new Set([0,...e])).sort((t,e)=>t-e);const o=LO(n,TO(r,50)),i=new Set([0,...e]),l=Array.from(i);for(;l.length>0;){const t=zO(o,l.pop());!t||t.end<=t.start||t.end>a.byteLength||NO(a.slice(t.start,t.end),t=>{i.has(t)||(i.add(t),l.push(t))})}return Array.from(i).sort((t,e)=>t-e)}(t,n),o=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head"),o=t.getRawTableData("hhea"),i=t.getRawTableData("maxp"),l=t.getRawTableData("cmap");if(!(a&&n&&r&&o&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...e),d=new Set(e),c=LO(n,TO(r,50)),h=[],p=[];let u=0;for(let b=0;b<=s;b+=1){h.push(u);const t=zO(c,b);if(d.has(b)&&t&&t.end>t.start){const e=a.slice(t.start,t.end);p.push(e),u+=RO(e.byteLength)}}h.push(u);const f=r.slice();VO(f,8,0),kO(f,50,1);const g=o.slice();kO(g,34,s+1);const m=i.slice();kO(m,4,s+1);const v={cmap:l,head:f,hhea:g,hmtx:qO(t,s),loca:OO(h),maxp:m,glyf:EO(p)};for(const b of["OS/2","name","post"]){const e=t.getRawTableData(b);e&&(v[b]=e)}return v}(t,r),i=Ni(65536,new Map(Object.entries(o).map(([t,e])=>[t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3),e]))).ttf,l=Math.max(0,...r),s=[],d=[];for(let c=0;c<=l;c+=1)s[c]=t.advanceWidthForGlyph(c)/t.unitsPerEm*1e3,d[c]=a.get(c)??[0];return{fontFile:i,widths:s,unicode:d,encodeGlyph:t=>t}}}class WO{constructor(t){a(this,"fontResources",new Map),a(this,"unicodeFontStates",new Map),a(this,"usedFontResourceNames",new Set);for(const e of t)this.registerFontResource(e)}registerFontResource(t){if(this.fontResources.set(t.resourceName,t),"unicode"===t.kind&&!this.unicodeFontStates.has(t.resourceName)){const e=function(t){const e=new AO(t);return{program:t,layouter:e.hasShaping?e:new CO(t),subsetter:new PO}}(function(t){const e=al.decodeSync(t);return Il.parse(e)}(t.fontData)),a=1e3/e.program.unitsPerEm,n={id:0,codePoints:[0],advanceWidth:e.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(t.resourceName,{resource:t,font:e,usedGlyphs:new Map([[0,n]]),scale:a,layoutCache:new Map})}}resolveAndMarkFontName(t){const e=function(t){return t.fontResourceName?t.fontResourceName:t.bold&&t.italic?"F4":t.bold?"F2":t.italic?"F3":"F1"}(t);return this.usedFontResourceNames.add(e),e}getUnicodeState(t){return this.unicodeFontStates.get(t)}buildUnicodeShowCommand(t,e,a){const n=this.layoutUnicodeText(t,e,a),r=this.encodeUnicodeGlyphRun(t,n);if(0===r.length)return null;return r.some(t=>Math.abs(t.nominalWidth-t.desiredAdvance)>.01)?`[${r.map(t=>{const e=t.nominalWidth-t.desiredAdvance;return 0===e?`<${aO(t.glyphId)}>`:`<${aO(t.glyphId)}> ${ZN(e)}`}).join(" ")}] TJ`:`<${r.map(t=>aO(t.glyphId)).join("")}> Tj`}buildFontObjects(t){const e=Array.from(this.fontResources.values()).filter(t=>"base14"===t.kind||this.usedFontResourceNames.has(t.resourceName)),a=e.map(e=>{if("unicode"===e.kind){const a=this.unicodeFontStates.get(e.resourceName);if(a)return this.addUnicodeFontObjects(a,t)}return t(function(t){switch(t.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${t.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(e))});return{resourceXml:e.map((t,e)=>`/${t.resourceName} ${a[e]} 0 R`).join(" ")}}layoutUnicodeText(t,e,a){const n=`${(null==a?void 0:a.join(","))??""}\0${e}`,r=t.layoutCache.get(n);if(r)return r;const o=t.font.layouter.layout(e,a);return t.layoutCache.set(n,o),o}encodeUnicodeGlyphRun(t,e){return e.glyphs.map((a,n)=>{t.usedGlyphs.has(a.id)||t.usedGlyphs.set(a.id,a);const r=e.positions[n],o=a.advanceWidth*t.scale,i=((null==r?void 0:r.xAdvance)??a.advanceWidth)*t.scale;return{glyphId:a.id,nominalWidth:o,desiredAdvance:i}})}addUnicodeFontObjects(t,e){const a=t.font.subsetter.createSubset(t.font.program,t.usedGlyphs.values()),n=e(function(t,e=""){const a=`${XN(t)}>`,n=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${KN(a)} /Filter /ASCIIHexDecode${n} >>\nstream\n${a}\nendstream`}(a.fontFile)),r=t.font.program.metadata,o=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),o>=1&&o<=7&&(i|=2),10===o&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${_N(`${t.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${_N(r.postscriptName,t.resource.family)}`,s=r.bbox,d=e(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*t.scale,s.minY*t.scale,s.maxX*t.scale,s.maxY*t.scale].map(ZN).join(" ")}]`,`/ItalicAngle ${ZN(r.italicAngle)}`,`/Ascent ${ZN(r.ascent*t.scale)}`,`/Descent ${ZN(r.descent*t.scale)}`,`/CapHeight ${ZN(r.capHeight*t.scale)}`,`/XHeight ${ZN(r.xHeight*t.scale)}`,"/StemV 0",`/FontFile2 ${n} 0 R`,">>"].join("\n")),c=e(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [0 [${a.widths.map(t=>ZN(t??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),h=e(function(t,e=""){const a=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${KN(t)}${a} >>\nstream\n${t}endstream`}(function(t){const e=t.map(t=>`<${eO(t)}>`).filter(t=>"<>"!==t);0===e.length&&e.push("<0000>");const a=[];for(let n=0;n<e.length;n+=256){const t=Math.min(n+256,e.length);a.push(`<${YN(n)}> <${YN(t-1)}> [${e.slice(n,t).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",`${a.length} beginbfrange`,a.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(a.unicode)));return e(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${c} 0 R]`,`/ToUnicode ${h} 0 R`,">>"].join("\n"))}}class BO{constructor(){a(this,"imageResources",new Map)}registerImageResource(t){const e=t.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(e)||this.imageResources.set(e,{resourceName:e,width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height)),data:t.data,filter:t.filter}),e}has(t){return this.imageResources.has(t)}buildImageObjects(t){const e=new Map;for(const a of this.imageResources.values())e.set(a.resourceName,this.addImageObject(a,t));return e}addImageObject(t,e){return e(function(t,e){const a=`${XN(t)}>`;return[`<< /Length ${KN(a)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${e.join(" ")}`," >>","stream",a,"endstream"].join("\n")}(t.data,["/Type /XObject","/Subtype /Image",`/Width ${t.width}`,`/Height ${t.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}}class FO{constructor(){a(this,"shadings",[])}register(t){const e=`Sh${this.shadings.length+1}`;return this.shadings.push({name:e,spec:t}),e}buildShadingObjects(t){const e=new Map;for(const{name:a,spec:n}of this.shadings)e.set(a,this.addShadingObject(n,t));return e}addShadingObject(t,e){const a=e(function(t){if(2===t.length)return HO(t[0].rgb,t[1].rgb);const e=[];for(let r=0;r<t.length-1;r+=1)e.push(HO(t[r].rgb,t[r+1].rgb));const a=t.slice(1,-1).map(t=>ZN(t.offset)),n=t.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${e.join(" ")}]`,`/Bounds [${a.join(" ")}]`,`/Encode [${n}]`,">>"].join("\n")}(function(t){const e=t.map(t=>({offset:Math.min(1,Math.max(0,t.offset)),rgb:JN(t.color,[0,0,0])})).sort((t,e)=>t.offset-e.offset);if(0===e.length)return[{offset:0,rgb:[0,0,0]},{offset:1,rgb:[0,0,0]}];if(1===e.length)return[{offset:0,rgb:e[0].rgb},{offset:1,rgb:e[0].rgb}];e[0].offset=0,e[e.length-1].offset=1;for(let a=1;a<e.length-1;a+=1){const t=e[a-1].offset+1e-4;e[a].offset<=t&&(e[a].offset=Math.min(.9999,t))}return e}(t.stops)));return e(["<< /ShadingType 2","/ColorSpace /DeviceRGB",`/Coords [${[t.x0,t.y0,t.x1,t.y1].map(ZN).join(" ")}]`,"/Domain [0 1]",`/Function ${a} 0 R`,"/Extend [true true]",">>"].join("\n"))}}function HO(t,e){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${t.map(ZN).join(" ")}]`,`/C1 [${e.map(ZN).join(" ")}]`,"/N 1",">>"].join("\n")}var UO=Uint8Array,GO=Uint16Array,DO=Int32Array,jO=new UO([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ZO=new UO([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),KO=new UO([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),XO=function(t,e){for(var a=new GO(31),n=0;n<31;++n)a[n]=e+=1<<t[n-1];var r=new DO(a[30]);for(n=1;n<30;++n)for(var o=a[n];o<a[n+1];++o)r[o]=o-a[n]<<5|n;return{b:a,r:r}},YO=XO(jO,2),JO=YO.b,QO=YO.r;JO[28]=258,QO[258]=28;for(var _O=XO(ZO,0).r,$O=new GO(32768),tq=0;tq<32768;++tq){var eq=(43690&tq)>>1|(21845&tq)<<1;eq=(61680&(eq=(52428&eq)>>2|(13107&eq)<<2))>>4|(3855&eq)<<4,$O[tq]=((65280&eq)>>8|(255&eq)<<8)>>1}var aq=function(t,e,a){for(var n=t.length,r=0,o=new GO(e);r<n;++r)t[r]&&++o[t[r]-1];var i,l=new GO(e);for(r=1;r<e;++r)l[r]=l[r-1]+o[r-1]<<1;if(a){i=new GO(1<<e);var s=15-e;for(r=0;r<n;++r)if(t[r])for(var d=r<<4|t[r],c=e-t[r],h=l[t[r]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)i[$O[h]>>s]=d}else for(i=new GO(n),r=0;r<n;++r)t[r]&&(i[r]=$O[l[t[r]-1]++]>>15-t[r]);return i},nq=new UO(288);for(tq=0;tq<144;++tq)nq[tq]=8;for(tq=144;tq<256;++tq)nq[tq]=9;for(tq=256;tq<280;++tq)nq[tq]=7;for(tq=280;tq<288;++tq)nq[tq]=8;var rq=new UO(32);for(tq=0;tq<32;++tq)rq[tq]=5;var oq=aq(nq,9,0),iq=aq(rq,5,0),lq=function(t){return(t+7)/8|0},sq=function(t,e,a){a<<=7&e;var n=e/8|0;t[n]|=a,t[n+1]|=a>>8},dq=function(t,e,a){a<<=7&e;var n=e/8|0;t[n]|=a,t[n+1]|=a>>8,t[n+2]|=a>>16},cq=function(t,e){for(var a=[],n=0;n<t.length;++n)t[n]&&a.push({s:n,f:t[n]});var r=a.length,o=a.slice();if(!r)return{t:vq,l:0};if(1==r){var i=new UO(a[0].s+1);return i[a[0].s]=1,{t:i,l:1}}a.sort(function(t,e){return t.f-e.f}),a.push({s:-1,f:25001});var l=a[0],s=a[1],d=0,c=1,h=2;for(a[0]={s:-1,f:l.f+s.f,l:l,r:s};c!=r-1;)l=a[a[d].f<a[h].f?d++:h++],s=a[d!=c&&a[d].f<a[h].f?d++:h++],a[c++]={s:-1,f:l.f+s.f,l:l,r:s};var p=o[0].s;for(n=1;n<r;++n)o[n].s>p&&(p=o[n].s);var u=new GO(p+1),f=hq(a[c-1],u,0);if(f>e){n=0;var g=0,m=f-e,v=1<<m;for(o.sort(function(t,e){return u[e.s]-u[t.s]||t.f-e.f});n<r;++n){var b=o[n].s;if(!(u[b]>e))break;g+=v-(1<<f-u[b]),u[b]=e}for(g>>=m;g>0;){var y=o[n].s;u[y]<e?g-=1<<e-u[y]++-1:++n}for(;n>=0&&g;--n){var M=o[n].s;u[M]==e&&(--u[M],++g)}f=e}return{t:new UO(u),l:f}},hq=function(t,e,a){return-1==t.s?Math.max(hq(t.l,e,a+1),hq(t.r,e,a+1)):e[t.s]=a},pq=function(t){for(var e=t.length;e&&!t[--e];);for(var a=new GO(++e),n=0,r=t[0],o=1,i=function(t){a[n++]=t},l=1;l<=e;++l)if(t[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(r),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(r);o=1,r=t[l]}return{c:a.subarray(0,n),n:e}},uq=function(t,e){for(var a=0,n=0;n<e.length;++n)a+=t[n]*e[n];return a},fq=function(t,e,a){var n=a.length,r=lq(e+2);t[r]=255&n,t[r+1]=n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<n;++o)t[r+o+4]=a[o];return 8*(r+4+n)},gq=function(t,e,a,n,r,o,i,l,s,d,c){sq(e,c++,a),++r[256];for(var h=cq(r,15),p=h.t,u=h.l,f=cq(o,15),g=f.t,m=f.l,v=pq(p),b=v.c,y=v.n,M=pq(g),x=M.c,w=M.n,S=new GO(19),A=0;A<b.length;++A)++S[31&b[A]];for(A=0;A<x.length;++A)++S[31&x[A]];for(var C=cq(S,7),I=C.t,T=C.l,k=19;k>4&&!I[KO[k-1]];--k);var V,R,E,L,z=d+5<<3,N=uq(r,nq)+uq(o,rq)+i,O=uq(r,p)+uq(o,g)+i+14+3*k+uq(S,I)+2*S[16]+3*S[17]+7*S[18];if(s>=0&&z<=N&&z<=O)return fq(e,c,t.subarray(s,s+d));if(sq(e,c,1+(O<N)),c+=2,O<N){V=aq(p,u,0),R=p,E=aq(g,m,0),L=g;var q=aq(I,T,0);sq(e,c,y-257),sq(e,c+5,w-1),sq(e,c+10,k-4),c+=14;for(A=0;A<k;++A)sq(e,c+3*A,I[KO[A]]);c+=3*k;for(var P=[b,x],W=0;W<2;++W){var B=P[W];for(A=0;A<B.length;++A){var F=31&B[A];sq(e,c,q[F]),c+=I[F],F>15&&(sq(e,c,B[A]>>5&127),c+=B[A]>>12)}}}else V=oq,R=nq,E=iq,L=rq;for(A=0;A<l;++A){var H=n[A];if(H>255){dq(e,c,V[(F=H>>18&31)+257]),c+=R[F+257],F>7&&(sq(e,c,H>>23&31),c+=jO[F]);var U=31&H;dq(e,c,E[U]),c+=L[U],U>3&&(dq(e,c,H>>5&8191),c+=ZO[U])}else dq(e,c,V[H]),c+=R[H]}return dq(e,c,V[256]),c+R[256]},mq=new DO([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vq=new UO(0),bq=function(t,e,a,n,r,o){var i=o.z||t.length,l=new UO(n+i+5*(1+Math.ceil(i/7e3))+r),s=l.subarray(n,l.length-r),d=o.l,c=7&(o.r||0);if(e){c&&(s[0]=o.r>>3);for(var h=mq[e-1],p=h>>13,u=8191&h,f=(1<<a)-1,g=o.p||new GO(32768),m=o.h||new GO(f+1),v=Math.ceil(a/3),b=2*v,y=function(e){return(t[e]^t[e+1]<<v^t[e+2]<<b)&f},M=new DO(25e3),x=new GO(288),w=new GO(32),S=0,A=0,C=o.i||0,I=0,T=o.w||0,k=0;C+2<i;++C){var V=y(C),R=32767&C,E=m[V];if(g[R]=E,m[V]=R,T<=C){var L=i-C;if((S>7e3||I>24576)&&(L>423||!d)){c=gq(t,s,0,M,x,w,A,I,k,C-k,c),I=S=A=0,k=C;for(var z=0;z<286;++z)x[z]=0;for(z=0;z<30;++z)w[z]=0}var N=2,O=0,q=u,P=R-E&32767;if(L>2&&V==y(C-P))for(var W=Math.min(p,L)-1,B=Math.min(32767,C),F=Math.min(258,L);P<=B&&--q&&R!=E;){if(t[C+N]==t[C+N-P]){for(var H=0;H<F&&t[C+H]==t[C+H-P];++H);if(H>N){if(N=H,O=P,H>W)break;var U=Math.min(P,H-2),G=0;for(z=0;z<U;++z){var D=C-P+z&32767,j=D-g[D]&32767;j>G&&(G=j,E=D)}}}P+=(R=E)-(E=g[R])&32767}if(O){M[I++]=268435456|QO[N]<<18|_O[O];var Z=31&QO[N],K=31&_O[O];A+=jO[Z]+ZO[K],++x[257+Z],++w[K],T=C+N,++S}else M[I++]=t[C],++x[t[C]]}}for(C=Math.max(C,T);C<i;++C)M[I++]=t[C],++x[t[C]];c=gq(t,s,d,M,x,w,A,I,k,C-k,c),d||(o.r=7&c|s[c/8|0]<<3,c-=7,o.h=m,o.p=g,o.i=C,o.w=T)}else{for(C=o.w||0;C<i+d;C+=65535){var X=C+65535;X>=i&&(s[c/8|0]=d,X=i),c=fq(s,c+1,t.subarray(C,X))}o.i=i}return function(t,e,a){return(null==a||a>t.length)&&(a=t.length),new UO(t.subarray(e,a))}(l,0,n+lq(c)+r)},yq=function(){var t=1,e=0;return{p:function(a){for(var n=t,r=e,o=0|a.length,i=0;i!=o;){for(var l=Math.min(i+2655,o);i<l;++i)r+=n+=a[i];n=(65535&n)+15*(n>>16),r=(65535&r)+15*(r>>16)}t=n,e=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(e%=65521))<<8|e>>8}}},Mq=function(t,e,a){for(;a;++e)t[e]=a,a>>>=8};function xq(t,e){e||(e={});var a=yq();a.p(t);var n=function(t,e,a,n,r){if(!r&&(r={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),i=new UO(o.length+t.length);i.set(o),i.set(t,o.length),t=i,r.w=o.length}return bq(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,a,n,r)}(t,e,e.dictionary?6:2,4);return function(t,e){var a=e.level,n=0==a?0:a<6?1:9==a?3:2;if(t[0]=120,t[1]=n<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var r=yq();r.p(e.dictionary),Mq(t,2,r.d())}}(n,e),Mq(n,n.length-4,a.d()),n}var wq="undefined"!=typeof TextDecoder&&new TextDecoder;try{wq.decode(vq,{stream:!0})}catch(eB){}const Sq=new TextEncoder;function Aq(t){return"string"==typeof t?KN(t):t.length}function Cq(t){const e=t.reduce((t,e)=>t+Aq(e),0),a=new Uint8Array(e);let n=0;for(const r of t){const t="string"==typeof r?Sq.encode(r):r;a.set(t,n),n+=t.length}return a}function Iq(t){const e=xq(Sq.encode(t));return Cq([`<< /Length ${e.length} /Filter /FlateDecode >>\nstream\n`,e,"\nendstream"])}function Tq(t){return t.replace(/[\\()]/g,t=>`\\${t}`)}function kq(t){return`<FEFF${eO(Array.from(t).map(t=>t.codePointAt(0)??63))}>`}function Vq(t){const e=[];if(t.title&&e.push(`/Title ${kq(t.title)}`),t.author&&e.push(`/Author ${kq(t.author)}`),t.subject&&e.push(`/Subject ${kq(t.subject)}`),t.keywords&&e.push(`/Keywords ${kq(t.keywords)}`),t.producer&&e.push(`/Producer (${Tq(t.producer)})`),t.creationDate&&e.push(`/CreationDate (${function(t){const e=(t,e=2)=>String(t).padStart(e,"0");return`D:${t.getUTCFullYear()}${e(t.getUTCMonth()+1)}${e(t.getUTCDate())}${e(t.getUTCHours())}${e(t.getUTCMinutes())}${e(t.getUTCSeconds())}+00'00'`}(t.creationDate)})`),0!==e.length)return`<< ${e.join(" ")} >>`}function Rq(t){return t.children.reduce((t,e)=>t+1+Rq(e),0)}function Eq(t,e,a,n,r=[],o=[],i){const l=[],s=t=>{const e=l.length+1;return l.push({id:e,body:t}),e},d=s(""),c=s(""),{resourceXml:h}=e.buildFontObjects(s),p=a.buildImageObjects(s),u=n.buildShadingObjects(s),f=[];for(const k of t){const t=`${k.commands.join("\n")}\n`,e=s(Iq(t)),a=Array.from(k.imageResourceNames).map(t=>{const e=p.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),n=a?` /XObject << ${a} >>`:"",r=Array.from(k.shadingResourceNames).map(t=>{const e=u.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),o=r?` /Shading << ${r} >>`:"",i=k.annotations.map(t=>{const e=t.x,a=t.x+t.width,n=k.height-t.y-t.height,r=k.height-t.y,o=void 0!==t.destName?`/A << /Type /Action /S /GoTo /D (${Tq(t.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Tq(t.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${ZN(e)} ${ZN(n)} ${ZN(a)} ${ZN(r)}]`,"/Border [0 0 0]",o,">>"].join("\n"))}),l=i.length>0?`\n/Annots [${i.map(t=>`${t} 0 R`).join(" ")}]`:"",d=s(["<< /Type /Page",`/Parent ${c} 0 R`,`/MediaBox [0 0 ${ZN(k.width)} ${ZN(k.height)}]`,`/Resources << /Font << ${h} >>${n}${o} >>`,`/Contents ${e} 0 R${l}`,">>"].join("\n"));f.push(d)}let g;const m=r.filter(t=>void 0!==f[t.pageIndex]).sort((t,e)=>t.name<e.name?-1:t.name>e.name?1:0);if(m.length>0){const e=m.map(e=>{const a=f[e.pageIndex],n=t[e.pageIndex].height-e.y;return`(${Tq(e.name)}) [${a} 0 R /XYZ ${ZN(e.x)} ${ZN(n)} null]`}).join(" "),a=s(`<< /Names [${e}] >>`);g=s(`<< /Dests ${a} 0 R >>`)}let v;const b=new Set(m.map(t=>t.name)),y=function(t){const e=[],a=[];for(const n of t){const t={title:n.title,destName:n.destName,children:[]};for(;a.length>0&&a[a.length-1].level>=n.level;)a.pop();0===a.length?e.push(t):a[a.length-1].node.children.push(t),a.push({node:t,level:n.level})}return e}(o.filter(t=>b.has(t.destName)));if(y.length>0){v=s("");const t=e=>e.map(e=>{const a=s("");return e.id=a,e.childIds=t(e.children),a}),e=t(y),a=(t,e)=>{t.forEach((n,r)=>{const o=n,i=r>0?t[r-1]:void 0,s=r<t.length-1?t[r+1]:void 0,d=["<< /Title "+kq(n.title),`/Parent ${e} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${Tq(n.destName)})`];o.childIds.length>0&&(d.push(`/First ${o.childIds[0]} 0 R`),d.push(`/Last ${o.childIds[o.childIds.length-1]} 0 R`),d.push(`/Count ${Rq(n)}`)),d.push(">>"),l[o.id-1].body=d.filter(Boolean).join("\n"),a(n.children,o.id)})};a(y,v);const n=o.filter(t=>b.has(t.destName)).length;l[v-1].body=["<< /Type /Outlines",`/First ${e[0]} 0 R`,`/Last ${e[e.length-1]} 0 R`,`/Count ${n}`,">>"].join("\n")}let M;if(l[d-1].body=["<< /Type /Catalog",`/Pages ${c} 0 R`,void 0!==g?`/Names ${g} 0 R`:"",void 0!==v?`/Outlines ${v} 0 R`:"",void 0!==v?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[c-1].body=["<< /Type /Pages",`/Kids [${f.map(t=>`${t} 0 R`).join(" ")}]`,`/Count ${f.length}`,">>"].join("\n"),i){const t=Vq(i);t&&(M=s(t))}const x=[DN];let w=Aq(DN);const S=[0],A=t=>{x.push(t),w+=Aq(t)};for(const k of l)S[k.id]=w,A(`${k.id} 0 obj\n`),A(k.body),A("\nendobj\n");const C=w;let I=`xref\n0 ${l.length+1}\n`;I+="0000000000 65535 f \n";for(const k of l)I+=`${String(S[k.id]??0).padStart(10,"0")} 00000 n \n`;A(I);const T=void 0!==M?` /Info ${M} 0 R`:"";return A(["trailer",`<< /Size ${l.length+1} /Root ${d} 0 R${T} >>`,"startxref",String(C),"%%EOF",""].join("\n")),Cq(x)}class Lq{constructor(t=jN){a(this,"pages",[]),a(this,"streams",[]),a(this,"fonts"),a(this,"images",new BO),a(this,"shadings",new FO),a(this,"namedDestinations",[]),a(this,"outlineItems",[]),a(this,"documentInfo"),this.fonts=new WO(t)}registerFontResource(t){this.fonts.registerFontResource(t)}addPage(t){const e={width:Math.max(1,t.width),height:Math.max(1,t.height),commands:[],imageResourceNames:new Set,shadingResourceNames:new Set,annotations:[]};return this.pages.push(e),this.streams.push(new rO(e,this.fonts,this.images,this.shadings)),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(t,e){var a;null==(a=this.streams[t])||a.drawRect(e)}drawLine(t,e){var a;null==(a=this.streams[t])||a.drawLine(e)}drawPath(t,e){var a;null==(a=this.streams[t])||a.drawPath(e)}saveGraphicsState(t){var e;null==(e=this.streams[t])||e.saveGraphicsState()}restoreGraphicsState(t){var e;null==(e=this.streams[t])||e.restoreGraphicsState()}rotateAbout(t,e,a,n){var r;null==(r=this.streams[t])||r.rotateAbout(e,a,n)}clipRect(t,e,a,n,r){var o;null==(o=this.streams[t])||o.clipRect(e,a,n,r)}drawText(t,e){var a;null==(a=this.streams[t])||a.drawText(e)}registerAxialGradient(t,e){var a;return(null==(a=this.streams[t])?void 0:a.registerAxialGradient(e))??null}registerImageResource(t){return this.images.registerImageResource(t)}drawImage(t,e){var a;null==(a=this.streams[t])||a.drawImage(e)}addLinkAnnotation(t,e){var a;null==(a=this.pages[t])||a.annotations.push(e)}addNamedDestination(t){this.namedDestinations.some(e=>e.name===t.name)||this.namedDestinations.push(t)}addOutlineItem(t){this.outlineItems.push(t)}setDocumentInfo(t){this.documentInfo=t}toArrayBuffer(){const t=this.toUint8Array();return Uint8Array.from(t).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){return 0===this.pages.length&&this.addPage({width:612,height:792}),Eq(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}}function zq(t,e,a,n,r){if(0!==n.size||0!==r.size)return(o,i)=>{const l=Zw(i),s=Zw(a);for(const a of n.get(o)??[])t.addNamedDestination({name:a,pageIndex:e,x:s,y:l});const d=r.get(o);if(d){const a=`__oasis_heading_${o}`;t.addNamedDestination({name:a,pageIndex:e,x:s,y:l}),t.addOutlineItem({title:d.title,level:d.level,destName:a})}}}async function Nq(t){t=hN(t);const e=new GN;await e.loadBundledUnicodeFaces({families:td(t)});const a=new Lq(e.getPdfFontResources());a.setDocumentInfo(function(t){const e=t.metadata??{},a=t=>"string"==typeof t&&""!==t.trim()?t:void 0;return{title:a(e.title),author:a(e.author),subject:a(e.subject),keywords:a(e.keywords),producer:"Oasis Editor",creationDate:new Date}}(t));const n=nh(t),r=function(t){return Va(t)}(t),o=function(t){var e;const a=new Map,n=t.bookmarks;if(!n)return a;for(const r of n.order){const t=n.items[r],o=null==(e=null==t?void 0:t.start)?void 0:e.paragraphId;if(!t||!o)continue;const i=a.get(o)??[];i.push(t.name),a.set(o,i)}return a}(t),i=new Map(Nn(t).map(t=>[t.id,{level:t.level,title:t.text}]));for(const l of n.pages){const n=Math.max(1,Zw(l.pageSettings.width)),s=Math.max(1,Zw(l.pageSettings.height)),d=a.addPage({width:n,height:s});BN(a,d,n,s);const c=l.pageSettings.margins.left+l.pageSettings.margins.gutter,h=De(l.pageSettings);await WN(a,d,l.headerBlocks,t,c,l.headerTop??Ke(l.pageSettings),h,e,r,l.pageSettings);const p=l.bodyTop??Xe(l.pageSettings);if(l.blocks.some(t=>void 0!==t.columnIndex)){const n=je(l.pageSettings),s=new Map;for(const t of l.blocks){const e=t.columnIndex??0,a=s.get(e)??[];a.push(t),s.set(e,a)}for(const[c,h]of s){const s=n[c]??n[0];await WN(a,d,h,t,s.left,p,s.width,e,r,l.pageSettings,zq(a,d,s.left,o,i))}}else await WN(a,d,l.blocks,t,c,p,h,e,r,l.pageSettings,zq(a,d,c,o,i));await WN(a,d,l.footerBlocks,t,c,l.footerTop??l.bodyBottom??l.pageSettings.height,h,e,r,l.pageSettings),l.footnoteBlocks&&l.footnoteBlocks.length>0&&void 0!==l.footnoteTop&&(void 0!==l.footnoteSeparatorTop&&a.drawLine(d,{x1:Zw(c),y1:Zw(l.footnoteSeparatorTop+.5),x2:Zw(c+Math.min(180,.35*h)),y2:Zw(l.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:Zw(1)}),await Oq(a,d,l.footnoteBlocks,l.footnoteReferenceIds??[],t,c,l.footnoteTop,h,e,r))}if(0===a.getPageCount()){const t=a.addPage({width:612,height:792});BN(a,t,612,792)}return a.toArrayBuffer()}async function Oq(t,e,a,n,r,o,i,l,s,d){var c;let h=i;const p=new Set,u=new Map(n.map(t=>{var e;return[t,(null==(e=Kc(r,t))?void 0:e.run.text)??""]}));for(const f of a){const a=n.find(t=>f.blockId.startsWith(`${t}:`));if(a&&!p.has(a)){const n=u.get(a);if(n){const a="paragraph"===f.sourceBlock.type?f.sourceBlock:void 0,i=la(void 0,null==(c=null==a?void 0:a.style)?void 0:c.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});t.drawText(e,{x:Zw(o),y:Zw(h+12),text:n,fontSize:Kw(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}p.add(a)}await WN(t,e,[f],r,o+ed,h,Math.max(24,l-ed),s,d),h+=Math.max(0,f.estimatedHeight)+2}}function qq(t,e){const a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e,n.click(),URL.revokeObjectURL(a)}function Pq(t){const e=t.download??qq;return{handleExportDocx:async()=>{const a=await async function(t){const e=await fN(t);return new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}(t.document());e(a,"oasis-editor.docx"),t.focusInput()},handleExportPdf:async()=>{const a=await async function(t){const e=await Nq(t);return new Blob([e],{type:"application/pdf"})}(t.document());e(a,"oasis-editor.pdf"),t.focusInput()}}}async function Wq(t){return"function"==typeof t.arrayBuffer?t.arrayBuffer():new Promise((e,a)=>{const n=new FileReader;n.onerror=()=>a(n.error??new Error("Failed to read file.")),n.onload=()=>{const t=n.result;t instanceof ArrayBuffer?e(t):a(new Error("Failed to read file as ArrayBuffer."))},n.readAsArrayBuffer(t)})}function Bq(t){if(!t)return null;for(const e of Array.from(t.items??[])){if("file"!==e.kind)continue;const t=e.getAsFile();if(t&&t.type.startsWith("image/"))return t}for(const e of Array.from(t.files??[]))if(e.type.startsWith("image/"))return e;return null}function Fq(t){return{handleImportFile:async e=>{if(!e)return;const a=function(t){return jM.find(e=>e.matches(t))}(e);if(!a)return t.setImportPhase("error"),t.logger.error("import:unsupported-format",{name:e.name,type:e.type}),void t.clearImportProgressSoon();const n=t.now();t.logger.info("import:start",{format:a.id,name:e.name,size:e.size}),t.setImportPhase("reading-file");try{const r=t.now(),o=await Wq(e);t.logger.info("import:phase",{phase:"reading-file",durationMs:Fl(t.now()-r,2)});let i=null,l=-1,s=0;const d=await a.import(o,(e,a)=>{const n=t.now(),r=void 0!==a&&Number.isFinite(a)?Math.floor(100*a):void 0,o=e!==i;if(!o&&!(void 0!==r&&(l<0||r-l>=1))&&!(n-s>=40))return;i=e,l=r??l,s=n,t.setImportPhase(e,a);const d={phase:e,subProgress:a};o||void 0===a||1===a?t.logger.info("import:phase",d):t.logger.debug("import:phase",d)});t.logger.debug("import:document-diagnostics",function(t){var e;const a=ba(t),n=new Map,r=new Map;let o=0,i=0;for(const l of a){const a=sa(l.style,t.styles);r.set(a.align,(r.get(a.align)??0)+1);for(const r of l.runs){const a=la(r.styles,null==(e=l.style)?void 0:e.styleId,t.styles),s=a.fontFamily??"<null>";n.set(s,(n.get(s)??0)+1),null!==a.characterSpacing&&(o+=1),null!==a.characterScale&&(i+=1)}}return{paragraphCount:a.length,alignCounts:Array.from(r.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:o,characterScaleRuns:i,firstParagraphs:a.slice(0,30).map((e,a)=>{var n;const r=sa(e.style,t.styles),o=e.runs[0],i=la(null==o?void 0:o.styles,null==(n=e.style)?void 0:n.styleId,t.styles);return{index:a,textLength:Je(e).length,runCount:e.runs.length,rawParagraphStyle:e.style,align:r.align,indentFirstLine:r.indentFirstLine,lineGridPitch:r.lineGridPitch,lineGridType:r.lineGridType,fontFamily:i.fontFamily,fontSize:i.fontSize,characterSpacing:i.characterSpacing,characterScale:i.characterScale,firstRunStyle:null==o?void 0:o.styles}})}}(d)),t.setImportPhase("applying-editor-state"),t.resetEditorChromeState(),t.applyState(rn(d));const c=t.now();t.setImportPhase("stabilizing-layout"),await t.stabilizeLayoutAfterImport(),t.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Fl(t.now()-c,2)});const h=ca(d).reduce((t,e)=>{var a,n;return t+((null==(a=e.header)?void 0:a.length)??0)+e.blocks.length+((null==(n=e.footer)?void 0:n.length)??0)},0),p=va(d).length;t.setImportPhase("done"),t.logger.info("import:done",{format:a.id,blocks:h,paragraphs:p,durationMs:Fl(t.now()-n,2)}),t.focusInput()}catch(r){t.setImportPhase("error"),t.logger.error("import:error",r)}finally{t.clearImportProgressSoon()}}}}function Hq(t,e){const a=Da(t);if(a.isCollapsed||a.startIndex!==a.endIndex||a.endParagraphOffset-a.startParagraphOffset!==1)return null;const n=Na(t)[a.startIndex];if(!n)return null;let r=0;for(let o=0;o<n.runs.length;o+=1){const t=n.runs[o],i=r;if(r+=t.text.length,e(t)&&1===t.text.length&&i===a.startParagraphOffset)return{paragraph:n,paragraphIndex:a.startIndex,run:t,runIndex:o,offset:i}}return null}function Uq(t,e){if("inline"===e)return;const a={...t??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(e){case"square":case"tight":case"through":case"topAndBottom":return{...a,wrap:e,behindDoc:!1};case"behind":return{...a,wrap:"none",behindDoc:!0};case"front":return{...a,wrap:"none",behindDoc:!1}}}function Gq(t){return t?t.behindDoc?"behind":t.wrap&&"none"!==t.wrap?t.wrap:"front":"inline"}function Dq(t,e){return{...t,positionV:{...t.positionV??{},relativeFrom:e?"page":"paragraph"}}}function jq(t){var e;return"page"===(null==(e=null==t?void 0:t.positionV)?void 0:e.relativeFrom)}function Zq(t){return Hq(t,t=>"image"===t.kind)}function Kq(t,e){const a=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e);return Xq(t,t=>({...t,rotation:a}))}function Xq(t,e){const a=Zq(t);if(!a||!ye(a.run))return t;const n=Na(t),{paragraphIndex:r,run:o}=a,i=n.map((t,a)=>a!==r?MA(t):{...MA(t),runs:t.runs.map(t=>t.id===o.id&&"image"===t.kind?{...t,image:e(t.image)}:yA(t))});return rR(t,i,cR(i,Da(t)))}function Yq(t,e){return Xq(t,t=>{const a=e(t.floating);if(a)return{...t,floating:a};const{floating:n,...r}=t;return r})}function Jq(t){const e=Zq(t);if(!e||!ye(e.run))return null;return function(t){var e;if(!sN(t))return"";let a=!1,n="";for(const r of t.runs)a?n+=r.text:"end"===(null==(e=we(r))?void 0:e.kind)&&(a=!0);return n.replace(/^[:\-\s]+/,"")}(Na(t)[e.paragraphIndex+1])}function Qq(t,e,a){const n=Zq(t);if(!n||!ye(n.run))return t;const r=Na(t),o=n.paragraphIndex+1,i=o<r.length&&sN(r[o])?function(t,e,a){var n;const r=(null==(n=t.runs.find(t=>/^\d+$/.test(t.text)))?void 0:n.text)??"1",o=lN(e,a,Number.parseInt(r,10)||1);return o.id=t.id,o}(r[o],e,a):lN(e,a,1),l=function(t){let e=1;return t.map(t=>sN(t)?dN(t,e++):MA(t))}(o<r.length&&sN(r[o])?[...wA(r.slice(0,o)),i,...wA(r.slice(o+1))]:[...wA(r.slice(0,o)),i,...wA(r.slice(o))]),s=l[o]??i;return rR(t,l,iR(_e(s,Qe(s))))}function _q(t,e){const a=Zq(t);if(!a)return t;const n=Na(t),{paragraphIndex:r,offset:o,run:i}=a,l=Ba(n,e.paragraphId);if(l<0)return t;const s=$e(n[l],e),d=l===r&&s>o?s-1:s;if(l===r&&d===o)return t;const c=t=>jV(t,[..._V(t,0,o),..._V(t,o+1,Qe(t))]),h=(t,e)=>$V(t,Math.max(0,Math.min(e,Qe(t))),[Ya("",JV(t,e),ye(i))]),p=n.map((t,e)=>e===r&&e===l?h(c(t),d):e===r?c(t):e===l?h(t,d):wA([t])[0]),u=p[l];return rR(t,p,iR(_e(u,Math.max(0,Math.min(d+1,Qe(u))))))}function $q(t,e,a,n=0){const r=De(Ge(e));if(!a)return r;const o=Zd(e,a,n);return null!==o&&Number.isFinite(o)&&o>0?Math.min(r,o):r}function tP(t){return{insertImageFromFile:async(e,a)=>{t.logger.info(`image insert:start name="${e.name}" type=${e.type} size=${e.size}`);const n=await Wq(e),r=`data:${e.type};base64,${function(t){return btoa(new Uint8Array(t).reduce((t,e)=>t+String.fromCharCode(e),""))}(n)}`,o=new Image;o.src=r,await new Promise(t=>{o.onload=t,o.onerror=t});const i=o.naturalWidth||300,l=o.naturalHeight||300,s=t.state(),d=(null==a?void 0:a.paragraphId)??s.selection.focus.paragraphId,c=$q(t.surfaceRef(),s.document,d,s.activeSectionIndex??0),h=i>c?c/i:1,p=Math.max(24,Math.round(i*h)),u=Math.max(24,Math.round(l*h));t.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${u} maxWidth=${c}`),t.applyTransactionalState(t=>function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i=$V(n,o,[Ya("",JV(n,o),e)]);return rR(a,Na(a).map((t,e)=>e===r?i:MA(t)),iR(_e(i,o+1)))}(a?hE(t,{anchor:a,focus:a}):t,{src:r,width:p,height:u}),{mergeKey:uV})}}}const eP={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"applying-editor-state":[78,88],"stabilizing-layout":[88,98],done:[100,100],error:[100,100]};function aP(t,e){return t.paragraph.runs.map(t=>t.text).join("")[e]??""}function nP(t){return" "===t||"\t"===t||"\n"===t}function rP(t,e,a){if(a.isCollapsed)return null;const n=e.get(t);return void 0===n||n<a.startIndex||n>a.endIndex?null:a.startIndex===a.endIndex?{start:a.startParagraphOffset,end:a.endParagraphOffset}:t===a.start.paragraphId?{start:a.startParagraphOffset,end:Number.POSITIVE_INFINITY}:t===a.end.paragraphId?{start:0,end:a.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function oP(t,e){var a,n,r,o;const i=Da(e),l=[],s=t.surfaceRect,d=new Map(Na(e).map((t,e)=>[t.id,e]));let c=null,h=null;if(!i.isCollapsed&&i.startIndex===i.endIndex&&i.endParagraphOffset-i.startParagraphOffset===1){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.inlineImages.find(e)??t.floatingImages.find(e);if(a&&(c={paragraphId:a.paragraphId,startOffset:a.startOffset,endOffset:a.endOffset,left:a.left-s.left,top:a.top-s.top,width:a.width,height:a.height,rotation:a.rotation??0}),!c){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.floatingTextBoxes.find(e),n=a?void 0:t.inlineTextBoxes.find(e),r=a??n;r&&(h={paragraphId:r.paragraphId,startOffset:r.startOffset,endOffset:r.endOffset,left:r.left-s.left,top:r.top-s.top,width:r.width,height:r.height,rotation:r.rotation??0,floating:Boolean(a)})}}const p=Ea(e),u=xa(e.document,e.selection.anchor.paragraphId,p),f=xa(e.document,e.selection.focus.paragraphId,p);let g=!1;if(u&&f&&u.blockIndex===f.blockIndex&&u.zone===f.zone&&(u.rowIndex!==f.rowIndex||u.cellIndex!==f.cellIndex)){const o=ha(e.document)[p];let i;if(i="header"===u.zone?null==(a=null==o?void 0:o.header)?void 0:a[u.blockIndex]:"footer"===u.zone?null==(n=null==o?void 0:o.footer)?void 0:n[u.blockIndex]:null==(r=null==o?void 0:o.blocks)?void 0:r[u.blockIndex],i&&"table"===i.type){g=!0;const e=Io(i),a=e.find(t=>t.rowIndex===u.rowIndex&&t.cellIndex===u.cellIndex),n=e.find(t=>t.rowIndex===f.rowIndex&&t.cellIndex===f.cellIndex);if(a&&n){const r=Math.min(a.visualRowIndex,n.visualRowIndex),o=Math.max(a.visualRowIndex+a.rowSpan-1,n.visualRowIndex+n.rowSpan-1),d=Math.min(a.visualColumnIndex,n.visualColumnIndex),c=Math.max(a.visualColumnIndex+a.colSpan-1,n.visualColumnIndex+n.colSpan-1),h=new Set;for(const a of t.paragraphs)if(a.tableCell&&a.tableCell.tableId===i.id){const t=e.find(t=>t.rowIndex===a.tableCell.rowIndex&&t.cellIndex===a.tableCell.cellIndex);if(t){const e=t.visualRowIndex<=o&&t.visualRowIndex+t.rowSpan-1>=r,n=t.visualColumnIndex<=c&&t.visualColumnIndex+t.colSpan-1>=d;if(e&&n){const e=`${t.rowIndex}:${t.cellIndex}`;h.has(e)||(h.add(e),l.push({left:a.tableCell.left-s.left,top:a.tableCell.top-s.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(g||i.isCollapsed||c||h))for(const S of t.paragraphs){const t=rP(S.paragraphId,d,i);if(!t)continue;const e=Math.max(t.start,S.startOffset),a=Math.min(t.end,S.endOffset);if(!(e>=a))for(const n of S.lines){let t=Math.max(e,n.startOffset),r=Math.min(a,n.endOffset);for(;t<r&&nP(aP(S,t));)t+=1;for(;r>t&&nP(aP(S,r-1));)r-=1;if(t>=r)continue;const o=n.slots.find(e=>e.offset===t),i=n.slots.find(t=>t.offset===r)??n.slots[n.slots.length-1];if(!o||!i)continue;const d=0===S.startOffset&&n.startOffset===S.startOffset&&n.top>S.top,c=d?S.top:n.top,h=d?n.top+n.height-S.top:n.height;l.push({left:o.left-s.left+1,top:c-s.top,width:Math.max(1,i.left-o.left+1-1),height:h})}}const m=e.selection.focus.paragraphId,v=t.paragraphsById.get(m)??[],b=null==(o=v[0])?void 0:o.paragraph,y=function(t,e){if(0===t.length)return null;const a=t.find(t=>e>=t.startOffset&&e<=t.endOffset)??t[t.length-1],n=a.lines.flatMap(t=>t.slots);if(0===n.length)return{left:a.left,top:a.top,height:Math.max(18,a.height)};let r=n[0],o=Math.abs(e-r.offset);for(const l of n){const t=Math.abs(e-l.offset);t<o&&(r=l,o=t)}const i=a.lines[0];return 0===a.startOffset&&void 0!==i&&e>=i.startOffset&&e<=i.endOffset&&r.top>a.top?{left:r.left,top:a.top,height:r.top+r.height-a.top}:{left:r.left,top:r.top,height:r.height}}(v,b?$e(b,e.selection.focus):e.selection.focus.offset),M=((null==y?void 0:y.left)??s.left)-s.left,x=((null==y?void 0:y.top)??s.top)-s.top,w=Math.max(18,(null==y?void 0:y.height)??28);return{selectionBoxes:l,inputBox:{left:M,top:x,height:w},caretBox:{left:M,top:x,height:w,visible:v.length>0&&!g&&!c&&!h},selectedImageBox:c,selectedTextBoxBox:h}}const iP={composeMeasuredParagraphLines:t=>qs.composeMeasuredParagraphLines(t),resolveRenderedLineHeightPx:(t,e)=>qs.resolveRenderedLineHeightPx(t,e)};function lP(t,e){return((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>(null==t?void 0:t[a])===e)}function sP(t,e){return((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>{const n=null==t?void 0:t[a];return(null==n?void 0:n.blockIndex)===e.blockIndex&&(null==n?void 0:n.offset)===e.offset})}function dP(){let t=new Map,e=new Map;return function(a){const n=new Map,r=e=>null==e?void 0:e.map(e=>{const a=t.get(e.blockId),r=function(t,e){var a,n,r,o,i,l,s,d,c,h,p,u,f,g;return Boolean(t&&t.blockId===e.blockId&&t.sourceBlock===e.sourceBlock&&t.estimatedHeight===e.estimatedHeight&&(null==(a=t.tableSegment)?void 0:a.startRowIndex)===(null==(n=e.tableSegment)?void 0:n.startRowIndex)&&(null==(r=t.tableSegment)?void 0:r.endRowIndex)===(null==(o=e.tableSegment)?void 0:o.endRowIndex)&&(null==(i=t.tableSegment)?void 0:i.repeatedHeaderRowCount)===(null==(l=e.tableSegment)?void 0:l.repeatedHeaderRowCount)&&lP(null==(s=t.tableSegment)?void 0:s.startRowCellBlockStarts,null==(d=e.tableSegment)?void 0:d.startRowCellBlockStarts)&&lP(null==(c=t.tableSegment)?void 0:c.endRowCellBlockEnds,null==(h=e.tableSegment)?void 0:h.endRowCellBlockEnds)&&sP(null==(p=t.tableSegment)?void 0:p.startRowCellBlockPositions,null==(u=e.tableSegment)?void 0:u.startRowCellBlockPositions)&&sP(null==(f=t.tableSegment)?void 0:f.endRowCellBlockPositions,null==(g=e.tableSegment)?void 0:g.endRowCellBlockPositions)&&function(t,e){return t===e||!(!t||!e)&&t.text===e.text&&t.startOffset===e.startOffset&&t.endOffset===e.endOffset&&t.lines.length===e.lines.length&&e.lines.every((e,a)=>{const n=t.lines[a];return void 0!==n&&n.startOffset===e.startOffset&&n.endOffset===e.endOffset&&n.top===e.top&&n.height===e.height})}(t.layout,e.layout))}(a,e)?a:e;return n.set(r.blockId,r),r}),o=a.pages.map(t=>{const a={...t,blocks:r(t.blocks)??[],headerBlocks:r(t.headerBlocks),footerBlocks:r(t.footerBlocks),footnoteBlocks:r(t.footnoteBlocks)},n=e.get(a.id);return function(t,e){const a=Boolean(t&&t.pageSettings.width===e.pageSettings.width&&t.pageSettings.height===e.pageSettings.height&&t.pageSettings.orientation===e.pageSettings.orientation&&t.pageSettings.margins.top===e.pageSettings.margins.top&&t.pageSettings.margins.right===e.pageSettings.margins.right&&t.pageSettings.margins.bottom===e.pageSettings.margins.bottom&&t.pageSettings.margins.left===e.pageSettings.margins.left&&t.pageSettings.margins.header===e.pageSettings.margins.header&&t.pageSettings.margins.footer===e.pageSettings.margins.footer&&t.pageSettings.margins.gutter===e.pageSettings.margins.gutter);if(!t||t.id!==e.id||t.index!==e.index||t.height!==e.height||t.maxHeight!==e.maxHeight||!a||t.bodyTop!==e.bodyTop||t.bodyBottom!==e.bodyBottom||t.headerTop!==e.headerTop||t.footerTop!==e.footerTop||t.footnoteTop!==e.footnoteTop||t.footnoteSeparatorTop!==e.footnoteSeparatorTop)return!1;const n=(t,e)=>((null==t?void 0:t.length)??0)===((null==e?void 0:e.length)??0)&&(e??[]).every((e,a)=>(null==t?void 0:t[a])===e);return n(t.blocks,e.blocks)&&n(t.headerBlocks,e.headerBlocks)&&n(t.footerBlocks,e.footerBlocks)&&n(t.footnoteBlocks,e.footnoteBlocks)&&(r=t.footnoteReferenceIds,o=e.footnoteReferenceIds,((null==r?void 0:r.length)??0)===((null==o?void 0:o.length)??0)&&(o??[]).every((t,e)=>(null==r?void 0:r[e])===t));var r,o}(n,a)?n:a});return t=n,e=new Map(o.map(t=>[t.id,t])),{pages:o}}}function cP(t,e){if(0===e.length)return t;let a;for(const n of e)Object.prototype.hasOwnProperty.call(t,n)&&(a??(a={...t}),delete a[n]);return a??t}function hP(t){const[e,a]=y({}),[n,r]=y({}),[o,i]=y({left:0,top:0,height:28}),[l,s]=y([]),[d,c]=y([]),[h,p]=y(null),[u,f]=y(null),[g,m]=y({left:0,top:0,height:28,visible:!1}),[v,b]=y(null),M=dP(),S=w(()=>(ih(),M(nh(t.state.document,void 0,e(),n(),{measurer:iP})))),A=ux();let C=0;const T=(e="selection")=>{var a;const n=t.surfaceRef();if(!n)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const r=A.getCanvasLayoutSnapshot({surface:n,state:t.state,documentLayout:S(),zoomFactor:null==(a=t.zoomFactor)?void 0:a.call(t)});if(!r)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const o=oP(r,t.state);s(o.selectionBoxes),c(function(t,e){const a=e.document.comments;if(!a||0===a.order.length)return[];const n=t.surfaceRect,r=new Map(Na(e).map((t,e)=>[t.id,e])),o=[];for(const i of a.order){const e=a.items[i];if(!(null==e?void 0:e.start)||!(null==e?void 0:e.end))continue;const l=r.get(e.start.paragraphId),s=r.get(e.end.paragraphId);if(void 0!==l&&void 0!==s)for(const a of t.paragraphs){const t=r.get(a.paragraphId);if(void 0===t||t<l||t>s)continue;const d=t===l?e.start.offset:0,c=t===s?e.end.offset:Number.POSITIVE_INFINITY,h=Math.max(d,a.startOffset),p=Math.min(c,a.endOffset);if(!(h>=p))for(const e of a.lines){const t=Math.max(h,e.startOffset),a=Math.min(p,e.endOffset);if(t>=a)continue;const r=e.slots.find(e=>e.offset===t),l=e.slots.find(t=>t.offset===a)??e.slots[e.slots.length-1];r&&l&&o.push({commentId:i,left:r.left-n.left,top:e.top-n.top,width:Math.max(1,l.left-r.left),height:e.height})}}}return o}(r,t.state)),p(o.selectedImageBox),f(o.selectedTextBoxBox),i(o.inputBox),m(o.caretBox)},k=(t="selection")=>{const e=++C;queueMicrotask(()=>{e===C&&T(t)})};x(()=>{t.state.selection.anchor.paragraphId,t.state.selection.anchor.runId,t.state.selection.anchor.offset,t.state.selection.focus.paragraphId,t.state.selection.focus.runId,t.state.selection.focus.offset,k("selection")}),x(()=>{var e;t.state.document,t.state.activeSectionIndex,t.state.activeZone,(null==(e=t.isImporting)?void 0:e.call(t))||k("content-change")}),x(()=>{const e=t.viewportRef();if(!e)return;const a=()=>{k("scroll")},n=()=>{k("resize")};e.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",n),I(()=>{e.removeEventListener("scroll",a),window.removeEventListener("resize",n)})});return{measuredBlockHeights:e,measuredParagraphLayouts:n,documentLayout:S,canvasSnapshotProvider:A,inputBox:o,selectionBoxes:l,commentHighlights:d,selectedImageBox:h,selectedTextBoxBox:u,caretBox:g,preferredColumnX:v,setPreferredColumnX:b,clearPreferredColumn:()=>b(null),requestInputBoxSync:k,scheduleDeferredLayoutMeasurement:(t,e={})=>(e.paragraphIds&&e.paragraphIds.length>0&&(r(t=>cP(t,e.paragraphIds??[])),lh()),k(t),e.resolveWhenDone?Promise.resolve():null),stabilizeLayoutAfterImport:async()=>{a({}),r({}),lh(),await new Promise(t=>{var e;e=()=>t(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16)}),k("import")},syncMeasuredLayoutMetrics:(t="content-change")=>(k(t),!1),syncInputBox:T,setMeasuredBlockHeights:a,setMeasuredParagraphLayouts:r,applyInvalidation:e=>{var n,o;if(!(null==(n=t.isImporting)?void 0:n.call(t))){if(e.dirtyAll||e.structureChanged)a({}),r({}),lh();else if(((null==(o=e.dirtyParagraphIds)?void 0:o.length)??0)>0){const t=e.dirtyParagraphIds??[];r(e=>cP(e,t)),lh()}k("content-change")}},onCleanupHook:()=>{C+=1,A.clear()}}}function pP(t){return{performUndo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.undoStack.length?null:{history:{undoStack:a.undoStack.slice(0,-1),redoStack:[...a.redoStack,n],lastTransactionMeta:null},nextState:a.undoStack[a.undoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},performRedo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.redoStack.length?null:{history:{undoStack:[...a.undoStack,n],redoStack:a.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:a.redoStack[a.redoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},moveSelectedImageByParagraph:e=>{const a=t.imageOps().getSelectedImageInfo(t.state());if(!a)return!1;const n=Na(t.state()),r=n.findIndex(t=>t.id===a.paragraph.id);if(r<0)return!1;const o=r+e;if(o<0||o>=n.length){const a=((t,e)=>{const a=ca(t.document),n=Math.max(0,Math.min(Ea(t),a.length-1)),r=La(t),o=a[n];if(!o)return t;const i=[...a],l={...o},s=Ja("");if("header"===r){const t=[...o.header??[]];e<0?t.unshift(s):t.push(s),l.header=t}else if("footer"===r){const t=[...o.footer??[]];e<0?t.unshift(s):t.push(s),l.footer=t}else{const t=[...o.blocks];e<0?t.unshift(s):t.push(s),l.blocks=t}return i[n]=l,{...t,document:{...t.document,sections:i}}})(t.state(),e),n=Na(a),r=e<0?n[0]:n[n.length-1];if(!r)return!1;const o=_e(r,e<0?Qe(r):0);return t.applyTransactionalState(()=>_q(a,o),{mergeKey:gV}),t.focusInput(),!0}const i=n[o],l=e<0?Qe(i):0;return t.applyTransactionalState(t=>_q(t,_e(i,l)),{mergeKey:gV}),t.focusInput(),!0},applySelectionPreservingStructure:e=>{var a;const n=t.stateSnapshot();t.applyHistoryState({...n,document:{...n.document,sections:null==(a=n.document.sections)?void 0:a.map(CA)},selection:{anchor:{...e.anchor},focus:{...e.focus}}})}}}function uP(t={}){const e=t.dbName??"oasis-editor-db",a=t.storeName??"documents",n=t.key??"current-document";let r=null;async function o(){return r||(r=await function(t){return new Promise((e,a)=>{const n=indexedDB.open(t.name,t.version);n.onerror=()=>{var t;a(new Error(`Failed to open IndexedDB: ${null==(t=n.error)?void 0:t.message}`))},n.onsuccess=()=>{e(n.result)},n.onupgradeneeded=e=>{const a=n.result;t.onUpgrade(a,e.oldVersion,e.newVersion)}})}({name:e,version:1,onUpgrade:t=>{t.objectStoreNames.contains(a)||t.createObjectStore(a)}}),r)}return{async saveDocument(t){await function(t,e,a,n){return new Promise((r,o)=>{try{const i=t.transaction([e],"readwrite"),l=i.objectStore(e).put(n,a);l.onerror=()=>{var t;o(new Error(`Failed to put item in ${e}: ${null==(t=l.error)?void 0:t.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{var t;o(new Error(`Transaction failed putting item in ${e}: ${null==(t=i.error)?void 0:t.message}`))}}catch(i){o(i)}})}(await o(),a,n,t)},loadDocument:async()=>function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readonly").objectStore(e).get(a);o.onerror=()=>{var t;r(new Error(`Failed to get item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n(o.result??null)}}catch(o){r(o)}})}(await o(),a,n),async clearDocument(){await function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readwrite"),i=o.objectStore(e).delete(a);i.onerror=()=>{var t;r(new Error(`Failed to delete item from ${e}: ${null==(t=i.error)?void 0:t.message}`))},o.oncomplete=()=>{n()},o.onabort=o.onerror=()=>{var t;r(new Error(`Transaction failed deleting item from ${e}: ${null==(t=o.error)?void 0:t.message}`))}}catch(o){r(o)}})}(await o(),a,n)},close(){r&&(r.close(),r=null)}}}function fP(t){const[e,a]=y([]),[n,r]=y([]);let o={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{a(o.undoStack),r(o.redoStack)};return{undoStack:e,redoStack:n,applyTransactionalState:(e,a)=>{const n=t.stateSnapshot(),r=ud("txn:produce",()=>e(n),0);if(r===n)return;o=function(t,e,a,n,r=Date.now()){var o;return{undoStack:void 0!==(null==n?void 0:n.mergeKey)&&(null==(o=t.lastTransactionMeta)?void 0:o.mergeKey)===n.mergeKey&&r-t.lastTransactionMeta.timestamp<1e3?t.undoStack:[...t.undoStack,e],redoStack:[],lastTransactionMeta:(null==n?void 0:n.mergeKey)?{mergeKey:n.mergeKey,timestamp:r}:null}}(o,n,0,a),i();const l=ud("txn:invalidate",()=>function(t,e){var a,n,r,o,i,l;if(t===e||t.document===e.document)return{};const s=t=>ca(t.document).map(t=>[...(t.header??[]).map(t=>t.id),...t.blocks.map(t=>t.id),...(t.footer??[]).map(t=>t.id)].join("|")).join("||");if(s(t)!==s(e))return{dirtyAll:!0,structureChanged:!0};const d=Na(t),c=Na(e),h=new Map;for(const u of d)h.set(u.id,u);const p=[];for(const u of c){const t=h.get(u.id);if(!t){p.push(u.id);continue}if(t===u)continue;if(t.runs.length!==u.runs.length){p.push(u.id);continue}let e=!1;for(let s=0;s<t.runs.length;s+=1){const d=t.runs[s],c=u.runs[s];if(d===c)continue;if(d.id!==c.id||d.text!==c.text){e=!0;break}const h=ye(d),p=ye(c);if(Boolean(h)!==Boolean(p)||((null==h?void 0:h.width)??-1)!==((null==p?void 0:p.width)??-1)||((null==h?void 0:h.height)??-1)!==((null==p?void 0:p.height)??-1)||((null==(a=null==h?void 0:h.floating)?void 0:a.wrap)??"")!==((null==(n=null==p?void 0:p.floating)?void 0:n.wrap)??"")||Boolean(null==(r=null==h?void 0:h.floating)?void 0:r.behindDoc)!==Boolean(null==(o=null==p?void 0:p.floating)?void 0:o.behindDoc)||((null==(i=null==h?void 0:h.wrapPolygon)?void 0:i.length)??-1)!==((null==(l=null==p?void 0:p.wrapPolygon)?void 0:l.length)??-1)){e=!0;break}}e&&p.push(u.id)}return{dirtyParagraphIds:p}}(n,r),0);t.applyLayoutInvalidation(l),ud("txn:setState",()=>t.commitState(r),0)},applyHistoryState:e=>{t.commitState(t.cloneState(e))},resetTransactionGrouping:()=>{var t;t=o,o={...t,lastTransactionMeta:null}},updateHistoryState:t=>{o=t(o),i()},getHistoryState:()=>o,clearHistory:()=>{o={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}function gP(t){x(()=>{var e,a;if(t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone,a=t.state,aV&&(oV={anchor:{paragraphId:a.selection.anchor.paragraphId,runId:a.selection.anchor.runId,offset:a.selection.anchor.offset},focus:{paragraphId:a.selection.focus.paragraphId,runId:a.selection.focus.runId,offset:a.selection.focus.offset},activeZone:a.activeZone??"main",activeSectionIndex:a.activeSectionIndex??0}),t.isImportInProgress())return;const n=t.cloneState(t.getStateSnapshot());null==(e=t.getOnStateChange())||e(n),t.emit("change",n),t.emit("documentChange",n.document),t.emit("selectionChange",n.selection)})}function mP(t){const{documentOptions:e,logger:a,runtimeClient:n,state:r,commitState:o,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:d,focusInput:c,surfaceRef:h,viewportRef:p,zoomFactor:u,getImageOps:f}=t,g=function(t){const[e,a]=y(null),n=(t,e)=>{const[a,n]=eP[t];return void 0!==e&&Number.isFinite(e)?Math.round(10*(a+(n-a)*Math.min(1,Math.max(0,e))))/10:n},r=Fq({applyState:t.applyState,stabilizeLayoutAfterImport:t.stabilizeLayoutAfterImport,resetEditorChromeState:t.resetEditorChromeState,focusInput:t.focusInput,setImportPhase:(t,e)=>{a({phase:t,progress:n(t,e),subProgress:e})},clearImportProgressSoon:()=>{globalThis.setTimeout(()=>{a(t=>"done"===(null==t?void 0:t.phase)||"error"===(null==t?void 0:t.phase)?null:t)},1200)},now:()=>performance.now(),logger:t.logger}),o=tP({state:t.state,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,logger:t.logger}),i=Pq({document:()=>t.state().document,focusInput:t.focusInput}),l=async(t,e)=>{await o.insertImageFromFile(t,e)};return{importProgress:e,handleImportFile:async e=>{t.isReadOnly()||await r.handleImportFile(e)},handleExportDocx:async()=>{await i.handleExportDocx()},handleExportPdf:async()=>{await i.handleExportPdf()},insertImageFromFile:l,handleInsertImage:async e=>{t.isReadOnly()||e&&(await l(e),t.focusInput())}}}({state:()=>r,applyState:l,applyTransactionalState:(t,e)=>D(t,e),isReadOnly:d,surfaceRef:()=>h()??null,stabilizeLayoutAfterImport:async()=>{await N()},resetEditorChromeState:()=>Q(),focusInput:c,logger:a}),m=()=>{var t,e;return"done"!==(null==(t=g.importProgress())?void 0:t.phase)&&"error"!==(null==(e=g.importProgress())?void 0:e.phase)&&null!==g.importProgress()},{measuredBlockHeights:v,measuredParagraphLayouts:b,documentLayout:M,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:T,selectedImageBox:k,selectedTextBoxBox:V,caretBox:R,preferredColumnX:E,setPreferredColumnX:L,clearPreferredColumn:z,stabilizeLayoutAfterImport:N,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:q,applyInvalidation:P,onCleanupHook:W}=hP({state:r,surfaceRef:h,viewportRef:p,isImporting:m,zoomFactor:u}),B=uP({key:e().persistenceKey}),{status:F}=function(t,e,a){const[n,r]=y("Initial"),[o,i]=y(!1),l=()=>a.enabled??!1,s=a.persistence,d=On(async t=>{var e;if(l()&&o()){r("Saving...");try{const e=JSON.parse(JSON.stringify(oe(t)));await s.saveDocument(e),r("Saved")}catch(n){null==(e=a.logger)||e.error("persistence:autosave failed",n),r("Error")}}},1e3);return x(A(()=>t.document,t=>{l()&&o()&&d(t)},{defer:!0})),C(async()=>{var t;if(!l())return i(!0),void r("Saved");try{const t=await s.loadDocument();t&&e(t)}catch(n){null==(t=a.logger)||t.error("persistence:load failed",n)}finally{i(!0),r("Saved")}}),{status:n}}(r,t=>{a.info("persistence:loaded",{docId:t.id});const e=rn(t);o(e),Q()},{enabled:e().persistenceEnabled??!1,persistence:e().persistence??B,logger:a}),H=fP({stateSnapshot:i,commitState:o,cloneState:s,applyLayoutInvalidation:P}),{undoStack:U,redoStack:G,applyTransactionalState:D,applyHistoryState:j,resetTransactionGrouping:Z,updateHistoryState:K,getHistoryState:X,clearHistory:Y}=H,J=pP({state:()=>r,stateSnapshot:i,applyHistoryState:j,applyTransactionalState:D,focusInput:c,clearPreferredColumn:z,imageOps:f,updateHistoryState:K,getHistoryState:X}),Q=()=>{z(),O({}),q({}),lh(),w.clear(),Y()};return gP({state:r,isImportInProgress:m,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>e().onStateChange,emit:n.emit}),{docIO:g,isImportInProgress:m,measuredBlockHeights:v,measuredParagraphLayouts:b,documentLayout:M,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:T,selectedImageBox:k,selectedTextBoxBox:V,caretBox:R,preferredColumnX:E,setPreferredColumnX:L,clearPreferredColumn:z,stabilizeLayoutAfterImport:N,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:q,applyLayoutInvalidation:P,onCleanupHook:W,fallbackPersistence:B,persistenceStatus:F,undoStack:U,redoStack:G,applyTransactionalState:D,applyHistoryState:j,resetTransactionGrouping:Z,updateHistoryState:K,getHistoryState:X,clearHistory:Y,historyActions:J,resetEditorChromeState:Q}}function vP(t){return Hq(t,t=>"textBox"===t.kind)}function bP(t,e){const a=vP(t);if(!a||!Me(a.run))return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),{paragraphIndex:r,run:o}=a,i=Na(t).map((t,e)=>e!==r?MA(t):{...MA(t),runs:t.runs.map(t=>t.id===o.id&&"textBox"===t.kind?{...t,textBox:{...t.textBox,rotation:n}}:yA(t))});return rR(t,i,cR(i,Da(t)))}function yP(t,e){const a=vP(t);if(!a||!Me(a.run))return t;const{paragraphIndex:n,run:r}=a,o=Na(t).map((t,a)=>a!==n?MA(t):{...MA(t),runs:t.runs.map(t=>{if(t.id!==r.id||"textBox"!==t.kind)return yA(t);const a=e(t.textBox.floating),n={...t.textBox};return a?n.floating=a:delete n.floating,{...t,textBox:n}})});return rR(t,o,cR(o,Da(t)))}function MP(t,e,a,n={}){const r=vP(t),o=r&&Me(r.run);if(!r||!o)return t;const i=n.handleDirection??"se",l=i.includes("n")||i.includes("s"),s=i.includes("w"),d=i.includes("n"),c=Math.max(24,Math.round(e)),h=Math.max(24,Math.round(a)),{paragraphIndex:p,run:u}=r,f=c-o.width,g=h-o.height,m=Na(t).map((t,e)=>e!==p?MA(t):{...MA(t),runs:t.runs.map(t=>{var e;if(t.id!==u.id||"textBox"!==t.kind)return yA(t);const a=t.textBox,n={...a,width:c,height:h};return l&&(null==(e=a.body)?void 0:e.autoFit)&&(n.body={...a.body,autoFit:!1}),a.floating&&(n.floating=function(t,e,a,n,r){let o=t;if(n&&0!==e){const a=t.positionH;(null==a?void 0:a.align)||(o={...o,positionH:{...a??{},offset:((null==a?void 0:a.offset)??0)-e*Le}})}if(r&&0!==a){const t=o.positionV;(null==t?void 0:t.align)||(o={...o,positionV:{...t??{},offset:((null==t?void 0:t.offset)??0)-a*Le}})}return o}(a.floating,f,g,s,d)),{...t,textBox:n}})});return rR(t,m,cR(m,Da(t)))}const xP=t=>t.cells.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),wP=t=>t.rows.reduce((t,e)=>Math.max(t,xP(e)),0),SP=(t,e)=>{let a=0;for(const n of t.cells){const t=Math.max(1,n.colSpan??1);if(e>=a&&e<a+t)return n;a+=t}return null},AP=t=>{for(const e of t.rows)for(const t of e.cells){if("continue"===t.vMerge)continue;const e=t.blocks[0];if(e)return e}return null},CP=(t,e,a)=>{const n=ha(t);for(const r of n){const t=[...r.header||[],...r.blocks,...r.footer||[]];for(const n of t){if("table"!==n.type)continue;const t=n.rows.flatMap(t=>t.cells.filter(t=>"continue"!==t.vMerge&&t.blocks.length>0)),r=t.findIndex(t=>t.blocks.some(t=>t.id===e));if(-1===r)continue;const o=t[r+a],i=null==o?void 0:o.blocks[0];return i?_e(i,0):null}}return null},IP=(t,e,a="main")=>{const n=Ea(t),r=ca(t.document),o=Math.max(0,Math.min(n,r.length-1)),i=r[o];if(!i)return t;const l=[...r];return l[o]="header"===a?{...i,header:e}:"footer"===a?{...i,footer:e}:{...i,blocks:e},{...t,document:{...t.document,sections:l}}};function TP(t,e){const a=xa(t.document,t.selection.focus.paragraphId,Ea(t));if(!a)return null;const n=e(t,a.zone).map(AA),r=n[a.blockIndex];return r&&"table"===r.type?{tableBlock:r,location:a,targetBlocks:n}:null}function kP(t,e,a,n){const r=IP(t,e,a);return n?{...r,selection:{anchor:_e(n,0),focus:_e(n,0)}}:r}function VP(t,e){return t.visualRowIndex!==e.visualRowIndex?t.visualRowIndex-e.visualRowIndex:t.visualColumnIndex!==e.visualColumnIndex?t.visualColumnIndex-e.visualColumnIndex:0}function RP(t,e){const a=t.selection,n=Ea(t),r=xa(t.document,a.anchor.paragraphId,n),o=xa(t.document,a.focus.paragraphId,n);if(!r||!o||r.blockIndex!==o.blockIndex||r.zone!==o.zone)return null;const i=e.getTargetBlocks(t,r.zone)[r.blockIndex];if(!i||"table"!==i.type)return null;const l=Io(i),s=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),d=l.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex);return s&&d?{anchorLocation:r,focusLocation:o,anchorCell:s,focusCell:d,tableBlock:i,tableLayout:l}:null}function EP(t){const e=(t,e)=>{const a=ca(t.document),n=Ea(t),r=a[Math.max(0,Math.min(n,a.length-1))];return r?"header"===e?r.header||[]:"footer"===e?r.footer||[]:r.blocks:[]},{resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}=function(t){return{resolveTableCellRangeSelection:e=>{var a,n,r,o,i;const l=e.selection,s=RP(e,t);if(!s||s.anchorLocation.rowIndex===s.focusLocation.rowIndex&&s.anchorLocation.cellIndex===s.focusLocation.cellIndex)return null==(a=t.logger)||a.debug(`resolveTableCellRangeSelection: no expansion (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId})`),null;const d=Math.min(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),c=Math.max(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),h=Math.min(s.anchorLocation.cellIndex,s.focusLocation.cellIndex),p=Math.max(s.anchorLocation.cellIndex,s.focusLocation.cellIndex);null==(n=t.logger)||n.info(`resolveTableCellRangeSelection: expanding r${s.anchorLocation.rowIndex}:c${s.anchorLocation.cellIndex}->r${s.focusLocation.rowIndex}:c${s.focusLocation.cellIndex} (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId}) range=[rows ${d}..${c}, cells ${h}..${p}]`);const u=VP(s.anchorCell,s.focusCell)<=0?s.anchorLocation:s.focusLocation,f=VP(s.anchorCell,s.focusCell)<=0?s.focusLocation:s.anchorLocation,g=null==(o=null==(r=s.tableBlock.rows[u.rowIndex])?void 0:r.cells[u.cellIndex])?void 0:o.blocks[0],m=null==(i=s.tableBlock.rows[f.rowIndex])?void 0:i.cells[f.cellIndex],v=null==m?void 0:m.blocks[m.blocks.length-1];return g&&v?{anchor:_e(g,0),focus:_e(v,Je(v).length)}:null},resolveSelectedTableCells:e=>{const a=RP(e,t);if(!a)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex+a.anchorCell.rowSpan-1,a.focusCell.visualRowIndex+a.focusCell.rowSpan-1),o=Math.min(a.anchorCell.visualColumnIndex,a.focusCell.visualColumnIndex),i=Math.max(a.anchorCell.visualColumnIndex+a.anchorCell.colSpan-1,a.focusCell.visualColumnIndex+a.focusCell.colSpan-1),l=a.tableLayout.filter(t=>t.visualRowIndex<=r&&t.visualRowIndex+t.rowSpan-1>=n&&t.visualColumnIndex<=i&&t.visualColumnIndex+t.colSpan-1>=o);return{blockIndex:a.anchorLocation.blockIndex,cells:l,zone:a.anchorLocation.zone}},resolveHorizontalTableCellRange:e=>{const a=RP(e,t);if(!a||a.anchorCell.visualRowIndex!==a.focusCell.visualRowIndex)return null;const n=VP(a.anchorCell,a.focusCell);if(0===n)return null;const r=n<=0?a.anchorLocation:a.focusLocation,o=n<=0?a.focusLocation:a.anchorLocation;return{blockIndex:a.anchorLocation.blockIndex,rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:o.cellIndex,zone:a.anchorLocation.zone}},resolveVerticalTableCellRange:e=>{const a=RP(e,t);if(!a||a.anchorLocation.cellIndex!==a.focusLocation.cellIndex)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex);return n===r?null:{blockIndex:a.anchorLocation.blockIndex,startRowIndex:n,endRowIndex:r,cellIndex:a.anchorLocation.cellIndex,zone:a.anchorLocation.zone}}}}({getTargetBlocks:e,logger:t.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);return Boolean(a&&a.endCellIndex>a.startCellIndex)},a=e=>{var a;const n=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.colSpan)??1)>1)},n=e=>{var a;const n=t.resolveVerticalTableCellRange(e);if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=null==(a=r.rows[t])?void 0:a.cells[n.cellIndex];if(!e||"continue"===e.vMerge||1!==e.blocks.length)return!1}return!0},r=e=>{var a;const n=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.rowSpan)??1)>1&&"restart"===(null==o?void 0:o.vMerge))};return{canMergeSelectedTableCells:e,canSplitSelectedTableCell:a,canMergeSelectedTableRows:n,canMergeSelectedTable:t=>e(t)||n(t),canSplitSelectedTableCellVertically:r,canSplitSelectedTable:t=>a(t)||r(t),canEditSelectedTableRow:e=>{const a=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return Boolean(n&&"table"===n.type)},canEditSelectedTableColumn:e=>{const a=xa(e.document,e.selection.focus.paragraphId,Ea(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return!(!n||"table"!==n.type)&&wP(n)>1}}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}),{mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y}=function(t){const e=t=>({...t,style:t.style?{...t.style}:void 0,conditionalStyle:t.conditionalStyle?{...t.conditionalStyle}:void 0,mergeRevisionState:void 0,blocks:t.blocks.map(t=>AA(t))}),a=a=>{const n=t.resolveHorizontalTableCellRange(a);if(!n)return a;const r=t.getTargetBlocks(a,n.zone).map(AA),o=r[n.blockIndex];if(!o||"table"!==o.type)return a;const i=o.rows[n.rowIndex];if(!i)return a;const l=i.cells.slice(n.startCellIndex,n.endCellIndex+1);if(l.length<2)return a;const s=a.trackChangesEnabled?VR():void 0,d={...l[0],colSpan:l.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),blocks:l.flatMap(t=>t.blocks.map(t=>AA(t))),...s?{style:{...l[0].style??{},revision:{...s,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:s.id,orientation:"horizontal",currentCellCount:1,previousCells:l.map(e)}}:{}};i.cells.splice(n.startCellIndex,l.length,d);const c=d.blocks[0];return c?kP(a,r,n.zone,c):a},n=a=>{const n=t.resolveVerticalTableCellRange(a);if(!n)return a;const r=t.getTargetBlocks(a,n.zone).map(AA),o=r[n.blockIndex];if(!o||"table"!==o.type)return a;const i=[];for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=o.rows[t],r=null==e?void 0:e.cells[n.cellIndex];if(!e||!r||"continue"===r.vMerge||1!==r.blocks.length)return a;i.push(r)}if(i.length<2)return a;const l=Math.max(1,i[0].colSpan??1);if(!i.every(t=>Math.max(1,t.colSpan??1)===l))return a;const s=a.trackChangesEnabled?VR():void 0,d={...i[0],rowSpan:i.length,vMerge:"restart",blocks:i.flatMap(t=>t.blocks.map(t=>AA(t))),...s?{style:{...i[0].style??{},revision:{...s,type:"merge",previous:{colSpan:i[0].colSpan,rowSpan:i[0].rowSpan,vMerge:i[0].vMerge}}},mergeRevisionState:{revisionId:s.id,orientation:"vertical",currentCellCount:1,previousCells:i.map(e)}}:{}};o.rows[n.startRowIndex].cells[n.cellIndex]=d;for(let t=n.startRowIndex+1;t<=n.endRowIndex;t+=1){const e=_a([Ja("")],l);e.blocks=[],e.vMerge="continue",o.rows[t].cells[n.cellIndex]=e}const c=d.blocks[0];return c?kP(a,r,n.zone,c):a},r=a=>{var n;const r=TP(a,t.getTargetBlocks);if(!r)return a;const{tableBlock:o,location:i,targetBlocks:l}=r,s=null==(n=o.rows[i.rowIndex])?void 0:n.cells[i.cellIndex],d=Math.max(1,(null==s?void 0:s.rowSpan)??1);if(!s||d<=1||"restart"!==s.vMerge)return a;const c=e(s),h=a.trackChangesEnabled?VR():void 0,p=Math.max(1,s.colSpan??1);s.rowSpan=void 0,s.vMerge=void 0,h&&(s.style={...s.style??{},revision:{...h,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},s.mergeRevisionState={revisionId:h.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:d-1},(t,a)=>{var n;const r=null==(n=o.rows[i.rowIndex+a+1])?void 0:n.cells[i.cellIndex];return r?e(r):_a([],p)})]});for(let t=1;t<d;t+=1){const e=o.rows[i.rowIndex+t];if(!e)break;const a=_a([Ja("")],p);e.cells[i.cellIndex]=a}const u=s.blocks[0];return u?kP(a,l,i.zone,u):a},o=a=>{var n;const r=TP(a,t.getTargetBlocks);if(!r)return a;const{tableBlock:o,location:i,targetBlocks:l}=r,s=o.rows[i.rowIndex],d=null==s?void 0:s.cells[i.cellIndex],c=Math.max(1,(null==d?void 0:d.colSpan)??1);if(!s||!d||c<=1)return a;const h=e(d),p=a.trackChangesEnabled?VR():void 0,u=[{...d,colSpan:1,blocks:d.blocks.map(t=>AA(t)),...p?{style:{...d.style??{},revision:{...p,type:"merge",previous:{colSpan:h.colSpan,rowSpan:h.rowSpan,vMerge:h.vMerge}}},mergeRevisionState:{revisionId:p.id,orientation:"horizontal",currentCellCount:c,previousCells:[h]}}:{}},...Array.from({length:c-1},()=>_a([Ja("")]))];s.cells.splice(i.cellIndex,1,...u);const f=null==(n=u[0])?void 0:n.blocks[0];return f?kP(a,l,i.zone,f):a};return{mergeSelectedTableCells:a,mergeSelectedTableRows:n,mergeSelectedTable:e=>t.canMergeSelectedTableCells(e)?a(e):t.canMergeSelectedTableRows(e)?n(e):e,splitSelectedTableCellVertically:r,splitSelectedTableCell:o,splitSelectedTable:e=>t.canSplitSelectedTableCellVertically(e)?r(e):t.canSplitSelectedTableCell(e)?o(e):e}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:c}),{insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S}=function(t){return{insertSelectedTableRow:(e,a)=>{var n,r;const o=TP(e,t.getTargetBlocks);if(!o)return e;const{tableBlock:i,location:l,targetBlocks:s}=o,d=i.rows[l.rowIndex];if(!d)return e;const c=Math.max(0,Math.min(i.rows.length,l.rowIndex+(a>0?1:0)));let h;if(i.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge))){const t=Io(i),a=t.find(t=>t.rowIndex===l.rowIndex&&t.cellIndex===l.cellIndex),r=t.filter(t=>t.rowIndex===l.rowIndex);h=$a((r.length>0?r:t.filter(t=>t.rowIndex===Math.max(0,l.rowIndex-1))).map(e=>{const a=t.find(t=>t.visualColumnIndex===e.visualColumnIndex&&t.visualRowIndex<c&&t.visualRowIndex+t.rowSpan>c);if(a){a.cell.rowSpan=Math.max(1,a.cell.rowSpan??1)+1,a.cell.vMerge="restart";const t=_a([Ja("")],e.colSpan);return t.blocks=[],t.vMerge="continue",t}return _a([Ja("")],e.colSpan)})),e.trackChangesEnabled&&(h.style={...h.style??{},revision:{...VR(),type:"insert"}}),i.rows.splice(c,0,h);const o=(null==a?void 0:a.visualColumnIndex)??l.cellIndex,d=SP(h,o),p=(null==d?void 0:d.blocks[0])??(null==(n=h.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:n.blocks[0])??AP(i);return kP(e,s,l.zone,p)}h=$a(d.cells.map(t=>_a([Ja("")],Math.max(1,t.colSpan??1)))),e.trackChangesEnabled&&(h.style={...h.style??{},revision:{...VR(),type:"insert"}}),i.rows.splice(c,0,h);const p=h.cells[Math.min(l.cellIndex,h.cells.length-1)],u=(null==p?void 0:p.blocks[0])??(null==(r=h.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:r.blocks[0])??AP(i);return kP(e,s,l.zone,u)},deleteSelectedTableRow:e=>{const a=TP(e,t.getTargetBlocks);if(!a)return e;const{tableBlock:n,location:r,targetBlocks:o}=a;if(n.rows.length<=1&&!e.trackChangesEnabled)return e;const i=n.rows[r.rowIndex];if(!i)return e;if(e.trackChangesEnabled)return i.style={...i.style??{},revision:{...VR(),type:"delete"}},kP(e,o,r.zone,null);if(i.cells.some(t=>"continue"!==t.vMerge&&Math.max(1,t.rowSpan??1)>1))return e;const l=n.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge)),s=l?Io(n).find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex):null;if(l){const t=Io(n);for(const e of t)e.visualRowIndex<r.rowIndex&&e.visualRowIndex+e.rowSpan>r.rowIndex&&(e.cell.rowSpan=Math.max(1,e.cell.rowSpan??1)-1,e.cell.rowSpan<=1?(e.cell.rowSpan=void 0,e.cell.vMerge=void 0):e.cell.vMerge="restart")}n.rows.splice(r.rowIndex,1);const d=n.rows[Math.min(r.rowIndex,n.rows.length-1)],c=d?SP(d,Math.min((null==s?void 0:s.visualColumnIndex)??r.cellIndex,Math.max(0,xP(d)-1))):null,h=(null==c?void 0:c.blocks[0])??AP(n);return kP(e,o,r.zone,h)},insertSelectedTableColumn:(e,a)=>{var n;const r=TP(e,t.getTargetBlocks);if(!r)return e;const{tableBlock:o,location:i,targetBlocks:l}=r;if(o.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=Io(o).find(t=>t.rowIndex===i.rowIndex&&t.cellIndex===i.cellIndex),n=((null==t?void 0:t.visualColumnIndex)??i.cellIndex)+(a>0?Math.max(1,(null==t?void 0:t.colSpan)??1):0);for(const a of o.rows){const t=[];let r=0,o=!1;for(const i of a.cells){const a=Math.max(1,i.colSpan??1);if(!o&&n<=r){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.push(a),o=!0}!o&&r<n&&n<r+a?(t.push({...i,colSpan:a+1,...e.trackChangesEnabled?{style:{...i.style??{},revision:{...VR(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),o=!0):t.push(i),r+=a}if(!o){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.push(a)}a.cells=t}const r=o.rows[i.rowIndex],s=r?SP(r,n):null,d=(null==s?void 0:s.blocks[0])??AP(o);return kP(e,l,i.zone,d)}const s=Math.max(0,Math.min((null==(n=o.rows[0])?void 0:n.cells.length)??0,i.cellIndex+(a>0?1:0)));for(const t of o.rows){const a=_a([Ja("")]);e.trackChangesEnabled&&(a.style={revision:{...VR(),type:"insert"}}),t.cells.splice(s,0,a)}const d=o.rows[i.rowIndex],c=null==d?void 0:d.cells[s],h=(null==c?void 0:c.blocks[0])??AP(o);return kP(e,l,i.zone,h)},deleteSelectedTableColumn:e=>{var a;const n=TP(e,t.getTargetBlocks);if(!n)return e;const{tableBlock:r,location:o,targetBlocks:i}=n;if(wP(r)<=1)return e;if(e.trackChangesEnabled){const t=Io(r).find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??o.cellIndex;for(const e of r.rows){const t=SP(e,a);t&&(t.style={...t.style??{},revision:{...VR(),type:"delete"}})}return kP(e,i,o.zone,null)}if(r.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=Io(r).find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??o.cellIndex;for(const e of r.rows){const t=[];let n=0;for(const r of e.cells){const e=Math.max(1,r.colSpan??1);a>=n&&a<n+e?e>1&&t.push({...r,colSpan:e-1>1?e-1:void 0}):t.push(r),n+=e}e.cells=t}const n=r.rows[o.rowIndex],l=n&&SP(n,Math.min(a,Math.max(0,xP(n)-1))),s=(null==l?void 0:l.blocks[0])??AP(r);return kP(e,i,o.zone,s)}if((null==(a=r.rows[0])?void 0:a.cells.length)<=1)return e;for(const t of r.rows)t.cells.splice(o.cellIndex,1);const l=r.rows[o.rowIndex],s=null==l?void 0:l.cells[Math.min(o.cellIndex,l.cells.length-1)],d=(null==s?void 0:s.blocks[0])??AP(r);return kP(e,i,o.zone,d)}}}({getTargetBlocks:e}),{withExpandedTableCellSelection:A,applySelectionAwareTextCommand:C,applySelectionAwareParagraphCommand:I}=function(t){const e=e=>{const a=t.resolveTableCellRangeSelection(e);return a?t.applySelectionToStatePreservingStructure(e,a):e},a=(a,n)=>{t.applyTransactionalState(r=>{var o,i,l;const s=t.resolveSelectedTableCells(r);if(!s||s.cells.length<=1){const i=e(r);return i!==r&&(null==(o=t.logger)||o.info(`${n}: expanded selection to ${i.selection.anchor.paragraphId}[${i.selection.anchor.offset}]..${i.selection.focus.paragraphId}[${i.selection.focus.offset}]`)),a(i)}const{blockIndex:d,cells:c,zone:h}=s;null==(i=t.logger)||i.info(`${n}: multi-cell selection in table block ${d} (${c.length} cells) in zone ${h}`);const p=[],u=[];for(const t of c)p.push(...t.cell.blocks),u.push(t.cell.blocks.length);if(0===p.length)return r;const f={...r,document:nn(p,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:_e(p[0],0),focus:_e(p[p.length-1],Je(p[p.length-1]).length)}},g=Na(a(f)),m=t.getTargetBlocks(r,h),v=AA(m[d]);if(!v)return r;const b=m.map((t,e)=>e===d?v:t),y=v;let M=0;for(let t=0;t<c.length;t+=1){const e=c[t],a=u[t],n=g.slice(M,M+a);M+=a;const r=null==(l=y.rows[e.rowIndex])?void 0:l.cells[e.cellIndex];r&&(r.blocks=n)}return IP(r,b,h)})};return{withExpandedTableCellSelection:e,applySelectionAwareTextCommand:t=>{a(t,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:t=>{a(t,"applySelectionAwareParagraphCommand")}}}({applyTransactionalState:t.applyTransactionalState,applySelectionToStatePreservingStructure:t.applySelectionToStatePreservingStructure,getTargetBlocks:e,resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,logger:t.logger});return{resolveTableCellRangeSelection:a,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u,mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y,insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S,getRowVisualWidth:xP,getTableVisualWidth:wP,findCellAtVisualColumn:SP,findFirstNavigableParagraphInTable:AP,updateBlocksInCurrentSection:IP,resolveAdjacentTableCellPosition:CP,applyTableAwareParagraphEdit:(t,a)=>((t,e,a)=>{var n;const r=xa(t.document,t.selection.focus.paragraphId,Ea(t));if(!r||t.selection.anchor.paragraphId!==t.selection.focus.paragraphId)return a(t);const o=r.zone,i=e(t,o),l=AA(i[r.blockIndex]);if(!l||"table"!==l.type)return a(t);const s=i.map((t,e)=>e===r.blockIndex?l:t),d=null==(n=l.rows[r.rowIndex])?void 0:n.cells[r.cellIndex];if(!d)return a(t);const c=a({...t,document:nn(d.blocks,void 0,void 0,void 0,void 0,t.document.assets),selection:{anchor:{...t.selection.anchor},focus:{...t.selection.focus}}}),h=ba(c.document).filter(t=>"paragraph"===t.type);return d.blocks.splice(0,d.blocks.length,...h),{...IP(t,s,o),selection:c.selection}})(t,e,a),withExpandedTableCellSelection:A,applySelectionAwareTextCommand:C,applySelectionAwareParagraphCommand:I,insertTableCommand:(e,a)=>{var n;null==(n=t.logger)||n.info(`insertTableCommand: ${e}x${a}`),t.applyTransactionalState(t=>function(t,e,a){const n=100/Math.max(1,a)+"%",r=t.trackChangesEnabled?VR():void 0,o=[];for(let m=0;m<e;m+=1){const t=[];for(let r=0;r<a;r+=1)t.push({..._a([Ja("")]),style:{width:n}});const e=$a(t);r&&(e.style={revision:{...r,type:"insert"}}),o.push(e)}const i={...tn(o),style:{width:"100%"}},l=Fa(t,t.selection.focus),s=ha(t.document),d=Ea(t),c=La(t),h=t=>{const e=t.findIndex(t=>t.id===l.paragraphId||"paragraph"!==t.type&&pa(t).some(t=>t.id===l.paragraphId));return-1===e?{nextBlocks:t,found:!1}:{nextBlocks:[...t.slice(0,e+1),i,...t.slice(e+1)],found:!0}},p=s[d];if(!p)return t;const u={...p};let f=!1;if("header"===c){const t=h(p.header??[]);u.header=t.nextBlocks,f=t.found}else if("footer"===c){const t=h(p.footer??[]);u.footer=t.nextBlocks,f=t.found}else{const t=h(p.blocks);u.blocks=t.nextBlocks,f=t.found}if(!f)return t;const g=[...s];return g[d]=u,{...t,document:{...t.document,sections:g},selection:iR(_e(i.rows[0].cells[0].blocks[0],0))}}(t,e,a),{mergeKey:fV}),t.focusInput()}}}function LP(t,e){let a=null;const n=(t,e,a)=>{const n=Na(t).find(t=>t.id===e);return n?{anchor:_e(n,a),focus:_e(n,a+1)}:null},r=(t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}),o=o=>{var i;const l=a;if(!l)return;const s=(null==(i=e.zoomFactor)?void 0:i.call(e))??1,d=(o.clientX-l.startClientX)/s,c=(o.clientY-l.startClientY)/s,h=t.getMaxWidth(e.state,l.paragraphId),{width:p,height:u}=function(t,e,a,n,r){const o=YM(t.handleDirection,"x"),i=YM(t.handleDirection,"y"),l=0===o?t.startWidth:t.startWidth+e*o,s=0===i?t.startHeight:t.startHeight+a*i;let d=XM(l,KM,r),c=XM(s,KM);if(!n)return{width:d,height:c};const h=t.aspectRatio||1,p=0!==o;if(p&&0!==i){const e=d/t.startWidth,a=c/t.startHeight,n=Math.abs(e-1)>=Math.abs(a-1)?e:a;return d=XM(t.startWidth*n,KM,r),c=XM(d/h,KM),{width:d,height:c}}return p?(d=XM(d,KM,r),c=XM(d/h,KM),{width:d,height:c}):(c=XM(c,KM),d=XM(c*h,KM,r),c=XM(d/h,KM),{width:d,height:c})}(l,d,c,o.shiftKey,h),f=n(e.state,l.paragraphId,l.paragraphOffset);f?e.applyState(t.applyResize(r(e.state,f),p,u,l.handleDirection)):e.logger.warn(`${t.label} resize:missing paragraph`,l)},i=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),l(),e.focusInput()},l=()=>{a=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",i)};return{start:(l,s,d,c,h)=>{const p=n(h,l,s);if(!p)return;const u=t.getSelected(r(h,p));u&&(a={paragraphId:l,paragraphOffset:s,handleDirection:d,startClientX:c.clientX,startClientY:c.clientY,startWidth:u.width,startHeight:u.height,aspectRatio:u.width/u.height,initialState:e.cloneState(h)},window.addEventListener("mousemove",o),window.addEventListener("mouseup",i))},stop:l}}function zP(t,e){let a=null;const n=n=>{const r=a;if(!r)return;let o=((180*Math.atan2(n.clientY-r.centerY,n.clientX-r.centerX)/Math.PI+90)%360+360)%360;n.shiftKey&&(o=15*Math.round(o/15)%360);const i=((t,e,a)=>{const n=Na(t).find(t=>t.id===e);return n?{anchor:_e(n,a),focus:_e(n,a+1)}:null})(e.state,r.paragraphId,r.paragraphOffset);i?e.applyState(t.applyRotate(((t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}))(e.state,i),o)):e.logger.warn(`${t.label} rotate:missing paragraph`,r)},r=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),o(),e.focusInput()},o=()=>{a=null,window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{start:(t,o,i,l)=>{const s=i.currentTarget.closest(".oasis-editor-selection-overlay");if(!s)return;const d=s.getBoundingClientRect();a={paragraphId:t,paragraphOffset:o,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:e.cloneState(l)},window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)},stop:o}}function NP(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y({x:0,y:0}),[l,s]=y(null);let d=null,c=null,h=null;const p=t=>{const e=Da(t);if(e.isCollapsed||e.startIndex!==e.endIndex||e.endParagraphOffset-e.startParagraphOffset!==1)return null;const a=Na(t)[e.startIndex];if(!a)return null;let n=0;for(const r of a.runs){const o=n;if(n+=r.text.length,"image"===r.kind&&1===r.text.length&&o===e.startParagraphOffset)return{paragraph:a,run:r,startOffset:o,width:r.image.width,height:r.image.height,src:da(t.document,r.image.src)}}return null},u=(e,a)=>t.resolvePositionAtSurfacePoint(e,a),f=()=>{h&&(h.remove(),h=null),document.body.style.cursor="",c=null,d=null,a(!1),r(null),s(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},g=LP({label:"image",getSelected:t=>p(t),applyResize:(t,e,a)=>function(t,e,a){return Xq(t,t=>({...t,width:Math.max(24,Math.round(e)),height:Math.max(24,Math.round(a))}))}(t,e,a),getMaxWidth:(e,a)=>$q(t.surfaceRef(),e.document,a,e.activeSectionIndex??0)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),m=zP({label:"image",applyRotate:(t,e)=>Kq(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger}),v=e=>{let n=d;if(!n){const r=c;if(!r)return;if(Math.abs(e.clientX-r.startClientX)+Math.abs(e.clientY-r.startClientY)<4)return;n={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},d=n,c=null,a(!0),h||(h=document.createElement("style"),h.setAttribute("data-oasis-image-drag-cursor",""),h.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(h)),t.logger.info(`image drag:start ${n.paragraphId}@${n.paragraphOffset} client=(${e.clientX},${e.clientY})`)}i({x:e.clientX,y:e.clientY}),r({...n}),s(u(e.clientX,e.clientY))},b=e=>{const a=d;if(a||c){if(a){const n=u(e.clientX,e.clientY);n?(t.logger.info(`image drag:done ${a.paragraphId} -> ${n.paragraphId}:${n.runId}[${n.offset}]`),t.applyTransactionalState(t=>_q(t,n),{mergeKey:gV})):t.logger.warn(`image drag:cancel ${a.paragraphId} no target at (${e.clientX},${e.clientY})`)}f(),t.focusInput()}else t.focusInput()},M=(e,n,o,l)=>{const h=o.currentTarget,u=l?{left:l.left,top:l.top,width:l.width,height:l.height}:null==h?void 0:h.getBoundingClientRect();if(!u)return;const f=p(t.state);c={paragraphId:e,paragraphOffset:n,startClientX:o.clientX,startClientY:o.clientY,src:(null==f?void 0:f.src)??"",width:(null==f?void 0:f.width)??u.width,height:(null==f?void 0:f.height)??u.height,offsetX:o.clientX-u.left,offsetY:o.clientY-u.top},d=null,i({x:o.clientX,y:o.clientY}),a(!1),r(null),s(null),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)};return{dragging:e,draggedImageInfo:n,mousePos:o,dropTargetPos:l,getSelectedImageInfo:p,startImageDrag:M,stopImageDrag:()=>{f()},stopImageResize:g.stop,stopImageRotate:m.stop,handleImageMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation();const r=ba(t.state.document).find(t=>t.id===e);r&&t.applyState(hE(t.state,{anchor:_e(r,a),focus:_e(r,a+1)})),M(e,a,n),t.focusInputAfterPointerSelection()},handleImageResizeHandleMouseDown:(e,a,n,r)=>{r.preventDefault(),r.stopPropagation(),g.start(e,a,n,r,t.state)},handleImageRotateHandleMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation(),m.start(e,a,n,t.state)}}}function OP(t){const[e,a]=y(void 0),n=()=>{a(void 0)};x(()=>{Ga(t.state().selection)||n()});const r=()=>{const a=zu(t.state()),n=e();return Ga(t.state().selection)&&n?{...a,bold:n.bold??a.bold,italic:n.italic??a.italic,underline:n.underline??a.underline,underlineStyle:void 0!==n.underlineStyle&&null!==n.underlineStyle?String(n.underlineStyle):a.underlineStyle,strike:n.strike??a.strike,superscript:n.superscript??a.superscript,subscript:n.subscript??a.subscript,fontFamily:n.fontFamily??a.fontFamily,fontSize:void 0!==n.fontSize&&null!==n.fontSize?String(n.fontSize):a.fontSize,color:n.color??a.color,highlight:n.highlight??a.highlight,textShading:n.shading??a.textShading,link:n.link??a.link,characterStyleId:void 0!==n.styleId&&null!==n.styleId?String(n.styleId):a.characterStyleId}:a};return{pendingCaretTextStyle:e,clearPendingCaretTextStyle:n,toolbarStyleState:r,applyToolbarValueStyleCommand:(e,n)=>{if(Ga(t.state().selection))return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return null==e||""===e?delete n[t]:n[t]=e,Object.keys(n).length>0?n:void 0})})(e,n),void t.focusInput();t.commandsController().applyValueStyleCommand(e,n)},applyToolbarBooleanStyleCommand:e=>{if(Ga(t.state().selection)){const n=!r()[e];return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return n[t]=e,"superscript"===t&&e&&(n.subscript=!1),"subscript"===t&&e&&(n.superscript=!1),n})})(e,n),void t.focusInput()}t.commandsController().applyBooleanStyleCommand(e)}}}function qP(t){const[e,a]=y(""),[n,r]=y(""),[o,i]=y({matchCase:!1,wholeWord:!1}),[l,s]=y([]),[d,c]=y(-1),[h,p]=y(!1);x(A([()=>t.state.document,e,o],([t,e,a])=>{const n=function(t,e,a={}){if(!e)return[];const n=[],r=ba(t),{matchCase:o=!1,wholeWord:i=!1}=a,l=o?"g":"gi";let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const d=new RegExp(s,l);return r.forEach((t,e)=>{const a=Je(t);let r;for(d.lastIndex=0;null!==(r=d.exec(a));){const a=r.index,o=r.index+r[0].length;n.push({anchor:_e(t,a),focus:_e(t,o),paragraphIndex:e}),r.index===d.lastIndex&&d.lastIndex++}}),n}(t,e,a);s(n),0===n.length?c(-1):(d()>=n.length||-1===d())&&c(0)}));const u=e=>{const a=l()[e];a&&t.applyState(hE(t.state,{anchor:a.anchor,focus:a.focus}))};return{searchTerm:e,setSearchTerm:a,replaceTerm:n,setReplaceTerm:r,findOptions:o,setFindOptions:i,matches:l,currentIndex:d,findNext:()=>{const t=l().length;if(0===t)return;const e=(d()+1)%t;c(e),u(e)},findPrevious:()=>{const t=l().length;if(0===t)return;const e=(d()-1+t)%t;c(e),u(e)},replace:()=>{if(0===l().length||-1===d())return;const e=l()[d()];t.applyTransactionalState(t=>mR(hE(t,{anchor:e.anchor,focus:e.focus}),n()),{mergeKey:SV})},replaceAll:()=>{const e=l();0!==e.length&&(t.applyTransactionalState(t=>{let a=t;for(let r=e.length-1;r>=0;r--){const t=e[r];a=hE(a,{anchor:t.anchor,focus:t.focus}),a=mR(a,n())}return a},{mergeKey:AV}),p(!1),t.focusInput())},isOpen:h,setIsOpen:p}}function PP(t,e,a,n,r,o){const i=t+a,l=e+n;return 1e3*(o<e?e-o:o>l?o-l:0)+(r<t?t-r:r>i?r-i:0)}function WP(t,e,a){if(0===t.slots.length)return{offset:t.startOffset,score:Number.POSITIVE_INFINITY};let n=t.slots[0].offset,r=Number.POSITIVE_INFINITY,o=t.slots[0].left,i=t.slots[0].top,l=t.slots[0].height;for(const s of t.slots){const t=1e3*(a<s.top?s.top-a:a>s.top+s.height?a-(s.top+s.height):0)+Math.abs(e-s.left);t<r&&(r=t,n=s.offset,o=s.left,i=s.top,l=s.height)}return{offset:n,score:r,slotLeft:o,slotTop:i,slotHeight:l}}function BP(t,e,a){let n=t.startOffset,r=Number.POSITIVE_INFINITY;for(const o of t.lines){const{offset:t,score:i}=WP(o,e,a);i<r&&(r=i,n=t)}return Math.max(t.startOffset,Math.min(n,t.endOffset))}function FP(t,e,a){return t>=a.left&&t<=a.left+a.width&&e>=a.top&&e<=a.top+a.height}function HP(t){var e,a,n;const{snapshot:r,state:o}=t,i=t.pierce??!1,l=t.zoomFactor&&t.zoomFactor>0?t.zoomFactor:1,s=r.surfaceRect,d=s.left+(t.clientX-s.left)/l,c=s.top+(t.clientY-s.top)/l,h=function(t,e,a){if(0===t.length)return null;let n=t[0],r=Number.POSITIVE_INFINITY;for(const o of t){const t=PP(o.left,o.top,o.width,o.height,e,a);t<r&&(r=t,n=o)}return n}(r.pages,d,c);if(!h)return null;const p=function(t,e){const a=e-t.top;return a<t.bodyTop?"header":void 0!==t.footnoteSeparatorTop&&a>=t.footnoteSeparatorTop&&a<(t.footerTop??t.height)?"footnote":a>=t.bodyBottom?"footer":"main"}(h,c),u=function(t,e,a,n,r,o){for(let i=t.floatingTextBoxes.length-1;i>=0;i-=1){const l=t.floatingTextBoxes[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&n>=l.left&&n<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(r,h.index,p,d,c,i);if(u){const t=r.paragraphsById.get(u.paragraphId)??[],a=t.find(t=>t.pageIndex===h.index&&t.zone===p&&u.startOffset>=t.startOffset&&u.startOffset<=t.endOffset)??t[0];if(a){const t=Math.max(a.startOffset,Math.min(u.startOffset,a.endOffset)),n=_e(a.paragraph,t);return{zone:p,footnoteId:a.footnoteId,paragraphId:u.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(e=a.tableCell)?void 0:e.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},textBox:{paragraphId:u.paragraphId,paragraphOffset:t,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const f=function(t,e,a,n,r,o){for(let i=t.floatingImages.length-1;i>=0;i-=1){const l=t.floatingImages[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&FP(n,r,l))return l}for(const i of t.inlineImages)if(i.pageIndex===e&&i.zone===a&&FP(n,r,i))return i;return null}(r,h.index,p,d,c,i);if(f){const t=r.paragraphsById.get(f.paragraphId)??[],e=t.find(t=>t.pageIndex===h.index&&t.zone===p&&f.startOffset>=t.startOffset&&f.startOffset<=t.endOffset)??t[0];if(e){const t=Math.max(e.startOffset,Math.min(f.startOffset,e.endOffset)),n=_e(e.paragraph,t);return{zone:p,footnoteId:e.footnoteId,paragraphId:f.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(a=e.tableCell)?void 0:a.anchorPosition,caretViewport:{left:f.left,top:f.top,height:f.height},image:{paragraphId:f.paragraphId,paragraphOffset:t,startOffset:f.startOffset,endOffset:f.endOffset,left:f.left,top:f.top,width:f.width,height:f.height}}}}const g=function(t,e,a){if(0===t.length)return null;let n=null;for(const i of t)for(const t of i.lines){const r=t.top-2,o=t.top+t.height+2;if(a<r||a>o)continue;const{offset:l,score:s,slotLeft:d,slotTop:c,slotHeight:h}=WP(t,e,a);(!n||s<n.score)&&(n={paragraph:i,offset:l,score:s,caretViewport:void 0!==d&&void 0!==c&&void 0!==h?{left:d,top:c,height:h}:void 0})}if(n)return{paragraph:n.paragraph,offset:n.offset,caretViewport:n.caretViewport};let r=null,o=Number.POSITIVE_INFINITY;for(const i of t){const t=PP(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),e,a);t<o&&(o=t,r=i)}return r?{paragraph:r,offset:BP(r,e,a),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(r.paragraphs.filter(t=>t.pageIndex===h.index&&t.zone===p),d,c);if(!g){const t=o.selection.focus.paragraphId,e=o.selection.focus.offset,a=function(t,e,a,n,r){const o=t.unsupportedRegions.find(t=>t.pageIndex===e&&t.zone===a&&n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height);return(null==o?void 0:o.reason)??null}(r,h.index,p,d,c);return{zone:p,paragraphId:t,paragraphOffset:e,position:{...o.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:a??"zone-without-paragraph"}}const m=g.paragraph,v=Math.max(0,Math.min(g.offset,m.textLength)),b=_e(m.paragraph,v);return{zone:p,footnoteId:m.footnoteId,paragraphId:m.paragraphId,paragraphOffset:v,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(n=m.tableCell)?void 0:n.anchorPosition,caretViewport:g.caretViewport}}function UP(t){return{resolveSurfaceHitAtPoint:(e,a,n={})=>{const r=t.surfaceRef();if(!r)return null;const o=t.state(),i=t.zoomFactor(),l=t.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:o,documentLayout:t.documentLayout(),zoomFactor:i});if(function(t){aV&&(rV=t?function(t){return{surfaceRect:{left:t.surfaceRect.left,top:t.surfaceRect.top,width:t.surfaceRect.width,height:t.surfaceRect.height},pages:(e=t.pages,e.map(t=>({index:t.index,left:t.left,top:t.top,width:t.width,height:t.height,bodyTop:t.bodyTop,bodyBottom:t.bodyBottom}))),paragraphs:t.paragraphs.map(t=>{return{paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,textLength:t.textLength,left:t.left,top:t.top,width:t.width,height:t.height,lines:(e=t.lines,e.map(t=>{return{startOffset:t.startOffset,endOffset:t.endOffset,top:t.top,height:t.height,slots:(e=t.slots,e.map(t=>({offset:t.offset,left:t.left,top:t.top,height:t.height})))};var e})),tableCell:t.tableCell?{tableId:t.tableCell.tableId,rowIndex:t.tableCell.rowIndex,cellIndex:t.tableCell.cellIndex,left:t.tableCell.left,top:t.tableCell.top,width:t.tableCell.width,height:t.tableCell.height}:void 0,verticalMode:t.verticalMode};var e}),inlineImages:t.inlineImages.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height})),inlineTextBoxes:t.inlineTextBoxes.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height,rotation:t.rotation})),unsupportedRegions:t.unsupportedRegions.map(t=>({...t}))};var e}(t):null)}(l),!l)return sV(null),null;const s=HP({snapshot:l,state:o,clientX:e,clientY:a,pierce:n.pierce??!1,zoomFactor:i});return sV(s),s}}}const GP=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],DP=new Map;function jP(){return GP.map(t=>({...t}))}const ZP=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function KP(t,e,a){const[n,r]=t,[o,i]=e,[l,s]=a,d=l-o,c=s-i,h=d*d+c*c;if(0===h)return Math.hypot(n-o,r-i);return Math.abs(d*(i-r)-c*(o-n))/Math.sqrt(h)}function XP(t,e){if(t.length<3)return t.slice();let a=0,n=0;const r=t[0],o=t[t.length-1];for(let s=1;s<t.length-1;s+=1){const e=KP(t[s],r,o);e>a&&(a=e,n=s)}if(a<=e)return[r,o];const i=XP(t.slice(0,n+1),e),l=XP(t.slice(n),e);return[...i.slice(0,-1),...l]}function YP(t,e,a){let n=0;for(let s=0;s<t.length;s+=1)1===t[s]&&(n+=1);if(e<=0||a<=0||0===n||n/(e*a)>=.985)return jP();const r=function(t,e,a){const n=(n,r)=>n>=0&&n<e&&r>=0&&r<a&&1===t[r*e+n];let r=-1,o=-1;for(let h=0;h<a&&o<0;h+=1)for(let a=0;a<e;a+=1)if(1===t[h*e+a]){r=a,o=h;break}if(r<0)return[];const i=[];let l=r,s=o,d=6;const c=e*a*4;for(let h=0;h<c;h+=1){let t=!1;for(let e=1;e<=8;e+=1){const a=(d+e)%8,[r,o]=ZP[a],c=l+r,h=s+o;if(n(c,h)){i.push([l,s]),d=(a+4)%8,l=c,s=h,t=!0;break}}if(!t){i.push([l,s]);break}if(l===r&&s===o&&i.length>1)break}return i}(t,e,a);if(r.length<3)return jP();const o=.012*Math.max(e,a);let i=XP(r,o),l=o;for(;i.length>40;)l*=1.6,i=XP(r,l);return i.length<3?jP():i.map(([t,n])=>({x:Math.min(1,Math.max(0,t/e)),y:Math.min(1,Math.max(0,n/a))}))}function JP(t){const e=t.src,a=DP.get(e);if(a)return a.map(t=>({...t}));const n=function(t){const e=t.naturalWidth||t.width,a=t.naturalHeight||t.height;if(!e||!a)return null;const n=Math.min(1,256/Math.max(e,a)),r=Math.max(1,Math.round(e*n)),o=Math.max(1,Math.round(a*n)),i=document.createElement("canvas");i.width=r,i.height=o;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(t,0,0,r,o);try{s=l.getImageData(0,0,r,o).data}catch{return null}const d=new Uint8Array(r*o);let c=0;for(let h=0;h<d.length;h+=1)s[4*h+3]>=128&&(d[h]=1,c+=1);return{mask:d,width:r,height:o,foreground:c}}(t);if(!n)return jP();const r=YP(n.mask,n.width,n.height);return DP.set(e,r),r.map(t=>({...t}))}function QP(t){const{state:e,resetTransactionGrouping:a,applyTransactionalState:n,focusInput:r}=t,o=()=>Zq(e())?"image":vP(e())?"textBox":null,i=(t,e)=>{const i=o();i&&(a(),n(t=>e(t,i),{mergeKey:t}),r())},l=(t,a)=>{const r=da(e().document,a),o=e=>{const a=JP(e);n(e=>function(t,e,a){const n=Na(t);let r=!1;const o=n.map(t=>t.runs.some(t=>t.id===e&&"image"===t.kind)?{...MA(t),runs:t.runs.map(t=>{if(t.id!==e||"image"!==t.kind)return yA(t);r=!0;const n={...t.image};return a&&a.length>0?n.wrapPolygon=a:delete n.wrapPolygon,{...t,image:n}})}:MA(t));return r?rR(t,o,cR(o,Da(t))):t}(e,t,a),{mergeKey:MV})},i=wp(r,()=>{i.naturalWidth>0&&o(i)});i.complete&&i.naturalWidth>0&&o(i)};return{target:o,preset:()=>{const t=o();return"image"===t?function(t){const e=Zq(t),a=e&&ye(e.run);return a?Gq(a.floating):null}(e()):"textBox"===t?function(t){const e=vP(t),a=e&&Me(e.run);return a?Gq(a.floating):null}(e()):null},fixedPosition:()=>{const t=o();return"image"===t?function(t){const e=Zq(t),a=e&&ye(e.run);return jq(null==a?void 0:a.floating)}(e()):"textBox"===t&&function(t){const e=vP(t),a=e&&Me(e.run);return jq(null==a?void 0:a.floating)}(e())},setPreset:t=>{if(i(UV,(e,a)=>"image"===a?function(t,e){return Yq(t,t=>Uq(t,e))}(e,t):function(t,e){return yP(t,t=>Uq(t,e))}(e,t)),"tight"===t||"through"===t){const t=Zq(e()),a=t&&ye(t.run);a&&!a.wrapPolygon&&l(t.run.id,a.src)}},setFixedPosition:t=>i(GV,(e,a)=>"image"===a?function(t,e){return Yq(t,t=>t?Dq(t,e):t)}(e,t):function(t,e){return yP(t,t=>t?Dq(t,e):t)}(e,t))}}function _P(t,e){const a=function(t){return ca(t.document).flatMap(t=>[...t.header??[],...t.blocks,...t.footer??[]])}(t).find(t=>"table"===t.type&&t.id===e);return a??null}function $P(t,e,a,n,r,o){const i=function(t,e,a,n,r){const o=n.getCanvasLayoutSnapshot({surface:t,state:e,documentLayout:a,zoomFactor:r});if(!o)return[];const i=new Map,l=new Map;for(const d of o.paragraphs){const t=d.tableCell;if(!t)continue;const e=`${d.pageIndex}:${t.rowIndex}:${t.cellIndex}`,a=i.get(t.tableId)??new Map;let n=a.get(e);n||(n={tableId:t.tableId,rowIndex:t.rowIndex,cellIndex:t.cellIndex,pageIndex:d.pageIndex,left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height,width:t.width,height:t.height,contentMinWidth:0,contentMinHeight:0},a.set(e,n),i.set(t.tableId,a));const r=d.lines.flatMap(t=>t.slots.map(t=>t.left)),o=d.lines.map(t=>t.top+t.height),s=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,h=d.lines.length>0?d.lines[0].top:d.top,p=o.length>0?Math.max(...o):d.top+d.height,u=`${t.tableId}:${d.pageIndex}:${t.rowIndex}:${t.cellIndex}`,f=l.get(u);f?(f.left=Math.min(f.left,s),f.top=Math.min(f.top,h),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):l.set(u,{left:s,top:h,right:c,bottom:p})}for(const[d,c]of i.entries())for(const t of c.values()){const e=l.get(`${d}:${t.pageIndex}:${t.rowIndex}:${t.cellIndex}`);e&&(t.contentMinWidth=Math.max(0,e.right-e.left),t.contentMinHeight=Math.max(0,e.bottom-e.top))}const s=[];for(const[d,c]of i.entries()){const t=Array.from(c.values());if(0===t.length)continue;const e=Math.min(...t.map(t=>t.left)),a=Math.min(...t.map(t=>t.top)),n=Math.max(...t.map(t=>t.right)),r=Math.max(...t.map(t=>t.bottom));s.push({tableId:d,cells:t,bounds:{left:e,top:a,right:n,bottom:r,width:Math.max(1,n-e),height:Math.max(1,r-a)}})}return s}(e,a,n,r,o);if(0===i.length)return null;let l=null;for(const c of i)for(const e of c.cells){const a=t.clientY>=e.top-4&&t.clientY<=e.bottom+4,n=t.clientX>=e.left-4&&t.clientX<=e.right+4;if(a){const a=Math.abs(t.clientX-e.left);a<=4&&(!l||a<l.distance)&&(l={geometry:c,cell:e,side:"left",distance:a});const n=Math.abs(t.clientX-e.right);n<=4&&(!l||n<l.distance)&&(l={geometry:c,cell:e,side:"right",distance:n})}if(n){const a=Math.abs(t.clientY-e.top);a<=4&&(!l||a<l.distance)&&(l={geometry:c,cell:e,side:"top",distance:a});const n=Math.abs(t.clientY-e.bottom);n<=4&&(!l||n<l.distance)&&(l={geometry:c,cell:e,side:"bottom",distance:n})}}if(!l)return null;const s=_P(a,l.geometry.tableId);if(!s)return null;const d=Io(s).find(t=>t.rowIndex===l.cell.rowIndex&&t.cellIndex===l.cell.cellIndex);return d?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:d,tableGeometry:l.geometry}:null}const tW=1/.75,eW=10;function aW(t){return.75*t}function nW(t){return t*tW}function rW(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e)return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?aW(t):null}if(e.includes("%"))return null;if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function oW(t){var e,a,n,r,o;return("number"==typeof(null==(e=t.style)?void 0:e.padding)&&Number.isFinite(t.style.padding)?2*Math.max(0,nW(t.style.padding)):Math.max(0,(void 0!==(null==(a=t.style)?void 0:a.paddingLeft)?nW(t.style.paddingLeft):7.2)+(void 0!==(null==(n=t.style)?void 0:n.paddingRight)?nW(t.style.paddingRight):7.2)))+((null==(r=t.style)?void 0:r.borderLeft)?Math.max(0,nW(t.style.borderLeft.width)):1)+((null==(o=t.style)?void 0:o.borderRight)?Math.max(0,nW(t.style.borderRight.width)):1)}function iW(t,e,a){if("row"!==e.type)return t;const n=e.initialRowHeightPx??nW(eW),r=Math.max(nW(eW),e.minRowHeightPx??nW(eW)),o=Math.max(eW,aW(Math.max(r,n+a)));return function(t,e,a,n){const r=r=>{if(r.id!==e)return r;const o=[...r.rows],i=o[a];if(i){let e=i.style;t.trackChangesEnabled&&!(null==e?void 0:e.propertyRevision)&&(e={...e??{},propertyRevision:{...VR(),type:"property",previous:{...e??{}}}}),o[a]={...i,style:RR(e,"height",n)}}return{...r,rows:o}};return ER(t,t=>LR(t,r))}(t,e.tableId,e.index,o)}function lW(t){const e=t();if(!e)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const a=e.getBoundingClientRect();return{left:a.left,top:a.top,width:Math.max(0,a.width),height:Math.max(0,a.height)}}function sW(t){t?(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 dW(){document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")}function cW(t){sW(t)}function hW(t){const[e,a]=y(null),n=n=>{const r=e();r&&(a({...r,currentPos:"column"===r.type?n.clientX:n.clientY,guideBounds:lW(t.viewportRef)}),cW("column"===r.type))},r=o=>{var i;const l=e();if(!l)return;const s=(null==(i=t.zoomFactor)?void 0:i.call(t))??1,d=(("column"===l.type?o.clientX:o.clientY)-l.initialPos)/s;Math.abs(d)>=2&&t.applyTransactionalState(t=>"row"===l.type?iW(t,l,d):function(t,e,a){var n;if("column"!==e.type)return t;const r=aW(a),o=e.maxColumnIndex??e.index,i={...e.columnWidthsPt??{}};for(let m=0;m<=o;m+=1)void 0===i[m]&&(i[m]=eW);const l=e.minColumnWidthsPx??{},s=i[e.index]??eW,d=Math.max(eW,aW(l[e.index]??nW(eW)));if(e.resizeFromLeftEdge){const a=Math.max(0,e.initialTableIndentLeftPt??0);let n=Math.max(d,s-r),o=s-n;a+o<0&&(o=-a,n=s-o),i[e.index]=n;const l=Object.values(i).reduce((t,e)=>t+e,0),c=Math.max(0,a+o);return GR(t,e.tableId,i,l,c)}let c=Math.max(d,s+r);const h=e.index===o;if(h)i[e.index]=c;else{const t=e.index+1,a=i[t]??eW,n=Math.max(eW,aW(l[t]??nW(eW)));let r=a-(c-s);r<n&&(r=n,c=s+(a-n),c=Math.max(d,c)),i[e.index]=c,i[t]=r}const p=Object.values(i).reduce((t,e)=>t+e,0),u=_P(t,e.tableId),f=rW(null==(n=null==u?void 0:u.style)?void 0:n.width),g=h?p:null!==f?f:void 0;return GR(t,e.tableId,i,g)}(t,l,d)),a(null),dW(),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{resizing:e,handleMouseMove:a=>{var n;if(e())return void cW("column"===e().type);const r=t.surfaceRef();if(!r)return void dW();const o=$P(a,r,t.state(),t.documentLayout(),t.canvasSnapshotProvider,null==(n=t.zoomFactor)?void 0:n.call(t));o?sW("left"===o.side||"right"===o.side):dW()},handleMouseDown:e=>{var o,i;const l=t.surfaceRef();if(!l)return!1;const s=$P(e,l,t.state(),t.documentLayout(),t.canvasSnapshotProvider,null==(o=t.zoomFactor)?void 0:o.call(t));if(!s)return!1;const d=t.state(),c=Io(s.tableNode);if("left"===s.side||"right"===s.side){const o="left"===s.side&&0===s.layoutEntry.visualColumnIndex,l=o?0:"left"===s.side?s.layoutEntry.visualColumnIndex-1:s.layoutEntry.visualColumnIndex+s.layoutEntry.colSpan-1;if(l<0)return!1;const h="left"===s.side?s.rect.left:s.rect.right,{widthsPt:p,maxColumnIndex:u}=function(t,e,a){const n=Math.max(1,...e.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),r=n-1,o=Array(n).fill(a.bounds.width/n),i=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));if(t.gridCols&&t.gridCols.length>=n)for(let s=0;s<n;s+=1)o[s]=Math.max(1,nW(t.gridCols[s]));else for(const s of e){if(1!==s.colSpan)continue;const t=i.get(`${s.rowIndex}:${s.cellIndex}`);t&&(o[s.visualColumnIndex]=Math.max(1,t.width))}const l={};for(let s=0;s<n;s+=1)l[s]=Math.max(eW,aW(o[s]));return{widthsPt:l,maxColumnIndex:r}}(s.tableNode,c,s.tableGeometry),f=function(t,e,a,n){var r;const o=nW(eW),i={},l=new Map(n.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(const s of a){if(1!==s.colSpan)continue;if(!l.get(`${s.rowIndex}:${s.cellIndex}`))continue;const a=null==(r=e.rows[s.rowIndex])?void 0:r.cells[s.cellIndex];if(!a)continue;const n=s.visualColumnIndex,d=i[n]??o,c=a.blocks.reduce((e,a)=>Math.max(e,Os(a,t.document.styles)),1);i[n]=Math.max(d,c+oW(a)+12,o)}return i}(d,s.tableNode,c,s.tableGeometry);return a({type:"column",tableId:s.tableId,index:l,initialPos:h,currentPos:h,columnWidthsPt:p,maxColumnIndex:u,minColumnWidthsPx:f,resizeFromLeftEdge:o,initialTableIndentLeftPt:rW(null==(i=s.tableNode.style)?void 0:i.indentLeft)??0,guideBounds:lW(t.viewportRef)}),cW(!0),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}const h=function(t,e,a){var n,r;const o=Math.max(1,t.rows.length),i=a.bounds.height/o,l=Array(o).fill(i),s=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(let d=0;d<o;d+=1){const a=rW(null==(r=null==(n=t.rows[d])?void 0:n.style)?void 0:r.height);if(null!==a){l[d]=Math.max(1,nW(a));continue}const o=e.find(t=>t.rowIndex===d&&1===t.rowSpan);if(o){const t=s.get(`${o.rowIndex}:${o.cellIndex}`);t&&(l[d]=Math.max(1,t.height))}}return l}(s.tableNode,c,s.tableGeometry),p="top"===s.side?s.layoutEntry.visualRowIndex-1:s.layoutEntry.visualRowIndex+s.layoutEntry.rowSpan-1;if(p<0||p>=h.length)return!1;const u="top"===s.side?s.rect.top:s.rect.bottom,f=function(t,e,a,n){const r=t.rows[n];if(!r)return nW(eW);const o=nW(eW);let i=o;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const t=e.find(t=>t.rowIndex===n&&t.cellIndex===l);if(!t||1!==t.rowSpan)continue;const o=a.cells.find(t=>t.rowIndex===n&&t.cellIndex===l);o&&(i=Math.max(i,o.contentMinHeight+4))}return Math.max(o,i)}(s.tableNode,c,s.tableGeometry,p);return a({type:"row",tableId:s.tableId,index:p,initialPos:u,currentPos:u,initialRowHeightPx:h[p],minRowHeightPx:f,guideBounds:lW(t.viewportRef)}),cW(!1),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}}}function pW(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(null),[l,s]=y(0),[d,c]=y(0),[h,p]=y({x:0,y:0}),u=r=>{var o;if(p({x:r.clientX,y:r.clientY}),!e()){if(!(Math.abs(r.clientY-l())>4))return;a(!0),document.body.style.cursor="grabbing"}document.body.style.cursor="grabbing";const s=t.resolvePositionAtSurfacePoint(r.clientX,r.clientY),d=null==(o=n())?void 0:o.tableId;if(s&&d){const e=t.state(),a=xa(e.document,s.paragraphId,Ea(e));if(a){const t=za(e,a.zone)[a.blockIndex];if(t&&"table"===t.type&&t.id===d)return void i(null)}}i(s)},f=o=>{const s=n();if(e()){const e=t.resolvePositionAtSurfacePoint(o.clientX,o.clientY),a=null==s?void 0:s.tableId;a&&t.applyTransactionalState(t=>{var n;const r=(()=>{for(const e of["main","header","footer"]){const n=za(t,e).find(t=>"table"===t.type&&t.id===a);if(n)return n}})();if("table"===(null==r?void 0:r.type)&&(null==(n=r.style)?void 0:n.floating)){const e=r.style.floating;return FR(t,a,"floating",{...e,x:(e.x??0)+(o.clientX-d())*Re,y:(e.y??0)+(o.clientY-l())*Re,xAlign:void 0,yAlign:void 0})}return e?CR(t,a,e):t})}a(!1),r(null),i(null),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",f),document.body.style.cursor="",t.focusInput()};return{dragging:e,draggedTableInfo:n,mousePos:h,dropTargetPos:o,handleMouseDown:(t,e)=>{e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect(),o=n;r({tableId:t,width:o.width,height:o.height,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top}),s(e.clientY),c(e.clientX),p({x:e.clientX,y:e.clientY}),a(!1),i(null),window.addEventListener("mousemove",u),window.addEventListener("mouseup",f)}}}function uW(t){return/[\p{L}\p{N}_]/u.test(t)}function fW(t,e){if(0===t.length)return{start:0,end:0};const a=Math.max(0,Math.min(e,t.length)),n=a===t.length?Math.max(0,a-1):a,r=t[n];if(!r||!uW(r))return{start:a,end:Math.min(t.length,a+1)};let o=n,i=n+1;for(;o>0&&uW(t[o-1]);)o-=1;for(;i<t.length&&uW(t[i]);)i+=1;return{start:o,end:i}}function gW(t,e,a){const n=ba(t.document).filter(e=>{const n=Ma(t.document,e.id);return null!==n&&n.zone===a}),r=n.findIndex(t=>t.id===e.id),o=r>=0?n[r+1]:void 0;return{start:_e(e,0),end:o?_e(o,0):_e(e,Je(e).length)}}function mW(t){let e=null,a=null,n=null,r=0,o=0,i=0,l=0,s=0,d=null,c=0,h=0,p=0;const u=(e,a,n,r)=>{var o;const i=a!==(e.activeZone??"main"),l="footnote"===a&&r?null==(o=Ma(n.document,r.paragraphId))?void 0:o.footnoteId:void 0,s="footnote"===a&&l!==e.activeFootnoteId;if(!i&&!s)return void t.applyState(n);let d=n.document,c=e.activeSectionIndex??0;if(!d.sections||0===d.sections.length){const t=on("header"),e=on("footer");d={...d,sections:[{id:"section:1",blocks:[],pageSettings:Ue(d.pageSettings??He),header:[t],footer:[e]}]},c=0}const h=d.sections,p=h[c];let u=p.header,f=p.footer,g=null;if("header"===a)if(u&&0!==u.length){const t=u[0];g="paragraph"===t.type?t:pa(t)[0]??null}else g=on("header"),u=[g];else if("footer"===a)if(f&&0!==f.length){const t=f[0];g="paragraph"===t.type?t:pa(t)[0]??null}else g=on("footer"),f=[g];if(u!==p.header||f!==p.footer){const t=[...h];t[c]={...p,header:u,footer:f},d={...d,sections:t}}const m=r||(g?_e(g,0):n.selection.anchor);t.applyState({...n,document:d,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:a,activeFootnoteId:"footnote"===a?l:void 0})},f=e=>{const a=t.state(),n=a.selection,r=Ea(a),o=xa(a.document,n.anchor.paragraphId,r),i=xa(a.document,n.focus.paragraphId,r),l=o?`b${o.blockIndex}r${o.rowIndex}c${o.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";t.logger.debug(`${e} ${n.anchor.paragraphId}[${n.anchor.offset}]→${n.focus.paragraphId}[${n.focus.offset}] [${l}→${s}]`)},g=()=>{var t;e=null,n=null,null!==a&&(t=a,"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(t):window.cancelAnimationFrame(t),a=null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},m=()=>{if(a=null,!e)return;const r=n;if(n=null,!r)return;const o=t.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!(null==o?void 0:o.resolvedFromParagraph))return;const i=t.state(),l=hE(i,{anchor:e,focus:o.position});u(i,o.zone,l,o.position),f("selection:drag")},v=t=>{var r;e&&(n={clientX:t.clientX,clientY:t.clientY},null===a&&(r=m,a="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>r()):globalThis.setTimeout(r,16)))},b=()=>{f("selection:end"),g(),t.focusInputAfterPointerSelection()},y=a=>{var n;if(0!==a.button)return;const f=Date.now(),m=Math.hypot(a.clientX-i,a.clientY-l),y=f-o<=450&&m<=6&&a.button===s;r=y?r+1:1,o=f,i=a.clientX,l=a.clientY,s=a.button;const M=Math.max(a.detail,r),x=t.state();if(t.clearPendingCaretTextStyle(),t.tableResize.handleMouseDown(a))return;a.preventDefault(),t.imageOps.stopImageDrag(),t.imageOps.stopImageResize(),t.clearPreferredColumn(),t.resetTransactionGrouping();const w=t.resolveSurfaceHitAtPoint(a.clientX,a.clientY,{pierce:a.altKey});if(d=w,c=f,h=a.clientX,p=a.clientY,!w)return void t.focusInputAfterPointerSelection();if(null==(n=t.textDrag)?void 0:n.tryStartTextDrag(a,w))return e=null,g(),void t.focusInputAfterPointerSelection();const S=t.getParagraphById(x.document,w.paragraphId);w.zone!==(x.activeZone??"main")?((a,n,r)=>{if(r<2)return e=null,g(),void t.focusInputAfterPointerSelection();e=null,n.resolvedFromParagraph?u(a,n.zone,{...a,selection:{anchor:{...n.position},focus:{...n.position}}},n.position):u(a,n.zone,a),g(),t.focusInputAfterPointerSelection()})(x,w,M):w.textBox?((a,n)=>{const r=t.getParagraphById(a.document,n.textBox.paragraphId);if(!r)return void t.focusInputAfterPointerSelection();e=null;const o=_e(r,n.textBox.startOffset),i=_e(r,n.textBox.endOffset);u(a,n.zone,hE(a,{anchor:o,focus:i}),o),g(),t.focusInputAfterPointerSelection()})(x,w):w.image?((a,n,r)=>{const o=t.getParagraphById(a.document,n.image.paragraphId);if(!o)return void t.focusInputAfterPointerSelection();e=null;const i=_e(o,n.image.startOffset),l=_e(o,n.image.endOffset);u(a,n.zone,hE(a,{anchor:i,focus:l}),i),g(),t.imageOps.startImageDrag(n.image.paragraphId,n.image.startOffset,r,{left:n.image.left,top:n.image.top,width:n.image.width,height:n.image.height}),t.focusInputAfterPointerSelection()})(x,w,a):a.shiftKey&&w.resolvedFromParagraph?((a,n)=>{e=a.selection.anchor,u(a,n.zone,hE(a,{anchor:a.selection.anchor,focus:n.position}),n.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()})(x,w):M>=3&&S?((a,n,r)=>{e=null;const o=gW(a,r,n.zone);u(a,n.zone,hE(a,{anchor:o.start,focus:o.end}),o.start),g(),t.focusInputAfterPointerSelection()})(x,w,S):2===M&&S?((a,n,r)=>{e=null;const o=fW(Je(r),n.paragraphOffset),i=_e(r,o.start),l=_e(r,o.end);u(a,n.zone,hE(a,{anchor:i,focus:l}),i),g(),t.focusInputAfterPointerSelection()})(x,w,S):w.resolvedFromParagraph?(e=w.position,u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()):t.focusInputAfterPointerSelection()};return{handleSurfaceMouseDown:y,handleSurfaceClick:a=>{if(a.detail<3)return;a.preventDefault();const n=t.state(),r=Math.hypot(a.clientX-h,a.clientY-p),o=Date.now()-c<=600&&r<=8?d:t.resolveSurfaceHitAtPoint(a.clientX,a.clientY);if(!(null==o?void 0:o.resolvedFromParagraph))return void t.focusInputAfterPointerSelection();const i=t.getParagraphById(n.document,o.paragraphId);if(!i)return void t.focusInputAfterPointerSelection();e=null;const l=gW(n,i,o.zone);u(n,o.zone,hE(n,{anchor:l.start,focus:l.end}),l.start),g(),t.focusInputAfterPointerSelection()},handleSurfaceDblClick:t=>{t.preventDefault()},handleParagraphMouseDown:(t,e)=>{0===e.button&&(e.preventDefault(),y(e))},stopDragging:g}}function vW(t,e){const a=Da(t);if(a.isCollapsed)return!1;const n=Na(t),r=n.findIndex(t=>t.id===e.paragraphId);if(r<a.startIndex||r>a.endIndex)return!1;const o=n[r];if(!o)return!1;const i=$e(o,e);return!(r===a.startIndex&&i<a.startParagraphOffset)&&!(r===a.endIndex&&i>a.endParagraphOffset)}function bW(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(!1),[l,s]=y(null),[d,c]=y(null);let h=null,p=null,u=null;const f=()=>{var l;null==(l=t.logger)||l.info("text-drag:stop",{dragging:e(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null,copyMode:o()}),h=null,u=null,a(!1),r(null),i(!1),s(null),c(null),p&&(p.remove(),p=null),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",m)},g=n=>{var o,l,d;if(!h)return;const f=n.ctrlKey||n.metaKey;if(i(f),!e()){const e=Math.abs(n.clientX-h.x),r=Math.abs(n.clientY-h.y);if(e+r<4)return;null==(o=t.logger)||o.info("text-drag:activate",{start:h,at:{x:n.clientX,y:n.clientY},deltaX:e,deltaY:r}),a(!0),p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent="*, *::before, *::after { cursor: 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 !important; }",document.head.appendChild(p))}s({x:n.clientX,y:n.clientY});const g=t.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!(null==g?void 0:g.resolvedFromParagraph))return null==(l=t.logger)||l.debug("text-drag:hit-miss",{x:n.clientX,y:n.clientY}),r(null),void c(null);const m=g.tableCellAnchorPosition??g.position,v=`${m.paragraphId}:${m.runId}[${m.offset}]|${g.zone}|src=${g.tableCellAnchorPosition?"cell-anchor":"hit"}`;v!==u&&(null==(d=t.logger)||d.info("text-drag:target",{x:n.clientX,y:n.clientY,zone:g.zone,resolvedFromParagraph:g.resolvedFromParagraph,paragraphId:g.paragraphId,paragraphOffset:g.paragraphOffset,hitPosition:`${g.position.paragraphId}:${g.position.runId}[${g.position.offset}]`,target:`${m.paragraphId}:${m.runId}[${m.offset}]`,source:g.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),u=v),r(m),c(g.caretViewport??null)},m=a=>{var r,i,l;if(null==(r=t.logger)||r.info("text-drag:mouseup",{x:a.clientX,y:a.clientY,dragging:e(),copyMode:o(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null}),e()&&n()){const e=n(),a=o();t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(n=>t.applyTableAwareParagraphEdit(n,t=>gR(t,e,{copy:a})),{mergeKey:a?kV:VV}),null==(i=t.logger)||i.info("text-drag:apply",{mode:a?"copy":"move",destination:`${e.paragraphId}:${e.runId}[${e.offset}]`})}else if(h){const e=h.position;t.applyTransactionalState(t=>vW(t,e)?hE(t,{anchor:e,focus:e}):t,{mergeKey:RV}),null==(l=t.logger)||l.info("text-drag:collapse",{at:`${e.paragraphId}:${e.runId}[${e.offset}]`})}f(),t.focusInputAfterPointerSelection()};return{dragging:e,dropTargetPos:n,copyMode:o,pointerPos:l,caretViewport:d,tryStartTextDrag:(e,n)=>{var o,l,d;if(t.isReadOnly()||!(null==n?void 0:n.resolvedFromParagraph))return null==(o=t.logger)||o.debug("text-drag:skip-start",{reason:t.isReadOnly()?"readonly":"no-hit",x:e.clientX,y:e.clientY}),!1;return vW(t.state(),n.position)?(null==(d=t.logger)||d.info("text-drag:start-pending",{x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`,zone:n.zone}),h={x:e.clientX,y:e.clientY,position:n.tableCellAnchorPosition??n.position},s({x:e.clientX,y:e.clientY}),i(e.ctrlKey||e.metaKey),r(null),c(n.caretViewport??null),a(!1),window.addEventListener("mousemove",g),window.addEventListener("mouseup",m),!0):(null==(l=t.logger)||l.debug("text-drag:skip-start",{reason:"outside-selection",x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`}),!1)},stopDrag:f}}function yW(t){const e=(e,a)=>{var n,r,o,i,l,s;const d=t.state(),c=Na(d),h=c.findIndex(t=>t.id===d.selection.focus.paragraphId);if(-1===h)return!1;const p=t.surfaceRef(),u=(null==p?void 0:p.getBoundingClientRect())??null,f=t.preferredColumnX(),g=null===f?t.caretBox().left+((null==u?void 0:u.left)??0):f,m=p?t.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:p,state:d,documentLayout:t.documentLayout(),zoomFactor:null==(n=t.zoomFactor)?void 0:n.call(t)}):null;let v=h+e;const b=xa(d.document,d.selection.focus.paragraphId,Ea(d));if(b){const t=za(d,b.zone)[b.blockIndex];if(t&&"table"===t.type){const a=Io(t),n=a.find(t=>t.rowIndex===b.rowIndex&&t.cellIndex===b.cellIndex);if(n){const o=[];for(let a=n.visualRowIndex+e;a>=0&&a<t.rows.length;a+=e)o.push(a);for(const n of o){const o=a.filter(t=>t.visualRowIndex===n&&t.cell.blocks.length>0&&"continue"!==t.cell.vMerge);if(0===o.length)continue;const i=null==(r=o.map(e=>{var a,n;const r=null==(a=e.cell.blocks[0])?void 0:a.id,o=r?null==(n=null==m?void 0:m.paragraphs.find(e=>e.paragraphId===r&&e.tableCell&&e.tableCell.tableId===t.id))?void 0:n.tableCell:null,i=(null==o?void 0:o.left)??g,l=o?o.left+o.width:g;return{entry:e,distance:g<i?i-g:g>l?g-l:0}}).sort((t,e)=>t.distance-e.distance)[0])?void 0:r.entry;if(!i)continue;const l=e<0?i.cell.blocks[i.cell.blocks.length-1].id:i.cell.blocks[0].id;v=c.findIndex(t=>t.id===l);break}}else if(e<0){const e=null==(l=null==(i=null==(o=t.rows[0])?void 0:o.cells[0])?void 0:i.blocks[0])?void 0:l.id;e&&(v=c.findIndex(t=>t.id===e)-1)}else{const e=t.rows[t.rows.length-1],a=null==e?void 0:e.cells[e.cells.length-1],n=null==(s=null==a?void 0:a.blocks[a.blocks.length-1])?void 0:s.id;n&&(v=c.findIndex(t=>t.id===n)+1)}}}if(v<0||v>=c.length)return!1;const y=c[v];let M=0;const x=m?Pn(m,y.id):[],w=e<0?x[x.length-1]:x[0];if(w&&w.lines.length>0){const t=w.lines,a=e<0?t[t.length-1]:t[0];M=a.slots.length?a.slots.reduce((t,e)=>Math.abs(g-e.left)<Math.abs(g-t.left)?e:t,a.slots[0]).offset:0}else M=Math.min($e(y,d.selection.focus),Je(y).length);return t.setPreferredColumnX(g),t.resetTransactionGrouping(),t.applyTransactionalState(t=>hE(t,{anchor:a?t.selection.anchor:_e(y,M),focus:_e(y,M)})),t.focusInput(),!0};return{moveSelectionToParagraphBoundary:(e,a)=>{const n=t.state(),r=Na(n).find(t=>t.id===n.selection.focus.paragraphId);if(!r)return!1;const o=_e(r,"start"===e?0:Je(r).length);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:o,focus:o})),!0},moveSelectionToDocumentBoundary:(e,a)=>{const n=t.state(),r=Na(n);if(0===r.length)return!1;const o="start"===e?r[0]:r[r.length-1],i=_e(o,"start"===e?0:Je(o).length);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:i,focus:i})),!0},moveSelectionByWord:(e,a)=>{const n=t.state(),r=Na(n),o=r.findIndex(t=>t.id===n.selection.focus.paragraphId),i=r[o];if(!i)return!1;const l=Je(i),s=n.selection.focus.offset,d=l.length;if(!a&&!Ga(n.selection))return t.clearPreferredColumn(),t.applyState("left"===e?pE(n):uE(n)),!0;let c=i,h=s;"left"===e?0===s&&o>0?(c=r[o-1],h=Je(c).length):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(0===a)return 0;if(uW(t[a-1]??"")){for(;a>0&&uW(t[a-1]??"");)a-=1;return a}for(;a>0&&!uW(t[a-1]??"");)a-=1;for(;a>0&&uW(t[a-1]??"");)a-=1;return a}(l,s):s===d&&o<r.length-1?(c=r[o+1],h=0):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(a>=t.length)return t.length;if(uW(t[a]??"")){for(;a<t.length&&uW(t[a]??"");)a+=1;for(;a<t.length&&!uW(t[a]??"");)a+=1;return a}for(;a<t.length&&!uW(t[a]??"");)a+=1;return a}(l,s);const p=_e(c,h);return t.clearPreferredColumn(),t.applyState(hE(n,{anchor:a?n.selection.anchor:p,focus:p})),!0},moveVerticalByBlock:t=>e(t,!1),moveVerticalSelection:e}}function MW(t){const e=()=>t.state,a=hW({state:e,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,viewportRef:t.viewportRef,zoomFactor:t.zoomFactor,documentLayout:t.documentLayout,canvasSnapshotProvider:t.canvasSnapshotProvider}),n=pW({state:e,applyTransactionalState:t.applyTransactionalState,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint,focusInput:t.focusInput}),r=function(t){const[e,a]=y(null);return{hoveredRevision:e,handleRevisionMouseEnter:(e,n)=>{var r,o,i;const l=Na(t.state());let s;for(const t of l){for(const a of t.runs)if((null==(r=a.revision)?void 0:r.id)===e){s=a.revision;break}if(s)break}const d=t=>{var a,n,r,o,i,l,s,c,h,p,u;for(const f of t)if("paragraph"!==f.type){if((null==(n=null==(a=f.style)?void 0:a.revision)?void 0:n.id)===e)return f.style.revision;if((null==(r=f.gridRevision)?void 0:r.id)===e)return f.gridRevision;for(const t of f.rows){if((null==(i=null==(o=t.style)?void 0:o.revision)?void 0:i.id)===e)return t.style.revision;if((null==(s=null==(l=t.style)?void 0:l.propertyRevision)?void 0:s.id)===e)return t.style.propertyRevision;for(const a of t.cells){if((null==(h=null==(c=a.style)?void 0:c.revision)?void 0:h.id)===e)return a.style.revision;if((null==(u=null==(p=a.style)?void 0:p.propertyRevision)?void 0:u.id)===e)return a.style.propertyRevision;const t=d(a.blocks);if(t)return t}}}};if(!s)for(const a of ha(t.state().document)){for(const t of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])if(t&&(s=d(t),s))break;if(s)break}if(!s)return;const c=n.currentTarget.getBoundingClientRect(),h=null==(o=t.surfaceRef())?void 0:o.getBoundingClientRect();if(!h)return;const p=(null==(i=t.zoomFactor)?void 0:i.call(t))??1;a({revisionId:s.id,author:s.author,date:s.date,type:s.type,left:(c.left-h.left)/p,top:(c.top-h.top)/p})},handleRevisionMouseLeave:()=>{a(null)}}}({state:e,surfaceRef:()=>t.surfaceRef()??null,zoomFactor:t.zoomFactor}),o=bW({state:e,isReadOnly:t.isReadOnly,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,logger:t.logger}),i=mW({state:e,applyState:t.applyState,tableResize:a,imageOps:t.imageOps,clearPendingCaretTextStyle:t.styleController.clearPendingCaretTextStyle,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,getParagraphById:ya,textDrag:{tryStartTextDrag:o.tryStartTextDrag},logger:t.logger}),l=function(t){const[e,a]=y(!1);let n=null;return{handleTextInput:a=>{var r,o,i,l;if(hd("input:text"),t.isReadOnly())return t.logger.debug(`input:readonly ignored value=${JSON.stringify(a.currentTarget.value)}`),void(a.currentTarget.value="");const s=a.currentTarget.value;if(0===s.length)return;if(e())return void t.logger.debug(`input:composing buffer=${JSON.stringify(s)}`);if(null!==n&&s===n)return t.logger.debug(`input:suppressed text=${JSON.stringify(s)}`),n=null,void(a.currentTarget.value="");const d=t.state(),c=d.selection,h=null==(r=Na(d).find(t=>t.id===c.anchor.paragraphId))?void 0:r.runs.find(t=>t.id===c.anchor.runId),p=h?{bold:null==(o=h.styles)?void 0:o.bold,italic:null==(i=h.styles)?void 0:i.italic,underline:null==(l=h.styles)?void 0:l.underline}:null;t.logger.info(`input:text ${JSON.stringify(s)} (len=${s.length}) at ${c.anchor.paragraphId}:${c.anchor.runId}[${c.anchor.offset}] run:${JSON.stringify(p)}`),t.clearPreferredColumn();const u=fA(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,s,u)),{mergeKey:pV}),a.currentTarget.value="",t.focusInput(),pd("input:text")},handleCompositionStart:()=>{t.logger.debug("input:composition start"),a(!0)},handleCompositionEnd:e=>{if(t.isReadOnly())return e.currentTarget.value="",void a(!1);const r=e.data??e.currentTarget.value;if(a(!1),0===r.length)return void(e.currentTarget.value="");const o=t.state().selection;t.logger.info(`input:composition end ${JSON.stringify(r)} (len=${r.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),n=r,t.clearPreferredColumn();const i=fA(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,r,i)),{mergeKey:pV}),e.currentTarget.value="",t.focusInput()},composing:e}}({state:e,isReadOnly:t.isReadOnly,logger:t.logger,clearPreferredColumn:t.clearPreferredColumn,pendingCaretTextStyle:t.styleController.pendingCaretTextStyle,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput}),s=yW({state:e,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,surfaceRef:()=>t.surfaceRef()??null,caretBox:t.caretBox,preferredColumnX:t.preferredColumnX,setPreferredColumnX:t.setPreferredColumnX,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:t.focusInput,zoomFactor:t.zoomFactor,documentLayout:t.documentLayout,canvasSnapshotProvider:t.canvasSnapshotProvider}),{handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}=(u={state:e,isReadOnly:t.isReadOnly,forcePlainTextPaste:t.getForcePlainTextPaste,setForcePlainTextPaste:t.setForcePlainTextPaste,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,insertImageFromFile:t.insertImageFromFile,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint},{handleCopy:t=>{var e,a;const n=cE(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",rE(u.state())))},handleCut:t=>{var e,a;if(u.isReadOnly())return void t.preventDefault();const n=cE(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",rE(u.state())),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>bR(t))),u.focusInput())},handlePaste:t=>{var e,a,n;if(u.isReadOnly())return void t.preventDefault();if(u.forcePlainTextPaste()){u.setForcePlainTextPaste(!1);const a=(null==(e=t.clipboardData)?void 0:e.getData("text/plain"))??"";return 0===a.length?void t.preventDefault():(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>vR(t,a))),t.currentTarget.value="",void u.focusInput())}const r=Bq(t.clipboardData);if(r)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.insertImageFromFile(r),t.currentTarget.value="",void u.focusInput();const o=fE((null==(a=t.clipboardData)?void 0:a.getData("text/html"))??"");if(o.length>0)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>oE(t,o))),t.currentTarget.value="",void u.focusInput();const i=(null==(n=t.clipboardData)?void 0:n.getData("text/plain"))??"";0!==i.length&&(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>vR(t,i))),t.currentTarget.value="",u.focusInput())},handleDrop:t=>{if(u.isReadOnly())return void t.preventDefault();const e=Bq(t.dataTransfer);if(!e)return;t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping();const a=u.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??u.state().selection.focus;u.insertImageFromFile(e,a),u.focusInput()}});var u;return{tableResize:a,tableDrag:n,revisionController:r,textDrag:o,surfaceEvents:i,textInput:l,navigation:s,handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}}function xW(t){const{state:e,logger:a,isReadOnly:n,applyState:r,cloneState:o,focusInput:i,focusInputAfterPointerSelection:l,surfaceRef:s,viewportRef:d,zoomFactor:c,insertImageFromFile:h,getForcePlainTextPaste:p,setForcePlainTextPaste:u,getCommandsController:f,applyTransactionalState:g,clearPreferredColumn:m,resetTransactionGrouping:v,updateHistoryState:b,caretBox:y,preferredColumnX:M,setPreferredColumnX:x,documentLayout:w,canvasSnapshotProvider:S}=t,A=QP({state:()=>e,resetTransactionGrouping:v,applyTransactionalState:g,focusInput:i}),C=UP({state:()=>e,surfaceRef:()=>s()??null,viewportRef:()=>d()??null,documentLayout:w,canvasSnapshotProvider:S,zoomFactor:c}).resolveSurfaceHitAtPoint,I=qP({state:e,applyState:r,applyTransactionalState:g,focusInput:i}),T=EP({applyTransactionalState:g,applySelectionToStatePreservingStructure:(t,e)=>({...t,document:RA(t).document,selection:e}),focusInput:i,logger:a}),k=(t,e)=>{var a;return(null==(a=C(t,e))?void 0:a.position)??null},V=NP({state:e,surfaceRef:s,resolvePositionAtSurfacePoint:k,applyState:r,applyTransactionalState:g,updateHistoryState:b,focusInput:i,focusInputAfterPointerSelection:l,cloneState:o,logger:a,zoomFactor:c}),R=function(t){const e=t=>{const e=vP(t),a=e&&Me(e.run);return a?{width:a.width,height:fp(a,t,0)}:null},a=LP({label:"text box",getSelected:e,applyResize:(t,e,a,n)=>MP(t,e,a,{handleDirection:n}),getMaxWidth:(a,n)=>{const r=$q(t.surfaceRef(),a.document,n,a.activeSectionIndex??0),o=e(a);return o?Math.max(r,o.width):r}},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),n=zP({label:"text box",applyRotate:(t,e)=>bP(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger});return{handleTextBoxResizeHandleMouseDown:(e,n,r,o)=>{o.preventDefault(),o.stopPropagation(),a.start(e,n,r,o,t.state)},handleTextBoxRotateHandleMouseDown:(e,a,r)=>{r.preventDefault(),r.stopPropagation(),n.start(e,a,r,t.state)},stopTextBoxResize:a.stop,stopTextBoxRotate:n.stop}}({state:e,surfaceRef:s,applyState:r,updateHistoryState:b,focusInput:i,cloneState:o,logger:a,zoomFactor:c}),E=OP({state:()=>e,commandsController:f,clearPreferredColumn:m,resetTransactionGrouping:v,focusInput:i,logger:a}),L=MW({state:e,applyState:r,applyTransactionalState:g,isReadOnly:n,logger:a,focusInput:i,focusInputAfterPointerSelection:l,clearPreferredColumn:m,resetTransactionGrouping:v,surfaceRef:s,viewportRef:d,caretBox:()=>y(),preferredColumnX:()=>M(),setPreferredColumnX:x,zoomFactor:c,documentLayout:w,canvasSnapshotProvider:S,resolveSurfaceHitAtPoint:C,resolvePositionAtSurfacePoint:k,tableOps:T,imageOps:V,styleController:E,getForcePlainTextPaste:p,setForcePlainTextPaste:u,insertImageFromFile:h});return{selectedImageRun:()=>Zq(e),selectedTextBoxRun:()=>vP(e),layoutOptionsOverlay:A,fr:I,resolveSurfaceHitAtPoint:C,resolvePositionAtSurfacePoint:k,tableOps:T,imageOps:V,textBoxOps:R,styleController:E,onEditorMouseDown:t=>{0===t.button&&(E.clearPendingCaretTextStyle(),t.preventDefault(),i())},tableResize:L.tableResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}function wW(t){if("main"!==(t.activeZone??"main"))return t;const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=function(){const t=[en("",{styleId:"footnoteText"})];return{id:ja("footnote"),blocks:t}}(),i=function(t){var e,a;const n=t.footnotes,r=(null==(e=null==n?void 0:n.settings)?void 0:e.numberFormat)??"decimal";let o=((null==(a=null==n?void 0:n.settings)?void 0:a.startAt)??1)-1;const i=new Set;for(const{run:l}of Fc(t)){const t=Ae(l);t&&!t.customMark&&(i.has(t.footnoteId)||(i.add(t.footnoteId),o+=1))}return jc(o+1,r)}(e.document),l=function(t,e){const a={styleId:"footnoteReference",superscript:!0},n={footnoteId:t};return{id:ja("run"),text:e,styles:a,kind:"footnoteReference",footnoteReference:n}}(o.id,i),s=$V(a,r,[l]),d=rR(e,Na(e).map((t,e)=>e===n?s:t),Ua(_e(s,r+i.length))),c=function(t){return t||{items:{}}}(d.document.footnotes),h=Xc({...d.document,footnotes:{...c,items:{...c.items,[o.id]:o}}}),p=o.blocks.flatMap(pa).find(Boolean);return p?{...d,document:h,selection:Ua(_e(p,0)),activeZone:"footnote",activeFootnoteId:o.id}:{...d,document:h}}function SW(t,e,a){return t.flatMap(t=>{var n;if("paragraph"===t.type)return[t];let r=t.style;if((null==(n=null==r?void 0:r.revision)?void 0:n.id)===e)if(a){const{revision:t,...e}=r;r=e}else r={...r.revision.previous};let o=t.gridCols,i=t.gridRevision;(null==i?void 0:i.id)===e&&(o=a?o:[...i.previous],i=void 0);const l=t.rows.map(t=>({...t,cells:[...t.cells]}));for(let d=0;d<l.length;d+=1){const t=l[d];for(let n=0;n<t.cells.length;n+=1){const r=t.cells[n],o=r.mergeRevisionState;if(o&&o.revisionId===e){if(a){const{mergeRevisionState:e,...a}=r;t.cells[n]=a;continue}"horizontal"===o.orientation?t.cells.splice(n,o.currentCellCount,...o.previousCells):o.previousCells.forEach((t,e)=>{const a=l[d+e];a&&(a.cells[n]=t)})}}}const s=l.flatMap(t=>{var n,r,o,i;if((null==(r=null==(n=t.style)?void 0:n.revision)?void 0:r.id)===e){if(a&&"delete"===t.style.revision.type||!a&&"insert"===t.style.revision.type)return[]}let l=t.style;if((null==(o=null==l?void 0:l.propertyRevision)?void 0:o.id)===e)if(a){const{propertyRevision:t,...e}=l;l=e}else l={...l.propertyRevision.previous,revision:l.revision};if((null==(i=null==l?void 0:l.revision)?void 0:i.id)===e){const{revision:t,...e}=l;l=e}const s=t.cells.flatMap(t=>{var n,r,o,i,l;if((null==(r=null==(n=t.style)?void 0:n.revision)?void 0:r.id)===e){if(a&&"delete"===t.style.revision.type||!a&&"insert"===t.style.revision.type)return[]}let s=t.style;if((null==(o=null==s?void 0:s.propertyRevision)?void 0:o.id)===e)if(a){const{propertyRevision:t,...e}=s;s=e}else s={...s.propertyRevision.previous,revision:s.revision};let d={...t,style:s,blocks:SW(t.blocks,e,a)};if((null==(i=null==s?void 0:s.revision)?void 0:i.id)===e&&(null==(l=t.mergeRevisionState)?void 0:l.revisionId)!==e){const t=s.revision,{revision:e,...n}=s;d={...d,...a||"merge"!==t.type?{}:t.previous,style:n}}return[d]});return[{...t,isHeader:l&&"isHeader"in l?l.isHeader:t.isHeader,style:l,cells:s}]});return 0===s.length?[]:[{...t,style:r,gridCols:o,gridRevision:i,rows:s}]})}function AW(t,e,a){const n=ha(t.document).map(t=>({...t,blocks:SW(t.blocks,e,a),header:t.header?SW(t.header,e,a):void 0,firstPageHeader:t.firstPageHeader?SW(t.firstPageHeader,e,a):void 0,evenPageHeader:t.evenPageHeader?SW(t.evenPageHeader,e,a):void 0,footer:t.footer?SW(t.footer,e,a):void 0,firstPageFooter:t.firstPageFooter?SW(t.firstPageFooter,e,a):void 0,evenPageFooter:t.evenPageFooter?SW(t.evenPageFooter,e,a):void 0}));return{...t,document:{...t.document,sections:n}}}function CW(t,e){const a=Na(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:jV(t,a)});return AW(rR(t,a,cR(a,Da(t))),e,!0)}function IW(t,e){const a=Na(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:jV(t,a)});return AW(rR(t,a,cR(a,Da(t))),e,!1)}function TW(t,e,a){var n,r,o,i,l;for(const s of t){if("paragraph"===s.type)continue;s.rows.some(t=>t.cells.some(t=>t.blocks.some(t=>e.has(t.id))))&&((null==(n=s.style)?void 0:n.revision)&&a.add(s.style.revision.id),s.gridRevision&&a.add(s.gridRevision.id));for(const t of s.rows){const n=t.cells.filter(t=>t.blocks.some(t=>e.has(t.id)));n.length>0&&((null==(r=t.style)?void 0:r.revision)&&a.add(t.style.revision.id),(null==(o=t.style)?void 0:o.propertyRevision)&&a.add(t.style.propertyRevision.id));for(const t of n)(null==(i=t.style)?void 0:i.revision)&&a.add(t.style.revision.id),(null==(l=t.style)?void 0:l.propertyRevision)&&a.add(t.style.propertyRevision.id),TW(t.blocks,e,a)}}}function kW(t){var e,a,n;const r=Da(t),o=Na(t);if(r.isCollapsed){const t=o[r.startIndex];return t?(null==(e=QV(t,r.startParagraphOffset))?void 0:e.href)??null:null}const i=o.slice(r.startIndex,r.endIndex+1).flatMap((t,e)=>{const a=r.startIndex+e;return _V(t,a===r.startIndex?r.startParagraphOffset:0,a===r.endIndex?r.endParagraphOffset:Qe(t))}).filter(t=>t.text.length>0&&"image"!==t.kind);if(0===i.length)return null;const l=null==(n=null==(a=i[0])?void 0:a.styles)?void 0:n.link;return l&&i.every(t=>{var e;return(null==(e=t.styles)?void 0:e.link)===l})?l:null}function VW(t){const e=Da(t),a=Na(t).map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return MA(t);if(!t.list)return MA(t);const n=t.list.level??0;return n<=0?YV(t):XV(t,n-1)});return rR(t,a,cR(a,e))}function RW(t){const{state:e,logger:a,applyState:n,applyTransactionalState:r,applySelectionAwareTextCommand:o,applySelectionAwareParagraphCommand:i,applyTableAwareParagraphEdit:l,focusInput:s,clearPreferredColumn:d,resetTransactionGrouping:c,toolbarStyleState:h,selectionCollapsed:p,selectedImageRun:u}=t,f=t=>{d(),c(),n(t),s()},g=t=>{d(),c(),o(t),s()},m=t=>{d(),c(),i(t),s()},v=(t,e)=>{d(),c(),r(t,e),s()},b=()=>(()=>{const t=Da(e);return Na(e).slice(t.startIndex,t.endIndex+1)})().some(t=>Boolean(t.list)),y=()=>{const t=e.selection.focus.paragraphId;return Na(e).find(e=>e.id===t)??null},M=()=>{const t=e.selection,a=Ea(e),n=xa(e.document,t.anchor.paragraphId,a),r=xa(e.document,t.focus.paragraphId,a);return n&&r&&n.blockIndex===r.blockIndex?` [table b${n.blockIndex} r${n.rowIndex}:c${n.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},x=(t,e)=>{m(a=>kR(a,t,e))},w=()=>"main"===(e.activeZone??"main"),S=t=>{const a=kW(e);p()&&!a||v(e=>function(t,e){const a=Da(t);if(!a.isCollapsed)return xR(t,"link",e);const n=Na(t)[a.startIndex];if(!n)return t;const r=QV(n,a.startParagraphOffset);if(!r)return t;const o=xR(hE(t,{anchor:_e(n,r.startOffset),focus:_e(n,r.endOffset)}),"link",e),i=Na(o)[a.startIndex];return i?{...o,selection:{anchor:_e(i,r.startOffset),focus:_e(i,r.endOffset)}}:o}(e,t),{mergeKey:vV})};return{applyBooleanStyleCommand:t=>{if(p())return;const n=e.selection;a.info(`toggleStyle:${t} at ${n.anchor.paragraphId}:${n.anchor.runId}[${n.anchor.offset}..${n.focus.offset}]${M()}`),g(e=>MR(e,t))},applyValueStyleCommand:(t,n)=>{if(p())return;const r=e.selection;a.info(`setStyle:${t}=${JSON.stringify(n)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${M()}`),g(e=>xR(e,t,n))},applyChangeTextCaseCommand:t=>{p()||g(e=>AR(e,t))},applyClearFormattingCommand:()=>{p()||g(t=>function(t){const e=Da(t);if(e.isCollapsed)return t;const a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?t:dR(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:Qe(t),t=>{var e;const a=null==(e=t.styles)?void 0:e.link,n=null!=a&&""!==a?{link:a}:{};return{...t,styles:n}}));return rR(t,a,cR(a,e))}(t))},applyParagraphStyleCommand:x,toggleParagraphFlagCommand:t=>{const e=!h()[t];x(t,!!e||null)},applyParagraphListCommand:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t),r=a.startIndex,o=a.endIndex,i=n.slice(r,o+1),l=i.length>0&&i.every(t=>{var a;return(null==(a=t.list)?void 0:a.kind)===e}),s=n.map((t,a)=>{var n,i,s;if(a<r||a>o)return MA(t);const d=MA(t);return l?(delete d.list,d):(d.list={kind:e,level:(null==(n=t.list)?void 0:n.level)??0,format:null==(i=t.list)?void 0:i.format,startAt:null==(s=t.list)?void 0:s.startAt},d)});return rR(t,s,cR(s,a))}(e,t))},handleListFormatChange:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t).map((t,n)=>n<a.startIndex||n>a.endIndex?MA(t):t.list?{...MA(t),list:{...t.list,format:e||void 0}}:MA(t));return rR(t,n,cR(n,a))}(e,t))},handleListStartAtChange:t=>{m(e=>function(t,e){const a=Da(t),n=Na(t).map((t,n)=>n<a.startIndex||n>a.endIndex?MA(t):t.list?{...MA(t),list:{...t.list,startAt:null!==e?e:void 0}}:MA(t));return rR(t,n,cR(n,a))}(e,t))},applyInsertSectionBreakCommand:t=>{f(function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,offset:r}=lR(a),o=ha(a.document),i=Ea(a);if("main"!==La(a))return t;const l=o[i];if(!l)return t;const s=l.blocks.findIndex(t=>"paragraph"===t.type&&t.id===n.id);if(-1===s)return t;const d=l.blocks.slice(0,s),c=l.blocks.slice(s+1),h=jV(n,_V(n,0,r),JV(n,r)),p=_V(n,r,Qe(n)),u=p.length>0?KV(n,p.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=n.style?{...n.style}:void 0,t.list=n.list?{...n.list}:void 0,t})(),f={id:`section:${Math.random().toString(36).slice(2,9)}`,blocks:[u,...c],pageSettings:{...l.pageSettings},header:l.header?SA(l.header):void 0,footer:l.footer?SA(l.footer):void 0,breakType:e},g={...l,blocks:[...d,h]},m=[...o.slice(0,i),g,f,...o.slice(i+1)];return{...a,document:{...a.document,sections:m},activeSectionIndex:i+1,selection:iR(_e(u,0))}}(e,t))},applyInsertPageBreakCommand:()=>{v(t=>l(t,t=>TR(t)))},canInsertFootnoteCommand:w,applyInsertFootnoteCommand:()=>{w()&&v(t=>wW(t))},handleStyleChange:t=>{m(e=>function(t,e){return kR(t,"styleId",e)}(e,t||null))},applyUpdateSectionSettingsCommand:(t,a)=>{f(function(t,e,a){var n;const r=ha(t.document);if(e<0||e>=r.length)return t;const o=[...r];return o[e]={...o[e],...a,pageSettings:{...o[e].pageSettings,...a.pageSettings??{},margins:{...o[e].pageSettings.margins,...(null==(n=a.pageSettings)?void 0:n.margins)??{}}}},{...t,document:{...t.document,sections:o}}}(e,t,a))},applyToggleTrackChangesCommand:()=>{f(function(t){return{...t,trackChangesEnabled:!t.trackChangesEnabled}}(e))},applyToggleShowMarginsCommand:()=>{n({...e,showMargins:!e.showMargins}),s()},applyToggleShowParagraphMarksCommand:()=>{n({...e,showParagraphMarks:!e.showParagraphMarks}),s()},applyAcceptRevisionsCommand:()=>{f(function(t){var e;const a=Da(t),n=Na(t),r=new Set;for(let l=a.startIndex;l<=a.endIndex;l+=1){const t=n[l],o=_V(t,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}const o=new Set(n.slice(a.startIndex,a.endIndex+1).map(t=>t.id));for(const l of ha(t.document))for(const t of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])t&&TW(t,o,r);let i=t;for(const l of r)i=CW(i,l);return i}(e))},applyRejectRevisionsCommand:()=>{f(function(t){var e;const a=Da(t),n=Na(t),r=new Set;for(let l=a.startIndex;l<=a.endIndex;l+=1){const t=n[l],o=_V(t,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:Qe(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}const o=new Set(n.slice(a.startIndex,a.endIndex+1).map(t=>t.id));for(const l of ha(t.document))for(const t of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])t&&TW(t,o,r);let i=t;for(const l of r)i=IW(i,l);return i}(e))},applyLinkCommand:S,promptForLink:()=>{const a=kW(e)??"";p()&&!a||t.openLinkDialog(a)},removeLinkCommand:()=>{S(null)},applyImageAltCommand:t=>{u()&&v(e=>function(t,e){return Xq(t,t=>({...t,alt:e??void 0}))}(e,t),{mergeKey:bV})},promptForImageAlt:()=>{var e;const a=u();if(!a)return;const n=(null==(e=ye(a.run))?void 0:e.alt)??"";t.openImageAltDialog(n)},applyImageCaptionCommand:e=>{u()&&v(a=>Qq(a,e,t.imageCaptionLabel()),{mergeKey:yV})},promptForImageCaption:()=>{u()&&t.openImageCaptionDialog(Jq(e)??"")},handleListTab:t=>!xa(e.document,e.selection.focus.paragraphId,Ea(e))&&(!!b()&&(m(e=>"indent"===t?function(t){const e=Da(t),a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?MA(t):t.list?XV(t,(t.list.level??0)+1):MA(t));return rR(t,a,cR(a,e))}(e):VW(e)),!0)),handleListEnter:()=>{const t=y();return!!(null==t?void 0:t.list)&&(d(),c(),p()&&0===Je(t).length?i(t=>function(t){const e=Da(t),a=Na(t).map((t,a)=>a<e.startIndex||a>e.endIndex?MA(t):YV(t));return rR(t,a,cR(a,e))}(t)):r(t=>l(t,t=>function(t){const e=Ga(t.selection)?t:sR(t),{paragraph:a,index:n,offset:r}=lR(e),o=jV(a,_V(a,0,r),JV(a,r)),i=_V(a,r,Qe(a)),l=i.length>0?KV(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Ja("");return t.style=a.style?{...a.style}:void 0,t.list=xA(a.list),t})(),s=Na(e);return rR(e,[...wA(s.slice(0,n)),o,l,...wA(s.slice(n+1))],iR(_e(l,0)))}(t)),{mergeKey:mV}),s(),!0)},handleListBoundaryBackspace:t=>{const a=y();if(!(null==a?void 0:a.list)||!p())return!1;return 0===$e(a,e.selection.focus)&&(d(),c(),i(t=>VW(t)),t.currentTarget.value="",s(),!0)}}}class EW{constructor(){a(this,"bindings",new Map)}register(t){this.bindings.set(t.id,t)}unregister(t){this.bindings.delete(t)}getBindings(){return Array.from(this.bindings.values())}execute(t,e,a){var n;const r=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();for(const i of this.bindings.values())if(i.key.toLowerCase()===o&&Boolean(i.ctrlOrMeta)===r&&Boolean(i.shift)===t.shiftKey&&Boolean(i.alt)===t.altKey){if(i.command&&a){if((null==(n=a.canExecuteCommand)?void 0:n.call(a,i.command))??!0)return a.executeCommand(i.command),t.preventDefault(),!0}if(!1!==i.execute(e,t))return t.preventDefault(),!0}return!1}}const LW=[{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:t=>{const e=t.state(),a=Na(e);if(0===a.length)return!1;const n=a[0],r=a[a.length-1];return t.clearPreferredColumn(),t.applyState(hE(e,{anchor:_e(n,0),focus:_e(r,Je(r).length)})),t.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:t=>!!t.selectedImageRun()&&(t.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:t=>(t.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:t=>(t.setForcePlainTextPaste(!0),t.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:t=>(t.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:t=>(t.toggleFindReplace(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:t=>(t.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:t=>(t.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:t=>(t.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:t=>(t.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>TR(t))),t.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>mR(t,"\n"))),t.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:t=>(t.commandsController.handleListEnter()||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>IR(t))),t.focusInput()),!0)}];function zW(t){const e=new EW;LW.forEach(t=>e.register(t));return{handleKeyDown:a=>{const n=t.state();if(t.isReadOnly()){const t=a.key,e=t.toLowerCase(),n="ArrowLeft"===t||"ArrowRight"===t||"ArrowUp"===t||"ArrowDown"===t||"Home"===t||"End"===t||"PageUp"===t||"PageDown"===t,r="Shift"===t||"Control"===t||"Meta"===t||"Alt"===t,o=(a.ctrlKey||a.metaKey)&&("a"===e||"c"===e);return void(n||r||o||a.preventDefault())}const r=t.executeCommand?{executeCommand:(e,a)=>{var n;return null==(n=t.executeCommand)?void 0:n.call(t,e,a)},canExecuteCommand:(e,a)=>{var n;return null==(n=t.canExecuteCommand)?void 0:n.call(t,e,a)}}:void 0;if(!e.execute(a,t,r)){if((a.ctrlKey||a.metaKey)&&!a.altKey){if(("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),t.resetTransactionGrouping(),t.moveSelectionByWord("ArrowLeft"===a.key?"left":"right",a.shiftKey)))return void t.focusInput();if("Backspace"===a.key||"Delete"===a.key){if(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),!Ga(n.selection))return t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),a.currentTarget.value="",void t.focusInput();const e=Na(n),r=e.findIndex(t=>t.id===n.selection.focus.paragraphId),o=e[r];if(!o)return a.currentTarget.value="",void t.focusInput();if("Backspace"===a.key&&o.list){if(0===$e(o,n.selection.focus))return t.applySelectionAwareParagraphCommand(t=>VW(t)),a.currentTarget.value="",void t.focusInput()}const i=n.selection.focus.offset,l=Je(o),s=fW(l,i);return"Backspace"===a.key?0===i||s.start===i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(hE(e,{anchor:_e(o,s.start),focus:_e(o,i)}),t=>bR(t))):i>=l.length?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))):s.end>i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(hE(e,{anchor:_e(o,i),focus:_e(o,s.end)}),t=>bR(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))),a.currentTarget.value="",void t.focusInput()}}if("Home"===a.key||"End"===a.key){a.preventDefault(),t.resetTransactionGrouping();const e="Home"===a.key?"start":"end";return a.ctrlKey||a.metaKey?t.moveSelectionToDocumentBoundary(e,a.shiftKey):t.moveSelectionToParagraphBoundary(e,a.shiftKey),void t.focusInput()}if(!a.altKey||a.ctrlKey||a.metaKey||"ArrowUp"!==a.key&&"ArrowDown"!==a.key||(a.preventDefault(),t.resetTransactionGrouping(),t.clearPreferredColumn(),!t.moveSelectedImageByParagraph("ArrowUp"===a.key?-1:1)))switch(a.key){case"Backspace":return t.commandsController.handleListBoundaryBackspace(a)?void a.preventDefault():(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>bR(t))),a.currentTarget.value="",void t.focusInput());case"Delete":return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>yR(t))),a.currentTarget.value="",void t.focusInput();case"Tab":{if(t.commandsController.handleListTab(a.shiftKey?"outdent":"indent"))return void a.preventDefault();const e=t.resolveAdjacentTableCellPosition(n.document,n.selection.focus.paragraphId,a.shiftKey?-1:1);if(e)return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applySelectionPreservingStructure({anchor:e,focus:e}),void t.focusInput();break}case"ArrowLeft":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(sE(n,-1))):(t.clearPreferredColumn(),t.applyState(pE(n))),void t.focusInput();case"ArrowRight":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(function(t){return sE(t,1)}(n))):(t.clearPreferredColumn(),t.applyState(uE(n))),void t.focusInput();case"ArrowUp":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(-1,!0)||(t.applyState(function(t){return dE(t,-1)}(n)),t.focusInput()):t.moveVerticalByBlock(-1)||(t.applyState(function(t){return lE(t,-1)}(n)),t.focusInput()));case"ArrowDown":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(1,!0)||(t.applyState(function(t){return dE(t,1)}(n)),t.focusInput()):t.moveVerticalByBlock(1)||(t.applyState(function(t){return lE(t,1)}(n)),t.focusInput()));default:return}}},registry:e}}const NW=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];const OW=t=>Math.round(t/Ne*ke);function qW(t,e=3){var a;const n=[];for(const r of ba(t.document)){const t=zn(null==(a=r.style)?void 0:a.styleId);if(null===t||t>e)continue;const o=Je(r).trim();o&&n.push({id:r.id,level:t,text:o})}return n}function PW(t){const e=Xa(t.text).id;return t.fieldChar?{id:e,text:t.text,kind:"fieldChar",fieldChar:t.fieldChar}:void 0!==t.fieldInstruction?{id:e,text:t.text,kind:"fieldInstruction",fieldInstruction:t.fieldInstruction}:{id:e,text:t.text,kind:"text"}}function WW(t,e){const a=Ja("");return a.runs=t,e&&(a.style=e),a}function BW(t,e,a){const n=void 0!==e?String(e):"";return WW([PW({text:`${t.text}\t${n}`})],{tabs:[{position:a,type:"right",leader:"dot"}],spacingAfter:OW(40),indentLeft:OW(397*(t.level-1))})}function FW(t){const{width:e,margins:a}=t.pageSettings;return Fl(Math.max(0,e-a.left-a.right)*Re,2)}function HW(t,e,a,n){const r=ha(t.document),o=r[e];if(!o)return t;const i=[...r];return i[e]={...o,blocks:a},{...t,document:{...t.document,sections:i},selection:iR(_e(n,0))}}function UW(t,e=()=>{},a=3){if("main"!==La(t))return t;const n=Ea(t),r=ha(t.document)[n];if(!r)return t;const o=function(t,e,a){const n=t.map(t=>BW(t,e(t.id),a));return[WW([PW({text:"",fieldChar:{kind:"begin"}}),PW({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),PW({text:"",fieldChar:{kind:"separate"}})]),...n,WW([PW({text:"",fieldChar:{kind:"end"}})])]}(qW(t,a),e,FW(r)),i=Fa(t,t.selection.focus),l=r.blocks.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&pa(t).some(t=>t.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return HW(t,n,[...r.blocks.slice(0,s),...o,...r.blocks.slice(s)],o[0])}function GW(t,e=()=>{},a=3){const n=Ea(t),r=ha(t.document)[n];if(!r)return t;const o=function(t){let e=0,a="",n=-1,r=-1,o=!1;for(let i=0;i<t.length;i+=1){const l=t[i];if("paragraph"===l.type)for(const t of l.runs){const l=we(t),s=Se(t);if("begin"===(null==l?void 0:l.kind))e+=1,1===e&&(r=i,a="",o=!1,n=-1);else if(1===e&&void 0!==s)a+=s,/\bTOC\b/i.test(a)&&(o=!0);else if("separate"===(null==l?void 0:l.kind))1===e&&(n=i);else if("end"===(null==l?void 0:l.kind)){if(1===e&&o)return{startBlockIndex:n>=0?n:r,endBlockIndex:i};e=Math.max(0,e-1)}}}return null}(r.blocks);if(!o)return t;const i=qW(t,a).map(t=>BW(t,e(t.id),FW(r)));return HW(t,n,[...r.blocks.slice(0,o.startBlockIndex+1),...i,...r.blocks.slice(o.endBlockIndex)],i[0]??r.blocks[o.startBlockIndex])}function DW(t){return null!=t&&""!==t?Number(t):null}function jW({gate:t,style:e,selection:a,history:n,formatting:r,link:o,command:i,valueCommand:l,actionCommand:s}){const d=e.state;return{selectAll:i("selectAll",r.selectAll),insertFootnote:i("insertFootnote",r.insertFootnote),pastePlainText:i("pastePlainText",r.pastePlainText),bold:i("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(d().underline)})),strike:i("strike",r.strike,()=>({isActive:Boolean(d().strike)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:i("link",()=>(o.prompt(),!0),()=>({isEnabled:t.isCommandEnabled("link")&&o.canPrompt(),isActive:Boolean(d().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:i("find",r.find),replace:i("replace",r.replace),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges),acceptRevisions:i("acceptRevisions",r.acceptRevisions),rejectRevisions:i("rejectRevisions",r.rejectRevisions),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(El(),{isActive:Ll()})),undo:i("undo",n.undo,()=>({isEnabled:t.isCommandEnabled("undo")&&n.canUndo()})),redo:i("redo",n.redo,()=>({isEnabled:t.isCommandEnabled("redo")&&n.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),splitBlock:i("splitBlock",r.splitBlock),setFontFamily:l("setFontFamily",t=>r.setFontFamily(t||null),()=>d().fontFamily),setFontSize:l("setFontSize",t=>{const e=t&&"object"==typeof t&&"size"in t?t.size:t;return r.setFontSize(null!=e&&""!==e?_w(e):null),!0},()=>Qw(d().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),changeTextCase:s("changeTextCase",t=>{r.changeTextCase(t??"sentence")},()=>({isEnabled:t.isCommandEnabled("changeTextCase")&&!a.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",t=>r.setColor(t??null),()=>d().color||null),setHighlight:l("setHighlight",t=>r.setHighlight(t??null),()=>d().highlight||null),setTextShading:l("setTextShading",t=>r.setTextShading(t??null),()=>d().textShading||null),setStyleId:l("setStyleId",t=>r.setStyleId(String(t)),()=>d().styleId||"normal"),setCharacterStyleId:l("setCharacterStyleId",t=>r.setCharacterStyleId(String(t)),()=>d().characterStyleId||""),setUnderlineStyle:l("setUnderlineStyle",t=>(r.setUnderlineStyle(t||null),!0),()=>d().underlineStyle)}}function ZW({gate:t,style:e,document:a,link:n,image:r,browser:o,actionCommand:i}){const l=e.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:a.documentStyles()})),print:i("print",()=>o.print(),()=>({isEnabled:!0})),copy:i("copy",()=>o.copy(),()=>({isEnabled:!0})),exportDocx:i("exportDocx",()=>a.exportDocx()),exportPdf:i("exportPdf",()=>a.exportPdf()),importDocument:i("importDocument",()=>a.importDocument()),insertImage:i("insertImage",()=>a.insertImage()),insertShape:i("insertShape",t=>a.insertShape(String(t))),unlink:i("unlink",()=>n.remove(),()=>({isEnabled:t.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()}))}}function KW({style:t,paragraph:e,section:a,valueCommand:n,actionCommand:r}){const o=t.state;return{outdent:r("outdent",()=>e.outdent()),indent:r("indent",()=>e.indent()),togglePageBreakBefore:r("togglePageBreakBefore",()=>e.togglePageBreakBefore(),()=>({isActive:Boolean(o().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>e.toggleKeepWithNext(),()=>({isActive:Boolean(o().keepWithNext)})),setSpacingAfter:n("setSpacingAfter",t=>(e.setSpacingAfter(DW(t)),!0),()=>o().spacingAfter),setSpacingBefore:n("setSpacingBefore",t=>(e.setSpacingBefore(DW(t)),!0),()=>o().spacingBefore),setIndentLeft:n("setIndentLeft",t=>(e.setIndentLeft(DW(t)),!0),()=>o().indentLeft),setIndentRight:n("setIndentRight",t=>(e.setIndentRight(DW(t)),!0),()=>o().indentRight),setIndentFirstLine:n("setIndentFirstLine",t=>(e.setIndentFirstLine(DW(t)),!0),()=>o().indentFirstLine),setIndentHanging:n("setIndentHanging",t=>(e.setIndentHanging(DW(t)),!0),()=>o().indentHanging),setSpecialIndent:r("setSpecialIndent",t=>{const a=t??{};e.setSpecialIndent(a.kind??"none",DW(a.value))},()=>{const t=Number(o().indentFirstLine),e=Number(o().indentHanging),a=Number.isFinite(e)&&e>0?"hanging":Number.isFinite(t)&&t>0?"firstLine":"none";return{isActive:"none"!==a,value:a}}),setParagraphShading:n("setParagraphShading",t=>(e.setShading(t??null),!0),()=>o().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>e.applyBorders()),setLineHeight:n("setLineHeight",t=>(e.setLineHeight(DW(t)),!0),()=>o().lineHeight),setListFormat:r("setListFormat",t=>e.setListFormat(String(t))),setListStartAt:r("setListStartAt",t=>e.setListStartAt(DW(t))),toggleOrientation:r("toggleOrientation",()=>a.toggleOrientation(),()=>({isActive:a.isLandscape()})),setOrientation:r("setOrientation",t=>a.setOrientation(t)),sectionBreakNextPage:r("sectionBreakNextPage",()=>a.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>a.breakContinuous()),setPageMargins:r("setPageMargins",t=>{a.setPageMargins(t??{})},()=>({value:a.getMargins()}))}}function XW({gate:t,table:e,actionCommand:a}){return{tableContext:a("tableContext",()=>{},()=>({isEnabled:e.insideTable(),isActive:e.insideTable(),value:e.selectionLabel()})),tableMerge:a("tableMerge",()=>e.merge(),()=>({isEnabled:t.isCommandEnabled("tableMerge")&&e.canMerge()})),tableSplit:a("tableSplit",()=>e.split(),()=>({isEnabled:t.isCommandEnabled("tableSplit")&&e.canSplit()})),tableInsertColumnBefore:a("tableInsertColumnBefore",()=>e.insertColumnBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnBefore")&&e.canEditColumn()})),tableInsertColumnAfter:a("tableInsertColumnAfter",()=>e.insertColumnAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnAfter")&&e.canEditColumn()})),tableDeleteColumn:a("tableDeleteColumn",()=>e.deleteColumn(),()=>({isEnabled:t.isCommandEnabled("tableDeleteColumn")&&e.canEditColumn()})),tableInsertRowBefore:a("tableInsertRowBefore",()=>e.insertRowBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowBefore")&&e.canEditRow()})),tableInsertRowAfter:a("tableInsertRowAfter",()=>e.insertRowAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowAfter")&&e.canEditRow()})),tableDeleteRow:a("tableDeleteRow",()=>e.deleteRow(),()=>({isEnabled:t.isCommandEnabled("tableDeleteRow")&&e.canEditRow()})),tableCellShading:a("tableCellShading",t=>e.cellShading(t??null)),tableCellBorders:a("tableCellBorders",()=>e.cellBorders()),tableCellNoBorders:a("tableCellNoBorders",()=>e.cellNoBorders()),tableWidth100:a("tableWidth100",()=>e.width100()),tableAlignLeft:a("tableAlignLeft",()=>e.alignLeft()),tableAlignCenter:a("tableAlignCenter",()=>e.alignCenter()),tableAlignRight:a("tableAlignRight",()=>e.alignRight()),tableSetCellWidth:a("tableSetCellWidth",t=>e.setCellWidth(String(t))),insertTable:a("insertTable",t=>{const{rows:a,cols:n,columns:r}=t??{},o=n??r;a&&o&&e.insert(a,o)})}}function YW(t){const e=e=>{const a=Number(t.styleController.toolbarStyleState().fontSize),n=Number.isFinite(a)&&a>0?Yw(a):11,r="increase"===e?function(t){for(const e of Xw)if(e>t+1e-6)return e;return Math.round(t)+10}(n):function(t){for(let e=Xw.length-1;e>=0;e-=1){const a=Xw[e];if(a<t-1e-6)return a}return Math.max(1,Math.round(t)-1)}(n);return t.styleController.applyToolbarValueStyleCommand("fontSize",Jw(r)),!0},a=t=>{const e=nh(t.document),a=new Map;for(const n of e.pages)for(const t of n.blocks){const e=t.paragraphId;e&&!a.has(e)&&a.set(e,n.index+1)}return t=>a.get(t)},n={isLandscape:()=>{var e,a;const n=Ea(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return"landscape"===(null==(a=null==r?void 0:r.pageSettings)?void 0:a.orientation)},setOrientation:e=>{var a;const n=Ea(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;r&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,orientation:e}})},toggleOrientation:()=>{var e,a;const r=Ea(t.state()),o=(null==(e=t.state().document.sections)?void 0:e[r])??t.state().document;if(!o)return;const i=(null==(a=o.pageSettings)?void 0:a.orientation)??"portrait";n.setOrientation("portrait"===i?"landscape":"portrait")},breakNextPage:()=>t.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>t.commandsController.applyInsertSectionBreakCommand("continuous"),getMargins:()=>{var e,a;const n=Ea(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return null==(a=null==r?void 0:r.pageSettings)?void 0:a.margins},setPageMargins:e=>{var a;const n=Ea(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;(null==r?void 0:r.pageSettings)&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,margins:{...r.pageSettings.margins,...e}}})}};return function(t){const e=(a=t.gate.isCommandEnabled,(t,e,n)=>({execute:e,refresh:()=>({isEnabled:a(t),...null==n?void 0:n()})}));var a;const n=function(t){return(e,a,n)=>({execute:a,refresh:()=>({isEnabled:t(e),value:n()})})}(t.gate.isCommandEnabled),r=function(t){return(e,a,n)=>({execute:t=>(a(t),!0),refresh:()=>({isEnabled:t(e),...null==n?void 0:n()})})}(t.gate.isCommandEnabled);return{name:"Essentials",commands:{...jW({gate:t.gate,style:t.style,selection:t.selection,history:t.history,formatting:t.formatting,link:t.link,command:e,valueCommand:n,actionCommand:r}),...ZW({gate:t.gate,style:t.style,document:t.document,link:t.link,image:t.image,browser:t.browser,actionCommand:r}),...KW({style:t.style,paragraph:t.paragraph,section:t.section,valueCommand:n,actionCommand:r}),...XW({gate:t.gate,table:t.table,actionCommand:r})}}}({gate:{isCommandEnabled:e=>!t.isReadOnly()&&("insertFootnote"!==e||t.commandsController.canInsertFootnoteCommand())},style:{state:()=>t.styleController.toolbarStyleState()},selection:{isCollapsed:()=>Ga(t.state().selection)},history:{canUndo:()=>t.undoStack().length>0,canRedo:()=>t.redoStack().length>0,undo:()=>(t.historyActions.performUndo(),!0),redo:()=>(t.historyActions.performRedo(),!0)},formatting:{selectAll:()=>{const e=ba(t.state().document);if(0===e.length)return!1;const a=e[0],n=e[e.length-1];return t.applyState({...t.state(),selection:{anchor:_e(a,0),focus:_e(n,Je(n).length)}}),t.focusInput(),!0},insertFootnote:()=>(t.commandsController.applyInsertFootnoteCommand(),!0),insertTableOfContents:()=>(t.applyTransactionalState(t=>UW(t,a(t))),t.focusInput(),!0),updateTableOfContents:()=>(t.applyTransactionalState(t=>GW(t,a(t))),t.focusInput(),!0),pastePlainText:()=>(t.forcePlainTextPaste.set(!0),t.focusInput(),!0),bold:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),strike:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),superscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(t.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(t.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(t.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(t.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(t.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(t.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(t.findReplace.setIsOpen(!0),!0),replace:()=>(t.findReplace.setIsOpen(!0),!0),toggleTrackChanges:()=>(t.commandsController.applyToggleTrackChangesCommand(),!0),acceptRevisions:()=>(t.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(t.commandsController.applyRejectRevisionsCommand(),!0),toggleShowMargins:()=>(t.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(t.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(_s(),!0),pageBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>TR(t))),t.focusInput(),!0),lineBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>mR(t,"\n"))),t.focusInput(),!0),splitBlock:()=>(t.commandsController.handleListEnter()||(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>IR(t))),t.focusInput()),!0),setFontFamily:e=>(t.styleController.applyToolbarValueStyleCommand("fontFamily",e),!0),setFontSize:e=>(t.styleController.applyToolbarValueStyleCommand("fontSize",e),!0),increaseFontSize:()=>e("increase"),decreaseFontSize:()=>e("decrease"),changeTextCase:e=>(t.commandsController.applyChangeTextCaseCommand(e),!0),clearFormatting:()=>Ga(t.state().selection)?(t.styleController.clearPendingCaretTextStyle(),t.focusInput(),!0):(t.commandsController.applyClearFormattingCommand(),!0),setColor:e=>(t.styleController.applyToolbarValueStyleCommand("color",e),!0),setHighlight:e=>(t.styleController.applyToolbarValueStyleCommand("highlight",e),!0),setTextShading:e=>(t.styleController.applyToolbarValueStyleCommand("shading",e),!0),setStyleId:e=>(t.commandsController.handleStyleChange(e),!0),setCharacterStyleId:e=>(t.styleController.applyToolbarValueStyleCommand("styleId",e||null),!0),setUnderlineStyle:e=>t.styleController.applyToolbarValueStyleCommand("underlineStyle",e)},document:{documentStyles:()=>{var e,a;const n=t.state().document,r=(null==n?void 0:n.styles)??{},o=new Set;for(const t of ba(n)){(null==(e=t.style)?void 0:e.styleId)&&o.add(t.style.styleId);for(const e of t.runs)(null==(a=e.styles)?void 0:a.styleId)&&o.add(e.styles.styleId)}return Object.values(r).map(t=>{var e;const a=oa(t.id,r);return{id:t.id,name:t.name,type:t.type,qFormat:t.qFormat,uiPriority:t.uiPriority,semiHidden:t.semiHidden,unhideWhenUsed:t.unhideWhenUsed,isUsed:o.has(t.id),fontFamily:(null==(e=a.fontFamily)?void 0:e.trim())||void 0,fontSize:"number"==typeof a.fontSize?a.fontSize:void 0,color:a.color??void 0,bold:a.bold??void 0,italic:a.italic??void 0}})},exportDocx:()=>{t.docIO.handleExportDocx()},exportPdf:()=>{t.docIO.handleExportPdf()},importDocument:()=>{var e;return null==(e=t.importInputRef())?void 0:e.click()},insertImage:()=>{var e;return null==(e=t.imageInputRef())?void 0:e.click()},insertShape:e=>t.applyTransactionalState(t=>function(t,e){const a=Ga(t.selection)?t:sR(t),{paragraph:n,index:r,offset:o}=lR(a),i={width:150,height:100,blocks:[Ja("")],shape:{preset:e,fill:"#4472C4",borderColor:"#2F528F",borderWidthPt:1},floating:Uq(void 0,"front")},l=$V(n,o,[Ya("",JV(n,o),void 0,i)]);return rR(a,Na(a).map((t,e)=>e===r?l:MA(t)),iR(_e(l,o+1)))}(t,e))},link:{prompt:()=>t.commandsController.promptForLink(),remove:()=>t.commandsController.removeLinkCommand(),canPrompt:()=>!Ga(t.state().selection)||Boolean(t.styleController.toolbarStyleState().link)},image:{promptAlt:()=>t.commandsController.promptForImageAlt(),promptCaption:()=>t.commandsController.promptForImageCaption(),isSelected:()=>Boolean(t.selectedImageRun())},browser:{print:()=>window.print(),copy:()=>{document.execCommand("copy")}},paragraph:{togglePageBreakBefore:()=>t.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>t.commandsController.toggleParagraphFlagCommand("keepWithNext"),setSpacingAfter:e=>t.commandsController.applyParagraphStyleCommand("spacingAfter",e),setSpacingBefore:e=>t.commandsController.applyParagraphStyleCommand("spacingBefore",e),setIndentLeft:e=>t.commandsController.applyParagraphStyleCommand("indentLeft",e),setIndentRight:e=>t.commandsController.applyParagraphStyleCommand("indentRight",e),setIndentFirstLine:e=>t.commandsController.applyParagraphStyleCommand("indentFirstLine",e),setIndentHanging:e=>t.commandsController.applyParagraphStyleCommand("indentHanging",e),setSpecialIndent:(e,a)=>{const n=a??48;t.applyTransactionalState(t=>{let a=kR(t,"indentFirstLine",null);return a=kR(a,"indentHanging",null),"firstLine"===e?a=kR(a,"indentFirstLine",n):"hanging"===e&&(a=kR(a,"indentHanging",n)),a},{mergeKey:xV}),t.focusInput()},setShading:e=>t.commandsController.applyParagraphStyleCommand("shading",e),applyBorders:()=>{const e={width:1,type:"solid",color:"#000000"};t.applyTransactionalState(t=>{let a=kR(t,"borderTop",e);return a=kR(a,"borderRight",e),a=kR(a,"borderBottom",e),a=kR(a,"borderLeft",e),a},{mergeKey:wV}),t.focusInput()},setLineHeight:e=>t.commandsController.applyParagraphStyleCommand("lineHeight",e),setListFormat:e=>t.commandsController.handleListFormatChange(e),setListStartAt:e=>t.commandsController.handleListStartAtChange(e),outdent:()=>{t.commandsController.handleListTab("outdent")},indent:()=>{t.commandsController.handleListTab("indent")}},section:n,table:(()=>{const e=(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()};return{insideTable:()=>Boolean(xa(t.state().document,t.state().selection.focus.paragraphId,Ea(t.state()))),selectionLabel:()=>{if(Da(t.state()).isCollapsed)return null;const e=Ea(t.state()),a=xa(t.state().document,t.state().selection.anchor.paragraphId,e),n=xa(t.state().document,t.state().selection.focus.paragraphId,e);if(!a||!n||a.blockIndex!==n.blockIndex||a.rowIndex===n.rowIndex&&a.cellIndex===n.cellIndex)return null;const r=t.selectionBoxes().length;return 0===r?null:`Table selection: ${r} cell${1===r?"":"s"}`},canMerge:()=>t.tableOps.canMergeSelectedTable(t.state()),canSplit:()=>t.tableOps.canSplitSelectedTable(t.state()),canEditColumn:()=>t.tableOps.canEditSelectedTableColumn(t.state()),canEditRow:()=>t.tableOps.canEditSelectedTableRow(t.state()),merge:()=>e(e=>t.tableOps.mergeSelectedTable(e),EV),split:()=>e(e=>t.tableOps.splitSelectedTable(e),LV),insertColumnBefore:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,-1),zV),insertColumnAfter:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,1),zV),deleteColumn:()=>e(e=>t.tableOps.deleteSelectedTableColumn(e),NV),insertRowBefore:()=>e(e=>t.tableOps.insertSelectedTableRow(e,-1),OV),insertRowAfter:()=>e(e=>t.tableOps.insertSelectedTableRow(e,1),OV),deleteRow:()=>e(e=>t.tableOps.deleteSelectedTableRow(e),qV),cellShading:t=>e(e=>PR(e,"shading",t||null),PV),cellBorders:()=>e(t=>WR(t,{width:1,type:"solid",color:"#64748b"}),WV),cellNoBorders:()=>e(t=>WR(t,{width:0,type:"none",color:"transparent"}),WV),width100:()=>e(t=>BR(t,"width","100%"),BV),alignLeft:()=>e(t=>PR(t,"horizontalAlign","left"),FV),alignCenter:()=>e(t=>PR(t,"horizontalAlign","center"),FV),alignRight:()=>e(t=>PR(t,"horizontalAlign","right"),FV),setCellWidth:t=>e(e=>function(t,e){return PR(t,"width",e)}(e,t),HV),insert:(e,a)=>t.tableOps.insertTableCommand(e,a)}})()})}const JW=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",hidden:!0,icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.import",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",hidden:!0},{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",hidden:!0},{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:"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:t=>t.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:t=>t.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:t=>t.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_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:t=>t.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:t=>t.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 QW(t){const e=YW(t.essentials),{runtimePlugins:a,toolbarRegistry:n,menuRegistry:r,dispose:o}=function(t){var e,a;const n=[t.essentialsPlugin,...t.externalPlugins??[]],r=[],o=[],i=Gw(),l=new Dw;for(const s of uA(t.t))i.register(s);for(const s of JW)l.register(s);for(const s of n){for(const t of s.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",row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,order:t.order};i.register(e),r.push(t.id)}for(const t of s.menubar??[])l.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),o.push(t.id)}return null==(e=t.customizeToolbar)||e.call(t,i),null==(a=t.customizeMenubar)||a.call(t,l),{runtimePlugins:n,toolbarRegistry:i,menuRegistry:l,dispose:()=>{for(const t of r)i.remove(t);for(const t of o)l.unregister(t)}}}({essentialsPlugin:e,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),i=function(t){const[e,a]=y(!1),[n,r]=y(new fn({doc:t.initialDocument}));let o=!1;const i=t=>{var e;const a=Yt(t),r=n().commands.get(a);if(!r)return{isEnabled:!1,isActive:!1,value:void 0};const o=(null==(e=r.refresh)?void 0:e.call(r))??{isEnabled:!0};return{isEnabled:!1!==o.isEnabled,isActive:Boolean(o.isActive),value:o.value}};return{runtimeReady:e,runtimeEditor:n,commandStateOf:i,toolbarHost:()=>({commands:{execute:(t,e)=>{const a=Jt(t,e);return n().commands.execute(a.name,a.payload)},canExecute:(t,e)=>{const a=Jt(t,e);return n().commands.canExecute(a.name,a.payload)},state:i},focusEditor:t.focusEditor}),initialize:async()=>{var e,i;try{const e=await fn.create({doc:t.initialDocument,plugins:t.runtimePlugins});if(o)return void(await e.destroy());const i=n();r(e),await i.destroy(),a(!0),requestAnimationFrame(()=>{var a,n;null==(a=t.onSettled)||a.call(t),null==(n=t.onReady)||n.call(t,e)})}catch(l){t.logger.error("runtime:init failed",l),null==(e=t.onError)||e.call(t,l),null==(i=t.onSettled)||i.call(t)}},dispose:async()=>{o=!0,await n().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:a,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return C(()=>{i.initialize()}),I(()=>{i.dispose(),o()}),{toolbarRegistry:n,menuRegistry:r,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}function _W(t){const{document:e,interaction:a,runtimeClient:n}=t,{commandsController:r,keyboardCommandsController:o}=function(t){const e=RW({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,applySelectionAwareTextCommand:t.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:t.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,toolbarStyleState:t.toolbarStyleState,selectionCollapsed:()=>Ga(t.state.selection),selectedImageRun:t.selectedImageRun,openLinkDialog:e=>t.setLinkDialog({isOpen:!0,initialHref:e}),openImageAltDialog:e=>t.setImageAltDialog({isOpen:!0,initialAlt:e}),openImageCaptionDialog:e=>t.setImageCaptionDialog({isOpen:!0,initialCaption:e}),imageCaptionLabel:()=>t.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:e,keyboardCommandsController:{...e,applyBooleanStyleCommand:e=>t.applyBooleanStyleCommand(e)}}}({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:t.focusInput,selectedImageRun:a.selectedImageRun,tableOps:a.tableOps,toolbarStyleState:a.styleController.toolbarStyleState,applyBooleanStyleCommand:t=>a.styleController.applyToolbarBooleanStyleCommand(t),locale:t.locale,setLinkDialog:t.setLinkDialog,setImageAltDialog:t.setImageAltDialog,setImageCaptionDialog:t.setImageCaptionDialog}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h}=QW({essentials:{state:()=>t.state,isReadOnly:t.isReadOnly,forcePlainTextPaste:{get:t.getForcePlainTextPaste,set:t.setForcePlainTextPaste},undoStack:e.undoStack,redoStack:e.redoStack,commandsController:r,keyboardCommandsController:o,historyActions:e.historyActions,styleController:a.styleController,tableOps:a.tableOps,docIO:e.docIO,importInputRef:t.importInputRef,imageInputRef:t.imageInputRef,selectedImageRun:a.selectedImageRun,selectionBoxes:e.selectionBoxes,focusInput:t.focusInput,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,findReplace:{setIsOpen:a.fr.setIsOpen}},externalPlugins:t.runtimeOptions().plugins,t:t.translator,customizeToolbar:t.runtimeOptions().customizeToolbar,customizeMenubar:t.runtimeOptions().customizeMenubar,initialDocument:t.getStateSnapshot().document,focusEditor:t.focusInput,logger:t.logger,onReady:e=>{var a,r;n.resolveReady(e),null==(r=(a=t.runtimeOptions()).onReady)||r.call(a,n)},onSettled:()=>{t.setInitialLoading(!1)},onError:t=>n.rejectReady(t)});!function(t,e){const a=()=>e.cloneState(e.getStateSnapshot());t.connectHost({getRuntimeEditor:()=>e.runtimeReady()?e.runtimeEditor():null,getState:()=>a(),getDocument:()=>a().document,setDocument:t=>{e.applyState(rn(t)),e.resetEditorChromeState(),e.focusInput()},resetDocument:()=>{e.applyState(ln()),e.resetEditorChromeState(),e.focusInput()},saveDocument:async()=>{await e.getPersistence().saveDocument(a().document)},getSelection:()=>a().selection,setSelection:t=>{e.applyState({...a(),selection:t}),e.focusInput()},focus:()=>e.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.setFocused(!1)},clearHistory:()=>e.clearHistory(),importDocx:t=>e.docIO.handleImportFile(t),exportDocx:()=>Promise.resolve(e.docIO.handleExportDocx()),exportPdf:()=>Promise.resolve(e.docIO.handleExportPdf())})}(n,{runtimeReady:i,runtimeEditor:l,getStateSnapshot:t.getStateSnapshot,cloneState:t.cloneState,applyState:t.applyState,resetEditorChromeState:e.resetEditorChromeState,focusInput:t.focusInput,setFocused:t.setFocused,clearHistory:e.clearHistory,getPersistence:()=>t.documentOptions().persistence??e.fallbackPersistence,docIO:e.docIO}),x(()=>{if(!i())return;t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone;const e=t.cloneState(t.getStateSnapshot());l().dispatch(()=>e)});const{handleKeyDown:p}=function(t){const{state:e,isReadOnly:a,logger:n,focusInput:r,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:d,selectedImageRun:c,commandsController:h,tableOps:p,navigation:u,historyActions:f,styleController:g,findReplace:m,runtimeEditor:v}=t,{handleKeyDown:b}=zW({state:e,isReadOnly:a,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:h,selectedImageRun:c,setForcePlainTextPaste:d,moveSelectionByWord:u.moveSelectionByWord,moveSelectionToDocumentBoundary:u.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:u.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:u.moveVerticalSelection,moveVerticalByBlock:u.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:t=>{m.setIsOpen(t??!m.isOpen())},toggleReplace:t=>{m.setIsOpen(t??!m.isOpen())},executeCommand:(t,e)=>v().commands.execute(t,e),canExecuteCommand:t=>v().commands.canExecute(t)});return{handleKeyDown:t=>{NW.includes(t.key)&&g.clearPendingCaretTextStyle();const a=[t.ctrlKey?"Ctrl":null,t.metaKey?"Meta":null,t.altKey?"Alt":null,t.shiftKey?"Shift":null].filter(Boolean).join("+"),r=a?`${a}+${t.key}`:t.key,o=e().selection;n.debug(`key:down ${r} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),hd("input-to-layout"),b(t),pd("input-to-layout")}}}({state:()=>t.state,isReadOnly:t.isReadOnly,logger:t.logger,focusInput:t.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,setForcePlainTextPaste:t.setForcePlainTextPaste,selectedImageRun:a.selectedImageRun,commandsController:o,tableOps:a.tableOps,navigation:a.navigation,historyActions:e.historyActions,styleController:a.styleController,findReplace:a.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h,handleKeyDown:p}}var $W=gt('<div class="oasis-editor-shell oasis-editor-app">');const tB=Object.freeze(Object.defineProperty({__proto__:null,OasisEditorApp:function(t={}){var e;const a=(null==(e=t.runtime)?void 0:e.client)??Qt(),n=()=>t.ui??{},r=()=>t.document??{};lV();const o=Wt(()=>n().locale??"pt-BR"),i=bl("app"),{state:l,commitState:s,getStateSnapshot:d}=function(t){const e=t.initialState?RA(t.initialState):t.initialDocument?rn(t.initialDocument):ln();let a=e;const[n,r]=y(e);return{state:new Proxy({},{get(t,e){const a=n();if(null!==a&&("object"==typeof a||"function"==typeof a))return Reflect.get(a,e)},has(t,e){const a=n();return null!==a&&("object"==typeof a||"function"==typeof a)&&Reflect.has(a,e)},ownKeys(t){const e=n();return null===e||"object"!=typeof e&&"function"!=typeof e?[]:Reflect.ownKeys(e)},getOwnPropertyDescriptor(t,e){const a=n();return null===a||"object"!=typeof a&&"function"!=typeof a?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(a,e),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:t=>{a=t,r(t)},getStateSnapshot:()=>a}}({initialDocument:r().initialDocument,initialState:r().initialState}),c=t=>{s(t)},h=RA;let p=!1;const{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x,isReadOnly:S,useComposedShell:A,loadingOptions:T,loadingLabel:k,shellComponent:V}=function(t){const{ui:e,documentOptions:a}=t,n=()=>{const t=e().loading;return"object"==typeof t&&null!==t?t:void 0};return{showChrome:()=>e().showChrome??!0,showTitleBar:()=>e().showTitleBar??!0,showMenubar:()=>e().showMenubar??!0,showToolbar:()=>e().showToolbar??!0,showOutline:()=>e().showOutline??!0,toolbarView:()=>{var t;return(null==(t=e().toolbar)?void 0:t.view)??"ribbon"},toolbarLayout:()=>{var t;return(null==(t=e().toolbar)?void 0:t.layout)??"overflow"},isReadOnly:()=>a().readOnly??!1,useComposedShell:()=>"docs"===e().uiVariant||"document"!==(e().shell??"document"),loadingOptions:n,loadingLabel:()=>{var t;return(null==(t=n())?void 0:t.label)??"Loading oasis-editor..."},shellComponent:()=>{const t=e().shell??"document";return"inline"===t?Nx:"balloon"===t?Px:Ex}}}({ui:n,documentOptions:r}),R=function(){const[t,e]=y(!1);let a,n,r,o,i;return{focused:t,setFocused:e,focusInput:()=>{e(!0),queueMicrotask(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{e(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},get viewportRef(){return a},set viewportRef(t){a=t},get surfaceRef(){return n},set surfaceRef(t){n=t},get textareaRef(){return r},set textareaRef(t){r=t},get importInputRef(){return o},set importInputRef(t){o=t},get imageInputRef(){return i},set imageInputRef(t){i=t}}}(),E=R.focused,L=R.setFocused,z=R.focusInput,N=R.focusInputAfterPointerSelection,[O,q]=y(!1!==n().loading),P=function(t=100){const[e,a]=y(tx(t)),n=w(()=>e()/100);return{zoomPercent:e,setZoomPercent:t=>a(tx(t)),adjustZoom:t=>a(e=>tx(e+t)),zoomFactor:n}}(),{linkDialog:W,setLinkDialog:B,imageAltDialog:F,setImageAltDialog:H,imageCaptionDialog:U,setImageCaptionDialog:G,contextMenu:D,setContextMenu:j,fontDialog:Z,setFontDialog:X,paragraphDialog:Y,setParagraphDialog:J,tablePropertiesDialog:Q,setTablePropertiesDialog:_}=function(){const[t,e]=y({isOpen:!1,initialHref:""}),[a,n]=y({isOpen:!1,initialAlt:""}),[r,o]=y({isOpen:!1,initialCaption:""}),[i,l]=y({isOpen:!1,x:0,y:0}),[s,d]=y({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}}),[c,h]=y({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",spacingBefore:"",spacingAfter:"",lineHeight:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1}}),[p,u]=y({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{linkDialog:t,setLinkDialog:e,imageAltDialog:a,setImageAltDialog:n,imageCaptionDialog:r,setImageCaptionDialog:o,contextMenu:i,setContextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}}(),[$,tt]=y(!1),et=()=>R.viewportRef,at=()=>R.surfaceRef,nt=mP({documentOptions:r,logger:i,runtimeClient:a,state:l,commitState:s,getStateSnapshot:d,applyState:c,cloneState:h,isReadOnly:S,focusInput:z,surfaceRef:at,viewportRef:et,zoomFactor:P.zoomFactor,getImageOps:()=>Tt.imageOps}),{docIO:ot,measuredBlockHeights:it,measuredParagraphLayouts:lt,documentLayout:st,canvasSnapshotProvider:dt,inputBox:ct,selectionBoxes:ht,commentHighlights:ut,selectedImageBox:ft,selectedTextBoxBox:gt,caretBox:mt,preferredColumnX:vt,setPreferredColumnX:bt,clearPreferredColumn:yt,onCleanupHook:Mt,persistenceStatus:xt,applyTransactionalState:St,resetTransactionGrouping:At,updateHistoryState:It}=nt,Tt=xW({state:l,logger:i,isReadOnly:S,applyState:c,cloneState:h,focusInput:z,focusInputAfterPointerSelection:N,surfaceRef:at,viewportRef:et,zoomFactor:P.zoomFactor,insertImageFromFile:ot.insertImageFromFile,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},getCommandsController:()=>Xt.commandsController,applyTransactionalState:St,clearPreferredColumn:yt,resetTransactionGrouping:At,updateHistoryState:It,caretBox:mt,preferredColumnX:vt,setPreferredColumnX:bt,documentLayout:st,canvasSnapshotProvider:dt}),{layoutOptionsOverlay:kt,fr:Vt,tableOps:Rt,imageOps:Et,textBoxOps:Lt,styleController:zt,onEditorMouseDown:Nt,tableResize:Ot,tableDrag:qt,revisionController:Pt,textDrag:Bt,surfaceEventsWithTextDrag:Ft,textInput:Ut,handleCopy:Gt,handleCut:Dt,handlePaste:jt,handleDrop:Zt}=Tt,Xt=_W({document:nt,interaction:Tt,state:l,logger:i,isReadOnly:S,focusInput:z,applyState:c,getStateSnapshot:d,cloneState:h,setFocused:L,setInitialLoading:q,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},locale:()=>n().locale??"pt-BR",translator:o,runtimeClient:a,runtimeOptions:()=>t.runtime??{},documentOptions:r,importInputRef:()=>R.importInputRef,imageInputRef:()=>R.imageInputRef,setLinkDialog:B,setImageAltDialog:H,setImageCaptionDialog:G}),{commandsController:Yt,runtimeReady:Jt,runtimeEditor:_t,commandStateOf:$t,toolbarHost:te,toolbarRegistry:ee,menuRegistry:ae,handleKeyDown:ne}=Xt,{computeFontFamilyOptions:re,computeFontSizeOptions:oe,applyFontDialogValues:ie,applyParagraphDialogValues:le,applyTablePropertiesDialogValues:se,buildContextMenuItems:de,handleEditorContextMenu:ce,closeContextMenu:he}=mE({state:()=>l,selection:()=>l.selection,toolbarStyleState:zt.toolbarStyleState,isReadOnly:S,t:o,logger:i,setFontDialog:X,setParagraphDialog:J,setTablePropertiesDialog:_,setContextMenu:j,clearPreferredColumn:yt,resetTransactionGrouping:At,applyTransactionalState:St,applyTableAwareParagraphEdit:Rt.applyTableAwareParagraphEdit,focusInput:z,promptForLink:Yt.promptForLink,tableOps:Rt}),{layout:pe,overlays:ue,refs:fe,surfaceHandlers:ge,inputHandlers:me,fileHandlers:ve}=function(t){const{layout:e,overlays:a,refs:n,surface:r,input:o,files:i}=t,l={onImportInputChange:t=>{var e;return i.handleImportFile((null==(e=t.currentTarget.files)?void 0:e[0])??null)},onImageInputChange:t=>{var e;return i.handleInsertImage((null==(e=t.currentTarget.files)?void 0:e[0])??null)}};return{layout:{documentLayout:e.documentLayout,viewportHeight:e.viewportHeight,class:e.className,style:e.style,zoomPercent:e.zoomPercent,setZoomPercent:e.setZoomPercent,zoomFactor:e.zoomFactor},overlays:{selectionBoxes:a.selectionBoxes,commentHighlights:a.commentHighlights,selectedImageBox:a.selectedImageBox,selectedTextBoxBox:a.selectedTextBoxBox,layoutOptions:a.layoutOptions,caretBox:a.caretBox,inputBox:a.inputBox,hoveredRevision:a.hoveredRevision,focused:a.focused,showCaret:a.showCaret,importProgress:a.importProgress},refs:{onViewportRef:t=>{n.focusController.viewportRef=t},onSurfaceRef:t=>{n.focusController.surfaceRef=t},onTextareaRef:t=>{n.focusController.textareaRef=t},onImportInputRef:t=>{n.focusController.importInputRef=t},onImageInputRef:t=>{n.focusController.imageInputRef=t}},surfaceHandlers:{onDragOver:t=>t.preventDefault(),onDrop:r.handleDrop,onEditorMouseDown:r.onEditorMouseDown,onSurfaceMouseDown:r.surfaceEvents.handleSurfaceMouseDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfaceMouseMove:r.tableResize.handleMouseMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphMouseDown:r.surfaceEvents.handleParagraphMouseDown,onImageMouseDown:r.handleImageMouseDown,onImageResizeHandleMouseDown:r.handleImageResizeHandleMouseDown,onTextBoxResizeHandleMouseDown:r.handleTextBoxResizeHandleMouseDown,onImageRotateHandleMouseDown:r.handleImageRotateHandleMouseDown,onTextBoxRotateHandleMouseDown:r.handleTextBoxRotateHandleMouseDown,onTableDragHandleMouseDown:r.tableDrag.handleMouseDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:t=>r.handleEditorContextMenu(t)},inputHandlers:{onInputBlur:()=>o.setFocused(!1),onInputFocus:()=>o.setFocused(!0),onCompositionEnd:o.textInput.handleCompositionEnd,onCompositionStart:o.textInput.handleCompositionStart,onCopy:o.handleCopy,onCut:o.handleCut,onInput:o.textInput.handleTextInput,onKeyDown:o.handleKeyDown,onPaste:o.handlePaste},fileHandlers:l}}({layout:{documentLayout:st,viewportHeight:n().viewportHeight,className:n().class,style:n().style,zoomPercent:P.zoomPercent,setZoomPercent:P.setZoomPercent,zoomFactor:P.zoomFactor},overlays:{selectionBoxes:ht,commentHighlights:ut,selectedImageBox:ft,selectedTextBoxBox:gt,layoutOptions:kt,caretBox:mt,inputBox:ct,hoveredRevision:Pt.hoveredRevision,focused:E,showCaret:()=>function(t,e){if(!e.visible||!Ga(t.selection))return!1;const a=Ea(t),n=xa(t.document,t.selection.anchor.paragraphId,a),r=xa(t.document,t.selection.focus.paragraphId,a);return!(n&&r&&n.blockIndex===r.blockIndex&&(n.rowIndex!==r.rowIndex||n.cellIndex!==r.cellIndex))}(l,mt()),importProgress:ot.importProgress},refs:{focusController:R},files:{handleImportFile:ot.handleImportFile,handleInsertImage:ot.handleInsertImage},surface:{surfaceEvents:Ft,tableResize:Ot,tableDrag:qt,revisionController:Pt,handleDrop:Zt,onEditorMouseDown:Nt,handleImageMouseDown:Et.handleImageMouseDown,handleImageResizeHandleMouseDown:Et.handleImageResizeHandleMouseDown,handleTextBoxResizeHandleMouseDown:Lt.handleTextBoxResizeHandleMouseDown,handleImageRotateHandleMouseDown:Et.handleImageRotateHandleMouseDown,handleTextBoxRotateHandleMouseDown:Lt.handleTextBoxRotateHandleMouseDown,handleEditorContextMenu:ce},input:{textInput:Ut,setFocused:L,handleCopy:Gt,handleCut:Dt,handlePaste:jt,handleKeyDown:ne}});return C(()=>{!function(t=document.body){tV||($k({icons:_k,nameAttr:"data-lucide",root:t}),tV=new MutationObserver(e=>{let a=!1;for(const t of e)if(t.addedNodes.length>0||"attributes"===t.type){a=!0;break}a&&tV&&(tV.disconnect(),$k({icons:_k,nameAttr:"data-lucide",root:t}),tV.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}),tV.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}(),function(){if(!dd&&window.PerformanceObserver)try{dd=new PerformanceObserver(t=>{for(const e of t.getEntries())sd.push({duration:Fl(e.duration,2),startTime:Math.round(e.startTime)})}),dd.observe({type:"longtask",buffered:!0})}catch{}}(),window.__OASIS_PERF_REPORT=()=>{const t=ld.filter(t=>t.name.startsWith("layout:")).map(t=>t.duration),e=ld.filter(t=>"input-to-layout"===t.name).map(t=>t.duration),a=ld.filter(t=>"input:text"===t.name).map(t=>t.duration),n=md(t),r=md(e),o=md(a),i=md(sd.map(t=>t.duration));console.group("%c[perf] Summary","color: #f59e0b; font-weight: bold;"),console.info(`input:text → p50=${o.p50}ms p95=${o.p95}ms p99=${o.p99}ms max=${o.max}ms (n=${o.count})`),console.info(`input-to-layout → p50=${r.p50}ms p95=${r.p95}ms p99=${r.p99}ms max=${r.max}ms (n=${r.count})`),console.info(`layout:sync → p50=${n.p50}ms p95=${n.p95}ms p99=${n.p99}ms max=${n.max}ms (n=${n.count})`),console.info(`longtasks → p50=${i.p50}ms p95=${i.p95}ms p99=${i.p99}ms max=${i.max}ms (n=${i.count})`),console.groupEnd()},window.__OASIS_DOM_STATS=()=>{const t=(e=(null==fd?void 0:fd())??null)?{totalNodes:e.querySelectorAll("*").length,pages:e.querySelectorAll('[data-renderer="canvas"][data-page-index]').length,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0}:{totalNodes:0,pages:0,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0};var e;return console.info("%c[perf] DOM stats","color: #f59e0b; font-weight: bold;",t),t},fd=()=>at()??null,$s(),"1"!==Bs(Ps)&&Ks()&&tt(!0)}),I(()=>{Mt(),Ft.stopDragging(),Bt.stopDrag(),Et.stopImageDrag(),Et.stopImageResize(),Lt.stopTextBoxResize(),null==tV||tV.disconnect(),tV=null}),K(Ht,{translator:o,get children(){var t=$W();return wt(t,"--oasis-editor-gutter-x","34px"),Ct(t,K(rt,{get when(){return pt(()=>!(A()||!u()))()&&m()},get children(){return K(Co,{host:te,registry:ee,get view(){return b()},get layout(){return x()}})}}),null),Ct(t,K(IL,{dialogs:{linkDialog:W,setLinkDialog:B,imageAltDialog:F,setImageAltDialog:H,imageCaptionDialog:U,setImageCaptionDialog:G,contextMenu:D,setContextMenu:j,fontDialog:Z,setFontDialog:X,paragraphDialog:Y,setParagraphDialog:J,tablePropertiesDialog:Q,setTablePropertiesDialog:_},findReplace:Vt,fontFamilyOptions:re,fontSizeOptions:oe,contextMenuItems:de,focusInput:z,get applyLinkCommand(){return Yt.applyLinkCommand},get applyImageAltCommand(){return Yt.applyImageAltCommand},get applyImageCaptionCommand(){return Yt.applyImageCaptionCommand},applyFontDialogValues:ie,applyParagraphDialogValues:le,applyTablePropertiesDialogValues:se,closeContextMenu:he}),null),Ct(t,K(kL,{useComposedShell:A,shellComponent:V,runtime:{state:()=>l,toolbarHost:te,runtimeEditor:_t,persistenceStatus:xt,toolbarRegistry:ee,menuRegistry:ae,showFloatingTableToolbar:()=>!S()&&null!==$t("tableContext").value},chrome:{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x},view:{isReadOnly:S,viewportHeight:()=>n().viewportHeight,measuredBlockHeights:it,measuredParagraphLayouts:lt,documentLayout:st,layout:pe,overlays:ue,refs:fe,surfaceHandlers:ge,inputHandlers:me,fileHandlers:ve}}),null),Ct(t,K(xE,{state:l,get surfaceRef(){return at()},documentLayout:st,snapshotProvider:dt,get zoomFactor(){return P.zoomFactor},tableResize:Ot,imageOps:Et,tableDrag:qt,textDrag:Bt}),null),Ct(t,K(rt,{get when(){return O()||!Jt()},get children(){return K(Kt,{get label(){return k()},get class(){var t;return null==(t=T())?void 0:t.class},get style(){var t;return null==(t=T())?void 0:t.style}})}}),null),Ct(t,K(RL,{get isOpen(){return pt(()=>!(!$()||O()))()&&Jt()},onClose:()=>tt(!1)}),null),M(e=>{var a=!!A(),n=!!S();return a!==e.e&&t.classList.toggle("oasis-editor-docs",e.e=a),n!==e.t&&t.classList.toggle("oasis-editor-read-only",e.t=n),e},{e:void 0,t:void 0}),t}})}},Symbol.toStringTag,{value:"Module"}));t.ActionRow=function(t){const[e,a]=$(t,["align","wrap","class","classList","children"]);return St(n=Yx(),_({get class(){return`oasis-editor-ui-action-row ${e.class??""}`},get classList(){return{[`oasis-editor-ui-action-row-${e.align??"start"}`]:!0,"oasis-editor-ui-action-row-nowrap":!1===e.wrap,...e.classList}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.BalloonShell=Px,t.Button=Kx,t.Checkbox=bw,t.ColorField=fw,t.ColorPicker=Tr,t.CommandRegistry=dn,t.DEFAULT_PALETTE=Nr,t.Dialog=Fx,t.DialogFooter=function(t){const[e,a]=$(t,["align","class","classList","children"]);return St(n=Fw(),_({get class(){return`oasis-editor-ui-dialog-footer ${e.class??""}`},get classList(){return{[`oasis-editor-ui-dialog-footer-${e.align??"end"}`]:!0,...e.classList}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.DocumentShell=Ex,t.Editor=fn,t.FieldGroup=Pw,t.FieldRow=function(t){const[e,a]=$(t,["align","class","style","children"]);return St(n=zw(),_({get class(){return`oasis-editor-ui-field-row ${e.class??""}`},get style(){return{"align-items":Nw[e.align??"end"],..."object"==typeof e.style?e.style:{}}}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.FloatingActionButton=gx,t.FormField=iw,t.Grid=nw,t.GridPicker=zr,t.Heading=function(t){const[e,a]=$(t,["level","class","classList","children"]),n=e.level??2;return K(Ot,_({component:`h${n}`,get class(){return`oasis-editor-ui-heading ${e.class??""}`},get classList(){return{[`oasis-editor-ui-heading-${n}`]:!0,...e.classList}}},a,{get children(){return e.children}}))},t.IconButton=wx,t.InlineShell=Nx,t.Menu=dr,t.MenuRegistry=Dw,t.NumberField=Cw,t.OASIS_BUILTIN_COMMANDS=["selectAll","insertFootnote","insertTableOfContents","updateTableOfContents","pastePlainText","bold","italic","underline","strike","superscript","subscript","link","unlink","alignLeft","alignCenter","alignRight","alignJustify","orderedList","bulletList","find","replace","toggleTrackChanges","acceptRevisions","rejectRevisions","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","undo","redo","pageBreak","lineBreak","splitBlock","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setStyleId","setCharacterStyleId","setUnderlineStyle","documentStyles","print","copy","exportDocx","exportPdf","importDocument","insertImage","editImageAlt","insertImageCaption","outdent","indent","togglePageBreakBefore","toggleKeepWithNext","setSpacingAfter","setSpacingBefore","setIndentLeft","setIndentRight","setIndentFirstLine","setIndentHanging","setSpecialIndent","setParagraphShading","applyParagraphBorders","setLineHeight","setListFormat","setListStartAt","toggleOrientation","setOrientation","sectionBreakNextPage","sectionBreakContinuous","setPageMargins","tableContext","tableMerge","tableSplit","tableInsertColumnBefore","tableInsertColumnAfter","tableDeleteColumn","tableInsertRowBefore","tableInsertRowAfter","tableDeleteRow","tableCellShading","tableCellBorders","tableCellNoBorders","tableWidth100","tableAlignLeft","tableAlignCenter","tableAlignRight","tableSetCellWidth","insertTable"],t.OASIS_MENU_ITEMS={fileNew:"file_new",fileImport:"file_import",fileSave:"file_save",fileExport:"file_export",fileExportPdf:"file_export_pdf",fileExportDocx:"file_export_docx",filePrint:"file_print",editUndo:"edit_undo",editRedo:"edit_redo",editCopy:"edit_copy",editFind:"edit_find",editSelectAll:"edit_selectAll",viewMargins:"view_margins",viewParagraphMarks:"view_paragraph_marks",viewPreciseFonts:"view_precise_fonts",insertImage:"insert_image",insertImageCaption:"insert_image_caption",insertTable:"insert_table",insertLink:"insert_link",insertFootnote:"insert_footnote",insertPageBreak:"insert_pageBreak",formatText:"format_text",formatTextBold:"format_text_bold",formatTextItalic:"format_text_italic",formatTextUnderline:"format_text_underline",formatTextStrike:"format_text_strike",formatAlign:"format_align",formatAlignLeft:"format_align_left",formatAlignCenter:"format_align_center",formatAlignRight:"format_align_right",formatAlignJustify:"format_align_justify",formatLists:"format_lists",formatListsBullet:"format_lists_bullet",formatListsNumbered:"format_lists_numbered"},t.OASIS_TOOLBAR_ITEMS={fileDropdown:"editor-toolbar-file-dropdown",exportDocx:"editor-toolbar-export-docx",exportPdf:"editor-toolbar-export-pdf",importDocument:"editor-toolbar-import-document",undo:"editor-toolbar-undo",redo:"editor-toolbar-redo",style:"editor-toolbar-style",fontFamily:"editor-toolbar-font-family",fontSize:"editor-toolbar-font-size",color:"editor-toolbar-color",highlight:"editor-toolbar-highlight",textShading:"editor-toolbar-text-shading",bold:"editor-toolbar-bold",italic:"editor-toolbar-italic",underlineControl:"editor-toolbar-underline-control",strike:"editor-toolbar-strike",superscript:"editor-toolbar-superscript",subscript:"editor-toolbar-subscript",insertImage:"editor-toolbar-insert-image",insertTable:"editor-toolbar-insert-table",link:"editor-toolbar-link",unlink:"editor-toolbar-unlink",footnote:"editor-toolbar-footnote",imageAlt:"editor-toolbar-image-alt",imageCaption:"editor-toolbar-image-caption",alignLeft:"editor-toolbar-align-left",alignCenter:"editor-toolbar-align-center",alignRight:"editor-toolbar-align-right",alignJustify:"editor-toolbar-align-justify",bulletList:"editor-toolbar-list-bullet",orderedList:"editor-toolbar-list-ordered",outdent:"editor-toolbar-list-outdent",indent:"editor-toolbar-list-indent",listOptions:"editor-toolbar-list-options",specialIndent:"editor-toolbar-special-indent",lineSpacing:"editor-toolbar-line-spacing-control",metrics:"editor-toolbar-metrics",table:"editor-toolbar-table",margins:"editor-toolbar-margins",section:"editor-toolbar-section"},t.OasisEditorAppLazy=Xt,t.OasisEditorContainer=_t,t.OasisEditorLoading=Kt,t.PluginCollection=sn,t.Popover=ar,t.RIBBON_TABS=Kr,t.Radio=Ew,t.RadioGroup=Lw,t.Select=hr,t.SelectField=Aw,t.Separator=ur,t.SidePanel=bx,t.SidePanelBody=Mx,t.SidePanelFooter=function(t){const[e,a]=$(t,["class","children"]);return St(n=vx(),_({get class(){return`oasis-editor-plugin-side-panel-footer ${e.class??""}`}},a),!1,!0),Ct(n,()=>e.children),n;var n},t.SidePanelHeader=yx,t.SplitButton=gr,t.Stack=aw,t.StatusText=Xx,t.StyleGallery=Br,t.SurfaceButton=xn,t.Tabs=jx,t.Text=wn,t.TextAreaField=uw,t.TextField=hw,t.ToggleChip=Bw,t.Toolbar=Co,t.ToolbarButton=$n,t.ToolbarColorPicker=Tr,t.ToolbarGridPicker=zr,t.ToolbarMenu=dr,t.ToolbarSelect=hr,t.ToolbarSeparator=ur,t.ToolbarSplitButton=gr,t.buildRibbonTabDefinitions=Jr,t.commandRefName=Yt,t.createDefaultToolbarPreset=uA,t.createEditorCommandBus=function(t){return{execute(e,a){const n=Jt(e,a);return t.commands.execute(n.name,n.payload)},canExecute(e,a){const n=Jt(e,a);return t.commands.canExecute(n.name,n.payload)},state(e){const a=Jt(e);return t.commands.state(a.name,a.payload)}}},t.createOasisEditor=function(t,e={}){const a=Qt(),n=ft(()=>Xt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createOasisEditorContainer=function(t,e={}){const a=Qt(),n=ft(()=>_t({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createToolbarRegistry=Gw,t.mount=function(t,e={}){const a=Qt(),n=ft(()=>K(Xt,_(e,{get runtime(){return{...e.runtime,client:a}}})),t);return a.setDispose(()=>{n(),t.innerHTML=""}),Object.assign(a,{unmount:()=>a.dispose()})},t.registerToolbarRenderer=function(t,e){jr.set(t,e)},t.resolveCommandRef=Jt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|