efficient-office 0.12.0 → 0.14.0
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/Documents-4L3242LJ.js +1 -0
- package/dist/Slides-JLWEMUXJ.js +1 -0
- package/dist/SlidesEditor-DGK4W6W4.js +1 -0
- package/dist/Spreadsheet-WQOZPWY5.js +1 -0
- package/dist/chunk-5K2D7PBJ.js +1 -0
- package/dist/chunk-7B4B25DB.js +1 -0
- package/dist/chunk-AJTH75FI.js +1 -0
- package/dist/chunk-BDVKNU3U.js +1 -0
- package/dist/chunk-CEVQKZ66.js +1 -0
- package/dist/chunk-EDJRXJNE.js +1 -0
- package/dist/chunk-EP3ZNVDB.js +1 -0
- package/dist/{chunk-DG4VDXLL.js → chunk-HQM2HX4V.js} +1 -1
- package/dist/{chunk-HNNYUGDU.js → chunk-JI56OCIU.js} +1 -1
- package/dist/{chunk-O35VT6BD.js → chunk-LGY776XE.js} +1 -1
- package/dist/chunk-PX4QOBHF.js +1 -0
- package/dist/{chunk-MDG2ADZ7.js → chunk-R2CXMNZL.js} +1 -1
- package/dist/{chunk-EC6D54MM.js → chunk-SDLOT5Z5.js} +1 -1
- package/dist/chunk-T2TZ7HF5.js +1 -0
- package/dist/chunk-VMUUFEWS.js +1 -0
- package/dist/chunk-VYLIT7NN.js +1 -0
- package/dist/{chunk-MR7ZWQHF.js → chunk-WAB44FLE.js} +1 -1
- package/dist/{chunk-NRGUS5QY.js → chunk-XENQLN5I.js} +1 -1
- package/dist/deckPdf-KZFS4CTF.js +1 -0
- package/dist/documents/documents.css +43 -1
- package/dist/documents/index.d.ts +154 -2
- package/dist/documents/index.js +1 -1
- package/dist/docxPdf-LO2VPZSJ.js +1 -0
- package/dist/importDocument-C5L275FU.js +1 -0
- package/dist/importSpreadsheet-L5FJGRUV.js +1 -0
- package/dist/{pptxImport-OACGHWQ6.js → pptxImport-UQQXZUQL.js} +1 -1
- package/dist/slides/index.d.ts +213 -17
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +53 -0
- package/dist/spreadsheet/index.d.ts +2 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/workbookPdf-K65CQX4K.js +1 -0
- package/dist/xlsxFile-3GXD4KW5.js +1 -0
- package/package.json +1 -1
- package/dist/Documents-2ZU5D3ZI.js +0 -1
- package/dist/Slides-YZQXZJX4.js +0 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +0 -1
- package/dist/Spreadsheet-VWRRB6FE.js +0 -1
- package/dist/chunk-3RFDQOTI.js +0 -1
- package/dist/chunk-ADXHTZ3Q.js +0 -1
- package/dist/chunk-B2X3NIQR.js +0 -1
- package/dist/chunk-BGAR3P46.js +0 -1
- package/dist/chunk-JKYJGXJE.js +0 -1
- package/dist/chunk-POH6OTTR.js +0 -1
- package/dist/chunk-PXOQN7D6.js +0 -1
- package/dist/chunk-Q7NVDOCX.js +0 -1
- package/dist/chunk-UKGIT2RS.js +0 -1
- package/dist/chunk-YKQ5UKYZ.js +0 -1
- package/dist/chunk-ZS45QEF4.js +0 -1
- package/dist/deckPdf-4RC7QJ45.js +0 -1
- package/dist/docxPdf-QSMEFCUF.js +0 -1
- package/dist/importDocument-34WALCTG.js +0 -1
- package/dist/importSpreadsheet-IRN32JON.js +0 -1
- package/dist/workbookPdf-CQTTURQ5.js +0 -1
- package/dist/xlsxFile-SX767BIH.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{countWords as e,documentText as t,findInNodes as n,pageBlocks as r,pageDocument as o,pageStarts as a,pageStyles as i,replaceSpots as l,sanitizeHtml as s}from"./chunk-EC6D54MM.js";import{DocumentsConflict as c,useDocumentsHost as d,useDocumentsWords as u}from"./chunk-HNNYUGDU.js";import"./chunk-POH6OTTR.js";import{FileList as m}from"./chunk-PMGQ5GUH.js";import"./chunk-B32ASXHM.js";import{importDocumentFile as f}from"./chunk-O35VT6BD.js";import{fingerprintOf as p,headerKindFor as h,marginTextOfHtml as g,readDocx as w,readParts as b,stampFingerprints as y,tocEntryHtml as v}from"./chunk-YKQ5UKYZ.js";import{BUILTIN_STYLES as x,CHECK_BULLETS as k,HIGHLIGHTS as C,MARGIN_PRESETS as S,PAPER_SIZES as N,REL as $,WEB_FONTS as A,WORD_NS as L,addContentDefault as P,addContentOverride as T,addRel as M,blankDocxParts as R,child as E,escapeXml as z,marginsOf as F,paperOf as O,paraCss as j,parseParaProps as H,parseRunProps as D,parseTabsAttr as I,parseXml as B,partText as U,readRels as W,resolveTarget as q,runCss as K,setPartText as G,tabCss as V,tabsAttr as X,webFontSheetUrl as Q,withMargins as _,withPaper as J,writeZip as Y}from"./chunk-D3JKD7KW.js";import{hasExtension as Z,placeCopy as ee}from"./chunk-XYVQTQ6N.js";import{useEffect as te,useRef as ne,useState as re}from"react";import{WindowTitle as oe,useWindowDirty as ae}from"efficient-shell";import{Button as ie,EmptyState as le,Input as se,LoadingSpinner as ce,confirmDestructive as de,toast as ue}from"efficient-shell/ui";import{useCallback as me,useEffect as fe,useId as pe,useMemo as he,useRef as ge,useState as we}from"react";import{saveIndicator as be,useAutosave as ye}from"efficient-easel/autosave";import{useEaselStrings as ve}from"efficient-easel/strings";import{Icon as xe}from"efficient-shell/icons";import{Button as ke,ColorPickerPanel as Ce,ContextMenu as Se,DropdownMenu as Ne,IconButton as $e,Popover as Ae,PopupMenu as Le,PopupMenuDivider as Pe,PopupMenuItem as Te,PopupMenuLabel as Me,prompt as Re,registerModalEscapeInterceptor as Ee,toast as ze,useShellLocale as Fe}from"efficient-shell/ui";import{SettingsColour as Oe}from"efficient-easel/panel";import{useEaselStrings as je}from"efficient-easel/strings";import{Button as He,Select as De}from"efficient-shell/ui";import{jsx as Ie,jsxs as Be}from"react/jsx-runtime";function Ue({page:e,onPage:t,onMorePageSetup:n,colour:r,onColour:o,outline:a,onHeading:i}){const l=u(),s=je(),c=O(e),d=F(e),m={a4:"A4",a3:"A3",a5:"A5",letter:l.paperLetter,legal:l.paperLegal},f={normal:l.marginsNormal,narrow:l.marginsNarrow,moderate:l.marginsModerate,wide:l.marginsWide},p={value:"custom",label:l.custom};return Be("aside",{className:"docs-panel",children:[Ie("h3",{children:l.documentPanel}),Be("div",{className:"docs-panel-section",children:[Ie("p",{className:"docs-panel-label",children:l.pagePanel}),Ie(De,{"aria-label":l.paperSize,value:c??"custom",onChange:n=>{"custom"!==n&&t(J(e,n))},options:[...c?[]:[p],...Object.keys(N).map(e=>({value:e,label:m[e]}))]}),Ie(De,{"aria-label":l.margins,value:d??"custom",onChange:n=>{"custom"!==n&&t(_(e,n))},options:[...d?[]:[p],...Object.keys(S).map(e=>({value:e,label:f[e]}))]}),Ie(He,{variant:"secondary",block:!0,onClick:n,children:l.morePageSetup})]}),Ie("div",{className:"docs-panel-section",children:Ie(Oe,{label:l.textColor,value:r,onChange:o,words:s.colourRow})}),Be("div",{className:"docs-panel-section",children:[Ie("p",{className:"docs-panel-label",children:l.outline}),0===a.length?Ie("p",{className:"docs-panel-empty",children:l.outlineEmpty}):Ie("ul",{className:"docs-outline",children:a.map((e,t)=>Ie("li",{style:{paddingLeft:10*(e.level-1)+"px"},children:Ie("button",{type:"button",onClick:()=>i(t),children:e.text})},t))})]})]})}import{EaselIconButton as We,EaselTopBar as qe,SaveState as Ke,TopBarCluster as Ge,TopBarDivider as Ve}from"efficient-easel/chrome";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{Icon as Xe}from"efficient-shell/icons";import{DropdownMenu as Qe}from"efficient-shell/ui";import{jsx as _e,jsxs as Je}from"react/jsx-runtime";function Ye({onClose:e,fileMenu:t,name:n,saveState:r,canUndo:o,canRedo:a,onUndo:i,onRedo:l,exportControl:s}){const c=u();return Je(qe,{children:[Je(Ge,{children:[e&&_e(We,{label:c.backToFiles,onClick:e,children:_e(Xe,{name:"chevron-left",size:16})}),t.length>0&&_e(Qe,{trigger:c.menuFile,items:t,align:"start",triggerClassName:"docs-menu-trigger"}),n,_e(Ke,{...r}),_e(Ve,{}),Je("span",{className:"docs-history",onMouseDown:e=>e.preventDefault(),children:[_e(We,{label:c.undo,disabled:!o,onClick:i,children:_e(Xe,{name:"undo",size:16})}),_e(We,{label:c.redo,disabled:!a,onClick:l,children:_e(Xe,{name:"redo",size:16})})]})]}),_e(Ge,{kind:"right",children:s})]})}var Ze=["w:rStyle","w:rFonts","w:b","w:bCs","w:i","w:iCs","w:caps","w:smallCaps","w:strike","w:dstrike","w:outline","w:shadow","w:emboss","w:imprint","w:noProof","w:snapToGrid","w:vanish","w:webHidden","w:color","w:spacing","w:w","w:kern","w:position","w:sz","w:szCs","w:highlight","w:u","w:effect","w:bdr","w:shd","w:fitText","w:vertAlign","w:rtl","w:cs","w:em","w:lang","w:eastAsianLayout","w:specVanish","w:oMath","w:rPrChange"],et=["w:pStyle","w:keepNext","w:keepLines","w:pageBreakBefore","w:framePr","w:widowControl","w:numPr","w:suppressLineNumbers","w:pBdr","w:shd","w:tabs","w:suppressAutoHyphens","w:kinsoku","w:wordWrap","w:overflowPunct","w:topLinePunct","w:autoSpaceDE","w:autoSpaceDN","w:bidi","w:adjustRightInd","w:snapToGrid","w:spacing","w:ind","w:contextualSpacing","w:mirrorIndents","w:suppressOverlap","w:jc","w:textDirection","w:textAlignment","w:textboxTightWrap","w:outlineLvl","w:divId","w:cnfStyle","w:rPr","w:sectPr","w:pPrChange"],tt=["w:cnfStyle","w:tcW","w:gridSpan","w:hMerge","w:vMerge","w:tcBorders","w:shd","w:noWrap","w:tcMar","w:textDirection","w:tcFitText","w:vAlign","w:hideMark","w:headers","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"],nt=["w:headerReference","w:footerReference","w:footnotePr","w:endnotePr","w:type","w:pgSz","w:pgMar","w:paperSrc","w:pgBorders","w:lnNumType","w:pgNumType","w:cols","w:formProt","w:vAlign","w:noEndnote","w:titlePg","w:textDirection","w:bidi","w:rtlGutter","w:docGrid","w:printerSettings","w:sectPrChange"];function rt(e){if(!e)return[];return B(e).children.map(t=>({name:t.name,xml:e.slice(t.start,t.end)}))}function ot(e,t){const n=e=>{const n=t.indexOf(e);return n<0?t.length:n};return e.map((e,t)=>({p:e,i:t})).sort((e,t)=>n(e.p.name)-n(t.p.name)||e.i-t.i).map(e=>e.p.xml).join("")}function at(e){const t=new Map;for(const n of(e.getAttribute("style")??"").split(";")){const e=n.indexOf(":");e>0&&t.set(n.slice(0,e).trim().toLowerCase(),n.slice(e+1).trim())}return t}var it={black:"#000000",white:"#ffffff",red:"#ff0000",blue:"#0000ff",green:"#008000",yellow:"#ffff00"};function lt(e){if(!e)return;const t=e.trim().toLowerCase();if("transparent"===t||"inherit"===t||"initial"===t||"auto"===t)return;if(it[t])return it[t];if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t))return`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`;const n=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+))?\s*\)$/.exec(t);return!n||void 0!==n[4]&&0===Number(n[4])?void 0:`#${[n[1],n[2],n[3]].map(e=>Math.round(Number(e)).toString(16).padStart(2,"0")).join("")}`}function st(e){if(!e)return;const t=/^(-?[\d.]+)(pt|px|in|cm|mm|em)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);switch(t[2]){case"pt":return n;case"px":return.75*n;case"in":return 72*n;case"cm":return 72*n/2.54;case"mm":return 72*n/25.4;default:return"0"===t[1]?0:void 0}}var ct=[10,13,16,18,24,32,48].map(e=>.75*e);var dt=(e,t)=>void 0===e||void 0===t?e===t:Math.abs(e-t)<.02,ut=e=>Math.round(20*e);function mt(e,t,n){return ft(n?e.runs.get(n):void 0,t,e)}function ft(e,t,n){const r=e?B(e):void 0,o=D(r,n.theme);let a=rt(e);const i=(e,t)=>{a=a.filter(t=>!e.includes(t.name)),a.push(...t)},l=(e,t)=>void 0===t?[]:[{name:e,xml:t?`<${e}/>`:`<${e} w:val="0"/>`}];if(t.b!==o.b&&i(["w:b","w:bCs"],[...l("w:b",t.b),...l("w:bCs",t.b)]),t.i!==o.i&&i(["w:i","w:iCs"],[...l("w:i",t.i),...l("w:iCs",t.i)]),!!t.u!=!!o.u&&i(["w:u"],t.u?[{name:"w:u",xml:'<w:u w:val="single"/>'}]:o.u?[{name:"w:u",xml:'<w:u w:val="none"/>'}]:[]),t.strike!==o.strike&&!!t.strike!=!!o.strike&&i(["w:strike"],l("w:strike",t.strike)),t.vert!==o.vert&&i(["w:vertAlign"],t.vert?[{name:"w:vertAlign",xml:`<w:vertAlign w:val="${"sub"===t.vert?"subscript":"superscript"}"/>`}]:[]),t.font!==o.font){const e=z(t.font??"");i(["w:rFonts"],t.font?[{name:"w:rFonts",xml:`<w:rFonts w:ascii="${e}" w:hAnsi="${e}" w:eastAsia="${e}" w:cs="${e}"/>`}]:[])}if(t.size!==o.size){const e=t.size?Math.round(2*t.size):0;i(["w:sz","w:szCs"],e?[{name:"w:sz",xml:`<w:sz w:val="${e}"/>`},{name:"w:szCs",xml:`<w:szCs w:val="${e}"/>`}]:[])}if(t.color!==o.color&&i(["w:color"],t.color?[{name:"w:color",xml:`<w:color w:val="${t.color.slice(1).toUpperCase()}"/>`}]:[]),t.hl!==o.hl){const e=t.hl?Object.entries(C).find(([,e])=>e===t.hl)?.[0]:void 0;i(["w:highlight","w:shd"],t.hl?e?[{name:"w:highlight",xml:`<w:highlight w:val="${e}"/>`}]:[{name:"w:shd",xml:`<w:shd w:val="clear" w:color="auto" w:fill="${t.hl.slice(1).toUpperCase()}"/>`}]:[])}const s=ot(a,Ze);return s?`<w:rPr>${s}</w:rPr>`:""}var pt={FootnoteText:'<w:style w:type="paragraph" w:styleId="FootnoteText"><w:name w:val="footnote text"/><w:basedOn w:val="Normal"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style>',FootnoteReference:'<w:style w:type="character" w:styleId="FootnoteReference"><w:name w:val="footnote reference"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:vertAlign w:val="superscript"/></w:rPr></w:style>',TOCHeading:'<w:style w:type="paragraph" w:styleId="TOCHeading"><w:name w:val="TOC Heading"/><w:basedOn w:val="Heading1"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/></w:style>',...Object.fromEntries([1,2,3,4,5,6].map(e=>[`TOC${e}`,`<w:style w:type="paragraph" w:styleId="TOC${e}"><w:name w:val="toc ${e}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/><w:ind w:left="${220*(e-1)}"/></w:pPr></w:style>`]))};function ht(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.styles);return t?q(e.doc.docPath,t.target):void 0}function gt(e,t){const n=ht(e);if(!n)return;const r=U(e.parts,n);if(!r||new RegExp(`w:styleId="${t}"`).test(r))return;const o=x[t]?.xml??pt[t];o&&G(e.parts,n,r.replace("</w:styles>",`${o}</w:styles>`))}var wt=["w:name","w:aliases","w:basedOn","w:next","w:link","w:autoRedefine","w:hidden","w:uiPriority","w:semiHidden","w:unhideWhenUsed","w:qFormat","w:locked","w:personal","w:personalCompose","w:personalReply","w:rsid","w:pPr","w:rPr","w:tblPr","w:trPr","w:tcPr","w:tblStylePr"];function bt(e,t){let n=rt(e);const r=(e,t)=>{n=n.filter(t=>t.name!==e),t&&n.push({name:e,xml:t})};t.align&&r("w:jc",`<w:jc w:val="${"justify"===t.align?"both":t.align}"/>`);const o=[];void 0!==t.indentLeft&&o.push(`w:left="${ut(t.indentLeft)}"`),void 0!==t.indentRight&&o.push(`w:right="${ut(t.indentRight)}"`),void 0!==t.firstLine&&o.push(t.firstLine<0?`w:hanging="${ut(-t.firstLine)}"`:`w:firstLine="${ut(t.firstLine)}"`),o.length&&r("w:ind",`<w:ind ${o.join(" ")}/>`);const a=[];void 0!==t.before&&a.push(`w:before="${ut(t.before)}"`),void 0!==t.after&&a.push(`w:after="${ut(t.after)}"`),void 0!==t.lineMultiple&&a.push(`w:line="${Math.round(240*t.lineMultiple)}" w:lineRule="auto"`),void 0!==t.linePoints&&a.push(`w:line="${ut(t.linePoints)}" w:lineRule="exact"`),a.length&&r("w:spacing",`<w:spacing ${a.join(" ")}/>`);const i=ot(n,et);return i?`<w:pPr>${i}</w:pPr>`:""}function yt(e,t){const n=W(e.parts,e.doc.docPath).find(e=>e.type===$.styles),r=n?U(e.parts,q(e.doc.docPath,n.target)):void 0;if(r)for(const e of B(r).children)if("w:style"===e.name&&E(e,"w:name")?.attrs["w:val"]?.toLowerCase()===t)return e.attrs["w:styleId"];return Object.entries(x).find(([,e])=>e.name===t)?.[0]??null}var vt=["•","o","▪"],xt=["decimal","lowerLetter","lowerRoman"];function kt(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.numbering);if(t){const n=q(e.doc.docPath,t.target);return{path:n,text:U(e.parts,n)??`<w:numbering ${L}></w:numbering>`}}const n="word/numbering.xml";return M(e.parts,e.doc.docPath,$.numbering,"numbering.xml"),T(e.parts,n,"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"),{path:n,text:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:numbering ${L}></w:numbering>`}}function Ct(e,t,n){const{path:r,text:o}=kt(e),a=B(o),i=a.children.filter(e=>"w:abstractNum"===e.name).map(e=>Number(e.attrs["w:abstractNumId"])),l=String((i.length?Math.max(...i):-1)+1);let s="";for(let e=0;e<9;e++){s+=`<w:lvl w:ilvl="${e}"><w:start w:val="1"/><w:numFmt w:val="${t?xt[e%3]:"bullet"}"/><w:lvlText w:val="${t?`%${e+1}.`:n??vt[e%3]}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(e+1)}" w:hanging="360"/></w:pPr></w:lvl>`}const c=`<w:abstractNum w:abstractNumId="${l}"><w:multiLevelType w:val="hybridMultilevel"/>${s}</w:abstractNum>`,d=a.children.find(e=>"w:num"===e.name),u=d?d.start:a.innerEnd>a.innerStart||o.includes("</w:numbering>")?o.lastIndexOf("</w:numbering>"):-1,m=u>=0?o.slice(0,u)+c+o.slice(u):o.replace(/\/>\s*$/,`>${c}</w:numbering>`);return G(e.parts,r,m),l}function St(e,t,n){const{path:r,text:o}=kt(e),a=B(o),i=a.children.filter(e=>"w:num"===e.name).map(e=>Number(e.attrs["w:numId"])),l=String((i.length?Math.max(...i):0)+1),s=`<w:num w:numId="${l}"><w:abstractNumId w:val="${t}"/>${n?'<w:lvlOverride w:ilvl="0"><w:startOverride w:val="1"/></w:lvlOverride>':""}</w:num>`,c=[...a.children].reverse().find(e=>"w:num"===e.name),d=c?c.end:o.lastIndexOf("</w:numbering>");return G(e.parts,r,o.slice(0,d)+s+o.slice(d)),l}var Nt={"image/png":"png","image/jpeg":"jpeg","image/gif":"gif","image/bmp":"bmp","image/webp":"webp","image/svg+xml":"svg"};function $t(e,t){const n=t.getAttribute("data-raw"),r=function(e,t){const n=at(t),r=st(n.get("width")),o=st(n.get("height")),a=t.naturalWidth?.75*t.naturalWidth:0,i=t.naturalHeight?.75*t.naturalHeight:0,l=a&&i?i/a:o&&r?o/r:.75;let s=r??(a||e.contentWidth);return s>2*e.contentWidth&&(s=e.contentWidth),{width:s,height:o??s*l}}(e,t),o=Math.round(12700*r.width),a=Math.round(12700*r.height),i=n?e.doc.raw.get(n):void 0;if(i)return i.replace(/(<wp:extent\b[^>]*?\bcx=")\d+("[^>]*?\bcy=")\d+/,`$1${o}$2${a}`).replace(/(<a:xfrm\b[^>]*>\s*<a:off\b[^>]*\/>\s*<a:ext\b[^>]*?\bcx=")\d+("[^>]*?\bcy=")\d+/,`$1${o}$2${a}`);const l=t.getAttribute("src")??"",s=`${e.part}\n${l}`;let c=e.mediaBySrc.get(s);if(!c){const t=e.images.get(l)??function(e){const t=/^data:([^;,]+);base64,(.*)$/s.exec(e);if(!t)return null;const n=atob(t[2]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return{bytes:r,mime:t[1]}}(l);if(!t)return"";const n=Nt[t.mime]??"png";P(e.parts,n,t.mime);let r=1;const o=[...e.parts.keys()].find(r=>r.startsWith("word/media/inserted")&&r.endsWith(`.${n}`)&&function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e.parts.get(r),t.bytes));if(o)r=Number(/inserted(\d+)\./.exec(o)[1]);else{for(;e.parts.has(`word/media/inserted${r}.${n}`);)r++;e.parts.set(`word/media/inserted${r}.${n}`,t.bytes)}c=M(e.parts,e.part,$.image,function(e,t){const n=e.split("/").slice(0,-1),r=t.split("/");let o=0;for(;o<n.length&&o<r.length-1&&n[o]===r[o];)o++;return[...n.slice(o).map(()=>".."),...r.slice(o)].join("/")}(e.part,`word/media/inserted${r}.${n}`)),e.mediaBySrc.set(s,c)}const d=++e.drawingId;return`<w:r><w:drawing><wp:inline xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${o}" cy="${a}"/><wp:docPr id="${d}" name="Picture ${d}"/><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="${d}" name="Picture ${d}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${c}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${o}" cy="${a}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`}function At(e,t,n,r={}){let o="",a=null;const i=()=>{a?.body&&(o+=`<w:r>${mt(e.doc,a.format,a.runId)}${a.body}</w:r>`),a=null},l=(e,t,n)=>{n&&(a&&a.runId===t&&JSON.stringify(a.format)===JSON.stringify(e)?a.body+=n:(i(),a={format:e,runId:t,body:n}))},s=(t,r,a)=>{if(3===t.nodeType)return void l(r,a,function(e){let t="",n="";const r=()=>{n&&(t+=`<w:t xml:space="preserve">${z(n)}</w:t>`),n=""};for(const o of e)"\t"===o?(r(),t+="<w:tab/>"):"\n"===o?(r(),t+="<w:br/>"):"‑"===o?(r(),t+="<w:noBreakHyphen/>"):""===o?(r(),t+="<w:softHyphen/>"):""!==o&&"\ufeff"!==o&&(n+=o);return r(),t}(t.nodeValue??""));if(1!==t.nodeType)return;const c=t,d=c.tagName;if("IMG"===d)return i(),void(o+=$t(e,c));const u=c.getAttribute("data-raw");if(u){const t=e.doc.raw.get(u);if(t){i(),o+=t;const n=c.getAttribute("data-note");null!==n&&e.notesUsed.add(n)}return}if(c.hasAttribute("data-page-break"))return void l(r,a,'<w:br w:type="page"/>');const m=c.getAttribute("data-note");if(null!==m)return i(),e.notesUsed.add(m),gt(e,"FootnoteReference"),void(o+=`<w:r><w:rPr><w:rStyle w:val="FootnoteReference"/></w:rPr><w:footnoteReference w:id="${z(m)}"/></w:r>`);const f=c.getAttribute("data-bookmark");if(null!==f){i();const t=++e.bookmarkId;return void(o+=`<w:bookmarkStart w:id="${t}" w:name="${z(f)}"/><w:bookmarkEnd w:id="${t}"/>`)}const p=c.getAttribute("data-field");if("page"===p||"pages"===p)return i(),void(o+=`<w:fldSimple w:instr=" ${"page"===p?"PAGE":"NUMPAGES"} "><w:r>${mt(e.doc,r,a)}<w:t>1</w:t></w:r></w:fldSimple>`);if("BR"===d)return void(function(e,t){let n=e;for(;n!==t;){let e=n.nextSibling;for(;e&&3===e.nodeType&&!e.nodeValue;)e=e.nextSibling;if(e)return!1;if(!n.parentNode)return!0;n=n.parentNode}return!0}(c,n)||l(r,a,"<w:br/>"));if("A"===d)return i(),void(o+=function(e,t,n,r){const o=t.getAttribute("data-anchor"),a=t.getAttribute("href")??"";let i=t.getAttribute("data-rel");const l=W(e.parts,e.part),s=i?l.find(e=>e.id===i):void 0;a&&!a.startsWith("#")&&s?.target!==a&&(i=l.find(e=>e.external&&e.target===a)?.id??M(e.parts,e.part,$.hyperlink,a,!0),t.setAttribute("data-rel",i));const c=t.querySelector("[data-r]")?n:{color:"#0563c1",u:!0,...n},d=At(e,Array.from(t.childNodes),r,c);return`<w:hyperlink${o?` w:anchor="${z(o)}"`:i?` r:id="${z(i)}"`:a.startsWith("#")?` w:anchor="${z(a.slice(1))}"`:""} w:history="1">${d}</w:hyperlink>`}(e,c,r,n));const h=c.getAttribute("data-comment");h&&e.firstComment.get(h)===c&&(i(),o+=`<w:commentRangeStart w:id="${z(h)}"/>`);const g=c.getAttribute("data-r"),w=function(e,t){const n={...t},r=e.tagName;if("B"!==r&&"STRONG"!==r||(n.b=!0),"I"!==r&&"EM"!==r||(n.i=!0),"U"===r&&(n.u=!0),"S"!==r&&"STRIKE"!==r||(n.strike=!0),"SUB"===r&&(n.vert="sub"),"SUP"===r&&(n.vert="super"),"FONT"===r){const t=lt(e.getAttribute("color")??void 0);t&&(n.color=t);const r=e.getAttribute("face");r&&(n.font=r.split(",")[0].replace(/["']/g,"").trim());const o=Number(e.getAttribute("size"));o>=1&&o<=7&&(n.size=ct[o-1])}const o=at(e),a=o.get("font-weight");a&&(n.b="bold"===a||"bolder"===a||Number(a)>=600);const i=o.get("font-style");i&&(n.i="italic"===i||"oblique"===i);const l=o.get("text-decoration-line")??o.get("text-decoration");l&&(/none/.test(l)?(n.u=!1,n.strike=!1):(/underline/.test(l)&&(n.u=!0),/line-through/.test(l)&&(n.strike=!0)));const s=o.get("font-family");s&&(n.font=s.split(",")[0].replace(/["']|"/g,"").trim());const c=st(o.get("font-size"));if(c&&(n.size=Math.round(2*c)/2),o.has("color")){const e=lt(o.get("color"));e?n.color=e:delete n.color}const d=o.get("background-color")??o.get("background");if(void 0!==d){const e=lt(d);e?n.hl=e:delete n.hl}return n}(c,r);for(const e of Array.from(c.childNodes))s(e,w,g??a);h&&e.lastComment.get(h)===c&&(i(),o+=`<w:commentRangeEnd w:id="${z(h)}"/><w:r><w:commentReference w:id="${z(h)}"/></w:r>`)};for(const e of t)s(e,r,null);return i(),o}function Lt(e,t,n,r,o){const a=n?B(n):void 0,i=H(a),l=function(e){const t=at(e),n={},r=t.get("text-align")??e.getAttribute("align")??void 0;"left"===r||"start"===r?n.align="left":"center"!==r&&"right"!==r&&"justify"!==r||(n.align=r);const o=st(t.get("margin-left"));void 0!==o&&(n.indentLeft=o);const a=st(t.get("margin-right"));void 0!==a&&(n.indentRight=a),e.hasAttribute("data-tabs")&&(n.tabs=I(e.getAttribute("data-tabs")));const i=st(t.get("text-indent"));void 0!==i&&(n.firstLine=i);const l=st(t.get("margin-top"));void 0!==l&&(n.before=l);const s=st(t.get("margin-bottom"));void 0!==s&&(n.after=s);const c=t.get("line-height");if(c){const e=st(c);e?n.linePoints=e:Number(c)&&(n.lineMultiple=Number(c))}return n}(t);let s=rt(n);const c=(e,t)=>{s=s.filter(t=>t.name!==e),t&&s.push({name:e,xml:t})};if(c("w:pStyle",r?`<w:pStyle w:val="${z(r)}"/>`:null),c("w:numPr",o?`<w:numPr><w:ilvl w:val="${o.ilvl}"/><w:numId w:val="${z(o.numId)}"/></w:numPr>`:null),l.align!==i.align&&c("w:jc",l.align?`<w:jc w:val="${"justify"===l.align?"both":l.align}"/>`:null),!(o||dt(l.indentLeft,i.indentLeft)&&dt(l.firstLine,i.firstLine)&&dt(l.indentRight,i.indentRight))){const e=[];void 0!==l.indentLeft&&e.push(`w:left="${ut(l.indentLeft)}"`),void 0!==l.indentRight&&e.push(`w:right="${ut(l.indentRight)}"`),void 0!==l.firstLine&&e.push(l.firstLine<0?`w:hanging="${ut(-l.firstLine)}"`:`w:firstLine="${ut(l.firstLine)}"`),c("w:ind",e.length?`<w:ind ${e.join(" ")}/>`:null)}if(!(dt(l.before,i.before)&&dt(l.after,i.after)&&dt(l.lineMultiple,i.lineMultiple)&&dt(l.linePoints,i.linePoints))){const e=[];void 0!==l.before&&e.push(`w:before="${ut(l.before)}"`),void 0!==l.after&&e.push(`w:after="${ut(l.after)}"`),void 0!==l.lineMultiple&&e.push(`w:line="${Math.round(240*l.lineMultiple)}" w:lineRule="auto"`),void 0!==l.linePoints&&e.push(`w:line="${ut(l.linePoints)}" w:lineRule="exact"`),c("w:spacing",e.length?`<w:spacing ${e.join(" ")}/>`:null)}if(t.hasAttribute("data-tabs")&&!Pt(l.tabs??[],i.tabs??[])){const e=(l.tabs??[]).map(e=>`<w:tab w:val="${e.align}" w:pos="${ut(e.pos)}"/>`),t=(i.tabs??[]).filter(e=>!(l.tabs??[]).some(t=>dt(t.pos,e.pos))).map(e=>`<w:tab w:val="clear" w:pos="${ut(e.pos)}"/>`);c("w:tabs",e.length||t.length?`<w:tabs>${[...e,...t].join("")}</w:tabs>`:null)}c("w:sectPr",e.sections.get(t)??null);const d=ot(s,et);return d?`<w:pPr>${d}</w:pPr>`:""}var Pt=(e,t)=>e.length===t.length&&e.every((e,n)=>dt(e.pos,t[n].pos)&&e.align===t[n].align);function Tt(e,t,n,r){const o=t.getAttribute("data-docx"),a=o?e.doc.blocks.get(o):void 0;if(a?.xml&&a.xml.startsWith("<w:p")&&(a.fingerprint===p(t)||t.hasAttribute("data-locked"))&&!e.sections.has(t)&&(t.hasAttribute("data-locked")||(a.numId??null)===(r?.numId??null)&&(a.ilvl??null)===(r?.ilvl??null))){for(const t of a.xml.matchAll(/<w:footnoteReference\b[^>]*w:id="([^"]+)"/g))e.notesUsed.add(t[1]);return a.xml}const i=Lt(e,t,a?.props,function(e,t){let n=t.getAttribute("data-pstyle");if(!n){const r=/^H([1-6])$/.exec(t.tagName);r?n=yt(e,`heading ${r[1]}`)??`Heading${r[1]}`:"BLOCKQUOTE"===t.tagName&&(n=yt(e,"quote"))}return n&>(e,n),n}(e,t),r);let l=At(e,n,t);const s=t.getAttribute("data-bm");if(s&&/^[A-Za-z0-9_]+$/.test(s)&&!l.includes(`w:name="${s}"`)){const t=++e.bookmarkId;l=`<w:bookmarkStart w:id="${t}" w:name="${s}"/>${l}<w:bookmarkEnd w:id="${t}"/>`}return`<w:p>${i}${l}</w:p>`}var Mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","TABLE","LI","HR","SECTION","ARTICLE"]);function Rt(e,t,n,r){if(t.hasAttribute("data-checklist")){const n=function(e){if(e.checkNums)return e.checkNums;const{path:t,text:n}=kt(e),r=B(n),o={},a=new Map;for(const e of r.children.filter(e=>"w:abstractNum"===e.name)){const t=e.children.find(e=>"w:lvl"===e.name&&"0"===e.attrs["w:ilvl"]),n=E(t,"w:lvlText")?.attrs["w:val"];n===k.open&&a.set(e.attrs["w:abstractNumId"],"open"),n===k.done&&a.set(e.attrs["w:abstractNumId"],"done")}for(const e of r.children.filter(e=>"w:num"===e.name)){const t=a.get(E(e,"w:abstractNumId")?.attrs["w:val"]??"");t&&!o[t]&&(o[t]=e.attrs["w:numId"])}const i=t=>{const n=Ct(e,!1,t);return St(e,n,!1)};return e.checkNums={open:o.open??i(k.open),done:o.done??i(k.done)},e.checkNums}(e),o=t.getAttribute("data-ilvl"),a=null!==o&&Number(o)>r?Number(o):r+1;let i="";for(const r of Array.from(t.children)){if("UL"===r.tagName||"OL"===r.tagName){i+=Rt(e,r,null,a);continue}if("LI"!==r.tagName)continue;const t=Array.from(r.children).filter(e=>"UL"===e.tagName||"OL"===e.tagName);i+=Tt(e,r,Array.from(r.childNodes).filter(e=>!t.includes(e)),{numId:r.hasAttribute("data-checked")?n.done:n.open,ilvl:a});for(const n of t)i+=Rt(e,n,null,a)}return i}const o=function(e,t,n){const r=t.getAttribute("data-num-id");if(r)return r;if(n)return t.setAttribute("data-num-id",n),n;let o;return"OL"===t.tagName?(e.orderedAbstract??=Ct(e,!0),o=St(e,e.orderedAbstract,!0)):(e.bulletNum??=St(e,Ct(e,!1),!1),o=e.bulletNum),t.setAttribute("data-num-id",o),o}(e,t,n),a=t.getAttribute("data-ilvl"),i=null!==a&&Number(a)>r?Number(a):r+1;let l="";for(const n of Array.from(t.children)){if("UL"===n.tagName||"OL"===n.tagName){l+=Rt(e,n,o,i);continue}if("LI"!==n.tagName)continue;const t=Array.from(n.children).filter(e=>"UL"===e.tagName||"OL"===e.tagName);l+=Tt(e,n,Array.from(n.childNodes).filter(e=>!t.includes(e)),{numId:o,ilvl:i});for(const n of t)l+=Rt(e,n,o,i)}return l}function Et(e){return Array.from(e.children).some(e=>Mt.has(e.tagName))}function zt(e,t){let n="",r=[];const o=()=>{r.some(e=>1===e.nodeType||(e.nodeValue??"").trim())&&(n+=`<w:p>${At(e,r,t)}</w:p>`),r=[]};for(const a of Array.from(t.childNodes)){const t=a;if(1!==a.nodeType||!Mt.has(t.tagName)){r.push(a);continue}o();const i=t.getAttribute("data-docx"),l=i?e.doc.blocks.get(i):void 0;"UL"===t.tagName||"OL"===t.tagName?n+=Rt(e,t,null,-1):"TABLE"===t.tagName?n+=Ft(e,t):t.hasAttribute("data-toc")?n+=jt(e,t,l?.fingerprint===p(t)?l.xml:void 0):t.hasAttribute("data-locked")&&l?.xml?n+=l.xml:"HR"===t.tagName?n+='<w:p><w:pPr><w:pBdr><w:bottom w:val="single" w:sz="6" w:space="1" w:color="auto"/></w:pBdr></w:pPr></w:p>':Et(t)?n+=zt(e,t):n+=Tt(e,t,Array.from(t.childNodes),null)}return o(),n}function Ft(e,t){const n=t.getAttribute("data-docx"),r=n?e.doc.blocks.get(n):void 0;if(r?.xml&&(t.hasAttribute("data-locked")||r.fingerprint===p(t)))return r.xml;const o=Array.from(t.querySelectorAll(":scope > tbody > tr, :scope > tr, :scope > thead > tr, :scope > tfoot > tr")),a=[];let i=0;const l=o.map(t=>{const n=[];let r=0;const o=()=>{for(;a[r]?.left>0;){const e=a[r];e.left--,n.push({continuation:!0,span:e.span,col:r,props:e.props}),r+=e.span}};for(const i of Array.from(t.children).filter(e=>"TD"===e.tagName||"TH"===e.tagName)){o();const t=Math.max(1,Number(i.getAttribute("colspan")??1)),l=Math.max(1,Number(i.getAttribute("rowspan")??1));n.push({cell:i,span:t,col:r}),l>1&&(a[r]={left:l-1,span:t,props:e.doc.blocks.get(i.getAttribute("data-docx")??"")?.props}),r+=t}return o(),i=Math.max(i,r),n}),s=Array.from(t.querySelectorAll(":scope > colgroup > col")),c=[];for(let t=0;t<i;t++){const n=s[t]?st(at(s[t]).get("width")):void 0;c.push(void 0!==n&&s.length===i?ut(n):Math.round(20*e.contentWidth/Math.max(i,1)))}return`<w:tbl>${r?.props??'<w:tblPr><w:tblW w:w="5000" w:type="pct"/><w:tblBorders><w:top w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:bottom w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:insideH w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:insideV w:val="single" w:sz="4" w:space="0" w:color="auto"/></w:tblBorders><w:tblLook w:val="04A0"/></w:tblPr>'}${`<w:tblGrid>${c.map(e=>`<w:gridCol w:w="${e}"/>`).join("")}</w:tblGrid>`}${o.map((t,n)=>`<w:tr>${e.doc.blocks.get(t.getAttribute("data-docx")??"")?.props??""}${l[n].map(t=>{const n=t.span,r=c.slice(t.col,t.col+n).reduce((e,t)=>e+t,0);if("continuation"in t)return`<w:tc><w:tcPr>${Ot(t.props,r,n,"continue",void 0)}</w:tcPr><w:p/></w:tc>`;const o=e.doc.blocks.get(t.cell.getAttribute("data-docx")??""),a=Number(t.cell.getAttribute("rowspan")??1),i=lt(at(t.cell).get("background-color"));let l=zt(e,t.cell);return l.endsWith("</w:p>")||l.endsWith("<w:p/>")||(l+="<w:p/>"),`<w:tc><w:tcPr>${Ot(o?.props,r,n,a>1?"restart":null,i)}</w:tcPr>${l}</w:tc>`}).join("")}</w:tr>`).join("")}</w:tbl>`}function Ot(e,t,n,r,o){const a=e?B(e):void 0;let i=rt(e).filter(e=>!["w:tcW","w:gridSpan","w:vMerge"].includes(e.name));i.push({name:"w:tcW",xml:`<w:tcW w:w="${t}" w:type="dxa"/>`}),n>1&&i.push({name:"w:gridSpan",xml:`<w:gridSpan w:val="${n}"/>`}),r&&i.push({name:"w:vMerge",xml:"restart"===r?'<w:vMerge w:val="restart"/>':"<w:vMerge/>"});const l=E(a,"w:shd")?.attrs["w:fill"]?.toLowerCase();return"continue"!==r&&(o?.slice(1)??void 0)!==(l&&/^[0-9a-f]{6}$/.test(l)?l:void 0)&&(i=i.filter(e=>"w:shd"!==e.name),o&&i.push({name:"w:shd",xml:`<w:shd w:val="clear" w:color="auto" w:fill="${o.slice(1).toUpperCase()}"/>`})),ot(i,tt)}function jt(e,t,n){if(n)return n;const r=Math.round(20*e.contentWidth),o='<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve"> TOC \\o "1-3" \\h \\z \\u </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r>',a=Array.from(t.querySelectorAll("[data-toc-level]")).map((t,n)=>{const a=Math.min(Math.max(Number(t.getAttribute("data-toc-level"))||1,1),6);gt(e,`TOC${a}`);const i=t.querySelector("a"),l=i?.getAttribute("data-anchor")??"",s=t.querySelector("[data-toc-page]")?.textContent??"",c=(i??t).cloneNode(!0);c.querySelectorAll("[data-toc-page]").forEach(e=>e.remove());const d=`<w:r><w:t xml:space="preserve">${z(c.textContent??"")}</w:t></w:r><w:r><w:tab/></w:r><w:r><w:t>${z(s)}</w:t></w:r>`,u=/^[A-Za-z0-9_]+$/.test(l)?`<w:hyperlink w:anchor="${l}" w:history="1">${d}</w:hyperlink>`:d;return`<w:p><w:pPr><w:pStyle w:val="TOC${a}"/><w:tabs><w:tab w:val="right" w:leader="dot" w:pos="${r}"/></w:tabs></w:pPr>${0===n?o:""}${u}</w:p>`});return a.length||a.push(`<w:p>${o}</w:p>`),`<w:sdt><w:sdtPr><w:docPartObj><w:docPartGallery w:val="Table of Contents"/><w:docPartUnique/></w:docPartObj></w:sdtPr><w:sdtContent>${a.join("")}<w:p><w:r><w:fldChar w:fldCharType="end"/></w:r></w:p></w:sdtContent></w:sdt>`}function Ht(e,t){return`<w:footnote w:id="${z(e)}"><w:p><w:pPr><w:pStyle w:val="FootnoteText"/></w:pPr><w:r><w:rPr><w:rStyle w:val="FootnoteReference"/></w:rPr><w:footnoteRef/></w:r><w:r><w:t xml:space="preserve"> ${z(t)}</w:t></w:r></w:p></w:footnote>`}var Dt=["w:writeProtection","w:view","w:zoom","w:removePersonalInformation","w:removeDateAndTime","w:doNotDisplayPageBoundaries","w:displayBackgroundShape","w:printPostScriptOverText","w:printFractionalCharacterWidth","w:printFormsData","w:embedTrueTypeFonts","w:embedSystemFonts","w:saveSubsetFonts","w:saveFormsData","w:mirrorMargins","w:alignBordersAndEdges","w:bordersDoNotSurroundHeader","w:bordersDoNotSurroundFooter","w:gutterAtTop","w:hideSpellingErrors","w:hideGrammaticalErrors","w:activeWritingStyle","w:proofState","w:formsDesign","w:attachedTemplate","w:linkStyles","w:stylePaneFormatFilter","w:stylePaneSortMethod","w:documentType","w:mailMerge","w:revisionView","w:trackRevisions","w:doNotTrackMoves","w:doNotTrackFormatting","w:documentProtection","w:autoFormatOverride","w:styleLockTheme","w:styleLockQFSet","w:defaultTabStop","w:autoHyphenation","w:consecutiveHyphenLimit","w:hyphenationZone","w:doNotHyphenateCaps","w:showEnvelope","w:summaryLength","w:clickAndTypeStyle","w:defaultTableStyle","w:evenAndOddHeaders","w:bookFoldRevPrinting","w:bookFoldPrinting","w:bookFoldPrintingSheets","w:drawingGridHorizontalSpacing","w:drawingGridVerticalSpacing","w:displayHorizontalDrawingGridEvery","w:displayVerticalDrawingGridEvery","w:doNotUseMarginsForDrawingGridOrigin","w:drawingGridHorizontalOrigin","w:drawingGridVerticalOrigin","w:doNotShadeFormData","w:noPunctuationKerning","w:characterSpacingControl","w:printTwoOnOne","w:strictFirstAndLastChars","w:noLineBreaksAfter","w:noLineBreaksBefore","w:savePreviewPicture","w:doNotValidateAgainstSchema","w:saveInvalidXml","w:ignoreMixedContent","w:alwaysShowPlaceholderText","w:doNotDemarcateInvalidXml","w:saveXmlDataOnly","w:useXSLTWhenSaving","w:saveThroughXslt","w:showXMLTags","w:alwaysMergeEmptyNamespace","w:updateFields","w:hdrShapeDefaults","w:footnotePr","w:endnotePr","w:compat","w:docVars","w:rsids","m:mathPr","w:attachedSchema","w:themeFontLang","w:clrSchemeMapping","w:doNotIncludeSubdocsInStats","w:doNotAutoCompressPictures","w:forceUpgrade","w:captions","w:readModeInkLockDown","w:smartTagType","sl:schemaLibrary","w:shapeDefaults","w:doNotEmbedSmartTags","w:decimalSymbol","w:listSeparator"];function It(e,t,n){const{path:r,text:o}=function(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.settings);if(t){const n=q(e.doc.docPath,t.target);return{path:n,text:U(e.parts,n)??`<w:settings ${L}></w:settings>`}}const n="word/settings.xml";return M(e.parts,e.doc.docPath,$.settings,"settings.xml"),T(e.parts,n,"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"),{path:n,text:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:settings ${L}></w:settings>`}}(e),a=B(o),i=a.children.find(e=>e.name===t);let l=o;if(i)l=o.slice(0,i.start)+(n??"")+o.slice(i.end);else if(n){const e=Dt.indexOf(t),r=a.children.find(t=>Dt.indexOf(t.name)>e);l=r?o.slice(0,r.start)+n+o.slice(r.start):/<\/w:settings>\s*$/.test(o)?o.replace(/<\/w:settings>\s*$/,`${n}</w:settings>`):o.replace(/\/>\s*$/,`>${n}</w:settings>`)}l!==o&&G(e.parts,r,l)}function Bt(e,t,n){const r=/^<w:sectPr\b([^>]*?)\/?>/.exec(e)?.[1]??"";let o=rt(`<x>${/^<w:sectPr\b[^>]*\/>$/.test(e)?"":e.replace(/^<w:sectPr\b[^>]*>/,"").replace(/<\/w:sectPr>$/,"")}</x>`).filter(e=>e.name!==t);return n&&(o=[...o,{name:t,xml:n}]),`<w:sectPr${r}>${ot(o,nt)}</w:sectPr>`}var Ut=e=>e>1?`<w:cols w:num="${e}" w:space="720"/>`:null;var Wt=`${L} 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"`;function qt(e,t,n,r){const o=document.createElement("div");o.innerHTML=n;const a=e.part;let i;e.part=r;try{i=zt(e,o)}finally{e.part=a}/<\/w:p>\s*$|<w:p\/>\s*$/.test(i)||(i+="<w:p/>");const l=U(e.parts,r);return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n${(l?new RegExp(`<w:${t}\\b[^>]*>`).exec(l)?.[0]:void 0)??`<w:${t} ${Wt}>`}${i}</w:${t}>`}async function Kt(e,t,n){const r=new Map(e.parts),o=U(r,e.docPath);if(!o)throw new Error("Not a Word document");const a=B(o),i=E(a,"w:body"),l=E(i,"w:sectPr"),s={doc:e,parts:r,images:n.images??new Map,firstComment:new Map,lastComment:new Map,drawingId:9e4,mediaBySrc:e.insertedMedia??=new Map,contentWidth:(n.page.width-n.page.left-n.page.right)/20,bulletNum:null,orderedAbstract:null,part:e.docPath,checkNums:null,bookmarkId:8e4,sections:new Map,notesUsed:new Set};t.querySelectorAll("[data-comment]").forEach(e=>{const t=e.getAttribute("data-comment");s.firstComment.has(t)||s.firstComment.set(t,e),s.lastComment.set(t,e)});const c=l?o.slice(l.start,l.end):void 0,d=function(e,t,n){const r=Array.from(t.children).filter(e=>e.hasAttribute("data-section")),o=(n??"<w:sectPr/>").replace(/<w:(header|footer)Reference\b[^>]*\/>/g,"").replace(/<w:titlePg\b[^>]*\/>/g,"").replace(/<w:type\b[^>]*\/>/g,"");r.forEach((t,n)=>{const a=e.doc.blocks.get(t.getAttribute("data-docx")??""),i=a?.props?/<w:sectPr\b[\s\S]*?(?:<\/w:sectPr>|\/>)/.exec(a.props)?.[0]:void 0;let l=i??o;const s=0===n?null:r[n-1].getAttribute("data-section");l=0===n&&i?l:Bt(l,"w:type",s&&"nextPage"!==s?`<w:type w:val="${z(s)}"/>`:null),l=Bt(l,"w:cols",Ut(Number(t.getAttribute("data-cols")??1))),e.sections.set(t,l)});const a=r[r.length-1]?.getAttribute("data-section");return r.length?a??"nextPage":null}(s,t,c);let u=zt(s,t);/<\/w:p>\s*$|<w:p\/>\s*$/.test(u)||(u+="<w:p/>"),u=function(e){const t=new Set,n=e.replace(/<w:commentRangeStart\b[^>]*w:id="([^"]+)"[^>]*\/>/g,(e,n)=>t.has(n)?"":(t.add(n),e)),r=new Set,o=[],a=n.split(/(<w:commentRangeEnd\b[^>]*\/>|<w:r>(?:<w:rPr>(?:(?!<\/w:rPr>).)*<\/w:rPr>)?<w:commentReference\b[^>]*\/><\/w:r>)/s);for(let e=a.length-1;e>=0;e--){const t=a[e],n=/^<w:commentRangeEnd\b[^>]*w:id="([^"]+)"/.exec(t)??/^<w:r>.*<w:commentReference\b[^>]*w:id="([^"]+)"/s.exec(t);if(n&&e%2==1){const e=`${t.includes("commentRangeEnd")?"e":"r"}${n[1]}`;if(r.has(e))continue;r.add(e)}o.push(t)}return o.reverse().join("")}(u);const m=function(e,t,n,r){let o=t??"<w:sectPr/>";const a=n.page,i=e.doc.page;if(Object.keys(a).some(e=>a[e]!==i[e])||!t){const e=a.width>a.height,n=t?B(t):void 0,r=E(n,"w:pgMar")?.attrs["w:gutter"]??"0";o=Bt(o,"w:pgSz",`<w:pgSz w:w="${a.width}" w:h="${a.height}"${e?' w:orient="landscape"':""}/>`),o=Bt(o,"w:pgMar",`<w:pgMar w:top="${a.top}" w:right="${a.right}" w:bottom="${a.bottom}" w:left="${a.left}" w:header="${a.header}" w:footer="${a.footer}" w:gutter="${r}"/>`)}const l=n.columns??e.doc.columns;l!==e.doc.columns&&(o=Bt(o,"w:cols",Ut(l))),null!==r&&(o=Bt(o,"w:type","nextPage"!==r?`<w:type w:val="${z(r)}"/>`:null));const s=n.titlePage??e.doc.titlePage;s!==e.doc.titlePage&&(o=Bt(o,"w:titlePg",s?"<w:titlePg/>":null));const c=n.evenOdd??e.doc.evenOdd;c!==e.doc.evenOdd&&It(e,"w:evenAndOddHeaders",c?"<w:evenAndOddHeaders/>":null);const d=[],u=(t,n)=>{const r="headers"===t?"header":"footer";for(const o of["default","first","even"]){const a=e.doc[t][o],i=n?.[o];if(void 0===i||!a.editable||i===a.html)continue;if(!a.part&&!i.replace(/<br>|<p>|<\/p>|\s/g,""))continue;let l=a.part;if(!l){let n=1;for(;e.parts.has(`word/${r}${n}.xml`);)n++;l=`word/${r}${n}.xml`,G(e.parts,l,""),T(e.parts,l,`application/vnd.openxmlformats-officedocument.wordprocessingml.${r}+xml`);const i=M(e.parts,e.doc.docPath,"headers"===t?$.header:$.footer,`${r}${n}.xml`);d.push(`<w:${r}Reference w:type="${o}" r:id="${i}"/>`),a.part=l}G(e.parts,l,qt(e,"headers"===t?"hdr":"ftr",i,l))}};if(u("headers",n.headers),u("footers",n.footers),d.length){const e=/^<w:sectPr\b([^>]*?)\/?>/.exec(o)?.[1]??"",t=/^<w:sectPr\b[^>]*\/>$/.test(o)?"":o.replace(/^<w:sectPr\b[^>]*>/,"").replace(/<\/w:sectPr>$/,"");o=`<w:sectPr${e}>${ot([...rt(`<x>${t}</x>`),...d.map(e=>({name:/^<(w:\w+)/.exec(e)[1],xml:e}))],nt)}</w:sectPr>`}return o}(s,c,n,d);!function(e){const t=[...e.notesUsed].filter(t=>{const n=e.doc.footnotes.get(t);return n&&n.editable&&(!n.xml||n.text!==e.doc.footnotesRead?.get(t))});if(!t.length)return;gt(e,"FootnoteText"),gt(e,"FootnoteReference");const n=W(e.parts,e.doc.docPath).find(e=>e.type===$.footnotes);let r,o;n?(r=q(e.doc.docPath,n.target),o=U(e.parts,r)??""):(r="word/footnotes.xml",M(e.parts,e.doc.docPath,$.footnotes,"footnotes.xml"),T(e.parts,r,"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"),o=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:footnotes ${L}><w:footnote w:type="separator" w:id="-1"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote></w:footnotes>`,It(e,"w:footnotePr",'<w:footnotePr><w:footnote w:id="-1"/><w:footnote w:id="0"/></w:footnotePr>'));const a=B(o),i=new Map(a.children.filter(e=>"w:footnote"===e.name).map(e=>[e.attrs["w:id"],e]));let l=o;const s=[],c=[];for(const n of t){const t=Ht(n,e.doc.footnotes.get(n).text),r=i.get(n);r?c.push({start:r.start,end:r.end,xml:t}):s.push(t)}for(const e of c.sort((e,t)=>t.start-e.start))l=l.slice(0,e.start)+e.xml+l.slice(e.end);s.length&&(l=l.replace(/<\/w:footnotes>\s*$/,`${s.join("")}</w:footnotes>`)),G(e.parts,r,l)}(s),n.styleEdits?.size&&function(e,t){for(const n of t.keys())gt(e,n);const n=ht(e),r=n?U(e.parts,n):void 0;if(!n||!r)return;let o=r;const a=B(r).children.filter(e=>"w:style"===e.name&&t.has(e.attrs["w:styleId"])).reverse();for(const n of a){const a=t.get(n.attrs["w:styleId"]),i=r.slice(n.start,n.end),l=B(i),s=E(l,"w:rPr"),c=E(l,"w:pPr"),d=s?i.slice(s.start,s.end):void 0,u=c?i.slice(c.start,c.end):void 0,m=ft(d,{...D(s,e.doc.theme),...a.run},e.doc),f=bt(u,a.para);let p=l.children.filter(e=>"w:rPr"!==e.name&&"w:pPr"!==e.name).map(e=>({name:e.name,xml:i.slice(e.start,e.end)}));f&&p.push({name:"w:pPr",xml:f}),m&&p.push({name:"w:rPr",xml:m}),p=p.filter(Boolean);const h=`${/^<w:style\b[^>]*?(?=\/?>)/.exec(i)[0]}>${ot(p,wt)}</w:style>`;o=o.slice(0,n.start)+h+o.slice(n.end)}G(e.parts,n,o)}(s,n.styleEdits);const f=o.slice(a.start,a.innerStart),p=[!/\bxmlns:r=/.test(f)&&/\br:(id|embed)=/.test(u+m)?' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"':""].join(""),h=(p?o.slice(0,a.innerStart-1)+p+">":o.slice(0,a.innerStart))+o.slice(a.innerStart,i.innerStart)+u+m+o.slice(i.innerEnd);G(r,e.docPath,h),e.parts=r,e.page={...n.page};for(const t of["headers","footers"]){const r=n[t];for(const n of["default","first","even"]){const o=r?.[n];void 0!==o&&e[t][n].editable&&(e[t][n]={...e[t][n],html:o})}}return e.titlePage=n.titlePage??e.titlePage,e.evenOdd=n.evenOdd??e.evenOdd,e.columns=n.columns??e.columns,e.footnotesRead=new Map([...e.footnotes].map(([e,t])=>[e,t.text])),Y(r)}import{useRef as Gt,useState as Vt}from"react";import{Icon as Xt}from"efficient-shell/icons";import{Button as Qt,Checkbox as _t,Dialog as Jt,IconButton as Yt}from"efficient-shell/ui";import{Fragment as Zt,jsx as en,jsxs as tn}from"react/jsx-runtime";function nn({label:e,html:t,locked:n,scope:r,onRef:o}){const a=u(),i=Gt(null),l=(e,t)=>{document.activeElement!==i.current&&i.current?.focus(),document.execCommand(e,!1,t)},s=e=>{const t=i.current,n=document.getSelection();if(!t||!n)return;if(!n.rangeCount||!t.contains(n.anchorNode)){t.focus();const e=document.createRange();e.selectNodeContents(t.lastElementChild??t),e.collapse(!1),n.removeAllRanges(),n.addRange(e)}const r=n.getRangeAt(0);r.deleteContents();const o=document.createElement("div");o.innerHTML=(e=>`<span data-kind="field" data-field="${e}" contenteditable="false">1</span>`)(e);const a=o.firstChild;r.insertNode(a);const l=a.nextSibling;l&&"BR"===l.nodeName&&!l.nextSibling&&l.remove();const s=document.createTextNode("");a.after(s),n.collapse(s,1)};return tn("div",{className:"docs-hf-region",children:[tn("div",{className:"docs-hf-tools",onMouseDown:e=>e.preventDefault(),children:[en("span",{className:"docs-hf-label",children:e}),!n&&tn(Zt,{children:[en(Yt,{size:"sm",variant:"ghost","aria-label":a.bold,title:a.bold,onClick:()=>l("bold"),children:en(Xt,{name:"bold",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.italic,title:a.italic,onClick:()=>l("italic"),children:en(Xt,{name:"italic",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.underline,title:a.underline,onClick:()=>l("underline"),children:en(Xt,{name:"underline",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignLeft,title:a.alignLeft,onClick:()=>l("justifyLeft"),children:en(Xt,{name:"align-left",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignCenter,title:a.alignCenter,onClick:()=>l("justifyCenter"),children:en(Xt,{name:"align-center",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignRight,title:a.alignRight,onClick:()=>l("justifyRight"),children:en(Xt,{name:"align-right",size:14})}),en(Qt,{size:"sm",variant:"ghost",onClick:()=>s("page"),children:a.pageNumber}),en(Qt,{size:"sm",variant:"ghost",onClick:()=>s("pages"),children:a.pageCount})]})]}),en("div",{ref:e=>{i.current=e,o(e),e&&!e.dataset.ready&&(e.innerHTML=t||"<p><br></p>",e.dataset.ready="1")},className:"docs-page docs-hf-edit","data-doc":r,role:"textbox","aria-label":e,"aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0}),n&&en("p",{className:"docs-hf-note",children:a.headerFooterLocked})]})}function rn({value:e,locked:t,scope:n,onApply:r,onClose:o}){const a=u(),[i,l]=Vt(e.titlePage),[s,c]=Vt(e.evenOdd),d=Gt({}),m=[...i?["first"]:[],"default",...s?["even"]:[]],f={first:a.headerFirst,default:s?a.headerOdd:a.headerDefault,even:a.headerEven};return en(Jt,{open:!0,onClose:o,title:a.headersFooters,size:"lg",footer:tn(Zt,{children:[en(Qt,{variant:"secondary",onClick:o,children:a.cancel}),en(Qt,{variant:"primary",onClick:()=>{const t=(t,n)=>{const r=d.current[`${t}:${n}`];if(!r)return e[t][n];const o=r.innerHTML;return"<p><br></p>"!==o||e[t][n]?o:""},n=e=>({default:t(e,"default"),first:t(e,"first"),even:t(e,"even")});r({headers:n("headers"),footers:n("footers"),titlePage:i,evenOdd:s})},children:a.ok})]}),children:tn("div",{className:"docs-hf",children:[tn("div",{className:"docs-hf-options",children:[en(_t,{checked:i,onChange:l,label:a.differentFirst}),en(_t,{checked:s,onChange:c,label:a.differentOddEven})]}),m.map(r=>tn("section",{className:"docs-hf-kind",children:[en("h4",{children:f[r]}),en(nn,{label:`${a.header} · ${f[r]}`,html:e.headers[r],locked:t.headers[r],scope:n,onRef:e=>{d.current[`headers:${r}`]=e}}),en(nn,{label:`${a.footer} · ${f[r]}`,html:e.footers[r],locked:t.footers[r],scope:n,onRef:e=>{d.current[`footers:${r}`]=e}})]},r))]})})}import{useState as on}from"react";import{Button as an,Dialog as ln,FormField as sn,Input as cn,Select as dn}from"efficient-shell/ui";import{Fragment as un,jsx as mn,jsxs as fn}from"react/jsx-runtime";var pn=e=>{const t=Number(e.replace(",","."));return""!==e.trim()&&Number.isFinite(t)?t:void 0},hn=e=>void 0===e?"":String(Math.round(100*e)/100);function gn({value:e,onApply:t,onClose:n}){const r=u(),[o,a]=on(hn(e.lineMultiple??1.15)),[i,l]=on(hn(e.before??0)),[s,c]=on(hn(e.after??0)),[d,m]=on(hn(e.indentLeft??0)),[f,p]=on(hn(e.indentRight??0)),[h,g]=on(void 0===e.firstLine||0===e.firstLine?"none":e.firstLine>0?"first":"hanging"),[w,b]=on(hn(void 0===e.firstLine?36:Math.abs(e.firstLine)||36)),[y,v]=on(""),x=e=>t=>{e(t.target.value),v("")};return fn(ln,{open:!0,onClose:n,title:r.customSpacing,size:"sm",footer:fn(un,{children:[mn(an,{variant:"secondary",onClick:n,children:r.cancel}),mn(an,{variant:"primary",onClick:()=>{if([o,i,s,d,f,..."none"===h?[]:[w]].some(e=>void 0===pn(e)||pn(e)<0)||pn(o)<=0||pn(o)>10)return void v(r.spacingInvalid);const e=pn(w);t({lineMultiple:pn(o),before:pn(i),after:pn(s),indentLeft:pn(d),indentRight:pn(f),firstLine:"none"===h?0:"first"===h?e:-e})},children:r.ok})]}),children:[fn("div",{className:"docs-para-grid",children:[mn(sn,{label:r.lineSpacingCustom,children:mn(cn,{inputMode:"decimal",value:o,onChange:x(a)})}),mn(sn,{label:r.spacingBefore,children:mn(cn,{inputMode:"decimal",value:i,onChange:x(l)})}),mn(sn,{label:r.spacingAfter,children:mn(cn,{inputMode:"decimal",value:s,onChange:x(c)})}),mn(sn,{label:r.indentLeft,children:mn(cn,{inputMode:"decimal",value:d,onChange:x(m)})}),mn(sn,{label:r.indentRight,children:mn(cn,{inputMode:"decimal",value:f,onChange:x(p)})}),mn(sn,{label:r.indentSpecial,children:mn(dn,{value:h,onChange:e=>{g(String(e)),v("")},options:[{value:"none",label:r.indentNone},{value:"first",label:r.indentFirstLine},{value:"hanging",label:r.indentHanging}]})}),"none"!==h&&mn(sn,{label:r.indentBy,children:mn(cn,{inputMode:"decimal",value:w,onChange:x(b)})})]}),y&&mn("p",{className:"docs-para-error",role:"alert",children:y})]})}import{useRef as wn}from"react";import{Fragment as bn,jsx as yn,jsxs as vn}from"react/jsx-runtime";var xn=4/3,kn={left:"center",center:"right",right:"left"};function Cn({pageWidth:e,marginLeft:t,marginRight:n,zoom:r,value:o,onChange:a}){const i=u(),l=wn(null),s=r/100*xn,c=e-t-n,d=e=>(t+e)*s+"px",m=e=>{const n=l.current.getBoundingClientRect();return r=(e-n.left)/s-t,4.5*Math.round(r/4.5);var r},f=(e,t,n)=>{e.preventDefault(),e.stopPropagation();const r=e.currentTarget;r.setPointerCapture(e.pointerId);const o=l.current.getBoundingClientRect().bottom,i=e=>{const n=t(m(e.clientX),e.clientY>o+12);n&&a(n)},s=e=>{r.removeEventListener("pointermove",i),r.removeEventListener("pointerup",s);const t=n?.(m(e.clientX),e.clientY>o+12);t&&a(t)};r.addEventListener("pointermove",i),r.addEventListener("pointerup",s)},p=(e,t,n)=>Math.min(Math.max(e,t),n),h=o;return vn("div",{className:"docs-ruler",style:{width:e*s+"px"},"aria-label":i.ruler,title:h?i.tabStopHint:void 0,ref:l,onPointerDown:e=>{if(!h||0!==e.button)return;const t=m(e.clientX);t<=0||t>=c||a({...h,tabs:[...h.tabs.filter(e=>Math.abs(e.pos-t)>1),{pos:t,align:"left"}].sort((e,t)=>e.pos-t.pos)})},children:[yn("div",{className:"docs-ruler-margin",style:{left:0,width:d(0)}}),yn("div",{className:"docs-ruler-margin",style:{right:0,width:n*s+"px"}}),Array.from({length:Math.floor(c/36)+1},(e,t)=>yn("span",{className:"docs-ruler-tick",style:{left:d(36*t)},children:t?t/2:""},t)),h&&vn(bn,{children:[yn("button",{type:"button",className:"docs-ruler-first","aria-label":i.indentFirstLine,style:{left:d(h.indentLeft+h.firstLine)},onPointerDown:e=>f(e,e=>({...h,firstLine:p(e,0,c-18)-h.indentLeft}))}),yn("button",{type:"button",className:"docs-ruler-left","aria-label":i.indentLeft,style:{left:d(h.indentLeft)},onPointerDown:e=>f(e,e=>{const t=p(e,0,c-h.indentRight-18);return{...h,indentLeft:t}})}),yn("button",{type:"button",className:"docs-ruler-right","aria-label":i.indentRight,style:{left:d(c-h.indentRight)},onPointerDown:e=>f(e,e=>({...h,indentRight:p(c-e,0,c-h.indentLeft-18)}))}),h.tabs.map((e,t)=>yn("button",{type:"button",className:`docs-ruler-tab docs-ruler-tab-${e.align}`,"aria-label":`${i.tabStop} ${Math.round(e.pos)}pt`,style:{left:d(e.pos)},onDoubleClick:e=>{e.stopPropagation(),a({...h,tabs:h.tabs.map((e,n)=>n===t?{...e,align:kn[e.align]}:e)})},onPointerDown:e=>f(e,e=>({...h,tabs:h.tabs.map((n,r)=>r===t?{...n,pos:p(e,0,c)}:n)}),(e,n)=>({...h,tabs:n?h.tabs.filter((e,n)=>n!==t):h.tabs.map((n,r)=>r===t?{...n,pos:p(e,0,c)}:n).sort((e,t)=>e.pos-t.pos)}))},`${e.pos}-${t}`))]})]})}function Sn(e,t,n){const r=new Blob([e],{type:n}),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(o),1e4)}import{useEffect as Nn,useRef as $n}from"react";import{Icon as An}from"efficient-shell/icons";import{Button as Ln,Checkbox as Pn,IconButton as Tn,Input as Mn}from"efficient-shell/ui";import{jsx as Rn,jsxs as En}from"react/jsx-runtime";function zn({query:e,replacement:t,matchCase:n,current:r,total:o,onQuery:a,onReplacement:i,onMatchCase:l,onStep:s,onReplace:c,onReplaceAll:d,onClose:m}){const f=u(),p=$n(null);return Nn(()=>{p.current?.focus(),p.current?.select()},[]),En("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1",children:[Rn("div",{className:"w-40",children:Rn(Mn,{ref:p,size:"sm","aria-label":f.find,placeholder:f.find,value:e,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s(!e.shiftKey))}})}),Rn("span",{className:"min-w-14 text-xs text-ink-muted","aria-live":"polite",children:e?o?f.matchCount(r+1,o):f.noMatches:""}),Rn(Tn,{size:"sm",variant:"ghost","aria-label":f.previousMatch,title:f.previousMatch,onClick:()=>s(!1),children:Rn(An,{name:"chevron-up",size:16})}),Rn(Tn,{size:"sm",variant:"ghost","aria-label":f.nextMatch,title:f.nextMatch,onClick:()=>s(!0),children:Rn(An,{name:"chevron-down",size:16})}),Rn("div",{className:"ml-1 w-40",children:Rn(Mn,{size:"sm","aria-label":f.replaceWith,placeholder:f.replaceWith,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c())}})}),Rn(Ln,{size:"sm",variant:"secondary",onClick:c,children:f.replace}),Rn(Ln,{size:"sm",variant:"secondary",onClick:d,children:f.replaceAll}),En("label",{className:"ml-1 flex items-center gap-1 text-xs text-ink-muted",children:[Rn(Pn,{checked:n,onChange:l,"aria-label":f.matchCase}),f.matchCase]}),Rn(Tn,{className:"ml-auto",size:"sm",variant:"ghost","aria-label":f.closeFind,title:f.closeFind,onClick:m,children:Rn(An,{name:"close",size:16})})]})}var Fn=class{past=[];future=[];get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}record(e){if(this.past[this.past.length-1]?.html===e.html)return;this.past.push(e),this.future=[];let t=this.past.reduce((e,t)=>e+t.html.length,0);for(;this.past.length>1&&(this.past.length>200||t>67108864);)t-=this.past.shift().html.length}undo(e){const t=this.past.pop();return t?(this.future.push(e),t):null}redo(e){const t=this.future.pop();return t?(this.past.push(e),t):null}};function On(e,t,n){const r=[];let o=t;for(;o&&o!==e;){const e=o.parentNode;if(!e)return null;r.unshift(Array.prototype.indexOf.call(e.childNodes,o)),o=e}return o===e?{path:r,offset:n}:null}function jn(e,t){let n=e;for(const e of t.path){const t=n.childNodes[e];if(!t)return null;n=t}const r=3===n.nodeType?(n.nodeValue??"").length:n.childNodes.length;return{node:n,offset:Math.min(t.offset,r)}}function Hn(e){return Array.from(e.querySelectorAll("h1,h2,h3,h4,h5,h6")).filter(e=>!e.closest("[data-hidden]")&&""!==(e.textContent??"").trim())}var Dn=["#000000","#404040","#7f7f7f","#c00000","#ff0000","#ffc000","#00b050","#0070c0","#002060","#7030a0"],In=["#ffff00","#00ff00","#00ffff","#ff00ff","#ff0000","#c0c0c0"],Bn=["#d9e2f3","#e2efd9","#fff2cc","#fbe4d5","#ededed","#bfbfbf"];function Un(e){if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();const t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);return t?`#${[t[1],t[2],t[3]].map(e=>Number(e).toString(16).padStart(2,"0")).join("")}`:""}import{useState as Wn}from"react";import{Button as qn,Dialog as Kn,FormField as Gn,Select as Vn}from"efficient-shell/ui";import{Fragment as Xn,jsx as Qn,jsxs as _n}from"react/jsx-runtime";function Jn({value:e,onApply:t,onClose:n}){const r=u(),[o,a]=Wn(e.page),i=o.width>o.height,l=O(o),s=F(o),c={a4:"A4",a3:"A3",a5:"A5",letter:r.paperLetter,legal:r.paperLegal},d={normal:r.marginsNormal,narrow:r.marginsNarrow,moderate:r.marginsModerate,wide:r.marginsWide},m={value:"custom",label:r.custom};return Qn(Kn,{open:!0,onClose:n,title:r.pageSetup,size:"sm",footer:_n(Xn,{children:[Qn(qn,{variant:"secondary",onClick:n,children:r.cancel}),Qn(qn,{variant:"primary",onClick:()=>t({page:o}),children:r.ok})]}),children:_n("div",{className:"space-y-3",children:[Qn(Gn,{label:r.paperSize,children:Qn(Vn,{value:l??"custom",onChange:e=>{"custom"!==e&&a(t=>J(t,e))},options:[...l?[]:[m],...Object.keys(N).map(e=>({value:e,label:c[e]}))]})}),Qn(Gn,{label:r.orientation,children:Qn(Vn,{value:i?"landscape":"portrait",onChange:e=>{"landscape"===e!==i&&a(e=>({...e,width:e.height,height:e.width}))},options:[{value:"portrait",label:r.portrait},{value:"landscape",label:r.landscape}]})}),Qn(Gn,{label:r.margins,children:Qn(Vn,{value:s??"custom",onChange:e=>{"custom"!==e&&a(t=>_(t,e))},options:[...s?[]:[m],...Object.keys(S).map(e=>({value:e,label:d[e]}))]})})]})})}var Yn=e=>e.querySelectorAll("ul,ol").forEach(e=>e.removeAttribute("data-ilvl"));function Zn(e){const t=e.previousElementSibling,n=e.parentElement;if(!t||"LI"!==t.tagName||!n)return!1;const r=t.lastElementChild;let o;var a;return a=r,"UL"===a?.tagName||"OL"===a?.tagName?o=r:(o=e.ownerDocument.createElement(n.tagName),t.appendChild(o)),o.appendChild(e),Yn(e),!0}function er(e){const t=e.parentElement,n=t?.parentElement;if(!t||"LI"!==n?.tagName)return!1;const r=[];for(let t=e.nextElementSibling;t;t=t.nextElementSibling)r.push(t);if(r.length){const n=e.ownerDocument.createElement(t.tagName),o=t.getAttribute("data-num-id");o&&n.setAttribute("data-num-id",o),r.forEach(e=>n.appendChild(e)),e.appendChild(n)}return n.parentElement.insertBefore(e,n.nextSibling),Yn(e),t.children.length||t.remove(),!0}var tr=e=>Array.from(e.querySelectorAll(":scope > tbody > tr, :scope > tr, :scope > thead > tr, :scope > tfoot > tr")),nr=(e,t)=>Math.max(1,Number(e.getAttribute(t)??1));function rr(e){const t=tr(e),n=t.map(()=>[]);return t.forEach((e,r)=>{let o=0;for(const a of(e=>Array.from(e.children).filter(e=>"TD"===e.tagName||"TH"===e.tagName))(e)){for(;n[r][o];)o++;const e=nr(a,"colspan"),i=nr(a,"rowspan");for(let l=r;l<Math.min(r+i,t.length);l++)for(let t=o;t<o+e;t++)n[l][t]=a;o+=e}}),{table:e,slots:n,cols:Math.max(0,...n.map(e=>e.length))}}function or(e,t){for(let n=0;n<e.slots.length;n++){const r=e.slots[n].indexOf(t);if(r>=0)return{row:n,col:r}}return null}function ar(e){const t=e.createElement("td");return t.innerHTML="<p><br></p>",t}function ir(e,t,n){const r=rr(e),o=or(r,t);if(!o)return;const a=tr(e),i=nr(t,"rowspan"),l=n?o.row+i:o.row,s=e.ownerDocument.createElement("tr"),c=new Set;for(let t=0;t<r.cols;t++){const n=l>0?r.slots[l-1]?.[t]:void 0,o=r.slots[l]?.[t];n&&n===o?c.has(n)||(c.add(n),n.setAttribute("rowspan",String(nr(n,"rowspan")+1))):s.appendChild(ar(e.ownerDocument))}const d=a[l];d?d.parentNode.insertBefore(s,d):a[a.length-1].parentNode.appendChild(s)}function lr(e,t,n){const r=rr(e),o=or(r,t);if(!o)return;const a=n?o.col+nr(t,"colspan"):o.col,i=new Set;r.slots.forEach((t,n)=>{const r=a>0?t[a-1]:void 0,o=t[a];if(r&&r===o)return void(i.has(r)||(i.add(r),r.setAttribute("colspan",String(nr(r,"colspan")+1))));if(o&&o.parentElement!==tr(e)[n])return;const l=tr(e)[n],s=t.slice(a).find(e=>e.parentElement===l);l.insertBefore(ar(e.ownerDocument),s??null)}),sr(e,r.cols+1,a,null)}function sr(e,t,n,r){const o=e.querySelector(":scope > colgroup");if(!o)return;const a=Array.from(o.children);if(null!==r&&a[r]?.remove(),null!==n){const t=e.ownerDocument.createElement("col"),r=a[Math.min(n,a.length-1)];r?.getAttribute("style")&&t.setAttribute("style",r.getAttribute("style")),o.insertBefore(t,a[n]??null)}o.children.length!==t&&o.remove()}import{Fragment as cr,jsx as dr,jsxs as ur}from"react/jsx-runtime";var mr=["Calibri","Arial","Cambria","Courier New","Georgia","Tahoma","Times New Roman","Verdana"],fr=[8,9,10,10.5,11,12,14,16,18,20,22,24,28,32,36,48,72],pr=[1,1.15,1.5,2,2.5,3],hr=/^[A-Za-z][A-Za-z0-9_]{0,39}$/,gr="data-docs-fonts",wr=["default","first","even"];function br(e){const t=[...new Set(e)].filter(e=>A.includes(e));if(!t.length||"undefined"==typeof document)return;const n=document.head.querySelector(`link[${gr}]`),r=n?.getAttribute(gr)?.split("|").filter(Boolean)??[],o=[...new Set([...r,...t])].sort();if(n&&o.length===r.length)return;const a=document.createElement("link");a.rel="stylesheet",a.href=Q(o),a.setAttribute(gr,o.join("|")),document.head.appendChild(a),n?.remove()}function yr(e,t,n){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.querySelectorAll('[data-field="page"]').forEach(e=>{e.textContent=String(t)}),r.querySelectorAll('[data-field="pages"]').forEach(e=>{e.textContent=String(n)}),r.innerHTML}var vr=e=>Math.round(.75*(parseFloat(e)||0)*100)/100,xr=[50,75,90,100,110,125,150,200],kr="p,h1,h2,h3,h4,h5,h6,li,blockquote,pre",Cr=/^(https?:|mailto:|tel:)/i,Sr={bold:!1,italic:!1,underline:!1,strike:!1,sub:!1,sup:!1,ul:!1,ol:!1,align:"left",font:"",size:null,styleId:null,color:""};function Nr({sessionKey:d,doc:m,filename:f,images:p,fileEntries:w,title:b,startsDirty:y,dirty:x,onDirty:k,onOpenFile:C,onNewImageUrl:S,onClose:N,stored:$,onReload:L}){const P=u(),T=Fe(),M=pe().replace(/[^a-zA-Z0-9]/g,""),R=ge(null),E=ge(null),z=ge(null),F=ge(new Fn),H=ge(null),D=ge(null),B=ge(null),U=ge(!!y),W=ge(0),q=ge(()=>{}),G=ge(null),Q=ge(0),_=ge($?.version??""),J=ge(null),[Y,Z]=we({page:m.page}),[ee,te]=we(()=>({headers:{default:m.headers.default.html,first:m.headers.first.html,even:m.headers.even.html},footers:{default:m.footers.default.html,first:m.footers.first.html,even:m.footers.even.html},titlePage:m.titlePage,evenOdd:m.evenOdd})),[ne,re]=we(!1),[oe,ae]=we(m.columns),[ie,le]=we(!1),se=ge(new Map),[ce,de]=we(""),[ue,Oe]=we(null),[je,He]=we(null),De=ge(null),Ie=ge(null),[Be,We]=we(!1),[qe,Ke]=we([]),[,Ge]=we(0),Ve=ge(null),[Xe,Qe]=we(null),[_e,Je]=we(Sr),[Ze,et]=we({undo:!1,redo:!1}),[tt,nt]=we({words:0,pageNow:1}),[rt,ot]=we([0]),[at,it]=we([]),[lt,st]=we(!1),[ct,dt]=we(100),[ut,mt]=we(!1),[ft,pt]=we(!0),[ht,gt]=we(!1),[wt,bt]=we({rows:0,cols:0}),[yt,vt]=we(null),[xt,kt]=we(null),[Ct,St]=we(!1),[Nt,$t]=we(""),[At,Lt]=we(""),[Pt,Tt]=we(!1),[Mt,Rt]=we(0),[Et,zt]=we(0),Ft=ge([]),Ot=(Y.page.width-Y.page.left-Y.page.right)/20,jt=e=>!!e&&!!E.current?.contains(e),Ht=me(()=>{const e=E.current,t=document.getSelection();if(!(e&&t?.anchorNode&&t.focusNode&&jt(t.anchorNode))){const t=H.current;if(!e||!t)return null;const n=On(e,t.startContainer,t.startOffset),r=On(e,t.endContainer,t.endOffset);return n&&r?{anchor:n,focus:r}:null}const n=On(e,t.anchorNode,t.anchorOffset),r=On(e,t.focusNode,t.focusOffset);return n&&r?{anchor:n,focus:r}:null},[]),Dt=me(e=>{const t=E.current,n=document.getSelection();if(!t||!n||!e)return;const r=jn(t,e.anchor),o=jn(t,e.focus);r&&o&&n.setBaseAndExtent(r.node,r.offset,o.node,o.offset)},[]),It=me(e=>{const t=E.current;if(!t)return;const n=document.getSelection(),r=!e&&!!n&&jt(n.anchorNode);if(document.activeElement!==t&&t.focus({preventScroll:!0}),r&&n?.rangeCount)return void(H.current=n.getRangeAt(0).cloneRange());const o=e??H.current;n&&o&&(n.removeAllRanges(),n.addRange(o),H.current=o.cloneRange())},[]),Bt=me(()=>{const e=E.current,t=H.current;if(!e||!t)return[];const n=Array.from(e.querySelectorAll(kr)).filter(e=>!e.closest("[data-locked]"));var r;return(t.collapsed?[(r=t.startContainer,(1===r.nodeType?r:r.parentElement)?.closest(kr))].filter(Boolean):n.filter(e=>t.intersectsNode(e))).filter(e=>jt(e)&&!e.closest("[data-locked]"))},[]),Ut=me(()=>{cancelAnimationFrame(W.current),W.current=requestAnimationFrame(()=>{const n=E.current;if(!n)return;const o=n.getBoundingClientRect().height/(n.offsetHeight||1)||1,i=n.getBoundingClientRect().top+Y.page.top/20*(4/3)*o,l=(Y.page.height-Y.page.top-Y.page.bottom)/20*(4/3),s=a(r(n,i,o),l);ot(e=>e.length===s.length&&e.every((e,t)=>e===s[t])?e:s);const c=document.getSelection();let d=1;if(c?.rangeCount&&jt(c.anchorNode)){const e=c.getRangeAt(0).getClientRects()[0]??c.anchorNode?.getBoundingClientRect?.();if(e){const t=(e.top-i)/o;for(let e=0;e<s.length;e++)s[e]<=t+1&&(d=e+1)}}nt({words:e(t(n)),pageNow:d});const u=[...new Set(Array.from(n.querySelectorAll("[data-note]")).map(e=>e.getAttribute("data-note")))];Ke(e=>e.length===u.length&&e.every((e,t)=>e===u[t])?e:u),le(!!n.querySelector(":scope > [data-section]"));const m=function(e){return Hn(e).map(e=>({level:Number(e.tagName[1]),text:(e.textContent??"").trim().replace(/\s+/g," ")}))}(n);it(e=>{return n=m,(t=e).length===n.length&&t.every((e,t)=>e.level===n[t].level&&e.text===n[t].text)?e:m;var t,n})})},[Y.page]),Wt=me(()=>{const e=document.getSelection();if(!e?.anchorNode||!jt(e.anchorNode))return;const t=1===e.anchorNode.nodeType?e.anchorNode:e.anchorNode.parentElement;if(!t)return;const n=getComputedStyle(t),r=t.closest(kr),o=e=>{try{return document.queryCommandState(e)}catch{return!1}},a=n.textAlign,i=.75*parseFloat(n.fontSize);if(Je({bold:o("bold"),italic:o("italic"),underline:o("underline"),strike:o("strikeThrough"),sub:o("subscript"),sup:o("superscript"),ul:o("insertUnorderedList"),ol:o("insertOrderedList"),align:"center"===a||"right"===a||"justify"===a?a:"left",font:n.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:i?Math.round(2*i)/2:null,styleId:r?.getAttribute("data-pstyle")??null,color:Un(n.color)}),r&&!r.closest("[data-locked]")){const e=getComputedStyle(r),t="LI"===r.tagName;He({indentLeft:t?0:vr(e.marginLeft),indentRight:vr(e.marginRight),firstLine:t?0:vr(e.textIndent),tabs:I(r.getAttribute("data-tabs"))})}else He(null)},[]),qt=async()=>{const e=G.current;if(!e)throw new Error("No page");if(!U.current&&Y.page===m.page&&m.source)return m.source;const t=Q.current,n=await Kt(m,e,{page:Y.page,headers:ee.headers,footers:ee.footers,titlePage:ee.titlePage,evenOdd:ee.evenOdd,columns:oe,styleEdits:se.current,images:p});return U.current&&Q.current===t&&(m.source=n,U.current=!1,Z(e=>({...e,page:m.page}))),n},Gt=ve(),Vt=ye({debounceMs:1500,maxWaitMs:4e3,save:async()=>{$&&(_.current=await $.store.save($.id,await qt(),_.current))},onFailure:(e,t)=>{e instanceof c?(Vt.stop(),st(!0)):0===t&&ze.error(P.saveFailed)}}),{push:Xt,flush:Qt}=Vt,_t=!!$,Jt=Vt.state.pending;fe(()=>{_t&&k(Jt||lt)},[lt,_t,k,Jt]),fe(()=>()=>{Qt()},[Qt]);const Yt=me(()=>{U.current=!0,Q.current+=1,k(!0),_t&&Xt(Q.current),Ut(),et({undo:F.current.canUndo,redo:F.current.canRedo})},[_t,Ut,k,Xt]),Zt=me(()=>({html:E.current?.innerHTML??"",caret:Ht()}),[Ht]),en=()=>{D.current&&clearTimeout(D.current),D.current=null},tn=me(e=>{e&&E.current&&(E.current.innerHTML=e.html,E.current.focus({preventScroll:!0}),Dt(e.caret),en(),Yt(),Wt())},[Dt,Yt,Wt]),nn=me(()=>tn(F.current.undo(Zt())),[tn,Zt]),on=me(()=>tn(F.current.redo(Zt())),[tn,Zt]),an=me(e=>{It(),en(),F.current.record(Zt()),e(),Yt(),Wt()},[Yt,Wt,It,Zt]),ln=me((e,t)=>an(()=>{document.execCommand(e,!1,t)}),[an]),sn=e=>an(()=>{document.execCommand(e);const t=E.current;if(!t)return;const n=document.getSelection(),r=n?.anchorNode??null,o=n?.anchorOffset??0;let a=!1;t.querySelectorAll("p > ul, p > ol").forEach(e=>{const t=e.parentElement;Array.from(t.childNodes).some(t=>t!==e&&(1===t.nodeType||(t.nodeValue??"").trim()))||(t.replaceWith(e),a=!0)}),a&&r&&n?.collapse(r,o)});fe(()=>{const e=E.current;if(!e)return;G.current=e,e.innerHTML=m.html,br(A.filter(e=>m.html.includes(e)||m.css.includes(e)||m.defaultFont===e));try{document.execCommand("defaultParagraphSeparator",!1,"p"),document.execCommand("styleWithCSS",!1,"true")}catch{}e.focus({preventScroll:!0});const t=e.querySelector(kr);t&&document.getSelection()?.collapse(t,0),Ut();const n=t=>"historyUndo"===t.inputType?(t.preventDefault(),void nn()):"historyRedo"===t.inputType?(t.preventDefault(),void on()):(D.current?clearTimeout(D.current):F.current.record({html:e.innerHTML,caret:Ht()}),void(D.current=setTimeout(()=>{D.current=null},600))),r=()=>{(()=>{const t=B.current;e.querySelectorAll('font[size="7"]').forEach(e=>{const n=document.createElement("span");for(n.setAttribute("style",`font-size:${t??11}pt`);e.firstChild;)n.appendChild(e.firstChild);e.replaceWith(n),3===n.lastChild?.nodeType&&document.getSelection()?.collapse(n.lastChild,(n.lastChild.nodeValue??"").length)})})(),Yt(),Wt()},o=()=>{const e=document.getSelection();e?.rangeCount&&jt(e.anchorNode)&&(H.current=e.getRangeAt(0).cloneRange(),Wt(),Ut())};e.addEventListener("beforeinput",n),e.addEventListener("input",r),document.addEventListener("selectionchange",o);const a=new ResizeObserver(()=>Ut());return a.observe(e),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",r),document.removeEventListener("selectionchange",o),a.disconnect(),cancelAnimationFrame(W.current),en(),J.current&&clearTimeout(J.current)}},[]),fe(()=>{Ut()},[Ut]),fe(()=>{const e=Ve.current;e&&qe.includes(e)&&(Ve.current=null,R.current?.querySelector(`input[data-note-input="${e}"]`)?.focus())},[qe]),fe(()=>{y&&k(!0)},[]);const cn=e=>an(()=>{const t=Ht(),n=e?/^heading ([1-6])$/i.exec(m.styles.find(t=>t.id===e)?.name??"")?.[1]:void 0,r=n?`H${n}`:"P";for(const t of Bt()){if("LI"===t.tagName){e?t.setAttribute("data-pstyle",e):t.removeAttribute("data-pstyle");continue}let n=t;if(t.tagName!==r){n=document.createElement(r);for(const e of Array.from(t.attributes))n.setAttribute(e.name,e.value);for(;t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n)}e?n.setAttribute("data-pstyle",e):n.removeAttribute("data-pstyle")}Dt(t)}),dn=(e,t)=>an(()=>{for(const n of Bt())n.style["before"===e?"marginTop":"marginBottom"]=t?"10pt":"0pt"}),un=()=>{const e=Bt()[0];if(!e)return{};const t=getComputedStyle(e),n=parseFloat(t.fontSize)||14.67,r=parseFloat(t.lineHeight);return{before:vr(t.marginTop),after:vr(t.marginBottom),lineMultiple:Number.isFinite(r)?Math.round(r/n*100)/100:1.15,indentLeft:"LI"===e.tagName?void 0:vr(t.marginLeft),indentRight:vr(t.marginRight),firstLine:"LI"===e.tagName?void 0:vr(t.textIndent)}},mn=()=>{const e=Ie.current,t=document.getSelection();e&&t&&!t.isCollapsed&&jt(t.anchorNode)&&(Ie.current=null,We(!1),H.current=t.getRangeAt(0).cloneRange(),an(()=>{const t=(e,t)=>{!!t!==(e=>{try{return document.queryCommandState(e)}catch{return!1}})(e)&&document.execCommand(e)};t("bold",e.run.b),t("italic",e.run.i),t("underline",e.run.u),t("strikeThrough",e.run.strike),e.run.font&&document.execCommand("fontName",!1,e.run.font),e.run.color&&document.execCommand("foreColor",!1,e.run.color),document.execCommand("hiliteColor",!1,e.run.hl||"transparent"),e.run.size&&(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7"),document.execCommand("styleWithCSS",!1,"true"),E.current?.querySelectorAll('font[size="7"]').forEach(t=>{const n=document.createElement("span");for(n.setAttribute("style",`font-size:${e.run.size}pt`);t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n)}));for(const t of Bt())"LI"!==t.tagName&&(e.styleId?t.setAttribute("data-pstyle",e.styleId):t.removeAttribute("data-pstyle"))}))},fn=e=>{br([e]),ln("fontName",e)},pn=e=>an(()=>{const t=E.current,n=Bt()[0];if(!t||!n)return;const r=Array.from(t.children).find(e=>e.contains(n));if(!r)return;r.setAttribute("data-section",e);const o=document.createElement("p");o.innerHTML="<br>",r.after(o),document.getSelection()?.collapse(o,0)}),hn=e=>{let t=e.getAttribute("data-bm");return t||(t=`_Toc${Math.floor(1e8+899999999*Math.random())}`,e.setAttribute("data-bm",t)),t},wn=()=>{const e=E.current;if(!e)return"";const t=e.getBoundingClientRect().height/(e.offsetHeight||1)||1,n=e.getBoundingClientRect().top+Y.page.top/20*(4/3)*t;return Hn(e).filter(e=>Number(e.tagName[1])<=3&&!e.closest("[data-toc]")).map(e=>{const r=(e.getBoundingClientRect().top-n)/t;let o=1;for(let e=0;e<rt.length;e++)rt[e]<=r+1&&(o=e+1);return v(Number(e.tagName[1]),hn(e),(e.textContent??"").trim(),String(o))}).join("")},bn=()=>{const e=[...m.footnotes.keys(),...qe].map(Number).filter(Number.isFinite),t=String(Math.max(0,...e)+1);m.footnotes.set(t,{text:"",editable:!0}),Ve.current=t,ln("insertHTML",`<span data-kind="note" data-note="${t}" contenteditable="false"></span>`)},yn=()=>Array.from(E.current?.querySelectorAll("[data-bookmark]")??[]).map(e=>e.getAttribute("data-bookmark")),vn=(e,t)=>{It();const n=H.current;if(n&&!n.collapsed)ln("createLink",`#${e}`);else{const n=document.createElement("a");n.href=`#${e}`,n.textContent=t,ln("insertHTML",n.outerHTML)}},xn=e=>{const t=E.current;return t&&/^[A-Za-z0-9_]+$/.test(e)?t.querySelector(`[data-bm="${e}"],[data-bookmark="${e}"],[data-toc-anchor="${e}"]`):null},kn=e=>an(()=>{const t=Bt(),n=t.filter(e=>"LI"===e.tagName);if(n.length){const t=document.getSelection(),r=t?.anchorNode??null,o=t?.anchorOffset??0;for(const t of e?n:[...n].reverse())e?Zn(t):er(t);return void(r&&t?.collapse(r,o))}for(const n of t){const t=parseFloat(n.style.marginLeft)||0,r=Math.max(0,t+(e?36:-36));n.style.marginLeft=r?`${r}pt`:""}}),Nn=e=>ln({left:"justifyLeft",center:"justifyCenter",right:"justifyRight",justify:"justifyFull"}[e]),$n=async e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new Uint8Array(await t.arrayBuffer()),n=URL.createObjectURL(new Blob([e],{type:t.type}));S(n),p.set(n,{bytes:e,mime:t.type});const r=new Image;r.src=n,await r.decode().catch(()=>{});const o=.75*r.naturalWidth,a=Math.min(o||Ot,Ot),i=o?a*(r.naturalHeight/r.naturalWidth):0;ln("insertHTML",`<img src="${n}" alt="" style="width:${Math.round(100*a)/100}pt${i?`;height:${Math.round(100*i)/100}pt`:""}">`)}},An=async()=>{It();const e=H.current?.cloneRange()??null,t=e?.startContainer?1===e.startContainer.nodeType?e.startContainer:e.startContainer.parentElement:null,n=t?.closest("a")??null,r=await Re({title:P.link,message:P.linkPrompt,placeholder:"https://example.com",defaultValue:n?.getAttribute("href")??"",confirmLabel:P.ok,cancelLabel:P.cancel,allowEmpty:!0});if(await new Promise(e=>setTimeout(e,0)),It(e),null===r)return;const o=r.trim();if(!o)return void(n&&ln("unlink"));const a=/^[a-z][a-z0-9+.-]*:/i.test(o)?o:`https://${o}`;if(Cr.test(a))if(n)an(()=>{n.setAttribute("href",a)});else if(e?.collapsed){const e=document.createElement("a");e.href=a,e.textContent=o,ln("insertHTML",e.outerHTML)}else ln("createLink",a);else ze.error(P.linkInvalid)},Ln=()=>ln("insertHTML",'<span data-page-break="" contenteditable="false"></span>'),Pn=(e,t)=>{gt(!1);const n=function(e,t,n,r){const o=e.createElement("table"),a=e.createElement("colgroup");for(let t=0;t<n;t++){const t=e.createElement("col");t.setAttribute("style",`width:${Math.round(r/n*100)/100}pt`),a.appendChild(t)}o.appendChild(a);const i=e.createElement("tbody");for(let r=0;r<t;r++){const t=e.createElement("tr");for(let r=0;r<n;r++)t.appendChild(ar(e));i.appendChild(t)}return o.appendChild(i),o}(document,e,t,Ot);n.setAttribute("data-new",""),ln("insertHTML",`${n.outerHTML}<p><br></p>`);const r=E.current?.querySelector("table[data-new]");if(r){r.removeAttribute("data-new");const e=r.querySelector("td p");e&&document.getSelection()?.collapse(e,0)}};q.current=e=>{$n(e)};const Tn=e=>{if(!yt)return;const t=yt.el;an(()=>{const n=.75*t.naturalWidth,r=null===e?n:Ot*e,o=t.naturalWidth?t.naturalHeight/t.naturalWidth:.75;t.removeAttribute("width"),t.removeAttribute("height"),t.style.width=Math.round(100*r)/100+"pt",t.style.height=Math.round(r*o*100)/100+"pt"}),vt(null)},Mn=me((e,t)=>{const n=Ft.current,r=e=>{const t=document.createRange();return t.setStart(e[0].node,e[0].start),t.setEnd(e[e.length-1].node,e[e.length-1].end),t},o=globalThis.CSS?.highlights,a=globalThis.Highlight;o&&a&&(o.set("docs-find",new a(...n.map(r))),o.set("docs-find-current",new a(...n[e]?[r(n[e])]:[]))),t&&n[e]&&n[e][0].node.parentElement?.scrollIntoView({block:"center"})},[]),Rn=()=>{const e=globalThis.CSS?.highlights;e?.delete("docs-find"),e?.delete("docs-find-current")},En=me((e,t,r)=>{const o=E.current,a=o?n(o,e,t):[];Ft.current=a,zt(a.length);const i=a.length?Math.min(r,a.length-1):0;Rt(i),Mn(i,!0)},[Mn]),Wn=me(()=>{const e=Ft.current[Mt];St(!1),Rn();const t=E.current;t?.focus({preventScroll:!0}),e&&document.getSelection()?.setBaseAndExtent(e[0].node,e[0].start,e[e.length-1].node,e[e.length-1].end),Ft.current=[]},[Mt]),qn=()=>{const e=document.getSelection(),t=e&&jt(e.anchorNode)?e.toString():"";St(!0);const n=t&&!t.includes("\n")?t:Nt;$t(n),setTimeout(()=>En(n,Pt,0),0)},Kn=ge(Wn);Kn.current=Wn;const Gn=ge(Ct);Gn.current=Ct,fe(()=>Ee(()=>!(!Gn.current||!R.current?.contains(document.activeElement))&&(Kn.current(),!0)),[]),fe(()=>()=>Rn(),[]),fe(()=>{const e=e=>{const{key:t,files:n}=e.detail;t===d&&q.current(n)};return window.addEventListener("docs-insert-images",e),()=>window.removeEventListener("docs-insert-images",e)},[d]);const Vn=$?f:(e=>e.replace(/\.[^.]+$/,"")||e)(f),Xn=`${Vn}.docx`,Qn=async()=>{try{const e=Q.current;Sn(await qt(),Xn,"application/vnd.openxmlformats-officedocument.wordprocessingml.document"),$||Q.current!==e||k(!1)}catch{ze.error(P.saveFailed)}},_n=e=>o({title:Vn,html:e,doc:{css:`${m.css}\n${ce}`},scope:M,page:Y.page,header:g(ee.headers.default),footer:g(ee.footers.default)}),Yn=()=>{const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;width:0;height:0;border:0;left:-10px;top:-10px",document.body.appendChild(e);const t=e.contentWindow;if(!t)return void e.remove();t.document.open(),t.document.write(_n(E.current?.innerHTML??"")),t.document.close();const n=()=>{t.focus(),t.print(),setTimeout(()=>e.remove(),6e4)},r=Array.from(t.document.images).filter(e=>!e.complete);r.length?Promise.all(r.map(e=>e.decode().catch(()=>{}))).then(n):n()},gr=w.length?[...w,{type:"divider",key:"d1"},{key:"save",label:dr($r,{label:P.saveDocx,hint:"⌘S"}),onSelect:()=>{Qn()}}]:[],Nr=[{key:"docx",label:P.saveAsWord,onSelect:()=>{Qn()}},{key:"pdf",label:P.saveAsPdf,onSelect:Yn},{key:"html",label:P.saveAsWeb,onSelect:()=>{(async()=>{const e=document.createElement("div");e.innerHTML=E.current?.innerHTML??"";for(const t of Array.from(e.querySelectorAll("img"))){const e=p.get(t.getAttribute("src")??"");if(!e)continue;let n="";for(let t=0;t<e.bytes.length;t+=32768)n+=String.fromCharCode(...e.bytes.subarray(t,t+32768));t.setAttribute("src",`data:${e.mime};base64,${btoa(n)}`)}e.querySelectorAll("[data-hidden]").forEach(e=>e.remove()),Sn(_n(e.innerHTML),`${Vn}.html`,"text/html")})()}},{key:"txt",label:P.saveAsText,onSelect:()=>{Sn(t(E.current),`${Vn}.txt`,"text/plain")}}],Ar=E.current?yn():[],Lr=[{key:"table",label:P.table,onSelect:()=>gt(!0)},{key:"image",label:P.image,onSelect:()=>z.current?.click()},{key:"link",label:dr($r,{label:P.link,hint:"⌘K"}),onSelect:()=>{An()}},{type:"submenu",key:"linkHeading",label:P.linkToHeading,items:at.length?at.map((e,t)=>({key:`h${t}`,label:dr("span",{style:{paddingLeft:8*(e.level-1)},children:e.text}),onSelect:()=>(e=>{const t=E.current,n=t?Hn(t)[e]:void 0;if(!n)return;It();const r=H.current?.cloneRange()??null;F.current.record(Zt());const o=hn(n);It(r),vn(o,(n.textContent??"").trim())})(t)})):[{type:"label",key:"none",label:P.noHeadings}]},{type:"submenu",key:"linkBookmark",label:P.linkToBookmark,items:Ar.length?Ar.map(e=>({key:e,label:e,onSelect:()=>vn(e,e)})):[{type:"label",key:"none",label:P.noBookmarks}]},{type:"divider",key:"d1"},{key:"toc",label:P.tableOfContents,onSelect:()=>{It();const e=wn();ln("insertHTML",`<div data-toc="" contenteditable="false">${e}</div><p><br></p>`)}},{key:"footnote",label:dr($r,{label:P.footnote,hint:"⌘⌥F"}),onSelect:bn},{key:"bookmark",label:P.bookmark,onSelect:()=>{(async()=>{It();const e=H.current?.cloneRange()??null,t=await Re({title:P.bookmark,message:P.bookmarkPrompt,placeholder:"Clause_4",confirmLabel:P.ok,cancelLabel:P.cancel});if(await new Promise(e=>setTimeout(e,0)),It(e),null===t)return;const n=t.trim();hr.test(n)?yn().includes(n)?ze.error(P.bookmarkTaken):ln("insertHTML",`<span data-kind="mark" data-bookmark="${n}" contenteditable="false"></span>`):ze.error(P.bookmarkInvalid)})()}},{type:"submenu",key:"breaks",label:P.breakMenu,items:[{key:"page",label:dr($r,{label:P.pageBreak,hint:"⌘↵"}),onSelect:Ln},{key:"next",label:P.sectionBreakNext,onSelect:()=>pn("nextPage")},{key:"cont",label:P.sectionBreakContinuous,onSelect:()=>pn("continuous")}]},{key:"number",label:P.pageNumber,onSelect:()=>re(!0)},{key:"line",label:P.horizontalLine,onSelect:()=>ln("insertHorizontalRule")}],Pr=(()=>{const e=E.current,t=H.current?1===H.current.startContainer.nodeType?H.current.startContainer:H.current.startContainer.parentElement:null;return e&&t?Array.from(e.children).find(e=>e.contains(t))??null:null})(),Tr=[{key:"setup",label:P.pageSetup,onSelect:()=>mt(!0)},{key:"hf",label:P.headersFooters,onSelect:()=>re(!0)},{type:"submenu",key:"cols",label:P.columns,items:[1,2,3].map(e=>({key:String(e),label:P.columnsCount(e),onSelect:()=>(e=>{const t=E.current,n=Bt()[0];if(!t)return;let r=n?Array.from(t.children).find(e=>e.contains(n))??null:null;for(;r&&!r.hasAttribute("data-section");)r=r.nextElementSibling;r?an(()=>{e>1?r.setAttribute("data-cols",String(e)):r.removeAttribute("data-cols")}):(ae(e),Yt())})(e)}))},...Pr?.hasAttribute("data-section")?[{key:"unsection",label:P.removeSectionBreak,onSelect:()=>{return e=Pr,an(()=>{e.removeAttribute("data-section"),e.removeAttribute("data-cols")});var e}}]:[]],Mr={Title:P.styleTitle,"heading 1":P.styleHeading1,"heading 2":P.styleHeading2,"heading 3":P.styleHeading3,"heading 4":P.styleHeading4,"heading 5":P.styleHeading5,"heading 6":P.styleHeading6,Quote:P.styleQuote},Rr=[{key:"normal",label:P.styleNormal,onSelect:()=>cn(null)},...m.styles.map(e=>{const t=Mr[e.name]??e.name;return{type:"submenu",key:e.id,label:t,items:[{key:"apply",label:P.applyStyle(t),onSelect:()=>cn(e.id)},{key:"update",label:P.updateStyle(t),onSelect:()=>((e,t)=>an(()=>{const n=Bt()[0];if(!n)return;const r=Array.from(n.querySelectorAll("*")).find(e=>(e.textContent??"").trim()&&!e.querySelector("*"))??n,o=getComputedStyle(r),a=getComputedStyle(n),i=parseFloat(o.fontSize)||14.67,l=parseFloat(a.lineHeight),s={b:Number(o.fontWeight)>=600,i:"italic"===o.fontStyle,u:/underline/.test(o.textDecorationLine),strike:/line-through/.test(o.textDecorationLine),font:o.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:Math.round(.75*i*2)/2,color:Un(o.color)||void 0},c=a.textAlign,d={align:"center"===c||"right"===c||"justify"===c?c:"left",before:vr(a.marginTop),after:vr(a.marginBottom),...Number.isFinite(l)?{lineMultiple:Math.round(l/(parseFloat(a.fontSize)||i)*100)/100}:{}};se.current.set(e,{run:s,para:d});const u=n.style.tabSize;n.removeAttribute("style"),u&&(n.style.tabSize=u),n.querySelectorAll("[style]").forEach(e=>{for(const t of["font-family","font-size","font-weight","font-style","color","text-decoration","text-decoration-line"])e.style.removeProperty(t)}),de([...se.current].map(([e,t])=>`.docs-page [data-pstyle="${e.replace(/["\\]/g,"")}"]{${[K(t.run),j(t.para)].filter(Boolean).join(";")}}`).join("\n")),br(s.font?[s.font]:[]),ze.success(P.styleUpdated(t))}))(e.id,t)}]}})],Er=he(()=>Array.from(new Set([...m.defaultFont?[m.defaultFont]:[],...mr])),[m.defaultFont]),zr=[{type:"label",key:"word",label:P.wordFonts},...Er.map(e=>({key:e,label:dr("span",{style:{fontFamily:`"${e}"`},children:e}),onSelect:()=>fn(e)})),{type:"label",key:"web",label:P.webFonts},...A.filter(e=>!Er.includes(e)).map(e=>({key:e,label:dr("span",{style:{fontFamily:`"${e}"`},children:e}),onSelect:()=>fn(e)}))],Fr=fr.map(e=>({key:String(e),label:String(e),onSelect:()=>(e=>an(()=>{B.current=e,document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7"),document.execCommand("styleWithCSS",!1,"true");const t=E.current,n=[];if(t.querySelectorAll('font[size="7"]').forEach(t=>{const r=document.createElement("span");for(r.setAttribute("style",`font-size:${e}pt`);t.firstChild;)r.appendChild(t.firstChild);t.replaceWith(r),n.push(r)}),n.length){const e=document.getSelection();e?.setBaseAndExtent(n[0],0,n[n.length-1],n[n.length-1].childNodes.length)}}))(e)})),Or=E.current&&H.current?un():{},jr=[...pr.map(e=>({key:String(e),label:e.toFixed(1.15===e?2:1),onSelect:()=>{return t=e,an(()=>{for(const e of Bt())e.style.lineHeight=String(t)});var t}})),{type:"divider",key:"d1"},(Or.before??0)>0?{key:"before",label:P.removeSpaceBefore,onSelect:()=>dn("before",!1)}:{key:"before",label:P.addSpaceBefore,onSelect:()=>dn("before",!0)},(Or.after??0)>0?{key:"after",label:P.removeSpaceAfter,onSelect:()=>dn("after",!1)}:{key:"after",label:P.addSpaceAfter,onSelect:()=>dn("after",!0)},{type:"divider",key:"d2"},{key:"custom",label:P.customSpacing,onSelect:()=>{It(),Oe(un())}}],Hr=e=>e.preventDefault(),Dr="rounded px-2 py-0.5 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",Ir="inline-flex h-7 items-center gap-1 rounded px-2 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",Br=dr("div",{className:"mx-1 h-4 w-px bg-line"}),Ur=(e,t,n,r={})=>dr($e,{"aria-label":e,title:e,size:"sm",variant:"ghost",onMouseDown:Hr,onClick:n,disabled:r.disabled,...void 0!==r.pressed?{"aria-pressed":r.pressed}:{},children:t}),Wr=(e,t,n,r="")=>dr(Ne,{"aria-label":e,align:"start",items:n,triggerClassName:Ir,trigger:ur("span",{title:e,className:`flex items-center justify-between gap-1 ${r}`,children:[dr("span",{className:"truncate",children:t}),dr(xe,{name:"chevron-down",size:12})]})}),qr=(e,t,n,r,o)=>dr(Ae,{triggerLabel:e,align:"start",triggerClassName:"inline-flex h-7 w-7 flex-col items-center justify-center rounded text-ink-muted hover:bg-line-subtle hover:text-ink",trigger:ur(cr,{children:[t,dr("span",{className:"h-0.5 w-4 rounded-sm",style:{background:n}})]}),children:({close:t})=>dr(Ce,{label:e,value:"",presets:r,clearable:!0,dragWrites:"end",onChange:e=>{"hiliteColor"===o?ln("hiliteColor",e||"transparent"):ln("foreColor",e||Dn[0]),Gr(t=>({...t,[o]:e||("hiliteColor"===o?"var(--line)":"var(--ink)")})),t()}})}),[Kr,Gr]=we({foreColor:"var(--ink)",hiliteColor:"var(--line)"}),Vr=O(Y.page),Xr=Vr?{a4:"A4",a3:"A3",a5:"A5",letter:P.paperLetter,legal:P.paperLegal}[Vr]:P.custom,Qr=he(()=>{if(!m.lang)return"";try{return new Intl.DisplayNames(T?[T]:void 0,{type:"language"}).of(m.lang)??m.lang}catch{return m.lang}},[m.lang,T]),_r=Y.page.width/20,Jr=Y.page.top/20,Yr=rt.length,Zr=ee.headers[h(1,ee.titlePage,ee.evenOdd)],eo=ee.footers[h(Yr,ee.titlePage,ee.evenOdd)],to=[`.docs-page [data-section="nextPage"]::after{content:${JSON.stringify(P.sectionBreakNext)}}`,`.docs-page [data-section="continuous"]::after{content:${JSON.stringify(P.sectionBreakContinuous)}}`,...[2,3].map(e=>`.docs-page [data-section][data-cols="${e}"]::after{content:${JSON.stringify(`${P.sectionBreakNext} · ${P.columnsCount(e)}`)}}`),`.docs-page [data-section="continuous"][data-cols]::after{content:${JSON.stringify(P.sectionBreakContinuous)}}`,`.docs-page [data-toc]:empty::before{content:${JSON.stringify(P.noHeadings)}}`,ce].join("\n").replaceAll(".docs-page",`.docs-page[data-doc="${M}"]`),no=m.notices,ro=[no.comments&&P.noticeComments(no.comments),no.tracked&&P.noticeTracked(no.tracked),no.objects&&P.noticeObjects(no.objects),no.footnotes&&P.noticeFootnotes(no.footnotes)].filter(Boolean);return ur("div",{ref:R,className:"es-editor docs-frame",onKeyDown:e=>{const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),r=jt(e.target),o=()=>{e.preventDefault(),e.stopPropagation()};if(t&&!e.altKey){if("s"===n)return o(),void($?Qt():Qn());if("o"===n)return o(),void C();if("p"===n)return o(),void Yn();if("f"===n)return o(),void qn();if("k"===n)return o(),void An()}if(t&&e.altKey&&("f"===n||"KeyF"===e.code)&&r)return o(),void bn();if(t&&!e.altKey&&r){if("z"===n&&!e.shiftKey)return o(),void nn();if("z"===n&&e.shiftKey||"y"===n)return o(),void on();if("b"===n)return o(),void ln("bold");if("i"===n)return o(),void ln("italic");if("u"===n)return o(),void ln("underline");if("Enter"===e.key)return o(),void Ln()}if(r&&"Tab"===e.key&&!t&&!e.altKey){const t=document.getSelection(),n=t?.anchorNode?1===t.anchorNode.nodeType?t.anchorNode:t.anchorNode.parentElement:null,r=n?.closest("td,th");if(r)return o(),void((e,t)=>{const n=Array.from(e.closest("table").querySelectorAll("td,th")),r=n[n.indexOf(e)+(t?1:-1)];if(r){const e=document.createRange();e.selectNodeContents(r);const t=document.getSelection();t?.removeAllRanges(),t?.addRange(e)}else t&&an(()=>ir(e.closest("table"),e,!0))})(r,!e.shiftKey);if(n?.closest("li"))return o(),void kn(!e.shiftKey);if(!e.shiftKey)return o(),void ln("insertText","\t")}},children:[ur("style",{children:[i(m,M),to]}),dr("input",{ref:z,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&$n(Array.from(e.target.files)),e.target.value=""}}),dr(Ye,{onClose:N,fileMenu:gr,name:b,saveState:$?be(Vt.state,Gt.save):{tone:x?"off-unsaved":"off",label:x?P.noStoreEdited:P.noStoreClean},canUndo:Ze.undo,canRedo:Ze.redo,onUndo:nn,onRedo:on,exportControl:dr(Ne,{"aria-label":P.export,align:"end",items:Nr,triggerClassName:"docs-export-trigger",trigger:ur(cr,{children:[dr(xe,{name:"download",size:16}),P.export]})})}),lt&&ur("div",{className:"docs-conflict",role:"alert",children:[dr("span",{children:P.conflict}),dr(ke,{variant:"secondary",onClick:L,children:P.reload})]}),ur("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[dr(Ne,{trigger:P.menuInsert,items:Lr,align:"start",triggerClassName:Dr}),dr(Ae,{open:ht,onOpenChange:gt,align:"start",triggerLabel:P.table,triggerClassName:"h-5 w-0 overflow-hidden",trigger:dr("span",{}),children:ur("div",{className:"p-1",children:[dr("div",{className:"mb-1 text-xs text-ink-muted",children:wt.rows?P.tableSize(wt.cols,wt.rows):P.table}),dr("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(8, 1fr)"},onMouseLeave:()=>bt({rows:0,cols:0}),children:Array.from({length:48},(e,t)=>{const n=Math.floor(t/8)+1,r=t%8+1,o=n<=wt.rows&&r<=wt.cols;return dr("button",{type:"button","aria-label":P.tableSize(r,n),onMouseEnter:()=>bt({rows:n,cols:r}),onFocus:()=>bt({rows:n,cols:r}),onClick:()=>Pn(n,r),className:"h-4 w-4 rounded-sm border "+(o?"border-accent-fill bg-accent-tint-strong":"border-line bg-surface")},t)})})]})}),dr(Ne,{trigger:P.menuLayout,items:Tr,align:"start",triggerClassName:Dr}),Br,Ur(P.print,dr(xe,{name:"print",size:16}),Yn),Ur(P.find,dr(xe,{name:"search",size:16}),()=>Ct?Wn():qn(),{pressed:Ct}),Br,Wr(P.paragraphStyle,(e=>{if(!e)return P.styleNormal;const t=m.styles.find(t=>t.id===e);return t?Mr[t.name]??t.name:e})(_e.styleId),Rr,"w-20"),Wr(P.font,_e.font||m.defaultFont||"Calibri",zr,"w-20"),Wr(P.fontSize,_e.size??m.defaultSize??11,Fr),Br,Ur(P.bold,dr(xe,{name:"bold",size:16}),()=>ln("bold"),{pressed:_e.bold}),Ur(P.italic,dr(xe,{name:"italic",size:16}),()=>ln("italic"),{pressed:_e.italic}),Ur(P.underline,dr(xe,{name:"underline",size:16}),()=>ln("underline"),{pressed:_e.underline}),Ur(P.strikethrough,dr(xe,{name:"strike",size:16}),()=>ln("strikeThrough"),{pressed:_e.strike}),Ur(P.superscript,dr(xe,{name:"superscript",size:16}),()=>ln("superscript"),{pressed:_e.sup}),Ur(P.subscript,dr(xe,{name:"subscript",size:16}),()=>ln("subscript"),{pressed:_e.sub}),qr(P.textColor,dr(xe,{name:"text-color",size:14}),Kr.foreColor,Dn,"foreColor"),qr(P.highlight,dr(xe,{name:"palette",size:14}),Kr.hiliteColor,In,"hiliteColor"),Ur(P.paintFormat,dr(xe,{name:"paint-brush",size:16}),()=>{if(Ie.current)return Ie.current=null,void We(!1);It(),Ie.current=(()=>{const e=document.getSelection();if(!e?.anchorNode||!jt(e.anchorNode))return null;const t=1===e.anchorNode.nodeType?e.anchorNode:e.anchorNode.parentElement,n=getComputedStyle(t),r=t.closest(kr),o=e=>{try{return document.queryCommandState(e)}catch{return!1}};return{run:{b:o("bold"),i:o("italic"),u:o("underline"),strike:o("strikeThrough"),font:n.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:Math.round(.75*parseFloat(n.fontSize)*2)/2,color:Un(n.color),hl:Un(n.backgroundColor)||void 0},styleId:r?.getAttribute("data-pstyle")??null,tag:r?.tagName??"P"}})(),We(!!Ie.current),Ie.current&&ze.info(P.paintFormatHint)},{pressed:Be}),Ur(P.clearFormatting,dr(xe,{name:"clear-marks",size:16}),()=>an(()=>{document.execCommand("removeFormat");for(const e of Bt())e.style.removeProperty("text-align"),e.style.removeProperty("line-height"),e.style.removeProperty("margin-left")})),Br,Ur(P.bulletedList,dr(xe,{name:"list",size:16}),()=>sn("insertUnorderedList"),{pressed:_e.ul}),Ur(P.numberedList,dr(xe,{name:"numbered-list",size:16}),()=>sn("insertOrderedList"),{pressed:_e.ol}),Ur(P.checklist,dr(xe,{name:"checkbox",size:16}),()=>an(()=>{const e=E.current;if(!e)return;const t=Bt(),n=t.length>0&&t.every(e=>e.closest("ul[data-checklist]")),r=document.getSelection(),o=r?.anchorNode??null,a=r?.anchorOffset??0;if(n)document.execCommand("insertUnorderedList");else{const n=new Set(t.map(e=>e.closest("ul,ol")).filter(Boolean));n.size&&![...n].some(e=>"UL"!==e.tagName)||document.execCommand("insertUnorderedList");const r=(document.getSelection()?.anchorNode?.parentElement??o?.parentElement)?.closest("ul");e.querySelectorAll("p > ul").forEach(e=>{const t=e.parentElement;Array.from(t.childNodes).some(t=>t!==e&&(1===t.nodeType||(t.nodeValue??"").trim()))||t.replaceWith(e)});for(const e of[r,...n])e&&"UL"===e.tagName&&(e.setAttribute("data-checklist",""),e.removeAttribute("data-num-id"))}o&&o.isConnected&&r?.collapse(o,Math.min(a,3===o.nodeType?(o.nodeValue??"").length:o.childNodes.length))})),Ur(P.decreaseIndent,dr(xe,{name:"chevron-double-left",size:16}),()=>kn(!1)),Ur(P.increaseIndent,dr(xe,{name:"chevron-double-right",size:16}),()=>kn(!0)),Br,Ur(P.alignLeft,dr(xe,{name:"align-left",size:16}),()=>Nn("left"),{pressed:"left"===_e.align}),Ur(P.alignCenter,dr(xe,{name:"align-center",size:16}),()=>Nn("center"),{pressed:"center"===_e.align}),Ur(P.alignRight,dr(xe,{name:"align-right",size:16}),()=>Nn("right"),{pressed:"right"===_e.align}),Ur(P.justify,dr(xe,{name:"align-justify",size:16}),()=>Nn("justify"),{pressed:"justify"===_e.align}),dr(Ne,{"aria-label":P.paragraphSpacing,align:"start",items:jr,triggerClassName:Ir,trigger:ur("span",{title:P.paragraphSpacing,className:"flex items-center gap-0.5",children:[dr(xe,{name:"line-spacing",size:16}),dr(xe,{name:"chevron-down",size:12})]})})]}),ft&&ro.length>0&&ur("div",{role:"status",className:"flex shrink-0 items-center gap-2 border-b border-status-warning-line bg-status-warning-soft px-3 py-1 text-xs text-status-warning-soft-ink",children:[dr(xe,{name:"info",size:14}),dr("span",{className:"min-w-0 flex-1",children:P.noticeLead(ro)}),dr($e,{size:"sm",variant:"ghost",ink:"inherit","aria-label":P.dismiss,title:P.dismiss,onClick:()=>pt(!1),children:dr(xe,{name:"close",size:14})})]}),Ct&&dr(zn,{query:Nt,replacement:At,matchCase:Pt,current:Mt,total:Et,onQuery:e=>{$t(e),En(e,Pt,0)},onReplacement:Lt,onMatchCase:e=>{Tt(e),En(Nt,e,0)},onStep:e=>{const t=Ft.current.length;if(!t)return;const n=(Mt+(e?1:-1)+t)%t;Rt(n),Mn(n,!0)},onReplace:()=>{const e=Ft.current[Mt];e&&(F.current.record(Zt()),l(e,At),Yt(),En(Nt,Pt,Mt))},onReplaceAll:()=>{const e=Ft.current;if(e.length){F.current.record(Zt());for(let t=e.length-1;t>=0;t--)l(e[t],At);Yt(),ze.success(P.replacedCount(e.length)),En(Nt,Pt,0)}},onClose:Wn}),ur("div",{className:"docs-body",children:[ur("div",{className:"docs-centre",children:[ur("div",{className:"min-h-0 flex-1 overflow-auto bg-surface-sunken px-6 pb-6",children:[dr("div",{className:"docs-ruler-row",children:dr(Cn,{pageWidth:_r,marginLeft:Y.page.left/20,marginRight:Y.page.right/20,zoom:ct,value:je,onChange:e=>{He(e),It(),De.current?clearTimeout(De.current):F.current.record(Zt()),De.current=setTimeout(()=>{De.current=null},500);for(const t of Bt()){"LI"!==t.tagName&&(t.style.marginLeft=e.indentLeft?`${e.indentLeft}pt`:"",t.style.textIndent=e.firstLine?`${e.firstLine}pt`:""),t.style.marginRight=e.indentRight?`${e.indentRight}pt`:"",e.tabs.length?t.setAttribute("data-tabs",X(e.tabs)):t.hasAttribute("data-tabs")&&t.setAttribute("data-tabs","");const n=V({indentLeft:e.indentLeft,tabs:e.tabs});t.style.tabSize=n?n.split(":")[1]:""}Yt()}})}),ur("div",{className:"docs-sheet relative mx-auto shadow",style:{width:`${_r}pt`,zoom:ct/100,minHeight:Y.page.height/20+"pt"},children:[dr("div",{ref:E,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!0,lang:m.lang,role:"textbox","aria-multiline":"true","aria-label":f,"data-doc":M,onPaste:e=>{(async e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e),n=e.clipboardData?.getData("text/html");if(n){e.preventDefault();const t=document.createElement("div");t.innerHTML=s(n);for(const e of Array.from(t.querySelectorAll("img"))){const t=e.getAttribute("src")??"";if(t.startsWith("blob:")&&!p.has(t))try{const e=await(await fetch(t)).blob();p.set(t,{bytes:new Uint8Array(await e.arrayBuffer()),mime:e.type})}catch{e.remove()}}return void ln("insertHTML",t.innerHTML)}t.length&&(e.preventDefault(),$n(t))})(e)},onMouseUp:mn,onKeyUp:e=>{e.shiftKey&&mn()},onClick:e=>{const t=e.target,n=t.closest("[data-toc]");if(n&&jt(n)){const r=t.closest("a"),o=r&&(e.metaKey||e.ctrlKey)?xn(r.getAttribute("data-anchor")??(r.getAttribute("href")??"").slice(1)):null;return o?void o.scrollIntoView({block:"start"}):void Qe({x:e.clientX,y:e.clientY,el:n})}if("LI"===t.tagName&&t.parentElement?.hasAttribute("data-checklist")&&e.nativeEvent.offsetX<0)return void an(()=>{t.toggleAttribute("data-checked")});if("IMG"===t.tagName&&null===t.closest('[contenteditable="false"]')&&!t.getAttribute("contenteditable"))return e.preventDefault(),void vt({x:e.clientX,y:e.clientY,el:t});const r=t.closest("a");if(r&&(e.metaKey||e.ctrlKey)){const e=r.getAttribute("href")??"";e.startsWith("#")?xn(e.slice(1))?.scrollIntoView({block:"start"}):Cr.test(e)&&window.open(e,"_blank","noopener,noreferrer")}},onContextMenu:e=>{const t=e.target.closest?.("td,th");t&&!e.shiftKey&&!t.closest("[data-locked]")&&jt(t)&&(e.preventDefault(),kt({x:e.clientX,y:e.clientY,cell:t}))},className:"docs-page",style:{paddingTop:`${Jr}pt`,paddingRight:Y.page.right/20+"pt",paddingBottom:Y.page.bottom/20+"pt",paddingLeft:Y.page.left/20+"pt",minHeight:Y.page.height/20+"pt",boxSizing:"border-box",...oe>1&&!ie?{columnCount:oe,columnGap:"36pt"}:{},...Be?{cursor:"copy"}:{}}}),dr("button",{type:"button",className:"docs-hf-preview docs-page","data-doc":M,title:P.headersFootersHint,"aria-label":P.headersFooters,onClick:()=>re(!0),"data-hint":P.headersFootersHint,style:{top:Y.page.header/20+"pt",left:Y.page.left/20+"pt",right:Y.page.right/20+"pt",minHeight:Math.max(Y.page.top-Y.page.header-120,240)/20+"pt",maxHeight:Math.max(Y.page.top-Y.page.header,240)/20+"pt"},dangerouslySetInnerHTML:{__html:yr(Zr,1,Yr)}}),qe.length>0&&dr("section",{className:"docs-footnotes","aria-label":P.footnotes,style:{marginLeft:Y.page.left/20+"pt",marginRight:Y.page.right/20+"pt",marginBottom:Y.page.bottom/20+"pt"},children:qe.map((e,t)=>{const n=m.footnotes.get(e);return ur("div",{className:"docs-footnote",children:[dr("sup",{children:t+1}),!1===n?.editable?dr("span",{title:P.footnoteLocked,children:n.text}):dr("input",{"data-note-input":e,value:n?.text??"",placeholder:P.footnotePlaceholder,"aria-label":`${P.footnote} ${t+1}`,onChange:t=>((e,t)=>{const n=m.footnotes.get(e);n?.editable&&(m.footnotes.set(e,{...n,text:t}),Ge(e=>e+1),Yt())})(e,t.target.value)})]},e)})}),rt.slice(1).map((e,t)=>dr("div",{className:"docs-sheet-line pointer-events-none absolute left-0 right-0 border-t border-dashed","aria-hidden":"true",style:{top:`calc(${Jr}pt + ${e}px)`},children:dr("span",{className:"docs-sheet absolute right-1 -top-2 px-1 text-2xs",children:P.pageLabel(t+2)})},e)),dr("button",{type:"button",className:"docs-hf-preview docs-page","data-doc":M,title:P.headersFootersHint,"aria-label":P.headersFooters,onClick:()=>re(!0),"data-hint":P.headersFootersHint,style:{bottom:Y.page.footer/20+"pt",left:Y.page.left/20+"pt",right:Y.page.right/20+"pt",minHeight:Math.max(Y.page.bottom-Y.page.footer-120,240)/20+"pt",maxHeight:Math.max(Y.page.bottom-Y.page.footer,240)/20+"pt"},dangerouslySetInnerHTML:{__html:yr(eo,Yr,Yr)}})]})]}),ur("div",{className:"flex shrink-0 items-center gap-2 border-t border-line bg-surface-sunken px-3 py-1 text-xs text-ink-muted",children:[dr("span",{children:P.pageOf(Math.min(tt.pageNow,rt.length),rt.length)}),dr("span",{children:P.wordCount(tt.words)}),dr("span",{children:Xr}),Qr&&dr("span",{children:Qr}),ur("span",{className:"ml-auto flex items-center gap-1",children:[dr(ke,{size:"sm",variant:"ghost","aria-label":P.zoomOut,onClick:()=>dt(e=>[...xr].reverse().find(t=>t<e)??e),children:"−"}),ur("span",{className:"w-9 text-center tabular-nums",children:[ct,"%"]}),dr(ke,{size:"sm",variant:"ghost","aria-label":P.zoomIn,onClick:()=>dt(e=>xr.find(t=>t>e)??e),children:"+"})]})]})]}),dr(Ue,{page:Y.page,onPage:e=>{Z(t=>({...t,page:e})),Yt()},onMorePageSetup:()=>mt(!0),colour:_e.color,onColour:e=>{Je(t=>({...t,color:e})),Gr(t=>({...t,foreColor:e})),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{J.current=null,ln("foreColor",e)},150)},outline:at,onHeading:e=>{const t=E.current;t&&Hn(t)[e]?.scrollIntoView({block:"start"})}})]}),ut&&dr(Jn,{value:Y,onClose:()=>mt(!1),onApply:e=>{Z(e),mt(!1),Yt()}}),ne&&dr(rn,{value:ee,scope:M,locked:{headers:Object.fromEntries(wr.map(e=>[e,!m.headers[e].editable])),footers:Object.fromEntries(wr.map(e=>[e,!m.footers[e].editable]))},onClose:()=>re(!1),onApply:e=>{te(e),re(!1),Yt()}}),ue&&dr(gn,{value:ue,onClose:()=>Oe(null),onApply:e=>{var t;Oe(null),t=e,an(()=>{for(const e of Bt())void 0!==t.lineMultiple&&(e.style.lineHeight=String(t.lineMultiple)),void 0!==t.before&&(e.style.marginTop=`${t.before}pt`),void 0!==t.after&&(e.style.marginBottom=`${t.after}pt`),void 0!==t.indentRight&&(e.style.marginRight=t.indentRight?`${t.indentRight}pt`:""),"LI"!==e.tagName&&(void 0!==t.indentLeft&&(e.style.marginLeft=t.indentLeft?`${t.indentLeft}pt`:""),void 0!==t.firstLine&&(e.style.textIndent=t.firstLine?`${t.firstLine}pt`:""))})}}),Xe&&ur(Le,{minWidth:180,portal:!0,style:{position:"fixed",left:Xe.x,top:Xe.y},onClose:()=>Qe(null),children:[dr(Te,{onClick:()=>{var e;e=Xe.el,an(()=>{e.innerHTML=wn()}),Qe(null)},children:P.tocRefresh}),dr(Pe,{}),dr(Te,{danger:!0,onClick:()=>{const e=Xe.el;an(()=>{e.remove()}),Qe(null)},children:P.tocDelete})]}),yt&&ur(Le,{minWidth:150,portal:!0,style:{position:"fixed",left:yt.x,top:yt.y},onClose:()=>vt(null),children:[dr(Me,{children:P.imageWidth}),dr(Te,{onClick:()=>Tn(.25),children:"25%"}),dr(Te,{onClick:()=>Tn(.5),children:"50%"}),dr(Te,{onClick:()=>Tn(.75),children:"75%"}),dr(Te,{onClick:()=>Tn(1),children:"100%"}),dr(Te,{onClick:()=>Tn(null),children:P.imageOriginalSize}),dr(Pe,{}),dr(Te,{danger:!0,onClick:()=>{if(!yt)return;const e=yt.el;an(()=>{e.remove()}),vt(null)},children:P.imageRemove})]}),xt&&dr(Se,{at:{x:xt.x,y:xt.y},owner:xt.cell,onClose:()=>kt(null),items:(e=>{const t=e.closest("table"),n=(e,t,n,r={})=>({key:e,label:t,onSelect:()=>an(n),...r}),r=(e=>{const t=H.current;return t?Array.from(e.querySelectorAll("td,th")).filter(n=>n.closest("table")===e&&t.intersectsNode(n)):[]})(t);return[n("above",P.rowAbove,()=>ir(t,e,!1)),n("below",P.rowBelow,()=>ir(t,e,!0)),n("left",P.columnLeft,()=>lr(t,e,!1)),n("right",P.columnRight,()=>lr(t,e,!0)),{type:"divider",key:"d1"},n("merge",P.mergeCells,()=>{(function(e,t){if(t.length<2)return!1;const n=rr(e);let r=1/0,o=1/0,a=-1,i=-1;for(const e of t){const t=or(n,e);if(!t)return!1;r=Math.min(r,t.row),o=Math.min(o,t.col),a=Math.max(a,t.row+nr(e,"rowspan")-1),i=Math.max(i,t.col+nr(e,"colspan")-1)}const l=new Set;for(let e=r;e<=a;e++)for(let t=o;t<=i;t++){const r=n.slots[e]?.[t];r&&l.add(r)}for(const e of l){const t=or(n,e);if(t.row<r||t.col<o||t.row+nr(e,"rowspan")-1>a||t.col+nr(e,"colspan")-1>i)return!1}const s=n.slots[r][o];for(const e of l)if(e!==s){if((e.textContent??"").trim())for(;e.firstChild;)s.appendChild(e.firstChild);e.remove()}return s.setAttribute("colspan",String(i-o+1)),s.setAttribute("rowspan",String(a-r+1)),i===o&&s.removeAttribute("colspan"),a===r&&s.removeAttribute("rowspan"),!0})(t,r)||ze.error(P.mergeFailed)},{disabled:r.length<2}),{type:"submenu",key:"shade",label:P.cellShading,items:[...Bn.map(t=>({key:t,label:ur("span",{className:"flex items-center gap-2",children:[dr("span",{className:"h-3 w-5 rounded-sm border border-line",style:{background:t}}),t.toUpperCase()]}),onSelect:()=>an(()=>{for(const n of r.length?r:[e])n.style.backgroundColor=t})})),{key:"none",label:P.noColor,onSelect:()=>an(()=>{for(const t of r.length?r:[e])t.style.removeProperty("background-color")})}]},{type:"divider",key:"d2"},n("delRow",P.deleteRow,()=>{!function(e,t){const n=rr(e),r=or(n,t);if(!r)return!1;const o=tr(e);if(1===o.length)return e.remove(),!1;const a=new Set;for(let e=0;e<n.cols;e++){const t=n.slots[r.row][e];if(!t||a.has(t))continue;a.add(t);const i=nr(t,"rowspan");if(1!==i)if(t.parentElement===o[r.row]){const a=o[r.row+1],l=n.slots[r.row+1].slice(e+nr(t,"colspan")).find(e=>e.parentElement===a);t.setAttribute("rowspan",String(i-1)),a.insertBefore(t,l??null)}else t.setAttribute("rowspan",String(i-1))}o[r.row].remove()}(t,e)}),n("delCol",P.deleteColumn,()=>{!function(e,t){const n=rr(e),r=or(n,t);if(!r)return!1;if(1===n.cols)return e.remove(),!1;const o=new Set;for(const e of n.slots){const t=e[r.col];if(!t||o.has(t))continue;o.add(t);const n=nr(t,"colspan");n>1?t.setAttribute("colspan",String(n-1)):t.remove()}sr(e,n.cols-1,null,r.col)}(t,e)}),n("delTable",P.deleteTable,()=>{t.remove()},{danger:!0})]})(xt.cell)})]})}function $r({label:e,hint:t}){return ur("span",{className:"flex w-full items-center justify-between gap-4",children:[dr("span",{children:e}),dr("span",{className:"text-2xs text-ink-faint",children:t})]})}import{useEffect as Ar,useRef as Lr,useState as Pr}from"react";import{Icon as Tr}from"efficient-shell/icons";import{Button as Mr,IconButton as Rr,registerModalEscapeInterceptor as Er,toast as zr}from"efficient-shell/ui";var Fr={LF:"\n",CRLF:"\r\n",CR:"\r"};function Or(e,t){let n=1,r=-1;for(let o=e.indexOf("\n");o>=0&&o<t;o=e.indexOf("\n",o+1))n++,r=o;return{line:n,col:t-r}}function jr(e){let t=1;for(let n=e.indexOf("\n");n>=0;n=e.indexOf("\n",n+1))t++;return t}import{jsx as Hr,jsxs as Dr}from"react/jsx-runtime";function Ir({filename:e,decoded:t,bytes:n,fileEntries:r,title:o,dirty:a,onDirty:i,onOpenFile:l,onClose:s}){const c=u(),d=Lr(null),m=Lr(null),f=Lr(t.text),p=Lr(!1),[h,g]=Pr(!0),[w,b]=Pr(!1),[y,v]=Pr({line:1,col:1,lines:jr(t.text)}),[x,k]=Pr(!1),[C,S]=Pr(""),[N,$]=Pr(""),[A,L]=Pr(!1),[P,T]=Pr(0),[M,R]=Pr([]),E=()=>m.current?.value??"",z=Lr(null),[F,O]=Pr(0),j=()=>{z.current&&m.current&&(z.current.scrollTop=m.current.scrollTop,z.current.scrollLeft=m.current.scrollLeft)};Ar(()=>{const e=z.current?.querySelector("[data-current]"),t=m.current;if(!e||!t)return;const n=e.offsetTop-t.clientHeight/3;(e.offsetTop<t.scrollTop||e.offsetTop>t.scrollTop+t.clientHeight-42)&&(t.scrollTop=Math.max(0,n)),h||(t.scrollLeft=Math.max(0,e.offsetLeft-t.clientWidth/2)),j()},[F,P,M,h]);const H=()=>{const e=m.current;e&&v({...Or(e.value,e.selectionStart),lines:jr(e.value)})},D=(e=C,t=A)=>{const n=function(e,t,n){if(!t)return[];const r=n?e:e.toLowerCase(),o=n?t:t.toLowerCase(),a=r.length===e.length?r:e,i=[];for(let e=a.indexOf(o);e>=0;e=a.indexOf(o,e+Math.max(o.length,1)))i.push(e);return i}(E(),e,t);return R(n),n},I=(e,t,n=C)=>{const r=m.current;if(!r||!e.length)return;const o=(t%e.length+e.length)%e.length;T(o),r.setSelectionRange(e[o],e[o]+n.length),O(e=>e+1)},B=()=>{Sn(p.current?function(e,t,n){const r=e.replace(/\n/g,Fr[n]);if("utf-16le"===t||"utf-16be"===t){const e=new Uint8Array(2+2*r.length),n=new DataView(e.buffer),o="utf-16le"===t;n.setUint16(0,65279,o);for(let e=0;e<r.length;e++)n.setUint16(2+2*e,r.charCodeAt(e),o);return e}const o=(new TextEncoder).encode(r);if("utf-8-bom"!==t)return o;const a=new Uint8Array(o.length+3);return a.set([239,187,191]),a.set(o,3),a}(E(),t.encoding,t.eol):n,e,"text/plain"),p.current&&"windows-1252"===t.encoding&&zr.info(c.savedAsUtf8),f.current=E(),i(!1)},U=()=>{p.current=!0,b(!0),i(E()!==f.current),H(),x&&D()},W=e=>{document.execCommand("insertText",!1,e)||m.current?.setRangeText(e,m.current.selectionStart,m.current.selectionEnd,"end"),U()},q=e=>{m.current?.focus(),document.execCommand(e)},K=()=>{k(!1),m.current?.focus()};Ar(()=>{m.current?.focus(),m.current?.setSelectionRange(0,0)},[]);const G=Lr(x);G.current=x,Ar(()=>Er(()=>!(!G.current||!d.current?.contains(document.activeElement))&&(K(),!0)),[]);const V=[...r,{type:"divider",key:"d1"},{key:"save",label:c.saveKeepType,onSelect:B}],X=a?c.noStoreEdited:c.noStoreClean;return Dr("div",{ref:d,className:"es-editor docs-frame",onKeyDown:e=>{const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();if(t&&"s"===n)e.preventDefault(),B();else if(t&&"o"===n)e.preventDefault(),l();else if(t&&"f"===n){e.preventDefault(),k(!0);const t=m.current,n=t?t.value.slice(t.selectionStart,t.selectionEnd):"";n&&!n.includes("\n")&&(S(n),D(n))}else"Tab"!==e.key||t||e.shiftKey||e.target!==m.current||(e.preventDefault(),W("\t"))},children:[Hr(Ye,{onClose:s,fileMenu:V,name:o,saveState:{tone:a?"off-unsaved":"off",label:X},canUndo:w,canRedo:w,onUndo:()=>q("undo"),onRedo:()=>q("redo"),exportControl:Hr(Mr,{variant:"secondary",leftIcon:Hr(Tr,{name:"download",size:16}),onClick:B,children:c.export})}),Dr("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[Hr(Rr,{size:"sm",variant:"ghost","aria-label":c.find,title:c.find,"aria-pressed":x,onClick:()=>k(e=>!e),children:Hr(Tr,{name:"search",size:16})}),Hr(Rr,{size:"sm",variant:"ghost","aria-label":c.wrapLines,title:c.wrapLines,"aria-pressed":h,onClick:()=>g(e=>!e),children:Hr(Tr,{name:"wrap",size:16})})]}),x&&Hr(zn,{query:C,replacement:N,matchCase:A,current:P,total:M.length,onQuery:e=>{S(e);const t=D(e);T(0),I(t,0,e)},onReplacement:$,onMatchCase:e=>{L(e);const t=D(C,e);T(0),I(t,0)},onStep:e=>I(M,P+(e?1:-1)),onReplace:()=>{const e=m.current;if(!e||!M.length)return;e.focus(),e.setSelectionRange(M[P],M[P]+C.length),W(N);const t=D();I(t,P)},onReplaceAll:()=>{const e=m.current;if(!e||!M.length)return;const t=M.length;e.focus();for(let t=M.length-1;t>=0;t--)e.setSelectionRange(M[t],M[t]+C.length),W(N);D(),T(0),zr.success(c.replacedCount(t))},onClose:K}),Dr("div",{className:"relative min-h-0 flex-1 bg-surface",children:[x&&C&&M.length>0&&M.length<=2e3&&Hr("div",{ref:z,"aria-hidden":"true",style:{lineHeight:"21px",scrollbarGutter:"stable"},className:"pointer-events-none absolute inset-0 overflow-hidden p-4 font-mono text-sm text-transparent "+(h?"whitespace-pre-wrap break-words":"whitespace-pre"),children:(()=>{const e=E(),t=[];let n=0;return M.forEach((r,o)=>{t.push(e.slice(n,r)),n=r+C.length,t.push(Hr("mark",{...o===P?{"data-current":""}:{},className:"rounded-sm text-transparent "+(o===P?"bg-status-warning-line":"bg-status-warning-soft"),children:e.slice(r,n)},r))}),t.push(e.slice(n)),t})()}),Hr("textarea",{ref:m,defaultValue:t.text,"aria-label":e,spellCheck:!1,wrap:h?"soft":"off",onInput:U,onSelect:H,onKeyUp:H,onClick:H,onScroll:j,style:{lineHeight:"21px",scrollbarGutter:"stable"},className:"absolute inset-0 h-full w-full resize-none bg-transparent p-4 font-mono text-sm text-ink outline-none "+(h?"whitespace-pre-wrap break-words":"overflow-x-auto whitespace-pre")})]}),Dr("div",{className:"flex shrink-0 items-center gap-2 border-t border-line bg-surface-sunken px-3 py-1 text-xs text-ink-muted",children:[Hr("span",{children:e}),Hr("span",{children:c.lineColumn(y.line,y.col)}),Hr("span",{children:c.lineCount(y.lines)}),Hr("span",{children:t.eol})]})]})}import{jsx as Br,jsxs as Ur}from"react/jsx-runtime";var Wr=new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),qr=["docx"],Kr=`${Array.from(Wr,e=>`.${e}`).join(",")},.docx,text/*`,Gr=/^<!doctype html><meta charset="utf-8"><title>[^<]*<\/title>(?!<body style="font-family:ui-monospace)/,Vr=()=>"undefined"!=typeof navigator&&navigator.language||"en-AU";function Xr({value:e,onRename:t}){const n=u(),[r,o]=re(e);return te(()=>o(e),[e]),Br("div",{className:"docs-title",children:Br(se,{"aria-label":n.documentName,value:r,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},onBlur:()=>{const n=r.trim();o(n||e),n&&n!==e&&t(n)}})})}function Qr({documentId:e,onClose:t}){const n=u(),{store:r,canCreate:o=!0,canDelete:a=!0,chooseFile:i}=d(),[l,s]=re(null),[c,p]=re(null);if(!r||e)return Br(_r,{documentId:e,onClose:t});if(l)return Br(_r,{documentId:l.id,initialFile:l.file,onClose:()=>s(null)},l.key);return Br(m,{words:{windowTitle:n.filesHeading,heading:n.filesHeading,newFile:n.newFile,emptyTitle:n.filesEmptyTitle,emptyBody:n.filesEmptyBody,deleteConfirm:n.deleteConfirm,createFailed:n.createFailed,deleteFailed:n.deleteFailed},files:n.files,list:r.list,create:()=>r.create(n.untitled),rename:r.rename,remove:r.remove,canCreate:o,canDelete:a,accept:Kr,choose:i&&{run:i,request:{title:n.files.choosing(n.fileKind,n.filesHeading),extensions:qr}},onOpen:e=>s({key:Date.now(),id:e}),onOpenFile:(e,t)=>{Z(e.name,qr)?c||(p(n.files.opening(e.name)),f(r,e).then(async r=>{const o=await ee(t,r.id);ue.success(n.files.savedCopy(r.title,e.name,o?t?.location:void 0)),s({key:Date.now(),id:r.id})}).catch(()=>ue.error(n.files.openFailed(e.name))).finally(()=>p(null))):s({key:Date.now(),file:e})},busy:c})}function _r({documentId:e,onClose:t,initialFile:n}){const r=u(),{store:o}=d(),a=o&&e?e:null,i=ne([]),l=ne(0),c=ne(null),m={textBox:r.objectTextBox,chart:r.objectChart,diagram:r.objectDiagram,equation:r.objectEquation,picture:r.objectPicture,object:r.objectOther,contents:r.objectField},f=e=>({labels:m,imageUrl:(t,n)=>{const r=URL.createObjectURL(new Blob([t],{type:n}));return i.current.push(r),e.set(r,{bytes:t,mime:n}),r}}),p=e=>{const t=new Map;return{key:++l.current,kind:"rich",filename:e,images:t,doc:b(R(Vr()),null,f(t))}},[h,g]=re(()=>a?null:p(r.untitled)),[v,x]=re(!1),[k,C]=re(0),[S,N]=re(!1),[$,A]=re(!1),[L,P]=re(!1);ae(L),te(()=>()=>{i.current.forEach(e=>URL.revokeObjectURL(e))},[]),te(()=>{if(!o||!a)return;let e=!0;return x(!1),(async()=>{const t=await o.get(a),n=new Map,r=t.bytes?.length?await w(t.bytes,f(n)):b(R(Vr()),null,f(n));e&&T({key:++l.current,kind:"rich",doc:r,images:n,filename:t.title,stored:{id:t.id,version:t.version}})})().catch(()=>{e&&x(!0)}),()=>{e=!1}},[o,a,k]);const T=e=>{const t=i.current;if(i.current=[],"rich"===e.kind)for(const t of e.images.keys())i.current.push(t);g(e),P(!1),setTimeout(()=>t.filter(e=>!i.current.includes(e)).forEach(e=>URL.revokeObjectURL(e)),0)},M=async()=>!L||de({title:r.discardTitle(h?.filename??""),message:r.discardMessage,confirmLabel:r.discard,cancelLabel:r.keepEditing}),E=async e=>{if(!await M())return;const t=(e.name.split(".").pop()||"").toLowerCase();N(!0);try{if("docx"===t){const t=new Map,n=new Uint8Array(await e.arrayBuffer());try{const r=await w(n,f(t));T({key:++l.current,kind:"rich",doc:r,filename:e.name,images:t})}catch{ue.error(r.cannotRead(e.name))}}else if("doc"===t)ue.error(r.legacyDoc);else if(Wr.has(t)||e.type.startsWith("text/")){const n=new Uint8Array(await e.arrayBuffer()),o=function(e){let t,n="utf-8";if(239===e[0]&&187===e[1]&&191===e[2])n="utf-8-bom",t=new TextDecoder("utf-8").decode(e.subarray(3));else if(255===e[0]&&254===e[1])n="utf-16le",t=new TextDecoder("utf-16le").decode(e.subarray(2));else if(254===e[0]&&255===e[1])n="utf-16be",t=new TextDecoder("utf-16be").decode(e.subarray(2));else try{t=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{n="windows-1252",t=new TextDecoder("windows-1252").decode(e)}const r=t.match(/\r\n/g)?.length??0,o=(t.match(/\n/g)?.length??0)-r,a=(t.match(/\r/g)?.length??0)-r,i=r>o&&r>=a?"CRLF":a>o?"CR":"LF";return{text:t.replace(/\r\n?/g,"\n"),encoding:n,eol:i}}(n);if("html"!==t&&"htm"!==t||!Gr.test(o.text))T({key:++l.current,kind:"text",decoded:o,bytes:n,filename:e.name});else{const t=new Map,n=b(R(Vr()),null,f(t));n.html=s(o.text)||n.html,y(n),T({key:++l.current,kind:"rich",doc:n,images:t,filename:e.name.replace(/\.[^.]+$/,".docx"),imported:!0}),ue.info(r.openedOldSave)}}else ue.error(r.unsupported(t))}finally{N(!1)}};te(()=>{n&&E(n)},[]);const z=async()=>{await M()&&(P(!1),c.current?.click())},F="rich"===h?.kind&&!!h.stored,O=()=>ue.info(r.openFromFiles),j=[{key:"new",label:r.newDocument,onSelect:()=>{(async()=>{await M()&&T(p(r.untitled))})()}},{key:"open",label:Ur("span",{className:"flex w-full items-center justify-between gap-4",children:[Br("span",{children:r.open}),Br("span",{className:"text-2xs text-ink-faint",children:"⌘O"})]}),onSelect:()=>{z()}}],H=h&&Br(Xr,{value:h.filename,onRename:e=>{const t=h?.filename??e;g(t=>t?{...t,filename:e}:t),o&&"rich"===h?.kind&&h.stored&&o.rename(h.stored.id,e).catch(()=>{ue.error(r.renameFailed),g(e=>e?{...e,filename:t}:e)})}});return Ur("div",{className:"relative flex h-full flex-col bg-surface text-ink",onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),$||A(!0))},onDragLeave:e=>{e.currentTarget===e.target&&A(!1)},onDrop:e=>{if(!e.dataTransfer.types.includes("Files"))return;e.preventDefault(),A(!1);const t=Array.from(e.dataTransfer.files??[]);"rich"===h?.kind&&t.length&&t.every(e=>e.type.startsWith("image/"))?window.dispatchEvent(new CustomEvent("docs-insert-images",{detail:{key:h.key,files:t}})):t[0]&&F?O():t[0]&&E(t[0])},children:[h&&Br(oe,{title:`${D=h.filename,D.length>24?`${D.slice(0,23)}…`:D}${L?" •":""} - Documents`}),Br("input",{ref:c,type:"file",accept:Kr,className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&E(t),e.target.value=""}}),v?Br("div",{className:"docs-open-failed",children:Br(le,{title:r.openFailed,children:t&&Br(ie,{onClick:t,children:r.backToFiles})})}):S||!h?Br(ce,{size:"sm",padding:"",className:"h-full",label:r.loading}):"rich"===h.kind?Br(Nr,{sessionKey:h.key,doc:h.doc,filename:h.filename,images:h.images,fileEntries:F?[]:j,title:H,startsDirty:h.imported,dirty:L,onDirty:P,onOpenFile:()=>{F?O():z()},onNewImageUrl:e=>{i.current.push(e)},onClose:t,stored:o&&h.stored?{store:o,...h.stored}:void 0,onReload:()=>{P(!1),g(null),C(e=>e+1)}},h.key):Br(Ir,{filename:h.filename,decoded:h.decoded,bytes:h.bytes,fileEntries:j,title:H,dirty:L,onDirty:P,onOpenFile:()=>{z()},onClose:t},h.key),$&&Br("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center border-4 border-dashed border-accent-fill bg-accent-tint",children:Br("div",{className:"rounded-md bg-accent-fill px-4 py-2 text-sm font-medium text-on-accent",children:r.dropHint})})]});var D}function Jr({id:e,onClose:t}){return Br(Qr,{documentId:e,onClose:t})}export{Jr as OpenDocument,Qr as default};
|
package/dist/Slides-YZQXZJX4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-ADXHTZ3Q.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),D=d(()=>import("./SlidesEditor-ETCUQVJ7.js")),j=["pptx"];function F({id:e,onClose:t,note:n}){const i=r(),{store:s}=o(),[l,a]=h(null),[c,d]=h(!1),[b,w]=h(n??null),j=p(()=>{s.get(e).then(e=>a(t=>({deck:e,nonce:(t?.nonce??0)+1})),()=>d(!0))},[e,s]);if(u(j,[j]),c)return v("div",{className:"slides-list-empty",children:v(k,{title:i.openFailed,children:v(f,{onClick:t,children:i.backToDecks})})});if(!l)return null;const F=v(m,{fallback:null,children:v(D,{deck:l.deck,onClose:t,onReload:j},l.nonce)});return b?C("div",{className:"slides-with-note",children:[C("div",{className:"slides-import-note",role:"status",children:[v(N,{name:"info",size:16}),v("span",{children:b}),v(y,{"aria-label":i.dismiss,onClick:()=>w(null),children:v(N,{name:"close",size:14})})]}),v("div",{className:"slides-with-note-body",children:F})]}):F}function P(){const d=r(),{store:m,canCreate:u=!0,canDelete:f=!0,chooseFile:k,storeImage:y}=o(),[N,D]=h(null),[P,g]=h(null),x=p(()=>m.list(),[m]);if(N)return v(F,{id:N.id,note:N.note,onClose:()=>D(null)});const Q=u&&v("div",{className:"slides-starters","aria-label":d.startFrom,role:"group",children:s.map(e=>{const t="blank"===e?null:l(e,w(d));return C("button",{type:"button",className:"slides-starter",disabled:!!P,onClick:()=>{(async e=>{if(!P)try{const t=await m.create("blank"===e?d.untitledDeck:d.starterName(e));"blank"!==e&&await m.save(t.id,l(e,w(d)),t.version),D({id:t.id})}catch{b.error(d.createFailed)}})(e)},children:[v("span",{className:"slides-starter-thumb",children:t?v(a,{slide:t.slides[0],width:128}):v("span",{className:"slides-starter-blank"})}),v("span",{children:d.starterName(e)})]},e)})});return v(e,{extra:Q,words:{windowTitle:d.slidesPanel,heading:d.decks,newFile:d.newDeck,emptyTitle:d.emptyTitle,emptyBody:d.emptyBody,deleteConfirm:d.deleteConfirm,createFailed:d.createFailed,deleteFailed:d.deleteFailed},files:d.files,list:x,create:()=>m.create(d.untitledDeck),rename:m.rename,remove:m.remove,canCreate:u,canDelete:f,accept:".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation",choose:k&&{run:k,request:{title:d.files.choosing(d.fileKind,d.slidesPanel),extensions:j}},onOpen:e=>D({id:e}),onOpenFile:(e,s)=>{if(P)return;const l=d.files.opening(e.name);g(l),t(m,e,{storeImage:y,onProgress:e=>g(`${l} ${Math.round(100*e)}%`)}).then(async t=>{const n=await c(s,t.id);b.success(d.files.savedCopy(t.title,e.name,n?s?.location:void 0)),D({id:t.id,note:d.importNotes({skipped:t.notes.skipped,animations:t.notes.animationsDropped,fonts:t.notes.fontsReplaced})})}).catch(t=>{b.error(t instanceof n?d.pptxPasswordProtected:t instanceof i?t.message:d.files.openFailed(e.name))}).finally(()=>g(null))},busy:P})}export{F as OpenDeck,P as default,w as starterWords};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mergeDecks as e}from"./chunk-3RFDQOTI.js";import{LAYOUTS as t,THEMES as n,applyTheme as i,ensureFonts as l,fontsOf as r,slideFromLayout as o,themeOf as s}from"./chunk-Q7NVDOCX.js";import{SlidesConflict as a,useSlidesHost as d,useSlidesWords as c}from"./chunk-BGAR3P46.js";import{DEFAULT_TRANSITION_SECONDS as m,PPTX_SHAPES as u,SlideView as h,applyStyle as p,boxStyle as f,chartToGrid as b,clicksOf as g,connectorPath as v,editorHtml as y,gridToChart as k,indent as w,insertColumn as x,insertRow as C,listMarkers as S,mergeAt as N,mergeCells as z,moveAnimation as I,nearestSide as D,newAnimation as M,paragraphsIn as E,paragraphsOf as A,plainText as P,readParagraphs as F,relayConnectors as T,removeColumn as L,removeRow as j,restoreSelection as $,selectionOffsets as R,seriesOf as B,setCell as W,setParagraphs as O,shapePath as K,shownSlides as U,stateAt as H,styleAt as V,toggleList as _,transitionKeyframes as J,unmergeCell as q,videoSource as X,withEnds as G,withParagraphs as Q}from"./chunk-B2X3NIQR.js";import{DECK_FONT as Y,DECK_FONTS as Z,HANDLES as ee,NO_FILL as te,SHAPE_KINDS as ne,SLIDE_H as ie,SLIDE_W as le,angleTo as re,asDocument as oe,boundsOf as se,boxesTouch as ae,bringForward as de,copySlide as ce,historyReducer as me,insertSlideAfter as ue,moveSlide as he,newElement as pe,newId as fe,removeElements as be,removeSlide as ge,resizeBox as ve,shiftElement as ye,snapBox as ke,updateElements as we,updateSlide as xe}from"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{useCallback as Ce,useEffect as Se,useMemo as Ne,useReducer as ze,useRef as Ie,useState as De}from"react";import{saveIndicator as Me,useAutosave as Ee}from"efficient-easel/autosave";import{EaselIconButton as Ae,EaselTopBar as Pe,SaveState as Fe,TopBarCluster as Te,TopBarDivider as Le}from"efficient-easel/chrome";import{useEaselStrings as je}from"efficient-easel/strings";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{AvatarGroup as $e,Avatar as Re,Button as Be,ContextMenu as We,DropdownMenu as Oe,IconButton as Ke,Input as Ue,Popover as He,registerModalEscapeInterceptor as Ve,Textarea as _e,useContextMenu as Je}from"efficient-shell/ui";import{Icon as qe}from"efficient-shell/icons";import{toast as Xe}from"efficient-shell";import{useRef as Ge,useState as Qe}from"react";import{Button as Ye,IconButton as Ze,Textarea as et}from"efficient-shell/ui";import{Icon as tt}from"efficient-shell/icons";import{toast as nt}from"efficient-shell";import{Button as it,IconButton as lt,Select as rt,Slider as ot,Switch as st}from"efficient-shell/ui";import{Icon as at}from"efficient-shell/icons";import{jsx as dt,jsxs as ct}from"react/jsx-runtime";var mt=["none","fade","slide","push","zoom","flip"],ut=["appear","fadeIn","flyIn","zoomIn","fadeOut"],ht=(e,t)=>({none:e.transitionNone,fade:e.transitionFade,slide:e.transitionSlide,push:e.transitionPush,zoom:e.transitionZoom,flip:e.transitionFlip}[t]),pt=(e,t)=>({appear:e.effectAppear,fadeIn:e.effectFadeIn,flyIn:e.effectFlyIn,zoomIn:e.effectZoomIn,fadeOut:e.effectFadeOut}[t]);function ft(e,t){return t?"text"===t.type?P(A(t)).split("\n")[0].slice(0,32)||e.elementText:{shape:e.elementShape,image:e.elementImage,video:e.elementVideo,connector:e.elementConnector,chart:e.elementChart,table:e.elementTable}[t.type]:""}function bt({slide:e,slideNumber:t,selected:n,onSlide:i,onAllSlides:l,onPlay:r}){const o=c(),s=e.animations??[],a=e=>i({animations:e.length>0?e:void 0}),d=(e,t)=>a(s.map(n=>n.id===e?{...n,...t}:n)),u=1===n.length?n[0]:null;return ct("aside",{className:"slides-inspector",children:[dt("h3",{children:o.motion}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:`${o.transition} · ${o.slideNumber(t)}`}),dt("div",{className:"slides-pills",role:"radiogroup","aria-label":o.transition,children:mt.map(t=>{const n=(e.transition?.kind??"none")===t;return dt("button",{type:"button",role:"radio","aria-checked":n,className:"slides-pill",onClick:()=>i({transition:"none"===t?void 0:{kind:t,duration:e.transition?.duration??m}}),children:ht(o,t)},t)})}),e.transition&&dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:e.transition.duration,onChange:t=>i({transition:{...e.transition,duration:t??m}})}),ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",onClick:()=>l({transition:e.transition}),children:o.applyToAll}),dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"play",size:14}),onClick:r,children:o.play})]})]}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:o.animations}),0===s.length&&dt("small",{className:"slides-hint",children:o.noAnimations}),s.map((t,n)=>{const i=e.elements.find(e=>e.id===t.elementId);return ct("div",{className:"slides-animation",children:[ct("div",{className:"slides-animation-head",children:[dt("span",{className:"slides-animation-number",children:n+1}),dt("span",{className:"slides-animation-name",children:ft(o,i)}),dt(lt,{"aria-label":o.moveEarlier,size:"sm",disabled:0===n,onClick:()=>a(I(s,n,n-1)),children:dt(at,{name:"chevron-up",size:14})}),dt(lt,{"aria-label":o.moveLater,size:"sm",disabled:n===s.length-1,onClick:()=>a(I(s,n,n+1)),children:dt(at,{name:"chevron-down",size:14})}),dt(lt,{"aria-label":o.removeAnimation,size:"sm",onClick:()=>a(s.filter(e=>e.id!==t.id)),children:dt(at,{name:"trash",size:14})})]}),dt(rt,{"aria-label":o.animations,size:"sm",value:t.effect,onChange:e=>d(t.id,{effect:e,from:"flyIn"===e?t.from??"bottom":void 0}),options:ut.map(e=>({value:e,label:pt(o,e)}))}),"flyIn"===t.effect&&dt(rt,{"aria-label":o.effectFlyIn,size:"sm",value:t.from??"bottom",onChange:e=>d(t.id,{from:e}),options:[{value:"left",label:o.fromLeft},{value:"right",label:o.fromRight},{value:"top",label:o.fromTop},{value:"bottom",label:o.fromBottom}]}),dt(rt,{"aria-label":o.startClick,size:"sm",value:t.start,onChange:e=>d(t.id,{start:e}),options:[{value:"click",label:o.startClick},{value:"withPrevious",label:o.startWithPrevious},{value:"afterPrevious",label:o.startAfterPrevious}]}),dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:t.duration,onChange:e=>d(t.id,{duration:e??.5})}),"text"===i?.type&&dt(st,{label:o.byParagraph,checked:!!t.byParagraph,onChange:e=>d(t.id,{byParagraph:e||void 0})})]},t.id)}),u?ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"add",size:14}),onClick:()=>a([...s,M(u.id)]),children:o.addAnimation}),dt(it,{variant:"secondary",size:"sm",onClick:()=>a([...s,M(u.id,"fadeOut")]),children:o.effectFadeOut})]}):dt("small",{className:"slides-hint",children:o.selectToAnimate})]})]})}import{Fragment as gt,jsx as vt,jsxs as yt}from"react/jsx-runtime";function kt(e){return e.filter(e=>!e.parent).map(t=>({first:t,replies:e.filter(e=>e.parent===t.id)}))}function wt({placeholder:e,label:t,onPost:n,autoFocus:i}){const{people:l}=d(),r=c(),[o,s]=Qe(""),[a,m]=Qe([]),u=Ge(new Map),h=Ge(null),p=()=>{const e=o.trim();if(!e)return;const t=[...u.current].filter(([,t])=>e.includes(`@${t}`)).map(([e])=>e);n(e,t).then(()=>{s(""),u.current.clear()},()=>nt.error(r.commentFailed))};return yt("div",{className:"slides-composer",children:[vt(et,{ref:h,rows:2,"aria-label":t,placeholder:e,autoFocus:i,value:o,onChange:e=>{s(e.target.value),(e=>{const t=(e=>e.match(/@([\p{L}\p{N} .'-]{0,30})$/u)?.[1])(e);if(void 0===t||!l)return m([]);l(t.trim()).then(e=>m(e.slice(0,6)),()=>m([]))})(e.target.value)},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&p()}}),a.length>0&&vt("ul",{className:"slides-mentions",role:"listbox","aria-label":t,children:a.map(e=>vt("li",{role:"option","aria-selected":!1,onMouseDown:t=>{t.preventDefault(),(e=>{const t=o.replace(/@([\p{L}\p{N} .'-]{0,30})$/u,`@${e.name} `);u.current.set(e.id,e.name),s(t),m([]),h.current?.focus()})(e)},children:e.name},e.id))}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{size:"sm",disabled:!o.trim(),onClick:p,children:t})})]})}function xt({comment:e,mine:t,onSave:n,onDelete:i}){const l=c(),[r,o]=Qe(!1),[s,a]=Qe(e.body);return yt("div",{className:"slides-comment",children:[yt("div",{className:"slides-comment-head",children:[vt("span",{className:"slides-avatar","aria-hidden":"true",children:Ct(e.authorName)}),vt("span",{className:"slides-comment-author",children:e.authorName}),vt("time",{className:"slides-comment-time",dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}),t&&!r&&yt(gt,{children:[vt(Ze,{"aria-label":l.editComment,size:"sm",onClick:()=>o(!0),children:vt(tt,{name:"edit",size:14})}),vt(Ze,{"aria-label":l.deleteComment,size:"sm",onClick:i,children:vt(tt,{name:"trash",size:14})})]})]}),r?yt("div",{className:"slides-composer",children:[vt(et,{rows:2,"aria-label":l.editComment,value:s,onChange:e=>a(e.target.value)}),yt("div",{className:"slides-actions slides-actions-end",children:[vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(!1),children:l.cancel}),vt(Ye,{size:"sm",onClick:()=>{n(s.trim()),o(!1)},disabled:!s.trim(),children:l.save})]})]}):vt("p",{className:"slides-comment-body",children:e.body})]})}var Ct=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function St({comments:e,slides:t,slide:n,selectedId:i,focusId:l,onAdd:r,onUpdate:o,onRemove:s,onShowSlide:a}){const m=c(),{currentUser:u}=d(),[h,p]=Qe(!1),f=kt(e).filter(e=>h||!e.first.resolvedAt).sort((e,i)=>{const l=e=>e.first.slideId===n.id?0:1,r=e=>t.findIndex(t=>t.id===e.first.slideId);return l(e)-l(i)||r(e)-r(i)||e.first.createdAt.localeCompare(i.first.createdAt)}),b=n.elements.find(e=>e.id===i);return yt("aside",{className:"slides-inspector slides-comments",children:[vt("h3",{children:m.comments}),yt("div",{className:"slides-section",children:[vt("p",{className:"slides-label",children:b?ft(m,b):m.onSlide}),vt(wt,{label:m.post,placeholder:m.commentPlaceholder,onPost:(e,t)=>r({slideId:n.id,elementId:i??"",body:e,parent:null,mentions:t})},`${n.id}-${i??""}`),yt("label",{className:"slides-check",children:[vt("input",{type:"checkbox",checked:h,onChange:e=>p(e.target.checked)}),m.showResolved]})]}),0===f.length&&vt("p",{className:"slides-empty",children:m.noComments}),f.map(({first:e,replies:n})=>{const i=t.findIndex(t=>t.id===e.slideId),d=t[i]?.elements.find(t=>t.id===e.elementId);return yt("article",{className:"slides-thread","data-focus":l===e.id||void 0,"data-resolved":e.resolvedAt?"":void 0,children:[yt("button",{type:"button",className:"slides-thread-where",onClick:()=>a(e.slideId),children:[m.slideNumber(i+1),e.elementId?` · ${d?ft(m,d):m.objectGone}`:""]}),[e,...n].map(e=>vt(xt,{comment:e,mine:e.authorId===u?.id,onSave:t=>o(e.id,{body:t}),onDelete:()=>s(e.id)},e.id)),e.resolvedAt?yt("div",{className:"slides-actions slides-actions-between",children:[vt("small",{className:"slides-hint",children:`${m.resolvedBy} · ${e.resolvedByName}`}),vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(e.id,{resolved:!1}),children:m.reopen})]}):yt(gt,{children:[vt(wt,{label:m.reply,placeholder:m.replyPlaceholder,onPost:(t,n)=>r({slideId:e.slideId,elementId:e.elementId,body:t,parent:e.id,mentions:n})}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{variant:"secondary",size:"sm",leftIcon:vt(tt,{name:"check",size:14}),onClick:()=>o(e.id,{resolved:!0}),children:m.resolve})})]})]},e.id)})]})}import{useCallback as Nt,useEffect as zt,useState as It}from"react";import{Button as Dt,confirm as Mt,prompt as Et}from"efficient-shell/ui";import{Icon as At}from"efficient-shell/icons";import{toast as Pt}from"efficient-shell";import{jsx as Ft,jsxs as Tt}from"react/jsx-runtime";var Lt=e=>new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"});function jt({deckId:e,previewing:t,onPreview:n,onRestore:i,refreshKey:l}){const r=c(),{versions:o}=d(),[s,a]=It(null),m=Nt(()=>{o&&o.list(e).then(a,()=>Pt.error(r.versionsFailed))},[e,o,r.versionsFailed]);if(zt(m,[m,l]),!o)return null;const u=async(t,n="")=>{const i=await Et({title:r.nameVersion,message:r.versionName,defaultValue:n});if(null!==i)try{t?await o.rename(e,t,i.trim()):await o.name(e,i.trim()),m()}catch{Pt.error(r.versionsFailed)}};return Tt("aside",{className:"slides-inspector",children:[Ft("h3",{children:r.versionHistory}),Ft("div",{className:"slides-section",children:Ft(Dt,{variant:"secondary",size:"sm",leftIcon:Ft(At,{name:"bookmark",size:14}),onClick:()=>{u(null)},children:r.nameVersion})}),0===s?.length&&Ft("p",{className:"slides-empty",children:r.noVersions}),Ft("ul",{className:"slides-versions",children:s?.map(l=>Tt("li",{"data-current":t===l.id||void 0,children:[Ft("button",{type:"button",className:"slides-version-name",onClick:()=>{u(l.id,l.name)},children:l.name||Lt(l.createdAt)}),l.name&&Ft("small",{children:Lt(l.createdAt)}),Ft("small",{children:l.editorNames.join(", ")}),Tt("div",{className:"slides-actions",children:[Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{t===l.id?n(null,null):o.get(e,l.id).then(e=>n(l.id,e),()=>Pt.error(r.versionsFailed))},children:t===l.id?r.closePreview:r.previewVersion}),Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{(async t=>{if(await Mt({title:r.restore,message:r.restoreConfirm(Lt(t.createdAt)),confirmLabel:r.restore}))try{i(await o.get(e,t.id))}catch{Pt.error(r.restoreFailed)}})(l)},children:r.restore})]})]},l.id))})]})}import{useEffect as $t,useMemo as Rt,useRef as Bt,useState as Wt}from"react";import{Button as Ot,registerModalEscapeInterceptor as Kt}from"efficient-shell/ui";import{Icon as Ut}from"efficient-shell/icons";import{useLayoutEffect as Ht,useRef as Vt,useState as _t}from"react";import{createPortal as Jt}from"react-dom";import{jsx as qt,jsxs as Xt}from"react/jsx-runtime";function Gt(e){const[t,n]=_t(0);return Ht(()=>{const t=e.current;if(!t)return;const i=t.ownerDocument.defaultView,l=()=>n(Math.min(t.clientWidth,t.clientHeight*le/ie));l();const r=new(i?.ResizeObserver??ResizeObserver)(l);return r.observe(t),()=>r.disconnect()},[e]),t}function Qt({slide:e,popup:t,number:n,motion:i,fonts:r,transition:o,onLink:s,onAdvance:a}){const[d]=_t(()=>{const e=t.document.createElement("div");return e.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#000;cursor:pointer;overflow:hidden",t.document.body.appendChild(e),{current:e}}),c=Gt(d),[m,u]=_t(null),p=Vt(e),f=Vt(null),b=Vt(null);Ht(()=>{r&&l(t.document,r)},[r,t]),Ht(()=>{const t=p.current;p.current=e,t.id!==e.id&&o?u(t):u(null)},[e,o]),Ht(()=>{if(!m||!o)return;const{incoming:e,outgoing:n}=J(o),i={duration:1e3*o.duration,easing:"ease-in-out",fill:"both"},l=f.current?.animate(e,i),r=b.current?.animate(n,i),s=t.setTimeout(()=>u(null),1e3*o.duration+30);return()=>{t.clearTimeout(s),l?.cancel(),r?.cancel()}},[m,o,t]);const g=Vt(!1);return Jt(Xt("div",{style:{position:"relative",width:c,height:c*ie/le},onClick:()=>{if(!g.current&&t.document.documentElement.requestFullscreen)return g.current=!0,void t.document.documentElement.requestFullscreen().catch(()=>{});a?.()},children:[m&&qt("div",{ref:b,style:{position:"absolute",inset:0},children:qt(h,{slide:m,width:c})}),qt("div",{ref:f,style:{position:"absolute",inset:0},children:qt(h,{slide:e,width:c,number:n,motion:i,options:{live:!0,onLink:s}})})]}),d.current)}import{jsx as Yt,jsxs as Zt}from"react/jsx-runtime";var en=e=>String(e).padStart(2,"0");function tn({slides:e,startIndex:t,numbers:n,fonts:i,popup:l,onEnd:r}){const o=Rt(()=>U(e),[e]),s=Math.max(0,o.findIndex(e=>e>=t)),[a,d]=Wt({at:s,step:0}),[m,u]=Wt(!0),p=function(){const[e,t]=Wt(0);return $t(()=>{const e=Date.now(),n=setInterval(()=>t(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(n)},[]),`${en(Math.floor(e/60))}:${en(e%60)}`}(),f=c(),b=Bt(null),v=Gt(b),y=t=>{const n=function(e,t,n,i){const l=e[t[n.at]];if(1===i)return l&&n.step<g(l)?{at:n.at,step:n.step+1}:n.at<t.length-1?{at:n.at+1,step:0}:n;if(n.step>0)return{at:n.at,step:n.step-1};if(0===n.at)return n;const r=e[t[n.at-1]];return{at:n.at-1,step:g(r)}}(e,o,a,t);u(n.at!==a.at&&1===t),d(n)},k=Bt({go:y,onEnd:r});k.current={go:y,onEnd:r},$t(()=>{const e=e=>{["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(e.key)?(e.preventDefault(),k.current.go(1)):["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(e.key)&&(e.preventDefault(),k.current.go(-1))};return window.addEventListener("keydown",e),l?.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),l?.removeEventListener("keydown",e)}},[l]),$t(()=>Kt(()=>(k.current.onEnd(),!0)),[]),$t(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&k.current.onEnd()};return l.addEventListener("keydown",e),()=>{l.removeEventListener("keydown",e),l.close()}},[l]);const w=o[Math.min(a.at,o.length-1)],x=e[w],C=o[a.at+1],S=void 0!==C?e[C]:void 0,N=g(x),z=Rt(()=>H(x,a.step),[x,a.step]),I=t=>{if(t.startsWith("#slide=")){const n=e.findIndex(e=>e.id===t.slice(7));-1!==n&&(e=>{const t=o.indexOf(e);-1!==t&&(u(!0),d({at:t,step:0}))})(n)}else window.open(t,"_blank","noopener")},D=n?w+1:void 0;return Zt("div",{className:"slides-presenter",children:[Zt("div",{className:"slides-presenter-head",children:[Yt("span",{className:"slides-presenter-clock",children:p}),Zt("span",{children:[f.slideOf(w+1,e.length),N>0&&` · ${f.presenterStep(a.step,N)}`]}),Yt(Ot,{variant:"secondary",onClick:r,leftIcon:Yt(Ut,{name:"close",size:16}),children:f.endShow})]}),!l&&Yt("p",{className:"slides-presenter-blocked",children:f.popupBlocked}),Zt("div",{className:"slides-presenter-body",children:[Zt("div",{className:"slides-presenter-main",children:[Yt("div",{ref:b,className:"slides-presenter-current",children:Yt(h,{slide:x,width:v,number:D,motion:z,options:{onLink:I}})}),Zt("div",{className:"slides-presenter-steps",children:[Yt(Ot,{variant:"secondary",onClick:()=>y(-1),leftIcon:Yt(Ut,{name:"arrow-left",size:16}),children:f.back}),Yt(Ot,{variant:"secondary",onClick:()=>y(1),rightIcon:Yt(Ut,{name:"arrow-right",size:16}),children:f.next})]})]}),Zt("div",{className:"slides-presenter-side",children:[Yt("p",{className:"slides-presenter-label",children:f.nextSlide}),S?Yt(h,{slide:S,width:280,number:n?C+1:void 0}):Yt("p",{children:f.endOfDeck}),Yt("p",{className:"slides-presenter-label",children:f.notes}),Yt("p",{className:"slides-presenter-notes",children:x.notes||f.noNotes})]})]}),l&&Yt(Qt,{slide:x,popup:l,number:D,motion:z,fonts:i,transition:m&&0===a.step?x.transition:void 0,onLink:I,onAdvance:()=>y(1)})]})}import{useState as nn}from"react";import{SettingsColour as ln}from"efficient-easel/panel";import{Button as rn}from"efficient-shell/ui";import{IconButton as on}from"efficient-shell/ui";import{Input as sn}from"efficient-shell/ui";import{Select as an}from"efficient-shell/ui";import{Slider as dn}from"efficient-shell/ui";import{Switch as cn}from"efficient-shell/ui";import{Icon as mn}from"efficient-shell/icons";import{Fragment as un,jsx as hn,jsxs as pn}from"react/jsx-runtime";var fn=e=>e===te?"#ffffff":e;function bn({label:e,value:t,onChange:n}){return pn("label",{className:"slides-number",children:[hn("span",{children:e}),hn(sn,{type:"number",value:Math.round(t),onChange:e=>{const t=Number(e.target.value);""!==e.target.value&&Number.isFinite(t)&&n(t)}})]})}function gn(e){return[{label:e.alignLeft,icon:"box-x-start",action:{kind:"align",to:"left"}},{label:e.alignCentre,icon:"box-x-center",action:{kind:"align",to:"center"}},{label:e.alignRight,icon:"box-x-end",action:{kind:"align",to:"right"}},{label:e.alignTop,icon:"box-y-start",action:{kind:"align",to:"top"}},{label:e.alignMiddle,icon:"box-y-center",action:{kind:"align",to:"middle"}},{label:e.alignBottom,icon:"box-y-end",action:{kind:"align",to:"bottom"}},{label:e.distributeAcross,icon:"box-x-between",action:{kind:"distribute",axis:"horizontal"}},{label:e.distributeDown,icon:"box-y-between",action:{kind:"distribute",axis:"vertical"}}]}function vn({chart:e,accents:t,onChange:n}){const i=c(),l=b(e),r="pie"===e.kind||"donut"===e.kind;return pn("div",{className:"slides-field",children:[hn("span",{children:i.values}),hn("div",{className:"slides-grid-edit",style:{gridTemplateColumns:`repeat(${l[0].length}, minmax(0, 1fr))`},children:l.map((r,o)=>r.map((r,s)=>hn("input",{"aria-label":0===o?i.seriesName:0===s?i.rows:`${l[0][s]} ${l[o][0]}`,className:"slides-grid-cell","data-head":0===o||0===s||void 0,value:r,disabled:0===o&&0===s,inputMode:o>0&&s>0?"decimal":void 0,onChange:i=>((i,r,o)=>n(k(e,l.map((e,t)=>e.map((e,n)=>t===i&&n===r?o:e)),t)))(o,s,i.target.value)},`${o}-${s}`)))}),pn("div",{className:"slides-actions",children:[!r&&hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,l.map((e,t)=>[...e,0===t?`${i.addSeries} ${e.length}`:"0"]),t)),children:i.addSeries}),hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,[...l,l[0].map((e,t)=>0===t?"":"0")],t)),children:i.addCategory})]})]})}function yn({slide:e,selected:t,onChangeSlide:n,onChangeSelected:i,onAlign:l,onForward:r,onDelete:o,onArrange:s,cells:a,accents:m=[]}){const u=c(),{pickImage:h}=d();if(0===t.length)return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:u.slide}),pn("div",{className:"slides-section",children:[hn(ln,{label:u.background,value:e.background,onChange:e=>n({background:e})}),hn(cn,{label:u.skipSlide,checked:!!e.skip,onChange:e=>n({skip:e||void 0})})]})]});const p=1===t.length?t[0]:null,f={text:u.elementText,shape:u.elementShape,image:u.elementImage,video:u.elementVideo,connector:u.elementConnector,chart:u.elementChart,table:u.elementTable},g=e=>i(t=>({...t,...e})),v=e=>{s?s(e):"align"!==e.kind||"left"!==e.to&&"center"!==e.to&&"right"!==e.to?"order"===e.kind&&"forward"===e.to&&r():l(e.to)},y=t.some(e=>e.groupId),w=t.every(e=>e.locked);return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:p?f[p.type]:u.objects(t.length)}),p&&"connector"!==p.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.positionAndSize}),pn("div",{className:"slides-numbers",children:[hn(bn,{label:"X",value:p.x,onChange:e=>g({x:e})}),hn(bn,{label:"Y",value:p.y,onChange:e=>g({y:e})}),hn(bn,{label:u.width,value:p.w,onChange:e=>g({w:Math.max(20,e)})}),hn(bn,{label:u.height,value:p.h,onChange:e=>g({h:Math.max(20,e)})}),hn(bn,{label:u.angle,value:p.rotation,onChange:e=>g({rotation:e})})]})]}),pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.align}),hn("div",{className:"slides-actions",children:gn(u).map(({label:e,icon:t,action:n})=>hn(on,{"aria-label":e,size:"sm",onClick:()=>v(n),children:hn(mn,{name:t,size:16})},e))}),pn("div",{className:"slides-actions",children:[hn(on,{"aria-label":u.bringToFront,size:"sm",onClick:()=>v({kind:"order",to:"front"}),children:hn(mn,{name:"move-up",size:16})}),hn(on,{"aria-label":u.bringForward,size:"sm",onClick:()=>v({kind:"order",to:"forward"}),children:hn(mn,{name:"layers",size:16})}),hn(on,{"aria-label":u.sendBackward,size:"sm",onClick:()=>v({kind:"order",to:"backward"}),children:hn(mn,{name:"arrow-down",size:16})}),hn(on,{"aria-label":u.sendToBack,size:"sm",onClick:()=>v({kind:"order",to:"back"}),children:hn(mn,{name:"move-down",size:16})}),t.length>1&&!y&&hn(on,{"aria-label":u.group,size:"sm",onClick:()=>v({kind:"group"}),children:hn(mn,{name:"rectangle-group",size:16})}),y&&hn(on,{"aria-label":u.ungroup,size:"sm",onClick:()=>v({kind:"ungroup"}),children:hn(mn,{name:"detach",size:16})}),hn(on,{"aria-label":w?u.unlock:u.lock,size:"sm",pressed:w,onClick:()=>v({kind:"lock",locked:!w}),children:hn(mn,{name:"lock",size:16})}),hn(on,{"aria-label":u.delete,size:"sm",onClick:o,children:hn(mn,{name:"trash",size:16})})]})]}),"shape"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.elementShape,value:p.shape,onChange:e=>g({shape:e}),options:ne.map(e=>({value:e,label:u.shapeName(e)}))}),"line"!==p.shape&&hn(ln,{label:u.colour,value:fn(p.fill),onChange:e=>g({fill:e})}),(p.stroke||"line"===p.shape)&&hn(ln,{label:u.outlineColour,value:fn(p.stroke??p.fill),onChange:e=>g({stroke:e})}),"line"!==p.shape&&!p.stroke&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>g({stroke:"#2c2c2a",strokeWidth:4}),children:u.outline}),(p.stroke||"line"===p.shape)&&hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth??4,onChange:e=>g({strokeWidth:e??4})}),"line"===p.shape&&pn(un,{children:[hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]})]}),"connector"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.route,value:p.route,onChange:e=>g({route:e}),options:[{value:"straight",label:u.routeStraight},{value:"elbow",label:u.routeElbow},{value:"curved",label:u.routeCurved}]}),hn(ln,{label:u.outlineColour,value:p.stroke,onChange:e=>g({stroke:e})}),hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth,onChange:e=>g({strokeWidth:e??4})}),hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]}),"image"===p?.type&&hn(kn,{element:p,pickImage:h,onChange:g,onChangeSelected:i}),"video"===p?.type&&pn("div",{className:"slides-section",children:[pn("label",{className:"slides-field",children:[hn("span",{children:u.videoAddress}),hn(sn,{value:p.src,placeholder:"https://youtu.be/…",onChange:e=>g({src:e.target.value.trim()})}),hn("small",{children:u.videoHint})]}),pn("label",{className:"slides-field",children:[hn("span",{children:u.description}),hn(sn,{value:p.alt,onChange:e=>g({alt:e.target.value})})]})]}),"chart"===p?.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.data}),hn(an,{"aria-label":u.chartType,value:p.kind,onChange:e=>g({kind:e}),options:[{value:"bar",label:u.chartBar},{value:"hbar",label:u.chartHbar},{value:"line",label:u.line},{value:"area",label:u.chartArea},{value:"pie",label:u.chartPie},{value:"donut",label:u.chartDonut}]}),hn(vn,{chart:p,accents:m,onChange:e=>i(()=>e)}),hn(an,{"aria-label":u.legend,value:p.legend??"auto",onChange:e=>g({legend:"auto"===e?void 0:e}),options:[{value:"auto",label:u.legend},{value:"bottom",label:u.legendBottom},{value:"right",label:u.legendRight},{value:"none",label:u.legendNone}]}),hn(ln,{label:u.colour,value:p.series?.[0]?.color??p.color,onChange:e=>i(t=>{const n=t,i=b(n);return k({...n,color:e,series:n.series?.map((t,n)=>0===n?{...t,color:e}:t)},i,m)})})]}),"table"===p?.type&&hn(wn,{table:p,cells:a??null,onChange:e=>i(()=>e)})]})}function kn({element:e,pickImage:t,onChange:n,onChangeSelected:i}){const l=c(),r=e.crop??{left:0,top:0,right:0,bottom:0};return pn("div",{className:"slides-section",children:[t?hn(rn,{variant:"secondary",block:!0,onClick:()=>{const{id:n}=e;t().then(e=>{e&&i(t=>t.id===n?{...t,src:e}:t)})},children:e.src?l.replaceImage:l.chooseImage}):pn("label",{className:"slides-field",children:[hn("span",{children:l.imageAddress}),hn(sn,{value:e.src,onChange:e=>n({src:e.target.value})})]}),pn("label",{className:"slides-field",children:[hn("span",{children:l.description}),hn(sn,{value:e.alt,onChange:e=>n({alt:e.target.value})})]}),hn("p",{className:"slides-label",children:l.crop}),["left","top","right","bottom"].map(e=>hn(dn,{label:l[{left:"cropLeft",top:"cropTop",right:"cropRight",bottom:"cropBottom"}[e]],min:0,max:45,suffix:"%",value:Math.round(100*r[e]),onChange:t=>((e,t)=>{const i={...r,[e]:Math.max(0,Math.min(.45,(t??0)/100))};n({crop:i.left||i.top||i.right||i.bottom?i:void 0})})(e,t)},e)),hn(dn,{label:l.opacity,min:0,max:100,suffix:"%",value:Math.round(100*(e.opacity??1)),onChange:e=>n({opacity:null===e||e>=100?void 0:e/100})})]})}function wn({table:e,cells:t,onChange:n}){const i=c(),[l]=nn(i.cellEditHint),r=t??{row:e.rows.length-1,col:(e.rows[0]?.length??1)-1,rows:1,cols:1},o=N(e,r.row,r.col);return pn("div",{className:"slides-section",children:[hn("small",{className:"slides-hint",children:l}),pn("div",{className:"slides-actions slides-actions-words",children:[hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row)),children:i.insertRowAbove}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row+r.rows)),children:i.insertRowBelow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col)),children:i.insertColumnLeft}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col+r.cols)),children:i.insertColumnRight}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(j(e,r.row)),children:i.deleteRow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(L(e,r.col)),children:i.deleteColumn}),t&&t.rows*t.cols>1&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(z(e,t)),children:i.mergeCells}),o&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(q(e,r.row,r.col)),children:i.unmergeCells})]}),hn(ln,{label:i.headingColour,value:fn(e.headerFill),onChange:t=>n({...e,headerFill:t})}),hn(ln,{label:i.borderColour,value:e.borderColor??"#b4b2a9",onChange:t=>n({...e,borderColor:t})}),hn(dn,{label:i.borderWidth,min:0,max:12,value:e.borderWidth??2,onChange:t=>n({...e,borderWidth:t??2})})]})}import{useState as xn}from"react";import{Button as Cn,ContextMenu as Sn,useContextMenu as Nn}from"efficient-shell/ui";import{Icon as zn}from"efficient-shell/icons";import{jsx as In,jsxs as Dn}from"react/jsx-runtime";function Mn({slides:e,currentId:t,onShow:n,onAdd:i,onMove:l,onDuplicate:r,onDelete:o,onSkip:s,numbers:a,visitors:d=[]}){const[m,u]=xn(null),p=c(),f=Nn(),b=f.state?e.findIndex(e=>e.id===f.state?.data):-1;return Dn("nav",{className:"slides-rail","aria-label":p.slidesPanel,children:[e.map((e,i)=>Dn("div",{className:"slides-thumb","data-current":e.id===t||void 0,"data-skipped":e.skip||void 0,draggable:!0,onDragStart:()=>u(e.id),onDragEnd:()=>u(null),onDragOver:e=>e.preventDefault(),onContextMenu:t=>f.open(t,e.id),onDrop:()=>{m&&m!==e.id&&l(m,i),u(null)},children:[In("span",{className:"slides-thumb-number",children:i+1}),Dn("div",{role:"button",tabIndex:0,"aria-label":p.slideNumber(i+1),"aria-current":e.id===t,className:"slides-thumb-image",onClick:()=>n(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),n(e.id))},children:[In(h,{slide:e,width:132,number:a?i+1:void 0}),e.skip&&In("span",{className:"slides-thumb-skip",title:p.skipped,children:In(zn,{name:"eye-off",size:14})}),In("span",{className:"slides-thumb-visitors",children:d.filter(t=>t.slide===e.id).map(e=>In("span",{title:e.user.name,style:{background:e.color}},e.key))})]})]},e.id)),In(Cn,{variant:"secondary",block:!0,onClick:i,children:p.addSlide}),b>=0&&In(Sn,{...f.props,items:(g=e[b],[{key:"duplicate",label:p.duplicateSlide,icon:In(zn,{name:"copy",size:14}),onSelect:()=>r(g.id)},...s?[{key:"skip",label:g.skip?p.unskipSlide:p.skipSlide,icon:In(zn,{name:"eye-off",size:14}),onSelect:()=>s(g.id)}]:[],{type:"divider",key:"d-delete"},{key:"delete",label:p.deleteSlide,danger:!0,icon:In(zn,{name:"trash",size:14}),onSelect:()=>o(g.id)}]),"aria-label":p.slideNumber(b+1)})]});var g}import{useLayoutEffect as En,useRef as An,useState as Pn}from"react";function Fn(e,t){const n=[...e.elements];for(let e=1;e<n.length;e+=1)t.has(n[e].id)&&!t.has(n[e-1].id)&&([n[e],n[e-1]]=[n[e-1],n[e]]);return{...e,elements:n}}function Tn(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...n,...e.elements.filter(e=>t.has(e.id))]}}function Ln(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...e.elements.filter(e=>t.has(e.id)),...n]}}var jn={x:0,y:0,w:le,h:ie};function $n(e,t){const n=new Set(e.elements.filter(e=>t.has(e.id)&&e.groupId).map(e=>e.groupId));return new Set(e.elements.filter(e=>t.has(e.id)||e.groupId&&n.has(e.groupId)).map(e=>e.id))}var Rn="efficient-office/slide-elements";function Bn(e){try{const t=JSON.parse(e);return t?.type===Rn&&Array.isArray(t.elements)?t.elements:null}catch{return null}}function Wn(e,t){const n=new Map(t.map(e=>[e.id,fe()])),i=new Map,l=t.some(t=>e.elements.some(e=>e.id===t.id))?40:0,r=t.map(e=>{const t={...ye(e,l,l),id:n.get(e.id),locked:void 0};var r;if(e.groupId&&(t.groupId=(r=e.groupId,i.has(r)||i.set(r,fe()),i.get(r))),"connector"===t.type){const e=({attach:e,...t})=>{const i=e&&n.get(e.id);return i?{...t,attach:{...e,id:i}}:t};return{...t,start:e(t.start),end:e(t.end)}}return t});return{slide:{...e,elements:[...e.elements,...r]},ids:r.map(e=>e.id)}}import{useEffect as On,useLayoutEffect as Kn,useRef as Un}from"react";import{registerModalEscapeInterceptor as Hn}from"efficient-shell/ui";import{jsx as Vn}from"react/jsx-runtime";var _n=e=>e.reduce((e,t)=>e+t.runs.reduce((e,t)=>e+t.text.length,0),0)+e.length-1;function Jn({element:e,onCommit:t,onEnd:n,onEditing:i,onLinkShortcut:l}){const r=c(),o=Un(null),s=Un(A(e)),a=Un({start:0,end:_n(s.current)}),d=Un(t);d.current=t;const m=Un(n);m.current=n;const u=Un(i);u.current=i;const h=()=>{const t=o.current;t&&(t.innerHTML=y(e,s.current))},b=()=>{const{start:e,end:t}=a.current,n=s.current,i=e!==t,{runs:l,...r}=n[E(n,e,t)[0]??0]??{runs:[]};u.current({style:i?V(n,e,t):V(n,0,_n(n)),paragraph:r,hasRange:i,applyRun:e=>g((t,n,i)=>n===i?p(t,0,_n(t),e):p(t,n,i,e)),applyParagraph:e=>g((t,n,i)=>O(t,n,i,e)),toggleList:e=>g((t,n,i)=>_(t,n,i,e)),indent:e=>g((t,n,i)=>w(t,n,i,e))})},g=e=>{const t=o.current;if(!t)return;const{start:n,end:i}=a.current;s.current=e(s.current,n,i),h(),t.focus(),$(t,n,i),b()};return Kn(()=>{const e=o.current;if(!e)return;h(),e.focus();const t=_n(s.current);$(e,0,t),a.current={start:0,end:t},b()},[]),On(()=>Hn(()=>!!o.current?.contains(o.current.ownerDocument.activeElement)&&(m.current(),!0)),[]),On(()=>{const e=o.current;if(!e)return;const t=e.ownerDocument,n=()=>{const t=R(e);t&&(a.current=t,b())};return t.addEventListener("selectionchange",n),()=>{t.removeEventListener("selectionchange",n),u.current(null),d.current(s.current)}},[]),Vn("div",{ref:o,contentEditable:!0,role:"textbox","aria-multiline":"true","aria-label":r.slideText,suppressContentEditableWarning:!0,className:"slides-text-edit",style:{...f(e),display:"flex",flexDirection:"column",justifyContent:{top:"flex-start",middle:"center",bottom:"flex-end"}[e.anchor??"top"]},onPointerDown:e=>e.stopPropagation(),onInput:()=>{const e=o.current,t=s.current,n=F(e);s.current=n;if((n.some(e=>e.list)||t.some(e=>e.list))&&n.length!==t.length){const t=R(e)??a.current;h(),$(e,t.start,t.end)}},onPaste:e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");o.current?.ownerDocument.execCommand("insertText",!1,t)},onKeyDown:e=>{e.stopPropagation();const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=V(s.current,a.current.start,a.current.end);t&&"b"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{bold:!i.bold}))):t&&"i"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{italic:!i.italic||void 0}))):t&&"u"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{underline:!i.underline||void 0}))):t&&"k"===n?(e.preventDefault(),l?.()):"Tab"===e.key?(e.preventDefault(),g((t,n,i)=>w(t,n,i,e.shiftKey?-1:1))):"Escape"===e.key&&m.current()}})}import{Fragment as qn,jsx as Xn,jsxs as Gn}from"react/jsx-runtime";var Qn={x:[],y:[]};function Yn({text:e,onDone:t}){const n=An(null);return En(()=>{const t=n.current;t&&(t.innerText=e,t.focus(),t.ownerDocument.getSelection()?.selectAllChildren(t))},[]),Xn("div",{ref:n,contentEditable:"plaintext-only",role:"textbox",suppressContentEditableWarning:!0,className:"slides-cell-edit",onPointerDown:e=>e.stopPropagation(),onBlur:e=>t(e.currentTarget.innerText.replace(/\n+$/,"")),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&t(null),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())}})}function Zn({slide:e,selected:t,onSelect:n,onLive:i,onSettle:l,onCommit:r,onEditing:o,onLink:s,cells:a,onCells:d,onContextMenu:c,visitors:m=[],pins:u=[],onPin:p,grid:f,slideNumber:b}){const g=An(null),[v,y]=Pn(0),[k,w]=Pn(Qn),[x,C]=Pn(null),[S,N]=Pn(null),[z,I]=Pn(null),M=An(null);En(()=>{const e=g.current;if(!e)return;const t=()=>{y(Math.max(0,Math.min(e.clientWidth-48,(e.clientHeight-48)*le/ie)))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=v/le,P=An(null),F=e=>{const t=P.current?.getBoundingClientRect();return{x:(e.clientX-(t?.left??0))/E,y:(e.clientY-(t?.top??0))/E}},L=(t,n,i=!1)=>{for(let l=e.elements.length-1;l>=0;l-=1){const r=e.elements[l];if(r.locked&&!i)continue;const o=-r.rotation*Math.PI/180,s=t-(r.x+r.w/2),a=n-(r.y+r.h/2),d=s*Math.cos(o)-a*Math.sin(o),c=s*Math.sin(o)+a*Math.cos(o);if(Math.abs(d)<=r.w/2&&Math.abs(c)<=r.h/2)return r}return null},j=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),M.current=t},$=l=>{const r=M.current;if(!r)return;const{x:o,y:s}=F(l);if("marquee"===r.kind){const t={x:Math.min(r.px,o),y:Math.min(r.py,s),w:Math.abs(o-r.px),h:Math.abs(s-r.py)};C(t);const i=new Set(e.elements.filter(e=>!e.locked&&ae(t,e)).map(e=>e.id));n($n(e,i))}else if("move"===r.kind){const e=r.start.elements.filter(e=>t.has(e.id)),n=r.start.elements.filter(e=>!t.has(e.id)),a=se(e),d={...a,x:a.x+o-r.px,y:a.y+s-r.py},c=l.altKey?{box:d,guides:Qn}:ke(d,n);w(c.guides);const m=c.box.x-a.x,u=c.box.y-a.y;i(T(we(r.start,t,e=>ye(e,m,u)),t))}else if("resize"===r.kind){const e=we(r.start,new Set([r.id]),e=>{const t=-e.rotation*Math.PI/180,n=o-r.px,i=s-r.py,a=n*Math.cos(t)-i*Math.sin(t),d=n*Math.sin(t)+i*Math.cos(t);return{...e,...ve(e,r.handle,a,d,l.shiftKey)}});i(T(e))}else if("rotate"===r.kind){const e=we(r.start,new Set([r.id]),e=>({...e,rotation:re(e,o,s,l.shiftKey)}));i(T(e))}else{const e=r.start.elements.find(e=>e.id===r.id&&"connector"===e.type);if(!e)return;const t=l.altKey?null:D(r.start.elements,o,s,e.id),n=t?{x:t.x,y:t.y,attach:{id:t.id,side:t.side}}:{x:o,y:s},a="start"===r.end?n:e.start,d="end"===r.end?n:e.end;i(we(r.start,new Set([e.id]),()=>G(e,a,d)))}},R=()=>{const e=M.current;M.current=null,w(Qn),C(null),e&&"marquee"!==e.kind&&l()},B=e.elements.filter(e=>t.has(e.id)),O=1===B.length?B[0]:void 0,K=e.elements.find(e=>e.id===S&&"text"===e.type),U=An({slide:e,onCommit:r});U.current={slide:e,onCommit:r};const H=(e,t=null,n="slides-selection",i)=>Gn("div",{className:n,style:{left:e.x*E,top:e.y*E,width:e.w*E,height:e.h*E,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,...i?{borderColor:i.color}:{}},children:[i&&Xn("span",{className:"slides-visitor-name",style:{background:i.color},children:i.name}),t]},`${n}-${e.id}-${i?.name??""}`),V="table"===O?.type?O:null;return Xn("div",{ref:g,className:"slides-pane",children:Gn("div",{ref:P,className:"slides-stage",style:{width:v,height:v*ie/le},onPointerDown:i=>{if(0!==i.button)return;S&&N(null);const{x:l,y:r}=F(i),o=L(l,r);if(!o)return i.shiftKey||n(new Set),d(null),void j(i,{kind:"marquee",px:l,py:r});if("table"===o.type&&t.has(o.id)&&1===t.size){const e=i.target.closest("[data-cell]")?.dataset.cell;if(e){const[t,n]=e.split(":").map(Number);if(i.shiftKey&&a){const e=Math.min(a.row,t),i=Math.min(a.col,n);return void d({row:e,col:i,rows:Math.max(a.row+a.rows-1,t)-e+1,cols:Math.max(a.col+a.cols-1,n)-i+1})}d({row:t,col:n,rows:1,cols:1})}}else d(null);let s=t;const c=$n(e,new Set([o.id]));if(i.shiftKey){const e=new Set(t),i=!e.has(o.id);for(const t of c)i?e.add(t):e.delete(t);s=e,n(e)}else t.has(o.id)||(s=c,n(s));s.has(o.id)&&j(i,{kind:"move",start:e,px:l,py:r})},onPointerMove:$,onPointerUp:R,onPointerCancel:R,onContextMenu:i=>{const{x:l,y:r}=F(i),o=L(l,r,!0);o&&!t.has(o.id)&&n($n(e,new Set([o.id]))),c(i,o?.id??null)},onDoubleClick:e=>{const{x:t,y:i}=F(e),l=L(t,i);if("text"===l?.type)n(new Set([l.id])),N(l.id);else if("table"===l?.type){const t=e.target.closest("[data-cell]")?.dataset.cell;if(t){const[e,n]=t.split(":").map(Number);I({id:l.id,row:e,col:n})}}},children:[Xn(h,{slide:e,width:v,number:b,editingId:K?.id,options:V?{cellEditor:(J=V,(t,n)=>z&&z.id===J.id&&z.row===t&&z.col===n?Xn(Yn,{text:J.rows[t][n],onDone:i=>{I(null),null!==i&&i!==J.rows[t][n]&&r(we(e,new Set([J.id]),()=>W(J,t,n,i)))}}):void 0)}:void 0,editor:K&&Xn(Jn,{element:K,onCommit:(_=K.id,e=>{const{slide:t,onCommit:n}=U.current,i=t.elements.find(e=>e.id===_&&"text"===e.type);if(!i)return;const l=Q(i,e);JSON.stringify(l.paragraphs)===JSON.stringify(A(i))&&l.text===i.text||n(we(t,new Set([_]),()=>l))}),onEnd:()=>N(null),onEditing:o,onLinkShortcut:s},K.id)}),f&&Xn("div",{className:"slides-grid",style:{backgroundSize:`${60*E}px ${60*E}px`}}),m.flatMap(t=>e.elements.filter(e=>t.selected.includes(e.id)).map(e=>H(e,null,"slides-visitor",t))),!K&&B.map(t=>H(t,O?.id!==t.id||t.locked?t.locked?Xn("span",{className:"slides-lock","aria-hidden":"true"}):null:(t=>"connector"===t.type?["start","end"].map(n=>{const i=t[n];return Xn("div",{className:"slides-handle slides-end","data-held":i.attach?"":void 0,style:{left:(i.x-t.x)*E,top:(i.y-t.y)*E},onPointerDown:i=>j(i,{kind:"end",start:e,id:t.id,end:n}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)}):Gn(qn,{children:[ee.map(n=>Xn("div",{className:`slides-handle slides-handle-${n}`,onPointerDown:i=>j(i,{kind:"resize",start:e,id:t.id,handle:n,...ti(F(i))}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)),Xn("div",{className:"slides-rotate-stem"}),Xn("div",{className:"slides-rotate",onPointerDown:n=>j(n,{kind:"rotate",start:e,id:t.id}),onPointerMove:$,onPointerUp:R,onPointerCancel:R})]}))(t))),V&&a&&Xn("div",{className:"slides-cells","aria-hidden":"true",style:ei(P.current,V,a,E)}),u.map(e=>Xn("button",{type:"button",className:"slides-pin",style:{left:e.x*E,top:e.y*E},onPointerDown:e=>e.stopPropagation(),onClick:()=>p?.(e.id),children:e.count},e.id)),k.x.map(e=>Xn("div",{className:"slides-guide slides-guide-x",style:{left:e*E}},`x${e}`)),k.y.map(e=>Xn("div",{className:"slides-guide slides-guide-y",style:{top:e*E}},`y${e}`)),x&&Xn("div",{className:"slides-marquee",style:{left:x.x*E,top:x.y*E,width:x.w*E,height:x.h*E}})]})});var _,J}function ei(e,t,n,i){const l=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row}:${n.col}"]`),r=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row+n.rows-1}:${n.col+n.cols-1}"]`)??l;if(!e||!l||!r)return{display:"none"};const o=e.getBoundingClientRect(),s=l.getBoundingClientRect(),a=r.getBoundingClientRect();return{left:s.left-o.left,top:s.top-o.top,width:a.right-s.left,height:a.bottom-s.top}}var ti=({x:e,y:t})=>({px:e,py:t});import{ColorPicker as ni,DropdownMenu as ii,IconButton as li,prompt as ri,Select as oi}from"efficient-shell/ui";import{Icon as si}from"efficient-shell/icons";import{toast as ai}from"efficient-shell";import{jsx as di,jsxs as ci}from"react/jsx-runtime";var mi=[12,16,20,24,28,32,40,48,56,64,72,96,120,160],ui=[1,1.15,1.25,1.5,2];function hi({element:e,editing:t,slides:n,accents:i,onBox:l}){const r=c(),o=A(e),s=P(o).length,a=t?t.style:V(o,0,s),d=t?t.paragraph:o[0]??{runs:[]},m=a.size??(t?.hasRange?void 0:e.fontSize)??e.fontSize,u=a.font??e.font??Z[0],h=a.bold??e.bold,f=e=>{t?t.applyRun(e):l(t=>{const n={},i={...e};"size"in e&&e.size&&(n.fontSize=e.size,i.size=void 0),"bold"in e&&(n.bold=!!e.bold,i.bold=void 0),"color"in e&&e.color&&(n.color=e.color,i.color=void 0),"font"in e&&e.font&&(n.font=e.font,i.font=void 0);const l=A(t);return Q({...t,...n},p(l,0,P(l).length,i))})},b=e=>{t?t.applyParagraph(e):l(t=>Q(t,O(A(t),0,Number.MAX_SAFE_INTEGER,e)))},g=e=>{t?t.toggleList(e):l(t=>Q(t,_(A(t),0,Number.MAX_SAFE_INTEGER,e)))},v=e=>{t?t.indent(e):l(t=>Q(t,w(A(t),0,Number.MAX_SAFE_INTEGER,e)))},y=async()=>{const e=await ri({title:r.link,message:r.linkPrompt,allowEmpty:!0,defaultValue:a.link?.startsWith("#slide=")?"":a.link??""});if(null==e)return;if(!e.trim())return void f({link:void 0});const t=function(e,t){const n=e.trim();if(!n)return null;if(/^\d+$/.test(n)){const e=t[Number(n)-1];return e?`#slide=${e.id}`:null}return/^(https?:\/\/|mailto:)/i.test(n)?n:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:/^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(n)?`https://${n}`:null}(e,n);t?f({link:t}):ai.error(r.badLink)},k=e=>{const t=mi.findIndex(e=>e>=m),n=-1===t?mi.length-1:1===e?mi[t]>m?t:t+1:t-1;return mi[Math.max(0,Math.min(mi.length-1,n))]},x=d.align??e.align,C=(e,t,n,i)=>di(li,{"aria-label":e,size:"sm",pressed:i,onClick:n,children:di(si,{name:t,size:16})},e);return ci("div",{className:"slides-toolbar slides-texttools","data-text-toolbar":"",onMouseDown:e=>{e.target.closest('input, select, [role="combobox"], [role="listbox"]')||e.preventDefault()},children:[di("div",{className:"slides-tool-font",children:di(oi,{"aria-label":r.font,size:"sm",value:u,onChange:e=>f({font:String(e)}),options:Z.map(e=>({value:e,label:e}))})}),C(r.smaller,"remove",()=>f({size:k(-1)})),di("div",{className:"slides-tool-size",children:di(oi,{"aria-label":r.fontSize,size:"sm",value:String(Math.round(m)),onChange:e=>f({size:Number(e)}),options:[...new Set([...mi,Math.round(m)])].sort((e,t)=>e-t).map(e=>({value:String(e),label:String(e)}))})}),C(r.larger,"add",()=>f({size:k(1)})),di("span",{className:"slides-tool-gap"}),C(r.bold,"bold",()=>f({bold:!h}),h),C(r.italic,"italic",()=>f({italic:!a.italic||void 0}),!!a.italic),C(r.underline,"underline",()=>f({underline:!a.underline||void 0}),!!a.underline),C(r.strikethrough,"strike",()=>f({strike:!a.strike||void 0}),!!a.strike),di(ni,{label:r.textColour,size:"sm",value:a.color??e.color,presets:i,onChange:e=>f({color:e})}),di(ni,{label:r.highlight,size:"sm",value:a.highlight??"#ffffff",presets:["#fac775","#c0dd97","#b5d4f4","#f4c0d1"],clearable:!0,onChange:e=>f({highlight:e||void 0})}),C(r.link,"link",()=>{y()},!!a.link),di("span",{className:"slides-tool-gap"}),C(r.alignLeft,"align-left",()=>b(e=>({...e,align:"left"})),"left"===x),C(r.alignCentre,"align-center",()=>b(e=>({...e,align:"center"})),"center"===x),C(r.alignRight,"align-right",()=>b(e=>({...e,align:"right"})),"right"===x),C(r.alignJustify,"align-justify",()=>b(e=>({...e,align:"justify"})),"justify"===x),di("span",{className:"slides-tool-gap"}),C(r.bulletList,"list",()=>g("bullet"),"bullet"===d.list),C(r.numberedList,"numbered-list",()=>g("number"),"number"===d.list),C(r.indentLess,"chevron-left",()=>v(-1)),C(r.indentMore,"chevron-right",()=>v(1)),di(ii,{"aria-label":r.lineSpacing,trigger:di(si,{name:"line-spacing",size:16}),items:ui.map(e=>({type:"radio",key:String(e),label:String(e),checked:(d.lineHeight??1.25)===e,onSelect:()=>b(t=>({...t,lineHeight:1.25===e?void 0:e}))}))}),di(ii,{"aria-label":r.verticalAlign,trigger:di(si,{name:"v-align",size:16}),items:[...["top","middle","bottom"].map(t=>({type:"radio",key:t,label:r[t],checked:(e.anchor??"top")===t,onSelect:()=>l(e=>({...e,anchor:t}))})),{type:"divider",key:"d"},{type:"checkbox",key:"fit",label:r.shrinkToFit,checked:!!e.autofit,onSelect:()=>l(e=>({...e,autofit:!e.autofit||void 0}))}]})]})}import{SettingsColour as pi}from"efficient-easel/panel";import{Select as fi,Switch as bi}from"efficient-shell/ui";import{jsx as gi,jsxs as vi}from"react/jsx-runtime";function yi({doc:e,slide:t,onTheme:i,onDeck:l,onSlide:r}){const a=c(),d=s(e),m=e=>i({...d,...e,id:n.some(t=>t.id===d.id&&JSON.stringify({...t,...e})===JSON.stringify(t))?d.id:"custom"}),u={title:"Aa",subtitle:"",body:""};return vi("aside",{className:"slides-inspector",children:[gi("h3",{children:a.theme}),gi("div",{className:"slides-section",children:gi("div",{className:"slides-themes",children:n.map(e=>vi("button",{type:"button",className:"slides-theme-tile","aria-pressed":e.id===d.id,onClick:()=>i(e),children:[gi(h,{slide:{...o("title",e,u),elements:o("title",e,u).elements.slice(0,1)},width:96}),gi("span",{children:a.themeName(e.id)})]},e.id))})}),vi("div",{className:"slides-section",children:[gi("p",{className:"slides-label",children:a.colours}),gi(pi,{label:a.background,value:d.background,onChange:e=>m({background:e})}),gi(pi,{label:a.headingFont,value:d.heading,onChange:e=>m({heading:e})}),gi(pi,{label:a.bodyFont,value:d.text,onChange:e=>m({text:e})}),gi("div",{className:"slides-swatches","aria-hidden":"true",children:d.accents.map(e=>gi("span",{style:{background:e}},e))})]}),vi("div",{className:"slides-section",children:[gi(fi,{"aria-label":a.headingFont,value:d.headingFont,onChange:e=>m({headingFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.headingFont}: ${e}`}))}),gi(fi,{"aria-label":a.bodyFont,value:d.bodyFont,onChange:e=>m({bodyFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.bodyFont}: ${e}`}))})]}),vi("div",{className:"slides-section",children:[gi(bi,{label:a.slideNumbers,checked:!!e.slideNumbers,onChange:e=>l({slideNumbers:e||void 0})}),gi(bi,{label:a.skipSlide,checked:!!t.skip,onChange:e=>r({skip:e||void 0})})]})]})}import{useEffect as ki,useRef as wi,useState as xi}from"react";var Ci=["#1d9e75","#d85a30","#378add","#d4537e","#ba7517","#639922","#7f77dd","#993c1d"];function Si(e){let t=0;for(const n of e)t=31*t+n.charCodeAt(0)>>>0;return Ci[t%Ci.length]}var Ni=13.333,zi=e=>e/le*Ni,Ii=e=>e.replace("#","").toUpperCase(),Di=e=>Math.round(72*zi(e));function Mi(e){return`${e.replace(/[^\p{L}\p{N} _-]+/gu," ").replace(/ +/g," ").trim()||"Deck"}.pptx`}var Ei=e=>e===te?{type:"none"}:{color:Ii(e)},Ai=e=>e.stroke?{color:Ii(e.stroke),width:Di(e.strokeWidth??1)}:void 0;function Pi(e,t,n,i){const l=e.cellFills?.[n]?.[i]??(0===n?e.headerFill:null),r=e.cellColors?.[n]?.[i]??(0===n?e.headerColor:void 0),o=e.merges?.find(e=>e.row===n&&e.col===i);return{text:t,options:{...0===n?{bold:!0}:{},...l?{fill:Ei(l)}:{},...r?{color:Ii(r)}:{},...o?{rowspan:o.rows,colspan:o.cols}:{}}}}var Fi={bar:"bar",hbar:"bar",line:"line",area:"area",pie:"pie",donut:"doughnut"};function Ti(e,t,n){const i={x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),rotate:n.rotation};switch(n.type){case"text":!function(e,t,n){const i=A(t),l=S(i),r=[];i.forEach((e,n)=>{const o=e.runs.length>0?e.runs:[{text:""}];o.forEach((s,a)=>{const d=a===o.length-1;r.push({text:s.text,options:{bold:s.bold??t.bold,italic:s.italic,underline:s.underline||s.link?{style:"sng"}:void 0,strike:s.strike?"sngStrike":void 0,color:Ii(s.color??t.color),highlight:s.highlight?Ii(s.highlight):void 0,fontSize:Di(s.size??t.fontSize),fontFace:s.font??t.font??Y,hyperlink:s.link&&!s.link.startsWith("#")?{url:s.link}:void 0,align:e.align??t.align,bullet:l[n]?"number"!==e.list||{type:"number"}:void 0,indentLevel:e.level||void 0,lineSpacingMultiple:e.lineHeight,breakLine:d&&n<i.length-1}})})}),e.addText(r,{...n,valign:t.anchor??"top",margin:0,fit:t.autofit?"shrink":void 0})}(t,n,i);break;case"shape":!function(e,t,n,i){"line"!==n.shape?t.addShape(u[n.shape],{...i,fill:Ei(n.fill),line:Ai(n),rectRadius:"roundRect"===n.shape&&void 0!==n.radius?zi(n.radius):void 0}):t.addShape(e.ShapeType.line,{...i,y:i.y+i.h/2,h:0,line:{color:Ii(n.stroke??n.fill),width:Di(n.strokeWidth??1),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"}})}(e,t,n,i);break;case"image":{if(!n.src)break;const e=n.crop;t.addImage({...i,path:n.src,altText:n.alt,transparency:void 0!==n.opacity?Math.round(100*(1-n.opacity)):void 0,...e&&(e.left||e.top||e.right||e.bottom)?{sizing:{type:"crop",x:zi(n.w*e.left/Math.max(.05,1-e.left-e.right)),y:zi(n.h*e.top/Math.max(.05,1-e.top-e.bottom)),w:i.w,h:i.h}}:{}});break}case"video":{const e=X(n.src);"youtube"===e?.kind?t.addMedia({...i,type:"online",link:`https://www.youtube.com/embed/${e.id}`}):n.src&&t.addText([{text:n.alt||n.src,options:{hyperlink:{url:n.src}}}],{...i,align:"center",valign:"middle",fill:{color:"2C2C2A"},color:"FFFFFF"});break}case"connector":!function(e,t,n){const i={color:Ii(n.stroke),width:Di(n.strokeWidth),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"};if("straight"===n.route){const l=Math.min(n.start.x,n.end.x),r=Math.min(n.start.y,n.end.y);return void t.addShape(e.ShapeType.line,{x:zi(l),y:zi(r),w:zi(Math.abs(n.end.x-n.start.x)),h:zi(Math.abs(n.end.y-n.start.y)),flipH:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.x<n.start.x,flipV:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.y<n.start.y,line:i})}const l=v(n),r=l.match(/-?\d+(\.\d+)?/g)?.map(Number)??[],o=[];if("elbow"===n.route){let e=r[0],t=r[1];o.push({x:e,y:t});for(const n of l.slice(l.indexOf(" ")+1).split(" ")){const i=Number(n.slice(1));"H"===n[0]?e=i:t=i,o.push({x:e,y:t})}}else{const[e,t,n,i,l,s,a,d]=r;for(let r=0;r<=16;r+=1){const c=r/16,m=1-c;o.push({x:m*m*m*e+3*m*m*c*n+3*m*c*c*l+c*c*c*a,y:m*m*m*t+3*m*m*c*i+3*m*c*c*s+c*c*c*d})}}t.addShape("custGeom",{x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),points:o.map((e,t)=>0===t?{x:zi(e.x),y:zi(e.y),moveTo:!0}:{x:zi(e.x),y:zi(e.y)}),line:i})}(e,t,n);break;case"chart":!function(e,t,n,i){const{categories:l,series:r}=B(n),o="pie"===n.kind||"donut"===n.kind,s=(o?r.slice(0,1):r).map(e=>({name:e.name||" ",labels:l,values:e.values})),a=n.legend??(o||r.length>1?"bottom":"none");t.addChart(Fi[n.kind],s,{...i,barDir:"hbar"===n.kind?"bar":"col",chartColors:o?void 0:r.map(e=>Ii(e.color)),showValue:1===r.length&&!o,showPercent:o,showLegend:"none"!==a,legendPos:"right"===a?"r":"b"})}(0,t,n,i);break;case"table":!function(e,t,n){const{columnWidths:i,rowHeights:l,fontSize:r}=t,o=t.rows.map((e,n)=>e.flatMap((e,i)=>((e,t,n)=>e.merges?.some(e=>t>=e.row&&t<e.row+e.rows&&n>=e.col&&n<e.col+e.cols&&(t!==e.row||n!==e.col)))(t,n,i)?[]:[Pi(t,e,n,i)])),s=t.borderWidth??2;e.addTable(o,{...n,border:s?{type:"solid",color:Ii(t.borderColor??"#B4B2A9"),pt:Math.max(.25,Di(s))}:{type:"none"},...r?{fontSize:Di(r)}:{},...i?{colW:i.map(e=>e*n.w)}:{},...l?{rowH:l.map(zi)}:{}})}(t,n,i)}}async function Li(e,t){const n=await async function(e,t){const{default:n}=await(import("pptxgenjs")),i=new n;return i.defineLayout({name:"SLIDE_16_9",width:Ni,height:7.5}),i.layout="SLIDE_16_9",i.title=e,t.slides.forEach(e=>{const n=i.addSlide();n.background={color:Ii(e.background)},e.skip&&(n.hidden=!0),e.notes&&n.addNotes(e.notes);for(const t of e.elements)Ti(i,n,t);t.slideNumbers&&(n.slideNumber={x:zi(1780),y:zi(1010),fontSize:11,color:"888780"})}),i}(e,t);await n.writeFile({fileName:Mi(e)})}import{jsx as ji,jsxs as $i}from"react/jsx-runtime";var Ri=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t),Bi=(e,t)=>({title:e.layoutTitle,titleBody:e.layoutTitleBody,section:e.layoutSection,twoColumns:e.layoutTwoColumns,titleOnly:e.layoutTitleOnly,blank:e.layoutBlank}[t]);function Wi({onPick:e}){const t=c();return ji(He,{"aria-label":t.addShape,triggerLabel:t.addShape,trigger:ji(qe,{name:"shape-rect",size:16}),children:({close:n})=>ji("div",{className:"slides-shape-grid",role:"listbox","aria-label":t.addShape,children:ne.filter(e=>"line"!==e).map(i=>ji("button",{type:"button",title:t.shapeName(i),"aria-label":t.shapeName(i),onClick:()=>{e(i),n()},children:ji("svg",{viewBox:"-2 -2 28 28",width:22,height:22,"aria-hidden":"true",children:ji("path",{d:K(i,24,24),fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round"})})},i))})})}function Oi(e,t){return kt(t).filter(t=>t.first.slideId===e.id&&!t.first.resolvedAt).map((t,n)=>{const i=e.elements.find(e=>e.id===t.first.elementId);return{id:t.first.id,x:i?i.x+i.w-8:1880-40*n,y:i?i.y-28:16,count:1+t.replies.length}})}function Ki({deck:n,onClose:m,onReload:u}){const f=c(),b=d(),{store:g}=b,[v,y]=De(n.title),[k,w]=ze(me,void 0,()=>({past:[],present:oe(n.document),future:[]})),x=k.present,C=s(x),[S,N]=De(x.slides[0].id),[z,I]=De(new Set),[D,M]=De(!0),[E,F]=De(null),[L,j]=De("inspector"),[$,R]=De(null),[B,W]=De(null),[O,K]=De(!1),[U,H]=De(null),[V,_]=De([]),[J,q]=De(null),[X,G]=De(0),Y=Ie(null),Z=Ie(""),ee=x.slides.find(e=>e.id===S)??x.slides[0],te=x.slides.indexOf(ee);Se(()=>l(document,r(x)),[x]);const ne=Ie(n.version),ie=Ie(oe(n.document)),le=Ie(x);le.current=x;const[re,ae]=De(!1),ve=Ie(!1),ke=Ce(async()=>{const t=await g.get(n.id),i=oe(t.document),l=ie.current,r=le.current,o=e(l,r,i);return w({type:"rebase",rebase:t=>e(l,t,i)}),ie.current=i,ne.current=t.version,Ri(r,l)||ve.current||(ve.current=!0,Xe.info(f.merged)),o},[n.id,g,f.merged]),He=Ie(Promise.resolve()),Ge=je(),Qe=Ee({save:async t=>{await He.current.catch(()=>{});let i=t;for(let t=0;;t+=1)try{return ne.current=await g.save(n.id,i,ne.current),ie.current=i,void G(e=>e+1)}catch(n){if(!(n instanceof a)||t>=3)throw n;const l=ie.current;await ke(),i=e(l,i,ie.current)}},onFailure:(e,t)=>{e instanceof a?(Qe.stop(),ae(!0)):0===t&&Xe.error(f.saveFailed)}}),Ye=Ie(x),{push:Ze,flush:et}=Qe;Se(()=>{x!==Ye.current&&(Ye.current=x,Ri(x,ie.current)||Ze(x))},[x,Ze]),Se(()=>()=>{et()},[et]);const tt=Ce(()=>{b.comments?.list(n.id).then(_,()=>{})},[b.comments,n.id]);Se(tt,[tt]);const nt=Ne(()=>[...z],[z]),it=function(e,t,n,i){const[l,r]=xi([]),o=wi(null),s=wi(n);s.current=n;const a=wi(i);a.current=i,ki(()=>{if(!e.live)return;const n=e.live(t,e=>{if("saved"===e.event)return a.current.saved(e.payload.version);if("comments"===e.event)return a.current.comments();if("bye"===e.event)return r(t=>t.filter(t=>t.key!==e.payload.key));const{user:t,key:n,slide:i,selected:l}=e.payload;r(e=>[...e.filter(e=>e.key!==n),{key:n,user:t,slide:i,selected:l,color:Si(t.id)}]),"hello"===e.event&&o.current?.send({type:"presence",...s.current})});return o.current=n,n.send({type:"hello",...s.current}),()=>{n.close(),o.current=null,r([])}},[e,t]);const d=JSON.stringify(n);return ki(()=>{o.current?.send({type:"presence",...s.current})},[d]),l}(b,n.id,{slide:ee.id,selected:nt},{saved:e=>{e===ne.current||Date.parse(e)&&Date.parse(e)===Date.parse(ne.current)||(He.current=He.current.then(()=>Qe.hasPending()?void 0:ke()).catch(()=>{}))},comments:tt}),lt=it.filter(e=>e.slide===ee.id).map(e=>({key:e.key,name:e.user.name,color:e.color,selected:e.selected})),rt=Ce(e=>w({type:"commit",doc:e}),[]),ot=e=>rt(xe(x,ee.id,()=>e)),st=e=>ot(T(we(ee,z,e))),at=Ie(null),dt=e=>{N(e),I(new Set),W(null)},ct={text:C.text,accents:C.accents,shapeFill:x.theme?C.accents[0]:"#afa9ec",bodyFont:C.bodyFont},mt=e=>{ot({...ee,elements:[...ee.elements,e]}),I(new Set([e.id])),j("inspector")},ut=e=>mt(pe(e,ct)),ht=e=>{const t=pe("connector",ct);mt({...t,route:"elbow"===e?"elbow":"curved"===e?"curved":"straight",arrowEnd:"line"!==e,arrowStart:"double"===e||void 0})},pt={title:f.placeholderTitle,subtitle:f.placeholderSubtitle,body:f.placeholderBody},ft=(e=("title"===ee.layout?"titleBody":ee.layout??"titleBody"))=>{const t=o(e,C,pt);rt(ue(x,ee.id,t)),dt(t.id)},gt=()=>{ot(T(be(ee,z))),I(new Set)},vt=e=>{const t=$n(ee,z);switch(e.kind){case"align":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(0===i.length)return e;const l=1===new Set(i.map(e=>e.groupId??e.id)).size?jn:se(i),r=e=>e.groupId??e.id,o=new Map;for(const e of i){const t=r(e);o.set(t,o.has(t)?se([o.get(t),e]):e)}const s=e=>{switch(n){case"left":return{dx:l.x-e.x,dy:0};case"right":return{dx:l.x+l.w-e.x-e.w,dy:0};case"center":return{dx:l.x+(l.w-e.w)/2-e.x,dy:0};case"top":return{dx:0,dy:l.y-e.y};case"bottom":return{dx:0,dy:l.y+l.h-e.y-e.h};case"middle":return{dx:0,dy:l.y+(l.h-e.h)/2-e.y}}},a=new Map([...o].map(([e,t])=>[e,s(t)]));return we(e,t,e=>{const{dx:t,dy:n}=a.get(r(e));return ye(e,t,n)})}(ee,t,e.to),t));case"distribute":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(i.length<3)return e;const l=e=>"horizontal"===n?e.x:e.y,r=e=>"horizontal"===n?e.w:e.h,o=[...i].sort((e,t)=>l(e)-l(t)),s=o[0],a=o[o.length-1],d=o.reduce((e,t)=>e+r(t),0),c=(l(a)+r(a)-l(s)-d)/(o.length-1),m=new Map;let u=l(s);for(const e of o)m.set(e.id,u),u+=r(e)+c;return we(e,t,e=>"horizontal"===n?ye(e,m.get(e.id)-e.x,0):ye(e,0,m.get(e.id)-e.y))}(ee,t,e.axis),t));case"order":return ot({front:Tn,forward:de,backward:Fn,back:Ln}[e.to](ee,t));case"group":return ot(function(e,t){if(t.size<2)return e;const n=fe();return we(e,t,e=>({...e,groupId:n}))}(ee,t));case"ungroup":return ot(function(e,t){return we(e,t,({groupId:e,...t})=>t)}(ee,t));case"lock":return ot(function(e,t,n){return we(e,t,({locked:e,...t})=>n?{...t,locked:n}:t)}(ee,t,e.locked))}},yt=e=>{const t=ee.elements.filter(e=>z.has(e.id));if(0===t.length)return;const n=(i=t,JSON.stringify({type:Rn,elements:i}));var i;Z.current=n,navigator.clipboard?.writeText(n).catch(()=>{}),e&>()},wt=async()=>{const e=Bn(await(navigator.clipboard?.readText().catch(()=>""))||Z.current)??Bn(Z.current);if(!e)return;const t=Wn(ee,e);ot(t.slide),I(new Set(t.ids))},xt=()=>{const e=Wn(ee,ee.elements.filter(e=>z.has(e.id)));ot(e.slide),I(new Set(e.ids))},Ct=()=>{b.comments&&j("comments")},Nt=(e=te)=>{const t=window.open("about:blank","_blank","popup,width=1280,height=720");t&&(t.document.title=v),F({popup:t,at:e})},zt=Ie(()=>!1);zt.current=()=>!(E||0===z.size&&!B&&!U)&&(I(new Set),W(null),H(null),!0),Se(()=>Ve(()=>zt.current()),[]);const It=Je(),Dt=z.size>0,Mt=ee.elements.filter(e=>z.has(e.id)),Et=Dt&&Mt.every(e=>e.locked),At=[{type:"submenu",key:"order",label:f.order,disabled:!Dt,items:[{key:"front",label:f.bringToFront,onSelect:()=>vt({kind:"order",to:"front"})},{key:"forward",label:f.bringForward,onSelect:()=>vt({kind:"order",to:"forward"})},{key:"backward",label:f.sendBackward,onSelect:()=>vt({kind:"order",to:"backward"})},{key:"back",label:f.sendToBack,onSelect:()=>vt({kind:"order",to:"back"})}]},{type:"submenu",key:"align",label:f.align,disabled:!Dt,items:gn(f).map(({label:e,action:t})=>({key:e,label:e,onSelect:()=>vt(t)}))},{key:"group",label:f.group,disabled:z.size<2,onSelect:()=>vt({kind:"group"})},{key:"ungroup",label:f.ungroup,disabled:!Mt.some(e=>e.groupId),onSelect:()=>vt({kind:"ungroup"})},{key:"lock",label:Et?f.unlock:f.lock,disabled:!Dt,onSelect:()=>vt({kind:"lock",locked:!Et})},{type:"divider",key:"d-grid"},{type:"checkbox",key:"grid",label:f.grid,checked:O,onSelect:()=>K(e=>!e)}],Pt=It.state?.data?[{key:"cut",label:f.cut,onSelect:()=>yt(!0)},{key:"copy",label:f.copy,onSelect:()=>yt(!1)},{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"duplicate",label:f.duplicate,onSelect:xt},{key:"copy-style",label:f.copyStyle,onSelect:()=>{return Y.current=Mt[0]?"text"===(e=Mt[0]).type?{fontSize:e.fontSize,bold:e.bold,color:e.color,font:e.font}:"shape"===e.type?{fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth}:"connector"===e.type?{stroke:e.stroke,strokeWidth:e.strokeWidth}:{}:null;var e}},{key:"paste-style",label:f.pasteStyle,disabled:!Y.current,onSelect:()=>Y.current&&st(e=>function(e,t){if("text"===e.type){const n=A(e);return Q({...e,fontSize:t.fontSize??e.fontSize,bold:t.bold??e.bold,color:t.color??e.color,font:t.font},p(n,0,P(n).length,{size:void 0,bold:void 0,color:void 0,font:void 0}))}return"shape"===e.type?{...e,fill:t.fill??e.fill,stroke:t.stroke,strokeWidth:t.strokeWidth}:"connector"===e.type&&t.stroke?{...e,stroke:t.stroke,strokeWidth:t.strokeWidth??e.strokeWidth}:e}(e,Y.current))},{type:"divider",key:"d1"},...At.slice(0,5),...b.comments?[{type:"divider",key:"d2"},{key:"comment",label:f.comment,onSelect:Ct}]:[],{type:"divider",key:"d3"},{key:"delete",label:f.delete,danger:!0,onSelect:gt}]:[{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"new-slide",label:f.newSlide,onSelect:()=>ft()},{key:"skip",label:ee.skip?f.unskipSlide:f.skipSlide,onSelect:()=>ot({...ee,skip:!ee.skip||void 0})},...b.comments?[{key:"comment",label:f.comment,onSelect:Ct}]:[]],Ft=1===Mt.length&&"text"===Mt[0].type?Mt[0]:null,Tt=(e,t,n)=>ji(Ke,{"aria-label":e,onClick:n,children:ji(qe,{name:t,size:16})},e),Lt=e=>j(t=>t===e?"inspector":e),$t=U?U.doc.slides.find(e=>e.id===ee.id)??U.doc.slides[Math.min(te,U.doc.slides.length-1)]:ee;return $i("div",{className:"es-editor slides-editor",onKeyDown:e=>{if(E||U)return;if(e.target.closest('input, textarea, select, [contenteditable], [role="listbox"], [role="menu"], [role="dialog"]'))return;const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=z.size>0;if(t&&"z"===n)e.preventDefault(),w({type:e.shiftKey?"redo":"undo"});else if(t&&"y"===n)e.preventDefault(),w({type:"redo"});else if(t&&"a"===n)e.preventDefault(),I(new Set(ee.elements.filter(e=>!e.locked).map(e=>e.id)));else if(t&&"d"===n&&i)e.preventDefault(),xt();else if(t&&("c"===n||"x"===n)&&i)e.preventDefault(),yt("x"===n);else if(t&&"v"===n)e.preventDefault(),wt();else if(t&&"g"===n&&i)e.preventDefault(),vt({kind:e.shiftKey?"ungroup":"group"});else if(t&&e.altKey&&"m"===n)e.preventDefault(),Ct();else if(t&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&i){e.preventDefault();const t="ArrowUp"===e.key;vt({kind:"order",to:e.shiftKey?t?"front":"back":t?"forward":"backward"})}else if("Delete"!==e.key&&"Backspace"!==e.key||!i){if("Escape"===e.key)I(new Set),W(null);else if(e.key.startsWith("Arrow")&&i){e.preventDefault();const t=e.shiftKey?1:10,n="ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,i="ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0,l=new Set(ee.elements.filter(e=>z.has(e.id)&&!e.locked).map(e=>e.id));ot(T(we(ee,l,e=>ye(e,n,i)),l))}}else e.preventDefault(),gt()},tabIndex:-1,children:[$i(Pe,{children:[$i(Te,{children:[ji(Ae,{label:f.backToDecks,onClick:m,children:ji(qe,{name:"chevron-left",size:16})}),ji(Ae,{label:f.slidesPanel,state:D?"active":"inactive",onClick:()=>M(e=>!e),children:ji(qe,{name:"bars-3-bottom-left",size:16})}),ji("div",{className:"slides-title",children:ji(Ue,{"aria-label":f.deckName,value:v,onChange:e=>y(e.target.value),onBlur:()=>{const e=v.trim();e&&e!==n.title?g.rename(n.id,e).catch(()=>Xe.error(f.renameFailed)):y(e||n.title)}})}),ji(Fe,{...Me(Qe.state,Ge.save)}),ji(Le,{}),ji(Ae,{label:f.undo,disabled:0===k.past.length,onClick:()=>w({type:"undo"}),children:ji(qe,{name:"undo",size:16})}),ji(Ae,{label:f.redo,disabled:0===k.future.length,onClick:()=>w({type:"redo"}),children:ji(qe,{name:"redo",size:16})})]}),$i(Te,{kind:"right",children:[it.length>0&&ji("span",{className:"slides-visitors",title:f.editingNow(it.map(e=>e.user.name).join(", ")),children:ji($e,{size:"sm",max:4,children:[...new Map(it.map(e=>[e.user.id,e])).values()].map(e=>ji(Re,{name:e.user.name,size:"sm"},e.user.id))})}),b.versions&&ji(Ae,{label:f.versionHistory,state:"history"===L?"active":"inactive",onClick:()=>Lt("history"),children:ji(qe,{name:"clock",size:16})}),b.comments&&ji(Ae,{label:f.commentCount(kt(V).filter(e=>!e.first.resolvedAt).length),state:"comments"===L?"active":"inactive",onClick:()=>Lt("comments"),children:ji(qe,{name:"chat",size:16})}),ji(Oe,{"aria-label":f.export,trigger:$i("span",{className:"slides-export-trigger",children:[ji(qe,{name:"download",size:16}),f.export]}),items:[{key:"pptx",label:f.exportPptx,onSelect:()=>{Li(v,x).catch(()=>Xe.error(f.exportFailed))}},{key:"pdf",label:f.exportPdf,onSelect:()=>{(async()=>{const{deckToPdf:e}=await(import("./deckPdf-4RC7QJ45.js")),t=await e(x),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`${v.trim()||"Deck"}.pdf`,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)})().catch(()=>Xe.error(f.exportFailed))}}]}),ji(Be,{leftIcon:ji(qe,{name:"play",size:16}),onClick:()=>Nt(),children:f.present})]})]}),re&&$i("div",{className:"slides-conflict",role:"alert",children:[ji("span",{children:f.conflict}),ji(Be,{variant:"secondary",onClick:u,children:f.reload})]}),U&&$i("div",{className:"slides-conflict",role:"status",children:[ji("span",{children:f.previewVersion}),ji(Be,{variant:"secondary",onClick:()=>H(null),children:f.closePreview})]}),$i("div",{className:"slides-body",children:[D&&ji(Mn,{slides:x.slides,currentId:ee.id,numbers:!!x.slideNumbers,visitors:it,onShow:dt,onAdd:()=>ft(),onMove:(e,t)=>rt(he(x,e,t)),onDuplicate:e=>{const t=x.slides.find(t=>t.id===e);if(!t)return;const n=ce(t);rt(ue(x,e,n)),dt(n.id)},onDelete:e=>{const t=ge(x,e);rt(t),e===ee.id&&dt(t.slides[Math.min(te,t.slides.length-1)].id)},onSkip:e=>rt(xe(x,e,e=>({...e,skip:!e.skip||void 0})))}),$i("div",{className:"slides-centre",children:[$i("div",{className:"slides-toolbar",children:[ji(Oe,{"aria-label":f.newSlide,trigger:$i("span",{className:"slides-export-trigger",children:[f.newSlide,ji(qe,{name:"chevron-down",size:14})]}),items:[{type:"label",key:"l",label:f.layouts},...t.map(e=>({key:e,label:Bi(f,e),onSelect:()=>ft(e)}))]}),Tt(f.addText,"type",()=>ut("text")),Tt(f.addImage,"image",()=>ut("image")),ji(Wi,{onPick:e=>mt({...pe("shape",ct),shape:e})}),ji(Oe,{"aria-label":f.addLine,trigger:ji(qe,{name:"line-solid",size:16}),items:[{key:"line",label:f.lineStraight,onSelect:()=>ht("line")},{key:"arrow",label:f.lineArrow,onSelect:()=>ht("arrow")},{key:"double",label:f.lineDoubleArrow,onSelect:()=>ht("double")},{key:"elbow",label:f.connectorElbow,onSelect:()=>ht("elbow")},{key:"curved",label:f.connectorCurved,onSelect:()=>ht("curved")}]}),Tt(f.addTable,"table",()=>ut("table")),Tt(f.addChart,"chart-bar",()=>ut("chart")),Tt(f.addVideo,"block-video",()=>ut("video")),ji("span",{className:"slides-tool-gap"}),ji(Oe,{"aria-label":f.arrange,trigger:$i("span",{className:"slides-export-trigger",children:[f.arrange,ji(qe,{name:"chevron-down",size:14})]}),items:At}),ji(Be,{variant:"theme"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("theme"),children:f.theme}),ji(Be,{variant:"motion"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("motion"),children:f.motion})]}),Ft&&!U&&ji(hi,{element:Ft,editing:$,slides:x.slides,accents:C.accents,onBox:e=>ot(we(ee,new Set([Ft.id]),t=>e(t)))}),U?ji("div",{className:"slides-pane slides-preview",children:ji(h,{slide:$t,width:720,number:U.doc.slideNumbers?te+1:void 0})}):ji(Zn,{slide:ee,selected:z,onSelect:e=>I(e),onLive:e=>{at.current??=x,w({type:"live",doc:xe(at.current,ee.id,()=>e)})},onSettle:()=>{at.current&&w({type:"settle",from:at.current}),at.current=null},onCommit:ot,onEditing:R,onLink:()=>{document.querySelector(`[data-text-toolbar] button[aria-label="${CSS.escape(f.link)}"]`)?.click()},cells:B,onCells:W,onContextMenu:(e,t)=>It.open(e,t),visitors:lt,pins:b.comments?Oi(ee,V):[],onPin:e=>{q(e),j("comments")},grid:O,slideNumber:x.slideNumbers?te+1:void 0},ee.id),$i("label",{className:"slides-notes",children:[ji("span",{children:f.speakerNotes}),ji(_e,{rows:2,value:ee.notes,onChange:e=>ot({...ee,notes:e.target.value})})]})]}),"inspector"===L&&ji(yn,{slide:ee,selected:Mt,onChangeSlide:e=>ot({...ee,...e}),onChangeSelected:st,onAlign:e=>vt({kind:"align",to:e}),onForward:()=>vt({kind:"order",to:"forward"}),onDelete:gt,onArrange:vt,cells:B,accents:C.accents}),"theme"===L&&ji(yi,{doc:x,slide:ee,onTheme:e=>rt(i(x,e)),onDeck:e=>rt({...x,...e}),onSlide:e=>ot({...ee,...e})}),"motion"===L&&ji(bt,{slide:ee,slideNumber:te+1,selected:Mt,onSlide:e=>ot({...ee,...e}),onAllSlides:e=>rt({...x,slides:x.slides.map(t=>({...t,...e}))}),onPlay:()=>Nt(te)}),"comments"===L&&b.comments&&ji(St,{comments:V,slides:x.slides,slide:ee,selectedId:1===Mt.length?Mt[0].id:null,focusId:J,onAdd:async e=>{const t=await b.comments.add(n.id,e);_(e=>[...e,t])},onUpdate:(e,t)=>b.comments.update(n.id,e,t).then(t=>_(n=>n.map(n=>n.id===e?t:n)),()=>Xe.error(f.commentFailed)),onRemove:e=>b.comments.remove(n.id,e).then(()=>_(t=>t.filter(t=>t.id!==e&&t.parent!==e)),()=>Xe.error(f.commentFailed)),onShowSlide:dt}),"history"===L&&ji(jt,{deckId:n.id,previewing:U?.id??null,refreshKey:X,onPreview:(e,t)=>H(e?{id:e,doc:oe(t)}:null),onRestore:e=>{H(null);const t=oe(e);rt(t),t.slides.some(e=>e.id===ee.id)||dt(t.slides[0].id)}})]}),It.state&&ji(We,{...It.props,items:Pt,"aria-label":f.arrange}),E&&ji(tn,{slides:x.slides,startIndex:E.at,numbers:!!x.slideNumbers,fonts:r(x),popup:E.popup,onEnd:()=>F(null)})]})}export{Ki as default};
|