From 1a9d7abd4866098ec5bf6852d47a220f08222910 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Mon, 30 Nov 2026 22:22:47 -0500 Subject: [PATCH 1/2] fix(build): on Windows the desktop build tries the Tauri build once more when it stops The Windows release run built and signed the MSI, then stopped at "Verifying NSIS package" with "hash mismatch of downloaded file", as formMCP's did the same day. The nsis-3.11.zip on GitHub has exactly the SHA-1 that the pinned Tauri CLI 2.12.1 expects, so the run received a damaged download. Tauri checks it in memory and writes nothing, so a second tauri build downloads it again; the engine is already frozen and the Rust side built, so the retry costs about a minute. A second stop fails the build as before. --- setup/desktop_build.bat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/desktop_build.bat b/setup/desktop_build.bat index 4d1764e..06b332b 100644 --- a/setup/desktop_build.bat +++ b/setup/desktop_build.bat @@ -4,5 +4,9 @@ cd /d "%~dp0.." call setup\build_frontend.bat || exit /b 1 call setup\freeze_backend.bat || exit /b 1 if not exist src-tauri\icons\icon.ico call frontend\node_modules\.bin\tauri.cmd icon assets\formtxt_icon.png -o src-tauri\icons +call frontend\node_modules\.bin\tauri.cmd build %* && goto :built +echo [formtxt] the Tauri build stopped; trying once more in 15 seconds, since a tool Tauri downloads for the installers can arrive damaged ^(hash mismatch^) and the Rust side is already built +ping -n 16 127.0.0.1 >nul call frontend\node_modules\.bin\tauri.cmd build %* || exit /b 1 +:built echo [formtxt] bundles are in src-tauri\target\release\bundle From 73a8df14a64c9c929a02357176b3d820df7f3711 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Mon, 30 Nov 2026 22:24:26 -0500 Subject: [PATCH 2/2] chore(release): 0.39.1, the Windows build tries the Tauri build once more Version sites, as 0.39.0 did them: README.md (badge and line), backend/app/__init__.py, frontend/package.json, frontend/package-lock.json (the project's two fields), frontend/src/version.ts, src-tauri/Cargo.toml, src-tauri/Cargo.lock (formtxt's own version), src-tauri/tauri.conf.json, the current build version in backend/HASHOUT_LOG.md and frontend/HASHOUT_LOG.md, and the CHANGELOG entry, which says that 0.39.0 was never published and that this release carries it, plus the second tauri build in setup/desktop_build.bat. The three browser demos (demo, demos/paper, demos/newsletter) are rebuilt by npm run demo and carry 0.39.1. --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- backend/HASHOUT_LOG.md | 2 +- backend/app/__init__.py | 2 +- demo/assets/demo.js | 2 +- demos/newsletter/assets/demo.js | 2 +- demos/paper/assets/demo.js | 2 +- frontend/HASHOUT_LOG.md | 4 ++-- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- frontend/src/version.ts | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 14 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 920f300..8079cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.39.1 · 2026-11-30 + +A small fix release for Windows. 0.39.0 was never published, so this release also carries everything listed under 0.39.0. + +- Windows: the desktop build tries once more when it stops, because a tool that Tauri downloads to make the setup.exe installer can arrive damaged. The 0.39.0 Windows release stopped this way, with "hash mismatch of downloaded file". + ## 0.39.0 · 2026-11-30 - A menu opened from the menu bar now always opens just under the bar and is at most three quarters of the window tall; the rest of it scrolls. Before, in a short window a menu could run past the bottom of the window, and a long submenu could cover the menu bar. diff --git a/README.md b/README.md index d85ad26..31d81c7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

- version 0.39.0 + version 0.39.1 TypeScript and Vite Python and FastAPI macOS, Windows, Linux @@ -24,7 +24,7 @@ Run it from source

-Version 0.39.0 · Apache-2.0 · macOS, Windows, Linux (browser, or the desktop app built with ./build_app) +Version 0.39.1 · Apache-2.0 · macOS, Windows, Linux (browser, or the desktop app built with ./build_app)
diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index f5a15b9..8348826 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -2,7 +2,7 @@ Living log of comment content, rationale and removed code for the engine. Source files stay comment-free; read this first, then edit surgically. -Current build version: v0.39.0 +Current build version: v0.39.1 Last updated: 2026-11-19 · v0.36.0: one engine per data folder, the engine's log file, an engine started alone opens the app, the engine leaving with its app by the family's watch, and in the shell the failure sentence before the loading window closes (sections below, headed "after v0.35.0" as they were written). Before: 2026-11-19 · v0.35.0: the family's finder for the agent programs at 1.0.1, an Antigravity tab, agents install for Antigravity, tests that find only stand-ins, the engine starting with no output streams (sections below, headed "after v0.34.0" as they were written). Before: 2026-11-19 · v0.34.0: database merge data, list reports and report run, changes only from the window, the outside-agent question with Allow once and Block all agents, Codex and Cursor tabs (sections below, headed "v0.34.0, not released yet" as they were written). Before: 2026-11-17 · v0.33.0 has no change in the engine; the AMOLED Black theme is in the frontend log. Before: 2026-11-14 · v0.32.1: the macOS freeze keeps the Python library loadable inside the app bundle (section below). Before: 2026-11-13 · v0.32.0 has no change in the engine; `setup/icon_rules.py` also checks the insertable icon and emoji data (frontend log). Before: 2026-11-13 · v0.31.0: MCP, terminals and Claude Code in the engine, the agent kit (section below). Before: 2026-11-13 · the v0.30.8 fixes to the engine entry and scripts (section below). Before: 2026-11-12 · the v0.30.7 review fixes. Before: 2026-10-31 · .js, .mjs and .css keep their types on Windows; the Linux packages pull in the media plugins. Before: macOS engine signed for notarization --- diff --git a/backend/app/__init__.py b/backend/app/__init__.py index e72781a..9442842 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -1 +1 @@ -__version__ = "0.39.0" +__version__ = "0.39.1" diff --git a/demo/assets/demo.js b/demo/assets/demo.js index 45858d1..4a5dbe2 100644 --- a/demo/assets/demo.js +++ b/demo/assets/demo.js @@ -4900,7 +4900,7 @@ if (text) { } `,Ryn=gt.run.bind(gt),x7=null,zyn=0,Byn=0,S7=[],C7=null,w7=null}));async function T7(){let e=await ke.get(`/collab/addins`);Yyn=e.addins,Xyn=e.permissions,Zyn=e.folder,Uyn()}function Uyn(){E7&&(N(E7.folder,Zyn),Min(E7.list,Yyn,{key:e=>e.id,create:e=>{let t=P(`

`);return t.dataset.id=e.id,t},update:(e,t)=>{e.dataset.id=t.id,N(e.querySelector(`.ft-add-name`),t.name),N(e.querySelector(`.ft-add-ver`),`${t.version}${t.bundled?`, bundled`:``}${t.author?`, ${t.author}`:``}`),N(e.querySelector(`.ft-add-desc`),t.description),N(e.querySelector(`.ft-add-perms`),t.permissions.length?`Can: ${t.permissions.map(e=>Xyn[e]??e).join(`; `)}${t.permissions.includes(`commands`)?` (${(t.commandPrefixes.length?t.commandPrefixes:Qyn).join(` `)})`:``}`:`Needs no permissions`);let n=e.querySelector(`[data-act="toggle"]`);n&&n.checked!==t.enabled&&(n.checked=t.enabled);let r=e.querySelector(`[data-act="run"]`);r&&(r.disabled=!t.enabled),Ke(e.querySelector(`[data-act="remove"]`),t.bundled)}}))}async function Wyn(e){let t=Yyn.find(t=>t.id===e);if(!t)throw Error(`No add-in has that id. List them with collab.addin.list.`);if(!t.enabled)throw Error(`${t.name} is disabled. Enable it in Tools > Add-ins first.`);let n=await fetch(`/api/collab/addins/${encodeURIComponent(e)}/script`);if(!n.ok)throw Error(`The add-in script could not be loaded.`);let r=await n.text(),i=``,a={read:t.permissions.includes(`read`),write:t.permissions.includes(`write`),display:t.permissions.includes(`display`),prefixes:t.permissions.includes(`commands`)?t.commandPrefixes.length?t.commandPrefixes:Qyn:[]};return await myn(Jyn,r,a,{run:yyn,show:e=>{i=e,E7&&(N(E7.out,e),Ke(E7.out,!1))}}),i&&(!E7||E7.d.root.hidden)&&it(i.split(` `).slice(0,4).join(` | `)),{id:e,output:i}}async function Gyn(e){let t=await ke.post(`/collab/addins/install`,{filename:e.name,data:await Vin(e)});return await T7(),it(`Installed ${t.name}. Review its permissions, then tick Enabled.`),t}function Kyn(){if(!E7){let e=new pn(`Add-ins`,640);e.body.appendChild(P(`

Add-ins are small scripts that run in a sandbox with only the permissions they declare. There is no online store: install an add-in file, or put a folder with manifest.json and main.js in the add-ins folder.

`));let t=P(`

`),n=P(`
`),r=P(``),i=P(``);e.body.append(t,n,r,i),e.button(`Install from file`,``,()=>i.click()),e.button(`Close`,`primary`,()=>e.close()),E7={d:e,list:n,out:r,folder:t,file:i},i.addEventListener(`change`,()=>{let e=i.files?.[0];i.value=``,e&&Gyn(e).catch(e=>it(l5(e),`error`))}),n.addEventListener(`change`,e=>{let t=e.target,n=t.closest(`[data-id]`)?.dataset.id;t.dataset.act===`toggle`&&n&&ke.post(`/collab/addins/${encodeURIComponent(n)}/enabled`,{enabled:t.checked}).then(T7).catch(e=>it(l5(e),`error`))}),n.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-act]`),n=t?.closest(`[data-id]`)?.dataset.id;t&&n&&(t.dataset.act===`run`?(Ke(r,!0),Wyn(n).catch(e=>it(l5(e),`error`))):t.dataset.act===`remove`&&ke.del(`/collab/addins/${encodeURIComponent(n)}`).then(T7).catch(e=>it(l5(e),`error`)))})}E7.d.open(),T7().catch(e=>it(l5(e),`error`))}function qyn(e,t){Jyn=t,T7().catch(()=>void 0),e.register({id:`collab.addins`,label:`Add-ins`,group:`Tools`,description:`Open the add-ins window: bundled samples and add-ins from the add-ins folder, with permissions, enable, disable and install from a file.`,run:()=>(Kyn(),!0)}),e.register({id:`collab.addin.list`,label:`List add-ins`,group:`Tools`,description:`List add-ins with their permissions and whether they are enabled.`,run:async()=>(await T7(),Yyn.map(e=>({id:e.id,name:e.name,enabled:e.enabled,permissions:e.permissions})))}),e.register({id:`collab.addin.run`,label:`Run add-in`,group:`Tools`,description:`Run an enabled add-in in its sandbox with the permissions it declares.`,params:[{name:`id`,type:`string`,description:`Add-in id, from collab.addin.list`}],run:async e=>(await T7(),Wyn(String(e.id??``)))}),e.register({id:`collab.addin.enable`,label:`Enable or disable add-in`,group:`Tools`,description:`Turn an add-in on or off.`,params:[{name:`id`,type:`string`,description:`Add-in id`},{name:`enabled`,type:`boolean`,description:`true to enable, false to disable`}],run:async e=>(await ke.post(`/collab/addins/${encodeURIComponent(String(e.id??``))}/enabled`,{enabled:e.enabled!==!1}),await T7(),!0)}),e.register({id:`collab.addin.install`,label:`Install add-in`,group:`Tools`,description:`Install an add-in from a manifest (JSON text) and a script; it starts disabled.`,params:[{name:`manifest`,type:`string`,description:`JSON with id, name, version, description, permissions (read, write, commands, display) and optional commandPrefixes`},{name:`script`,type:`string`,description:`JavaScript using the ft object`}],run:async e=>{let t=JSON.stringify({...JSON.parse(String(e.manifest??`{}`)),script:String(e.script??``)}),n=await ke.post(`/collab/addins/install`,{filename:`add-in.json`,data:btoa(unescape(encodeURIComponent(t)))});return await T7(),{id:n.id}}}),r8(`Tools`,[{cmd:`collab.addins`,label:`Add-ins...`}])}var Jyn,Yyn,Xyn,Zyn,E7,Qyn,$yn=o((()=>{Ae(),mn(),tt(),ot(),f8(),Hyn(),vyn(),Kin(),Yyn=[],Xyn={},Zyn=``,E7=null,Qyn=[`format.`,`paragraph.`]}));function ebn(e){return Array.isArray(e)?e.map(ebn):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([e])=>e!==`id`).map(([e,t])=>[e,ebn(t)])):e}function tbn(e){let t=[];return e.forEach((e,n)=>{e.type===da.nodes.component&&t.push({pos:n,node:e})}),t}function nbn(e,t){if(e.type===da.nodes.image)return e.attrs.from||!t?e:e.type.create({...e.attrs,from:t},null,e.marks);if(e.isLeaf)return e;let n=[];return e.forEach(e=>n.push(nbn(e,t))),e.copy(xn.fromArray(n))}function rbn(e,t){let n=O7.docId();return Ea(e).filter(e=>vbn.has(e.type.name)).map(e=>t&&t!==n?nbn(e,t):e)}function ibn(){if(Sbn&&Sbn.readyState<=WebSocket.OPEN)return;let e=new WebSocket(Iin(`/collab/components/live`));Sbn=e,e.onopen=()=>{Cbn=0},e.onmessage=e=>{try{sbn(JSON.parse(String(e.data)))}catch{}},e.onclose=()=>{if(Sbn!==e)return;Sbn=null;let t=O7.view;t&&tbn(t.state.doc).length&&(Cbn=Math.min(Cbn+1,5),window.setTimeout(ibn,1e3*2**Cbn))}}function abn(e,t,n){let r=k7(n.blocks),i=e.state.tr,a=!1;for(let{pos:o,node:s}of tbn(e.state.doc).reverse()){if(s.attrs.cid!==t||xbn.has(t)&&k7(Tbn(s))!==r||k7(Tbn(s))===r&&s.attrs.name===n.name)continue;let e=rbn(n.blocks,n.source??``);e.length&&(i=i.replaceWith(o+1,o+s.nodeSize-1,e),i=i.setNodeMarkup(o,void 0,{...s.attrs,name:n.name,rev:n.rev}),a=!0)}D7.set(t,r),a&&e.dispatch(i.setMeta(`componentSync`,!0).setMeta(`addToHistory`,!1).setMeta(`paste`,!0))}function obn(e,t){let n=e.state.tr,r=!1;for(let{pos:i,node:a}of tbn(e.state.doc).reverse())a.attrs.cid===t&&(n=n.replaceWith(i,i+a.nodeSize,a.content),r=!0);D7.delete(t),r&&e.dispatch(n.setMeta(`componentSync`,!0))}function sbn(e){let t=O7.view;if(!t)return;let n=String(e.id??``);e.t===`component`?abn(t,n,{name:String(e.name??``),rev:Number(e.rev)||0,source:String(e.source??``),blocks:e.blocks}):e.t===`component-gone`&&obn(t,n)}function cbn(e){xbn.delete(e);let t=O7.view;if(!t)return;let n=D7.get(e),r=[],i=``,a=``;for(let{node:o}of tbn(t.state.doc)){if(o.attrs.cid!==e)continue;let t=Tbn(o);if(k7(t)!==n){r=t,i=k7(t),a=String(o.attrs.name);break}}i&&(D7.set(e,i),ke.put(`/collab/components/${encodeURIComponent(e)}`,{name:a,blocks:r,source:O7.docId()}).catch(e=>it(`Could not update the component: ${e.message}`,`error`)))}function lbn(e){window.clearTimeout(xbn.get(e)),xbn.set(e,window.setTimeout(()=>cbn(e),450))}async function ubn(){let e=O7.view;if(!e)return;let t=tbn(e.state.doc);if(!t.length)return;ibn();let n=[...new Set(t.map(e=>String(e.node.attrs.cid)))];for(let r of n)try{let t=await ke.get(`/collab/components/${encodeURIComponent(r)}`);O7.view===e&&abn(e,r,t)}catch{let e=t.find(e=>e.node.attrs.cid===r);e&&D7.set(r,k7(Tbn(e.node)))}}function dbn(e){let{selection:t}=e,{$from:n,$to:r}=t;if(t instanceof Gn&&t.$from.depth===0)return{from:t.from,to:t.to};if(n.depth===0||r.depth===0)throw Error(`Select some text first.`);return{from:n.before(1),to:r.after(1)}}async function fbn(e){let t=O7.view;if(!t)throw Error(`Open a document first.`);let{from:n,to:r}=dbn(t.state),i=[];if(t.state.doc.nodesBetween(n,r,(e,t)=>t>=n&&t+e.nodeSize<=r&&e.type.name!==`doc`?(i.push(e),!1):!0),!i.length)throw Error(`Select some text first.`);if(i.some(e=>!vbn.has(e.type.name)))throw Error(`A component can hold paragraphs, code and tables.`);let a=da.nodes.component.create({},i),o=Tbn(a),s=e.trim()||i[0].textContent.trim().slice(0,40)||`Component`,l=await ke.post(`/collab/components`,{name:s,blocks:o,source:O7.docId()});D7.set(l.id,k7(o));let u=da.nodes.component.create({cid:l.id,name:l.name,rev:l.rev,src:O7.docId()},i);return bbn.add(u),t.dispatch(t.state.tr.replaceWith(n,r,u).setMeta(`componentSync`,!0)),ibn(),{id:l.id,name:l.name}}async function pbn(e){let t=O7.view;if(!t)throw Error(`Open a document first.`);let n=await ke.get(`/collab/components/${encodeURIComponent(e)}`),r=rbn(n.blocks,n.source??``);if(!r.length)throw Error(`That component is empty.`);let i=da.nodes.component.create({cid:n.id,name:n.name,rev:n.rev,src:n.source??``},r),{$to:a}=t.state.selection,o=a.depth>=1?a.after(1):a.pos;return D7.set(n.id,k7(n.blocks)),bbn.add(i),t.dispatch(t.state.tr.insert(o,i).setMeta(`componentSync`,!0).setMeta(`paste`,!0).scrollIntoView()),ibn(),{id:n.id,name:n.name}}function mbn(){let e=O7.view;if(!e)throw Error(`Open a document first.`);let{$from:t}=e.state.selection;for(let n=t.depth;n>=1;n--){let r=t.node(n);if(r.type===da.nodes.component){let i=t.before(n);return e.dispatch(e.state.tr.replaceWith(i,i+r.nodeSize,r.content)),!0}}throw Error(`Put the cursor inside a component first.`)}async function hbn(){if(!A7)return;let{components:e}=await ke.get(`/collab/components`);Min(A7.list,e,{key:e=>e.id,create:e=>{let t=P(`
`);return t.dataset.id=e.id,t},update:(e,t)=>{e.dataset.id=t.id,e.dataset.name=t.name,N(e.querySelector(`.ft-cmp-name`),t.name),N(e.querySelector(`.ft-cmp-meta`),`${t.blocks} block${t.blocks===1?``:`s`}, revision ${t.rev}`)}}),A7.note.hidden=e.length>0}function gbn(){if(!A7){let e=new pn(`Components`,560);e.body.appendChild(P(`

A component is a block of text or a table kept in your library. Insert it into any document; an edit in one place updates every copy, on open and live while documents are open.

`));let t=P(``);e.field(`Save the selection as a component`,t);let n=P(``);e.body.appendChild(n);let r=P(`
`),i=P(`

No components yet. Select some text and save it as a component.

`);e.body.append(P(`

In your library

`),r,i),e.button(`Close`,`primary`,()=>e.close()),n.addEventListener(`click`,()=>{fbn(t.value).then(e=>(it(`Saved ${e.name}.`),t.value=``,hbn())).catch(e=>it(l5(e),`error`))}),r.addEventListener(`click`,t=>{let n=t.target.closest(`[data-act]`),r=n?.closest(`[data-id]`);if(!n||!r?.dataset.id)return;let i=r.dataset.id;if(n.dataset.act===`insert`)pbn(i).then(()=>e.close()).catch(e=>it(l5(e),`error`));else if(n.dataset.act===`delete`)ke.del(`/collab/components/${encodeURIComponent(i)}`).then(hbn).catch(e=>it(l5(e),`error`));else if(n.dataset.act===`rename`){let e=window.prompt(`Component name`,r.dataset.name??``);e?.trim()&&ke.put(`/collab/components/${encodeURIComponent(i)}`,{name:e.trim()}).then(hbn).catch(e=>it(l5(e),`error`))}}),A7={d:e,list:r,note:i,name:t}}A7.d.open(A7.name),hbn().catch(e=>it(l5(e),`error`))}function _bn(e,t){O7=t,Ci(Ebn),e.register({id:`collab.component.manage`,label:`Components`,group:`Share`,description:`Open the library of components: blocks you insert into many documents and edit in one place.`,run:()=>(gbn(),!0)}),e.register({id:`collab.component.create`,label:`Save selection as component`,group:`Share`,description:`Save the selected paragraphs or table as a live component in the library; the selection becomes the first copy.`,params:[{name:`name`,type:`string`,description:`Name of the component; defaults to the start of the text`}],run:e=>fbn(String(e.name??``))}),e.register({id:`collab.component.insert`,label:`Insert component`,group:`Share`,description:`Insert a copy of a library component after the current block.`,params:[{name:`id`,type:`string`,description:`Component id, from collab.component.list`}],run:e=>pbn(String(e.id??``))}),e.register({id:`collab.component.list`,label:`List components`,group:`Share`,description:`List the components in the library.`,run:async()=>(await ke.get(`/collab/components`)).components.map(e=>({id:e.id,name:e.name,rev:e.rev}))}),e.register({id:`collab.component.delete`,label:`Delete component`,group:`Share`,description:`Delete a component from the library; copies in documents become ordinary text.`,params:[{name:`id`,type:`string`,description:`Component id`}],run:async e=>(await ke.del(`/collab/components/${encodeURIComponent(String(e.id??``))}`),!0)}),e.register({id:`collab.component.unlink`,label:`Unlink component`,group:`Share`,description:`Turn the component copy at the cursor into ordinary text that no longer updates.`,run:()=>mbn()}),r8(`Share`,[{cmd:`collab.component.create`,label:`Save selection as component`},{cmd:`collab.component.manage`,label:`Components...`}])}var vbn,ybn,D7,bbn,xbn,Sbn,Cbn,O7,k7,wbn,Tbn,Ebn,A7,Dbn=o((()=>{kn(),Xn(),Ae(),mn(),tt(),ot(),Oa(),fa(),Ti(),f8(),Kin(),vbn=new Set([`paragraph`,`code_block`,`table`]),ybn=new Yn(`ftComponents`),D7=new Map,bbn=new WeakSet,xbn=new Map,Sbn=null,Cbn=0,k7=e=>JSON.stringify(ebn(e)),wbn=()=>O7.doc?.sections[0]?.id??``,Tbn=e=>Da(e,wbn()),Ebn=new Jn({key:ybn,view(){return Bin(()=>void ubn(),60)(),{update(e,t){if(e.state.doc!==t.doc)for(let{node:t}of tbn(e.state.doc)){if(bbn.has(t))continue;bbn.add(t);let e=String(t.attrs.cid);e&&D7.has(e)&&D7.get(e)!==k7(Tbn(t))&&lbn(e)}}}}}),A7=null}));function j7(e,t){let n=e.view;if(!n)throw Error(`Open a document first.`);n.dispatch(n.state.tr.setSelection(t(n.state)).scrollIntoView()),n.focus()}function Obn(){return[...Object.keys(Bbn),`heading 1 to 6`].sort()}function kbn(e){let t=e.toLowerCase().replace(/[.,!?;:]/g,` `).replace(/\s+/g,` `).trim();return t=t.replace(/^(please|computer)\s+/,``).replace(/\s+please$/,``),t=t.replace(/^heading (one|two|three|four|five|six)$/,(e,t)=>`heading ${Rbn[t]}`),(t===`bolt`||t===`bold text`)&&(t=`bold`),t}async function Abn(e){let t=kbn(e),n=/^heading ([1-6])$/.exec(t),r=n?{cmd:`paragraph.style`,params:{style:`Heading${n[1]}`}}:Bbn[t];if(!r)throw Error(`"${e}" is not a voice command. Say one of: ${Obn().join(`, `)}.`);return`local`in r?r.local(Vbn):await gt.run(r.cmd,r.params??{}),t}function jbn(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}async function Mbn(){return(await ke.get(`/collab/info`)).settings.voice}function Nbn(){return new Promise(e=>{let t=new pn(`Turn on voice commands`,480);t.body.appendChild(P(`

Voice commands use the speech recognition built into your browser. In Chrome and Edge the audio is sent to the browser maker's speech service to be turned into text. FormTxt itself sends nothing, and you can turn this off at any time.

`));let n=!1,r=r=>{n=!0,t.close(),e(r)};t.button(`Not now`,`ghost`,()=>r(!1)),t.button(`Turn on`,`primary`,()=>r(!0)),t.root.addEventListener(`click`,r=>{!n&&(r.target===t.root||r.target.closest(`[data-close]`))&&e(!1)}),t.open()})}function Pbn(){Ubn&&Ke(Ubn,!M7)}async function Fbn(){let e=jbn();if(!e)throw Error(`This browser has no speech recognition, so voice commands cannot listen. Chrome and Edge include it. You can still run a phrase with collab.voice.say.`);if(!await Mbn()){if(!await Nbn())return!1;await ke.post(`/collab/settings`,{voice:!0})}if(M7)return!0;let t=new e;return t.continuous=!0,t.interimResults=!1,t.lang=document.documentElement.lang||navigator.language||`en-US`,t.onresult=e=>{for(let t=e.resultIndex;tit(l5(e),`error`)))}},t.onerror=e=>{e.error!==`no-speech`&&e.error!==`aborted`&&(M7=!1,Pbn(),it(e.error===`not-allowed`||e.error===`service-not-allowed`?`Microphone access was blocked. Allow it in the browser to use voice commands.`:e.error===`network`?`The browser could not reach its speech service. Voice commands need it.`:`Speech recognition stopped: ${e.error}.`,`error`))},t.onend=()=>{if(M7&&Hbn===t)try{t.start()}catch{M7=!1,Pbn()}},Hbn=t,M7=!0,t.start(),Pbn(),!0}function Ibn(){M7=!1;let e=Hbn;return Hbn=null,e?.stop(),Pbn(),!1}function Lbn(e,t){Vbn=t;let n=document.querySelector(`.ft-editor .ft-menubar`);n&&(Ubn=P(``),n.appendChild(Ubn)),e.register({id:`collab.voice.toggle`,label:`Voice commands`,group:`Tools`,description:`Start or stop listening for spoken commands such as bold, select paragraph, new line, undo and go to end. Needs browser speech recognition and a one-time opt-in.`,run:async()=>M7?Ibn():Fbn()}),e.register({id:`collab.voice.say`,label:`Say a voice command`,group:`Tools`,description:`Run a spoken command from text, as if it had been heard: bold, italic, underline, undo, redo, select paragraph, select word, select all, go to end, go to start, new line, new paragraph, heading 1 to 6, bulleted list and more.`,params:[{name:`phrase`,type:`string`,description:`The phrase, for example select paragraph`}],run:async e=>({command:await Abn(String(e.phrase??``))})}),e.register({id:`collab.voice.list`,label:`List voice commands`,group:`Tools`,description:`List the phrases voice commands understand.`,run:()=>Obn()}),r8(`Tools`,[{cmd:`collab.voice.toggle`,label:`Voice commands`}])}var Rbn,zbn,Bbn,Vbn,Hbn,M7,Ubn,Wbn=o((()=>{pi(),Xn(),_t(),Ae(),mn(),tt(),ot(),fa(),f8(),Kin(),Rbn={one:`1`,two:`2`,three:`3`,four:`4`,five:`5`,six:`6`},zbn=e=>j7(e,e=>{let{$from:t}=e.selection,n=t.parent.textContent,r=t.parentOffset,i=r,a=r;for(;i>0&&/\S/.test(n[i-1]);)i--;for(;aj7(e,e=>new Kn(e.doc))},"select paragraph":{local:e=>j7(e,e=>{let{$from:t}=e.selection;return t.depth?Wn.create(e.doc,t.start(),t.end()):e.selection})},"select word":{local:zbn},"go to end":{local:e=>j7(e,e=>Un.atEnd(e.doc))},"go to start":{local:e=>j7(e,e=>Un.atStart(e.doc))},"go to the end":{local:e=>j7(e,e=>Un.atEnd(e.doc))},"go to the start":{local:e=>j7(e,e=>Un.atStart(e.doc))},"go to end of paragraph":{local:e=>j7(e,e=>{let{$from:t}=e.selection;return Wn.create(e.doc,t.depth?t.end():t.pos)})},"go to start of paragraph":{local:e=>j7(e,e=>{let{$from:t}=e.selection;return Wn.create(e.doc,t.depth?t.start():t.pos)})},"new line":{local:e=>{let t=e.view;t&&(t.dispatch(t.state.tr.replaceSelectionWith(da.nodes.hard_break.create()).scrollIntoView()),t.focus())}},"new paragraph":{local:e=>{let t=e.view;t&&(vle(t.state,t.dispatch),t.focus())}},delete:{local:e=>{let t=e.view;t&&(t.dispatch(t.state.tr.deleteSelection().scrollIntoView()),t.focus())}}},Hbn=null,M7=!1,Ubn=null}));function Gbn(e,t){gan(t),pon(e,t),_bn(e,t),Fyn(e,t),qyn(e,t),Lbn(e,t)}var Kbn=o((()=>{$yn(),Dbn(),Hyn(),Ban(),von(),Wbn()}));function qbn(e){return Array.from(e.querySelectorAll(`:scope > .ft-sheets > .ft-sheet`)).map(e=>({top:parseFloat(e.style.top)||0,height:parseFloat(e.style.height)||0,width:parseFloat(e.style.width)||e.offsetWidth}))}function Jbn(e,t){let n=document.querySelector(`.ft-editor .ft-pages`);if(!n)return;let r=document.createElement(`style`);r.id=`ft-multi-page`,document.head.appendChild(r);let i=!1,a=0,o=1,s=``,l={w:0,pitch:0,n:0},u=e=>e.every(t=>Math.abs(t.height-e[0].height)<.5&&Math.abs(t.width-e[0].width)<.5),d=()=>{let e=qbn(n);return!e.length||!u(e)?!1:(l={w:e[0].width,pitch:e[0].height+Xbn,n:e.length},!0)},f=()=>{if(!i)return;if(!d()){v(),it(`Multiple pages needs every page to be the same size; it was turned off.`,`info`);return}let e=`${l.w}|${l.pitch}|${l.n}`;if(e!==s){s=e;let t=[];for(let e=1;e .ft-sheets > .ft-sheet:nth-child(${e+1}){translate:${(e*(l.w+Xbn)).toFixed(2)}px ${(-e*l.pitch).toFixed(2)}px}`);r.textContent=t.join(` -`)}Ye(n,`--mp-w`,`${l.w.toFixed(2)}px`),Ye(n,`--mp-h`,`${l.pitch.toFixed(2)}px`),Ye(n,`--mp-total`,`${(l.n*l.w+(l.n-1)*Xbn).toFixed(2)}px`),n.dataset.multi!==`on`&&(n.dataset.multi=`on`)},p=t.paginator,m=p.beforeMeasure;p.beforeMeasure=(e,t)=>{n.dataset.multi===`on`&&delete n.dataset.multi,m?.(e,t)};let h=p.onLayout;p.onLayout=()=>{n.dataset.multi===`on`&&delete n.dataset.multi,h?.(),f()};let g=e=>{let t=(n.closest(`.ft-scroll`)?.clientWidth??window.innerWidth)-48;return Math.max(.25,Math.min(1,t/(e*l.w+(e-1)*Xbn)))},_=e=>n.dataset.mode===`pageless`?(it(`Multiple pages works in print layout.`,`info`),!1):d()?(i||(o=Number(t.zoom)||1),i=!0,a=Math.max(1,Math.min(8,Math.round(e)||2)),t.setZoom(g(Math.min(a,l.n))),f(),!0):(it(`Multiple pages needs every page to be the same size.`,`info`),!1),v=()=>{i&&(i=!1,delete n.dataset.multi,t.setZoom(o))};wi(()=>{i&&(i=!1,delete n.dataset.multi)}),e.register({id:`view.multiPage`,label:`Multiple pages`,group:`View`,description:`Show pages side by side, scaled to fit the window, and keep editing; run again to go back to one page.`,params:[{name:`pages`,type:`number`,description:`How many pages to fit across the window (1 to 8, default 2)`},{name:`on`,type:`boolean`,description:`Turn on or off instead of toggling`}],run:e=>(e.on===void 0?!i:e.on)?{on:_(Number(e.pages)||a||2),pages:l.n,zoom:Math.round(t.zoom*100)}:(v(),{on:!1})}),e.register({id:`view.onePage`,label:`One page`,group:`View`,description:`Leave the multiple-page view and fit one page across the window.`,run:()=>(v(),!0)});let y=!1,b=e=>{let r=t.section()?.margins;Ye(n,`--grid-step`,`${(e*Ybn).toFixed(2)}px`),Ye(n,`--grid-top`,`${((r?.top??72)*Ybn).toFixed(1)}px`),Ye(n,`--grid-bottom`,`${((r?.bottom??72)*Ybn).toFixed(1)}px`),Ye(n,`--grid-left`,`${((r?.left??72)*Ybn).toFixed(1)}px`),Ye(n,`--grid-right`,`${((r?.right??72)*Ybn).toFixed(1)}px`)},x=18;e.register({id:`view.gridlines`,label:`Gridlines`,group:`View`,description:`Show or hide gridlines over the page body to line up text, pictures and shapes. Gridlines are not printed.`,params:[{name:`on`,type:`boolean`,description:`Show or hide instead of toggling`},{name:`spacing`,type:`number`,description:`Grid spacing in points (default 18)`}],run:e=>(typeof e.spacing==`number`&&e.spacing>=4&&e.spacing<=144&&(x=e.spacing),y=e.on===void 0?!y:!!e.on,b(x),y?n.dataset.grid=`on`:delete n.dataset.grid,{on:y,spacing:x})}),wi(()=>{y&&b(x)}),r8(`View`,[{cmd:`view.multiPage`,label:`Multiple pages`,params:{on:!0,pages:2}},{cmd:`view.multiPage`,label:`Multiple pages, three across`,params:{on:!0,pages:3}},{cmd:`view.onePage`,label:`One page`},{cmd:`view.gridlines`,label:`Gridlines`}])}var Ybn,Xbn,Zbn=o((()=>{tt(),ot(),f8(),Ti(),Ybn=96/72,Xbn=24}));function Qbn(e,t){c7t();for(let n of $bn)n(e,t)}var $bn,exn=o((()=>{f8(),Tln(),Nun(),Xfn(),rpn(),umn(),sgn(),W_n(),cyn(),Kbn(),Zbn(),$bn=[Sln,kun,Yfn,npn,lmn,ogn,V_n,syn,Gbn,Jbn]}));async function txn(){let e=await fetch(`/api/notices`);if(!e.ok)throw Error(e.statusText);return e.text()}function nxn(){let e=P(`
Third-party notices
Loading the notices...
`),t=Ge(e,`.ft-wc-notices-text`),n=!1;return e.addEventListener(`toggle`,()=>{e.open&&!n&&(n=!0,txn().then(e=>N(t,e)).catch(()=>{n=!1,N(t,rxn)}))}),e}var rxn,ixn=o((()=>{tt(),rxn=`The notices could not be loaded. THIRD-PARTY-NOTICES.txt beside the app holds the same text.`})),axn,oxn=o((()=>{axn=`0.39.0`}));function sxn(e,t){if(t>0){for(let t of fxn)if(t>e+.01)return t;return Math.min(400,(Math.floor(e/10)+1)*10)}if(e<=8.01)return Math.max(1,Math.ceil(e-.01)-1);if(e>72)return Math.max(72,(Math.ceil(e/10)-1)*10);let n=fxn[0];for(let t of fxn)tt??=e()}function cxn(e,t=``,n=``){let r=P(``);return e===`checkbox`?r.checked=t===`true`:r.value=t,r}function lxn(e,t){let n=P(``);return n.value=t,n}function uxn(e,t,n){for(let e of t)e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),n())})}function dxn(e,t){let n=(t,n,r,i,a,o=[],s=[])=>{e.has(t)||e.register({id:t,label:n,group:r,description:i,run:a,params:o,keys:s})},r=()=>I7(t.view),i=e=>{throw Error(e)},a=()=>t.root.querySelector(`.ft-scroll`),o=(t,n={})=>e.run(t,n),s=(e,t,n)=>{Promise.resolve().then(()=>o(t,n)).then(()=>e.close()).catch(e=>it(e.message,`error`))},l=e=>Number(t.resolvedStyle(e).run.size)||11,u=e=>{let t=r(),{state:n}=t,i=da.marks.size,a=n.tr,o=0;if(n.selection.empty){let t=n.selection.$from,r=n.storedMarks??t.marks();o=sxn(Number(r.find(e=>e.type===i)?.attrs.pt)||l(String(t.parent.attrs.style??`Normal`)),e),a.setStoredMarks(i.create({pt:o}).addToSet(r.filter(e=>e.type!==i)))}else for(let t of n.selection.ranges)n.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,s)=>{if(!r.isText)return!0;let u=Math.max(t.$from.pos,s),d=Math.min(t.$to.pos,s+r.nodeSize);return u>=d||(o=sxn(Number(r.marks.find(e=>e.type===i)?.attrs.pt)||l(String(n.doc.resolve(s).parent.attrs.style??`Normal`)),e),a.addMark(u,d,i.create({pt:o}))),!1});return t.dispatch(a),t.focus(),{size:o}};n(`format.growFont`,`Grow font`,`Format`,`Step the font size of the selection up to the next size in the list (8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72, then by 10).`,()=>u(1),[],[`Ctrl+Shift+>`]),n(`format.shrinkFont`,`Shrink font`,`Format`,`Step the font size of the selection down to the previous size in the list.`,()=>u(-1),[],[`Ctrl+Shift+<`]);let d=!1,f=null,p=null,m=e=>{if(f?.doc===e)return f.set;let t=[];return e.descendants((e,n)=>{if(t.length>=hxn)return!1;if(e.type===da.nodes.hard_break)return t.push(Wr.widget(n,()=>{let e=document.createElement(`span`);return e.className=`ft-mark-br`,e.textContent=`↵`,e},{side:-1,key:`br`})),!1;if(!e.isText)return!0;let r=e.text??``;for(let e=0;e{d=e,He(t.root,`ft-marks`,e);let n=t.view;p&&p!==n&&p.setProps({decorations:void 0}),n&&(n.setProps({decorations:e?e=>m(e.doc):void 0}),p=n),e||(f=null),an()};rn(`view.formattingMarks`,{checked:()=>d}),n(`view.formattingMarks`,`Show formatting marks`,`View`,`Show or hide paragraph marks, spaces as dots, tabs as arrows, line breaks and page, section and column break markers; the marks are not part of the document and do not print.`,e=>(h(e.on===void 0?!d:!!e.on),{on:d}),[{name:`on`,type:`boolean`,description:`Show or hide instead of toggling`}],[`Ctrl+*`]);let g=`formtxt.darkPage`,_=!1;try{_=localStorage.getItem(g)===`1`}catch{_=!1}let v=e=>{_=e;let t=document.documentElement;e?t.hasAttribute(`data-page-dark`)||t.setAttribute(`data-page-dark`,``):t.hasAttribute(`data-page-dark`)&&t.removeAttribute(`data-page-dark`);try{localStorage.setItem(g,e?`1`:`0`)}catch{}an()};_&&v(!0),rn(`view.darkPage`,{checked:()=>_}),n(`view.darkPage`,`Dark page`,`View`,`Show the page dark with light text, inverting black and white and keeping colours and pictures recognisable. It only changes how the page looks on screen, separate from the app theme; the document, printing and exports keep their real colours.`,e=>(v(e.on===void 0?!_:!!e.on),{on:_}),[{name:`on`,type:`boolean`,description:`Turn on or off instead of toggling`}]);let y=e=>{let n=I7(t.doc);for(let r of[...n.sections].reverse())t.updateSectionById(r.id,e)},b=N7(()=>{let e=new pn(`Watermark`,440),t=P(`
`),n=cxn(`text`,``,`placeholder="Watermark text" spellcheck="false" maxlength="40"`);for(let e of pxn){let r=P(``);N(r,e),r.addEventListener(`click`,()=>{n.value=e}),t.appendChild(r)}e.body.appendChild(t),e.field(`Text`,n);let r=()=>s(e,`design.watermark`,{text:n.value});return e.button(`Remove watermark`,`ghost`,()=>s(e,`design.watermark`,{preset:`remove`})),e.button(`Cancel`,`ghost`,()=>e.close()),e.button(`Apply`,`primary`,r),uxn(e,[n],r),{d:e,text:n}});n(`design.watermark`,`Watermark`,`Layout`,`Put a text watermark on every page, or remove it; presets: ${pxn.join(`, `)}. With no parameters, opens a dialog.`,e=>{if(e.text===void 0&&e.preset===void 0){let e=b();return e.text.value=String(t.doc?.settings?.watermark??``),e.d.open(e.text),!0}let n=String(e.preset??``).trim(),r=e.text===void 0?n:String(e.text).trim();if(/^(remove|none|off)$/i.test(n)&&e.text===void 0&&(r=``),e.text===void 0&&n&&!/^(remove|none|off)$/i.test(n)){let e=pxn.find(e=>e.toLowerCase()===n.toLowerCase());e||i(`preset must be one of ${pxn.join(`, `)} or remove.`),r=e}return t.updatePage({},{watermark:r.slice(0,40)}),{watermark:r.slice(0,40)}},[{name:`text`,type:`string`,description:`Watermark text; empty removes it`},{name:`preset`,type:`string`,description:`${pxn.join(`, `)} or remove`}]);let x=N7(()=>{let e=new pn(`Page colour`,360),t=cxn(`color`,`#ffffff`);return e.field(`Colour`,t),e.button(`No colour`,`ghost`,()=>s(e,`design.pageColor`,{color:``})),e.button(`Cancel`,`ghost`,()=>e.close()),e.button(`Apply`,`primary`,()=>s(e,`design.pageColor`,{color:t.value})),{d:e,color:t}});n(`design.pageColor`,`Page colour`,`Layout`,`Set the background colour of every page; empty or white removes it. With no colour, opens a picker.`,e=>{if(e.color===void 0){let e=x();return e.color.value=I7(t.doc).sections[0].pageColor||`#ffffff`,e.d.open(e.color),!0}let n=String(e.color).trim().toLowerCase(),r=!n||n===`none`||n===`#ffffff`?``:n;return r&&!gxn.test(r)&&i(`color must be #rrggbb or empty.`),y({pageColor:r}),{color:r}},[{name:`color`,type:`string`,description:`#rrggbb; empty removes it`}]),n(`design.pageBorders`,`Page borders`,`Layout`,`Put a border around every page (thin, double or accent), or remove it; with no style, opens Page setup.`,e=>{if(e.style===void 0)return o(`layout.pageSetup`);let t=String(e.style).trim().toLowerCase(),n=t===`none`||t===``?``:t;return[``,`thin`,`double`,`accent`].includes(n)||i(`style must be none, thin, double or accent.`),y({pageBorder:n}),{style:n||`none`}},[{name:`style`,type:`string`,description:`none, thin, double or accent`}]),n(`insert.blankPage`,`Blank page`,`Insert`,`Insert an empty page at the cursor: a page break, an empty paragraph and a second page break.`,()=>{let e=r(),{state:t}=e,n=t.selection.$from,i=t.tr,a;n.depth<1||n.parent.type!==da.nodes.paragraph||n.depth>1?a=n.depth>=1?n.after(1):t.selection.from:n.parent.content.size===0||n.parentOffset===n.parent.content.size?a=n.after(1):n.parentOffset===0?a=n.before(1):(i.split(n.pos),a=i.mapping.map(n.pos,-1)+1);let o=[da.nodes.page_break.create(),da.nodes.paragraph.create(),da.nodes.page_break.create()];a>=i.doc.content.size&&o.push(da.nodes.paragraph.create()),i.insert(a,o);let s=a+o.reduce((e,t)=>e+t.nodeSize,0);return i.setSelection(Wn.near(i.doc.resolve(Math.min(s,i.doc.content.size)),1)),e.dispatch(i.scrollIntoView()),e.focus(),!0});let S=e=>{let t=[];return e.forEach((e,n)=>{let r=String(e.attrs.style??``);e.type===da.nodes.paragraph&&mxn.test(r)&&e.textContent.trim()&&t.push({pos:n,level:r===`Title`?0:Number(r.slice(7)),text:e.textContent.trim()})}),t},C=e=>{let t=[];return e.descendants((e,n)=>(e.type.name===`bookmark`&&t.push({pos:n,name:String(e.attrs.name)}),!0)),t},w=()=>Array.from(t.root.querySelectorAll(`.ft-sheets > .ft-sheet`)),T=e=>{let t=r(),n=Wn.near(t.state.doc.resolve(Math.max(0,Math.min(e,t.state.doc.content.size))),1);t.dispatch(t.state.tr.setSelection(n));let i=t.domAtPos(n.head).node;(i.nodeType===1?i:i.parentElement)?.scrollIntoView({block:`center`}),t.focus()},E=e=>{let n=w();n.length||i(`Pages are not shown in this view.`),(!Number.isInteger(e)||e<1||e>n.length)&&i(`The document has ${n.length} page${n.length===1?``:`s`}.`);let a=n[e-1];a.scrollIntoView({block:`start`});let o=r(),s=a.getBoundingClientRect(),l=I7(t.doc).sections[0].margins,u=o.posAtCoords({left:s.left+(l.left*P7+8)*t.zoom,top:s.top+(l.top*P7+6)*t.zoom});return u&&o.dispatch(o.state.tr.setSelection(Wn.near(o.state.doc.resolve(u.pos),1))),o.focus(),e},D=N7(()=>{let e=new pn(`Go to`,420),n=lxn([[`page`,`Page`],[`heading`,`Heading`],[`bookmark`,`Bookmark`],[`comment`,`Comment`]],`page`),r=cxn(`text`,``,`list="ft-goto-list" spellcheck="false" autocomplete="off"`),i=P(``),a=P(`

`);e.field(`Go to what`,n),e.field(`Enter value`,r),e.body.appendChild(i),e.body.appendChild(a);let s=()=>{let e=t.view?.state.doc,r=n.value,o=[],s=``;if(r===`page`)s=`Page number, 1 to ${t.paginator.pages}.`;else if(r===`heading`&&e)o=S(e).map(e=>e.text),s=`A heading number or part of its text; empty goes to the next heading.`;else if(r===`bookmark`&&e)o=C(e).map(e=>e.name),s=`A bookmark name.`;else if(r===`comment`){try{o=N4t().map(e=>e.comment.id)}catch{o=[]}s=`A comment number or id; empty goes to the next comment.`}Ve(i,o.slice(0,200),{key:e=>e,create:e=>{let t=P(``);return t.setAttribute(`value`,e),t},update:()=>void 0}),N(a,s)};n.addEventListener(`change`,s);let l=()=>{try{Promise.resolve(o(`edit.goTo`,{what:n.value,value:r.value})).then(()=>e.close()).catch(e=>it(e.message,`error`))}catch(e){it(e.message,`error`)}};return e.button(`Close`,`ghost`,()=>e.close()),e.button(`Go to`,`primary`,l),uxn(e,[r,n],l),{d:e,what:n,value:r,sync:s}});n(`edit.goTo`,`Go to`,`Edit`,`Jump to a page number, a heading (number or text), a bookmark or a comment; with no parameters, opens the Go To dialog.`,e=>{if(e.what===void 0){let e=D();return e.sync(),e.d.open(e.value),!0}let t=r(),n=String(e.what).toLowerCase(),a=String(e.value??``).trim();if(n===`page`)return{what:n,page:E(Number(a))};let o=t.state.selection.head;if(n===`heading`){let e=S(t.state.doc);e.length||i(`The document has no headings.`);let r=e[0];if(!a)r=e.find(e=>e.pos>o)??e[0];else if(/^\d+$/.test(a))r=e[Number(a)-1]??i(`The document has ${e.length} headings.`);else{let t=a.toLowerCase();r=e.find(e=>e.text.toLowerCase().startsWith(t))??e.find(e=>e.text.toLowerCase().includes(t))??i(`No heading matches that text.`)}return T(r.pos+1),{what:n,heading:r.text}}if(n===`bookmark`){let e=C(t.state.doc).find(e=>e.name.toLowerCase()===a.toLowerCase())??i(`No bookmark has that name.`);return T(e.pos),{what:n,bookmark:e.name}}if(n===`comment`){let e=N4t();e.length||i(`This document has no comments.`);let t=e[0];return t=a?/^\d+$/.test(a)&&!e.some(e=>e.comment.id===a)?e[Number(a)-1]??i(`The document has ${e.length} comments.`):e.find(e=>e.comment.id===a)??i(`No comment has that number or id.`):e.find(e=>e.from>o)??e[0],j4t(t.comment.id),{what:n,comment:t.comment.id}}return i(`what must be page, heading, bookmark or comment.`)},[{name:`what`,type:`string`,description:`page, heading, bookmark or comment`},{name:`value`,type:`number`,description:`Page number, heading number or text, bookmark name, comment number or id`}]);let O=!1,k=`headings`,A=N7(()=>{let e=t.root.querySelector(`.ft-editor-body`),n=P(`