isorite 0.7.0 → 0.8.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/README.md +1 -0
- package/dist/main.js +609 -96
- package/docs/setup-for-agents.md +3 -0
- package/docs/setup.md +20 -0
- package/docs/terminal.md +15 -0
- package/package.json +1 -1
- package/plugin/server.ts +4 -2
- package/web/_app/immutable/assets/{0.BKnIhFWM.css → 0.CTbO0owi.css} +1 -1
- package/web/_app/immutable/chunks/B-65IYX-.js +6 -0
- package/web/_app/immutable/chunks/{62dhNtvj.js → B91efLFT.js} +3 -3
- package/web/_app/immutable/chunks/{Cn-vtDpV.js → BjPiibIz.js} +1 -1
- package/web/_app/immutable/chunks/{BNjH_DUx.js → BrXPCJaM.js} +1 -1
- package/web/_app/immutable/chunks/{B7GA1FFB.js → BtUtjfIh.js} +1 -1
- package/web/_app/immutable/chunks/{CYNZ4aV_.js → CCiHXe5d.js} +1 -1
- package/web/_app/immutable/chunks/{DHfKGggc.js → CGzfi9Nl.js} +1 -1
- package/web/_app/immutable/chunks/CnP_Si9g.js +1 -0
- package/web/_app/immutable/chunks/{CWmfjLLv.js → D_JZ0swv.js} +1 -1
- package/web/_app/immutable/chunks/{WBFggAXs.js → DgZW3JtG.js} +1 -1
- package/web/_app/immutable/chunks/{CVbgxz8Y.js → Di_ac7WN.js} +1 -1
- package/web/_app/immutable/chunks/{DsBJWNWe.js → NmqB5ax3.js} +1 -1
- package/web/_app/immutable/chunks/{BoNMG-YE.js → dvrIP-Hm.js} +1 -1
- package/web/_app/immutable/chunks/hOAYc4Tf.js +1 -0
- package/web/_app/immutable/entry/{app.Dt52eXt2.js → app.DO9lj7h3.js} +2 -2
- package/web/_app/immutable/entry/start.Bg5TZs6n.js +1 -0
- package/web/_app/immutable/nodes/0.N1e1uAFq.js +26 -0
- package/web/_app/immutable/nodes/{1.B5qkcrvB.js → 1.BRTPLKyU.js} +1 -1
- package/web/_app/immutable/nodes/2.BWh1AYEd.js +1 -0
- package/web/_app/immutable/nodes/3.Cgqgn7Zv.js +1 -0
- package/web/_app/immutable/nodes/{4.BhNJiqT-.js → 4.DYW7Fxdy.js} +1 -1
- package/web/_app/immutable/nodes/{5.DXTbGemS.js → 5.Dkvkif0E.js} +1 -1
- package/web/_app/immutable/nodes/6.BinB0fuq.js +1 -0
- package/web/_app/version.json +1 -1
- package/web/index.html +15 -15
- package/web/_app/immutable/chunks/B3dCo0od.js +0 -1
- package/web/_app/immutable/chunks/D6Vzg2HD.js +0 -6
- package/web/_app/immutable/chunks/DkvLWnSd.js +0 -1
- package/web/_app/immutable/entry/start.mjqIl2PI.js +0 -1
- package/web/_app/immutable/nodes/0.DIhIOwuo.js +0 -26
- package/web/_app/immutable/nodes/2.CK3q7brK.js +0 -1
- package/web/_app/immutable/nodes/3.CrUewa31.js +0 -1
- package/web/_app/immutable/nodes/6.BZWaFgFP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,A as t,D as n,F as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,P as d,Q as f,S as p,T as m,U as h,X as g,Y as _,Z as v,_ as y,at as b,d as x,dt as S,f as C,h as w,j as T,k as E,m as ee,n as te,ot as D,p as O,pt as k,q as A,rt as j,s as M,tt as N,ut as P,w as F,x as I,z as L}from"../chunks/nMarIA7J.js";import{o as ne,t as R}from"../chunks/
|
|
1
|
+
import{$ as e,A as t,D as n,F as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,P as d,Q as f,S as p,T as m,U as h,X as g,Y as _,Z as v,_ as y,at as b,d as x,dt as S,f as C,h as w,j as T,k as E,m as ee,n as te,ot as D,p as O,pt as k,q as A,rt as j,s as M,tt as N,ut as P,w as F,x as I,z as L}from"../chunks/nMarIA7J.js";import{o as ne,t as R}from"../chunks/BrXPCJaM.js";import"../chunks/xihTtKlq.js";import{A as z,E as B,M as re,N as V,P as ie,T as H,h as ae,i as U,j as oe,m as se,t as W,w as ce,x as le}from"../chunks/B91efLFT.js";import{i as ue,n as de,r as fe,t as pe}from"../chunks/Di_ac7WN.js";import{i as G,r as me,t as K}from"../chunks/CnP_Si9g.js";import{i as q}from"../chunks/hOAYc4Tf.js";import{t as he}from"../chunks/NmqB5ax3.js";import{t as ge}from"../chunks/CGzfi9Nl.js";import{a as _e,i as J,n as Y,o as ve,r as ye,t as be}from"../chunks/B-65IYX-.js";var xe=T(`<button class="link svelte-1khbtcu" type="button">delete</button>`),Se=T(`<label class="wide svelte-1khbtcu" for="note-folder"><span>folder</span></label> <span class="wide svelte-1khbtcu"><!></span> <label class="svelte-1khbtcu"><span>name</span><input class="mono svelte-1khbtcu" spellcheck="false" autocomplete="off" aria-label="name: change it to rename the file"/></label> <!>`,1),X=T(`<div class="full ask svelte-1khbtcu" role="alertdialog" aria-label="delete this note"><span class="svelte-1khbtcu">Delete this note? <!> Its history stays.</span> <button class="btn danger svelte-1khbtcu" type="button">delete</button> <button class="btn quiet svelte-1khbtcu" type="button">keep it</button></div>`),Ce=T(`<p class="full problem svelte-1khbtcu" role="alert"> </p>`),we=T(`<option></option>`),Te=T(`<div class="details svelte-1khbtcu"><label class="svelte-1khbtcu"><span>type</span><input list="types" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="wide svelte-1khbtcu"><span>tags</span><input placeholder="none" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="full svelte-1khbtcu"><span>description</span><input placeholder="one line on what this note says" autocomplete="off" class="svelte-1khbtcu"/></label> <!> <!> <!> <datalist id="types"></datalist></div>`);function Ee(t,a){D(a,!0);let s=N(()=>[...new Set(K.listing.notes.map(e=>e.type).filter(Boolean))].sort()),l=N(()=>!a.note.id.startsWith(`@`)),d=e(``),h=e(null),v=e=>e.split(`/`).slice(0,-1).join(`/`),y=e=>e.split(`/`).at(-1),w=N(()=>v(a.note.id));async function T(e,t){let n=e=>e.trim().replace(/^\/+|\/+$/g,``).replace(/\.md$/,``),r=[n(e),n(t)].filter(Boolean).join(`/`);if(!n(t)||r===a.note.id)f(w,v(a.note.id));else{f(d,``);try{let e=await a.note.move(r);await K.refresh(),await R(me(e),{replaceState:!0})}catch(e){f(d,e.message,!0),f(w,v(a.note.id))}}}async function ee(){f(d,``);try{let e=await K.api.map();f(h,[...new Set(e.model.edges.filter(([e,t])=>t===a.note.id&&e!==a.note.id&&!e.startsWith(`@`)).map(([t])=>e.notes[t]?.title||t))],!0)}catch(e){f(d,e.message,!0)}}async function te(){try{await a.note.remove(),await K.refresh(),await R(ne(`/notes`),{replaceState:!0})}catch(e){f(d,e.message,!0),f(h,null)}}var k=Te(),j=A(k),M=g(A(j));x(M),S(j);var F=g(j,2),I=g(A(F));x(I),S(F);var L=g(F,2),z=g(A(L));x(z),S(L);var B=g(L,2),re=e=>{var t=Se(),n=g(o(t),2),s=A(n);ge(s,{id:`note-folder`,quiet:!0,label:`folder: change it to move the note`,placeholder:`the top of the base`,onpick:e=>void T(e,y(a.note.id)),onkeydown:e=>{e.key===`Escape`&&(f(w,v(a.note.id)),e.currentTarget.blur())},get value(){return c(w)},set value(e){f(w,e)}}),S(n);var l=g(n,2),u=g(A(l));x(u),S(l);var d=g(l,2),p=e=>{var t=xe();r(`click`,t,()=>void ee()),E(e,t)};m(d,e=>{c(h)===null&&e(p)}),i((e,t)=>{O(u,e),C(u,`size`,t)},[()=>y(a.note.id),()=>Math.max(8,y(a.note.id).length)]),r(`change`,u,e=>void T(c(w),e.currentTarget.value)),r(`keydown`,u,e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(e.currentTarget.value=y(a.note.id),e.currentTarget.blur())}),E(e,t)};m(B,e=>{c(l)&&e(re)});var V=g(B,2),ie=e=>{var t=X(),a=A(t),o=g(A(a)),s=e=>{var t=u();i(e=>n(t,`${c(h).length===1?`One note links`:`${c(h).length} notes link`} to it (${e??``}); ${c(h).length===1?`its link is`:`their links are`} left broken.`),[()=>c(h).join(`, `)]),E(e,t)},l=e=>{var t=u(`No note links to it.`);E(e,t)};m(o,e=>{c(h).length?e(s):e(l,-1)}),P(),S(a);var d=g(a,2),p=g(d,2);S(t),r(`click`,d,()=>void te()),r(`click`,p,()=>{f(h,null)}),E(e,t)};m(V,e=>{c(h)!==null&&e(ie)});var H=g(V,2),ae=e=>{var t=Ce(),r=_(t,!0);i(()=>n(r,c(d))),E(e,t)};m(H,e=>{c(d)&&e(ae)});var U=g(H,2);p(U,20,()=>c(s),e=>e,(e,t)=>{var n=we(),r={};i(()=>{r!==(r=t)&&(n.value=(n.__value=r)??``)}),E(e,n)}),S(U),S(k),i(e=>{O(M,a.note.fields.type),C(M,`size`,e),O(I,a.note.fields.tags),O(z,a.note.fields.description)},[()=>Math.max(7,a.note.fields.type.length)]),r(`input`,M,e=>a.note.setFields({type:e.currentTarget.value})),r(`change`,I,e=>a.note.setFields({tags:e.currentTarget.value})),r(`input`,z,e=>a.note.setFields({description:e.currentTarget.value})),E(t,k),b()}d([`input`,`change`,`keydown`,`click`]);var De=T(`<h1 class="serif title svelte-130pv1o"> </h1>`),Oe=T(`<p class="asked svelte-130pv1o"><i class="dia svelte-130pv1o" aria-hidden="true"></i><span> </span></p>`),ke=T(`<div class="offered svelte-130pv1o" aria-label="What Iso offered"><p class="serif svelte-130pv1o"> </p></div>`),Ae=T(`<div class="version svelte-130pv1o"><!> <!> <div class="text svelte-130pv1o"></div> <!></div>`);function je(t,r){D(r,!0);let a=N(()=>{try{let[e,t,n]=z(r.text);return{title:/^title:\s*(.*)$/m.exec(t??``)?.[1]?.trim().replace(/^["']|["']$/g,``)??``,body:n,lines:e.split(`
|
|
2
2
|
`).length-1}}catch{return{title:``,body:r.text,lines:0}}}),o,s=e(void 0);te(()=>(f(s,Y(o,{doc:c(a).body,onChange:()=>void 0,onSave:()=>void 0,label:`The note as it was`,notes:()=>[],readOnly:!0})),()=>c(s)?.destroy())),h(()=>{let e=r.touched,t=c(a).lines;c(s)?.dispatch({effects:J.of(e?{who:e.who,lines:e.lines.map(e=>e-t)}:null)})});var l=Ae(),u=A(l),d=e=>{var t=De(),r=_(t,!0);i(()=>n(r,c(a).title)),E(e,t)};m(u,e=>{c(a).title&&c(a).title!==r.title&&e(d)});var p=g(u,2),v=e=>{var t=Oe(),a=g(A(t)),o=_(a,!0);S(t),i(()=>n(o,r.asked)),E(e,t)};m(p,e=>{r.asked!==void 0&&e(v)});var y=g(p,2);M(y,e=>o=e,()=>o);var x=g(y,2),C=e=>{var t=ke(),a=A(t),o=_(a,!0);S(t),i(()=>n(o,r.offered)),E(e,t)};m(x,e=>{r.offered!==void 0&&e(C)}),S(l),E(t,l),b()}var Me=(e,t=k,n=k)=>{var r=Fe();let a;var o=A(r),s=e=>{var t=Ne();P(),E(e,t)},c=e=>{var t=Pe();i(()=>C(t,`fill`,n()?`currentColor`:`none`)),E(e,t)};m(o,e=>{t()===`question`?e(s):e(c,-1)}),S(r),i(()=>a=w(r,0,`glyph ${t()??``}`,`svelte-18ltlst`,a,{solved:n()})),E(e,r)},Ne=l(`<path d="M5.6 5.6a2.4 2.4 0 1 1 3.4 2.2c-.6.3-1 .8-1 1.5v.9"></path><path d="M8 12v1.2"></path>`,1),Pe=l(`<path d="M8 2.5l5.8 10.5H2.2z"></path>`),Fe=l(`<svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4"><!></svg>`),Ie=T(`<p class="faint">opening…</p>`),Le=T(`<p class="soft">There is no note at <span class="faint"> </span>.</p> <p><a>all notes</a></p>`,1),Re=T(`<p class="bad svelte-18ltlst"> </p>`),ze=T(`<button class="btn" type="button">take theirs</button>`),Be=T(`<div class="frame choice svelte-18ltlst" role="alert"><span class="frame-title">changed elsewhere</span> <p> </p> <div class="row svelte-18ltlst"><button class="btn primary" type="button">keep mine</button> <!></div> <p class="faint">Whichever you keep, the other stays in the note's journal.</p></div>`),Ve=T(`<button class="done-tg svelte-18ltlst" type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8.5l3 3 7-7"></path></svg></button>`),He=T(`<div class="titlerow svelte-18ltlst"><!> <label class="hidden-label" for="title">Title</label> <textarea id="title" class="serif title svelte-18ltlst" rows="1" autocomplete="off"></textarea> <!></div>`),Ue=T(`<span class="grow faint"> </span>`),We=T(`<button class="btn quiet svelte-18ltlst" type="button">details</button>`),Ge=T(` <a class="svelte-18ltlst"> </a>`,1),Ke=T(`<p class="about svelte-18ltlst"></p>`),qe=T(`<div class="tl-col svelte-18ltlst"><!></div>`),Je=T(`<span class="bad svelte-18ltlst" role="alert"> </span>`),Ye=T(`<div class="atbar svelte-18ltlst" role="status"><span class="label"> </span> <span class="grow"></span> <!> <button class="icon svelte-18ltlst" type="button" aria-label="restore to here" title="restore to here"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M3.2 9.5A5 5 0 1 0 4.6 4.3" stroke="currentColor" stroke-width="1.3" fill="none"></path><path d="M3 1.8v3.4h3.4" stroke="currentColor" stroke-width="1.3" fill="none"></path></svg></button> <button class="icon svelte-18ltlst" type="button" aria-label="back to now" title="back to now"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M2 8h9M8 4.8 11.2 8 8 11.2" stroke="currentColor" stroke-width="1.3" fill="none"></path><path d="M13.5 3v10" stroke="currentColor" stroke-width="1.3"></path></svg></button></div> <!>`,1),Xe=T(`<button class="toiso svelte-18ltlst" type="button"><i class="dia svelte-18ltlst" aria-hidden="true">◆</i>send to Iso</button>`),Ze=l(`<svg class="ok svelte-18ltlst" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8.5l3 3 7-7"></path></svg>`),Qe=T(`<li><a><!><span class="svelte-18ltlst"> </span><!></a></li>`),$e=T(`<ul class="attached svelte-18ltlst"></ul>`),et=T(`<div class="changes svelte-18ltlst" role="status"><i class="dia svelte-18ltlst" aria-hidden="true"></i> <span class="soft"> </span> <span class="grow"></span> <button class="link svelte-18ltlst" type="button">keep all</button> <button class="link svelte-18ltlst" type="button">remove all</button></div>`),tt=T(`<!> <div class="head svelte-18ltlst"><!> <div class="side svelte-18ltlst"><div class="tools svelte-18ltlst"><!> <button class="btn quiet svelte-18ltlst" type="button">source</button></div></div></div> <!> <!> <!> <!> <!> <div class="live"><!></div> <!> <!>`,1),nt=T(`<article><!></article>`);function rt(t,l){D(l,!0);let u=new _e(l.id),d=new ve(u),y=e=>{try{return localStorage.getItem(e)===`1`}catch{return!1}},x=(e,t)=>{try{localStorage.setItem(e,t?`1`:`0`)}catch{}},T=e(v(y(`isorite.details`))),k=e(!1),I=N(()=>c(k)||u.meta===null),z=N(()=>q.on.timeline),U=e(null),W=e(null),ge=e(!1),J=e(``),Y=N(()=>le(d.entries)),ye=e=>e.who.startsWith(`iso:`)||e.who.startsWith(`agent:`),xe=e=>e.flatMap(e=>Array.from({length:e.to-e.from},(t,n)=>e.from+n)),Se=N(()=>{if(!c(z)||c(W)||c(I))return null;let e=c(U)??(c(Te)?void 0:c(Y).findLast(e=>ye(e)&&(e.what===`kept`||e.what===`edited`)));if(!e)return null;let t=xe(H(d.entries,e.ids).runs);return t.length?{who:ye(e)?`iso`:`you`,lines:t}:null}),X=N(()=>{if(!c(W))return null;let e=ue(c(W)),t=ce(d.entries,e);if(t===null)return null;let n=d.entries.filter(t=>t.id<=e),r=d.entries.find(e=>e.id===c(W).ids[0]),i=(c(W).what===`offered`||c(W).what===`discarded`)&&r?.kind===`proposal`?r.form===`insert`?r.text:r.regions.map(e=>e.new).join(`
|
|
3
3
|
|
|
4
4
|
`):void 0;return{text:t,touched:{who:ye(c(W))?`iso`:`you`,lines:xe(H(n,c(W).ids).runs)},asked:c(W).asked,offered:i}}),Ce=()=>he.url.searchParams.get(`at`)??new URLSearchParams(location.hash.split(`?`)[1]??``).get(`at`),we=e(v(Ce()));h(()=>{let e=Ce();e&&f(we,e,!0)}),h(()=>{if(!c(we))return;let e=c(Y).find(e=>e.ids.includes(c(we)));e&&(f(we,null),q.flip(`timeline`,!0),f(W,e))});let Te=N(()=>q.on.provenance);h(()=>{c(z)||(f(W,null),f(U,null))});let De=N(()=>{if(!c(Te)||u.loaded!==`ready`)return[];let e=[],t=B(d.entries),n=u.text.split(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunks/nMarIA7J.js";import"../chunks/xihTtKlq.js";import{t as e}from"../chunks/CCiHXe5d.js";import"../chunks/D_19S_Iu.js";function t(t){e(t,{})}export{t as component};
|
package/web/_app/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1793057237766"}
|
package/web/index.html
CHANGED
|
@@ -36,42 +36,42 @@
|
|
|
36
36
|
history.replaceState(history.state, "", location.pathname.slice(0, -1) + location.search + location.hash);
|
|
37
37
|
}
|
|
38
38
|
</script>
|
|
39
|
-
<link href="/_app/immutable/entry/start.
|
|
40
|
-
<link href="/_app/immutable/chunks/
|
|
39
|
+
<link href="/_app/immutable/entry/start.Bg5TZs6n.js" rel="modulepreload">
|
|
40
|
+
<link href="/_app/immutable/chunks/BrXPCJaM.js" rel="modulepreload">
|
|
41
41
|
<link href="/_app/immutable/chunks/nMarIA7J.js" rel="modulepreload">
|
|
42
|
-
<link href="/_app/immutable/entry/app.
|
|
42
|
+
<link href="/_app/immutable/entry/app.DO9lj7h3.js" rel="modulepreload">
|
|
43
43
|
<link href="/_app/immutable/chunks/CRzLMJPS.js" rel="modulepreload">
|
|
44
44
|
<link href="/_app/immutable/chunks/xihTtKlq.js" rel="modulepreload">
|
|
45
|
-
<link href="/_app/immutable/nodes/0.
|
|
46
|
-
<link href="/_app/immutable/chunks/
|
|
47
|
-
<link href="/_app/immutable/chunks/
|
|
48
|
-
<link href="/_app/immutable/chunks/
|
|
45
|
+
<link href="/_app/immutable/nodes/0.N1e1uAFq.js" rel="modulepreload">
|
|
46
|
+
<link href="/_app/immutable/chunks/B91efLFT.js" rel="modulepreload">
|
|
47
|
+
<link href="/_app/immutable/chunks/CnP_Si9g.js" rel="modulepreload">
|
|
48
|
+
<link href="/_app/immutable/chunks/hOAYc4Tf.js" rel="modulepreload">
|
|
49
49
|
<link href="/_app/immutable/chunks/BxTFtVqu.js" rel="modulepreload">
|
|
50
50
|
<link href="/_app/immutable/chunks/yxd8jSz3.js" rel="modulepreload">
|
|
51
|
-
<link href="/_app/immutable/chunks/
|
|
52
|
-
<link href="/_app/immutable/chunks/
|
|
53
|
-
<link href="/_app/immutable/chunks/
|
|
54
|
-
<link href="/_app/immutable/chunks/
|
|
51
|
+
<link href="/_app/immutable/chunks/Di_ac7WN.js" rel="modulepreload">
|
|
52
|
+
<link href="/_app/immutable/chunks/NmqB5ax3.js" rel="modulepreload">
|
|
53
|
+
<link href="/_app/immutable/chunks/CCiHXe5d.js" rel="modulepreload">
|
|
54
|
+
<link href="/_app/immutable/chunks/CGzfi9Nl.js" rel="modulepreload">
|
|
55
55
|
<link href="/_app/immutable/chunks/DZYaqCwi.js" rel="modulepreload">
|
|
56
56
|
|
|
57
57
|
<link href="/_app/immutable/assets/Timeline.KTc3LKuK.css" rel="stylesheet">
|
|
58
58
|
<link href="/_app/immutable/assets/FolderField._A4_sc1Z.css" rel="stylesheet">
|
|
59
59
|
<link href="/_app/immutable/assets/NoteList.F579Zvj_.css" rel="stylesheet">
|
|
60
|
-
<link href="/_app/immutable/assets/0.
|
|
60
|
+
<link href="/_app/immutable/assets/0.CTbO0owi.css" rel="stylesheet">
|
|
61
61
|
</head>
|
|
62
62
|
<body>
|
|
63
63
|
<div style="display: contents">
|
|
64
64
|
<script>
|
|
65
65
|
{
|
|
66
|
-
|
|
66
|
+
__sveltekit_1s9eja2 = {
|
|
67
67
|
base: new URL('.', location).pathname.slice(0, -1)
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const element = document.currentScript.parentElement;
|
|
71
71
|
|
|
72
72
|
Promise.all([
|
|
73
|
-
import("/_app/immutable/entry/start.
|
|
74
|
-
import("/_app/immutable/entry/app.
|
|
73
|
+
import("/_app/immutable/entry/start.Bg5TZs6n.js"),
|
|
74
|
+
import("/_app/immutable/entry/app.DO9lj7h3.js")
|
|
75
75
|
]).then(([kit, app]) => {
|
|
76
76
|
kit.start(app, element);
|
|
77
77
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,L as t,Q as n,Z as r}from"./nMarIA7J.js";import{o as i,t as a}from"./BNjH_DUx.js";import{r as o}from"./DkvLWnSd.js";var s=(e,t)=>{try{return localStorage.getItem(e)??t}catch{return t}},c=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},l=(e,t)=>{try{return{...t,...JSON.parse(s(e,`{}`))}}catch{return t}},u=[`note`,`atlas`,`iso`],d=[`cols`,`stack`,`one`],f={note:[`provenance`,`timeline`],atlas:[`questions`,`problems`,`web`,`code`,`context`],iso:[`notes`,`files`,`run`]},p={provenance:!1,timeline:!1,questions:!0,problems:!0,web:!1,code:!1,context:!1,notes:!1,files:!1,run:!1},m={note:1.25,atlas:1,iso:1.05},h={min:.4,max:3},g=new class{#e=e(r(d.includes(s(`isorite.layout`,``))?s(`isorite.layout`,``):`cols`));get layout(){return t(this.#e)}set layout(e){n(this.#e,e,!0)}#t=e(r(l(`isorite.show`,{note:!0,atlas:!0,iso:!0})));get show(){return t(this.#t)}set show(e){n(this.#t,e,!0)}#n=e(r(l(`isorite.widths`,m)));get widths(){return t(this.#n)}set widths(e){n(this.#n,e,!0)}#r=e(r(l(`isorite.switches`,p)));get on(){return t(this.#r)}set on(e){n(this.#r,e,!0)}#i=e(s(`isorite.understanding`,``)===`1`);get understanding(){return t(this.#i)}set understanding(e){n(this.#i,e,!0)}#a=e(`note`);get focus(){return t(this.#a)}set focus(e){n(this.#a,e,!0)}#o=e(!1);get narrow(){return t(this.#o)}set narrow(e){n(this.#o,e,!0)}#s=e(0);get unseen(){return t(this.#s)}set unseen(e){n(this.#s,e,!0)}#c=e(!1);get tree(){return t(this.#c)}set tree(e){n(this.#c,e,!0)}#l=e(``);get fresh(){return t(this.#l)}set fresh(e){n(this.#l,e,!0)}#u=e(null);get settings(){return t(this.#u)}set settings(e){n(this.#u,e,!0)}#d=e(r(s(`isorite.last`,``)));get last(){return t(this.#d)}set last(e){n(this.#d,e,!0)}get standing(){if(this.narrow)return[...u];let e=u.filter(e=>this.show[e]);return this.layout===`one`?[e.includes(this.focus)?this.focus:e[0]??`note`]:e}setLayout(e){this.layout=e,c(`isorite.layout`,e)}nextLayout(){this.setLayout(d[(d.indexOf(this.layout)+1)%d.length])}toggle(e){this.show[e]&&u.filter(e=>this.show[e]).length===1||(this.show[e]=!this.show[e],c(`isorite.show`,JSON.stringify(this.show)),!this.show[e]&&this.focus===e&&(this.focus=u.find(e=>this.show[e])))}setWidth(e,t){this.widths[e]=Math.min(h.max,Math.max(h.min,t)),c(`isorite.widths`,JSON.stringify(this.widths))}to(e){!this.narrow&&!this.show[e]&&this.toggle(e),this.focus=e,e===`iso`&&(this.unseen=0),this.scroll?.(e)}scroll=null;step(e){let t=this.narrow?[...u]:u.filter(e=>this.show[e]),n=t.indexOf(this.focus);this.to(t[(n+e+t.length)%t.length])}flip(e,t=!this.on[e]){this.on[e]=t,c(`isorite.switches`,JSON.stringify(this.on)),(e===`notes`||e===`files`||e===`run`)&&this.onMode?.()}showUnderstanding(e=!this.understanding){this.understanding=e,c(`isorite.understanding`,e?`1`:``),this.onMode?.()}busy(e){let t=typeof document>`u`?null:document.activeElement;return!!t&&!!t.closest(`[data-pane="${e}"]`)&&(t.matches(`input, textarea, [contenteditable=true]`)||!!t.closest(`.cm-editor`))}#f=e(!1);get terminal(){return t(this.#f)}set terminal(e){n(this.#f,e,!0)}setTerminal(e){this.terminal=e}get mode(){return this.terminal&&(this.on.files||this.on.run)?`build`:this.on.notes?`write`:`ask`}onMode=null;setLast(e){e&&!e.startsWith(`@`)&&(this.last=e,c(`isorite.last`,e))}async open(e,t=this.narrow){await a(o(e)),t&&this.to(`note`)}async home(){await a(i(`/notes`))}};export{g as i,u as n,f as r,d as t};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,D as r,E as i,F as a,H as o,J as s,L as c,O as l,P as u,Q as d,S as f,T as p,U as m,X as h,Y as g,_,at as v,dt as y,f as b,h as x,i as S,j as C,k as w,n as T,ot as E,q as D,rt as ee,s as te,tt as O,u as ne,x as re,z as ie}from"./nMarIA7J.js";import{t as k}from"./BNjH_DUx.js";import"./xihTtKlq.js";import{A,C as ae,D as oe,F as se,S as ce,_ as le,a as ue,b as de,c as fe,f as pe,h as me,i as he,k as ge,m as _e,n as ve,o as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./62dhNtvj.js";import{a as De,n as Oe,r as ke,t as j}from"./DkvLWnSd.js";import{i as Ae}from"./B3dCo0od.js";import{B as je,D as M,E as Me,F as N,G as Ne,H as Pe,I as Fe,J as P,K as Ie,L as F,M as I,N as L,P as Le,R as Re,S as ze,W as Be,X as Ve,Y as He,at as Ue,ct as We,et as Ge,it as Ke,lt as qe,mt as Je,n as Ye,nt as Xe,rt as R,t as Ze,ut as Qe,v as $e,w as et,x as tt,y as nt}from"./BxTFtVqu.js";import{i as rt,l as it,n as at,o as ot,r as st}from"./yxd8jSz3.js";var ct=class{note;#e=e([]);get entries(){return c(this.#e)}set entries(e){d(this.#e,e)}#t=e(null);get prompt(){return c(this.#t)}set prompt(e){d(this.#t,e)}#n=e(null);get asking(){return c(this.#n)}set asking(e){d(this.#n,e)}#r=e(null);get failed(){return c(this.#r)}set failed(e){d(this.#r,e)}get tier(){return be.tier}#i=e(null);get cursor(){return c(this.#i)}set cursor(e){d(this.#i,e)}#a=e(``);get busy(){return c(this.#a)}set busy(e){d(this.#a,e,!0)}#o=e(null);get editing(){return c(this.#o)}set editing(e){d(this.#o,e,!0)}stop=null;constructor(e){this.note=e}#s=O(()=>ae(this.entries));get waiting(){return c(this.#s)}set waiting(e){d(this.#s,e)}#c=O(()=>this.waiting.filter(e=>e.form===`insert`));get proposals(){return c(this.#c)}set proposals(e){d(this.#c,e)}#l=O(()=>{let e=[],t=oe(this.note.text);for(let n of this.waiting)if(n.form===`rewrite`)for(let r of n.open??[]){let i=n.regions[r],a=le(this.note.text,i.old),o=a?this.note.text.slice(0,a.from).split(`
|
|
2
|
-
`).length-1:-1,s=t.find(e=>e.from<=o&&o<e.to);e.push({key:`r:${n.id}:${r}`,proposal:n,k:r,at:a,block:/\n/.test(i.old.text.trim())||/\n/.test(i.new.trim()),code:!!(s&&/^\s*(```|~~~)/.test(s.text))})}return e.sort((e,t)=>(e.at?.from??1/0)-(t.at?.from??1/0))});get changes(){return c(this.#l)}set changes(e){d(this.#l,e)}#u=O(()=>{try{let e=A(this.note.text)[0];return{lines:e.split(`
|
|
3
|
-
`).length-1,chars:e.length}}catch{return{lines:0,chars:0}}});get head(){return c(this.#u)}set head(e){d(this.#u,e)}get foot(){return this.note.text.split(`
|
|
4
|
-
`).length}spans(e){return e.flatMap(e=>{let t=le(this.note.text,e);return t?[t]:[]})}placed(e){return de(this.note.text,e)!==null}#d=O(()=>{let e=[];for(let t of this.proposals){let n=de(this.note.text,t);e.push({key:`p:${t.id}`,line:n?.form===`insert`?n.line:this.foot})}this.changes.some(e=>!e.at)&&e.push({key:`lost`,line:this.foot}),this.asking&&e.push({key:`asking`,line:this.asking.line}),this.failed&&e.push({key:`failed`,line:this.failed.line}),this.prompt&&e.push({key:`prompt`,line:this.prompt.line});let t=this.changes.filter(e=>e.at);for(let n of t)n.block&&e.push({key:n.key,line:this.note.text.slice(0,n.at.to).split(`
|
|
5
|
-
`).length});return{blocks:e,picked:this.spans(this.prompt?.regions??this.asking?.regions??[]),old:t.map(e=>e.at),inline:t.filter(e=>!e.block).map(e=>({key:e.key,at:e.at.to}))}});get layout(){return c(this.#d)}set layout(e){d(this.#d,e)}async open(){this.stop=j.on(e=>this.hear(e));let e=j.iso;e?.start&&e.note===this.note.id&&(e.state===`reading`||e.state===`writing`)&&(this.hear(e.start),this.asking&&={...this.asking,text:e.text??``,steps:e.steps});try{this.entries=await j.api.journal(this.note.id)}catch{}}close(){this.stop?.()}hear(e){if(e.type===`journal`){if(e.id!==this.note.id||this.entries.some(t=>t.id===e.entry.id))return;this.entries=[...this.entries,e.entry];let t=e.entry.kind===`discard`||e.entry.kind===`change`?e.entry.proposal:void 0;t&&this.editing?.id===t&&(this.editing=null);return}if(e.type===`note-changed`||e.type===`record`||e.type===`agent-sent`||!(`note`in e)||e.note!==this.note.id)return;if(e.type===`iso-start`){if(this.asking&&!this.asking.request){this.asking={...this.asking,request:e.request};return}let t=this.foot;if(e.place.form===`insert`||e.place.form===`rewrite`){let n=de(this.note.text,{form:`insert`,after:e.place.after,before:e.place.before});n?.form===`insert`&&(t=n.line)}this.asking={request:e.request,asked:e.asked,line:t,regions:e.place.form===`rewrite`?e.place.regions:[],text:``,steps:[]},this.failed=null,this.prompt=null;return}let t=this.asking;t&&t.request===e.request&&(e.type===`iso-text`?this.asking={...t,text:e.again?e.delta:t.text+e.delta}:e.type===`iso-step`?this.asking={...t,text:``,steps:[...t.steps,e.step]}:(e.type===`iso-failed`&&(this.failed={line:t.line,message:e.message}),this.asking=null))}promptAt(e,t){let n=oe(this.note.text).find(t=>t.from<=e&&e<t.to);this.failed=null,this.prompt={line:n?n.to:e,mode:`insert`,regions:[]},t&&t.to>t.from&&(this.setMode(`rewrite`),this.pick([t]))}promptHere(){let e=this.cursor;e?this.promptAt(e.line,e):this.promptAt(this.foot)}askAt(e,t){if(t&&t.to>t.from){this.promptAt(e,t);return}let n=oe(this.note.text).find(t=>t.from<=e&&e<t.to),r=n?.text.trim()??``;!n||!r||/^(```|~~~|\$\$|\|)/.test(r)?this.promptAt(e):(this.failed=null,this.prompt={line:n.to,mode:`insert`,regions:[]},this.ask(r))}askHere(){let e=this.cursor;e?this.askAt(e.line,e):this.promptAt(this.foot)}setMode(e){this.prompt&&={...this.prompt,mode:e}}get picking(){return this.prompt?.mode===`rewrite`}pick(e){let t=this.prompt;if(!t)return;let n=this.note.text,r=this.spans(t.regions);for(let t of e){let{from:e,to:i}=t;for(;e<i&&/\s/.test(n[e]);)e++;for(;i>e&&/\s/.test(n[i-1]);)i--;if(i<=e||e<this.head.chars)continue;let a=r.filter(t=>t.from<=i&&e<=t.to);r=[...r.filter(e=>!a.includes(e)),{from:Math.min(e,...a.map(e=>e.from)),to:Math.max(i,...a.map(e=>e.to))}]}r.sort((e,t)=>e.from-t.from),this.prompt={...t,regions:r.map(e=>ce(n,e.from,e.to))}}unpick(e){let t=this.prompt;if(!t)return;let n=t.regions.filter(t=>{let n=le(this.note.text,t);return!n||e<n.from||e>=n.to});n.length!==t.regions.length&&(this.prompt={...t,regions:n})}clearPicked(){this.prompt&&={...this.prompt,regions:[]}}setTier(e){be.setTier(e)}async ask(e){let t=this.prompt;if(!t||!e.trim()||this.asking||t.mode===`rewrite`&&!t.regions.length)return;let n=t.mode===`rewrite`?t.regions:[];this.prompt=null,this.failed=null,this.asking={request:``,asked:e,line:t.line,regions:n,text:``,steps:[]};try{await this.note.save();let r=Ee(this.note.text,t.line),i=be.of(this.note.id),a=Object.keys(i).length?{choice:i}:{},{request:o}=await j.api.ask(n.length?{note:this.note.id,form:`rewrite`,regions:n,after:r.after,before:r.before,asked:e,tier:this.tier,...a}:{note:this.note.id,...r,asked:e,tier:this.tier,...a});this.asking&&!this.asking.request&&(this.asking={...this.asking,request:o})}catch(e){this.asking=null,this.failed={line:t.line,message:e.message}}}async send(){if(this.asking)return``;this.failed=null,this.asking={request:``,asked:``,line:this.foot,regions:[],text:``,steps:[]};try{await this.note.save();let{request:e}=await j.api.ask({note:this.note.id,form:`note`,tier:this.tier});return this.asking&&!this.asking.request&&(this.asking={...this.asking,request:e}),e}catch(e){return this.asking=null,this.failed={line:this.foot,message:e.message},``}}halt(){let e=this.asking;if(!e)return;if(e.request){j.api.stop(e.request);return}let t=j.on(e=>{e.type===`iso-start`&&e.note===this.note.id&&(t(),j.api.stop(e.request))})}say(e,t){this.failed={line:e??this.foot,message:t.message}}lineOf(e){return this.layout.blocks.find(t=>t.key===`p:${e.id}`)?.line}edit(e){this.editing={id:e.id,text:e.text}}async done(e){let t=this.editing;if(t?.id===e.id)try{await j.api.revise(this.note.id,e.id,t.text),this.editing=null}catch(t){this.say(this.lineOf(e),t)}}async keep(e){this.busy=e.id;try{await this.note.save(),this.editing?.id===e.id&&await this.done(e),this.note.adopt(await j.api.keep(this.note.id,e.id))}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async discard(e){this.busy=e.id;try{await j.api.discard(this.note.id,e.id)}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async keepChange(e){this.busy=e.key;try{await this.note.save(),this.note.adopt(await j.api.keep(this.note.id,e.proposal.id,e.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}async discardChange(e){this.busy=e.key;try{await j.api.discard(this.note.id,e.proposal.id,e.k)}catch(e){this.say(void 0,e)}finally{this.busy=``}}async settleAll(e){this.busy=`all`;try{e&&await this.note.save();for(let t of[...this.changes].reverse())(!e||t.at)&&(e?this.note.adopt(await j.api.keep(this.note.id,t.proposal.id,t.k)):await j.api.discard(this.note.id,t.proposal.id,t.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}},lt=1500,ut=e=>`isorite.draft.${e}`;function dt(e,t){try{if(t===void 0)return JSON.parse(localStorage.getItem(ut(e))??`null`);t?localStorage.setItem(ut(e),JSON.stringify(t)):localStorage.removeItem(ut(e))}catch{}return null}var ft=e=>typeof e==`string`?e:e==null?``:String(e),pt=class{id;#e=e(`loading`);get loaded(){return c(this.#e)}set loaded(e){d(this.#e,e,!0)}#t=e(`saved`);get saving(){return c(this.#t)}set saving(e){d(this.#t,e,!0)}#n=e(``);get message(){return c(this.#n)}set message(e){d(this.#n,e,!0)}#r=e(``);get text(){return c(this.#r)}set text(e){d(this.#r,e,!0)}#i=e(void 0);get theirs(){return c(this.#i)}set theirs(e){d(this.#i,e)}#a=e(0);get revision(){return c(this.#a)}set revision(e){d(this.#a,e,!0)}base=``;saved=``;timer=null;inFlight=null;stop=null;constructor(e){this.id=e}#o=O(()=>{try{return se(this.text)[0]??{}}catch{return null}});get meta(){return c(this.#o)}set meta(e){d(this.#o,e)}#s=O(()=>{let e=this.meta??{};return{title:ft(e.title),type:ft(e.type),description:ft(e.description),tags:Array.isArray(e.tags)?e.tags.map(String).join(`, `):ft(e.tags)}});get fields(){return c(this.#s)}set fields(e){d(this.#s,e)}#c=O(()=>{try{return A(this.text)[2]}catch{return this.text}});get body(){return c(this.#c)}set body(e){d(this.#c,e)}async open(){try{let e=await j.api.readNote(this.id),t=dt(this.id);this.take(e),t&&t.text!==e.text&&(this.text=t.text,t.base===e.version?this.changed():(this.theirs=e,this.saving=`conflict`,dt(this.id,t))),this.loaded=`ready`,this.stop=j.on(e=>this.hear(e))}catch(e){this.loaded=e instanceof De&&e.status===404?`missing`:`error`,this.message=e.message}}async close(){this.stop?.(),await this.save()}adopt(e){this.take(e)}async restore(e){await this.settle(),this.take(await j.api.restore(this.id,e,this.base))}async move(e){await this.settle();let t=await j.api.moveNote(this.id,e,this.base);return this.stop?.(),t.id}async setDone(e){await this.settle(),this.take(await j.api.setDone(this.id,e,this.base)),await j.refresh()}async remove(){await this.settle(),await j.api.deleteNote(this.id,this.base),this.stop?.()}async settle(){if(this.saving!==`saved`&&await this.save(),this.saving!==`saved`)throw Error(this.message||`the note could not be saved first`)}take(e){this.text=this.saved=e.text,this.base=e.version,this.theirs=void 0,this.saving=`saved`,this.message=``,dt(this.id,null),this.revision++}setText(e){e!==this.text&&(this.text=e,this.changed())}setBody(e){e!==this.body&&this.setText(ge(this.text,{},e))}setFields(e){let t={};for(let[n,r]of Object.entries(e)){let e=r.trim();t[n]=n===`tags`?e?e.split(`,`).map(e=>e.trim()).filter(Boolean):null:e||null}this.setMeta(t)}setMeta(e){try{this.setText(ge(this.text,e,null))}catch{}}changed(){dt(this.id,{base:this.base,text:this.text}),this.saving!==`conflict`&&(this.saving=`unsaved`,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.save()},lt))}save(){return this.timer&&=(clearTimeout(this.timer),null),this.inFlight=(this.inFlight??Promise.resolve()).then(()=>this.send()),this.inFlight}async send(){if(this.loaded!==`ready`||this.saving===`conflict`||this.text===this.saved)return;let e=this.text;this.saving=`saving`;try{let t=await j.api.saveNote(this.id,{base:this.base,text:e});this.base=t.version,this.saved=e,this.message=``,this.text===e?(this.saving=`saved`,dt(this.id,null)):this.changed()}catch(t){if(t instanceof De&&t.status===409&&t.current!==void 0){if(t.current?.text===e)return this.take(t.current);this.theirs=t.current,this.saving=`conflict`}else this.saving=`failed`,this.message=t.message,this.timer=setTimeout(()=>{this.save()},5e3)}}hear(e){e.type===`note-changed`&&e.id===this.id&&e.version!==this.base&&e.version!==Te(this.text)&&this.saving===`saved`&&j.api.readNote(this.id).then(e=>{this.saving===`saved`&&e.version!==this.base&&this.take(e)},()=>void 0)}keepMine(){let e=this.theirs;return e===void 0?Promise.resolve():(this.theirs=void 0,this.saving=`unsaved`,e===null?j.api.createNote(this.id,this.text).then(e=>this.take(e),e=>{this.saving=`failed`,this.message=e.message}):(this.base=e.version,this.saved=e.text,this.save()))}keepTheirs(){this.theirs&&this.take(this.theirs)}},mt=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=yt(e.state,n.from);return r.line?gt(e):r.block?vt(e):!1};function ht(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var gt=ht(wt,0),_t=ht(Ct,0),vt=ht((e,t)=>Ct(e,t,St(t)),0);function yt(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var bt=50;function xt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-bt,r),o=e.sliceDoc(i,i+bt),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+bt),d=e.sliceDoc(i-bt,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function St(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ct(e,t,n=t.selection.ranges){let r=n.map(e=>yt(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function wt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=yt(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Tt=Be.define(),Et=Be.define(),Dt=Ve.define(),Ot=Ve.define({combine(e){return We(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),kt=R.define({create(){return Kt.empty},update(e,t){let n=t.state.facet(Ot),r=t.annotation(Tt);if(r){let i=z.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?It(o,o.length,n.minDepth,i):Vt(o,t.startState.selection),new Kt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Ue.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=z.fromTransaction(t),o=t.annotation(Ue.time),s=t.annotation(Ue.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Kt(e.done.map(z.fromJSON),e.undone.map(z.fromJSON))}});function At(e={}){return[kt,Ot.of(e),N.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Mt:e.inputType==`historyRedo`?Nt:null;return n?(e.preventDefault(),n(t)):!1}})]}function jt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(kt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Mt=jt(0,!1),Nt=jt(1,!1),Pt=jt(0,!0),Ft=jt(1,!0),z=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Ie.fromJSON(t.changes),[],t.mapped&&Ne.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=B;for(let e of t.startState.facet(Dt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,B)}static selection(t){return new e(void 0,B,void 0,void 0,t)}};function It(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Lt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Rt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function zt(e,t){return e.length?t.length?e.concat(t):e:t}var B=[],Bt=200;function Vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),It(e,e.length-1,1e9,n.setSelAfter(r)))}return[z.selection([t])]}function Ht(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ut(e,t){if(!e.length)return e;let n=e.length,r=B;for(;n;){let i=Wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[z.selection(r)]:B}function Wt(e,t,n){let r=zt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):B,n);if(!e.changes)return z.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new z(i,Xe.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Gt=/^(input\.type|delete)($|\.)/,Kt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Gt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Lt(s.changes,t.changes))||r==`input.type.compose`)?It(o,o.length-1,i.minDepth,new z(t.changes.compose(s.changes),zt(Xe.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,B)):It(o,o.length,i.minDepth,t),new e(o,B,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:B;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Rt(a[a.length-1],t)?this:new e(Vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ut(this.done,t),Ut(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Tt.of({side:e,rest:Ht(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?B:r.slice(0,r.length-1);return i.mapped&&(n=Ut(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Tt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Kt.empty=new Kt(B,B);var qt=[{key:`Mod-z`,run:Mt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Nt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Nt,preventDefault:!0},{key:`Mod-u`,run:Pt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Ft,preventDefault:!0}];function V(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function H(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function U({state:e,dispatch:t},n){let r=V(e.selection,n);return!r.eq(e.selection,!0)&&(t(H(e,r)),!0)}function Jt(e,t){return P.cursor(t?e.to:e.from)}function Yt(e,t){return U(e,n=>n.empty?e.moveByChar(n,t):Jt(n,t))}function W(e){return e.textDirectionAt(e.state.selection.main.head)==Le.LTR}var Xt=e=>Yt(e,!W(e)),Zt=e=>Yt(e,W(e));function Qt(e,t){return U(e,n=>n.empty?e.moveByGroup(n,t):Jt(n,t))}var $t=e=>Qt(e,!W(e)),en=e=>Qt(e,W(e));typeof Intl<`u`&&Intl.Segmenter;function tn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function nn(e,t,n){let r=M(e).resolveInner(t.head),i=n?Je.closedBy:Je.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;tn(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?et(e,r.from,1):et(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var rn=e=>U(e,t=>nn(e.state,t,!W(e))),an=e=>U(e,t=>nn(e.state,t,W(e)));function on(e,t){return U(e,n=>{if(!n.empty)return Jt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(N.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function un(e,t){let n=ln(e),{state:r}=e,i=V(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Jt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=N.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(H(r,i),{effects:a}),!0}var dn=e=>un(e,!1),fn=e=>un(e,!0);function G(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var pn=e=>U(e,t=>G(e,t,!0)),mn=e=>U(e,t=>G(e,t,!1)),hn=e=>U(e,t=>G(e,t,!W(e))),gn=e=>U(e,t=>G(e,t,W(e))),_n=e=>U(e,t=>e.moveToLineBoundary(t,!1,!1)),vn=e=>U(e,t=>e.moveToLineBoundary(t,!0,!1));function yn(e,t,n){let r=!1,i=V(e.selection,t=>{let i=et(e,t.head,-1)||et(e,t.head,1)||t.head>0&&et(e,t.head-1,1)||t.head<e.doc.length&&et(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(H(e,i)),!0):!1}var bn=({state:e,dispatch:t})=>yn(e,t,!1);function K(e,t,n){let r=V(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=P.range(e.head,e.anchor));let r=n(e);return P.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(H(e.state,r)),!0)}function xn(e,t){return K(e,t,n=>e.moveByChar(n,t))}var Sn=e=>xn(e,!W(e)),Cn=e=>xn(e,W(e));function wn(e,t){return K(e,t,n=>e.moveByGroup(n,t))}var Tn=e=>wn(e,!W(e)),En=e=>wn(e,W(e)),Dn=e=>{let t=!W(e);return K(e,t,n=>nn(e.state,n,t))},On=e=>{let t=W(e);return K(e,t,n=>nn(e.state,n,t))};function kn(e,t){return K(e,t,n=>e.moveVertically(n,t))}var An=e=>kn(e,!1),jn=e=>kn(e,!0);function Mn(e,t){return K(e,t,n=>e.moveVertically(n,t,ln(e).height))}var Nn=e=>Mn(e,!1),Pn=e=>Mn(e,!0),Fn=e=>K(e,!0,t=>G(e,t,!0)),In=e=>K(e,!1,t=>G(e,t,!1)),Ln=e=>{let t=!W(e);return K(e,t,n=>G(e,n,t))},Rn=e=>{let t=W(e);return K(e,t,n=>G(e,n,t))},zn=e=>K(e,!1,t=>P.cursor(e.lineBlockAt(t.head).from)),Bn=e=>K(e,!0,t=>P.cursor(e.lineBlockAt(t.head).to)),Vn=({state:e,dispatch:t})=>(t(H(e,{anchor:0})),!0),Hn=({state:e,dispatch:t})=>(t(H(e,{anchor:e.doc.length})),!0),Un=({state:e,dispatch:t})=>(t(H(e,{anchor:e.selection.main.anchor,head:0})),!0),Wn=({state:e,dispatch:t})=>(t(H(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Gn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Kn=({state:e,dispatch:t})=>{let n=dr(e).map(({from:t,to:n})=>P.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},qn=({state:e,dispatch:t})=>{let n=V(e.selection,t=>{let n=M(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(H(e,n)),!0)};function Jn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(H(n,P.create(i,i.length-1))),!0)}var Yn=e=>Jn(e,!1),Xn=e=>Jn(e,!0),Zn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(H(e,r)),!0):!1};function Qn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=$n(e,o,!1)):o>i&&(n=`delete.forward`,o=$n(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=$n(e,i,!1),a=$n(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?N.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function $n(e,t,n){if(e instanceof N)for(let r of e.state.facet(N.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var er=(e,t,n)=>Qn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=qe(s,a.tabSize)%$e(a)||$e(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=Qe(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=Qe(o.text,c-o.from,!1,!1)+o.from);return c}),tr=e=>er(e,!1,!0),nr=e=>er(e,!0,!1),rr=(e,t)=>Qn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=Qe(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),ir=e=>rr(e,!1),ar=e=>rr(e,!0),or=e=>Qn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),sr=e=>Qn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),cr=e=>Qn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),lr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Ke.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:Qe(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:Qe(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function dr(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function fr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of dr(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var pr=({state:e,dispatch:t})=>fr(e,t,!1),mr=({state:e,dispatch:t})=>fr(e,t,!0);function hr(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of dr(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var gr=({state:e,dispatch:t})=>hr(e,t,!1),_r=({state:e,dispatch:t})=>hr(e,t,!0),vr=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(dr(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=V(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function yr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=M(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Je.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var br=Sr(!1),xr=Sr(!0);function Sr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&yr(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Ye(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=nt(s,r);for(c??=qe(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,tt(t,c)];return o&&l.push(tt(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:Ke.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Cr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var wr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ye(e,{overrideIndentation:e=>n[e]??-1}),i=Cr(e,(t,i,a)=>{let o=nt(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=tt(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},Tr=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Cr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ze)})}),{userEvent:`input.indent`})),!0),Er=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Cr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=qe(r,e.tabSize),a=0,o=tt(e,Math.max(0,i-$e(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Dr=e=>(e.setTabFocusMode(),!0),Or=[{key:`Ctrl-b`,run:Xt,shift:Sn,preventDefault:!0},{key:`Ctrl-f`,run:Zt,shift:Cn},{key:`Ctrl-p`,run:sn,shift:An},{key:`Ctrl-n`,run:cn,shift:jn},{key:`Ctrl-a`,run:_n,shift:zn},{key:`Ctrl-e`,run:vn,shift:Bn},{key:`Ctrl-d`,run:nr},{key:`Ctrl-h`,run:tr},{key:`Ctrl-k`,run:or},{key:`Ctrl-Alt-h`,run:ir},{key:`Ctrl-o`,run:lr},{key:`Ctrl-t`,run:ur},{key:`Ctrl-v`,run:fn}],kr=[{key:`ArrowLeft`,run:Xt,shift:Sn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:$t,shift:Tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:hn,shift:Ln,preventDefault:!0},{key:`ArrowRight`,run:Zt,shift:Cn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:en,shift:En,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:gn,shift:Rn,preventDefault:!0},{key:`ArrowUp`,run:sn,shift:An,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Vn,shift:Un},{mac:`Ctrl-ArrowUp`,run:dn,shift:Nn},{key:`ArrowDown`,run:cn,shift:jn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Hn,shift:Wn},{mac:`Ctrl-ArrowDown`,run:fn,shift:Pn},{key:`PageUp`,run:dn,shift:Nn},{key:`PageDown`,run:fn,shift:Pn},{key:`Home`,run:mn,shift:In,preventDefault:!0},{key:`Mod-Home`,run:Vn,shift:Un},{key:`End`,run:pn,shift:Fn,preventDefault:!0},{key:`Mod-End`,run:Hn,shift:Wn},{key:`Enter`,run:br,shift:br},{key:`Mod-a`,run:Gn},{key:`Backspace`,run:tr,shift:tr,preventDefault:!0},{key:`Delete`,run:nr,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:ir,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:ar,preventDefault:!0},{mac:`Mod-Backspace`,run:sr,preventDefault:!0},{mac:`Mod-Delete`,run:cr,preventDefault:!0}].concat(Or.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Ar=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:rn,shift:Dn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:an,shift:On},{key:`Alt-ArrowUp`,run:pr},{key:`Shift-Alt-ArrowUp`,run:gr},{key:`Alt-ArrowDown`,run:mr},{key:`Shift-Alt-ArrowDown`,run:_r},{key:`Mod-Alt-ArrowUp`,run:Yn},{key:`Mod-Alt-ArrowDown`,run:Xn},{key:`Escape`,run:Zn},{key:`Mod-Enter`,run:xr},{key:`Alt-l`,mac:`Ctrl-l`,run:Kn},{key:`Mod-i`,run:qn,preventDefault:!0},{key:`Mod-[`,run:Er},{key:`Mod-]`,run:Tr},{key:`Mod-Alt-\\`,run:wr},{key:`Shift-Mod-k`,run:vr},{key:`Shift-Mod-\\`,run:bn},{key:`Mod-/`,run:mt},{key:`Alt-A`,mac:`Ctrl-A`,run:_t},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Dr}].concat(kr),jr={key:`Tab`,run:Tr,shift:Er},Mr=Ve.define({combine:e=>e[0]??null}),Nr=/^[ \t]*\[\[!([^\]\n]+)\]\][ \t]*$/,Pr={question:`<path d="M5.6 5.6a2.4 2.4 0 1 1 3.4 2.2c-.6.3-1 .8-1 1.5v.9"/><path d="M8 12v1.2"/>`,problem:`<path d="M8 2.5l5.8 10.5H2.2z"/>`,note:`<rect x="3.5" y="2.5" width="9" height="11"/>`},Fr=`<path d="M3 8.5l3 3 7-7"/>`,Ir=class extends F{ref;found;at;constructor(e,t,n){super(),this.ref=e,this.found=t,this.at=n}eq(e){return e.ref===this.ref&&JSON.stringify(e.found)===JSON.stringify(this.found)&&e.at===this.at}toDOM(e){let t=this.found,n=document.createElement(`div`);n.className=`cm-lp-embed${t?` cm-lp-embed-${t.kind}`:` cm-lp-embed-broken`}${t?.done?` cm-lp-embed-done`:``}`,n.title=`[[!${this.ref}]]`;let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`viewBox`,`0 0 16 16`),r.setAttribute(`width`,`16`),r.setAttribute(`height`,`16`),r.setAttribute(`aria-hidden`,`true`),r.innerHTML=t?.done?Fr:Pr[t?.kind??`question`];let i=document.createElement(`span`);return i.textContent=t?t.title:this.ref,n.append(r,i),n.addEventListener(`mousedown`,n=>{n.preventDefault(),t&&!n.altKey?e.state.facet(Mr)?.open(t.id):(e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus())}),n}ignoreEvent(){return!0}get estimatedHeight(){return 44}},Lr=class extends F{kind;source;at;beneath;constructor(e,t,n,r){super(),this.kind=e,this.source=t,this.at=n,this.beneath=r}eq(e){return e.kind===this.kind&&e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-${this.kind}${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`div`);return n.className=`prose`,t.append(n),n.innerHTML=he(this.source),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}ignoreEvent(){return!0}get estimatedHeight(){return this.kind===`maths`?60:120}},Rr=new WeakMap,zr=class extends F{source;at;beneath;constructor(e,t,n){super(),this.source=e,this.at=t,this.beneath=n}eq(e){return e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-diagram${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`pre`);n.className=`cm-lp-diagram-src`,n.textContent=this.source;let r=document.createElement(`div`);return r.className=`diagram`,t.append(n,r),Rr.set(t,{mounted:ve(r,this.source,()=>t.classList.add(`cm-lp-broken-diagram`)),source:this.source}),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}updateDOM(e){let t=Rr.get(e);return!t||!this.beneath||!e.classList.contains(`cm-lp-beneath`)?!1:(t.source!==this.source&&(t.source=this.source,e.classList.remove(`cm-lp-broken-diagram`),e.querySelector(`.cm-lp-diagram-src`).textContent=this.source,t.mounted.then(e=>xe(e,this.source))),!0)}ignoreEvent(){return!0}get estimatedHeight(){return 160}},Br=(e,t)=>t!==null&&e.sliceDoc(t.from,t.to).trim().split(/\s/)[0].toLowerCase()===`mermaid`;function Vr(e){let t=[],n=e.selection.ranges;M(e).iterate({enter:r=>{let i=null,a=``;if(r.name===`BlockMath`)i=`maths`,a=e.sliceDoc(r.from,r.to);else if(r.name===`Table`)i=`table`,a=e.sliceDoc(r.from,r.to);else if(r.name===`FencedCode`&&Br(e,r.node.getChild(`CodeInfo`))){let i=r.node.getChild(`CodeText`),a=i?e.sliceDoc(i.from,i.to):``,o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?a.trim()&&t.push(L.widget({widget:new zr(a,r.from,!0),block:!0,side:1}).range(s)):t.push(L.replace({widget:new zr(a,r.from,!1),block:!0}).range(o,s)),!1}else if(r.name===`Document`||r.name===`Blockquote`||/List|ListItem/.test(r.name))return;if(!i)return!1;let o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?i!==`table`&&a.trim()&&t.push(L.widget({widget:new Lr(i,a,r.from,!0),block:!0,side:1}).range(s)):t.push(L.replace({widget:new Lr(i,a,r.from,!1),block:!0}).range(o,s)),!1}});let r=e.facet(Mr);if(r){let i=!1;for(let a=1;a<=e.doc.lines;a++){let o=e.doc.line(a);if(/^\s*(```|~~~)/.test(o.text)){i=!i;continue}let s=i?null:Nr.exec(o.text);if(!s||n.some(e=>e.to>=o.from&&e.from<=o.to))continue;let c=s[1].trim();t.push(L.replace({widget:new Ir(c,r.find(c),o.from),block:!0}).range(o.from,o.to))}}return L.set(t,!0)}var Hr=R.define({create:Vr,update(e,t){return t.docChanged||t.selection||M(t.startState)!==M(t.state)?Vr(t.state):e},provide:e=>N.decorations.from(e)}),Ur=N.theme({".cm-lp-block":{padding:`0`,cursor:`text`},".cm-lp-block .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-block .prose":{maxWidth:`none`},".cm-lp-block .prose > :last-child, .cm-lp-block .table-wrap":{marginBottom:`0`},".cm-lp-block .katex-display":{margin:`0`},".cm-lp-diagram .diagram":{overflowX:`auto`,overflowY:`hidden`},".cm-lp-diagram-src":{display:`none`,margin:`0`,font:`13px/20px var(--font-mono)`,whiteSpace:`pre-wrap`,color:`var(--text-soft)`},".cm-lp-diagram.cm-lp-broken-diagram:not(.cm-lp-beneath) .cm-lp-diagram-src":{display:`block`},".cm-lp-beneath":{borderLeft:`2px solid var(--line)`,paddingLeft:`12px`,marginTop:`4px`,opacity:`.9`},".cm-lp-block:not(.cm-lp-beneath):hover":{outline:`1px dashed var(--line)`,outlineOffset:`2px`},".cm-lp-embed":{display:`flex`,alignItems:`center`,gap:`10px`,padding:`9px 12px`,border:`1px solid var(--rose)`,borderLeftWidth:`3px`,background:`var(--rose-soft)`,fontFamily:`var(--font-text)`,fontSize:`16px`,lineHeight:`1.45`,cursor:`pointer`},".cm-lp-embed svg":{flex:`none`,fill:`none`,stroke:`var(--rose)`,strokeWidth:`1.4`},".cm-lp-embed-problem":{borderColor:`var(--line-strong)`,background:`var(--ground-1)`},".cm-lp-embed-problem svg":{stroke:`var(--text-soft)`},".cm-lp-embed-done":{borderColor:`var(--malachite)`,background:`var(--malachite-soft)`},".cm-lp-embed-done svg":{stroke:`var(--malachite)`},".cm-lp-embed-broken":{borderStyle:`dashed`,borderColor:`var(--line-strong)`,background:`none`,color:`var(--text-faint)`},".cm-lp-embed-broken svg":{stroke:`var(--text-faint)`},".cm-lp-embed:hover":{borderColor:`var(--text-soft)`}});function Wr(e,t){let{state:n}=e,r=t.length;return e.dispatch(n.changeByRange(e=>{let i=n.sliceDoc(e.from-r,e.from),a=n.sliceDoc(e.to,e.to+r);return i===t&&a===t?{changes:[{from:e.from-r,to:e.from},{from:e.to,to:e.to+r}],range:P.range(e.from-r,e.to-r)}:{changes:[{from:e.from,insert:t},{from:e.to,insert:t}],range:P.range(e.from+r,e.to+r)}}),{scrollIntoView:!0,userEvent:`input`}),!0}function Gr(e){let{state:t}=e,n=new Map;for(let e of t.selection.ranges)for(let r=e.from;r<=e.to;){let e=t.doc.lineAt(r);n.set(e.number,{from:e.from,text:e.text}),r=e.to+1}return[...n.values()]}function Kr(e){let t=Gr(e).map(({from:e,text:t})=>{let n=/^(#{1,6}) /.exec(t),r=n?n[1].length:0,i=r>=3?``:`#`.repeat(r+1)+` `;return{from:e,to:e+(n?n[0].length:0),insert:i}});return e.dispatch({changes:t,scrollIntoView:!0,userEvent:`input`}),!0}function qr(e){let t=Gr(e),n=t.every(({text:e})=>/^\s*[-*+] /.test(e)),r=t.map(({from:e,text:t})=>{if(n){let n=/^(\s*)[-*+] /.exec(t);return{from:e+n[1].length,to:e+n[0].length}}return{from:e+/^\s*/.exec(t)[0].length,insert:`- `}});return e.dispatch({changes:r,scrollIntoView:!0,userEvent:`input`}),!0}function Jr(e){let{state:t}=e,n=t.selection.main;if(n.empty)e.dispatch({changes:{from:n.from,insert:`[[]]`},selection:{anchor:n.from+2},userEvent:`input`});else{let r=t.sliceDoc(n.from,n.to);e.dispatch({changes:{from:n.from,to:n.to,insert:`[${r}]()`},selection:{anchor:n.from+r.length+3},userEvent:`input`})}return it(e),!0}function q(e,t){switch(t){case`bold`:return Wr(e,`**`);case`italic`:return Wr(e,`*`);case`maths`:return Wr(e,`$`);case`heading`:return Kr(e);case`list`:return qr(e);case`link`:return Jr(e);case`undo`:return Mt(e);case`redo`:return Nt(e)}}var Yr=[{key:`Mod-b`,preventDefault:!0,run:e=>q(e,`bold`)},{key:`Mod-i`,preventDefault:!0,run:e=>q(e,`italic`)},{key:`Mod-k`,preventDefault:!0,run:e=>q(e,`link`)},{key:`Mod-Shift-m`,preventDefault:!0,run:e=>q(e,`maths`)},{key:`Mod-Shift-h`,preventDefault:!0,run:e=>q(e,`heading`)},{key:`Mod-Shift-8`,preventDefault:!0,run:e=>q(e,`list`)}],Xr=[`requires`,`uses`,`see also`];function Zr(e){if(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`#`))return null;let t=e.split(`#`)[0].split(`?`)[0];return/\.html?$/i.test(t)?`artifact`:/\.(png|jpe?g|gif|svg|webp|avif)$/i.test(t)?`image`:/\.md$/i.test(t)||t.endsWith(`/`)?`note`:null}function J(e,t){let n=M(e);for(let r of[-1,1])for(let i=n.resolveInner(t,r);i;i=i.parent){if(i.name!==`Link`&&i.name!==`Image`)continue;let t=i.getChild(`URL`);if(!t)break;let n=e.sliceDoc(t.from,t.to),r=Zr(n);if(!r)return null;let a=i.getChild(`LinkTitle`),o=a?e.sliceDoc(a.from,a.to):null;return{from:i.from,to:i.to,embed:i.name===`Image`,url:n,urlTo:t.to,title:o===null?null:o.replace(/^["'(]|["')]$/g,``),titleFrom:a?a.from:t.to,titleTo:a?a.to:t.to,kind:r}}return null}var Qr=e=>e.kind===`note`||e.kind===`artifact`&&!e.embed;function $r(e,t,n){let r=[];return M(e).iterate({from:t,to:n,enter:i=>{if(i.name!==`Link`&&i.name!==`Image`)return;if(i.from<t||i.to>n)return!1;let a=J(e,i.from+1);return a&&a.from===i.from&&Qr(a)&&r.push(a),!1}}),r}var ei=(e,t)=>e.filter(e=>Y(e)!==t).map(e=>X(e,t)),ti=e=>(e??``).trim().toLowerCase().replace(/[-_]/g,` `),Y=e=>Xr.includes(ti(e.title))?ti(e.title):ti(e.title)===`seealso`?`see also`:null,ni=e=>ti(e.title)===`left`?`left`:`center`;function X(e,t){return t===null?{from:e.urlTo,to:e.titleTo,insert:``}:e.titleFrom===e.titleTo?{from:e.urlTo,insert:` "${t}"`}:{from:e.titleFrom,to:e.titleTo,insert:`"${t}"`}}function ri(e,t){if(e.embed===t)return[];let n=[t?{from:e.from,insert:`!`}:{from:e.from,to:e.from+1,insert:``}];return e.title!==null&&(e.kind===`image`||Y(e)!==null)&&n.push(X(e,null)),n}var Z=(e,t)=>e.dispatch({changes:t,userEvent:`input.link`});function ii(e){let t=[...Xr.map(t=>({label:t[0].toUpperCase()+t.slice(1),on:Y(e)===t,run:(e,n)=>Z(e,X(n,t)),hint:t===`requires`?`This note cannot be followed without it: it shapes the Atlas and the study order`:t===`uses`?`It draws on it: it shapes the Atlas`:`Related reading: shown, but it does not shape the Atlas`})),{label:`Unrated`,on:Y(e)===null,run:(e,t)=>Z(e,X(t,null)),hint:`No rating: counted as uses`}];if(e.kind===`note`)return t;let n=[{label:`Shown here`,on:e.embed,run:(e,t)=>Z(e,ri(t,!0)),hint:e.kind===`image`?`The picture is shown in the note`:`The artifact is shown in the note, working`},{label:`Link`,on:!e.embed,run:(e,t)=>Z(e,ri(t,!1)),hint:`A link to it; it opens on its own`}];return e.kind===`image`?e.embed?[...n,{label:`Centre`,on:ni(e)===`center`,run:(e,t)=>Z(e,X(t,null)),hint:`In the middle, 80% of the text's width`},{label:`Left`,on:ni(e)===`left`,run:(e,t)=>Z(e,X(t,`left`)),hint:`At the left, 80% of the text's width`}]:n:e.embed?n:[...n,...t]}function ai(e){let t=t=>e.every(e=>Y(e)===t),n=e.length;return[...Xr.map(e=>({label:e[0].toUpperCase()+e.slice(1),on:t(e),run:t=>Z(t,ei($r(t.state,t.state.selection.main.from,t.state.selection.main.to),e)),hint:`Rate all ${n} links ${e}`})),{label:`Unrated`,on:t(null),run:e=>Z(e,ei($r(e.state,e.state.selection.main.from,e.state.selection.main.to),null)),hint:`Take the rating from all ${n} links`}]}function oi(e){let t=Y(e[0]),n=e.every(e=>Y(e)===t);return`${e.length} links, ${n?t??`unrated`:`mixed`}`}function si(e){return e.kind===`note`?Y(e)?Y(e)[0].toUpperCase()+Y(e).slice(1):`Unrated`:e.embed?e.kind===`image`?ni(e)===`left`?`Shown, left`:`Shown, centre`:`Shown here`:Y(e)?`Link, ${Y(e)}`:`Link`}var ci=(e,t)=>e===t||!!e&&!!t&&e.from===t.from&&e.to===t.to&&e.title===t.title&&e.embed===t.embed,li=class{view;layer;button;menu;leader;path;link=null;hover=null;many=[];open=!1;at=0;constructor(e){this.view=e,this.layer=document.createElement(`div`),this.layer.className=`cm-link-control`,this.layer.hidden=!0,this.leader=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this.leader.setAttribute(`class`,`cm-link-leader`),this.leader.setAttribute(`aria-hidden`,`true`),this.path=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),this.leader.append(this.path),this.button=document.createElement(`button`),this.button.type=`button`,this.button.className=`cm-link-button`,this.button.setAttribute(`aria-haspopup`,`menu`),this.button.addEventListener(`mousedown`,e=>e.preventDefault()),this.button.addEventListener(`click`,()=>this.toggle(!this.open,!1)),this.menu=document.createElement(`div`),this.menu.className=`cm-link-menu`,this.menu.setAttribute(`role`,`menu`),this.menu.hidden=!0,this.menu.tabIndex=-1,this.menu.addEventListener(`keydown`,e=>this.keys(e)),this.layer.append(this.leader,this.button,this.menu),e.dom.append(this.layer),e.dom.addEventListener(`mousemove`,this.onMove),e.dom.addEventListener(`mouseleave`,this.onLeave)}onMove=e=>{if(this.open||this.layer.contains(e.target))return;let t=this.view.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t===null?null:J(this.view.state,t);ci(n,this.hover)||(this.hover=n,this.view.requestMeasure(this.measure))};onLeave=e=>{this.open||this.layer.contains(e.relatedTarget)||this.hover&&(this.hover=null,this.view.requestMeasure(this.measure))};selected(){let e=this.view.state.selection.main;if(e.empty)return[];let t=$r(this.view.state,e.from,e.to);return t.length>=2?t:[]}current(){let e=this.view.state.selection.main,t=this.selected();return t.length?t[0]:J(this.view.state,e.head)??(e.empty?this.hover:null)}update(e){e.docChanged&&(this.hover=null),(e.docChanged||e.selectionSet||e.geometryChanged||e.viewportChanged||e.focusChanged)&&this.view.requestMeasure(this.measure)}measure={key:`link-control`,read:e=>{let t=this.current();if(!t)return null;let n=this.selected(),r=e.dom.getBoundingClientRect(),i=e.contentDOM.getBoundingClientRect(),a=e.coordsAtPos(Math.max(t.from,t.to-1),1)??e.coordsAtPos(t.to,-1);if(n.length){let t=Math.max(r.top,0),i=Math.min(r.bottom,window.innerHeight);a=null;for(let r=n.length-1;r>=0&&!a;r--){let o=e.coordsAtPos(Math.max(n[r].from,n[r].to-1),1);o&&o.top>=t&&o.bottom<=i-34&&(a=o)}a??=e.coordsAtPos(Math.max(n[0].from,n[0].to-1),1)}return a?{l:t,many:n,x:a.right-r.left,y:(a.top+a.bottom)/2-r.top,right:i.right-r.left,width:r.width}:null},write:e=>{if(!e){this.link=null,this.many=[],this.layer.hidden=!0,this.toggle(!1,!1);return}let t=e.many.length?oi(e.many):si(e.l),n=!ci(e.l,this.link)||e.many.length!==this.many.length||t!==this.button.textContent;this.link=e.l,this.many=e.many,this.layer.hidden=!1,this.button.textContent=t,this.button.title=e.many.length?`Rate all the selected links (Alt+L)`:`What this link is (Alt+L)`,this.button.setAttribute(`aria-label`,e.many.length?`${t}. Rate them all`:`This link: ${t}. Change it`);let r=this.button.offsetWidth||90,i=e.width-e.right>=r+20,a=i?e.right+14:Math.max(0,e.width-r-2),o=i?e.y-13:e.y+12;this.button.style.transform=`translate(${Math.round(a)}px, ${Math.round(o)}px)`,this.menu.style.transform=`translate(${Math.round(Math.min(a,e.width-250))}px, ${Math.round(o+30)}px)`;let s=a,c=o+13;this.path.setAttribute(`d`,i?`M${e.x+3} ${e.y} H${Math.max(e.x+3,s-3)}`:`M${e.x+3} ${e.y} V${c} H${s-3}`),n&&this.open&&(this.fill(),this.mark(this.at))}};fill(){let e=this.link;e&&this.menu.replaceChildren(...(this.many.length?ai(this.many):ii(e)).map((t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.tabIndex=-1,r.id=`cm-link-choice-${n}`,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`mousemove`,()=>this.mark(n)),r.setAttribute(`role`,`menuitemradio`),r.setAttribute(`aria-checked`,String(t.on)),r.title=t.hint,r.innerHTML=`<b></b><span></span>`,r.querySelector(`b`).textContent=t.label,r.querySelector(`span`).textContent=t.hint,r.addEventListener(`click`,()=>{let n=this.current()??e;t.run(this.view,n),this.toggle(!1,!0)}),r}))}toggle(e,t){if(e&&(this.link=this.current()??this.link,this.many=this.selected()),!e||this.link){if(this.open=e,this.menu.hidden=!e,this.layer.classList.toggle(`open`,e),this.button.setAttribute(`aria-expanded`,String(e)),e){this.fill();let e=[...this.menu.querySelectorAll(`button`)];this.mark(Math.max(0,e.findIndex(e=>e.getAttribute(`aria-checked`)===`true`))),this.menu.focus()}else t&&this.view.focus()}}mark(e){let t=[...this.menu.querySelectorAll(`button`)];this.at=t.length?(e+t.length)%t.length:0,t.forEach((e,t)=>e.classList.toggle(`on`,t===this.at)),this.menu.setAttribute(`aria-activedescendant`,t[this.at]?.id??``)}keys(e){let t=[...this.menu.querySelectorAll(`button`)],n=!0;if(e.key===`Escape`)this.toggle(!1,!0);else if(e.key===`Enter`||e.key===` `)t[this.at]?.click();else if(e.key===`ArrowDown`)this.mark(this.at+1);else if(e.key===`ArrowUp`)this.mark(this.at-1);else if(e.key===`Home`)this.mark(0);else if(e.key===`End`)this.mark(t.length-1);else if(e.key===`Tab`)this.toggle(!1,!0);else if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let r=t.findIndex(t=>t.textContent.toLowerCase().startsWith(e.key.toLowerCase()));r>=0?this.mark(r):n=!1}else n=!1;n&&(e.preventDefault(),e.stopPropagation())}destroy(){this.view.dom.removeEventListener(`mousemove`,this.onMove),this.view.dom.removeEventListener(`mouseleave`,this.onLeave),this.layer.remove()}},ui=Fe.fromClass(li),di=e=>t=>{let n=J(t.state,t.state.selection.main.head);return n?(e(t,n),!0):!1},fi=e=>t=>{let n=t.state.selection.main,r=n.empty?[]:$r(t.state,n.from,n.to);return r.length>=2?(Z(t,ei(r,e)),!0):di((t,n)=>{Qr(n)&&Z(t,X(n,e))})(t)},pi=[{key:`Alt-l`,run:e=>{let t=e.plugin(ui);return!t||!t.current()?!1:(t.toggle(!0,!1),!0)}},{key:`Alt-1`,run:fi(`requires`)},{key:`Alt-2`,run:fi(`uses`)},{key:`Alt-3`,run:fi(`see also`)},{key:`Alt-0`,run:fi(null)},{key:`Alt-e`,run:di((e,t)=>{t.kind!==`note`&&Z(e,ri(t,!t.embed))})}],mi=[ui,N.baseTheme({"&":{position:`relative`},".cm-link-control":{position:`absolute`,inset:`0`,pointerEvents:`none`,zIndex:`4`,overflow:`visible`},".cm-link-control[hidden]":{display:`none`},".cm-link-leader":{position:`absolute`,left:`0`,top:`0`,width:`100%`,height:`100%`,overflow:`visible`},".cm-link-leader path":{fill:`none`,stroke:`var(--lattice)`,strokeWidth:`1.75`,strokeDasharray:`.1 5`,strokeLinecap:`round`,opacity:`.7`},".cm-link-control:hover .cm-link-leader path, .cm-link-control:focus-within .cm-link-leader path, .cm-link-control.open .cm-link-leader path":{opacity:`1`,animation:`cm-link-run .6s linear infinite`},"@keyframes cm-link-run":{to:{strokeDashoffset:`-5.1`}},"@media (prefers-reduced-motion: reduce)":{".cm-link-leader path":{animation:`none !important`}},".cm-link-button":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,height:`26px`,padding:`0 9px`,font:`12.5px var(--font-ui)`,whiteSpace:`nowrap`,color:`var(--text)`,background:`var(--ground-1)`,border:`1px solid var(--lattice)`,cursor:`pointer`},".cm-link-button:hover, .cm-link-button[aria-expanded=true]":{background:`var(--lattice-soft)`},".cm-link-button:focus-visible":{outline:`2px solid var(--focus-ring)`,outlineOffset:`2px`},".cm-link-menu":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,width:`248px`,padding:`4px`,background:`var(--ground-1)`,border:`1px solid var(--line)`,display:`grid`,gap:`1px`},".cm-link-menu[hidden]":{display:`none`},".cm-link-menu button":{display:`grid`,gap:`1px`,textAlign:`left`,padding:`6px 8px 6px 24px`,background:`none`,border:`0`,color:`var(--text)`,font:`13.5px var(--font-ui)`,cursor:`pointer`,position:`relative`},".cm-link-menu button b":{fontWeight:`600`},".cm-link-menu button span":{fontSize:`12px`,color:`var(--text-faint)`,lineHeight:`1.3`},".cm-link-menu button[aria-checked=true]::before":{content:`"●"`,position:`absolute`,left:`8px`,top:`7px`,fontSize:`10px`,color:`var(--lattice)`},".cm-link-menu:focus":{outline:`none`},".cm-link-menu button.on":{background:`var(--lattice-soft)`},".cm-link-menu:focus-visible button.on":{outline:`2px solid var(--focus-ring)`,outlineOffset:`-2px`}}),je.of(pi)];function hi(e){return t=>{let n=t.matchBefore(/\[\[[^\]\n]*$/);if(!n)return null;let r=e().map(e=>({label:e.title,detail:e.folder,apply:(t,n,r,i)=>{let a=`[${e.title}](/${e.id}.md)`,o=r-2,s=t.state.sliceDoc(i,i+2)===`]]`?i+2:i;t.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}})}}));return{from:n.from+2,options:r,filter:!0,validFor:/^[^\]\n]*$/}}}function gi(e){return t=>{let n=t.matchBefore(/\]\([^)\s]*$/);return n?{from:n.from+2,options:e().map(e=>({label:`/${e.id}.md`,detail:e.title})),validFor:/^[^)\s]*$/}:null}}function _i(e){return at({override:[hi(e),gi(e)],icons:!1,activateOnTyping:!0})}var vi=36,yi=92,bi=40,xi=/^\$\$([^$]*?[^\\])\$\$/,Si=/^\$((?:[^\s\\])|(?:\S.*?[^\s\\]))\$(?!\d)/,Ci=/^\\\((.+?)\\\)/,wi=/^\$\$([^$]*?[^\\])\$\$(?:[ \t]*\([^)\s]+?\))?(?=[ \t]*(?:\n|$))/,Ti=/^\\\[([\s\S]+?)\\\](?:[ \t]*\([^)$\r\n]+?\))?(?=[ \t]*(?:\n|$))/;function Ei(e,t,n){if(t===vi){if(n>e.offset&&e.char(n-1)===yi)return-1;let t=e.slice(n,e.end),r=(t.charCodeAt(1)===vi?xi:Si).exec(t);return r?e.addElement(e.elt(`InlineMath`,n,n+r[0].length,[e.elt(`MathMark`,n,n+(r[0].startsWith(`$$`)?2:1)),e.elt(`MathMark`,n+r[0].length-(r[0].startsWith(`$$`)?2:1),n+r[0].length)])):-1}if(t===yi&&e.char(n+1)===bi){let t=Ci.exec(e.slice(n,e.end));if(!t)return-1;let r=n+t[0].length;return e.addElement(e.elt(`InlineMath`,n,r,[e.elt(`MathMark`,n,n+2),e.elt(`MathMark`,r-2,r)]))}return-1}var Di=2e4;function Oi(e,t){let n=t.text.slice(t.pos),r=n.startsWith(`$$`)?wi:n.startsWith(`\\[`)?Ti:null;if(!r)return!1;let i=e.lineStart+t.pos,a=e.input,o=r.exec(a.read(i,Math.min(a.length,i+Di)));if(!o)return!1;let s=i+o[0].length;for(;e.lineStart+t.text.length<s&&e.nextLine(););return e.addElement(e.elt(`BlockMath`,i,s)),e.nextLine(),!0}var ki={defineNodes:[{name:`InlineMath`,style:I.special(I.content)},{name:`BlockMath`,block:!0,style:I.special(I.content)},{name:`MathMark`,style:I.processingInstruction}],parseInline:[{name:`InlineMath`,parse:Ei,before:`Escape`}],parseBlock:[{name:`BlockMath`,parse:Oi,before:`FencedCode`}]};function Ai(e){let t;return(t=/^\$\$([\s\S]*?)\$\$/.exec(e))||(t=/^\\\[([\s\S]*?)\\\]/.exec(e))?{tex:t[1],display:!0}:(t=/^\\\(([\s\S]*?)\\\)$/.exec(e))||(t=/^\$([\s\S]*?)\$$/.exec(e))?{tex:t[1],display:!1}:{tex:e,display:!1}}var ji=class extends F{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-bullet`,e.textContent=`•`,e}},Mi=class extends F{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-hr`,e}},Ni=class extends F{name;constructor(e){super(),this.name=e}eq(e){return e.name===this.name}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-lang`,e.textContent=this.name,e}},Pi=class extends F{source;constructor(e){super(),this.source=e}eq(e){return e.source===this.source}toDOM(){let e=document.createElement(`span`);e.className=`cm-lp-imaths`;let{tex:t,display:n}=Ai(this.source);return e.innerHTML=we.renderToString(t,{displayMode:n,throwOnError:!1}),e}},Q=L.replace({}),Fi=L.replace({widget:new ji}),Ii=L.replace({widget:new Mi}),$=e=>L.mark({class:e}),Li=e=>L.line({class:e});function Ri(e,t){let n=new Set;if(!t)return n;for(let t of e.selection.ranges){let r=e.doc.lineAt(t.from).number,i=e.doc.lineAt(t.to).number;for(let e=r;e<=i;e++)n.add(e)}return n}function zi(e){let{state:t}=e,n=Ri(t,e.hasFocus),r=e=>n.has(t.doc.lineAt(e).number),i=[],a=(e,n,r)=>{for(let a=t.doc.lineAt(e).number,o=t.doc.lineAt(n).number;a<=o;a++)i.push(Li(r).range(t.doc.line(a).from))},o=e.visibleRanges;if(o.length){let e=o[0].from,s=o[o.length-1].to,c=/^ {0,3}([-*_])(?: *\1){2,} *$/,l=t.doc.lineAt(e).number,u=t.doc.lineAt(s).number,d=e=>e>=1&&e<=t.doc.lines?t.doc.line(e).text:``;for(let e=l;e<=u;e++){let r=t.doc.line(e);if(r.length!==0||/Code|Math|HTML|Comment/.test(M(t).resolveInner(r.from,1).name))continue;let a=e>1&&t.doc.line(e-1).length===0&&!n.has(e),o=c.test(d(e-1))||c.test(d(e+1));i.push(Li(a?`cm-lp-gap cm-lp-gap-more`:o?`cm-lp-gap cm-lp-gap-rule`:`cm-lp-gap`).range(r.from))}M(t).iterate({from:e,to:s,enter:e=>{let n=e.name,o=/^(?:ATX|Setext)Heading(\d)$/.exec(n);if(o)a(e.from,e.to,`cm-lp-h${o[1]}`);else switch(n){case`HeaderMark`:{if(r(e.from))break;if((e.node.parent?.name??``).startsWith(`SetextHeading`)){i.push(Q.range(t.doc.lineAt(e.from).from,e.to));break}let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;n>e.from&&i.push(Q.range(e.from,n));break}case`EmphasisMark`:case`StrikethroughMark`:r(e.from)||i.push(Q.range(e.from,e.to));break;case`Emphasis`:i.push($(`cm-lp-em`).range(e.from,e.to));break;case`StrongEmphasis`:i.push($(`cm-lp-strong`).range(e.from,e.to));break;case`Strikethrough`:i.push($(`cm-lp-strike`).range(e.from,e.to));break;case`InlineCode`:if(i.push($(`cm-lp-code`).range(e.from,e.to)),!r(e.from)){let t=e.node;for(let e=t.firstChild;e;e=e.nextSibling)e.name===`CodeMark`&&i.push(Q.range(e.from,e.to))}return!1;case`InlineMath`:return r(e.from)?i.push($(`cm-lp-mathsrc`).range(e.from,e.to)):i.push(L.replace({widget:new Pi(t.sliceDoc(e.from,e.to))}).range(e.from,e.to)),!1;case`BlockMath`:case`Table`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`Link`:{let n=e.node,a=[],o=!1;for(let e=n.firstChild;e;e=e.nextSibling)e.name===`LinkMark`&&a.push(e),e.name===`URL`&&(o=!0);let s=a[0],c=a[1],l=n.getChild(`URL`),u=l?t.sliceDoc(l.from,l.to):``,d=u.startsWith(`code:`),f=/^https?:/i.test(u),p=d?t.facet(Bi)(u)?`cm-lp-link cm-lp-codelink cm-lp-broken`:`cm-lp-link cm-lp-codelink`:f?`cm-lp-link cm-lp-weblink`:`cm-lp-link`;s&&c&&c.from>s.to&&i.push((d?L.mark({class:p,attributes:{title:t.facet(Bi)(u)?`${u.slice(5)}: not in the repository`:u.slice(5)}}):$(p)).range(s.to,c.from)),!r(e.from)&&o&&s&&c&&(i.push(Q.range(s.from,s.to)),i.push(Q.range(c.from,e.to)));break}case`ListMark`:{let n=t.sliceDoc(e.from,e.to);!r(e.from)&&/^[-*+]$/.test(n)?i.push(Fi.range(e.from,e.to)):i.push($(`cm-lp-listmark`).range(e.from,e.to));break}case`TaskMarker`:i.push($(`cm-lp-task`).range(e.from,e.to));break;case`Blockquote`:a(e.from,e.to,`cm-lp-quote`);break;case`QuoteMark`:if(!r(e.from)){let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;i.push(Q.range(e.from,n))}break;case`HorizontalRule`:r(e.from)||(i.push(Ii.range(e.from,e.to)),a(e.from,e.to,`cm-lp-ruleline`));break;case`FencedCode`:{a(e.from,e.to,`cm-lp-codeblock`);let n=e.node,o=t.doc.lineAt(e.from),s=t.doc.lineAt(e.to),c=n.getChild(`CodeInfo`),l=n.lastChild?.name===`CodeMark`&&n.lastChild.from>=s.from?n.lastChild:null;if(!r(o.from)){i.push(Li(`cm-lp-fence`).range(o.from));let e=c?t.sliceDoc(c.from,c.to).trim().split(/\s/)[0]:``;i.push((e?L.replace({widget:new Ni(e)}):Q).range(o.from,o.to))}return l&&s.number>o.number&&!r(s.from)&&(i.push(Li(`cm-lp-fence`).range(s.from)),s.to>s.from&&i.push(Q.range(s.from,s.to))),!1}case`CodeBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`HTMLBlock`:case`CommentBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1}}})}i.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide);let s=new Ge;for(let e of i)s.add(e.from,e.to,e.value);return s.finish()}var Bi=Ve.define({combine:e=>e[0]??(()=>!1)}),Vi=Fe.fromClass(class{decorations;constructor(e){this.decorations=zi(e)}update(e){(e.docChanged||e.viewportChanged||e.selectionSet||e.focusChanged||M(e.startState)!==M(e.state))&&(this.decorations=zi(e.view))}},{decorations:e=>e.decorations}),Hi=N.theme({".cm-scroller":{fontFamily:`var(--font-text)`,fontSize:`var(--text-size)`,lineHeight:`1.55`},".cm-lp-gap":{lineHeight:`20px`},".cm-lp-gap-rule":{lineHeight:`10px`},".cm-lp-gap-more":{lineHeight:`4px`},".cm-lp-ruleline":{lineHeight:`12px`},".cm-content":{fontVariationSettings:`"opsz" 18`},".cm-lp-h1, .cm-lp-h2, .cm-lp-h3, .cm-lp-h4, .cm-lp-h5, .cm-lp-h6":{fontWeight:`600`,lineHeight:`1.3`,fontVariationSettings:`"opsz" 36`,paddingTop:`.5em !important`},".cm-lp-h1":{fontSize:`26px`},".cm-lp-h2":{fontSize:`22px`},".cm-lp-h3":{fontSize:`19px`},".cm-lp-h4":{fontSize:`17px`,fontWeight:`700`},".cm-lp-em":{fontStyle:`italic`},".cm-lp-strong":{fontWeight:`700`},".cm-lp-strike":{textDecoration:`line-through`},".cm-lp-code":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,background:`color-mix(in srgb, var(--text) 8%, transparent)`,padding:`.1em .2em`},".cm-lp-link":{color:`var(--lattice)`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-lp-weblink":{textDecorationStyle:`dotted`},".cm-lp-codelink":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,textDecoration:`none`,borderBottom:`1px solid color-mix(in srgb, var(--lattice) 50%, transparent)`},".cm-lp-broken":{color:`var(--rose)`,textDecoration:`line-through`,borderBottomColor:`transparent`},".cm-lp-bullet":{color:`var(--text-faint)`,display:`inline-block`,minWidth:`1ch`},".cm-lp-listmark, .cm-lp-task":{color:`var(--text-faint)`,fontFamily:`var(--font-mono)`},".cm-lp-quote":{borderLeft:`3px solid var(--lattice)`,paddingLeft:`14px !important`,color:`var(--text-soft)`},".cm-lp-codeblock":{fontFamily:`var(--font-mono)`,fontSize:`13px`,lineHeight:`20px`,background:`color-mix(in srgb, var(--line) 38%, transparent)`,borderLeft:`2px solid var(--line-strong)`,padding:`0 16px !important`},".cm-lp-codeblock.cm-lp-fence":{lineHeight:`12px`,position:`relative`},".cm-lp-lang":{position:`absolute`,top:`8px`,right:`12px`,fontFamily:`var(--font-ui)`,fontSize:`12px`,lineHeight:`16px`,color:`var(--text-faint)`,pointerEvents:`none`},".cm-lp-mathsrc":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,color:`var(--text-soft)`},".cm-lp-imaths .katex":{fontSize:`1.05em`},".cm-lp-imaths .katex-display":{margin:`0`,padding:`6px 0`},".cm-lp-imaths .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-hr":{display:`inline-block`,width:`100%`,borderTop:`1px solid var(--line)`,verticalAlign:`middle`}});function Ui(e){let t=e.split(`#`)[0];return t.startsWith(`/`)&&t.endsWith(`.md`)?t.slice(1,-3):null}var Wi=Xe.define(),Gi=Xe.define(),Ki=[R.define({create:()=>L.none,update(e,t){for(let e of t.effects){if(!e.is(Gi))continue;let n=t.state.doc,r=e.value;if(!r)return L.none;let i=L.line({class:`cm-touched cm-touched-${r.who}`});return L.set([...new Set(r.lines)].filter(e=>e>=0&&e<n.lines&&n.line(e+1).text.trim()!==``).sort((e,t)=>e-t).map(e=>i.range(n.line(e+1).from)))}return t.docChanged?e.map(t.changes):e},provide:e=>N.decorations.from(e)}),N.theme({".cm-line.cm-touched-you":{background:`var(--lattice-soft)`,boxShadow:`-10px 0 0 var(--lattice-soft), -13px 0 0 var(--lattice), 10px 0 0 var(--lattice-soft)`},".cm-line.cm-touched-iso":{background:`var(--growth-soft)`,boxShadow:`-10px 0 0 var(--growth-soft), -13px 0 0 var(--growth), 10px 0 0 var(--growth-soft)`}})],qi=Xe.define(),Ji=class extends F{key;mount;block;down=null;watch=null;constructor(e,t,n){super(),this.key=e,this.mount=t,this.block=n}eq(e){return e.key===this.key&&e.block===this.block}toDOM(e){let t=document.createElement(this.block?`div`:`span`);return t.className=this.block?`cm-overlay`:`cm-iso-change`,t.contentEditable=`false`,this.down=this.mount(t,this.key),this.watch=new ResizeObserver(()=>e.requestMeasure()),this.watch.observe(t),t}destroy(){this.watch?.disconnect(),this.watch=null,this.down?.(),this.down=null}ignoreEvent(){return!0}get estimatedHeight(){return this.block?120:-1}};function Yi(e){return[R.define({create:()=>L.none,update(t,n){for(let t of n.effects){if(!t.is(Wi))continue;let r=n.state.doc;return L.set(t.value.map(t=>{let n=t.line>=r.lines,i=n?r.length:r.line(Math.max(1,t.line+1)).from;return L.widget({widget:new Ji(t.key,e,!0),block:!0,side:n?1:-1}).range(i)}),!0)}return n.docChanged?t.map(n.changes):t},provide:e=>N.decorations.from(e)}),R.define({create:()=>L.none,update(t,n){for(let t of n.effects){if(!t.is(qi))continue;let r=n.state.doc.length,i=[];for(let e of t.value.marks){let t=Math.max(0,Math.min(r,e.from)),n=Math.max(0,Math.min(r,e.to));n>t&&i.push(L.mark({class:`cm-iso-${e.kind}`}).range(t,n))}for(let n of t.value.inline)i.push(L.widget({widget:new Ji(n.key,e,!1),side:1}).range(Math.max(0,Math.min(r,n.at))));return L.set(i,!0)}return n.docChanged?t.map(n.changes):t},provide:e=>N.decorations.from(e)}),N.theme({".cm-overlay":{cursor:`default`,userSelect:`text`,padding:`10px 0`,display:`flow-root`,whiteSpace:`normal`},".cm-iso-picked":{background:`var(--lattice-soft)`,boxShadow:`inset 0 -2px 0 var(--lattice)`,cursor:`pointer`},".cm-iso-old":{textDecoration:`line-through`,textDecorationColor:`var(--text-faint)`,color:`var(--text-faint)`},".cm-iso-old *":{color:`var(--text-faint) !important`},".cm-iso-change":{cursor:`default`},".cm-iso-by-iso":{background:`var(--growth-soft)`,boxShadow:`inset 0 -1.5px 0 var(--growth)`},".cm-iso-given":{textDecoration:`underline dashed var(--growth)`,textUnderlineOffset:`4px`,textDecorationThickness:`1.5px`}})]}function Xi(e){let t=e.split(`#`)[0].split(`?`)[0];return!t.startsWith(`/`)||t.startsWith(`//`)?null:t.endsWith(`.md`)?{id:decodeURIComponent(t.slice(1,-3)),folder:!1}:t.endsWith(`/`)&&t.length>1?{id:decodeURIComponent(t.slice(1,-1)),folder:!0}:null}var Zi=Xe.define(),Qi=L.mark({class:`cm-pointed`});function $i(e,t){if(!t)return L.none;let n=[];return M(e).iterate({enter:r=>{if(r.name!==`Link`)return;let i=J(e,r.from+1);return i&&!i.embed&&i.from===r.from&&Xi(i.url)?.id===t&&n.push(Qi.range(i.from,i.to)),!1}}),L.set(n)}var ea=R.define({create:()=>({id:``,marks:L.none}),update(e,t){let n=e.id;for(let e of t.effects)e.is(Zi)&&(n=e.value);return n!==e.id||n&&t.docChanged?{id:n,marks:$i(t.state,n)}:e},provide:e=>N.decorations.from(e,e=>e.marks)}),ta=N.theme({".cm-pointed":{backgroundColor:`var(--lattice-soft)`,boxShadow:`0 2px 0 var(--lattice)`}});function na(e){if(!e)return[ea,ta];let t=``,n=n=>{let r=n?`${n.folder?`d`:`n`}:${n.id}`:``;r!==t&&(t=r,e(n))};return[ea,ta,N.domEventHandlers({pointermove(e,t){if(e.pointerType!==`mouse`)return!1;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:J(t.state,r);return n(i&&!i.embed?Xi(i.url):null),!1},pointerleave(){return n(null),!1}})]}var ra=N.theme({".cm-scroller":{fontFamily:`var(--font-mono)`,fontSize:`14px`,lineHeight:`1.6`}}),ia=N.theme({"&":{color:`var(--text)`,backgroundColor:`transparent`,fontSize:`16px`},"&.cm-focused":{outline:`none`},".cm-scroller":{overflow:`visible`},".cm-content":{padding:`12px 0 40vh`,caretColor:`var(--lattice)`},".cm-line":{padding:`0 2px`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--lattice)`,borderLeftWidth:`2px`},".cm-selectionBackground":{backgroundColor:`color-mix(in srgb, var(--lattice) 22%, transparent) !important`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`color-mix(in srgb, var(--lattice) 40%, transparent) !important`},".cm-placeholder":{color:`var(--text-faint)`},".cm-tooltip-autocomplete":{background:`var(--ground-1)`,border:`1px solid var(--line-strong)`,fontFamily:`var(--font-ui)`,fontSize:`13px`},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:`var(--font-ui)`,maxHeight:`16em`},".cm-tooltip-autocomplete > ul > li":{padding:`6px 10px !important`,lineHeight:`1.3`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{background:`var(--lattice-soft)`,color:`var(--text)`},".cm-completionDetail":{color:`var(--text-faint)`,fontStyle:`normal`,marginLeft:`10px`}}),aa=Ze.define([{tag:I.heading,fontWeight:`700`,color:`var(--text)`},{tag:I.strong,fontWeight:`700`},{tag:I.emphasis,fontStyle:`italic`},{tag:I.strikethrough,textDecoration:`line-through`},{tag:[I.link,I.url],color:`var(--lattice)`},{tag:[I.processingInstruction,I.punctuation,I.contentSeparator],color:`var(--text-faint)`},{tag:I.monospace,color:`var(--text-soft)`},{tag:I.quote,color:`var(--text-soft)`,fontStyle:`italic`}]);function oa(e){let t=e.selection.main;return{line:e.doc.lineAt(t.to).number-1,from:t.from,to:t.to}}function sa(e,t){let n=He.create({doc:t.doc,extensions:[At(),Re(),N.lineWrapping,Se({base:fe,extensions:[ki],completeHTMLTags:!1,codeLanguages:ye}),Me(aa),Me(ue),ia,...t.source?[ra]:[Vi,Hi,Hr,Ur,mi,...t.embeds?[Mr.of(t.embeds)]:[],...t.codeBroken?[Bi.of(t.codeBroken)]:[]],st(),He.languageData.of(()=>[{closeBrackets:{brackets:[`(`,`[`]}}]),...t.mountOverlay?[Yi(t.mountOverlay)]:[],Ki,na(t.onPoint),...t.readOnly?[He.readOnly.of(!0),N.editable.of(!1)]:[],_i(t.notes),Pe(t.placeholder??`Write the note here. # for a heading, [[ to link to another note, $x$ for maths.`),N.contentAttributes.of({"aria-label":t.label,spellcheck:`true`,autocapitalize:`sentences`,autocorrect:`on`}),je.of([{key:`Mod-s`,preventDefault:!0,run:()=>(t.onSave(),!0)},{key:`Mod-Enter`,preventDefault:!0,run:e=>(t.onAsk?.(oa(e.state)),!!t.onAsk)},...Yr,...rt,...ot,jr,...Ar,...qt]),N.domEventHandlers((()=>{let e=(e,n)=>{if(!t.picking?.())return;let r=e.state.selection,i=r.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to}));i.length?(t.onPick?.(i),setTimeout(()=>e.dispatch({selection:{anchor:Math.min(r.main.head,e.state.doc.length)}}),0)):n&&t.onUnpick?.(r.main.head)};return{mouseup:(t,n)=>(e(n,t.detail===1),!1),touchend:(t,n)=>(e(n,!1),!1),keyup:(t,n)=>(t.key===`Shift`&&e(n,!1),!1)}})()),N.domEventHandlers({mousedown(e,n){if(!t.onFollow||!(e.ctrlKey||e.metaKey)||e.button!==0)return!1;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:J(n.state,r),a=i&&!i.embed?Ui(i.url):null;return a!==null&&(e.preventDefault(),t.onFollow(a),!0)}}),N.updateListener.of(e=>{e.docChanged&&t.onChange(e.state.doc.toString()),t.onCursor&&(e.selectionSet||e.docChanged)&&t.onCursor(oa(e.state))})]});return new N({state:n,parent:e})}function ca(e,t){if(t===e.state.doc.toString())return;let n=Math.min(e.state.selection.main.head,t.length);e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},selection:{anchor:n}})}var la=C(`<span class="soft picked svelte-192cp36" role="status"> </span>`),ua=C(`<div class="between svelte-192cp36"><!> <div class="ask svelte-192cp36"><i class="dia open svelte-192cp36" aria-hidden="true"></i> <textarea rows="1" aria-label="Ask Iso" class="svelte-192cp36"></textarea></div> <div class="foot svelte-192cp36"><span class="grow"></span> <button class="link faint svelte-192cp36" type="button">cancel</button> <button class="btn primary" type="button">ask Iso</button></div></div>`),da=C(`<div class="prose said svelte-192cp36"></div>`),fa=C(`<span class="faint"> </span>`),pa=C(`<div class="between working svelte-192cp36" aria-live="polite"><!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="soft doing svelte-192cp36"> <!></span> <span class="grow"></span> <button class="link svelte-192cp36" type="button">stop</button></div></div>`),ma=C(`<div class="between stopped svelte-192cp36" role="alert"><p class="bad svelte-192cp36"> </p> <div class="foot svelte-192cp36"><span class="grow"></span><button class="link svelte-192cp36" type="button">dismiss</button></div></div>`),ha=C(`<p class="soft lost svelte-192cp36"><span class="strike svelte-192cp36"> </span> </p>`),ga=C(`<div class="between stopped svelte-192cp36"><p class="label"> </p> <!> <div class="foot svelte-192cp36"><span class="grow"></span><button class="btn remove" type="button">remove</button></div></div>`),_a=C(`<p class="label">The place this was written for is no longer in the note, so it is shown here. Keeping it adds it at the end.</p>`),va=C(`<textarea class="revision svelte-192cp36" aria-label="Iso's text, to edit"></textarea>`),ya=C(`<p class="label"> </p>`),ba=C(`<button class="btn edit" type="button">done</button>`),xa=C(`<button class="btn edit" type="button">edit</button>`),Sa=C(`<div class="between svelte-192cp36"><!> <!> <!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="grow"></span> <button class="btn keep" type="button">keep</button> <!> <button class="btn remove" type="button">remove</button></div></div>`);function Ca(n,i){E(i,!0);let l=S(i,`iso`,7),u=O(()=>i.key.startsWith(`p:`)?l().proposals.find(e=>e.id===i.key.slice(2)):void 0),x=O(()=>c(u)&&l().editing?.id===c(u).id?l().editing:null),C=O(()=>!!c(u)&&l().busy===c(u)?.id),T=O(()=>l().changes.filter(e=>!e.at)),k=e(``),A=e(void 0);m(()=>{i.key===`prompt`&&ie().then(()=>c(A)?.focus())});let ae=O(()=>l().asking?.steps.at(-1)?.said??``),oe=O(()=>(l().asking?.regions.length??0)>0),se=O(()=>l().prompt?.mode===`rewrite`),ce=O(()=>l().prompt?.regions.length??0),le=O(()=>!!c(k).trim()&&(!c(se)||c(ce)>0));function ue(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),l().ask(c(k))):e.key===`Escape`&&(e.preventDefault(),l().prompt=null)}var de=t(),fe=s(de),pe=e=>{var t=ua(),n=D(t),i=e=>{var t=la(),n=g(t,!0);o(()=>r(n,c(ce)===0?`select text in the note to rewrite`:`rewriting ${c(ce)} ${c(ce)===1?`passage`:`passages`} · select more, or click one to drop it`)),w(e,t)};p(n,e=>{c(se)&&e(i)});var s=h(n,2),u=h(D(s),2);ee(u),te(u,e=>d(A,e),()=>c(A)),y(s);var f=h(s,2),m=h(D(f),2),_=h(m,2);y(f),y(t),o(()=>{b(u,`placeholder`,c(se)?`how should Iso rewrite it?`:`what should Iso write here?`),_.disabled=!c(le)}),a(`keydown`,u,ue),ne(u,()=>c(k),e=>d(k,e)),a(`click`,m,()=>l().prompt=null),a(`click`,_,()=>l().ask(c(k))),w(e,t)},me=e=>{var t=pa(),n=D(t),i=e=>{var t=da();re(t,()=>he(l().asking.text),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>l().asking.text),w(e,t)};p(n,e=>{l().asking.text&&!c(oe)&&e(i)});var s=h(n,2),u=h(D(s),2),d=D(u,!0),f=h(d),m=e=>{var t=fa(),n=g(t);o(()=>r(n,`· ${c(ae)??``}`)),w(e,t)};p(f,e=>{c(ae)&&e(m)}),y(u);var v=h(u,4);y(s),y(t),o(()=>r(d,l().asking.text?c(oe)?`Iso is rewriting`:`Iso is writing`:`Iso is thinking`)),a(`click`,v,()=>l().halt()),w(e,t)},ge=e=>{var t=ma(),n=D(t),i=g(n,!0),s=h(n,2),c=h(D(s));y(s),y(t),o(()=>r(i,l().failed.message)),a(`click`,c,()=>l().failed=null),w(e,t)},_e=e=>{var t=ga(),n=D(t),i=g(n),s=h(n,2);f(s,17,()=>c(T),e=>e.key,(e,t)=>{var n=ha(),i=D(n),a=g(i,!0),s=h(i);y(n),o((e,t)=>{r(a,e),r(s,` → ${t??``}`)},[()=>c(t).proposal.regions[c(t).k].old.text.trim(),()=>c(t).proposal.regions[c(t).k].new.trim()||`(taken out)`]),w(e,n)});var u=h(s,2),d=h(D(u));y(u),y(t),o(()=>r(i,`${c(T).length===1?`One change Iso offered is`:`${c(T).length} changes Iso offered are`} for text that is no longer in the note as it was, so ${c(T).length===1?`it`:`they`} cannot be kept.`)),a(`click`,d,()=>{for(let e of c(T))l().discardChange(e)}),w(e,t)},ve=e=>{var t=Sa(),n=D(t),i=e=>{var t=_a();w(e,t)},s=O(()=>!l().placed(c(u)));p(n,e=>{c(s)&&e(i)});var d=h(n,2),f=e=>{var t=va();ee(t),o(e=>b(t,`rows`,e),[()=>Math.max(3,c(x).text.split(`
|
|
6
|
-
`).length+1)]),ne(t,()=>c(x).text,e=>c(x).text=e),w(e,t)},m=e=>{var t=da();re(t,()=>he(c(u).text),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>({given:c(u).text,copy:!0})),w(e,t)};p(d,e=>{c(x)?e(f):e(m,-1)});var v=h(d,2),S=e=>{var t=ya(),n=g(t,!0);o(()=>r(n,c(u).notice)),w(e,t)};p(v,e=>{c(u).notice&&e(S)});var T=h(v,2),E=h(D(T),4),te=h(E,2),ie=e=>{var t=ba();a(`click`,t,()=>l().done(c(u))),w(e,t)},k=e=>{var t=xa();o(()=>t.disabled=c(C)),a(`click`,t,()=>l().edit(c(u))),w(e,t)};p(te,e=>{c(x)?e(ie):e(k,-1)});var A=h(te,2);y(T),y(t),o(()=>{b(t,`data-proposal`,c(u).id),E.disabled=c(C),A.disabled=c(C)}),a(`click`,E,()=>l().keep(c(u))),a(`click`,A,()=>l().discard(c(u))),w(e,t)};p(fe,e=>{i.key===`prompt`?e(pe):i.key===`asking`&&l().asking?e(me,1):i.key===`failed`&&l().failed?e(ge,2):i.key===`lost`&&c(T).length?e(_e,3):c(u)&&e(ve,4)}),w(n,de),v()}u([`keydown`,`click`]);var wa=C(`<span class="label who svelte-1o10yjh"> </span>`),Ta=C(`<!> <span class="act svelte-1o10yjh"><button class="keep svelte-1o10yjh" type="button" aria-label="Keep this change">keep</button><button class="remove svelte-1o10yjh" type="button" aria-label="Remove this change">remove</button></span>`,1),Ea=C(`<span class="gone svelte-1o10yjh">the passage above is taken out</span>`),Da=C(`<pre class="new svelte-1o10yjh"> </pre>`),Oa=C(`<div class="new prose svelte-1o10yjh"></div>`),ka=C(`<div><!> <div class="foot svelte-1o10yjh"><i class="dia svelte-1o10yjh" aria-hidden="true"></i><span class="label">in place of the lines struck through above</span><span class="grow"></span><!></div></div>`),Aa=C(`<span class="new svelte-1o10yjh"></span>`),ja=C(`<span class="gone svelte-1o10yjh">taken out</span>`),Ma=C(`<span class="change svelte-1o10yjh"><!> <!></span>`);function Na(e,n){E(n,!0);let i=e=>{var t=Ta(),i=s(t),u=e=>{var t=wa(),n=g(t,!0);o(()=>{b(t,`title`,c(l)?.proposal.asked),r(n,c(S))}),w(e,t)};p(i,e=>{c(S)&&e(u)});var f=h(i,2),m=D(f),_=h(m);y(f),o(()=>{m.disabled=c(d),_.disabled=c(d)}),a(`click`,m,()=>c(l)&&n.iso.keepChange(c(l))),a(`click`,_,()=>c(l)&&n.iso.discardChange(c(l))),w(e,t)},l=O(()=>n.iso.changes.find(e=>e.key===n.key)),u=O(()=>c(l)?c(l).proposal.regions[c(l).k].new:``),d=O(()=>n.iso.busy===n.key||n.iso.busy===`all`),f=O(()=>he(c(u).trim())),m=O(()=>c(f).replace(/^<p>([\s\S]*)<\/p>\s*$/,`$1`)),S=O(()=>c(l)?me(c(l).proposal.who):``);var C=t(),T=s(C),ee=e=>{var t=ka();let a;var s=D(t),d=e=>{var t=Ea();w(e,t)},m=O(()=>!c(u).trim()),v=e=>{var t=Da(),n=g(t,!0);o(e=>r(n,e),[()=>c(u).replace(/^\n+|\s+$/g,``)]),w(e,t)},S=e=>{var t=Oa();re(t,()=>c(f),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>c(f)),w(e,t)};p(s,e=>{c(m)?e(d):c(l).code?e(v,1):e(S,-1)});var C=h(s,2),T=h(D(C),3);i(T),y(C),y(t),o(()=>{a=x(t,1,`change block svelte-1o10yjh`,null,a,{code:c(l).code}),b(t,`data-change`,n.key)}),w(e,t)},te=e=>{var t=Ma(),r=D(t),a=e=>{var t=Aa();re(t,()=>c(m),!0),y(t),w(e,t)},s=O(()=>c(u).trim()),l=e=>{var t=ja();w(e,t)};p(r,e=>{c(s)?e(a):e(l,-1)});var d=h(r,2);i(d),y(t),o(()=>b(t,`data-change`,n.key)),w(e,t)};p(T,e=>{c(l)?.block?e(ee):c(l)&&e(te,1)}),w(e,C),v()}u([`click`]);var Pa=C(`<div></div>`);function Fa(t,r){E(r,!0);let a=S(r,`iso`,7),s=S(r,`touched`,3,null),u=S(r,`lens`,19,()=>[]),f,p=e(void 0),h=O(()=>r.source||!a()?{lines:0,chars:0}:a().head),g=O(()=>{if(!a())return{blocks:[],marks:[],inline:[]};let e=e=>t=>({kind:e,from:t.from-c(h).chars,to:t.to-c(h).chars});return{blocks:a().layout.blocks.map(e=>({key:e.key,line:Math.max(0,e.line-c(h).lines)})).sort((e,t)=>e.line-t.line),marks:[...a().layout.picked.map(e(`picked`)),...a().layout.old.map(e(`old`)),...u().map(t=>e(t.kind)(t))].filter(e=>e.to>0),inline:a().layout.inline.map(e=>({key:e.key,at:e.at-c(h).chars})).filter(e=>e.at>=0)}});T(()=>{let e=sa(f,{doc:r.source?r.note.text:r.note.body,source:r.source,label:r.source?`The note's file`:`The note`,notes:()=>j.listing.notes.filter(e=>e.id!==r.note.id).map(e=>({id:e.id,title:e.title,folder:e.dir})),onChange:e=>r.source?r.note.setText(e):r.note.setBody(e),onSave:()=>{r.note.save()},onFollow:e=>{k(ke(e))},embeds:{find:Oe,open:e=>{k(ke(e))}},onPoint:e=>pe.set(`note`,e?{...e,who:`you`}:null),codeBroken:e=>j.listing.notes.find(e=>e.id===r.note.id)?.broken?.includes(e)??!1,...a()?{onAsk:e=>{let t=r.note.text.slice(e.from+c(h).chars,e.to+c(h).chars).trim();t&&_e.add({kind:`passage`,id:r.note.id,title:r.note.fields.title||r.note.id,text:t}),Ae.to(`iso`),requestAnimationFrame(()=>document.getElementById(`iso-box`)?.focus())},onCursor:e=>{a().cursor={line:e.line+c(h).lines,from:e.from+c(h).chars,to:e.to+c(h).chars}},picking:()=>a().picking,onPick:e=>a().pick(e.map(e=>({from:e.from+c(h).chars,to:e.to+c(h).chars}))),onUnpick:e=>a().unpick(e+c(h).chars),mountOverlay:(e,t)=>{let n=i(t.startsWith(`r:`)?Na:Ca,{target:e,props:{iso:a(),key:t}});return()=>{l(n)}}}:{placeholder:n(()=>r.placeholder)??`Write what you understand, what you do not, and what you want from Iso. [[ links a note it should rest on.`}});return d(p,e),()=>{e.destroy(),pe.set(`note`,null)}}),m(()=>{r.note.revision,n(()=>{c(p)&&ca(c(p),r.source?r.note.text:r.note.body)})}),m(()=>{let e=s(),t=c(h).lines;c(p)&&c(p).dispatch({effects:Gi.of(e?{who:e.who,lines:e.lines.map(e=>e-t)}:null)})}),m(()=>{let e=pe.onAtlas;c(p)&&c(p).dispatch({effects:Zi.of(e)})}),m(()=>{let{blocks:e,marks:t,inline:n}=c(g);c(p)&&c(p).dispatch({effects:[Wi.of(e),qi.of({marks:t,inline:n})]})});var _=Pa();let y;te(_,e=>f=e,()=>f),o(()=>y=x(_,1,`editor svelte-hrl8lz`,null,y,{source:r.source})),w(t,_),v()}export{pt as a,Gi as i,sa as n,ct as o,ca as r,Fa as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,L as t,Q as n}from"./nMarIA7J.js";import{o as r}from"./BNjH_DUx.js";var i=class extends Error{status;current;constructor(e,t,n){super(e),this.status=t,this.current=n}};function a(e=new URL(`api/`,document.baseURI).href){let t=null,n=async(t,n)=>{let r;try{r=await fetch(e+t,n)}catch{throw new i(`isorite is not answering`,0)}let a=await r.json().catch(()=>({}));if(!r.ok)throw new i(a.error??r.statusText,r.status,a.current);return a},r=()=>n(`session`),a=async(e,i,a)=>{t??=r().then(e=>e.token);let o={"Content-Type":`application/json`,"x-isorite-token":await t};return n(i,{method:e,headers:o,body:JSON.stringify(a)})},o=e=>`?id=${encodeURIComponent(e)}`;return{session:async()=>{let{token:e,...n}=await r();return t=Promise.resolve(e),n},notes:()=>n(`notes`),readNote:e=>n(`note`+o(e)),saveNote:(e,t)=>a(`PUT`,`note`+o(e),t),createNote:(e,t)=>a(`POST`,`note`+o(e),{text:t}),journal:e=>n(`journal`+o(e)),version:async(e,t)=>(await n(`version`+o(e)+`&entry=`+encodeURIComponent(t))).text,moveNote:(e,t,n)=>a(`POST`,`note/move`+o(e),{to:t,base:n}),deleteNote:async(e,t)=>{await a(`POST`,`note/delete`+o(e),{base:t})},restore:(e,t,n)=>a(`POST`,`note/restore`+o(e),{entry:t,base:n}),map:()=>n(`map`),timeline:()=>n(`timeline`),search:e=>n(`search?q=${encodeURIComponent(e)}`),ask:e=>a(`POST`,`iso/ask`,e),converse:e=>a(`POST`,`iso/converse`,e),understanding:e=>n(`understanding`+o(e)),saveScratchpad:(e,t,n)=>a(`POST`,`understanding/scratchpad`+o(e),{scratchpad:t,base:n}),undoTurn:(e,t)=>a(`POST`,`iso/undo`,{conversation:e,turn:t}),setContext:(e,t,n)=>a(`POST`,`iso/context`,{conversation:e,part:t,on:n}),compact:(e,t)=>a(`POST`,`iso/compact`,{conversation:e,...t===void 0?{}:{keep:t}}),branch:e=>a(`POST`,`iso/branch`,{conversation:e}),agents:()=>n(`agents`),saveAgents:e=>a(`POST`,`agents`,{text:e}),takeItem:(e,t,n)=>a(`POST`,`iso/take`,{conversation:e,turn:t,item:n}),nameRepository:async()=>!1,brokenNews:async()=>[],answer:async(e,t,n)=>{await a(`POST`,`iso/answer`,{turn:e,permission:t,decision:n})},conversation:async e=>{let t=await n(`conversation`+(e?o(e):``));return t.id?t:null},turnContext:e=>n(`turn/context?turn=${encodeURIComponent(JSON.stringify(e))}`),stop:async e=>{await a(`POST`,`iso/stop`,{request:e})},keep:(e,t,n)=>a(`POST`,`proposal/keep`+o(e),{proposal:t,...n===void 0?{}:{region:n}}),revise:async(e,t,n)=>{await a(`POST`,`proposal/revise`+o(e),{proposal:t,text:n})},discard:async(e,t,n)=>{await a(`POST`,`proposal/discard`+o(e),{proposal:t,...n===void 0?{}:{region:n}})},drafts:()=>n(`drafts`),createDraft:()=>a(`POST`,`drafts`,{}),keepDraft:(e,t,n)=>a(`POST`,`draft/keep`+o(e),{proposal:t,folder:n}),discardDraft:async e=>{await a(`POST`,`draft/discard`+o(e),{})},setDone:(e,t,n)=>a(`POST`,`note/done`+o(e),{done:t,base:n}),context:(e,t)=>n(`context`+(e?o(e):``)+(t?`${e?`&`:`?`}choice=${encodeURIComponent(JSON.stringify(t))}`:``)),clearConversation:async()=>{await a(`POST`,`context/clear`,{})},settings:()=>n(`settings`),setKey:e=>a(`PUT`,`settings/key`,{key:e}),spend:()=>n(`spend`),setSpendCap:e=>a(`PUT`,`settings/spend-cap`,{usd:e}),connect:e=>a(`POST`,`settings/connect`,{callback:e}),connected:(e,t)=>a(`POST`,`settings/connected`,{code:e,state:t}),agentTools:()=>n(`agent/tools`),agentLook:e=>a(`POST`,`agent/look`,e),agentWrite:e=>a(`POST`,`agent/write`,e),agentSend:e=>a(`POST`,`agent/send`,e),agentReceived:async(e,t)=>{await a(`POST`,`agent/received`,{id:e,agent:t})},agentStatus:async(e,t,n)=>{await a(`POST`,`agent/status`,{agent:e,session:t,busy:n})},setup:{view:()=>n(`settings/provider`),keep:e=>a(`PUT`,`settings/provider`,e),check:e=>a(`POST`,`settings/provider/check`,{draft:e}),models:async e=>(await a(`POST`,`settings/provider/models`,{draft:e})).models,report:async()=>(await a(`POST`,`settings/report`,{})).text},terminal:{view:()=>n(`terminal`),prompt:async(e,t)=>{await a(`POST`,`terminal/prompt`,{asked:e,given:t})},stop:async()=>{await a(`POST`,`terminal/stop`,{})},reply:async(e,t)=>{await a(`POST`,`terminal/permission`,{id:e,decision:t})}},events(t){let n=new EventSource(e+`events`),r=e=>{try{t(JSON.parse(e.data))}catch{}};for(let e of[`note-changed`,`journal`,`record`,`iso-start`,`iso-step`,`iso-text`,`iso-item`,`iso-answer`,`iso-taken`,`iso-done`,`iso-stopped`,`iso-failed`,`iso-retry`,`context`,`agent-start`,`agent-step`,`agent-done`,`agent-sent`,`agent-received`,`terminal`])n.addEventListener(e,r);return()=>n.close()}}}var o=class{api;#e=e(null);get session(){return t(this.#e)}set session(e){n(this.#e,e)}#t=e({notes:[],dirs:[]});get listing(){return t(this.#t)}set listing(e){n(this.#t,e)}#n=e(``);get error(){return t(this.#n)}set error(e){n(this.#n,e,!0)}#r=e(``);get open(){return t(this.#r)}set open(e){n(this.#r,e,!0)}#i=e(``);get here(){return t(this.#i)}set here(e){n(this.#i,e,!0)}#a=e(null);get saving(){return t(this.#a)}set saving(e){n(this.#a,e,!0)}#o=e(null);get atlas(){return t(this.#o)}set atlas(e){n(this.#o,e)}#s=e(null);get signIn(){return t(this.#s)}set signIn(e){n(this.#s,e)}#c=e(null);get iso(){return t(this.#c)}set iso(e){n(this.#c,e)}watching=``;listeners=new Set;relist=null;async load(e=a()){this.api=e;try{[this.session,this.listing]=await Promise.all([e.session(),e.notes()])}catch(e){this.error=e.message;return}await this.signedIn(),e.events(e=>{this.follow(e);for(let t of this.listeners)t(e);e.type===`note-changed`&&(this.relist&&clearTimeout(this.relist),this.relist=setTimeout(()=>{this.refresh()},300))})}async startSignIn(){let{url:e}=await this.api.connect(location.origin+location.pathname);try{sessionStorage.setItem(s,location.hash)}catch{}location.assign(e)}async signedIn(){let e=new URLSearchParams(location.search),t,n;try{if(e.has(`code`)||e.has(`state`)||e.has(`error`)){let t=sessionStorage.getItem(s)??location.hash;return sessionStorage.removeItem(s),sessionStorage.setItem(c,JSON.stringify({code:e.get(`code`),state:e.get(`state`)})),location.replace(location.pathname+t),new Promise(()=>void 0)}let r=sessionStorage.getItem(c);if(r===null)return;sessionStorage.removeItem(c),{code:t,state:n}=JSON.parse(r)}catch{if({code:t,state:n}={code:e.get(`code`),state:e.get(`state`)},!t&&!n)return}if(!t||!n)this.signIn={ok:!1,message:`No key was made: the sign-in was left or refused.`};else try{let e=await this.api.connected(t,n);this.signIn={ok:!0,message:`Signed in at ${e.provider}: a key was made for isorite, and is held on this device.`}}catch(e){this.signIn={ok:!1,message:e.message}}}async refresh(){try{this.listing=await this.api.notes()}catch{}}follow(e){if(e.type===`iso-start`){this.iso={request:e.request,note:e.note,agent:null,state:`reading`,steps:[],message:``,start:e,text:``};return}if((e.type===`agent-start`||e.type===`agent-step`)&&this.iso?.request!==e.request){if(this.iso&&!this.iso.agent&&(this.iso.state===`reading`||this.iso.state===`writing`))return;this.iso={request:e.request,note:``,agent:e.agent,state:`reading`,steps:[],message:``}}let t=this.iso;t&&`request`in e&&e.request===t.request&&(e.type===`iso-step`||e.type===`agent-step`?this.iso={...t,state:`reading`,steps:[...t.steps,e.step]}:e.type===`iso-text`?this.iso={...t,state:`writing`,text:e.again?e.delta:(t.text??``)+e.delta}:e.type===`iso-done`||e.type===`agent-done`?this.iso={...t,state:`done`}:e.type===`iso-stopped`?this.iso={...t,state:`stopped`}:e.type===`iso-failed`&&(this.iso={...t,state:`failed`,message:e.message}))}on(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},s=`isorite.sign-in.back`,c=`isorite.sign-in.code`,l=new o,u=e=>r(`/n/[...id]`,{id:e});function d(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``)}function f(e){let t=e.trim().replace(/^\/+/,``).replace(/\.md$/,``),n=t.includes(`/`)?l.listing.notes.filter(e=>e.id===t):l.listing.notes.filter(e=>e.id.split(`/`).at(-1)===t),r=n.length===1?n[0]:null;return r?{id:r.id,title:r.title,kind:r.kind??`note`,done:!!r.done}:null}export{i as a,d as i,f as n,u as r,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as load_css,n as start}from"../chunks/BNjH_DUx.js";
|