isorite 0.1.0 → 0.1.1

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.
Files changed (50) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +1 -1
  3. package/web/_app/immutable/assets/5.CUzWicH8.css +1 -0
  4. package/web/_app/immutable/assets/9.CFA9_nYZ.css +1 -0
  5. package/web/_app/immutable/assets/{NoteEditor.Bp-YDqYj.css → NoteEditor.CM4-yBF-.css} +1 -1
  6. package/web/_app/immutable/assets/Tutorial.BBInFlVA.css +1 -0
  7. package/web/_app/immutable/chunks/{gRYnlonl.js → 3kOo0zFs.js} +1 -1
  8. package/web/_app/immutable/chunks/{DN3dk6rD.js → 7G70dile.js} +3 -3
  9. package/web/_app/immutable/chunks/BC72R-M3.js +3 -0
  10. package/web/_app/immutable/chunks/{B-si2ell.js → BDArRuPR.js} +1 -1
  11. package/web/_app/immutable/chunks/BIIfi70-.js +1 -0
  12. package/web/_app/immutable/chunks/CRzLMJPS.js +1 -0
  13. package/web/_app/immutable/chunks/Cu92X5fL.js +1 -0
  14. package/web/_app/immutable/chunks/DZgc09PI.js +535 -0
  15. package/web/_app/immutable/chunks/{cmGruEKS.js → DhNgPNiM.js} +1 -1
  16. package/web/_app/immutable/chunks/DxgbXXT0.js +13 -0
  17. package/web/_app/immutable/chunks/VWXhPrtT.js +1 -0
  18. package/web/_app/immutable/chunks/czZbKOPp.js +1 -0
  19. package/web/_app/immutable/entry/app.CNsoor0D.js +2 -0
  20. package/web/_app/immutable/entry/start.DFtkKs7u.js +1 -0
  21. package/web/_app/immutable/nodes/0.156ZLyOF.js +2 -0
  22. package/web/_app/immutable/nodes/1.e1XDhJNT.js +1 -0
  23. package/web/_app/immutable/nodes/2.80TQrqQF.js +1 -0
  24. package/web/_app/immutable/nodes/3.Bk_l60Ut.js +13 -0
  25. package/web/_app/immutable/nodes/4.CektBUbm.js +2 -0
  26. package/web/_app/immutable/nodes/5.65PWTBsr.js +4 -0
  27. package/web/_app/immutable/nodes/6.a_57GKer.js +1 -0
  28. package/web/_app/immutable/nodes/7.DbM_N4_u.js +1 -0
  29. package/web/_app/immutable/nodes/8.CY3JWStn.js +1 -0
  30. package/web/_app/immutable/nodes/9.DurALis5.js +530 -0
  31. package/web/_app/version.json +1 -1
  32. package/web/index.html +19 -11
  33. package/web/_app/immutable/assets/5.BCvLF9Xz.css +0 -1
  34. package/web/_app/immutable/chunks/BD1Dpm2e.js +0 -3
  35. package/web/_app/immutable/chunks/C0fpmehI.js +0 -1
  36. package/web/_app/immutable/chunks/CWYACT2V.js +0 -1
  37. package/web/_app/immutable/chunks/CdQZ-ArP.js +0 -1
  38. package/web/_app/immutable/chunks/DtAOoM-T.js +0 -1
  39. package/web/_app/immutable/chunks/DykrN7z5.js +0 -535
  40. package/web/_app/immutable/entry/app.DgJiXIYs.js +0 -2
  41. package/web/_app/immutable/entry/start.l9vV7NaJ.js +0 -1
  42. package/web/_app/immutable/nodes/0.DWPeBju2.js +0 -1
  43. package/web/_app/immutable/nodes/1.CJVDS8FT.js +0 -1
  44. package/web/_app/immutable/nodes/2.o8ItfT-a.js +0 -1
  45. package/web/_app/immutable/nodes/3.uhHyOPGK.js +0 -13
  46. package/web/_app/immutable/nodes/4.BYKkAZTp.js +0 -2
  47. package/web/_app/immutable/nodes/5.BzEQO7Xv.js +0 -4
  48. package/web/_app/immutable/nodes/6.GxiAUa6J.js +0 -1
  49. package/web/_app/immutable/nodes/7.d2Ere8Jb.js +0 -1
  50. package/web/_app/immutable/nodes/8.CvPHZL8j.js +0 -1
@@ -1 +1 @@
1
- import{A as e,B as t,D as n,F as r,X as i,Y as a,Z as o,i as s,u as c}from"./BD1Dpm2e.js";import"./xihTtKlq.js";var l=e(`<svg class="logo" viewBox="-0.4 -9.5 32.4 9.9" role="img" aria-label="isorite"><path d="M2 0L2 -2L0 -4M2 -2L2 -4L4 -6M5.6 0L6.6 0L7.6 -1L5.6 -3L6.6 -4L7.6 -4M11.2 0L13.2 -2L11.2 -4L9.2 -2ZM14.8 0L14.8 -2L15.8 -3L16.8 -4M14.8 -2L14.8 -4M20.4 0L20.4 -2L18.4 -4M20.4 -2L20.4 -4L22.4 -6M26 0L25 -1L25 -4L24 -4M25 -4L26 -4M25 -4L25 -5M30.6 0L29.6 0L27.6 -2L29.6 -4L31.6 -2L27.6 -2"></path><path class="iso" d="M2 -9.05l1.2 1.2l-1.2 1.2l-1.2 -1.2z"></path><path class="right" d="M20.4 -9.05l1.2 1.2l-1.2 1.2l-1.2 -1.2z"></path></svg>`);function u(e,r){let i=s(r,`width`,3,72);var a=l();t(()=>{c(a,`width`,i()),c(a,`height`,i()*9.9/32.4)}),n(e,a)}var d=new class{#e=o(a(typeof document>`u`?``:document.documentElement.dataset.ground??``));get chosen(){return r(this.#e)}set chosen(e){i(this.#e,e,!0)}choose(e){this.chosen=e,e?document.documentElement.dataset.ground=e:delete document.documentElement.dataset.ground;try{e?localStorage.setItem(`isorite.ground`,e):localStorage.removeItem(`isorite.ground`)}catch{}}},f=[[``,`the system's`],[`lapis`,`lapis`],[`quartz`,`quartz`]];export{d as n,u as r,f as t};
1
+ import{I as e,O as t,Q as n,V as r,X as i,Z as a,i as o,j as s,u as c}from"./BC72R-M3.js";import"./xihTtKlq.js";var l=s(`<svg class="logo" viewBox="-0.4 -9.5 32.4 9.9" role="img" aria-label="isorite"><path d="M2 0L2 -2L0 -4M2 -2L2 -4L4 -6M5.6 0L6.6 0L7.6 -1L5.6 -3L6.6 -4L7.6 -4M11.2 0L13.2 -2L11.2 -4L9.2 -2ZM14.8 0L14.8 -2L15.8 -3L16.8 -4M14.8 -2L14.8 -4M20.4 0L20.4 -2L18.4 -4M20.4 -2L20.4 -4L22.4 -6M26 0L25 -1L25 -4L24 -4M25 -4L26 -4M25 -4L25 -5M30.6 0L29.6 0L27.6 -2L29.6 -4L31.6 -2L27.6 -2"></path><path class="iso" d="M2 -9.05l1.2 1.2l-1.2 1.2l-1.2 -1.2z"></path><path class="right" d="M20.4 -9.05l1.2 1.2l-1.2 1.2l-1.2 -1.2z"></path></svg>`);function u(e,n){let i=o(n,`width`,3,72);var a=l();r(()=>{c(a,`width`,i()),c(a,`height`,i()*9.9/32.4)}),t(e,a)}var d=new class{#e=n(i(typeof document>`u`?``:document.documentElement.dataset.ground??``));get chosen(){return e(this.#e)}set chosen(e){a(this.#e,e,!0)}choose(e){this.chosen=e,e?document.documentElement.dataset.ground=e:delete document.documentElement.dataset.ground;try{e?localStorage.setItem(`isorite.ground`,e):localStorage.removeItem(`isorite.ground`)}catch{}}},f=[[``,`the system's`],[`lapis`,`lapis`],[`quartz`,`quartz`]];export{d as n,u as r,f as t};
@@ -0,0 +1,13 @@
1
+ import{A as e,C as t,E as n,I as r,J as i,K as a,M as o,N as s,O as c,P as l,Q as u,V as d,X as f,Y as p,Z as m,at as h,ct as g,et as _,h as v,it as y,k as b,lt as x,m as S,n as C,q as w,u as T,x as ee}from"./BC72R-M3.js";import{t as E}from"./czZbKOPp.js";import"./xihTtKlq.js";import{n as D,t as O}from"./3kOo0zFs.js";import"./7G70dile.js";import"./VWXhPrtT.js";var k={type:`string`};({...k}),{...k},{...k},{...k},{...k};var A=`Notes are checked by the person: the change waits for them to keep it, in the browser or the terminal, and the note's file is unchanged until they do. Use this, never edit or write, for any note of the knowledge base.`;`${A}`,`${A}`;var j={insert:`how is a body inserted, and what does each node keep?`,rewrite:`answer my TODO`,speed:`how much faster is Barnes–Hut at N = 5000?`,octree:`How does the quadtree become an octree for 3D, and what changes in Barnes–Hut?`},M=`physics`,N=`integrators`,P=`algorithms`,F=`simulation`,I=(e,t)=>`${e}/${t}`,L=I(M,`newtons-law-of-gravitation`);I(M,`the-n-body-problem`);var R=I(M,`units`);I(M,`energy-conservation`);var te=I(M,`softening`);I(N,`eulers-method`);var z=I(N,`leapfrog`),B=I(N,`symplectic-integrators`),ne=I(N,`choosing-the-timestep`),V=I(P,`direct-summation`),re=I(P,`centre-of-mass`),H=I(P,`the-quadtree`),U=I(P,`barnes-hut`),W=I(P,`cost-and-accuracy`),G=I(F,`the-main-loop`);I(F,`initial-conditions`);var ie=I(F,`diagnostics`),K=I(F,`two-galaxies-colliding`),q=`Exact, and unaided.`,ae=`$F = G m_1 m_2 / d^2 = 1 \\cdot \\tfrac12 \\cdot \\tfrac12 / 1 = \\tfrac14$.
2
+
3
+ Each accelerates at $a = F/m = \\tfrac14 / \\tfrac12$.
4
+
5
+ So each accelerates at $\\tfrac12$, towards the other.`,oe=`$M = 1 + 2 + 1 = 4$.
6
+
7
+ $\\mathbf{R} = (1 \\cdot (0,0) + 2 \\cdot (3,0) + 1 \\cdot (0,4)) / 4 = (6, 4)/4$.
8
+
9
+ So $\\mathbf{R} = (1.5, 1)$, with $M = 4$.`,se=`The drift falls as $\\Delta t^2$; at $T/100$ it is a few parts in a million.
10
+
11
+ So $\\Delta t = 2\\pi/100 \\approx 0.06$ is enough.
12
+
13
+ Check: record $E$ every 100 steps and plot the drift; halve $\\Delta t$ and it should fall by four.`;[20,17,12,5,2].map((e,t)=>({day:e,working:ae,answer:`So each accelerates at $\\tfrac12$, towards the other.`,result:`right`,marks:[[`$F = G`,`right`],[`So each`,`right`]],moves:{[L]:[1,t?q:`The law, with its direction, unaided.`],[R]:[t<2?1:.5,`Uses G = 1 without a slip.`]}})),[6,4,2,1].map(e=>({day:e,working:oe,answer:`So $\\mathbf{R} = (1.5, 1)$, with $M = 4$.`,result:`right`,marks:[[`$M = 1`,`right`],[`So $\\mathbf{R}`,`right`]],moves:{[re]:[1,q]}})),[11,7].map(e=>({day:e,working:se,answer:`So $\\Delta t = 2\\pi/100 \\approx 0.06$ is enough.`,result:`right`,marks:[[`The drift falls`,`right`],[`So $\\Delta t`,`right`],[`Check:`,`right`]],moves:{[ne]:[1,q],[ie]:[1,`Knows what to measure, and what halving the step should do.`]}}));var ce=`@study/algorithms/the-cost-of-direct-summation`,le=18,ue=e=>t=>t.type===`journal`&&t.id===e&&(t.entry.kind===`discard`||t.entry.kind===`change`&&t.entry.why===`keep`),de=e=>t=>t.type===`journal`&&t.id===e&&t.entry.kind===`change`&&t.entry.why===`keep`,J=e=>t=>t.type===`iso-done`&&(typeof e==`string`?t.note===e:e(t.note)),Y=e=>()=>decodeURIComponent(location.hash).startsWith(e),X=e=>()=>document.querySelector(e)!==null,fe=e=>()=>document.querySelector(`[data-note="${e}"]`)?.classList.contains(`at`)??!1,pe=e=>O.listing.notes.find(t=>e.test(t.title)),Z=new Set;function me(){if(!Z.size)for(let e of O.listing.notes)Z.add(e.id)}var Q=()=>O.listing.notes.filter(e=>Z.size&&!Z.has(e.id)),he=[{key:`A`,title:`Your notes`,about:`The base as a bundle of linked Markdown notes: the Atlas, writing, links, frontmatter, and new, moved and deleted notes.`,steps:[{go:`/atlas`,target:`.atlas-world`,title:`This is the Atlas`,text:`nbody-notes: a developer's notes on an N-body simulation, three weeks in. Each block is a note, in its folder: physics, integrators, algorithms, the simulation itself. The lines are links between them.`},{go:`/atlas`,target:`[data-note="${z}"]`,check:fe(z),title:`What a note rests on`,text:`Click Leapfrog. What it requires lights up, all the way back to Newton's law, and so does what builds on it.`,phone:{text:`Tap Leapfrog. What it requires lights up, all the way back to Newton's law, and so does what builds on it.`}},{target:`[data-note="${z}"]`,check:Y(`#/n/${z}`),title:`Open it`,text:`Click it again to open the note.`,phone:{text:`Tap it again to open the note.`}},{go:`/n/${z}`,target:`.cm-content`,title:`A note is Markdown`,text:`Click into the code block, or the line with the link. Its Markdown shows on the lines you touch and hides again when you leave. $…$ is maths; Ctrl+B, Ctrl+I and Ctrl+K make bold, italics and a link; Ctrl+S saves, though it saves by itself.`,phone:{text:`Tap into the code block, or the line with the link. Its Markdown shows on the lines you touch and hides again when you leave. $…$ is maths. It saves by itself.`}},{target:`.cm-content`,title:`Links, and their kind`,text:`A link to another note is a Markdown link. Type [[ and a few letters of a title to make one. Its kind is the link's title: requires, uses, or see also. Alt+L on a link sets it, and the Atlas draws requires strongest.`,phone:{text:`A link to another note is a Markdown link. Type [[ and a few letters of a title to make one. Its kind is the link's title: requires, uses, or see also; the button beside a link sets it.`}},{target:`.cm-content`,check:Y(`#/n/${B}`),title:`Follow a link`,text:`Ctrl and click (⌘ on a Mac) the link to symplectic.`,phone:{go:`/atlas`,target:`[data-note="${B}"]`,text:`On a phone, the Atlas is the way between notes: tap Symplectic integrators, then tap it again.`}},{go:`/n/${B}`,check:X(`.details`),title:`Its frontmatter`,text:`Above the text, details shows the note's frontmatter: its type, a one-line description, and tags. source shows the whole file, frontmatter and all. Open details.`},{go:`/notes`,target:`[data-tour="new-note"]`,check:()=>Q().length>0,title:`A new note, in a new folder`,text:`Make a note: new note, a title (say Plummer sphere), and a folder that is not there yet (say galaxies). A folder is made when a note is put in it.`},{check:()=>Q().length>0&&Q().every(e=>e.id.startsWith(`simulation/`)),title:`Move it`,text:`In the new note's details, change its path to simulation/ and its name, and press Enter. The note moves; links to it would follow. Its old folder, now empty, is gone.`},{check:()=>Z.size>0&&Q().length===0&&O.listing.notes.length===le,title:`Delete it`,text:`In details, delete. You are told first which notes link to it, since their links would be left broken. Its history is kept.`},{title:`That is the base`,text:`nbody-notes is a folder of Markdown files in git: any editor opens it, and isorite notices what changed outside it. Next, Iso, in part B.`}]},{key:`B`,title:`Iso, in your notes`,about:`Asking in place, rewriting a selection, keeping or not, the timeline, what Iso is sent, and a note for Iso.`,steps:[{go:`/n/${H}`,target:`.cm-content`,fill:j.insert,until:J(H),title:`Ask Iso in place`,text:`The quadtree is a stub with a question in it. Click at the end of the question and press Ctrl+Enter. The prompt is filled in: press Enter, and watch what Iso looks up.`,phone:{text:`The quadtree is a stub with a question in it. Tap at the end of the question, then ask Iso here, at the foot of the screen. The prompt is filled in: send it.`}},{target:`.between[data-proposal]`,until:ue(H),title:`Keep it, or not`,text:`Iso read your notes before answering. Its answer waits between the dotted lines: it is not in the note until you keep it. Keep it, edit it first, or remove it.`},{go:`/n/${U}`,target:`.cm-content`,fill:j.rewrite,until:J(U),title:`Rewrite a selection`,text:`Select the paragraph that begins TODO, and press Ctrl+Enter. Iso may change only what you selected. The prompt is filled in: press Enter.`,phone:{text:`Select the paragraph that begins TODO (hold on a word, then drag), and tap ask Iso here. Iso may change only what you selected. The prompt is filled in: send it.`}},{target:`.cm-content`,until:de(U),title:`Keep the change`,text:`The old text is struck through and Iso's stands beside it. Keep it.`},{target:`.bar .count`,check:X(`[role="dialog"][aria-label="Context"]`),title:`What Iso is sent`,text:`The count in the header is what Iso would be sent from this note: the note, those it links, what you asked before, and what this session has cost. Click it to see it part by part. Here Iso is scripted, so nothing is spent.`,phone:{text:`The count in the header is what Iso would be sent from this note: the note, those it links, what you asked before, and what this session has cost. Tap it to see it part by part. Here Iso is scripted, so nothing is spent.`}},{go:`/n/${U}`,target:`button[aria-label="timeline"]`,check:X(`.timeline`),title:`Every change is kept`,text:`Open the timeline, the clock beside the title. Squares are your changes, diamonds Iso's. Point at a mark to see what it changed.`,phone:{text:`Open the timeline, the clock beside the title. Squares are your changes, diamonds Iso's.`}},{target:`.timeline`,check:X(`.atbar`),title:`The note as it was`,text:`Click the first mark, to see the note as it was first written.`,phone:{text:`Tap the first mark, to see the note as it was first written.`}},{target:`.atbar`,check:()=>!document.querySelector(`.atbar`),title:`Step through it`,text:`← and → step from moment to moment. The curved arrow restores the note to this point, as a new change; the other comes back to now.`,phone:{text:`Tap another mark to step to it. The curved arrow restores the note to this point, as a new change; the other comes back to now.`}},{go:`/atlas`,target:`.atlas-world`,check:Y(`#/draft/`),title:`A note for Iso`,text:`Hold on open ground to start a note for Iso: a question, answered from your notes, that becomes a note when you keep it. Hold on a note to start from it, linked.`,phone:{text:`Press and hold on open ground to start a note for Iso: a question, answered from your notes, that becomes a note when you keep it. Hold on a note to start from it, linked.`}},{go:async()=>`/draft/${((await O.api.drafts()).find(e=>e.title.includes(`Close encounters`))?.id??``).slice(7)}`,until:e=>e.type===`iso-start`&&e.note.startsWith(`@draft/`),title:`Send it`,text:`Here is one you wrote yesterday and did not send, with the notes it rests on linked. Send it to Iso, and watch the Atlas.`},{until:J(e=>e.startsWith(`@draft/`)),title:`What Iso reads`,text:`Iso's path through your base is drawn as it reads: found by words (dashed), by meaning (dotted), or along a link. This is its context: what it reads, it is sent.`},{check:()=>pe(/^Close encounters/)!==void 0,title:`Keep it as a note`,text:`When Iso is done, open the note, read the answer, and keep it in physics. It is a note of your base now, linked to what it rests on: found again by you, by Iso, and by the agent in the terminal, as an answer in a chat is not.`},{title:`Iso, in short`,text:`Iso writes only where you ask, and only what you keep goes in. It reads your notes to answer, and you can see what it read and what it costs. Part C puts this to work on the project.`}]},{key:`C`,title:`An evening on the project`,about:`Parts A and B together: from the goal back to what it rests on, a question answered, a plan written with Iso and linked in.`,steps:[{go:`/n/${K}`,target:`.cm-content`,title:`The goal`,text:`Two galaxies colliding, at N = 5000: where the tidal tails start to look right, and where direct summation is too slow. This evening's work is to get there with Barnes–Hut.`},{go:`/atlas`,target:`[data-note="${K}"]`,check:()=>fe(K)()&&!!O.atlas?.chain,title:`What it rests on`,text:`Choose Two galaxies colliding, then [ whole chain ] in the status line: everything it rests on, back to Newton's law. That is the reading list for tonight.`},{go:`/n/${W}`,target:`.cm-content`,fill:j.speed,until:J(W),title:`How much faster?`,text:`In Cost and accuracy, put the cursor after the last paragraph and press Ctrl+Enter. The prompt is filled in: send it.`,phone:{text:`In Cost and accuracy, tap after the last paragraph, then ask Iso here. The prompt is filled in: send it.`}},{target:`.between[data-proposal]`,until:ue(W),title:`Keep what is useful`,text:`Iso checked its arithmetic against your notes, and says to measure. Keep it, or edit it down first.`},{go:`/atlas`,target:`[data-note="${U}"]`,check:Y(`#/draft/`),title:`Plan the octree`,text:`The simulation is 3D, and the quadtree is 2D. Hold on Barnes–Hut to start a note for Iso from it, linked.`,phone:{text:`The simulation is 3D, and the quadtree is 2D. Press and hold on Barnes–Hut to start a note for Iso from it, linked.`}},{until:e=>e.type===`iso-start`&&e.note.startsWith(`@draft/`),title:`Ask it`,text:`Give it the title The octree, and write: ${j.octree} Then send it.`},{check:()=>pe(/octree/i)!==void 0,title:`Keep it in algorithms`,text:`When Iso is done, open the note and keep it in algorithms.`},{go:`/n/${G}`,target:`.cm-content`,check:()=>/octree/i.test(document.querySelector(`.cm-content`)?.textContent??``),title:`Link it in`,text:`The main loop is where it will be used. At the end of the first paragraph, type [[oct and choose the octree.`},{go:async()=>{let e=pe(/octree/i);return e?D(e.id).split(`#`).at(-1):`/n/${G}`},target:`[data-tour="send"]`,title:`Hand it on`,text:`The code is the agent's work, in the terminal. send to agent puts this note in its next prompt: part E.`}]},{key:`D`,title:`Study`,about:`The study base, how understanding is shown, an exercise marked, Iso's read of you, and what to study next.`,steps:[{go:`/atlas`,target:`.atlas-world`,title:`Two bases`,text:`Beside each folder of notes stands a dark-headed folder of exercises. They are the study base: a repository of its own. Your notes are yours to share or publish; what you know, and what you got wrong, stays with you.`},{go:`/n/${L}`,target:`.margin`,title:`What you understand`,text:`The six squares in the margin are Iso's read of how well you know this note, from the exercises you have done. On the Atlas they are four steps: dotted not reached, filled opened, worked through, and a double edge understood. Newton's law is understood.`},{go:`/study`,target:`.list`,title:`What to study next`,text:`Every exercise, in the order Iso would take them: due first, then never tried, then the fewest squares. A few are due: Iso would like to see them again.`},{go:`/n/${ce}`,target:`.cm-content`,until:J(ce),title:`An exercise`,text:`An exercise is written: a question, then your working under Working. This is yesterday's. Select the last line, mark it as your answer, and send it for marking.`},{target:`.cm-content`,check:()=>X(`.cm-iso-right`)()&&!X(`.cm-iso-wrong`)()&&!X(`[aria-label="Iso is marking"]`)(),title:`Wrong, and where`,text:`Iso marks what is right and what is wrong, and says nothing more unless you ask. The pairs were counted twice; the third law halves them. Change the last line to 0.04 s, mark it as your answer again, and send it.`},{target:`.bar .squares`,title:`The squares moved`,text:`Right, and unaided: direct summation is now opened, one square of six. Click the squares for Iso's reason for each move, and wind back if it rates you too highly.`,phone:{text:`Right, and unaided: direct summation is now opened, one square of six. Tap the squares for Iso's reason for each move, and wind back if it rates you too highly.`}},{go:`/atlas`,target:`[data-note="${V}"]`,title:`And on the map`,text:`Its block has moved from dotted to opened.`},{go:`/n/${te}`,target:`.margin`,check:()=>decodeURIComponent(location.hash).includes(`@study/physics/`),title:`Ask for an exercise`,text:`From a note's margin, + an exercise asks Iso for one on it. Ask for one on softening, send it, and keep it: it is filed in the study base, beside physics.`},{go:`/study`,target:`.list`,title:`Keep coming back`,text:`An answer right moves the notes it tests up; leave them, and they fall due, and then slip a square. The list says what is due. That is the whole of studying here.`}]},{key:`E`,title:`In the terminal`,about:`The agent in OpenCode, with your notes as its tools. Outlined here; walked through with isorite --tutorial.`,steps:[{title:`isorite in the terminal`,text:`For work that needs more than notes: code. isorite term runs OpenCode, an agent that edits code, with your base beside it. To walk through it on your machine, with OpenCode 2 installed: isorite --tutorial.`},{title:`It looks before it codes`,text:`The agent has your base as tools: brief_base, search_notes, find_similar, outline_note and read_note. Asked to write Barnes–Hut, it reads your notes on it first, and cites them.`},{go:`/atlas`,target:`.atlas-world`,title:`Watched from here`,text:`While it works, this Atlas follows it: what it found and read is drawn as Iso's path is, and what it used.`},{title:`Its changes to notes wait`,text:`propose_note_edit and propose_note_write: what the agent would change in your notes waits for you, as Iso's does, under its name. Its changes to code are OpenCode's own, which asks before it writes.`},{go:`/n/${G}`,target:`[data-tour="send"]`,title:`From here to there`,text:`send to agent puts a note, or a passage of it, in the agent's next prompt. In the terminal, /note opens a note and /atlas shows what it requires and what builds on it.`},{title:`Its tour, replayed`,link:{href:`#/terminal`,text:`isorite in the terminal: its tour, replayed`},text:`Every screen of the terminal's tour, as OpenCode drew it.`}],local:{about:`The agent in OpenCode, in the terminal beside this page, with your notes as its tools; this page follows it.`,steps:[{title:`The terminal beside this page`,text:`The terminal you ran isorite --tutorial in is this part: its own card leads, a step at a time. This page follows it. Keep the Atlas open where you can see both.`},{go:`/atlas`,target:`.atlas-world`,until:e=>e.type===`agent-done`,title:`Watched from here`,text:`In the terminal, ask the agent for code, as its card says. It looks in your notes first: watch its path drawn here as it reads, found by words, by meaning, or along a link.`},{go:`/n/${K}`,title:`Its changes to notes wait here too`,text:`When the agent would change a note, the change waits in the note, here as in the terminal, under its name. Keep it in either; the other sees it.`},{go:`/n/${G}`,target:`[data-tour="send"]`,until:e=>e.type===`agent-sent`,title:`From here to there`,text:`send to agent puts this note, or a passage of it, in the agent's next prompt. Send it, and look for it in the terminal under from you.`},{title:`On your own notes`,text:`In your project's folder: isorite term <your base>, and the browser at the address it gives. isorite serve <your base> opens the browser alone.`}]}}],$=f({part:-1,at:0,left:!1,done:[]}),ge=e(`<button class="back btn quiet svelte-1195hbs" type="button">the tutorial</button>`),_e=e(`<i class="dia" aria-hidden="true"></i>`),ve=e(`<li><button type="button"><span class="key svelte-1195hbs"> </span><span class="what svelte-1195hbs"><span class="t svelte-1195hbs"> </span><span class="about svelte-1195hbs"> </span></span><!></button></li>`),ye=e(`<div class="coach frame parts svelte-1195hbs" role="dialog" aria-label="The tutorial" aria-live="polite"><div class="row svelte-1195hbs"><i class="dia" aria-hidden="true"></i><span class="label">the tutorial</span></div> <h2 class="svelte-1195hbs"> </h2> <p class="svelte-1195hbs">The base here is a developer's notes on an N-body simulation: bodies under gravity, stepped in time, made fast with Barnes–Hut. Each part stands on its own. <!></p> <ol class="list svelte-1195hbs"></ol> <div class="row actions svelte-1195hbs"><span class="grow"></span><button class="btn quiet svelte-1195hbs" type="button">leave</button></div></div>`),be=e(`<div class="spot svelte-1195hbs" aria-hidden="true"></div>`),xe=e(`<i></i>`),Se=e(`<button class="fold svelte-1195hbs" type="button"> </button>`),Ce=e(`<p class="svelte-1195hbs"> </p>`),we=e(`<p class="svelte-1195hbs"><a> </a></p>`),Te=e(`<span class="label waiting svelte-1195hbs">waiting for you</span><span class="grow"></span> <button class="btn quiet svelte-1195hbs" type="button">skip</button>`,1),Ee=e(`<button class="btn primary svelte-1195hbs" type="button"> </button><span class="grow"></span>`,1),De=e(`<!> <div role="dialog" aria-label="The tutorial" aria-live="polite"><div class="row head svelte-1195hbs"><i class="dia" aria-hidden="true"></i><span class="label"> </span><span class="grow"></span> <span class="seg svelte-1195hbs"></span></div> <h2 class="svelte-1195hbs"><!></h2> <!> <!> <div><!> <button class="btn quiet svelte-1195hbs" type="button">parts</button> <button class="btn quiet svelte-1195hbs" type="button">leave</button></div></div>`,1);function Oe(e,s){h(s,!0);let f=!!O.session?.tutorial,D=he.map(e=>f&&e.local?{...e,...e.local}:e),k=_(()=>$.left),A=_(()=>$.part>=0?D[$.part]:null),j=u(!1),M=_(()=>{let e=r(A)?.steps[$.at];return e?{...e,...r(j)?e.phone:{}}:null}),N=_(()=>!!(r(M)?.until||r(M)?.check)),P=_(()=>r(A)!==null&&$.at===r(A).steps.length-1),F=u(null),I=u(0),L=u(!1);async function R(e){$.at=e,m(L,!1);let t=D[$.part].steps[e],n=(r(j)?t.phone?.go:void 0)??t.go;n&&await E(`#${typeof n==`string`?n:await n()}`)}function te(e){me(),$.part=e,$.left=!1,R(0)}function z(){r(A)&&(r(P)?($.done.includes($.part)||$.done.push($.part),$.part=-1):R($.at+1))}C(()=>{let e=matchMedia(`(max-width: 600px)`);m(j,e.matches,!0);let t=()=>{m(j,e.matches,!0)};e.addEventListener(`change`,t);let n=O.on(e=>{!r(k)&&r(M)?.until?.(e)&&z()}),i=0,a=()=>{if(i=requestAnimationFrame(a),r(k)||!r(M)){m(F,null);return}if(m(I,0),r(j))for(let e of document.querySelectorAll(`.seed, .foot, .changes, .deck`)){let t=e.getBoundingClientRect();t.height&&t.top>innerHeight/2&&m(I,Math.max(r(I),innerHeight-t.top+8),!0)}let e=(r(M).target?document.querySelector(r(M).target):null)?.getBoundingClientRect();m(F,e&&e.width&&e.height?{x:e.left,y:e.top,w:e.width,h:e.height}:null)};a();let o=setInterval(()=>{if(!r(k)&&r(M)){if(r(M).fill){let e=document.querySelector(`[aria-label="Ask Iso"]`);e&&!e.value&&!e.dataset.filled&&(e.dataset.filled=`1`,e.value=r(M).fill,e.dispatchEvent(new Event(`input`,{bubbles:!0})))}r(M).check?.()&&z()}},250);return()=>{n(),cancelAnimationFrame(i),clearInterval(o),e.removeEventListener(`change`,t)}});var B=b(),ne=w(B),V=e=>{var t=ge();l(`click`,t,()=>{$.left=!1,$.part=-1}),c(e,t)},re=e=>{var s=ye(),u=p(a(s),2),m=i(u,!0),h=p(u,2),g=p(a(h)),y=e=>{var t=o(`Iso and the agent are scripted, and nothing leaves your machine; what you change is kept in the tutorial's folder.`);c(e,t)},b=e=>{var t=o(`Iso is scripted, and nothing leaves this page; a reload starts it all again.`);c(e,t)};t(g,e=>{f?e(y):e(b,-1)}),x(h);var S=p(h,2);ee(S,23,()=>D,e=>e.key,(e,o,s)=>{var u=ve(),f=a(u);let m;var h=a(f),g=i(h,!0),y=p(h),b=a(y),S=i(b,!0),C=p(b),w=i(C,!0);x(y);var ee=p(y),E=e=>{var t=_e();c(e,t)},D=_(()=>$.done.includes(r(s)));t(ee,e=>{r(D)&&e(E)}),x(f),x(u),d((e,t)=>{T(f,`aria-label`,`part ${r(o).key??``}: ${r(o).title??``}${e??``}`),m=v(f,1,`svelte-1195hbs`,null,m,{done:t}),n(g,r(o).key),n(S,r(o).title),n(w,r(o).about)},[()=>$.done.includes(r(s))?`, done`:``,()=>$.done.includes(r(s))]),l(`click`,f,()=>te(r(s))),c(e,u)}),x(S);var C=p(S,2),w=p(a(C));x(C),x(s),d(()=>n(m,$.done.length?`Another part?`:`isorite, on a small project`)),l(`click`,w,()=>$.left=!0),c(e,s)},H=e=>{var s=De(),u=w(s),f=e=>{var t=be();d(()=>S(t,`left:${r(F).x-8}px;top:${r(F).y-8}px;width:${r(F).w+16}px;height:${r(F).h+16}px`)),c(e,t)};t(u,e=>{r(F)&&e(f)});var h=p(u,2);let _,y;var b=a(h),C=p(a(b)),E=i(C),D=p(C,3);ee(D,23,()=>r(A).steps,e=>e.title,(e,t,n)=>{var i=xe();let a;d(()=>a=v(i,1,`svelte-1195hbs`,null,a,{d:r(n)<=$.at})),c(e,i)}),x(D),x(b);var O=p(b,2),k=a(O),R=e=>{var t=Se(),a=i(t,!0);d(()=>{T(t,`aria-expanded`,!r(L)),n(a,r(M).title)}),l(`click`,t,()=>m(L,!r(L))),c(e,t)},te=e=>{var t=o();d(()=>n(t,r(M).title)),c(e,t)};t(k,e=>{r(j)?e(R):e(te,-1)}),x(O);var B=p(O,2),ne=e=>{var t=Ce(),a=i(t,!0);d(()=>n(a,r(M).text)),c(e,t)};t(B,e=>{r(L)||e(ne)});var V=p(B,2),re=e=>{var t=we(),o=a(t),s=i(o,!0);x(t),d(()=>{T(o,`href`,r(M).link.href),n(s,r(M).link.text)}),c(e,t)};t(V,e=>{r(M).link&&!r(L)&&e(re)});var H=p(V,2);let U;var W=a(H),G=e=>{var t=Te(),n=p(w(t),3);l(`click`,n,z),c(e,t)},ie=e=>{var t=Ee(),a=w(t),o=i(a,!0);g(),d(()=>n(o,r(P)?`done`:`next`)),l(`click`,a,z),c(e,t)};t(W,e=>{r(N)?e(G):e(ie,-1)});var K=p(W,2),q=p(K,2);x(H),x(h),d(e=>{_=v(h,1,`coach frame svelte-1195hbs`,null,_,{small:r(L)}),y=S(h,``,y,{bottom:r(I)?`${r(I)}px`:null}),n(E,`part ${r(A).key??``} · ${e??``}`),T(D,`aria-label`,`step ${$.at+1} of ${r(A).steps.length??``}`),U=v(H,1,`row actions svelte-1195hbs`,null,U,{hidden:r(L)})},[()=>r(A).title.toLowerCase()]),l(`click`,K,()=>$.part=-1),l(`click`,q,()=>$.left=!0),c(e,s)};t(ne,e=>{r(k)?e(V):r(A)?r(M)&&e(H,2):e(re,1)}),c(e,B),y()}s([`click`]);export{Oe as default};
@@ -0,0 +1 @@
1
+ import"./czZbKOPp.js";
@@ -0,0 +1 @@
1
+ import{I as e,L as t,Q as n,R as r,Z as i,a,n as o,t as s}from"./BC72R-M3.js";var c=class{constructor(e,t){this.status=e,this.body=typeof t==`string`?{message:t}:t||{message:`Error: ${e}`}}toString(){return JSON.stringify(this.body)}},l=class{constructor(e,t){try{new Headers({location:t})}catch{throw Error(`Invalid redirect location ${JSON.stringify(t)}: this string contains characters that cannot be used in HTTP headers`)}this.status=e,this.location=t}},u=class extends Error{constructor(e,t,n){super(n),this.status=e,this.text=t}};new URL(`sveltekit-internal://`);function d(e,t){return e===`/`||t===`ignore`?e:t===`never`?e.endsWith(`/`)?e.slice(0,-1):e:t===`always`&&!e.endsWith(`/`)?e+`/`:e}function f(e){return e.split(`%25`).map(decodeURI).join(`%25`)}function p(e){for(let t in e)e[t]=decodeURIComponent(e[t]);return e}function m({href:e}){return e.split(`#`)[0]}function ee(e,t,n,r=!1){let i=new URL(e);Object.defineProperty(i,"searchParams",{value:new Proxy(i.searchParams,{get(e,r){if(r===`get`||r===`getAll`||r===`has`)return(t,...i)=>(n(t),e[r](t,...i));t();let i=Reflect.get(e,r);return typeof i==`function`?i.bind(e):i}}),enumerable:!0,configurable:!0});let a=[`href`,`pathname`,`search`,`toString`,`toJSON`];r&&a.push(`hash`);for(let n of a)Object.defineProperty(i,n,{get(){return t(),e[n]},enumerable:!0,configurable:!0});return i}function h(){}function g(...e){let t=5381;for(let n of e)if(typeof n==`string`){let e=n.length;for(;e;)t=t*33^n.charCodeAt(--e)}else if(ArrayBuffer.isView(n)){let e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r=e.length;for(;r;)t=t*33^e[--r]}else throw TypeError(`value must be a string or TypedArray`);return(t>>>0).toString(36)}new TextEncoder;function _(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var te=window.fetch;window.fetch=(e,t)=>((e instanceof Request?e.method:t?.method||`GET`)!==`GET`&&v.delete(b(e)),te(e,t));var v=new Map;function y(e,t){let n=b(e,t),r=document.querySelector(n);if(r?.textContent){r.remove();let{body:e,...t}=JSON.parse(r.textContent);r.getAttribute(`data-b64`)!==null&&(e=_(e));let i=r.getAttribute(`data-ttl`);return i&&v.set(n,{body:e,init:t,ttl:1e3*Number(i)}),Promise.resolve(new Response(e,t))}return window.fetch(e,t)}function ne(e,t,n){if(v.size>0){let t=b(e,n),r=v.get(t);if(r){if(performance.now()<r.ttl&&[`default`,`force-cache`,`only-if-cached`,void 0].includes(n?.cache))return new Response(r.body,r.init);v.delete(t)}}return window.fetch(t,n)}function b(e,t){let n=`script[data-sveltekit-fetched][data-url=${JSON.stringify(e instanceof Request?e.url:e)}]`;if(t?.headers||t?.body){let e=[];t.headers&&e.push([...new Headers(t.headers)].join(`,`)),t.body&&(typeof t.body==`string`||ArrayBuffer.isView(t.body))&&e.push(t.body),n+=`[data-hash="${g(...e)}"]`}return n}var re=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/,ie=/^\/\((?:[^)]+)\)$/;function ae(e){let t=[];return{pattern:e===`/`||ie.test(e)?/^\/$/:RegExp(`^${se(e).map(e=>{let n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(e);if(n)return t.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),`(?:/([^]*))?`;let r=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(e);if(r)return t.push({name:r[1],matcher:r[2],optional:!0,rest:!1,chained:!0}),`(?:/([^/]+))?`;if(!e)return;let i=e.split(/\[(.+?)\](?!\])/);return`/`+i.map((e,n)=>{if(n%2){if(e.startsWith(`x+`))return le(String.fromCharCode(parseInt(e.slice(2),16)));if(e.startsWith(`u+`))return le(String.fromCharCode(...e.slice(2).split(`-`).map(e=>parseInt(e,16))));let[,r,a,o,s]=re.exec(e);return t.push({name:o,matcher:s,optional:!!r,rest:!!a,chained:a?n===1&&i[0]===``:!1}),a?`([^]*?)`:r?`([^/]*)?`:`([^/]+?)`}return le(e)}).join(``)}).join(``)}/?$`),params:t}}function oe(e){return e!==``&&!/^\([^)]+\)$/.test(e)}function se(e){return e.slice(1).split(`/`).filter(oe)}function ce(e,t,n){let r={},i=e.slice(1),a=i.filter(e=>e!==void 0),o=0;for(let e=0;e<t.length;e+=1){let s=t[e],c=i[e-o];if(s.chained&&s.rest&&o&&(c=i.slice(e-o,e+1).filter(e=>e).join(`/`),o=0),c===void 0){if(s.rest)c=``;else continue}if(!s.matcher||n[s.matcher](c)){r[s.name]=c;let n=t[e+1],l=i[e+1];n&&!n.rest&&n.optional&&l&&s.chained&&(o=0),!n&&!l&&Object.keys(r).length===a.length&&(o=0)}else if(s.optional&&s.chained)o++;else return}if(!o)return r}function le(e){return e.normalize().replace(/[[\]]/g,`\\$&`).replace(/%/g,`%25`).replace(/\//g,`%2[Ff]`).replace(/\?/g,`%3[Ff]`).replace(/#/g,`%23`).replace(/[.*+?^${}()|\\]/g,`\\$&`)}var ue=/\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;function de(e,t){let n=se(e),r=e!=`/`&&e.endsWith(`/`);return`/`+n.map(n=>n.replace(ue,(n,r,i,a)=>{let o=t[a];if(!o){if(r||i&&o!==void 0)return``;throw Error(`Missing parameter '${a}' in route ${e}`)}if(o.startsWith(`/`)||o.endsWith(`/`))throw Error(`Parameter '${a}' in route ${e} cannot start or end with a slash -- this would cause an invalid route like foo//bar`);return o})).filter(Boolean).join(`/`)+(r?`/`:``)}function fe({nodes:e,server_loads:t,dictionary:n,matchers:r}){let i=new Set(t);return Object.entries(n).map(([t,[n,i,s]])=>{let{pattern:c,params:l}=ae(t),u={id:t,exec:e=>{let t=c.exec(e);if(t)return ce(t,l,r)},errors:[1,...s||[]].map(t=>e[t]),layouts:[0,...i||[]].map(o),leaf:a(n)};return u.errors.length=u.layouts.length=Math.max(u.errors.length,u.layouts.length),u});function a(t){let n=t<0;return n&&(t=~t),[n,e[t]]}function o(t){return t===void 0?t:[i.has(t),e[t]]}}function pe(e,t=JSON.parse){try{return t(sessionStorage[e])}catch{}}function me(e,t,n=JSON.stringify){let r=n(t);try{sessionStorage[e]=r}catch{}}var x=globalThis.__sveltekit_bdiqfw?.base??``,he=globalThis.__sveltekit_bdiqfw?.assets??x??``,ge=`#`;function _e(...e){if(!e[0].startsWith(`/`))throw Error(`Cannot use \`resolve(...)\` with a non-absolute pathname or route ID (got "${e[0]}"). \`resolve\` is only for internal pathnames and route IDs; external URLs should be used directly.`);return x+ge+de(e[0],e[1])}var ve=`1792373687813`,ye=`sveltekit:snapshot`,be=`sveltekit:scroll`,xe=`sveltekit:states`,S=`sveltekit:history`,C=`sveltekit:navigation`,w={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},Se=location.origin;function Ce(e){if(e instanceof URL)return e;let t=document.baseURI;if(!t){let e=document.getElementsByTagName(`base`);t=e.length?e[0].href:document.URL}return new URL(e,t)}function T(){return{x:pageXOffset,y:pageYOffset}}function E(e,t){return e.getAttribute(`data-sveltekit-${t}`)}var we={...w,"":w.hover};function Te(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11&&(t=t.host),t}function Ee(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()===`A`&&e.hasAttribute(`href`))return e;e=Te(e)}}function De(e,t,n){let r;try{if(r=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){let e=location.hash.split(`#`)[1]||`/`;r.hash=`#${e}${r.hash}`}}catch{}let i=e instanceof SVGAElement?e.target.baseVal:e.target,a=!r||!!i||D(r,t,n)||(e.getAttribute(`rel`)||``).split(/\s+/).includes(`external`),o=r?.origin===Se&&e.hasAttribute(`download`);return{url:r,external:a,target:i,download:o}}function Oe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=e;for(;s&&s!==document.documentElement;)r===null&&(r=E(s,`preload-code`)),i===null&&(i=E(s,`preload-data`)),t===null&&(t=E(s,`keepfocus`)),n===null&&(n=E(s,`noscroll`)),a===null&&(a=E(s,`reload`)),o===null&&(o=E(s,`replacestate`)),s=Te(s);function c(e){switch(e){case``:case`true`:return!0;case`off`:case`false`:return!1;default:return}}return{preload_code:we[r??`off`],preload_data:we[i??`off`],keepfocus:c(t),noscroll:c(n),reload:c(a),replace_state:c(o)}}function ke(e){let t=a(e),n=!0;function r(){n=!0,t.update(e=>e)}function i(e){n=!1,t.set(e)}function o(e){let r;return t.subscribe(t=>{(r===void 0||n&&t!==r)&&e(r=t)})}return{notify:r,set:i,subscribe:o}}var Ae={v:h};function je(){let{set:e,subscribe:t}=a(!1),n;async function r(){clearTimeout(n);try{let t=await fetch(`${he}/_app/version.json`,{headers:{pragma:`no-cache`,"cache-control":`no-cache`}});if(!t.ok)return!1;let r=(await t.json()).version!==ve;return r&&(e(!0),Ae.v(),clearTimeout(n)),r}catch{return!1}}return{subscribe:t,check:r}}function D(e,t,n){return e.origin!==Se||!e.pathname.startsWith(t)?!0:n?e.pathname!==location.pathname:!1}function Me(e){}var Ne=new Set([`load`,`prerender`,`csr`,`ssr`,`trailingSlash`,`config`]);[...Ne],[...new Set([...Ne])];function Pe(e){return e.filter(e=>e!=null)}function O(e,t){return e+`/`+t}function Fe(e){return e instanceof c||e instanceof u?e.status:500}function Ie(e){return e instanceof u?e.text:`Internal Error`}var k,A,Le,Re=o.toString().includes(`$$`)||/function \w+\(\) \{\}/.test(o.toString()),ze=`a:`;Re?(k={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL(ze)},A={current:null},Le={current:!1}):(k=new class{#e=n({});get data(){return e(this.#e)}set data(e){i(this.#e,e)}#t=n(null);get form(){return e(this.#t)}set form(e){i(this.#t,e)}#n=n(null);get error(){return e(this.#n)}set error(e){i(this.#n,e)}#r=n({});get params(){return e(this.#r)}set params(e){i(this.#r,e)}#i=n({id:null});get route(){return e(this.#i)}set route(e){i(this.#i,e)}#a=n({});get state(){return e(this.#a)}set state(e){i(this.#a,e)}#o=n(-1);get status(){return e(this.#o)}set status(e){i(this.#o,e)}#s=n(new URL(ze));get url(){return e(this.#s)}set url(e){i(this.#s,e)}},A=new class{#e=n(null);get current(){return e(this.#e)}set current(e){i(this.#e,e)}},Le=new class{#e=n(!1);get current(){return e(this.#e)}set current(e){i(this.#e,e)}},Ae.v=()=>Le.current=!0);function Be(e){Object.assign(k,e)}var Ve={spanContext(){return He},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this},addLink(){return this},addLinks(){return this}},He={traceId:``,spanId:``,traceFlags:0},{onMount:Ue,tick:We}=s,Ge=new Set([`icon`,`shortcut icon`,`apple-touch-icon`]),j=null,M=pe(`sveltekit:scroll`)??{},N=pe(`sveltekit:snapshot`)??{},P={url:ke({}),page:ke({}),navigating:a(null),updated:je()};function Ke(e){M[e]=T()}function qe(e,t){let n=e+1;for(;M[n];)delete M[n],n+=1;for(n=t+1;N[n];)delete N[n],n+=1}function F(e,t=!1){return t?location.replace(e.href):location.href=e.href,new Promise(h)}async function Je(){if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistration(x||`/`);e&&await e.update()}}var Ye,Xe,I,L,Ze,R,Qe={},$e={},z=[],B=[],V=null;function H(){V?.fork?.then(e=>e?.discard()),V=null,Q={element:void 0,href:void 0}}var et=new Map,tt=new Set,nt=new Set,U=new Set,W={branch:[],error:null,url:null,nav:null},rt=!1,it=!1,at=!0,G=!1,K=!1,ot=!1,st=!1,ct,q,J,Y,lt=new Set,ut=new Map,dt=new Map;async function ft(e,t,n){if(globalThis.__sveltekit_bdiqfw.data){let{q:e={},p:t={},l:n={},f:r={}}=globalThis.__sveltekit_bdiqfw.data;for(let t in e)Qe[t]=e[t];for(let e in n)Qe[e]=n[e];for(let e in r)Qe[e]=r[e];for(let e in t)$e[e]=t[e]}document.URL!==location.href&&(location.href=location.href),R=e,await e.hooks.init?.(),Ye=fe(e),L=document.documentElement,Ze=t,Xe=e.nodes[0],I=e.nodes[1],Xe(),I(),q=history.state?.[S],J=history.state?.[C],q||(q=J=Date.now(),history.replaceState({...history.state,[S]:q,[C]:J},``));let r=M[q];function i(){r&&(history.scrollRestoration=`manual`,scrollTo(r.x,r.y))}n?(i(),await Bt(Ze,n)):(await Z({type:`enter`,url:Ce(R.hash?Kt(new URL(location.href)):location.href),replace_state:!0}),i()),zt()}function pt(){z.length=0,st=!1}function mt(e){B.some(e=>e?.snapshot)&&(N[e]=B.map(e=>e?.snapshot?.capture()))}function ht(e){N[e]?.forEach((e,t)=>{B[t]?.snapshot?.restore(e)})}function gt(){Ke(q),me(be,M),mt(J),me(ye,N)}async function _t(e,t,n,i){let a,o;t.invalidateAll&&H(),await Z({type:`goto`,url:Ce(e),keepfocus:t.keepFocus,noscroll:t.noScroll,replace_state:t.replaceState,state:t.state,redirect_count:n,nav_token:i,accept:()=>{if(t.invalidateAll){st=!0,a=new Set;for(let[e,t]of ut)for(let[n,r]of t)r.resource?.reset(),a.add(O(e,n));o=new Set;for(let[e,t]of dt)for(let n of t.keys())o.add(O(e,n))}t.invalidate&&t.invalidate.forEach(Rt)}}),t.invalidateAll&&r().then(r).then(()=>{for(let[e,t]of ut)for(let[n,{resource:r}]of t)a?.has(O(e,n))&&r.start();for(let[e,t]of dt)for(let[n,{resource:r}]of t)o?.has(O(e,n))&&r.reconnect()})}async function vt(e){if(e.id!==V?.id){H();let t={};lt.add(t),V={id:e.id,token:t,promise:Ot({...e,preload:t}).then(e=>(lt.delete(t),e.type===`loaded`&&e.state.error&&H(),e)),fork:null}}return V.promise}async function yt(e){let t=(await X(e,!1))?.route;t&&await Promise.all([...t.layouts,t.leaf].filter(Boolean).map(e=>e[1]()))}async function bt(e,t,n){let r={params:W.params,route:{id:W.route?.id??null},url:new URL(location.href)};if(W={...e.state,nav:r},Be(e.props.page),ct=new R.root({target:t,props:{...e.props,stores:P,components:B},hydrate:n,sync:!1,transformError:void 0}),await Promise.resolve(),n){let e={from:null,to:{...r,scroll:M[q]??T()},willUnload:!1,type:`enter`,complete:Promise.resolve()};U.forEach(t=>t(e))}ht(J),it=!0}async function xt({url:e,params:t,branch:n,errors:r,status:i,error:a,route:o,form:s}){let c=`never`;if(x&&(e.pathname===x||e.pathname===x+`/`))c=`always`;else for(let e of n)e?.slash!==void 0&&(c=e.slash);e.pathname=d(e.pathname,c),e.search=e.search;let l={type:`loaded`,state:{url:e,params:t,branch:n,error:a,route:o},props:{constructors:Pe(n).map(e=>e.node.component),page:Gt(k)}};s!==void 0&&(l.props.form=s);let u={},f=!k,p=0;for(let e=0;e<Math.max(n.length,W.branch.length);e+=1){let t=n[e],r=W.branch[e];t?.data!==r?.data&&(f=!0),t&&(u={...u,...t.data},f&&(l.props[`data_${p}`]=u),p+=1)}return(!W.url||e.href!==W.url.href||W.error!==a||s!==void 0&&s!==k.form||f)&&(l.props.page={error:a,params:t,route:{id:o?.id??null},state:{},status:i,url:new URL(e),form:s??null,data:f?u:k.data}),l}async function St({loader:e,parent:t,url:n,params:r,route:i,server_data_node:a}){let o=null,s=!0,c={dependencies:new Set,params:new Set,parent:!1,route:!1,url:!1,search_params:new Set},l=await e();if(l.universal?.load){function e(...e){for(let t of e){let{href:e}=new URL(t,n);c.dependencies.add(e)}}let u={tracing:{enabled:!1,root:Ve,current:Ve},route:new Proxy(i,{get:(e,t)=>(s&&(c.route=!0),e[t])}),params:new Proxy(r,{get:(e,t)=>(s&&c.params.add(t),e[t])}),data:a?.data??null,url:ee(n,()=>{s&&(c.url=!0)},e=>{s&&c.search_params.add(e)},R.hash),async fetch(t,r){t instanceof Request&&(r={body:t.method===`GET`||t.method===`HEAD`?void 0:await t.blob(),cache:t.cache,credentials:t.credentials,headers:[...t.headers].length>0?t?.headers:void 0,integrity:t.integrity,keepalive:t.keepalive,method:t.method,mode:t.mode,redirect:t.redirect,referrer:t.referrer,referrerPolicy:t.referrerPolicy,signal:t.signal,...r});let{resolved:i,promise:a}=Ct(t,r,n);return s&&e(i.href),a},setHeaders:h,depends:e,parent(){return s&&(c.parent=!0),t()},untrack(e){s=!1;try{return e()}finally{s=!0}}};o=await l.universal.load.call(null,u)??null}return{node:l,loader:e,server:a,universal:l.universal?.load?{type:`data`,data:o,uses:c}:null,data:o??a?.data??null,slash:l.universal?.trailingSlash??a?.slash}}function Ct(e,t,n){let r=e instanceof Request?e.url:e,i=new URL(r,n);return i.origin===n.origin&&(r=i.href.slice(n.origin.length)),{resolved:i,promise:it?ne(r,i.href,t):y(r,t)}}function wt(e,t,n,r,i,a){if(st)return!0;if(!i)return!1;if(i.parent&&e||i.route&&t||i.url&&n)return!0;for(let e of i.search_params)if(r.has(e))return!0;for(let e of i.params)if(a[e]!==W.params[e])return!0;for(let e of i.dependencies)if(z.some(t=>t(new URL(e))))return!0;return!1}function Tt(e,t){return e?.type===`data`?e:e?.type===`skip`?t??null:null}function Et(e,t){if(!e)return new Set(t.searchParams.keys());let n=new Set([...e.searchParams.keys(),...t.searchParams.keys()]);for(let r of n){let i=e.searchParams.getAll(r),a=t.searchParams.getAll(r);i.every(e=>a.includes(e))&&a.every(e=>i.includes(e))&&n.delete(r)}return n}function Dt({error:e,url:t,route:n,params:r}){return{type:`loaded`,state:{error:e,url:t,route:n,params:r,branch:[]},props:{page:Gt(k),constructors:[]}}}async function Ot({id:e,invalidating:t,url:n,params:r,route:i,preload:a}){if(V?.id===e)return lt.delete(V.token),V.promise;let{errors:o,layouts:s,leaf:u}=i,d=[...s,u];o.forEach(e=>e?.().catch(h)),d.forEach(e=>e?.[1]().catch(h));let f=W.url?e!==Nt(W.url):!1,p=W.route?i.id!==W.route.id:!1,m=Et(W.url,n),ee=!1,g=d.map(async(e,t)=>{if(!e)return;let a=W.branch[t];return e[1]===a?.loader&&!wt(ee,p,f,m,a.universal?.uses,r)?a:(ee=!0,St({loader:e[1],url:n,params:r,route:i,parent:async()=>{let e={};for(let n=0;n<t;n+=1)Object.assign(e,(await g[n])?.data);return e},server_data_node:Tt(e[0]?{type:`skip`}:null,e[0]?a?.server:void 0)}))});for(let e of g)e.catch(h);let _=[];for(let e=0;e<d.length;e+=1)if(d[e])try{_.push(await g[e])}catch(t){if(t instanceof l)return{type:`redirect`,location:t.location};if(a&&lt.has(a))return Dt({error:await $(t,{params:r,url:n,route:{id:i.id}}),url:n,params:r,route:i});let s=Fe(t),u;if(t instanceof c)u=t.body;else{if(await P.updated.check())return await Je(),await F(n);u=await $(t,{params:r,url:n,route:{id:i.id}})}let d=await kt(e,_,o);return d?xt({url:n,params:r,branch:_.slice(0,d.idx).concat(d.node),errors:o,status:s,error:u,route:i}):await Ft(n,{id:i.id},u,s)}else _.push(void 0);return xt({url:n,params:r,branch:_,errors:o,status:200,error:null,route:i,form:t?void 0:null})}async function kt(e,t,n){for(;e--;)if(n[e]){let r=e;for(;!t[r];)--r;try{return{idx:r+1,node:{node:await n[e](),loader:n[e],data:{},server:null,universal:null}}}catch{continue}}}async function At({status:e,error:t,url:n,route:r}){let i={};try{return xt({url:n,params:i,branch:[await St({loader:Xe,url:n,params:i,route:r,parent:()=>Promise.resolve({}),server_data_node:Tt(null)}),{node:await I(),loader:I,universal:null,server:null,data:null}],status:e,error:t,errors:[],route:null})}catch(t){if(t instanceof l){await _t(new URL(t.location,location.href),{},0);return}let a=await R.get_error_template(),o=await $(t,{url:n,params:i,route:r}),s=a({status:e,message:String(o?.message??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}),c=new DOMParser().parseFromString(s,`text/html`);throw document.documentElement.replaceChild(document.adoptNode(c.head),document.head),document.documentElement.replaceChild(document.adoptNode(c.body),document.body),t}}async function jt(e){let t=e.href;if(et.has(t))return et.get(t);let n;try{let r=(async()=>{let t=await R.hooks.reroute({url:new URL(e),fetch:async(t,n)=>Ct(t,n,e).promise})??e;if(typeof t==`string`){let n=new URL(e);R.hash?n.hash=t:n.pathname=t,t=n}return t})();et.set(t,r),n=await r}catch{et.delete(t);return}return n}async function X(e,t){if(e&&!D(e,x,R.hash)){let n=await jt(e);if(!n)return;let r=Mt(n);for(let n of Ye){let i=n.exec(r);if(i)return{id:Nt(e),invalidating:t,route:n,params:p(i),url:e}}}}function Mt(e){return f(R.hash?e.hash.replace(/^#/,``).replace(/[?#].+/,``):e.pathname.slice(x.length))||`/`}function Nt(e){return(R.hash?e.hash.replace(/^#/,``):e.pathname)+e.search}function Pt({url:e,type:t,intent:n,delta:r,event:i,scroll:a}){let o=!1,s=Wt(W,n,e,t,a??null);r!==void 0&&(s.navigation.delta=r),i!==void 0&&(s.navigation.event=i);let c={...s.navigation,cancel:()=>{o=!0,s.reject(Error(`navigation cancelled`))}};return G||tt.forEach(e=>e(c)),o?null:s}async function Z({type:e,url:n,popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c={},redirect_count:l=0,nav_token:d={},accept:f=h,block:p=h,event:m}){let ee=Y;Y=d;let g=await X(n,!1),_=e===`enter`?Wt(W,g,n,e):Pt({url:n,type:e,delta:i?.delta,intent:g,scroll:i?.scroll,event:m});if(!_){p(),Y===d&&(Y=ee);return}let te=q,v=J;f(),G=!0,it&&_.navigation.type!==`enter`&&P.navigating.set(A.current=_.navigation);let y=g&&await Ot(g);if(!y){if(D(n,x,R.hash))return await F(n,s);y=await Ft(n,{id:null},await $(new u(404,`Not Found`,`Not found: ${n.pathname}`),{url:n,params:{},route:{id:null}}),404,s)}if(n=g?.url||n,Y!==d){_.reject(Error(`navigation aborted`));return}if(!y)return;if(y.type===`redirect`){if(l<20){await Z({type:e,url:new URL(y.location,n),popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c,redirect_count:l+1,nav_token:d}),_.fulfil(void 0);return}if(y=await At({status:500,error:await $(Error(`Redirect loop`),{url:n,params:{},route:{id:null}}),url:n,route:{id:null}}),!y)return}else if(y.props.page.status>=400&&await P.updated.check())return await Je(),await F(n,s);if(pt(),Ke(te),mt(v),y.props.page.url.pathname!==n.pathname&&(n.pathname=y.props.page.url.pathname),c=i?i.state:c,!i){let e=+!s,t={[S]:q+=e,[C]:J+=e,[xe]:c};(s?history.replaceState:history.pushState).call(history,t,``,n),s||qe(q,J)}let ne=g&&V?.id===g.id?V.fork:null;V?.fork&&!ne?H():(V=null,Q={element:void 0,href:void 0}),y.props.page.state=c;let b;if(it){let e=(await Promise.all(Array.from(nt,e=>e(_.navigation)))).filter(e=>typeof e==`function`);if(e.length>0){function t(){e.forEach(e=>{U.delete(e)})}e.push(t),e.forEach(e=>{U.add(e)})}let r=_.navigation.to;W={...y.state,nav:{params:r.params,route:r.route,url:r.url}},y.props.page&&(y.props.page.url=n),!a&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur();let i=ne&&await ne;i?b=i.commit():(j=null,ct.$set(y.props),j&&Object.assign(y.props.page,j),Be(y.props.page),b=t?.()),ot=!0}else await bt(y,Ze,!1);let{activeElement:re}=document;if(await b,await r(),await r(),Y!==d){_.reject(Error(`navigation aborted`));return}y.props.page&&j&&Object.assign(y.props.page,j);let ie=null;if(at){let e=i?i.scroll:o?T():null;e?scrollTo(e.x,e.y):(ie=n.hash&&document.getElementById(qt(n)))?ie.scrollIntoView():scrollTo(0,0)}let ae=document.activeElement!==re&&document.activeElement!==document.body;!a&&!ae&&Ut(n,!ie),at=!0,G=!1,_.fulfil(void 0),_.navigation.to&&(_.navigation.to.scroll=T()),U.forEach(e=>e(_.navigation)),e===`popstate`&&ht(J),P.navigating.set(A.current=null)}async function Ft(e,t,n,r,i){return e.origin===Se&&e.pathname===location.pathname&&!rt?await At({status:r,error:n,url:e,route:t}):await F(e,i)}var Q={element:void 0,href:void 0};function It(){let e,t;L.addEventListener(`mousemove`,t=>{let n=t.target;clearTimeout(e),e=setTimeout(()=>{i(n,w.hover)},20)});function n(e){e.defaultPrevented||i(e.composedPath()[0],w.tap)}L.addEventListener(`mousedown`,n),L.addEventListener(`touchstart`,n,{passive:!0});let r=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(yt(new URL(t.target.href)),r.unobserve(t.target))},{threshold:0});async function i(e,n){let r=Ee(e,L),i=r===Q.element&&r?.href===Q.href&&n>=t;if(!r||i)return;let{url:a,external:o,download:s}=De(r,x,R.hash);if(o||s)return;let c=Oe(r),l=a&&Nt(W.url)===Nt(a);if(!(c.reload||l)){if(n<=c.preload_data){Q={element:r,href:r.href},t=w.tap;let e=await X(a,!1);if(!e)return;vt(e)}else n<=c.preload_code&&(Q={element:r,href:r.href},t=n,yt(a))}}function a(){r.disconnect();for(let e of L.querySelectorAll(`a`)){let{url:t,external:n,download:i}=De(e,x,R.hash);if(n||i)continue;let a=Oe(e);a.reload||(a.preload_code===w.viewport&&r.observe(e),a.preload_code===w.eager&&yt(t))}}U.add(a),a()}function $(e,t){if(e instanceof c)return e.body;let n=Fe(e),r=Ie(e);return R.hooks.handleError({error:e,event:t,status:n,message:r})??{message:r}}function Lt(e,t={}){return e=new URL(Ce(e)),e.origin===Se?_t(e,t,0):Promise.reject(Error(`goto: invalid URL`))}function Rt(e){if(typeof e==`function`)z.push(e);else{let{href:t}=new URL(e,location.href);z.push(e=>e.href===t)}}function zt(){history.scrollRestoration=`manual`,addEventListener(`beforeunload`,e=>{let t=!1;if(gt(),!G){let e=Wt(W,void 0,null,`leave`),n={...e.navigation,cancel:()=>{t=!0,e.reject(Error(`navigation cancelled`))}};tt.forEach(e=>e(n))}t?(e.preventDefault(),e.returnValue=``):history.scrollRestoration=`auto`}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&gt()}),navigator.connection?.saveData||It(),L.addEventListener(`click`,async t=>{if(t.button||t.which!==1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.defaultPrevented)return;let n=Ee(t.composedPath()[0],L);if(!n)return;let{url:r,external:i,target:a,download:o}=De(n,x,R.hash);if(!r)return;if(a===`_parent`||a===`_top`){if(window.parent!==window)return}else if(a&&a!==`_self`)return;let s=Oe(n);if(!(n instanceof SVGAElement)&&r.protocol!==location.protocol&&r.protocol!==`https:`&&r.protocol!==`http:`||o)return;let[c,l]=(R.hash?r.hash.replace(/^#/,``):r.href).split(`#`),u=c===m(location);if(i||s.reload&&(!u||!l))Pt({url:r,type:`link`,event:t})?G=!0:t.preventDefault();else{if(l!==void 0&&u){let[,i]=W.url.href.split(`#`);if(i===l){if(t.preventDefault(),l===``||l===`top`&&n.ownerDocument.getElementById(`top`)===null)scrollTo({top:0});else{let e=n.ownerDocument.getElementById(decodeURIComponent(l));e&&(e.scrollIntoView(),e.focus())}return}if(K=!0,Ke(q),e(r),!s.replace_state)return;K=!1}t.preventDefault(),await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,0)}),setTimeout(e,100)}),await Z({type:`link`,url:r,keepfocus:s.keepfocus,noscroll:s.noscroll,replace_state:s.replace_state??r.href===location.href,event:t})}}),L.addEventListener(`submit`,e=>{if(e.defaultPrevented)return;let t=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if((n?.formTarget||t.target)===`_blank`||(n?.formMethod||t.method)!==`get`)return;let r=new URL(n?.hasAttribute(`formaction`)&&n?.formAction||t.action);if(D(r,x,!1))return;let i=e.target,a=Oe(i);if(a.reload)return;e.preventDefault(),e.stopPropagation();let o=new FormData(i,n);r.search=new URLSearchParams(o).toString(),Z({type:`form`,url:r,keepfocus:a.keepfocus,noscroll:a.noscroll,replace_state:a.replace_state??r.href===location.href,event:e})}),addEventListener(`popstate`,async t=>{if(!Ht){if(t.state?.[`sveltekit:history`]){let n=t.state[S];if(Y={},n===q)return;let r=M[n],i=t.state[`sveltekit:states`]??{},a=new URL(t.state[`sveltekit:pageurl`]??location.href),o=t.state[C],s=W.url?m(location)===m(W.url):!1;if(o===J&&(ot||s)){i!==k.state&&(k.state=i),e(a),M[q]=T(),r&&scrollTo(r.x,r.y),q=n;return}let c=n-q;await Z({type:`popstate`,url:a,popped:{state:i,scroll:r,delta:c},accept:()=>{q=n,J=o},block:()=>{history.go(-c)},nav_token:Y,event:t})}else K||(e(new URL(location.href)),R.hash&&location.reload())}}),addEventListener(`hashchange`,()=>{K&&(K=!1,history.replaceState({...history.state,[S]:++q,[C]:J},``,location.href))});for(let e of document.querySelectorAll(`link`))Ge.has(e.rel)&&(e.href=e.href);addEventListener(`pageshow`,e=>{e.persisted&&P.navigating.set(A.current=null)});function e(e){W.url=k.url=e,P.page.set(Gt(k)),P.page.notify()}}async function Bt(e,{status:t=200,error:n,node_ids:r,params:i,route:a,server_route:o,data:s,form:c}){rt=!0;let u=new URL(location.href),d;({params:i={},route:a={id:null}}=await X(u,!1)||{}),d=Ye.find(({id:e})=>e===a.id);let f,p=!0;try{let e=r.map(async(t,n)=>{let r=s[n];return r?.uses&&(r.uses=Vt(r.uses)),St({loader:R.nodes[t],url:u,params:i,route:a,parent:async()=>{let t={};for(let r=0;r<n;r+=1)Object.assign(t,(await e[r]).data);return t},server_data_node:Tt(r)})}),o=await Promise.all(e);if(d){let e=d.layouts;for(let t=0;t<e.length;t++)e[t]||o.splice(t,0,void 0)}f=await xt({url:u,params:i,branch:o,status:t,error:n,errors:d?.errors,form:c,route:d??null})}catch(t){if(t instanceof l)return await F(new URL(t.location,location.href));f=await At({status:Fe(t),error:await $(t,{url:u,params:i,route:a}),url:u,route:a}),e.textContent=``,p=!1}f&&(f.props.page&&(f.props.page.state={}),await bt(f,e,p))}function Vt(e){return{dependencies:new Set(e?.dependencies??[]),params:new Set(e?.params??[]),parent:!!e?.parent,route:!!e?.route,url:!!e?.url,search_params:new Set(e?.search_params??[])}}var Ht=!1;function Ut(e,t=!0){let n=document.querySelector(`[autofocus]`);if(n)n.focus();else{let n=qt(e);if(n&&document.getElementById(n)){let{x:r,y:i}=T();setTimeout(()=>{let a=history.state;Ht=!0,location.replace(new URL(`#${n}`,location.href)),history.replaceState(a,``,e),t&&scrollTo(r,i),Ht=!1})}else{let e=document.body,t=e.getAttribute(`tabindex`);e.tabIndex=-1,e.focus({preventScroll:!0,focusVisible:!1}),t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t)}let r=getSelection();if(r&&r.type!==`None`){let e=[];for(let t=0;t<r.rangeCount;t+=1)e.push(r.getRangeAt(t));setTimeout(()=>{if(r.rangeCount===e.length){for(let t=0;t<r.rangeCount;t+=1){let n=e[t],i=r.getRangeAt(t);if(n.commonAncestorContainer!==i.commonAncestorContainer||n.startContainer!==i.startContainer||n.endContainer!==i.endContainer||n.startOffset!==i.startOffset||n.endOffset!==i.endOffset)return}r.removeAllRanges()}})}}}function Wt(e,t,n,r,i=null){let a,o,s=new Promise((e,t)=>{a=e,o=t});return s.catch(h),{navigation:{from:{params:e.params,route:{id:e.route?.id??null},url:e.url,scroll:T()},to:n&&{params:t?.params??null,route:{id:t?.route?.id??null},url:n,scroll:i},willUnload:!t,type:r,complete:s},fulfil:a,reject:o}}function Gt(e){return{data:e.data,error:e.error,form:e.form,params:e.params,route:e.route,state:e.state,status:e.status,url:e.url}}function Kt(e){let t=new URL(e);return t.hash=decodeURIComponent(e.hash),t}function qt(e){let t;if(R.hash){let[,,n]=e.hash.split(`#`,3);t=n??``}else t=e.hash.slice(1);return decodeURIComponent(t)}export{Me as a,k as i,ft as n,_e as o,A as r,Lt as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../nodes/0.156ZLyOF.js","../chunks/BC72R-M3.js","../chunks/czZbKOPp.js","../chunks/CRzLMJPS.js","../chunks/xihTtKlq.js","../chunks/3kOo0zFs.js","../chunks/7G70dile.js","../chunks/BDArRuPR.js","../chunks/DhNgPNiM.js","../assets/0.CbWSsYpm.css","../nodes/1.e1XDhJNT.js","../nodes/2.80TQrqQF.js","../chunks/BIIfi70-.js","../chunks/VWXhPrtT.js","../nodes/3.Bk_l60Ut.js","../chunks/Cu92X5fL.js","../assets/Timeline.UMF1LjSO.css","../assets/3.Bgs8n1LK.css","../nodes/4.CektBUbm.js","../chunks/DZgc09PI.js","../assets/NoteEditor.CM4-yBF-.css","../assets/4.CCFEPTFN.css","../nodes/5.65PWTBsr.js","../assets/5.CUzWicH8.css","../nodes/6.a_57GKer.js","../assets/6.kPo5mcJx.css","../nodes/7.DbM_N4_u.js","../assets/7.ljiu9bn5.css","../nodes/8.CY3JWStn.js","../assets/8.C0NYkyNY.css","../nodes/9.DurALis5.js","../assets/9.CFA9_nYZ.css"])))=>i.map(i=>d[i]);
2
+ import{A as e,C as t,E as n,H as r,I as i,K as a,M as o,O as s,Q as c,R as l,U as u,V as d,Y as f,Z as p,at as m,et as h,i as g,it as _,k as v,lt as y,n as b,q as x,r as S,s as C,v as w}from"../chunks/BC72R-M3.js";import{t as T}from"../chunks/CRzLMJPS.js";import"../chunks/xihTtKlq.js";var E={},D=e(`<div id="svelte-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"><!></div>`),O=e(`<!> <!>`,1);function k(e,S){m(S,!0);let T=g(S,`components`,23,()=>[]),E=g(S,`data_0`,3,null),k=g(S,`data_1`,3,null);u(()=>S.stores.page.set(S.page)),r(()=>{S.stores,S.page,S.constructors,T(),S.form,E(),k(),S.stores.page.notify()});let A=c(!1),j=c(!1),M=c(null);b(()=>{let e=S.stores.page.subscribe(()=>{i(A)&&(p(j,!0),l().then(()=>{p(M,document.title||`untitled page`,!0)}))});return p(A,!0),e});let N=h(()=>S.constructors[1]);var P=O(),F=x(P),I=e=>{let t=h(()=>S.constructors[0]);var n=v(),r=x(n);w(r,()=>i(t),(e,t)=>{C(t(e,{get data(){return E()},get form(){return S.form},get params(){return S.page.params},children:(e,t)=>{var n=v(),r=x(n);w(r,()=>i(N),(e,t)=>{C(t(e,{get data(){return k()},get form(){return S.form},get params(){return S.page.params}}),e=>T()[1]=e,()=>T()?.[1])}),s(e,n)},$$slots:{default:!0}}),e=>T()[0]=e,()=>T()?.[0])}),s(e,n)},L=e=>{let t=h(()=>S.constructors[0]);var n=v(),r=x(n);w(r,()=>i(t),(e,t)=>{C(t(e,{get data(){return E()},get form(){return S.form},get params(){return S.page.params}}),e=>T()[0]=e,()=>T()?.[0])}),s(e,n)};t(F,e=>{S.constructors[1]?e(I):e(L,-1)});var R=f(F,2),z=e=>{var r=D(),c=a(r),l=e=>{var t=o();d(()=>n(t,i(M))),s(e,t)};t(c,e=>{i(j)&&e(l)}),y(r),s(e,r)};t(R,e=>{i(A)&&e(z)}),s(e,P),_()}var A=S(k),j=[()=>T(()=>import(`../nodes/0.156ZLyOF.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url),()=>T(()=>import(`../nodes/1.e1XDhJNT.js`),__vite__mapDeps([10,1,4,7,2]),import.meta.url),()=>T(()=>import(`../nodes/2.80TQrqQF.js`),__vite__mapDeps([11,1,2,4,12,13]),import.meta.url),()=>T(()=>import(`../nodes/3.Bk_l60Ut.js`),__vite__mapDeps([14,1,2,4,5,6,15,16,7,13,17]),import.meta.url),()=>T(()=>import(`../nodes/4.CektBUbm.js`),__vite__mapDeps([18,1,2,4,5,6,7,12,13,19,20,21]),import.meta.url),()=>T(()=>import(`../nodes/5.65PWTBsr.js`),__vite__mapDeps([22,1,2,4,5,6,15,16,7,12,13,19,20,23]),import.meta.url),()=>T(()=>import(`../nodes/6.a_57GKer.js`),__vite__mapDeps([24,1,2,4,5,13,25]),import.meta.url),()=>T(()=>import(`../nodes/7.DbM_N4_u.js`),__vite__mapDeps([26,1,4,8,12,27]),import.meta.url),()=>T(()=>import(`../nodes/8.CY3JWStn.js`),__vite__mapDeps([28,1,2,4,5,7,13,29]),import.meta.url),()=>T(()=>import(`../nodes/9.DurALis5.js`),__vite__mapDeps([30,1,4,31]),import.meta.url)],M=[],N={"/":[2],"/atlas":[3],"/draft/[id]":[4],"/notes":[6],"/n/[...id]":[5],"/parts":[7],"/study":[8],"/terminal":[9]},P={handleError:(({error:e})=>{console.error(e)}),reroute:(()=>{}),transport:{}},F=Object.fromEntries(Object.entries(P.transport).map(([e,t])=>[e,t.decode])),I=Object.fromEntries(Object.entries(P.transport).map(([e,t])=>[e,t.encode])),L=!0,R=(e,t)=>F[e](t),z=()=>T(()=>import(`../chunks/Bjy-W4x2.js`).then(e=>e.default),[],import.meta.url);export{R as decode,F as decoders,N as dictionary,I as encoders,z as get_error_template,L as hash,P as hooks,E as matchers,j as nodes,A as root,M as server_loads};
@@ -0,0 +1 @@
1
+ export{a as load_css,n as start}from"../chunks/czZbKOPp.js";
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/DxgbXXT0.js","../chunks/BC72R-M3.js","../chunks/czZbKOPp.js","../chunks/xihTtKlq.js","../chunks/3kOo0zFs.js","../chunks/7G70dile.js","../chunks/VWXhPrtT.js","../assets/Tutorial.BBInFlVA.css"])))=>i.map(i=>d[i]);
2
+ import{A as e,B as t,C as n,E as r,F as i,G as a,H as o,I as s,J as c,K as l,N as u,O as d,P as f,Q as p,S as m,V as h,W as g,Y as _,Z as v,_ as y,at as b,c as x,ct as S,et as C,ft as w,g as T,h as E,it as D,k as O,l as k,lt as A,m as j,q as M,s as N,u as P,ut as F,v as I,w as ee,x as L,y as R}from"../chunks/BC72R-M3.js";import{o as z}from"../chunks/czZbKOPp.js";import{t as B}from"../chunks/CRzLMJPS.js";import"../chunks/xihTtKlq.js";import{t as V}from"../chunks/3kOo0zFs.js";import{t as H}from"../chunks/7G70dile.js";import{t as U}from"../chunks/BDArRuPR.js";import{n as W,r as G,t as K}from"../chunks/DhNgPNiM.js";var q=w({load:()=>J});async function J(){return await V.load(),{}}var Y=e(`<div class="part svelte-14btb5m"><span> </span><span class="faint detail svelte-14btb5m"> </span><span class="n svelte-14btb5m"> </span> <i class="svelte-14btb5m"></i></div>`),X=e(`<button class="away svelte-14btb5m" type="button" aria-label="Close the breakdown"></button> <div class="frame breakdown svelte-14btb5m" role="dialog" aria-label="Context"><span class="frame-title"> </span> <!> <div class="foot svelte-14btb5m"><span class="label"> </span> <button class="link svelte-14btb5m" type="button">[ clear the conversation ]</button></div> <p class="label">Sizes are estimates until Iso is asked. A long note or a long conversation is cut to fit, and Iso is told what was left out.</p></div>`,1),Z=e(`<span class="count svelte-14btb5m"><button class="tokens svelte-14btb5m" type="button" aria-haspopup="dialog"> </button> <span class="faint" aria-hidden="true">·</span> <span class="faint"> </span> <!></span>`);function te(e,t){b(t,!0);let u=p(null),m=p(!1),g,y=e=>e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1)}k`:String(e),x=e=>`$${e.toFixed(e>0&&e<.1?3:2)}`;function C(e=!1){clearTimeout(g),g=setTimeout(()=>{V.api.context(V.open||void 0).then(e=>v(u,e),()=>void 0)},e?0:600)}o(()=>{V.open,C(!0)}),o(()=>V.on(e=>{(e.type===`note-changed`||e.type===`journal`||e.type===`record`)&&C()})),o(()=>()=>clearTimeout(g));async function w(){await V.api.clearConversation(),C(!0)}var T=O();i(`keydown`,a,e=>{s(m)&&e.key===`Escape`&&v(m,!1)});var E=M(T),k=e=>{var t=Z(),i=l(t),a=c(i,!0),o=_(i,4),p=c(o,!0),g=_(o,2),b=e=>{var t=X(),n=M(t),i=_(n,2),a=l(i),o=c(a),p=_(a,2);L(p,17,()=>s(u).parts,e=>e.name,(e,t)=>{var n=Y(),i=l(n),a=c(i,!0),o=_(i),f=c(o,!0),p=_(o),m=c(p,!0),g=_(p,2);let v;A(n),h((e,n)=>{r(a,s(t).name),r(f,s(t).detail),r(m,e),v=j(g,``,v,{"--w":n})},[()=>y(s(t).tokens),()=>`${s(u).tokens?Math.round(100*s(t).tokens/s(u).tokens):0}%`]),d(e,n)});var g=_(p,2),b=l(g),C=c(b),T=_(b,2);A(g),S(2),A(i),h((e,t,n)=>{r(o,`context · ${e??``} of ${t??``} tokens`),r(C,`this session · ${n??``} · ${s(u).session.requests??``} ${s(u).session.requests===1?`request`:`requests`}`)},[()=>y(s(u).tokens),()=>y(s(u).limit),()=>x(s(u).session.usd)]),f(`click`,n,()=>v(m,!1)),f(`click`,T,w),d(e,t)};n(g,e=>{s(m)&&e(b)}),A(t),h((e,t,n,c)=>{P(i,`aria-expanded`,s(m)),P(i,`aria-label`,e),r(a,t),P(o,`aria-label`,n),r(p,c)},[()=>`Context: ${y(s(u).tokens)} tokens`,()=>y(s(u).tokens),()=>`This session has cost ${x(s(u).session.usd)}`,()=>x(s(u).session.usd)]),f(`click`,i,()=>v(m,!s(m))),d(e,t)};n(E,e=>{s(u)&&V.session?.study&&e(k)}),d(e,T),D()}u([`click`]);var Q=e(`<button type="button" role="radio"> </button>`),ne=e(`<button class="btn" type="button">forget it</button>`),$=e(`<div class="row svelte-15gydnd"><span class="faint">or</span> <button class="btn" type="button"> </button></div> <p class="faint">You sign in there, and the key it makes comes straight here. A spending limit for it is set on the provider's page of keys.</p>`,1),re=e(`<p role="status"> </p>`),ie=e(`<dt> </dt><dd class="faint svelte-15gydnd"> </dd>`,1),ae=e(`<p class="soft"> </p> <form class="row svelte-15gydnd"><label class="hidden-label" for="key">Provider key</label> <input id="key" class="field grow" type="password" autocomplete="off" spellcheck="false"/> <button class="btn primary" type="submit">hold it</button> <!></form> <!> <!> <p class="faint">The key is kept in this device's configuration, never in a base, and is not shown again.</p> <dl class="tiers svelte-15gydnd"></dl>`,1),oe=e(`<p class="bad svelte-15gydnd" role="alert"> </p>`),se=e(`<button class="shade svelte-15gydnd" type="button" aria-label="Close settings"></button> <div class="frame menu svelte-15gydnd" role="dialog" aria-label="Settings" tabindex="-1"><span class="frame-title">settings</span> <section class="svelte-15gydnd"><h2 class="label svelte-15gydnd">the ground</h2> <div class="row svelte-15gydnd" role="radiogroup" aria-label="Ground"></div></section> <section class="svelte-15gydnd"><h2 class="label svelte-15gydnd">Iso</h2> <!> <!></section> <div class="row foot svelte-15gydnd"><a>the parts</a> <span class="grow"></span> <button class="btn quiet" type="button">close</button></div></div>`,1);function ce(e,t){b(t,!0);let u=p(null),m=p(``),g=p(``),y;o(()=>{V.api.settings().then(e=>v(u,e),e=>v(g,e.message,!0))}),o(()=>{y.focus()});function w(){V.signIn=null,t.close()}async function O(e){v(g,``),V.signIn=null;try{v(u,await V.api.setKey(e)),v(m,``)}catch(e){v(g,e.message,!0)}}async function j(){v(g,``),V.signIn=null;try{await V.startSignIn()}catch(e){v(g,e.message,!0)}}var I=se();i(`keydown`,a,e=>{e.key===`Escape`&&w()});var ee=M(I),R=_(ee,2),B=_(l(R),2),H=_(l(B),2);L(H,21,()=>K,([e,t])=>e,(e,t)=>{var n=C(()=>F(s(t),2));let i=()=>s(n)[0],a=()=>s(n)[1];var o=Q();let l;var u=c(o,!0);h(()=>{l=E(o,1,`btn svelte-15gydnd`,null,l,{on:W.chosen===i()}),P(o,`aria-checked`,W.chosen===i()),r(u,a())}),f(`click`,o,()=>W.choose(i())),d(e,o)}),A(H),A(B);var U=_(B,2),G=_(l(U),2),q=e=>{var t=ae(),a=M(t),o=c(a),p=_(a,2),g=_(l(p),2);k(g);var y=_(g,2),b=_(y,2),C=e=>{var t=ne();f(`click`,t,()=>O(null)),d(e,t)};n(b,e=>{s(u).key&&e(C)}),A(p);var w=_(p,2),D=e=>{var t=$(),n=M(t),i=_(l(n),2),a=c(i);A(n),S(2),h(()=>r(a,`sign in at ${s(u).provider??``} for a new key`)),f(`click`,i,j),d(e,t)};n(w,e=>{s(u).connect&&e(D)});var N=_(w,2),F=e=>{var t=re(),n=c(t,!0);h(()=>{E(t,1,T(V.signIn.ok?`soft`:`bad`),`svelte-15gydnd`),r(n,V.signIn.message)}),d(e,t)};n(N,e=>{V.signIn&&e(F)});var I=_(N,4);L(I,20,()=>[`low`,`mid`,`max`],e=>e,(e,t)=>{var n=ie(),i=M(n),a=c(i,!0),o=_(i),l=c(o,!0);h(()=>{r(a,t),r(l,s(u).tiers[t])}),d(e,n)}),A(I),h(e=>{r(o,`Asked through ${s(u).provider??``}. ${s(u).key?`A key is held on this device.`:`No key is held yet, so Iso cannot be asked.`}`),P(g,`placeholder`,s(u).key?`paste another key to replace it`:`paste a key`),y.disabled=e},[()=>!s(m).trim()]),i(`submit`,p,e=>{e.preventDefault(),s(m).trim()&&O(s(m))}),x(g,()=>s(m),e=>v(m,e)),d(e,t)};n(G,e=>{s(u)&&e(q)});var J=_(G,2),Y=e=>{var t=oe(),n=c(t,!0);h(()=>r(n,s(g))),d(e,t)};n(J,e=>{s(g)&&e(Y)}),A(U);var X=_(U,2),Z=l(X),te=_(Z,4);A(X),A(R),N(R,e=>y=e,()=>y),h(e=>P(Z,`href`,e),[()=>z(`/parts`)]),f(`click`,ee,w),f(`click`,Z,w),f(`click`,te,w),d(e,I),D()}u([`click`]);var le=e(`<a class="back svelte-12qhfyh">‹ study</a>`),ue=e(`<a class="back svelte-12qhfyh"> </a>`),de=e(`<span class="faint sep svelte-12qhfyh">/</span> `,1),fe=e(`<a class="svelte-12qhfyh"> </a><!>`,1),pe=e(`<span class="where soft svelte-12qhfyh"> </span><button class="btn out svelte-12qhfyh" type="button">↑ out</button>`,1),me=e(`<button class="btn stop svelte-12qhfyh" type="button">stop</button>`),he=e(`<i></i>`),ge=e(`<button type="button"></button>`),_e=e(`<a class="next svelte-12qhfyh">next</a>`),ve=e(`<span class="label kind svelte-12qhfyh"> </span><span class="faint dot svelte-12qhfyh">·</span><span class="label read svelte-12qhfyh">Iso's read of you</span> <!> <button class="link wind svelte-12qhfyh" type="button">[ wind back ]</button> <!>`,1),ye=e(`<a class="svelte-12qhfyh"><span class="svelte-12qhfyh"> </span></a>`),be=e(`<p class="stopped svelte-12qhfyh"> </p>`),xe=e(`<span role="status"> </span>`),Se=e(`<span class="grow svelte-12qhfyh"></span><span class="hint svelte-12qhfyh"> </span>`,1),Ce=e(`<span class="hint svelte-12qhfyh"> </span>`),we=e(`<span class="hint svelte-12qhfyh"> </span> <button class="link svelte-12qhfyh" type="button">[ stop ]</button>`,1),Te=e(`<span> </span>`),Ee=e(`<span class="grow svelte-12qhfyh"></span> <!>`,1),De=e(`<span class="grow svelte-12qhfyh"></span> <span class="hint svelte-12qhfyh">click a note to link it, again to take it away</span>`,1),Oe=e(`<span class="svelte-12qhfyh"> </span>`),ke=e(`<!> <span class="grow svelte-12qhfyh"></span> <span class="hint svelte-12qhfyh">click a note it requires to step back to it, the note again to open it</span> <button class="link svelte-12qhfyh" type="button"> </button>`,1),Ae=e(`<span class="svelte-12qhfyh"> </span> <!> <span class="grow svelte-12qhfyh"></span> <span class="hint svelte-12qhfyh">click a note to see what it rests on · hold on open ground to start a note for Iso, on a note to start from it</span>`,1),je=e(`<span class="grow svelte-12qhfyh"></span> <span class="svelte-12qhfyh"> </span>`,1),Me=e(`<span class="svelte-12qhfyh"> </span> <!> <!> <!>`,1),Ne=e(`<div class="shell svelte-12qhfyh"><header class="bar svelte-12qhfyh"><button type="button" aria-label="isorite: settings" aria-haspopup="dialog"><!></button> <!> <span><!></span> <span class="grow svelte-12qhfyh"></span> <!> <!> <!> <!> <nav class="switch svelte-12qhfyh" aria-label="Views"></nav></header> <!> <main class="page svelte-12qhfyh"><!></main> <!> <footer class="status svelte-12qhfyh"><!></footer></div>`);function Pe(e,i){b(i,!0);let a=C(()=>V.session?.tutorial?B(()=>import(`../chunks/DxgbXXT0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url):null),o=p(V.signIn!==null),u=[[`atlas`,z(`/atlas`)],[`notes`,z(`/notes`)],[`study`,z(`/study`)]],x=C(()=>U.route.id===`/atlas`?`atlas`:U.route.id===`/study`||V.exercise||V.studying?`study`:U.route.id===`/parts`?``:`notes`),w=C(()=>U.route.id===`/n/[...id]`||U.route.id===`/draft/[id]`),T=C(()=>V.atlas&&!V.atlas.pick?V.iso:null),k=C(()=>s(T)?.state===`reading`||s(T)?.state===`writing`),j=C(()=>s(T)?V.listing.notes.find(e=>e.id===s(T).note)?.title??`your note`:``),N=()=>{s(T)&&V.api.stop(s(T).request)},W=C(()=>H(s(T)?.agent)),K=C(()=>{let e=s(T)?.steps.findLast(e=>e.opened&&!e.failed)?.opened;return e?V.listing.notes.find(t=>t.id===e)?.title??e:``});var q=Ne();y(`12qhfyh`,e=>{t(()=>{g.title=s(w)&&V.here?`${V.here} · isorite`:`isorite`})});var J=l(q),Y=l(J);let X;var Z=l(Y);G(Z,{}),A(Y);var Q=_(Y,2),ne=e=>{var t=O(),i=M(t),a=e=>{var t=le();h(e=>P(t,`href`,e),[()=>z(`/study`)]),d(e,t)},o=e=>{var t=ue(),n=c(t);h(e=>{P(t,`href`,e),r(n,`‹ ${V.session.name??``}`)},[()=>z(`/notes`)]),d(e,t)};n(i,e=>{V.exercise||V.studying?e(a):e(o,-1)}),d(e,t)};n(Q,e=>{s(w)&&V.session&&e(ne)});var $=_(Q,2);let re;var ie=l($),ae=e=>{var t=fe(),i=M(t),a=c(i,!0),o=_(i),l=e=>{var t=de(),n=_(M(t),1,!0);h(()=>r(n,V.here)),d(e,t)};n(o,e=>{s(w)&&V.here&&e(l)}),h(e=>{P(i,`href`,e),r(a,V.session.name)},[()=>z(`/notes`)]),d(e,t)};n(ie,e=>{V.session&&e(ae)}),A($);var oe=_($,4),se=e=>{var t=pe(),n=M(t),i=c(n,!0),a=_(n);h(()=>r(i,V.atlas.here)),f(`click`,a,function(...e){V.atlas.out?.apply(this,e)}),d(e,t)};n(oe,e=>{V.atlas?.here&&e(se)});var Pe=_(oe,2),Fe=e=>{var t=me();f(`click`,t,N),d(e,t)};n(Pe,e=>{s(k)&&!s(T)?.agent&&e(Fe)});var Ie=_(Pe,2),Le=e=>{let t=C(()=>V.exercise);var i=ve(),a=M(i),o=c(a,!0),l=_(a,4);m(l,()=>s(t).flash,e=>{var n=ge();let r;L(n,20,()=>[0,1,2,3,4,5],e=>e,(e,n)=>{var r=he();let i;h(()=>i=E(r,1,`pip svelte-12qhfyh`,null,i,{lv:n<s(t).squares})),d(e,r)}),A(n),h(()=>{r=E(n,1,`squares svelte-12qhfyh`,null,r,{flash:s(t).flash>0}),P(n,`aria-label`,`understanding ${s(t).squares??``} of 6${s(t).due?`, due`:``}: why`)}),f(`click`,n,function(...e){s(t).why?.apply(this,e)}),d(e,n)});var u=_(l,2),p=_(u,2),g=e=>{var n=_e();h(e=>P(n,`href`,e),[()=>z(`/n/[...id]`,{id:s(t).next})]),d(e,n)};n(p,e=>{s(t).next&&e(g)}),h(()=>r(o,s(t).kind)),f(`click`,u,function(...e){s(t).windBack?.apply(this,e)}),d(e,i)};n(Ie,e=>{V.exercise&&e(Le)});var Re=_(Ie,2),ze=e=>{te(e,{})};n(Re,e=>{V.error||e(ze)});var Be=_(Re,2);L(Be,21,()=>u,([e,t])=>e,(e,t)=>{var n=C(()=>F(s(t),2));let i=()=>s(n)[0],a=()=>s(n)[1];var o=ye(),u=l(o),f=c(u,!0);A(o),h(()=>{P(o,`href`,a()),P(o,`aria-current`,s(x)===i()?`page`:void 0),r(f,i())}),d(e,o)}),A(Be),A(J);var Ve=_(J,2),He=e=>{ce(e,{close:()=>v(o,!1)})};n(Ve,e=>{s(o)&&e(He)});var Ue=_(Ve,2),We=l(Ue),Ge=e=>{var t=be(),n=c(t);h(()=>r(n,`isorite could not open the base: ${V.error??``}`)),d(e,t)},Ke=e=>{var t=O(),n=M(t);R(n,()=>i.children),d(e,t)};n(We,e=>{V.error?e(Ge):e(Ke,-1)}),A(Ue);var qe=_(Ue,2),Je=e=>{var t=O(),n=M(t);ee(n,()=>s(a),null,(e,t)=>{var n=O(),r=M(n);I(r,()=>s(t).default,(e,t)=>{t(e,{})}),d(e,n)}),d(e,t)};n(qe,e=>{s(a)&&U.route.id!==`/terminal`&&e(Je)});var Ye=_(qe,2),Xe=l(Ye),Ze=e=>{var t=Me(),i=M(t),a=c(i,!0),o=_(i,2),l=e=>{var t=xe();let n;var i=c(t,!0);h(()=>{n=E(t,1,`svelte-12qhfyh`,null,n,{bad:V.saving.bad}),r(i,V.saving.text)}),d(e,t)};n(o,e=>{s(w)&&V.saving&&e(l)});var u=_(o,2),p=e=>{var t=Se(),n=_(M(t)),i=c(n,!0);h(()=>r(i,V.hint)),d(e,t)};n(u,e=>{s(w)&&V.hint&&!s(T)&&e(p)});var m=_(u,2),g=e=>{var t=Ee(),i=_(M(t),2),a=e=>{var t=Ce(),n=c(t,!0);h(()=>r(n,s(k)?`${s(W)} is ${s(K)?`reading ${s(K)}`:`at work`} in the terminal`:`${s(W)}'s turn is done · click open ground to let its path go`)),d(e,t)},o=e=>{var t=we(),n=M(t),i=c(n,!0),a=_(n,2);h(e=>r(i,e),[()=>s(T).note.startsWith(`@draft/`)?`your note opens when Iso is done`:`Iso is answering in ${s(j)}`]),f(`click`,a,N),d(e,t)},l=e=>{var t=Te();let n;var i=c(t);h(()=>{n=E(t,1,`hint svelte-12qhfyh`,null,n,{bad:s(T).state===`failed`}),r(i,`${s(T).state===`done`?`Iso is done in ${s(j)}`:s(T).state===`stopped`?`Iso was stopped`:`Iso could not answer: ${s(T).message}`} · click open ground to let its path go`)}),d(e,t)};n(i,e=>{s(T).agent?e(a):s(k)?e(o,1):e(l,-1)}),d(e,t)},v=e=>{var t=De();S(2),d(e,t)},y=e=>{var t=ke(),i=M(t),a=e=>{var t=Oe(),n=c(t);h(()=>r(n,`${V.atlas.steps??``} ${V.atlas.steps===1?`step`:`steps`} back`)),d(e,t)};n(i,e=>{V.atlas.steps&&e(a)});var o=_(i,6),s=c(o,!0);h(()=>{P(o,`aria-pressed`,V.atlas.chain),r(s,V.atlas.chain?`[ one step ]`:`[ whole chain ]`)}),f(`click`,o,function(...e){V.atlas.whole?.apply(this,e)}),d(e,t)},b=e=>{var t=Ae(),i=M(t),a=c(i),o=_(i,2),s=e=>{var t=Oe(),n=c(t);h(()=>r(n,`${V.atlas.items??``} study ${V.atlas.items===1?`item`:`items`}`)),d(e,t)};n(o,e=>{V.atlas.items&&e(s)}),S(4),h(()=>r(a,`${V.listing.notes.length??``} ${V.listing.notes.length===1?`note`:`notes`}`)),d(e,t)},x=e=>{var t=je(),n=_(M(t),2),i=c(n);h(()=>r(i,`${V.listing.notes.length??``} ${V.listing.notes.length===1?`note`:`notes`}`)),d(e,t)};n(m,e=>{s(T)&&(s(k)||!V.atlas?.chosen)?e(g):V.atlas?.pick?e(v,1):V.atlas?.chosen?e(y,2):V.atlas?e(b,3):e(x,-1)}),h(()=>r(a,V.session.study?`study`:`project: no journal is kept`)),d(e,t)};n(Xe,e=>{V.session&&e(Ze)}),A(Ye),A(q),h(()=>{X=E(Y,1,`home svelte-12qhfyh`,null,X,{"in-note":s(w)}),P(Y,`aria-expanded`,s(o)),re=E($,1,`path svelte-12qhfyh`,null,re,{"in-note":s(w)})}),f(`click`,Y,()=>v(o,!s(o))),d(e,q),D()}u([`click`]);export{Pe as component,q as universal};
@@ -0,0 +1 @@
1
+ import{A as e,E as t,J as n,O as r,V as i,Y as a,at as o,it as s,q as c}from"../chunks/BC72R-M3.js";import"../chunks/xihTtKlq.js";import{t as l}from"../chunks/BDArRuPR.js";var u=e(`<h1> </h1> <p> </p>`,1);function d(e,d){o(d,!0);var f=u(),p=c(f),m=n(p,!0),h=a(p,2),g=n(h,!0);i(()=>{t(m,l.status),t(g,l.error?.message)}),r(e,f),s()}export{d as component};
@@ -0,0 +1 @@
1
+ import{at as e,it as t,n,o as r}from"../chunks/BC72R-M3.js";import{o as i,t as a}from"../chunks/czZbKOPp.js";import"../chunks/xihTtKlq.js";import"../chunks/BIIfi70-.js";import"../chunks/VWXhPrtT.js";function o(o,s){e(s,!1),n(()=>{a(i(`/notes`),{replaceState:!0})}),r(),t()}export{o as component};
@@ -0,0 +1,13 @@
1
+ import{A as e,C as t,E as n,F as r,H as i,I as a,J as o,K as s,M as c,N as l,O as u,P as d,Q as f,V as p,X as m,Y as h,Z as g,at as _,et as v,g as y,h as b,i as x,it as S,j as C,k as w,lt as T,m as E,q as D,s as O,u as k,x as A}from"../chunks/BC72R-M3.js";import{o as j,t as M}from"../chunks/czZbKOPp.js";import"../chunks/xihTtKlq.js";import{n as N,t as P}from"../chunks/3kOo0zFs.js";import{_ as F,a as I,b as L,o as R}from"../chunks/7G70dile.js";import{i as z,t as B}from"../chunks/Cu92X5fL.js";import{t as V}from"../chunks/BDArRuPR.js";import"../chunks/VWXhPrtT.js";var H=[0,1,1,1,0,-1,-1,-1],U=[-1,-1,0,1,1,1,0,-1];function ee(e,t,{step:n=1,pad:r=.5}={}){let i=`X`,a=(Math.abs(Math.trunc(e))*7919+13)%2147483647,o=()=>(a=a*16807%2147483647,a/2147483647);for(let e=0;e<Math.max(0,Math.min(t,6));e++)i=i.replace(/[XF]/g,e=>e===`X`?`F[+X]F[-X]+X`:`FF`);i===`X`&&(i=`F`);let s=0,c=0,l=0,u=1,d=!1,f=0,p=0,m=0,h=0,g=[],_=[],v=[],y=n/2;for(let e of i)e===`F`?(d||=(_.push(`M${s} ${c}`),!0),s+=H[l]*n,c+=U[l]*n,_.push(`L${s} ${c}`),f=Math.min(f,s),p=Math.max(p,s),m=Math.min(m,c),h=Math.max(h,c)):e===`+`?l=(l+u+8)%8:e===`-`?l=(l-u+8)%8:e===`[`?(g.push([s,c,l,u]),o()<.5&&(u=-u)):e===`]`&&(v.push(`M${s-y/2} ${c-y/2}h${y}v${y}h${-y}z`),[s,c,l,u]=g.pop(),d=!1);let b=p-f+2*r,x=h-m+2*r;return{d:_.join(``),tips:v.join(``),viewBox:`${f-r} ${m-r} ${b} ${x}`,ratio:b/x}}var W=/\]\(\/([^)\s#]+)\.md(?:#[^)\s]*)?(?:\s+"[^"]*")?\)/g,G=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),K=e=>e.split(`/`).map(encodeURIComponent).join(`/`);function te(e){let t=[];for(let n of e.matchAll(W)){let e=decodeURIComponent(n[1]);t.includes(e)||t.push(e)}return t}function q(e,t,n){let r=e.replace(/\s+$/,``),i=RegExp(`^\\[[^\\]\\n]*\\]\\(/[^)\\n]*\\.md\\)$`);return`${r}${!r||r.endsWith(`---`)?`
2
+
3
+ `:i.test(r.split(`
4
+ `).at(-1))?`
5
+ `:`
6
+
7
+ `}[${n.replace(/[[\]]/g,``)}](/${K(t)}.md)\n`}function ne(e,t){let n=`\\[[^\\]\\n]*\\]\\(/${G(K(t))}\\.md\\)`,r=e.split(`
8
+ `),i=r.filter(e=>!RegExp(`^${n}$`).test(e.trim()));return i.length===r.length||te(i.join(`
9
+ `)).includes(t)?null:i.join(`
10
+ `).replace(/\n{3,}/g,`
11
+
12
+ `).replace(/\s+$/,``)+`
13
+ `}function re(e){try{let[t]=L(e);return t?.type===`Exercise`?R(t):null}catch{return null}}function ie(e,t){let n=re(e)??[];return F(e,{tests:n.includes(t)?n.filter(e=>e!==t):[...n,t]},null)}function ae(e){return(/^title:[ \t]*(.*)$/m.exec(e.split(/^---\s*$/m)[1]??``)?.[1]??``).trim().replace(/^(["'])(.*)\1$/,`$2`)}var oe=e=>e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.round(e/1e3)}k`,se=`isorite.atlas.drafts`,ce=()=>{try{return JSON.parse(localStorage.getItem(se)??`{}`)}catch{return{}}},le=e=>ce()[e]??null;function ue(e,t){try{let n=ce();t?n[e]=t:delete n[e],localStorage.setItem(se,JSON.stringify(n))}catch{}}var de=e(`<li class="svelte-1a0w8ls"><b class="num svelte-1a0w8ls"> </b><span class="t svelte-1a0w8ls"> </span><span class="faint"> </span></li>`),fe=e(`<span class="label over svelte-1a0w8ls"> </span>`),pe=e(`<div class="dock svelte-1a0w8ls" role="region"><i class="dia open" aria-hidden="true"></i> <div class="what svelte-1a0w8ls"><span class="name svelte-1a0w8ls"> </span> <span class="label" role="status"> </span></div> <ol class="grow svelte-1a0w8ls"></ol> <!> <a class="btn primary tall svelte-1a0w8ls">back to it</a></div>`);function me(e,r){_(r,!0);let i=x(r,`notice`,3,``),c=x(r,`tests`,3,!1),l=v(()=>r.picked.reduce((e,t)=>e+t.tokens,0)),d=v(()=>!c()&&a(l)>r.budget),f=v(()=>[c()?`${r.picked.length} to test`:`${r.picked.length} linked`,r.picked.length?`${oe(a(l))} tokens`:``,a(d)?`over ${oe(r.budget)}`:``,i()].filter(Boolean).join(` · `));var m=pe(),g=h(s(m),2),y=s(g),b=o(y,!0),C=h(y,2),w=o(C,!0);T(g);var E=h(g,2);A(E,23,()=>r.picked,e=>e.id,(e,t,r)=>{var i=de(),c=s(i),l=o(c,!0),d=h(c),f=o(d,!0),m=h(d),g=o(m,!0);T(i),p(e=>{n(l,a(r)+1),n(f,a(t).title),n(g,e)},[()=>oe(a(t).tokens)]),u(e,i)}),T(E);var D=h(E,2),O=e=>{var t=fe(),i=o(t);p(e=>n(i,`over ${e??``}: the last are cut short, or left for Iso to read itself`),[()=>oe(r.budget)]),u(e,t)};t(D,e=>{a(d)&&e(O)});var j=h(D,2);T(m),p(()=>{k(m,`aria-label`,c()?`Notes the exercise tests`:`Notes linked to the note for Iso`),n(b,r.title||`a new note`),n(w,a(f)),k(j,`href`,r.href)}),u(e,m),S()}var he=.55,ge=.04;function _e(e){let t=e.items.map(t=>{let n=[];for(let r=t.parent;r>=0;r=e.items[r].parent)n.push(r);return n}),n=e.items.map(()=>0);e.items.forEach((e,r)=>{if(e.kind===`note`)for(let e of t[r])n[e]++});let r=(t,n)=>{for(;e.items[t].parent!==n;)t=e.items[t].parent;return t},i=new Map(e.trunks.map((e,t)=>[`${e.a}|${e.b}`,t])),a=e.links.some(t=>t.s>=3&&!e.items[t.a].ref.startsWith(`@study`))?3:2,o=e.trunks.map(()=>!1);for(let t of e.links){let e=t.s>=a?i.get(`${r(t.a,t.level)}|${r(t.b,t.level)}`):void 0;e!==void 0&&(o[e]=!0)}return{up:t,noteCount:n,strong:o,at:new Map(e.items.flatMap((e,t)=>e.kind===`note`?[[e.ref,t]]:[])),trunkAt:i,feederAt:new Map(e.feeders.map((e,t)=>[`${e.trunk}|${e.folder}|${e.item}`,t])),ownPath:new Map(e.trunks.flatMap(e=>e.pts?[[`${e.a}|${e.b}`,e.pts]]:[]))}}var J=new WeakMap;function ve(e){let t=J.get(e);return t||J.set(e,t={...e,trunks:e.highways.trunks,feeders:e.highways.feeders}),t}function ye(e,t){let n=[];return e.items.forEach((r,i)=>{let a=r.parent<0||n[r.parent]===`o`;n[i]=a?r.kind===`folder`&&e.cell*t>=1.2&&Math.max(r.w,r.h)*e.cell*t>=53?`o`:`s`:`-`}),n.join(``)}function be(e,t,n){let r=e.up[n];for(let e=r.length-1;e>=0;e--)if(t[r[e]]!==`o`)return r[e];return n}function xe(e,t,n=[],r=!1){let i=e=>t[e]!==`-`,a=t=>e.items[t].ref.startsWith(`@study`),o=[];return e.trunks.forEach((t,r)=>{let s=e.items[t.a].kind===`folder`&&e.items[t.b].kind===`folder`;t.pts&&!t.implied&&i(t.a)&&i(t.b)&&o.push({key:`t`+r,pts:t.pts,lane:0,count:t.count,feed:!s,study:a(t.a)||a(t.b),strong:n[r]??!0})}),e.feeders.forEach((s,c)=>{let l=e.trunks[s.trunk];(r||!s.leaf)&&!l.implied&&t[s.folder]===`o`&&i(s.item)&&i(l.a)&&i(l.b)&&o.push({key:`f`+c,pts:s.pts,lane:s.lane,count:s.count,feed:!0,study:a(l.a)||a(l.b),strong:n[s.trunk]??!0})}),o}var Y=(e,t)=>Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6;function Se(e,t,n,r){let i=new Set(t.up[r]),a=t.up[n].find(e=>i.has(e))??-1,o=e=>{let n=[e];for(let r of t.up[e]){if(r===a)break;n.push(r)}return n},s=o(n),c=o(r),l=t.trunkAt.get(`${s.at(-1)}|${c.at(-1)}`);if(l===void 0||!e.trunks[l].pts||s.length<2&&c.length<2)return null;let u=(t,n=0)=>{let r=e.feeders[t];if(r.via<0||n>40)return r.pts;let i=u(r.via,n+1),a=i.findIndex(e=>Y(e,r.pts.at(-1)));return a<0?r.pts:[...r.pts,...i.slice(a+1)]},d=e=>{let n=[];for(let r=0;r+1<e.length;r++){let i=t.feederAt.get(`${l}|${e[r+1]}|${e[r]}`);if(i===void 0)return null;n=n.concat(u(i))}return n},f=d(c),p=d(s);if(!f||!p)return null;let m=[...f,...e.trunks[l].pts,...p.reverse()];return m.filter((e,t)=>!t||!Y(e,m[t-1]))}var Ce=[`uses`,`builds`,`requires`,`iso`];function we(e,t=!1){let n=e=>`${Math.round(e[0]*100)},${Math.round(e[1]*100)}`,r=new Map,i=new Map;for(let t of e){let e=Ce.indexOf(t.kind??`requires`),a=new Set;for(let o=1;o<t.pts.length;o++){let[s,c]=t.pts[o-1],[l,u]=t.pts[o],d=Math.max(1,Math.round(Math.max(Math.abs(l-s),Math.abs(u-c))*2));for(let o=0;o<d;o++){let f=[s+(l-s)*o/d,c+(u-c)*o/d],p=[s+(l-s)*(o+1)/d,c+(u-c)*(o+1)/d],m=n(f),h=n(p),g=m<h?m+`|`+h:h+`|`+m;if(m===h||a.has(g))continue;a.add(g);let _=r.get(g);if(!_){_=m<h?{a:m,b:h,A:f,B:p,count:0,strong:!1,study:!1,trunk:!1,kind:0,fwd:[0,0,0,0],back:[0,0,0,0]}:{a:h,b:m,A:p,B:f,count:0,strong:!1,study:!1,trunk:!1,kind:0,fwd:[0,0,0,0],back:[0,0,0,0]},r.set(g,_);for(let e of[_.a,_.b]){let t=i.get(e);t?t.push(g):i.set(e,[g])}}_.count+=t.count??1,_.strong||=t.strong??!0,_.study||=t.study??!1,_.trunk||=t.feed===!1,_.kind=Math.max(_.kind,e),(m===_.a?_.fwd:_.back)[e]+=1}}}let a=e=>t?`${e.kind}|${e.count}`:`${e.count}|${e.strong}|${e.study}|${e.trunk}`,o=(e,n)=>{let r=e.fwd[e.kind],i=e.back[e.kind];return!t||r&&i?0:(r?1:-1)*(n===e.a?1:-1)},s=(e,t)=>t===e.a?e.b:e.a,c=(e,t)=>t===e.a?e.A:e.B,l=(e,t,n)=>{let r=s(e,t);return a(e)===a(n)&&o(e,t)===o(n,r)},u=new Set,d=[],f=new Set,p=(e,t)=>{let p=e,m=t,h=r.get(m),g=[c(h,p)],_=o(h,p);for(;;){u.add(m);let e=s(h,p);g.push(c(h,e));let t=i.get(e).filter(e=>e!==m);if(t.length!==1||u.has(t[0])||!l(h,p,r.get(t[0])))break;p=e,m=t[0],h=r.get(m)}_<0&&g.reverse();let v=`${n(g[0])}>${n(g.at(-1))}:${a(h)}`;for(let e=2;f.has(v);e++)v=`${v.split(`#`)[0]}#${e}`;f.add(v),d.push({key:v,pts:g,count:h.count,strong:h.strong,study:h.study,trunk:h.trunk,kind:Ce[h.kind],flow:+!!_})};for(let[e,t]of i)if(t.length!==2||!l(r.get(t[0]),s(r.get(t[0]),e),r.get(t[1])))for(let n of t)u.has(n)||p(e,n);for(let[e,t]of r)u.has(e)||p(t.a,e);return d}function Te(e,t,n,r){let i=[],a=[],o=new Set;for(let{a:s,b:c,kind:l}of r){let r=be(t,n,s),u=be(t,n,c),d=`${l}:${r}|${u}`;if(r===u||o.has(d))continue;o.add(d);let f=r===s&&u===c?t.ownPath.get(`${s}|${c}`)??Se(e,t,s,c):t.ownPath.get(`${r}|${u}`)??null;f?i.push({key:d,kind:l,pts:f}):a.push({key:d,kind:l,a:r,b:u})}return{fixed:i,asks:a}}function Ee(e,t){if(!t)return e;let n=(e,t)=>{let n=t[0]-e[0],r=t[1]-e[1],i=Math.hypot(n,r)||1;return n/=i,r/=i,(n<-1e-6||Math.abs(n)<1e-6&&r<0)&&(n=-n,r=-r),[-r,n]};return e.map((r,i)=>{let a=i>0?n(e[i-1],r):n(r,e[i+1]),o=i<e.length-1?n(r,e[i+1]):a,s=1+a[0]*o[0]+a[1]*o[1];return s<.2?[r[0]+a[0]*t,r[1]+a[1]*t]:[r[0]+(a[0]+o[0])/s*t,r[1]+(a[1]+o[1])/s*t]})}function De(e,t=0,n=7){let r=Ee(e.map(([e,t])=>[e*n,t*n]),t*2.2),i=Math.min(n,10.5)*.9,a=r.filter((e,t)=>t===0||t===r.length-1||Math.abs((e[0]-r[t-1][0])*(r[t+1][1]-e[1])-(e[1]-r[t-1][1])*(r[t+1][0]-e[0]))>.001),o=e=>String(Math.round(e*10)/10),s=`M${o(a[0][0])} ${o(a[0][1])}`;for(let e=1;e<a.length-1;e++){let t=a[e-1],n=a[e],r=a[e+1],c=Math.hypot(n[0]-t[0],n[1]-t[1])||1,l=Math.hypot(r[0]-n[0],r[1]-n[1])||1;if(!(Math.abs((n[0]-t[0])*(r[0]-n[0])+(n[1]-t[1])*(r[1]-n[1]))<.001*c*l)){s+=`L${o(n[0])} ${o(n[1])}`;continue}let u=Math.min(i,c/2,l/2);s+=`L${o(n[0]-(n[0]-t[0])/c*u)} ${o(n[1]-(n[1]-t[1])/c*u)}L${o(n[0]+(r[0]-n[0])/l*u)} ${o(n[1]+(r[1]-n[1])/l*u)}`}let c=a.at(-1);return s+`L${o(c[0])} ${o(c[1])}`}function Oe(e,t,n){let r=n?t[0]-e[0]:t[1]-e[1],i=n?t[1]-e[1]:t[0]-e[0],a=Math.abs(r),o=Math.abs(i),s=Math.sign(r),c=Math.sign(i),l=(t,r)=>n?[e[0]+t,e[1]+r]:[e[0]+r,e[1]+t];if(a>=o){let e=(a-o)/2;return[l(0,0),l(s*e,0),l(s*(e+o),c*o),l(r,i)]}let u=a/2;return[l(0,0),l(s*u,c*u),l(s*u,c*(o-u)),l(r,i)]}function ke(e,t,n,r=3,i=7){let a=Math.max(ge,Math.min(r,.96*Math.min(t/((e.w+4)*i),n/((e.h+4)*i))));return{k:a,x:t/2-a*(e.gx+e.w/2)*i,y:n/2-a*(e.gy+e.h/2)*i}}function Ae(e,t,n,r){let i=Math.max(ge,Math.min(3,e.k*t)),a=i/e.k;return{k:i,x:n-(n-e.x)*a,y:r-(r-e.y)*a}}var je=2;function Me(e){let{W:t,H:n,items:r}=e,i=new Int8Array(t*n),a=new Uint8Array(t*n),o=new Int32Array(t*n).fill(-1),s=new Int32Array(t*n).fill(-1),c=r.map((e,t)=>t).filter(e=>r[e].kind===`folder`).sort((e,t)=>r[e].depth-r[t].depth||e-t);for(let e of c){let n=r[e];for(let r=n.gy;r<n.gy+n.h;r++)for(let a=n.gx;a<n.gx+n.w;a++)i[r*t+a]=n.depth,o[r*t+a]=e}r.forEach((e,n)=>{if(e.kind===`note`)for(let r=e.gy;r<e.gy+e.h;r++)for(let i=e.gx;i<e.gx+e.w;i++)a[r*t+i]=1,s[r*t+i]=n});let l=new Uint8Array(t*n),u=e.keep??je,d=(e,r,i,a)=>{for(let o=Math.max(0,r);o<Math.min(n,a);o++)for(let n=Math.max(0,e);n<Math.min(t,i);n++)l[o*t+n]=1};for(let e of r)e.kind===`note`?d(e.gx-u,e.gy-u,e.gx+e.w+u,e.gy+e.h+u):(d(e.gx-u,e.gy-u,e.gx+e.w+u,e.gy+u),d(e.gx-u,e.gy+e.h-u,e.gx+e.w+u,e.gy+e.h+u),d(e.gx-u,e.gy-u,e.gx+u,e.gy+e.h+u),d(e.gx+e.w-u,e.gy-u,e.gx+e.w+u,e.gy+e.h+u));return{W:t,H:n,elev:i,blocked:a,owner:o,noteAt:s,close:l}}function Ne(e,t){let n=e[t].kind===`folder`?[t]:[];for(let r=e[t].parent;r>=0;r=e[r].parent)n.push(r);return n}var Pe={bend:4,flow:1,area:.01,aspect:1,shape:1.4,effort:1e3,seed:0,cross:20};function X(e,t,n,r,i={}){let{bend:a,flow:o,area:s,aspect:c,shape:l,effort:u,seed:d,cross:f}={...Pe,...i},p=e.length,m=e.map(e=>e[0]),h=e.map(e=>e[1]);if(!p)return{x:[],y:[],w:0,h:0};let g=Array.from({length:p},(e,t)=>Array.from({length:p},(e,r)=>n(t,r))),_=new Float64Array(p),v=new Float64Array(p),y=[...Array(p).keys()],b=[...y],x=new Int32Array(p),S=new Int32Array(p),C=0,w=0,T=()=>{y.forEach((e,t)=>{x[e]=t}),b.forEach((e,t)=>{S[e]=t}),C=0,w=0;for(let e=0;e<p;e++){let t=y[e],n=0,r=0;for(let i=0;i<e;i++){let e=y[i];S[e]<S[t]?n=Math.max(n,_[e]+m[e]+g[e][t]):r=Math.max(r,v[e]+h[e]+g[e][t])}_[t]=n,v[t]=r,C=Math.max(C,n+m[t]),w=Math.max(w,r+h[t])}},E=e=>[_[e]+m[e]/2,v[e]+h[e]/2],D=()=>{T();let e=0;for(let[n,i,s]of t){let t=Math.max(0,_[i]-_[n]-m[n],_[n]-_[i]-m[i]),c=Math.max(0,v[i]-v[n]-h[n],v[n]-v[i]-h[i]);e+=s*(Math.max(t,c)+.414*Math.min(t,c)+(t>0&&c>0?a:0));let l=r===`right`?_[n]+m[n]/2-(_[i]+m[i]/2):v[i]+h[i]/2-(v[n]+h[n]/2);l>0&&(e+=o*s*l)}if(f)for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let[i,a,o]=t[n],[s,c,l]=t[r];i!==s&&i!==c&&a!==s&&a!==c&&Ie(E(i),E(a),E(s),E(c))&&(e+=f*Math.min(o,l))}let n=Math.log(C/w/l);return e+s*C*w*(1+c*n*n)},O=Fe(p,t);if(y.sort((e,t)=>O[e]-O[t]),b.splice(0,p,...y),r===`up`&&y.reverse(),i.pair)return y.splice(0,p,...i.pair[0]),b.splice(0,p,...i.pair[1]),T(),{x:[..._],y:[...v],w:C,h:w,pair:i.pair};let k=D(),A=k,j=[...y],M=[...b];if(p<2)return T(),{x:[..._],y:[...v],w:C,h:w,pair:[[...y],[...b]]};let N=Re(Le(e,t)^d),P=u*p,F=Math.max(1,k*.05),I=.001**(1/P);for(let e=0;e<P;e++,F*=I){let e=Math.floor(N()*p),t=(e+1+Math.floor(N()*(p-1)))%p,n=N(),r=n=>{let r=n[e];n[e]=n[t],n[t]=r};if(n<.4)r(y);else if(n<.8)r(b);else{let n=y.indexOf(b[e]),i=y.indexOf(b[t]);r(b);let a=y[n];y[n]=y[i],y[i]=a}let i=D();if(i<=k||N()<Math.exp((k-i)/F))k=i,k<A&&(A=k,j=[...y],M=[...b]);else if(n<.4)r(y);else if(n<.8)r(b);else{let n=y.indexOf(b[e]),i=y.indexOf(b[t]);r(b);let a=y[n];y[n]=y[i],y[i]=a}}return y.splice(0,p,...j),b.splice(0,p,...M),T(),{x:[..._],y:[...v],w:C,h:w,cost:A,pair:[j,M]}}function Fe(e,t){let n=Array(e).fill(0);for(let[e,r,i]of t)n[e]+=i,n[r]-=i;let r=[...Array(e).keys()].sort((e,t)=>n[t]-n[e]||e-t),i=Array(e);return r.forEach((e,t)=>{i[e]=t}),i}function Ie(e,t,n,r){let i=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return i(e,t,n)*i(e,t,r)<0&&i(n,r,e)*i(n,r,t)<0}function Le(e,t){let n=2166136261;for(let r of[...e.flat(),...t.flat()])n^=r|0,n=Math.imul(n,16777619);return n>>>0}function Re(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var ze={cell:7,note:[18,5],gap:6,gapFolders:8,channel:6,channelFolders:8,pad:6,head:2,margin:8,minFolder:12,slant:8,keep:2},Be={fine:ze,coarse:{cell:14,note:[9,3],gap:3,gapFolders:6,channel:3,channelFolders:6,pad:3,head:1,margin:6,minFolder:6,slant:4,keep:1},coarser:{cell:18,note:[7,2],gap:2,gapFolders:5,channel:2,channelFolders:5,pad:2,head:1,margin:5,minFolder:5,slant:3,keep:1}};ze.pad;var Ve=1.4,Z=8,He=12,Ue=ze.note,We=0,Ge=0,Ke=0,qe=0,Q=0,Je=0,Ye=0,Xe=0,Ze=0,$=2,Qe=0,$e=0;function et(e){({note:Ue,gap:We,gapFolders:Ge,channel:Ke,channelFolders:qe,head:Q,margin:Je,minFolder:Ye,slant:Xe,pad:Ze,keep:$}=e),Qe=Ue[0]+We,$e=3*Qe}function tt(e,{flow:t=`up`,grain:n=`fine`,plan:r=!1,planCosts:i={},planned:a=null}={}){let o=Be[n]??ze;et(o);let s=e=>e.kind===`dir`,c=new Map,l=new Map,u=[e.root];for(let e=0;e<u.length;e++)for(let t of u[e].children||[])c.set(t,u[e]),s(t)?u.push(t):l.set(t.ref,t);let d=e=>{let t=[];for(let n=e;n;n=c.get(n))t.push(n);return t.reverse()},f=new Map(u.map(e=>[e,new Map])),p=new Map;for(let e of u){p.set(e,p.size);for(let t of e.children||[])s(t)||p.set(t,p.size)}let m=new Map(l);if(e.code)for(let t of u)t!==e.root&&!m.has(t.ref)&&m.set(t.ref,t);for(let[t,n,r]of e.edges){if(r<2)continue;let e=m.get(t),i=m.get(n);if(!e||!i||e===i)continue;let a=d(e),o=d(i),s=0;for(;a[s+1]&&a[s+1]===o[s+1];)s++;if(!a[s+1]||!o[s+1])continue;let c=f.get(a[s]),l=o[s+1],u=a[s+1],h=p.get(l)+`|`+p.get(u),g=c.get(h)||{p:l,q:u,weight:0,count:0};g.weight+=r,g.count++,c.set(h,g)}let h=new Map,g=new Map,_=new Map,v=e=>e===`up`?`right`:`up`,y=(t,n)=>{let r=t.children||[];for(let e of r)s(e)?y(e,v(n)):h.set(e,{w:Ue[0],h:Ue[1]});let i=r.length?b(t,r,n):{w:0,h:0};h.set(t,t===e.root?i:r.length?{w:Math.max(Ye,i.w+2*Ze),h:i.h+Ze+Q+Ze}:{w:Ye,h:Q+2*Ze})};function b(e,t,n){if(r&&t.some(s))return x(e,t,n);let i=new Map(t.map(e=>[e,e])),a=e=>{for(;i.get(e)!==e;)e=i.get(e);return e};for(let t of f.get(e).values()){let e=a(t.p),n=a(t.q);e!==n&&i.set(n,e)}let o=new Map,c=new Set([...f.get(e).values()].flatMap(e=>[e.p,e.q]));for(let e of t){let t=c.has(e)?a(e):null;o.set(t,[...o.get(t)||[],e])}if(o.size<2){let r=S(e,t,n);return _.set(e,r.out),{w:r.w,h:r.h}}let l=[...o].map(([t,r],i)=>({list:r,loose:t===null,k:i,...S(e,r,n)}));l.sort((e,t)=>e.loose-t.loose||t.w*t.h-e.w*e.h||e.k-t.k);let u=t.some(s)?Ge:We,d=l.reduce((e,t)=>e+(t.w+u)*(t.h+u),0),p=Math.max(Math.ceil(Math.sqrt(d*Ve)),...l.map(e=>e.w)),m=0,g=0,v=0,y=0,b=[];for(let e of l){m&&m+e.w>p&&(m=0,g+=v+u,v=0);for(let t of e.list){let e=h.get(t);e.x+=m,e.y+=g}for(let t of e.out)b.push({...t,pts:t.pts&&t.pts.map(([e,t])=>[e+m,t+g])});y=Math.max(y,m+e.w),v=Math.max(v,e.h),m+=e.w+u}return _.set(e,b),{w:y,h:g+v}}function x(t,n,r){let o=new Map(n.map((e,t)=>[e,t])),c=[...f.get(t).values()].filter(e=>o.has(e.p)&&o.has(e.q)),l=t===e.root?``:t.ref,u=a?.get(l),d=(e,t)=>u?.wider.get([n[e].ref,n[t].ref].sort().join(`|`))??0,p=(e,t)=>(s(n[e])||s(n[t])?Ge:We)+d(e,t),m=n.map(e=>[h.get(e).w,h.get(e).h]),v=t===e.root&&r===`up`?1/Pe.shape:Pe.shape,y=X(m,c.map(e=>[o.get(e.p),o.get(e.q),e.count]),p,r,{shape:v,...i,pair:u?.pair});g.set(l,y.pair),n.forEach((e,t)=>Object.assign(h.get(e),{x:y.x[t],y:y.y[t]}));let b=e=>r===`right`?y.x[e]+m[e][0]/2:-(y.y[e]+m[e][1]/2),x=new Map;for(let e of c)x.set(e.p,[...x.get(e.p)||[],e.q]);let S=(e,t)=>{let n=new Set,r=(x.get(e)||[]).filter(e=>e!==t);for(;r.length;){let e=r.pop();if(e===t)return!0;n.has(e)||(n.add(e),r.push(...x.get(e)||[]))}return!1};return _.set(t,c.map(e=>({p:e.p,q:e.q,count:e.count,back:b(o.get(e.p))>b(o.get(e.q)),implied:!s(e.p)&&!s(e.q)&&S(e.p,e.q),pts:null}))),{w:y.w,h:y.h}}function S(e,t,n){let r=t.length,i=new Map(t.map((e,t)=>[e,t])),a=n===`up`,o=t.some(s)?Ge:We,c=t.map(e=>a?h.get(e).h:h.get(e).w),l=t.map(e=>a?h.get(e).w:h.get(e).h),u=[...f.get(e).values()].filter(e=>i.has(e.p)&&i.has(e.q)).map(e=>({...e,p:i.get(e.p),q:i.get(e.q)})),d=rt(r,u.map(e=>[e.p,e.q,e.weight]));for(let e of u)e.back=d[e.p]>d[e.q],e.u=e.back?e.q:e.p,e.v=e.back?e.p:e.q;let p=u.filter(e=>!e.back),m=Array(r).fill(0),g=t.map(()=>[]),_=t.map(()=>[]);for(let e of u)g[e.v].push(e.u),_[e.u].push(e.v);let v=t.map(()=>[]);for(let e of p)v[e.p].push(e.q);for(let e of[...Array(r).keys()].sort((e,t)=>d[e]-d[t]))for(let t of g[e])m[e]=Math.max(m[e],m[t]+1);for(let e=0;e<r;e++)!g[e].length&&_[e].length&&(m[e]=Math.min(..._[e].map(e=>m[e]))-1);let y=(e,t,n)=>{let r=new Set,i=v[e].filter(e=>e!==n);for(;i.length;){let e=i.pop();if(e===t)return!0;r.has(e)||(r.add(e),i.push(...v[e]))}return!1};for(let e of p)e.implied=!s(t[e.p])&&!s(t[e.q])&&y(e.p,e.q,e.q);let b=u.filter(e=>!e.implied).sort((e,t)=>t.weight-e.weight||e.p-t.p||e.q-t.q),x=t.reduce((e,t,n)=>e+(l[n]+o)*(c[n]+Ke),0),S=Math.max(Math.ceil(Math.sqrt(a?x*Ve:x/Ve)),...l),C=[],w=Array(r),T=Array(r).fill(!1);for(let e of u)T[e.p]=!0,T[e.q]=!0;let E=T.some(Boolean)&&T.some(e=>!e),D=e=>{let t=e.reduce((e,t)=>e+l[t]+o,0),n=Math.max(1,Math.ceil((t-o)/S)),r=t/n,i=null,a=0;for(let t of e)(!i||a+l[t]>S||C.length-O<n&&a>=r)&&(i=[],C.push(i),a=0),w[t]=C.length-1,i.push(t),a+=l[t]+o},O=0,k=e=>g[e].length?+!!_[e].length:2,A=e=>e.length?e.reduce((e,t)=>e+d[t],0)/e.length:0;for(let e=0;e<=Math.max(...m);e++){let t=[...Array(r).keys()].filter(t=>m[t]===e&&(T[t]||!E));t.reduce((e,t)=>e+l[t]+o,0)-o>S&&t.sort((e,t)=>k(e)-k(t)||A(g[e])-A(g[t])||e-t),O=C.length,D(t)}E&&(O=C.length,D([...Array(r).keys()].filter(e=>!T[e])));let j=[...l],M=t.map(()=>[]),N=t.map(()=>[]),P=new Map,F=new Map,I=[],L=new Set,R=new Map;for(let e of b){let t=[e.u];for(let n=w[e.u]+1;n<w[e.v];n++){let r=e.u+`|`+n;P.has(r)||(P.set(r,j.length),F.set(j.length,e.u),j.push(1),M.push([]),N.push([]),w.push(n),C[n].push(j.length-1)),t.push(P.get(r))}t.push(e.v);for(let e=1;e<t.length;e++){let n=t[e-1],r=t[e];L.has(n+`|`+r)||(L.add(n+`|`+r),I.push([n,r]),N[n].push(r),M[r].push(n))}R.set(e,t)}let z=e=>e>=r,B=Array(j.length);C.forEach(e=>e.forEach((e,t)=>{B[e]=t}));let V=(e,t)=>{let n=new Map(C[e].map(e=>[e,t[e].length?t[e].reduce((e,t)=>e+B[t],0)/t[e].length:B[e]]));C[e].sort((e,t)=>n.get(e)-n.get(t)||B[e]-B[t]),C[e].forEach((e,t)=>{B[e]=t})},H=()=>{let e=0;for(let t=0;t<C.length-1;t++){let n=[];for(let e of C[t])for(let t of N[e])n.push([B[e],B[t]]);for(let t=0;t<n.length;t++)for(let r=t+1;r<n.length;r++)(n[t][0]-n[r][0])*(n[t][1]-n[r][1])<0&&e++}return e},U=()=>{let e=(e,t,n)=>{let r=0;for(let i of n[e])for(let e of n[t])r+=B[i]>B[e]?1:B[i]<B[e]?-1:0;return r};for(let t=!0,n=0;t&&n<Z;n++){t=!1;for(let n of C)for(let r=0;r+1<n.length;r++){let i=n[r],a=n[r+1];e(i,a,M)+e(i,a,N)>0&&(n[r]=a,n[r+1]=i,B[i]=r+1,B[a]=r,t=!0)}}},ee=C.map(e=>[...e]),W=(e,t)=>(z(e)?d[F.get(e)]:d[e])-(z(t)?d[F.get(t)]:d[t])||e-t,G=null,K=1/0;for(let e of[e=>e,e=>[...e].sort(W),e=>[...e].reverse()]){C.forEach((t,n)=>{t.splice(0,t.length,...e(ee[n])),t.forEach((e,t)=>{B[e]=t})});let t=1/0,n=0;for(let e=0;e<24&&n<4&&K>0;e++,n++){if(e%2==0)for(let e=1;e<C.length;e++)V(e,M);else for(let e=C.length-2;e>=0;e--)V(e,N);U();let r=H();r<t&&(t=r,n=0),r<K&&(K=r,G=C.map(e=>[...e]))}}G&&C.forEach((e,t)=>{e.splice(0,e.length,...G[t]),e.forEach((e,t)=>{B[e]=t})});let te=(e,t)=>z(e)&&z(t)?1:z(e)||z(t)?$:o,q=Array(j.length).fill(0);for(let e of C){let t=0;e.forEach((n,r)=>{r&&(t+=te(e[r-1],n)),q[n]=t,t+=j[n]})}let ne=e=>e.length?q[e[e.length-1]]+j[e[e.length-1]]:0,re=Math.max(...C.map(ne));for(let e of C){let t=(re-ne(e))/2;for(let n of e)q[n]+=t}let ie=e=>q[e]+j[e]/2;for(let e=0;e<He;e++)for(let t of e%2?[...C].reverse():C){if(!t.length)continue;let e=t.map(e=>{let t=[...M[e],...N[e]];return(t.length?t.reduce((e,t)=>e+ie(t),0)/t.length:ie(e))-j[e]/2}),n=[],r=[];t.forEach((r,i)=>{n[i]=i?Math.max(e[i],n[i-1]+j[t[i-1]]+te(t[i-1],r)):e[i]});for(let n=t.length-1;n>=0;n--)r[n]=n<t.length-1?Math.min(e[n],r[n+1]-j[t[n]]-te(t[n],t[n+1])):e[n];t.forEach((e,t)=>{q[e]=(n[t]+r[t])/2})}let ae=e=>Math.floor((j[e]-1)/2),oe=Array(j.length).fill(-1),se=Array(j.length).fill(-1);for(let e of[!0,!1])for(let t=1;t<C.length;t++){let n=C[t].filter(e=>oe[e]>=0).map(e=>[B[oe[e]],B[e]]);for(let r of C[t]){if(oe[r]>=0||!M[r].length)continue;let t=[...M[r]].sort((e,t)=>B[e]-B[t]),i=(t.length-1)/2,a=t.map((e,t)=>[e,Math.abs(t-i)]).filter(([t])=>se[t]<0&&(!e||z(t)&&z(r))&&Math.abs(q[t]+ae(t)-q[r]-ae(r))<=(e?$e:Qe)).sort((e,t)=>e[1]-t[1]||B[e[0]]-B[t[0]]);for(let[e]of a)if(!n.some(([t,n])=>t<B[e]!=n<B[r])){oe[r]=e,se[e]=r,n.push([B[e],B[r]]);break}}}let ce=Array(j.length).fill(-1),le=0;for(let e=0;e<j.length;e++)if(oe[e]<0){for(let t=e;t>=0;t=se[t])ce[t]=le;le++}let ue=Array.from({length:le},()=>[]);ce.forEach((e,t)=>ue[e].push(t));let de=(e,t)=>j[e]-ae(e)+te(e,t)+ae(t),fe=Array(j.length).fill(-1),pe=Array(j.length).fill(-1);for(let e of C)e.forEach((t,n)=>{n&&(fe[t]=e[n-1],pe[e[n-1]]=t)});let me=Array(le).fill(0),he=!1;for(let e=0;e<=le&&!he;e++){he=!0;for(let e of C)for(let t=1;t<e.length;t++){let n=me[ce[e[t-1]]]+de(e[t-1],e[t]);me[ce[e[t]]]<n&&(me[ce[e[t]]]=n,he=!1)}}if(he){let e=ue.map(e=>Math.round(e.reduce((e,t)=>e+q[t]+ae(t),0)/e.length)),t=Math.min(...e.map((e,t)=>e-me[t])),n=[...Array(le).keys()].sort((t,n)=>e[n]-e[t]||t-n);for(let r=0;r<24;r++){let i=!1;for(let a of r%2?[...n].reverse():n){let n=-1/0,r=1/0;for(let e of ue[a])fe[e]>=0&&(n=Math.max(n,me[ce[fe[e]]]+de(fe[e],e))),pe[e]>=0&&(r=Math.min(r,me[ce[pe[e]]]-de(e,pe[e])));let o=Math.max(n,Math.min(r,e[a]-t));o!==me[a]&&(me[a]=o,i=!0)}if(!i)break}for(let e=0;e<j.length;e++)q[e]=me[ce[e]]-ae(e)}else for(let e of C)e.forEach((t,n)=>{q[t]=n?Math.max(Math.round(q[t]),q[e[n-1]]+j[e[n-1]]+te(e[n-1],t)):Math.round(q[t])});let ge=Math.min(...q);for(let e=0;e<q.length;e++)q[e]-=ge;let _e=Math.max(...q.map((e,t)=>e+j[t])),J=e=>q[e]+Math.floor((j[e]-1)/2)+.5,ve=new Map;for(let e=0;e<j.length;e++){let t=[...M[e]].sort((e,t)=>J(e)-J(t)),n=q[e]+.5,r=q[e]+j[e]-.5;if(t.length>j[e]){t.forEach((r,i)=>ve.set(r+`|`+e,n+Math.min(j[e]-1,Math.floor(i*j[e]/t.length))));continue}let i=t.map(e=>Math.max(n,Math.min(r,J(e))));for(let e=1;e<i.length;e++)i[e]=Math.max(i[e],i[e-1]+1);for(let e=i.length-1;e>=0;e--)i[e]=Math.min(i[e],e===i.length-1?r:i[e+1]-1);t.forEach((t,n)=>ve.set(t+`|`+e,i[n]))}let ye=(e,t)=>{let n=ve.get(e+`|`+t);return n>=q[e]+.5&&n<=q[e]+j[e]-.5},be=Array(j.length);for(let e=0;e<j.length;e++){let t=N[e].filter(t=>!ye(e,t)).map(t=>ve.get(e+`|`+t)).sort((e,t)=>e-t);be[e]=t.length?Math.max(q[e]+.5,Math.min(q[e]+j[e]-.5,t[t.length-1>>1])):J(e)}let xe=(e,t)=>ye(e,t)?ve.get(e+`|`+t):be[e],Y=(e,t)=>{let n=xe(e,t),r=ve.get(e+`|`+t);return[Math.min(n,r),Math.max(n,r)]},Se=new Set,Ce=C.map(()=>0);for(let[e,t]of I){if(ye(e,t))continue;let[n,r]=Y(e,t),i=ve.get(e+`|`+t)>be[e];r-n>Xe||I.every(([a,o])=>{if(w[a]!==w[e]||a===e&&o===t)return!0;let[s,c]=Y(a,o);return a===e?i?c<=n:s>=r:c<n-1||s>r+1})&&(Se.add(e+`|`+t),Ce[w[e]]=Math.max(Ce[w[e]],r-n))}let we=new Map;for(let[e,t]of I){if(ye(e,t)||Se.has(e+`|`+t))continue;let n=ve.get(e+`|`+t),r=we.get(e)||{u:e,lo:be[e],hi:be[e],track:0};r.lo=Math.min(r.lo,n),r.hi=Math.max(r.hi,n),we.set(e,r)}let Te=C.map(()=>0);C.forEach((e,t)=>{let n=[...we.values()].filter(e=>w[e.u]===t&&e.hi>e.lo).sort((e,t)=>e.lo-t.lo||e.hi-t.hi||e.u-t.u),r=n.map(e=>N[e.u].filter(t=>!ye(e.u,t)&&!Se.has(e.u+`|`+t)).map(t=>ve.get(e.u+`|`+t))),i=(e,t)=>!(n[e].hi<n[t].lo-1||n[t].hi<n[e].lo-1),a=(e,t)=>+(be[n[t].u]>n[e].lo&&be[n[t].u]<n[e].hi)+r[e].filter(e=>e>n[t].lo&&e<n[t].hi).length,o=[];for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){if(!i(e,t))continue;let n=a(t,e)-a(e,t);n>0?o.push([e,t,n]):n<0&&o.push([t,e,-n])}let s=rt(n.length,o),c=[];for(let e of[...n.keys()].sort((e,t)=>s[e]-s[t]))n[e].track=Math.max(0,...c.filter(t=>i(e,t)).map(e=>n[e].track+1)),c.push(e);Te[t]=Math.max(0,...n.map(e=>e.track+1))});let Ee=C.map(e=>Math.max(0,...e.filter(e=>!z(e)).map(e=>c[e]))),De=[],Oe=[],ke=[],Ae=0;C.forEach((e,n)=>{De[n]=Ae,Ae+=Ee[n];let r=Math.max(t.some(s)?qe:Ke,Te[n]+2*$,Ce[n]+2);Oe[n]=Ae+Math.max($,Math.floor((r-Te[n])/2));let i=Ae;ke[n]=e=>i+Math.floor((r-e)/2),n<C.length-1&&(Ae+=r)});let je=Ae,Me=e=>De[w[e]]+Math.floor((Ee[w[e]]-c[e])/2),Ne=(e,t)=>a?[t,je-e]:[e,t];t.forEach((e,t)=>Object.assign(h.get(e),a?{x:q[t],y:je-Me(t)-c[t]}:{x:Me(t),y:q[t]}));let Pe=[];for(let e of u){let n=R.get(e),r=null;if(n){r=[Ne(Me(e.u)+c[e.u],xe(e.u,n[1]))];for(let e=1;e<n.length;e++){let t=n[e-1],i=n[e],a=ve.get(t+`|`+i);if(Se.has(t+`|`+i)){let e=Math.abs(a-be[t]),n=ke[w[t]](e);r.push(Ne(n,be[t]),Ne(n+e,a));continue}let o=Oe[w[t]]+(we.get(t)?.track||0)+.5;r.push(Ne(o,xe(t,i)),Ne(o,a))}r.push(Ne(Me(e.v),ve.get(n[n.length-2]+`|`+e.v))),r=r.filter((e,t)=>!t||e[0]!==r[t-1][0]||e[1]!==r[t-1][1]),e.back&&r.reverse()}Pe.push({p:t[e.p],q:t[e.q],count:e.count,back:e.back,implied:!!e.implied,pts:r})}return a?{w:_e,h:je,out:Pe}:{w:je,h:_e,out:Pe}}y(e.root,t);let C=[],w=new Map,T=new Map([[e.root,[Je,Je]]]);for(let t of u){let[n,r]=T.get(t),i=t===e.root?-1:w.get(t),a=d(t).length;for(let e of t.children||[]){let t=h.get(e);w.set(e,C.length),C.push({id:e.id,ref:e.ref,kind:s(e)?`folder`:`note`,parent:i,depth:a,gx:n+t.x,gy:r+t.y,w:t.w,h:t.h}),s(e)&&T.set(e,[n+t.x+Ze,r+t.y+Q+Ze])}}let E=[],D=new Set;for(let e of u){let[t,n]=T.get(e);for(let r of _.get(e)||[]){let e=w.get(r.q),i=w.get(r.p);r.back&&D.add(e+`|`+i),E.push({a:e,b:i,count:r.count,back:r.back,implied:r.implied,pts:r.pts&&r.pts.map(([e,r])=>[e+t,r+n])})}}let O=nt(C,e.edges,new Map([...l].map(([e,t])=>[e,w.get(t)]))),k=(e,t)=>{for(;C[e].parent!==t;)e=C[e].parent;return e};for(let e of O)e.placed=e.s>=2&&!D.has(k(e.a,e.level)+`|`+k(e.b,e.level));let A=h.get(e.root);return{W:A.w+2*Je,H:A.h+2*Je,flow:t,cell:o.cell,keep:o.keep,margin:Je,items:C,links:O,trunks:E,pairs:g}}function nt(e,t,n){let r=t=>{let n=[];for(let r=e[t].parent;r>=0;r=e[r].parent)n.push(r);return n},i=[];for(let[e,a,o]of t){let t=n.get(e),s=n.get(a);if(t===void 0||s===void 0||t===s)continue;let c=new Set(r(s));i.push({a:t,b:s,s:o,level:r(t).find(e=>c.has(e))??-1,placed:!1})}return i}function rt(e,t){let n=Array.from({length:e},()=>new Map),r=Array.from({length:e},()=>new Map);for(let[e,i,a]of t)e!==i&&(n[e].set(i,(n[e].get(i)||0)+a),r[i].set(e,(r[i].get(e)||0)+a));let i=e=>{let t=0;for(let n of e.values())t+=n;return t},a=new Set([...Array(e).keys()]),o=[],s=[],c=(e,t)=>{a.delete(e),t.push(e);for(let t of n[e].keys())r[t].delete(e);for(let t of r[e].keys())n[t].delete(e)};for(;a.size;){let e=!0;for(;e;){e=!1;for(let t of[...a])r[t].size?n[t].size||(c(t,s),e=!0):(c(t,o),e=!0)}if(!a.size)break;let t=-1,l=-1/0;for(let e of a){let a=i(n[e])-i(r[e]);a>l&&(l=a,t=e)}c(t,o)}let l=Array(e);return[...o,...s.reverse()].forEach((e,t)=>{l[e]=t}),l}var it={climb:5,turn45:1.5,turn90:3,foreign:2.5,crowd:.2,near:0,hug:2.5,haste:3.2},at=[1,1,0,-1,-1,-1,0,1],ot=[0,1,1,1,0,-1,-1,-1],st=3,ct=8;function lt(e,t,n={}){let{climb:r,turn45:i,turn90:a,foreign:o,crowd:s,near:c,hug:l,haste:u}={...it,...n},{W:d,H:f,elev:p,blocked:m,owner:h}=t,g=t.close||new Uint8Array(d*f),_=d*f,v=e.items,y=new Uint16Array(_),b=new Uint16Array(_),x=new Float32Array(_*9),S=new Int32Array(_*9),C=new Uint32Array(_*9),w=new Uint32Array(v.length),T=_*9,E=0,D=new Float32Array(4096),O=new Float32Array(4096),k=new Int32Array(4096),A=0,j=(e,t,n)=>{if(A===D.length){let e=(e,t)=>{let n=new t(e.length*2);return n.set(e),n};D=e(D,Float32Array),O=e(O,Float32Array),k=e(k,Int32Array)}let r=A++;for(;r>0;){let t=r-1>>1;if(D[t]<=e)break;D[r]=D[t],O[r]=O[t],k[r]=k[t],r=t}D[r]=e,O[r]=t,k[r]=n},M=()=>{N=O[0],P=k[0];let e=D[--A],t=O[A],n=k[A],r=0;for(;;){let t=2*r+1;if(t>=A||(t+1<A&&D[t+1]<D[t]&&t++,D[t]>=e))break;D[r]=D[t],O[r]=O[t],k[r]=k[t],r=t}D[r]=e,O[r]=t,k[r]=n},N=0,P=0,F=(e,t)=>{y[e]+=t;let n=e%d,r=e/d|0;for(let e=Math.max(0,r-1);e<=Math.min(f-1,r+1);e++)for(let i=Math.max(0,n-1);i<=Math.min(d-1,n+1);i++)(i!==n||e!==r)&&(b[e*d+i]+=t)},I=e=>{let t=[],n=(e,n,r,i)=>{e>=0&&n>=0&&e<d&&n<f&&!m[n*d+e]&&t.push([n*d+e,r,i])};for(let t=e.gx;t<e.gx+e.w;t++)n(t,e.gy-1,t+.5,e.gy),n(t,e.gy+e.h,t+.5,e.gy+e.h);for(let t=e.gy;t<e.gy+e.h;t++)n(e.gx-1,t,e.gx,t+.5),n(e.gx+e.w,t,e.gx+e.w,t+.5);return t};function L(e,t,n,f,_,D,O=null){E++,A=0;for(let t of Ne(v,e))w[t]=E;if(O){w[O.folder]=E;for(let e of Ne(v,O.folder))w[e]=E}else for(let e of Ne(v,t))w[e]=E;let k=v[e],L=O?null:v[t],R=O?O.ends:new Map(I(L).map(e=>[e[0],e])),z,B,V,H;if(O?.toward!==void 0)z=B=O.toward%d,V=H=O.toward/d|0;else if(O){z=V=1/0,B=H=-1/0;for(let e of R.keys()){let t=e%d,n=e/d|0;z=Math.min(z,t),B=Math.max(B,t),V=Math.min(V,n),H=Math.max(H,n)}}else z=L.gx-1,B=L.gx+L.w,V=L.gy-1,H=L.gy+L.h;let U=(e,t)=>{let n=Math.max(z-e,e-B,0),r=Math.max(V-t,t-H,0);return u*(Math.max(n,r)+.414*Math.min(n,r))},ee=new Map;for(let e of I(k)){let t=e[0],n=t*9+ct,r=Math.fround(1+s*Math.min(y[t],st));C[n]===E&&x[n]<=r||(C[n]=E,x[n]=r,S[n]=-1,j(r+U(t%d,t/d|0),r,n),ee.set(t,e))}let W=!!O?.strict,G=-1;for(;A;){M();let e=P,t=N;if(e>=T){G=e-T;break}if(t!==x[e])continue;let u=e/9|0,v=e%9,k=R.get(u);if(k){if(!k[3]){G=e;break}j(Math.fround(t+k[3]),Math.fround(t+k[3]),T+e)}let A=u%d,F=u/d|0;for(let T=0;T<8;T++){let k=A+at[T],M=F+ot[T];if(k<n||M<f||k>_||M>D)continue;let N=M*d+k;if(m[N]||W&&h[N]!==O.folder)continue;if(at[T]&&ot[T]){let e=F*d+k,t=M*d+A;if(m[e]||m[t]||p[e]!==p[u]||p[t]!==p[u]||p[N]!==p[u])continue}let P=(at[T]&&ot[T]?1.414:1)*(1+s*Math.min(y[N],st)+c*Math.min(b[N],st))+r*Math.abs(p[N]-p[u]);if(v!==ct&&v!==T){let e=Math.min((T-v+8)%8,(v-T+8)%8);P+=e===1?i:a*(e>=3?2:1)}h[N]>=0&&w[h[N]]!==E&&(P+=o),g[N]&&(P+=l);let I=N*9+T,L=Math.fround(t+P);C[I]===E&&x[I]<=L||(C[I]=E,x[I]=L,S[I]=e,j(L+U(k,M),L,I))}}if(G<0)return null;let K=[];for(let e=G;e!==-1;e=S[e])K.push(e/9|0);K.reverse();for(let e of K)F(e,1);let te=ee.get(K[0]),q=R.get(K[K.length-1]),ne=[[te[1],te[2]]];for(let e of K)ne.push([e%d+.5,(e/d|0)+.5]);return ne.push([q[1],q[2]]),{cells:Int32Array.from(K),pts:ne}}function R(e,t){let n=v[e],r=v[t],i=Math.max(Math.abs(n.gx-r.gx),Math.abs(n.gy-r.gy)),a=Math.max(12,Math.ceil(i*.4)),o=Math.max(0,Math.min(n.gx,r.gx)-a),s=Math.max(0,Math.min(n.gy,r.gy)-a),c=Math.min(d-1,Math.max(n.gx+n.w,r.gx+r.w)+a),l=Math.min(f-1,Math.max(n.gy+n.h,r.gy+r.h)+a);return L(e,t,o,s,c,l)||(o||s||c<d-1||l<f-1?L(e,t,0,0,d-1,f-1):null)}function z(e,t){return v[e],v[t.folder],B(e,{...t,strict:!0})||B(e,t)}function B(e,t){let n=v[e],r=v[t.folder];return L(e,-1,Math.max(0,Math.min(n.gx,r.gx)-2),Math.max(0,Math.min(n.gy,r.gy)-2),Math.min(d-1,Math.max(n.gx+n.w,r.gx+r.w)+2),Math.min(f-1,Math.max(n.gy+n.h,r.gy+r.h)+2),t)}function V(e){let t=new Set;for(let n=1;n<e.length;n++){let[r,i]=e[n-1],[a,o]=e[n],s=Math.max(1,Math.ceil(Math.max(Math.abs(a-r),Math.abs(o-i))*2));for(let e=0;e<=s;e++){let n=Math.floor(r+(a-r)*e/s),c=Math.floor(i+(o-i)*e/s);n<0||c<0||n>=d||c>=f||m[c*d+n]||t.has(c*d+n)||(t.add(c*d+n),F(c*d+n,1))}}}return{route:R,routeTo:z,occupy:V,release:e=>{for(let t of e.cells)F(t,-1)},hold:e=>{for(let t of e.cells)F(t,1)}}}var ut=[0,1,-1,2,-2,3,-3];function dt(e,t){let n=new Map;e.forEach((e,r)=>{e.edges=new Set;for(let i=1;i<e.cells.length;i++){let a=e.cells[i-1],o=e.cells[i],s=a<o?a*t+o:o*t+a;e.edges.add(s),n.has(s)||n.set(s,[]),n.get(s).push(r)}}),e.forEach((t,r)=>{let i=new Set;for(let a of t.edges)for(let t of n.get(a))t<r&&i.add(e[t].lane);t.lane=ut.find(e=>!i.has(e))??0,delete t.edges})}var ft=(e,t,n,r)=>{let i=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return i(e,t,n)*i(e,t,r)<0&&i(n,r,e)*i(n,r,t)<0};function pt(e,t){let n=new Map;e.forEach((e,t)=>{for(let r of e.cells)n.has(r)||n.set(r,new Set),n.get(r).add(t)});let r=0,i=0;e.forEach((e,a)=>{for(let o of e.cells){r++;let e=!1,s=o%t;for(let r=-1;r<=1&&!e;r++)for(let i=-1;i<=1&&!e;i++){if(s+i<0||s+i>=t)continue;let c=n.get(o+r*t+i);if(c){for(let t of c)if(t!==a){e=!0;break}}}e||i++}});let a=e.map((e,t)=>{let n=[t*.618%1*.02-.01,t*.414%1*.02-.01],r=e.pts;return r.filter((e,t)=>t===0||t===r.length-1||Math.abs((e[0]-r[t-1][0])*(r[t+1][1]-e[1])-(e[1]-r[t-1][1])*(r[t+1][0]-e[0]))>1e-6).map(e=>[e[0]+n[0],e[1]+n[1]])}),o=0;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let r=e[t],i=e[n];if(r.a!==i.a&&r.a!==i.b&&r.b!==i.a&&r.b!==i.b)for(let e=1;e<a[t].length;e++)for(let r=1;r<a[n].length;r++)ft(a[t][e-1],a[t][e],a[n][r-1],a[n][r])&&o++}return{routes:e.length,crossings:o,length:r,beside:r?1-i/r:0}}function mt(e,t,n,r,i=t.length<=100?2:+(t.length<=300)){let a=t.map(({a:t,b:n})=>{let r=e.route(t,n);return r&&{a:t,b:n,...r}});for(let t=0;t<i;t++)a.forEach((t,n)=>{if(!t)return;e.release(t);let r=e.route(t.a,t.b);r?Object.assign(t,r):e.hold(t)});let o=a.filter(Boolean);dt(o,n*r);let s={...pt(o,n),lost:a.length-o.length};for(let t of o)e.release(t);return{routes:a.map(e=>e&&{pts:e.pts,lane:e.lane}),measures:s}}var ht=[1,1,0,-1,-1,-1,0,1],gt=[0,1,1,1,0,-1,-1,-1],_t=8,vt={turn45:1.5,turn90:3,diag:1.3,hug:1,share:.35,centre:.3,gather:224};function yt(e,t=Me(e),n={}){let{turn45:r,turn90:i,diag:a,hug:o,share:s,centre:c,gather:l}={...vt,...n},{items:u,trunks:d}=e,{W:f,H:p,blocked:m,owner:h}=t,g=f*p,_=Math.max(2,Math.round(28/(e.cell??7))),v=kt(t,_),y=_,b=new Uint8Array(g),x=10/(e.cell??7),S=(e,t)=>e>=0&&t>=0&&e<f&&t<p,C=(e,t,n)=>S(e,t)&&!m[t*f+e]&&h[t*f+e]===n;function w(e,t,n){let[r,i]=e,[a,o]=t,s=n?a-r:o-i,c=n?o-i:a-r,l=Math.sign(s),u=Math.sign(c),d=Math.abs(s),f=Math.abs(c),p=[];if(d>=f){let e=Math.floor((d-f)/2);for(let t=0;t<e;t++)p.push([l,0]);for(let e=0;e<f;e++)p.push([l,u]);for(let t=0;t<d-f-e;t++)p.push([l,0])}else{let e=Math.floor(d/2);for(let t=0;t<e;t++)p.push([l,u]);for(let e=0;e<f-d;e++)p.push([0,u]);for(let t=0;t<d-e;t++)p.push([l,u])}let m=[[r,i]],h=r,g=i;for(let[e,t]of p)n?(h+=e,g+=t):(h+=t,g+=e),m.push([h,g]);return m}function T(e,t,n,r,i){let a=Math.max(e.gx-(t.gx+t.w),t.gx-(e.gx+e.w)),o=Math.max(e.gy-(t.gy+t.h),t.gy-(e.gy+e.h)),s=a>=o;if((s?a:o)<1)return null;let[c,l]=s?t.gx<e.gx?[3,2]:[2,3]:t.gy<e.gy?[1,0]:[0,1];if(i&&i.side!==c||r&&r.side!==l)return null;let u=Ot(t)[c],d=Ot(e)[l],p=s?Math.max(e.gy,t.gy):Math.max(e.gx,t.gx),m=s?Math.min(e.gy+e.h,t.gy+t.h):Math.min(e.gx+e.w,t.gx+t.w),h=e=>Math.floor(e.mid-.5+1e-9),g=e=>e>=p&&e<m,b=r||i?[[i?i.t:g(r.t)?r.t:h(u),r?r.t:g(i.t)?i.t:h(d),0]]:m-p>=1?At(p,m).map(e=>[e,e,Math.abs(e+.5-(p+m)/2)]):[[h(u),h(d),0]],S=null;for(let[r,i,a]of b){if(bt(t,c,r,x)||bt(e,l,i,x))continue;let o=w(s?[c===3?t.gx+t.w:t.gx-1,r]:[r,c===1?t.gy+t.h:t.gy-1],s?[l===2?e.gx-1:e.gx+e.w,i]:[i,l===0?e.gy-1:e.gy+e.h],s);if(!o.every(([e,t])=>C(e,t,n)))continue;let u=o.slice(_,o.length-_),d=u.length?Math.min(...u.map(([e,t])=>v[t*f+e])):_;d<y||(!S||d>S.least||d===S.least&&a<S.off)&&(S={least:d,off:a,tb:r,ta:i,way:o})}return S?[u.wall(S.tb),...S.way.map(([e,t])=>[e+.5,t+.5]),d.wall(S.ta)]:null}let E=new Float32Array(g+1),D=new Int32Array(g+1),O=new Uint8Array(g+1),k=new Uint32Array(g+1),A=0,j=[],M=(e,t)=>{j.push([e,t]);let n=j.length-1;for(;n>0;){let t=n-1>>1;if(j[t][0]<=e)break;[j[t],j[n]]=[j[n],j[t]],n=t}},N=()=>{let e=j[0],t=j.pop();if(j.length){j[0]=t;let e=0;for(;;){let t=2*e+1;if(t>=j.length||(t+1<j.length&&j[t+1][0]<j[t][0]&&t++,j[t][0]>=j[e][0]))break;[j[t],j[e]]=[j[e],j[t]],e=t}}return e},P=(e,t)=>{if(e===_t||e===t)return 0;let n=Math.min((t-e+8)%8,(e-t+8)%8);return n===1?r:i*(n>=3?2:1)};function F(e,t,n,r,i){A++,j.length=0;let l=g,u=new Map,d=(e,t,n)=>!e||e.side===t&&e.t===n;if(Ot(e).forEach((t,i)=>t.cells.forEach(([a,o])=>{let s=t.dir===6||t.dir===2?a:o;C(a,o,n)&&d(r,i,s)&&!bt(e,i,s,x)&&u.set(o*f+a,[(t.dir+4)%8,c*Math.abs(s+.5-t.mid),t.wall(s)])})),!r)for(let t of xt(e,x))C(...t.out,n)&&u.set(t.out[1]*f+t.out[0],[(t.dir+4)%8,c*Math.min(e.w,e.h)/2,t.pt]);if(!u.size)return null;let p=e.gx-1,m=e.gx+e.w,h=e.gy-1,y=e.gy+e.h,S=(e,t)=>{let n=Math.max(p-e,e-m,0),r=Math.max(h-t,t-y,0);return Math.max(n,r)+.414*Math.min(n,r)},w=new Map,T=(e,t,n,r)=>{k[e]===A&&E[e]<=t||(k[e]=A,E[e]=t,D[e]=-1,O[e]=n,w.set(e,r),M(t+S(e%f,e/f|0),e))};if(Ot(t).forEach((e,r)=>e.cells.forEach(([a,o])=>{let s=e.dir===6||e.dir===2?a:o;C(a,o,n)&&d(i,r,s)&&!bt(t,r,s,x)&&T(o*f+a,c*Math.abs(s+.5-e.mid),e.dir,e.wall(s))})),!i)for(let e of xt(t,x))C(...e.out,n)&&T(e.out[1]*f+e.out[0],c*Math.min(t.w,t.h)/2,e.dir,e.pt);for(;j.length;){let[e,t]=N();if(t===l)break;let r=E[t];if(e-S(t%f,t/f|0)>r+1e-4)continue;let i=u.get(t);if(i){let e=r+i[1]+P(O[t],i[0]);(k[l]!==A||e<E[l])&&(k[l]=A,E[l]=e,D[l]=t,M(e,l))}let c=t%f,d=t/f|0;for(let e=0;e<8;e++){let i=c+ht[e],l=d+gt[e];if(!C(i,l,n)||ht[e]&&gt[e]&&(!C(i,d,n)||!C(c,l,n)))continue;let u=l*f+i,p=r+(ht[e]&&gt[e]?Math.SQRT2*a:1)*(b[u]?1-s:1)+o*(_-v[u])+P(O[t],e);k[u]===A&&E[u]<=p||(k[u]=A,E[u]=p,D[u]=t,O[u]=e,M(p+S(i,l),u))}}if(k[l]!==A)return null;let F=[];for(let e=D[l];e!==-1;e=D[e])F.push(e);return F.reverse(),[w.get(F[0]),...F.map(e=>[e%f+.5,Math.floor(e/f)+.5]),u.get(F.at(-1))[2]]}let I=d.map((e,t)=>t).sort((e,t)=>d[t].count-d[e].count||e-t),L=d.map(e=>({a:e.a,b:e.b,count:e.count,back:e.back,implied:e.implied})),R=e=>wt(e,(e,t)=>{S(e,t)&&!m[t*f+e]&&(b[t*f+e]=1)}),z=(e,t,n)=>{let r=d[e],i=u[r.a],a=u[r.b];return T(i,a,i.parent,t,n)??F(i,a,i.parent,t,n)};for(let e of I){let t=z(e);t&&(L[e].pts=t,R(t))}let B=l/(e.cell??7),V=new Map;L.forEach((e,t)=>{if(e.pts)for(let[n,r,i]of[[`b`,e.b,e.pts[0]],[`a`,e.a,e.pts.at(-1)]]){let a=u[r];if(a.kind!==`folder`||!St(a,i))continue;let o=Ct(a,i),s=`${r}|${o}`;V.set(s,[...V.get(s)||[],{k:t,end:n,t:Math.floor(o<2?i[0]:i[1]),count:e.count}])}});let H=new Map;for(let[e,t]of V){let[n,r]=e.split(`|`).map(Number),i=u[n];Ot(i)[r],r<2?i.gx:i.gy,t.sort((e,t)=>e.t-t.t);for(let e=0;e<t.length;){let n=e+1;for(;n<t.length&&t[n].t-t[n-1].t<=B;)n++;let a=t.slice(e,n);if(e=n,a.length<2||a.every(e=>e.t===a[0].t))continue;let o=new Map;for(let e of a)o.set(e.t,(o.get(e.t)||0)+e.count);let s=(a[0].t+a.at(-1).t)/2,c=[...o].filter(([e])=>!bt(i,r,e,x)).reduce((e,t)=>t[1]>e[1]||t[1]===e[1]&&Math.abs(t[0]-s)<Math.abs(e[0]-s)?t:e)[0];for(let e of a)e.t!==c&&H.set(e.k,{...H.get(e.k),[e.end]:{side:r,t:c}})}}if(H.size){b.fill(0),L.forEach((e,t)=>{e.pts&&!H.has(t)&&R(e.pts)});for(let e of I){let t=H.get(e);if(!t)continue;let n=L[e],r=(e,t)=>{if(!St(u[e],t))return;let n=Ct(u[e],t);return{side:n,t:Math.floor(n<2?t[0]:t[1])}},i=z(e,t.a??r(n.a,n.pts.at(-1)),t.b??r(n.b,n.pts[0]));i&&(L[e].pts=i),R(L[e].pts)}}return L}function bt(e,t,n,r){if(e.kind!==`folder`)return!1;let i=t<2?e.gx:e.gy,a=i+(t<2?e.w:e.h);return n+.5-i<r||a-(n+.5)<r}function xt(e,t){return e.kind===`folder`?[[e.gx,e.gy,1,1,5],[e.gx+e.w,e.gy,-1,1,7],[e.gx+e.w,e.gy+e.h,-1,-1,1],[e.gx,e.gy+e.h,1,-1,3]].map(([e,n,r,i,a])=>({out:[Math.floor(e-r*.5),Math.floor(n-i*.5)],in:[Math.floor(e+r*.5),Math.floor(n+i*.5)],dir:a,pt:[e+r*t/2,n+i*t/2]})):[]}function St(e,[t,n]){let r=(e,t)=>Math.abs(e-t)<1e-6;return(r(t,e.gx)||r(t,e.gx+e.w))&&n>=e.gy-1e-6&&n<=e.gy+e.h+1e-6||(r(n,e.gy)||r(n,e.gy+e.h))&&t>=e.gx-1e-6&&t<=e.gx+e.w+1e-6}function Ct(e,[t,n]){let r=(e,t)=>Math.abs(e-t)<1e-6;return r(n,e.gy)?0:r(n,e.gy+e.h)?1:r(t,e.gx)?2:3}function wt(e,t){for(let n=1;n<e.length;n++){let[r,i]=e[n-1],[a,o]=e[n],s=Math.max(1,Math.ceil(Math.max(Math.abs(a-r),Math.abs(o-i))*2));for(let e=0;e<=s;e++)t(Math.floor(r+(a-r)*e/s),Math.floor(i+(o-i)*e/s))}}var Tt={turn45:1.5,turn90:3,diag:1.3,hug:1,centre:1,join:.5,cross:1,haste:1.5,hasteNote:4};function Et(e,t,n=Me(e),r={}){let{turn45:i,turn90:a,diag:o,hug:s,centre:c,join:l,cross:u,haste:d,hasteNote:f}={...Tt,...r},{items:p,links:m}=e,{W:h,H:g,blocked:_,owner:v}=n,y=h*g,b=Math.max(2,Math.round(28/(e.cell??7))),x=kt(n,b),S=10/(e.cell??7),C=new Uint8Array(y);for(let e of t)e.pts&&wt(e.pts,(e,t)=>{e>=0&&t>=0&&e<h&&t<g&&(C[t*h+e]=1)});let w=(e,t)=>e>=0&&t>=0&&e<h&&t<g,T=(e,t)=>{for(;p[e].parent!==t;)e=p[e].parent;return e},E=(e,[t,n])=>{let r=(e,t)=>Math.abs(e-t)<1e-6;if(!St(e,[t,n])){let i=xt(e,S).find(e=>r(e.pt[0],t)&&r(e.pt[1],n));if(i)return[...i.in,i.dir]}return r(t,e.gx)?[e.gx,Math.floor(n),4]:r(t,e.gx+e.w)?[e.gx+e.w-1,Math.floor(n),0]:r(n,e.gy)?[Math.floor(t),e.gy,6]:[Math.floor(t),e.gy+e.h-1,2]},D=(e,t)=>(ht[e]&&gt[e]?Math.SQRT2*o:1)+s*(b-x[t]),O=(e,t)=>{if(e===_t||e===t)return 0;let n=Math.min((t-e+8)%8,(e-t+8)%8);return n===1?i:a*(n>=3?2:1)},k=new Float32Array(y*9+1),A=new Int32Array(y*9+1),j=new Uint32Array(y*9+1),M=y*9,N=0,P=new Float64Array(4096),F=new Float64Array(4096),I=new Int32Array(4096),L=0,R=0,z=0,B=(e,t,n)=>{if(L===P.length){let e=(e,t)=>{let n=new t(e.length*2);return n.set(e),n};P=e(P,Float64Array),F=e(F,Float64Array),I=e(I,Int32Array)}let r=L++;for(;r>0;){let t=r-1>>1;if(P[t]<=e)break;P[r]=P[t],F[r]=F[t],I[r]=I[t],r=t}P[r]=e,F[r]=t,I[r]=n},V=()=>{P[0],R=F[0],z=I[0];let e=P[--L],t=F[L],n=I[L],r=0;for(;;){let t=2*r+1;if(t>=L||(t+1<L&&P[t+1]<P[t]&&t++,P[t]>=e))break;P[r]=P[t],F[r]=F[t],I[r]=I[t],r=t}P[r]=e,F[r]=t,I[r]=n};function H(e,t,n,r,i){N++,L=0;let a=(e,t)=>w(e,t)&&!_[t*h+e]&&v[t*h+e]===n,o=r%h,d=r/h|0,f=(e,t)=>{let n=Math.abs(e-o),r=Math.abs(t-d);return i*(1-l)*(Math.max(n,r)+.414*Math.min(n,r))},p=new Map;if(e.kind===`folder`)for(let t of xt(e,S)){let[n,r]=t.out;if(!a(n,r))continue;let i=r*h+n,o=i*9+t.dir,l=Math.fround(c*Math.min(e.w,e.h)/2+s*(b-x[i]));j[o]===N&&k[o]<=l||(j[o]=N,k[o]=l,A[o]=-1,p.set(i,t.pt),B(l+f(n,r),l,o))}for(Ot(e).forEach((t,n)=>t.cells.forEach(([r,i])=>{if(!a(r,i)||bt(e,n,t.dir===6||t.dir===2?r:i,S))return;let o=t.dir===6||t.dir===2?r:i,l=i*h+r,u=l*9+t.dir,d=Math.fround(c*Math.abs(o+.5-t.mid)+s*(b-x[l]));j[u]===N&&k[u]<=d||(j[u]=N,k[u]=d,A[u]=-1,p.set(l,t.wall(o)),B(d+f(r,i),d,u))}));L;){V();let e=z,n=R;if(e===M)break;if(n!==k[e])continue;let r=e/9|0,i=e%9,o=r%h,s=r/h|0,c=t.get(r);if(c){let t=n+c.rest+O(i,c.dir);(j[M]!==N||t<k[M])&&(j[M]=N,k[M]=t,A[M]=e,B(t,t,M))}for(let t=0;t<8;t++){let r=o+ht[t],c=s+gt[t];if(!a(r,c)||ht[t]&&gt[t]&&(!a(r,s)||!a(o,c)))continue;let l=c*h+r,d=l*9+t,p=Math.fround(n+D(t,l)+(C[l]?u:0)+O(i,t));j[d]===N&&k[d]<=p||(j[d]=N,k[d]=p,A[d]=e,B(p+f(r,c),p,d))}}if(j[M]!==N)return null;let m=[];for(let e=A[M];e!==-1;e=A[e])m.push(e/9|0);return m.reverse(),{cells:m,pts:[p.get(m[0]),...m.map(e=>[e%h+.5,Math.floor(e/h)+.5]),t.get(m.at(-1)).pt]}}let U=[];t.forEach((e,t)=>{if(!e.pts)return;let n=p[e.a].parent,r=m.filter(t=>t.s>=2&&t.level===n&&T(t.a,n)===e.a&&T(t.b,n)===e.b);p[e.a].kind===`folder`&&U.push({folder:e.a,at:e.pts[e.pts.length-1],notes:r.map(e=>e.a),trunk:t}),p[e.b].kind===`folder`&&U.push({folder:e.b,at:e.pts[0],notes:r.map(e=>e.b),trunk:t})});let ee=[],W=e=>p[e].kind===`note`,G=new Map;for(let e=0;e<U.length;e++){let{folder:t,at:n,notes:r,trunk:i}=U[e],[a,c,u]=E(p[t],n);if(!w(a,c)||_[c*h+a])continue;let m=c*h+a,g={dir:u,rest:0,pt:n};G.has(m)||G.set(m,{ends:new Map([[m,g]]),endsAny:new Map([[m,g]]),owners:new Map([[m,-1]]),exits:new Map});let{ends:v,endsAny:y,owners:S,exits:C}=G.get(m),D=new Map;for(let e of r){let n=T(e,t);D.set(n,[...D.get(n)||[],e])}for(let[e,n]of[...D].sort((e,t)=>W(e[0])-W(t[0])||t[1].length-e[1].length||e[0]-t[0])){let r=W(e),a=C.get(e),c=r?y:v,u=a&&c.has(a.cell)?{cells:[a.cell],pts:[a.wall,c.get(a.cell).pt,c.get(a.cell).pt]}:H(p[e],c,t,m,r?f:d);if(!u)continue;a||C.set(e,{cell:u.cells[0],wall:u.pts[0]});let g=ee.length,_=u.cells.at(-1);ee.push({item:e,folder:t,trunk:i,count:n.length,pts:u.pts,cells:u.cells,leaf:r,via:S.get(_)??-1});let w=new Float32Array(u.cells.length);w[w.length-1]=y.get(_).rest;for(let e=u.cells.length-2;e>=0;e--){let t=u.cells[e],n=u.cells[e+1],r=t%h!==n%h&&Math.floor(t/h)!==Math.floor(n/h);w[e]=w[e+1]+(1-l)*((r?Math.SQRT2*o:1)+s*(b-x[n]))}for(let[e,t]of u.cells.entries()){if(y.has(t))continue;let n=u.cells[e+1],i={dir:n===void 0?y.get(_).dir:Dt(n%h-t%h,Math.floor(n/h)-Math.floor(t/h)),rest:w[e],pt:[t%h+.5,Math.floor(t/h)+.5]};y.set(t,i),S.set(t,g),r||v.set(t,i)}r||U.push({folder:e,at:u.pts[0],notes:n,trunk:i})}}return dt(ee,y),ee.map(({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s})=>({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s}))}var Dt=(e,t)=>ht.findIndex((n,r)=>n===Math.sign(e)&&gt[r]===Math.sign(t));function Ot(e){return[{dir:6,cells:At(e.gx,e.gx+e.w).map(t=>[t,e.gy-1]),mid:e.gx+e.w/2,wall:t=>[t+.5,e.gy]},{dir:2,cells:At(e.gx,e.gx+e.w).map(t=>[t,e.gy+e.h]),mid:e.gx+e.w/2,wall:t=>[t+.5,e.gy+e.h]},{dir:4,cells:At(e.gy,e.gy+e.h).map(t=>[e.gx-1,t]),mid:e.gy+e.h/2,wall:t=>[e.gx,t+.5]},{dir:0,cells:At(e.gy,e.gy+e.h).map(t=>[e.gx+e.w,t]),mid:e.gy+e.h/2,wall:t=>[e.gx+e.w,t+.5]}]}function kt({W:e,H:t,blocked:n,owner:r},i){let a=e*t,o=new Uint8Array(a).fill(i),s=new Int32Array(a),c=0,l=0;for(let i=0;i<a;i++){if(n[i]){o[i]=0;continue}let a=i%e,c=i/e|0;for(let u=0;u<8;u++){let d=a+ht[u],f=c+gt[u];if(d<0||f<0||d>=e||f>=t)continue;let p=f*e+d;if(n[p]||r[p]!==r[i]){o[i]=1,s[l++]=i;break}}}for(;c<l;){let a=s[c++],u=a%e,d=a/e|0;if(!(o[a]+1>=i))for(let i=0;i<8;i++){let c=u+ht[i],f=d+gt[i];if(c<0||f<0||c>=e||f>=t)continue;let p=f*e+c;o[p]>o[a]+1&&!n[p]&&r[p]===r[a]&&(o[p]=o[a]+1,s[l++]=p)}}return o}var At=(e,t)=>Array.from({length:Math.max(0,t-e)},(t,n)=>e+n);function jt(e,t){let n=10/(e.cell??7),r=e.items.filter(e=>e.kind===`folder`),i=(e,t)=>Math.abs(e-t)<1e-6,a=(e,t)=>{for(let a of r){let r=i(e[0],a.gx)||i(e[0],a.gx+a.w),o=i(e[1],a.gy)||i(e[1],a.gy+a.h);if(!(r&&e[1]>=a.gy-1e-6&&e[1]<=a.gy+a.h+1e-6)&&!(o&&e[0]>=a.gx-1e-6&&e[0]<=a.gx+a.w+1e-6))continue;let s=e[0]-a.gx<a.w/2?1:-1,c=e[1]-a.gy<a.h/2?1:-1,l=s>0?a.gx:a.gx+a.w,u=c>0?a.gy:a.gy+a.h;if(Math.abs(e[0]-l)+Math.abs(e[1]-u)>=n-1e-6)return null;let d=[l+s*n/2,u+c*n/2],f=t[0]>a.gx&&t[0]<a.gx+a.w&&t[1]>a.gy&&t[1]<a.gy+a.h?[s,c]:[-s,-c],p=t[0]-d[0],m=t[1]-d[1];if(Math.abs(Math.abs(p)-Math.abs(m))<1e-6&&p*f[0]>0)return[d];let h=[p/f[0],m/f[1]].filter(e=>e>1e-6).sort((e,t)=>e-t);return h.length?[d,[d[0]+f[0]*h[0],d[1]+f[1]*h[0]]]:null}return null};for(let e of t){if(!e.pts||e.pts.length<2)continue;let t=a(e.pts[0],e.pts[1]);t&&(e.pts=[...t,...e.pts.slice(1)]);let n=a(e.pts.at(-1),e.pts.at(-2));n&&(e.pts=[...e.pts.slice(0,-1),...n.reverse()])}return t}function Mt(e,t=!1){let n=e=>e.kind===`dir`?{kind:`dir`,id:e.id,ref:e.ref,children:e.children.map(n)}:{kind:e.kind,id:e.id,ref:e.ref,weight:e.weight,rank:e.rank||0};if(t){let t=[],r=e=>{e.kind===`dir`?e.children.forEach(r):t.push(n(e))};return r(e.root),{root:{kind:`dir`,id:e.root.id,ref:e.root.ref,children:t},edges:e.edges,code:!1}}return{root:n(e.root),edges:e.edges,code:!!e.code}}function Nt(e,t){let n={flow:t.gridFlow===`right`?`right`:`up`,grain:Rt(t),plan:!!t.blocks},r=tt(e,n);if(t.blocks){let t=Pt(r,yt(r,Me(r)));[...t.values()].some(e=>e.wider.size)&&(r=tt(e,{...n,planned:t}))}r.feeders=Ft(r);let i=Me(r),a=yt(r,i),o=Et(r,a,i);return jt(r,[...a,...o]),r.highways={trunks:a,feeders:o},r}function Pt(e,t){let{items:n}=e,r=e.cell>7?2:3,i=new Map;for(let[a,o]of e.pairs??[]){let e=a===``?-1:n.findIndex(e=>e.kind===`folder`&&e.ref===a),s=n.map((e,t)=>t).filter(t=>n[t].parent===e),c=t.filter(t=>t.pts&&n[t.a].parent===e),l=new Map;for(let e of s)for(let t of s){if(e>=t)continue;let i=n[e],a=n[t],[o,s]=i.gx<=a.gx?[i,a]:[a,i],[u,d]=i.gy<=a.gy?[i,a]:[a,i],f=s.gx-(o.gx+o.w),p=d.gy-(u.gy+u.h),m=null,h=!1;if(f>0&&f<=16&&Math.min(i.gy+i.h,a.gy+a.h)-Math.max(i.gy,a.gy)>=4?(m=[o.gx+o.w,Math.max(i.gy,a.gy),s.gx,Math.min(i.gy+i.h,a.gy+a.h)],h=!0):p>0&&p<=16&&Math.min(i.gx+i.w,a.gx+a.w)-Math.max(i.gx,a.gx)>=4&&(m=[Math.max(i.gx,a.gx),u.gy+u.h,Math.min(i.gx+i.w,a.gx+a.w),d.gy]),!m)continue;let g=new Map;for(let e of c)for(let t=1;t<e.pts.length;t++){let[n,r]=e.pts[t-1],[i,a]=e.pts[t],o=Math.max(1,Math.ceil(Math.max(Math.abs(i-n),Math.abs(a-r))));for(let e=0;e<=o;e++){let t=Math.floor(n+(i-n)*e/o),s=Math.floor(r+(a-r)*e/o);if(t<m[0]||t>=m[2]||s<m[1]||s>=m[3])continue;let c=h?t:s;g.has(c)||g.set(c,new Set),g.get(c).add(h?s:t)}}let _=[...g.values()].filter(e=>e.size>=4).length;_>1&&l.set([i.ref,a.ref].sort().join(`|`),r*(_-1))}i.set(a,{pair:o,wider:l})}return i}function Ft(e,t=e.trunks){let{items:n,links:r,W:i}=e;if(!t.some(e=>e.pts&&(n[e.a].kind===`folder`||n[e.b].kind===`folder`)))return[];let a=Me(e),o=lt(e,a,{crowd:1,haste:1.5});for(let e of t)e.pts&&o.occupy(e.pts);let s=(e,t)=>{for(;n[e].parent!==t;)e=n[e].parent;return e},c=(e,[t,r])=>{let i=n[e],a=(e,t)=>Math.abs(e-t)<1e-6;return a(t,i.gx)?[i.gx,Math.floor(r)]:a(t,i.gx+i.w)?[i.gx+i.w-1,Math.floor(r)]:a(r,i.gy)?[Math.floor(t),i.gy]:[Math.floor(t),i.gy+i.h-1]},l=[];t.forEach((e,t)=>{if(!e.pts)return;let i=n[e.a].parent,a=r.filter(t=>t.s>=2&&t.level===i&&s(t.a,i)===e.a&&s(t.b,i)===e.b);n[e.a].kind===`folder`&&l.push({folder:e.a,at:e.pts[e.pts.length-1],notes:a.map(e=>e.a),trunk:t}),n[e.b].kind===`folder`&&l.push({folder:e.b,at:e.pts[0],notes:a.map(e=>e.b),trunk:t})});let u=[];for(let e=0;e<l.length;e++){let{folder:t,at:r,notes:d,trunk:f}=l[e],[p,m]=c(t,r);if(p<0||m<0||p>=i||a.blocked[m*i+p])continue;let h=new Map;for(let e of d){let n=s(e,t);h.set(n,[...h.get(n)||[],e])}let g=m*i+p,_=e=>n[e].kind===`note`,v=new Map([[g,[g,r[0],r[1]]]]),y=new Map(v),b=new Map([[g,-1]]);for(let[e,n]of[...h].sort((e,t)=>_(e[0])-_(t[0])||t[1].length-e[1].length||e[0]-t[0])){let r=_(e),s=o.routeTo(e,{ends:r?y:v,folder:t,toward:g});if(!s)continue;let c=u.length;u.push({item:e,folder:t,trunk:f,count:n.length,pts:s.pts,cells:s.cells,leaf:r,via:b.get(s.cells[s.cells.length-1])??-1});let d=new Float32Array(s.cells.length);d[d.length-1]=y.get(s.cells[s.cells.length-1])?.[3]??0;for(let e=s.cells.length-2;e>=0;e--){let t=s.cells[e],n=s.cells[e+1];d[e]=d[e+1]+(t%i!==n%i&&Math.floor(t/i)!==Math.floor(n/i)?Math.SQRT2:1)+(a.close[n]?it.hug:0)}for(let[e,t]of s.cells.entries()){if(y.has(t))continue;let n=[t,t%i+.5,Math.floor(t/i)+.5,d[e]];y.set(t,n),b.set(t,c),r||v.set(t,n)}r||l.push({folder:e,at:s.pts[0],notes:n,trunk:f})}}return dt(u,a.W*a.H),u.map(({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s})=>({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s}))}function It(e){let t=Me(e),n=lt(e,t);return e=>mt(n,e,t.W,t.H)}function Lt(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}var Rt=e=>e.grain===`coarse`||e.grain===`coarser`?e.grain:`fine`;function zt(e,t={}){return Lt(JSON.stringify([12,t.gridFlow===`right`?`right`:`up`,Rt(t),!!t.blocks,e]))}var Bt,Vt=1,Ht=new Map;function Ut(e){if(Bt===void 0)try{Bt=new Worker(new URL(new URL(`../workers/worker-d9GxGKde.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),Bt.onmessage=({data:e})=>{let t=Ht.get(e.id);Ht.delete(e.id),e.error===void 0?t?.resolve(e.result):t?.reject(Error(e.error))},Bt.onerror=()=>{for(let e of Ht.values())e.reject(Error(`the layout worker stopped`));Ht.clear(),Bt=null}}catch{Bt=null}if(!Bt)return Promise.reject(Error(`no worker`));let t=Vt++;return new Promise((n,r)=>{Ht.set(t,{resolve:n,reject:r}),Bt.postMessage({id:t,...e})})}var Wt=new Map,Gt=new Map,Kt=``;async function qt(e,t){let n=Mt(e),r=zt(n,t),i=Wt.get(r);return i||(i=await Ut({layout:{model:n,o:t}}).catch(()=>Nt(n,t)),Wt.size>=6&&Wt.delete(Wt.keys().next().value),Wt.set(r,i)),{key:r,layout:i}}async function Jt(e,t,n){if(!n.length)return[];let r=()=>{let r=Gt.get(e);return r||(Gt.clear(),Gt.set(e,r=It(t))),r(n)},i=Kt!==e;return Kt=e,(await Ut({routes:{key:e,layout:i?t:null,asks:n}}).catch(()=>Ut({routes:{key:e,layout:t,asks:n}})).catch(r)).routes.map(e=>e?.pts??null)}var Yt=e(`<b class="num svelte-m50bdg"> </b>`),Xt=e(`<a><span class="t svelte-m50bdg"> </span><!></a>`);function Zt(e,i){_(i,!0);let a=x(i,`mark`,3,``),c=x(i,`far`,3,0),l=x(i,`num`,3,0),f=x(i,`iso`,3,``),m=x(i,`linked`,3,!1),g=x(i,`dim`,3,!1),v=x(i,`moment`,3,``);var y=Xt();let C;var w=s(y),D=o(w,!0),O=h(w),A=e=>{var t=Yt(),r=o(t,!0);p(()=>n(r,l())),u(e,t)};t(O,e=>{l()&&e(A)}),T(y),p(e=>{C=b(y,1,`n s${i.step??``} ${v()?`mo-${v()}`:``} ${f()?`p-${f()}`:``} ${a()??``}`,`svelte-m50bdg`,C,{linked:m(),dim:g()&&!l()&&!f()&&!m(),far:c()>1,pick:l()>0}),k(y,`href`,i.href),k(y,`aria-label`,l()?`${i.title}: linked, number ${l()}`:i.title),k(y,`data-note`,i.item.ref),E(y,`--x:${i.item.gx??``};--y:${i.item.gy??``};--w:${i.item.w??``};--h:${i.item.h??``};--lit:${e??``}%`),n(D,i.title)},[()=>Math.max(34,100-(c()-1)*20)]),d(`click`,y,function(...e){i.onpick?.apply(this,e)}),r(`pointerenter`,y,e=>{e.pointerType===`mouse`&&i.onpoint(!0)}),r(`pointerleave`,y,e=>{e.pointerType===`mouse`&&i.onpoint(!1)}),r(`focus`,y,()=>i.onpoint(!0)),r(`blur`,y,()=>i.onpoint(!1)),u(e,y),S()}l([`click`]);var Qt=e(`<button class="frame-title svelte-ywp27z" type="button"> </button>`),$t=e(`<span class="frame-title held svelte-ywp27z"> </span>`),en=e(`<div><!> <!></div>`),tn=e(`<button type="button"><span class="name svelte-ywp27z"> </span><span class="label svelte-ywp27z"> </span></button>`);function nn(e,r){_(r,!0);let i=x(r,`titled`,3,!0),c=x(r,`held`,19,()=>({req:0,bld:0})),l=x(r,`dim`,3,!1),f=v(()=>r.item.depth%2?`var(--ground-1)`:`var(--ground-0)`),m=v(()=>r.item.depth%2?`var(--ground-0)`:`var(--ground-1)`),g=v(()=>c().req?`req`:c().bld?`bld`:``),y=v(()=>[c().req?`${c().req} required here`:``,c().bld?`${c().bld} ${c().bld===1?`builds`:`build`} on it`:``].filter(Boolean).join(` · `)),C=v(()=>`--x:${r.item.gx};--y:${r.item.gy};--w:${r.item.w};--h:${r.item.h}`);var O=w(),A=D(O),j=e=>{var c=en(),l=s(c),_=e=>{var t=Qt(),i=o(t,!0);p(()=>n(i,r.name)),d(`click`,t,function(...e){r.onpick?.apply(this,e)}),u(e,t)};t(l,e=>{i()&&e(_)});var v=h(l,2),x=e=>{var t=$t(),r=o(t,!0);p(()=>n(r,a(y))),u(e,t)};t(v,e=>{a(y)&&e(x)}),T(c),p(()=>{b(c,1,`folder frame ${a(g)??``}`,`svelte-ywp27z`),k(c,`data-folder`,r.item.ref),E(c,`${a(C)??``};--inside:${a(f)??``};--behind:${a(m)??``};--ground-here:${a(f)??``}`)}),u(e,c)},M=e=>{var t=tn();let i;var c=s(t),f=o(c,!0),m=h(c),_=o(m,!0);T(t),p(()=>{i=b(t,1,`folder frame closed ${a(g)??``}`,`svelte-ywp27z`,i,{dim:l()}),k(t,`data-folder`,r.item.ref),E(t,a(C)),n(f,r.name),n(_,a(y)||`${r.count} ${r.count===1?`note`:`notes`}`)}),d(`click`,t,function(...e){r.onpick?.apply(this,e)}),u(e,t)};t(A,e=>{r.open?e(j):e(M,-1)}),u(e,O),S()}l([`click`]);var rn=C(`<path></path>`),an=C(`<path class="sent svelte-k96fgh"></path>`),on=C(`<svg class="routes svelte-k96fgh" aria-hidden="true"><g><!><!><!></g></svg>`);function sn(e,t){_(t,!0);let n=x(t,`sent`,19,()=>[]);var r=on(),i=s(r),o=s(i);A(o,17,()=>t.rest,e=>e.key,(e,t)=>{var n=rn();let r;p(()=>{r=b(n,0,y(a(t).study?`study`:a(t).strong?`base`:`base weak`),`svelte-k96fgh`,r,{trunk:a(t).trunk&&!a(t).study}),k(n,`d`,a(t).d)}),u(e,n)});var c=h(o);A(c,17,n,e=>e.key,(e,t)=>{var n=an();p(()=>k(n,`d`,a(t).d)),u(e,n)});var l=h(c);A(l,17,()=>t.hot,e=>e.key,(e,t)=>{var n=rn();let r;p(()=>{r=b(n,0,`lit ${a(t).kind??``}`,`svelte-k96fgh`,r,{still:a(t).still}),k(n,`d`,a(t).d)}),u(e,n)}),T(i),T(r),p(()=>{k(r,`data-requires`,t.counts.requires),k(r,`data-builds`,t.counts.builds),k(r,`data-uses`,t.counts.uses),k(i,`transform`,`scale(${t.k??``})`)}),u(e,r),S()}var cn=e(`<span class="name svelte-1hqh0lc"> </span> <svg aria-hidden="true" class="svelte-1hqh0lc"><path class="svelte-1hqh0lc"></path></svg>`,1),ln=e(`<div class="folder frame svelte-1hqh0lc"><button class="band svelte-1hqh0lc" type="button"><!></button></div>`),un=e(`<button class="folder frame closed svelte-1hqh0lc" type="button"><span class="band svelte-1hqh0lc"><!></span> <span class="label svelte-1hqh0lc"> </span></button>`);function dn(e,r){_(r,!0);let i=e=>{var t=cn(),i=D(t),s=o(i),l=h(i,2),d=o(l);p(()=>{n(s,`study · ${r.name??``}`),k(l,`viewBox`,a(m).viewBox),k(l,`data-passes`,c()),E(l,`width:${16*a(m).ratio}px`),k(d,`d`,a(m).d)}),u(e,t)},c=x(r,`passes`,3,0),l=v(()=>r.item.depth%2?`var(--ground-1)`:`var(--ground-0)`),f=v(()=>`--x:${r.item.gx};--y:${r.item.gy};--w:${r.item.w};--h:${r.item.h}`),m=v(()=>ee([...r.item.ref].reduce((e,t)=>(e*31+t.charCodeAt(0))%99991,7),c()?Math.min(c()+1,4):0));var g=w(),y=D(g),b=e=>{var t=ln(),n=s(t),o=s(n);i(o),T(n),T(t),p(()=>{k(t,`data-folder`,r.item.ref),E(t,`${a(f)??``};--inside:${a(l)??``};--ground-here:${a(l)??``}`)}),d(`click`,n,function(...e){r.onpick?.apply(this,e)}),u(e,t)},C=e=>{var t=un(),c=s(t),m=s(c);i(m),T(c);var g=h(c,2),_=o(g);T(t),p(()=>{k(t,`data-folder`,r.item.ref),E(t,`${a(f)??``};--inside:${a(l)??``}`),n(_,`${r.count??``} ${r.count===1?`item`:`items`}`)}),d(`click`,t,function(...e){r.onpick?.apply(this,e)}),u(e,t)};t(y,e=>{r.open?e(b):e(C,-1)}),u(e,g),S()}l([`click`]);var fn=e(`<a><span class="frame-title kind svelte-9q9bch"> </span><span class="t svelte-9q9bch"> </span></a>`);function pn(e,t){_(t,!0);let i=x(t,`mark`,3,``),a=x(t,`dim`,3,!1),c=x(t,`moment`,3,``);var l=fn();let f;var m=s(l),g=o(m,!0),v=h(m),y=o(v,!0);T(l),p(()=>{f=b(l,1,`sn frame ${i()??``} ${c()?`mo-${c()}`:``}`,`svelte-9q9bch`,f,{dim:a()}),k(l,`href`,t.href),k(l,`aria-label`,`${t.kind??``}: ${t.title??``}`),k(l,`data-note`,t.item.ref),E(l,`--x:${t.item.gx??``};--y:${t.item.gy??``};--w:${t.item.w??``};--h:${t.item.h??``}`),n(g,t.kind),n(y,t.title)}),d(`click`,l,function(...e){t.onpick?.apply(this,e)}),r(`pointerenter`,l,e=>{e.pointerType===`mouse`&&t.onpoint(!0)}),r(`pointerleave`,l,e=>{e.pointerType===`mouse`&&t.onpoint(!1)}),r(`focus`,l,()=>t.onpoint(!0)),r(`blur`,l,()=>t.onpoint(!1)),u(e,l),S()}l([`click`]);var mn=e(`<p class="said svelte-14y1y1z"> </p>`),hn=e(`<p class="said faint svelte-14y1y1z">There are no notes yet. The map draws itself as you write them.</p>`),gn=e(`<span> </span>`),_n=e(`<a class="eph svelte-14y1y1z"><span class="t svelte-14y1y1z"> </span></a>`),vn=e(`Iso is reading <span class="c-gold svelte-14y1y1z"> </span>`,1),yn=e(`<svg class="loader svelte-14y1y1z" aria-hidden="true"><path d="M0 1H1000" class="svelte-14y1y1z"></path></svg> <p class="doing svelte-14y1y1z" role="status"><i class="dia svelte-14y1y1z" aria-hidden="true"></i><!></p>`,1),bn=e(`<div><!> <!></div>`),xn=e(`<span class="svelte-14y1y1z"><i class="dia" aria-hidden="true"></i>a new note</span>`),Sn=e(`<div><svg aria-hidden="true" class="svelte-14y1y1z"><rect x="1" y="1" width="100%" height="100%" class="svelte-14y1y1z"></rect></svg> <!></div>`),Cn=e(`<p class="notice svelte-14y1y1z" role="alert"> </p>`),wn=e(`<!> <div><!> <!> <!> <!> <!> <!></div> <!>`,1),Tn=e(`<div role="application" aria-label="The atlas: the map of the base" tabindex="0"><!></div>`);function En(e,l){_(l,!0);let y=x(l,`pick`,3,``),C=x(l,`moment`,3,null),F=f(null),L=f(null),R=f(``),z=f({x:0,y:0,k:1}),B=f({w:0,h:0}),V=f(``),H=f([]),U=v(()=>a(H).at(-1)??``),ee=f(!1),W=f(void 0),G=[`fine`,`coarse`,`coarser`],K=f(m(G.find(e=>e===de(`isorite.atlas.grain`))??`fine`)),oe=f(de(`isorite.atlas.leaves`)===`on`),se=!1,ce=window.innerWidth>=window.innerHeight?`right`:`up`;function de(e){try{return localStorage.getItem(e)}catch{return null}}function fe(){g(K,G[(G.indexOf(a(K))+1)%G.length],!0),se=!1;try{localStorage.setItem(`isorite.atlas.grain`,a(K))}catch{}ge()}function pe(e){g(oe,e,!0);try{localStorage.setItem(`isorite.atlas.leaves`,e?`on`:`off`)}catch{}}async function ge(){try{let e=await P.api.map(),t=await qt(e.model,{gridFlow:ce,grain:a(K),blocks:!0}),n=!a(L)||a(L).key!==t.key&&!se;g(F,e),g(L,t),g(R,``),n&&a(B).w&&g(z,Ce())}catch(e){g(R,e.message,!0)}}i(()=>{ge();let e,t=P.on(t=>{(t.type===`note-changed`||t.type===`record`)&&(clearTimeout(e),e=setTimeout(()=>{ge()},400))});return()=>{t(),clearTimeout(e)}});let J=v(()=>a(L)?ve(a(L).layout):null),Y=v(()=>a(J)?_e(a(J)):null),Se=v(()=>a(J)?ye(a(J),a(z).k):``),Ce=()=>{let e=(a(J)?.margin??0)/2,t={gx:e,gy:e,w:(a(J)?.W??1)-2*e,h:(a(J)?.H??1)-2*e},n=a(Q)?.draft?a(Q):null;if(n&&a(J)){let e=Math.max(t.gx+t.w,n.gx+Math.max(n.w,240/a(J).cell)+2),r=Math.max(t.gy+t.h,n.gy+n.h+70/a(J).cell);t.gx=Math.min(t.gx,n.gx-2),t.gy=Math.min(t.gy,n.gy-2),t.w=e-t.gx,t.h=r-t.gy}return ke(t,a(B).w,a(B).h,1,a(J)?.cell)};i(()=>{if(!a(W))return;let e=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect,r=!a(B).w;g(B,{w:t,h:n}),r&&a(J)&&g(z,Ce())});return e.observe(a(W)),()=>e.disconnect()});let Ee=v(()=>a(J)?a(J).items.flatMap((e,t)=>e.kind===`folder`&&a(Se)[t]!==`-`?[{item:e,i:t,open:a(Se)[t]===`o`}]:[]):[]),je=v(()=>a(J)?a(J).items.flatMap((e,t)=>e.kind===`note`&&a(Se)[t]===`s`?[{item:e,i:t}]:[]):[]),Me=v(()=>a(J)?we(xe(a(J),a(Se),a(Y).strong,a(oe))).map(e=>({key:e.key,pts:e.pts,d:De(e.pts,0,a(J).cell),count:e.count,study:e.study,strong:e.strong,trunk:e.trunk,...Ne(e)})).map((e,t,n)=>({...e,label:e.label&&!n.some((n,r)=>r!==t&&n.label&&n.count===e.count&&Math.hypot(n.mid[0]-e.mid[0],n.mid[1]-e.mid[1])<10&&(n.length>e.length||n.length===e.length&&r<t))})):[]);function Ne(e){let t=e.pts[0],n=t,r=0;for(let i=1,a=0;i<e.pts.length;i++){let o=e.pts[i-1],s=e.pts[i],c=e.pts[i+1];if(c&&Math.abs((s[0]-o[0])*(c[1]-s[1])-(s[1]-o[1])*(c[0]-s[0]))<1e-6&&(s[0]-o[0])*(c[0]-s[0])+(s[1]-o[1])*(c[1]-s[1])>0)continue;let l=e.pts[a],u=Math.hypot(s[0]-l[0],s[1]-l[1]);u>r&&(r=u,t=l,n=s),a=i}return{label:e.trunk&&e.count>1&&r>=3,mid:[(t[0]+n[0])/2,(t[1]+n[1])/2],side:Math.abs(t[0]-n[0])<1e-6?`right`:`above`,length:r}}let Pe=v(()=>y()?``:a(U)||a(V)),X=v(()=>a(Pe)&&a(F)&&a(Y)?.at.has(a(Pe))?I(a(F).model,a(Pe)):null),Fe=v(()=>{let e=new Map;if(!a(X))return e;for(let t of a(X).also)e.set(t,{mark:`also`,far:0});for(let t of a(X).uses)e.set(t,{mark:`use`,far:0});for(let t of a(X).builds)e.set(t,{mark:`bld`,far:0});for(let t of a(X).requires)e.set(t,{mark:`req`,far:a(X).depth[t]??1});for(let t of a(H))e.set(t,{mark:`req`,far:1});return e.set(a(Pe),{mark:`at`,far:0}),e}),Ie=v(()=>{if(!a(X))return[];let e=a(H).slice(1).map((e,t)=>({from:a(H)[t],to:e,kind:`requires`})),t=a(H).at(-2);return[...e,...a(X).links.filter(e=>e.kind===`requires`?a(ee)?!e.spare:e.from===a(Pe):e.kind!==`builds`||e.from!==t)]}),Le=v(()=>{let e=new Map;if(!a(X)||!a(Y))return e;let t=new Set(a(Y).up[a(Y).at.get(a(Pe))]),n=(n,r)=>{for(let i of n)for(let n of a(Y).up[a(Y).at.get(i)??-1]??[]){if(t.has(n))break;let i=e.get(n)??{req:0,bld:0};i[r]++,e.set(n,i)}};return n(a(X).requires,`req`),n(a(X).builds,`bld`),e}),Re=(e,t)=>{let n=a(Le).get(e),r=a(J).items[e].parent;return n&&(!t||r<0||!a(Le).has(r))?n:{req:0,bld:0}},ze=f([]),Be=f({requires:0,builds:0,uses:0});function Ve(e,t){if(!e.length||!a(J)||!a(Y)||!a(L)){t([],[]);return}let n=e.flatMap(e=>{let t=a(Y).at.get(e.from),n=a(Y).at.get(e.to);return t===void 0||n===void 0?[]:[{a:t,b:n,kind:e.kind}]}),{fixed:r,asks:i}=Te(a(J),a(Y),a(Se),n),o=e=>t(we(e,!0).map(e=>({key:e.key,kind:e.kind,d:De(e.pts,0,a(J).cell),count:e.count,still:!e.flow})),e);if(o(r),!i.length)return;let s=!1;return Jt(a(L).key,a(J),i.map(({a:e,b:t})=>({a:e,b:t}))).then(e=>{s||o([...r,...i.flatMap((t,n)=>e[n]?[{key:t.key,kind:t.kind,pts:[...e[n]].reverse()}]:[])])}).catch(()=>void 0),()=>{s=!0}}i(()=>Ve(a(Ie),(e,t)=>{g(ze,e),g(Be,{requires:t.filter(e=>e.kind===`requires`).length,builds:t.filter(e=>e.kind===`builds`).length,uses:t.filter(e=>e.kind===`uses`).length})}));let Z=v(()=>y()?null:P.iso),He=v(()=>a(Z)?.state===`reading`||a(Z)?.state===`writing`),Ue=v(()=>{let e=new Map;for(let t of a(Z)?.steps??[])t.opened&&!t.failed&&!e.has(t.opened)&&e.set(t.opened,t.how);return e}),We=v(()=>a(He)?a(Z).steps.findLast(e=>e.opened&&!e.failed)?.opened??``:``),Ge=v(()=>(a(Z)?.steps??[]).flatMap(e=>e.how===`link`&&e.from&&e.opened&&!e.failed?[{from:e.opened,to:e.from,kind:`iso`}]:[])),Ke=f([]);i(()=>Ve(a(Ge),e=>{g(Ke,e)}));let qe=f(null);i(()=>{let e=a(Z)?.note??``;if(g(qe,null),!e.startsWith(`@draft/`))return;let t=!1;return P.api.readNote(e).then(e=>{t||g(qe,e)},()=>void 0),()=>{t=!0}});let Q=v(()=>{if(!a(Z)||!a(J)||!a(Y))return null;if(!a(Z).note.startsWith(`@draft/`)){let e=a(Y).at.get(a(Z).note);if(e===void 0)return null;let t=a(J).items[be(a(Y),a(Se),e)];return{gx:t.gx,gy:t.gy,w:t.w,h:t.h,draft:!1,title:ct(a(Z).note)}}let e=Math.round(126/a(J).cell),t=Math.round(35/a(J).cell),n=a(qe)?ae(a(qe).text)||`a new note`:``,r=le(a(Z).note),i=r?{gx:Math.round(r.gx*7/a(J).cell),gy:Math.round(r.gy*7/a(J).cell)}:null;if(i&&!a(J).items.some(n=>n.kind===`note`&&i.gx<n.gx+n.w+1&&n.gx<i.gx+e+1&&i.gy<n.gy+n.h+1&&n.gy<i.gy+t+1))return{...i,w:e,h:t,draft:!0,title:n};let o=a(J).items.filter(e=>e.parent<0),s=Math.max(...o.map(e=>e.gx+e.w)),c=Math.max(...o.map(e=>e.gy+e.h)),l=Math.round(84/a(J).cell);return ce===`right`?{gx:s+l,gy:Math.round((a(J).H-t)/2),w:e,h:t,draft:!0,title:n}:{gx:Math.round((a(J).W-e)/2),gy:c+l,w:e,h:t,draft:!0,title:n}}),Je=v(()=>a(qe)?te(a(qe).text).filter(e=>a(F)?.notes[e]):[]),Ye=v(()=>!a(Q)?.draft||!a(J)||!a(Y)?[]:a(Je).flatMap(e=>{let t=a(Y).at.get(e);if(t===void 0)return[];let n=a(J).items[be(a(Y),a(Se),t)],r=a(Q),i=n.gx+n.w/2-(r.gx+r.w/2),o=n.gy+n.h/2-(r.gy+r.h/2),s=5/18*Math.abs(i)>=Math.abs(o);return[{key:e,d:De(Oe(s?[i<0?r.gx:r.gx+r.w,r.gy+r.h/2]:[r.gx+r.w/2,o<0?r.gy:r.gy+r.h],s?[i<0?n.gx+n.w:n.gx,n.gy+n.h/2]:[n.gx+n.w/2,o<0?n.gy+n.h:n.gy],s),0,a(J).cell)}]})),Xe=e=>{if(e===a(We))return`used`;let t=a(Ue).get(e);return t===`keyword`?`key`:t===`meaning`?`sem`:t?`link`:``};i(()=>{let e=a(Z);e&&e.request===P.watching&&e.state!==`reading`&&e.state!==`writing`&&(P.watching=``,e.state===`done`&&M(j(`/draft/[id]`,{id:e.note.slice(7)})))});let Ze=``;i(()=>{a(Q)?.draft&&a(Z)&&Ze!==a(Z).request&&a(B).w&&(Ze=a(Z).request,se||g(z,Ce()))});let $=f(null),Qe=f(``);i(()=>{if(g($,null),g(Qe,``),!y())return;let e=!1;return P.api.readNote(y()).then(t=>{e||g($,t)},()=>{e||g(Qe,`that note for Iso is not here any more`)}),()=>{e=!0}});let $e=v(()=>a($)?(re(a($).text)??te(a($).text)).filter(e=>a(F)?.notes[e]&&!e.startsWith(`@`)):[]),et=Promise.resolve();function tt(e){et=et.then(async()=>{if(!a($)||e.startsWith(`@`))return;let t=t=>re(t)?ie(t,e):te(t).includes(e)?ne(t,e):q(t,e,ct(e)),n=t(a($).text);if(n===null)g(Qe,`linked in what you wrote: take it out there`);else{g(Qe,``);try{g($,await P.api.saveNote(y(),{base:a($).version,text:n}))}catch{try{let e=await P.api.readNote(y()),n=t(e.text);g($,n===null?e:await P.api.saveNote(y(),{base:e.version,text:n}))}catch(e){g(Qe,`not linked: ${e.message}`)}}}})}let nt=f(null),rt,it;function at(){clearTimeout(rt),clearTimeout(it),rt=it=void 0,g(nt,null)}function ot(e,t){if(at(),y()||!a(J)||!a(Y)||!(e.target instanceof Element)||e.target.closest(`button, .dock`))return;let n=e.target.closest(`[data-note]`)?.dataset.note??``;if(n.startsWith(`@`))return;let r=n?a(J).items[a(Y).at.get(n)??-1]:void 0,i=a(J).cell*a(z).k,o=Math.round(126/a(J).cell),s=Math.round(35/a(J).cell),c=r?{note:n,gx:r.gx,gy:r.gy,w:r.w,h:r.h}:{note:``,gx:Math.round((t.x-a(z).x)/i)-Math.floor(o/2),gy:Math.round((t.y-a(z).y)/i)-Math.ceil(s/2),w:o,h:s};rt=setTimeout(()=>{g(nt,c)},180),it=setTimeout(()=>{ft=!0,st(c)},650)}async function st(e){try{let t=await P.api.createDraft();e.note&&await P.api.saveNote(t.id,{base:t.version,text:q(t.text,e.note,ct(e.note))}),ue(t.id,{gx:e.gx*a(J).cell/7,gy:e.gy*a(J).cell/7}),await M(j(`/draft/[id]`,{id:t.id.slice(7)}))}catch(e){g(Qe,e.message,!0),at()}}let ct=e=>a(F)?.notes[e]?.title??e.split(`/`).at(-1)??e,lt=e=>e.startsWith(`@study`)?e.replace(/^@study\/?/,``).split(`/`).at(-1)||P.session?.name||`the base`:e.split(`/`).at(-1)??e,ut=0;function dt(e){if(cancelAnimationFrame(ut),matchMedia(`(prefers-reduced-motion: reduce)`).matches){g(z,e);return}let t=a(z),n=performance.now(),r=i=>{let o=Math.min(1,(i-n)/320),s=1-(1-o)**3,c=t.k*(e.k/t.k)**s,l=a(B).w/2,u=a(B).h/2,d=(l-t.x)/t.k*(1-s)+(l-e.x)/e.k*s,f=(u-t.y)/t.k*(1-s)+(u-e.y)/e.k*s;g(z,o===1?e:{k:c,x:l-d*c,y:u-f*c}),o<1&&(ut=requestAnimationFrame(r))};ut=requestAnimationFrame(r)}let ft=!1,pt=new Map,mt=null;function ht(){let e=[...pt.values()];if(!e.length){mt=null;return}let t=e.reduce((e,t)=>e+t.x,0)/e.length,n=e.reduce((e,t)=>e+t.y,0)/e.length;mt={view:a(z),x:t,y:n,span:e.length>1?Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y):0}}let gt=e=>{let t=a(W).getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}};function _t(e){(e.pointerType!==`mouse`||e.button===0)&&(cancelAnimationFrame(ut),pt.size||(ft=!1),pt.set(e.pointerId,gt(e)),ht(),pt.size===1?ot(e,gt(e)):at())}function vt(e){if(!pt.has(e.pointerId)||!mt)return;pt.set(e.pointerId,gt(e));let t=[...pt.values()],n=t.reduce((e,t)=>e+t.x,0)/t.length,r=t.reduce((e,t)=>e+t.y,0)/t.length;if(!ft&&t.length===1&&Math.hypot(n-mt.x,r-mt.y)<5)return;ft||(ft=se=!0,at(),a(W).setPointerCapture(e.pointerId));let i=t.length>1?Math.hypot(t[0].x-t[1].x,t[0].y-t[1].y):0,o=mt.span&&i?Ae(mt.view,i/mt.span,mt.x,mt.y):mt.view;g(z,{k:o.k,x:o.x+n-mt.x,y:o.y+r-mt.y})}function yt(e){pt.delete(e.pointerId)&&(it!==void 0&&at(),ht())}function bt(e){e.preventDefault(),cancelAnimationFrame(ut),se=!0;let t=gt(e),n=e.deltaMode===1?16:1;g(z,Ae(a(z),Math.exp(-e.deltaY*n*(e.ctrlKey?.01:.0015)),t.x,t.y))}i(()=>{if(!a(W))return;let e=a(W);return e.addEventListener(`wheel`,bt,{passive:!1}),()=>e.removeEventListener(`wheel`,bt)});function xt(e,t){if(e.metaKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),e.stopPropagation(),ft))return;if(y()){tt(t);return}if(a(U)===t){M(N(t));return}let n=[];if(a(X)&&a(Pe)===a(U)&&a(X).depth[t])for(let e=t;e&&e!==a(U);e=a(X).via[e])n.unshift(e);g(H,a(H).includes(t)?a(H).slice(0,a(H).indexOf(t)+1):n.length?[...a(H),...n]:[t])}function St(e){if(ft||!a(J))return;se=!0;let t=ke(a(J).items[e],a(B).w,a(B).h,1.5,a(J).cell),n=Math.abs(t.k-a(z).k)<.01*t.k&&Math.hypot(t.x-a(z).x,t.y-a(z).y)<4,r=a(J).items[e].parent;dt(n?r<0?Ce():ke(a(J).items[r],a(B).w,a(B).h,1.5,a(J).cell):t)}function Ct(e){if(ft||!(e.target instanceof Element)||e.target.closest(`.dock, .key`))return;let t=e.target.closest(`[data-folder]`);e.target.closest(`a, button`)||(a(U)?g(H,[]):a(Z)&&!a(He)?P.iso=null:t&&a(J)?St(a(J).items.findIndex(e=>e.kind===`folder`&&e.ref===t.dataset.folder)):dt(Ce()))}function wt(e){if(e.key===`Escape`){g(H,[]),g(V,``);return}if(e.key===`w`&&a(U)&&!e.metaKey&&!e.ctrlKey&&!e.altKey){g(ee,!a(ee));return}if(e.key===`c`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){fe();return}if(e.key===`l`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){pe(!a(oe));return}if(e.target!==a(W))return;let t={x:a(B).w/2,y:a(B).h/2};if(e.key===`+`||e.key===`=`)g(z,Ae(a(z),1.25,t.x,t.y));else if(e.key===`-`)g(z,Ae(a(z),.8,t.x,t.y));else if(e.key===`0`)dt(Ce());else if(e.key===`ArrowLeft`)g(z,{...a(z),x:a(z).x+80});else if(e.key===`ArrowRight`)g(z,{...a(z),x:a(z).x-80});else if(e.key===`ArrowUp`)g(z,{...a(z),y:a(z).y+80});else if(e.key===`ArrowDown`)g(z,{...a(z),y:a(z).y-80});else return;e.preventDefault(),se=!0}let Tt=v(()=>{if(!a(J)||!a(B).w||a(z).k<=Ce().k*1.05)return-1;let e=a(J).cell*a(z).k,t=(a(B).w/2-a(z).x)/e,n=(a(B).h/2-a(z).y)/e,r=-1;return a(J).items.forEach((i,o)=>{i.kind!==`folder`||a(Se)[o]!==`o`||t<i.gx||t>i.gx+i.w||n<i.gy||n>i.gy+i.h||(i.w*e>=.6*a(B).w||i.h*e>=.6*a(B).h)&&(r<0||a(J).items[r].depth<i.depth)&&(r=o)}),r});function Et(){if(!a(J))return;se=!0;let e=a(Tt)<0?-1:a(J).items[a(Tt)].parent;dt(e<0?Ce():ke(a(J).items[e],a(B).w,a(B).h,1.5,a(J).cell))}let Dt=v(()=>a(z).k>=he),Ot=v(()=>a(J)?a(J).items.filter(e=>e.kind===`note`&&e.ref.startsWith(`@study`)).length:0);i(()=>(P.atlas={items:a(Ot),chosen:a(U)?ct(a(U)):``,steps:a(H).length-1,chain:a(ee),whole:()=>{g(ee,!a(ee))},pick:!!y(),here:a(Tt)<0?``:lt(a(J).items[a(Tt)].ref),out:Et},()=>{P.atlas=null}));var kt=Tn();let At;var jt=s(kt),Mt=e=>{var t=mn(),r=o(t);p(()=>n(r,`The map could not be drawn: ${a(R)??``}`)),u(e,t)},Nt=e=>{var r=wn(),i=D(r),l=e=>{var t=hn();u(e,t)};t(i,e=>{a(J).items.length||e(l)});var d=h(i,2);let f;var m=s(d);A(m,17,()=>a(Ee),e=>e.item.id,(e,n)=>{var r=w(),i=D(r),o=e=>{{let t=v(()=>lt(a(n).item.ref)),r=v(()=>a(J).items.filter(e=>e.parent===a(n).i&&a(F)?.notes[e.ref]?.passed).length);dn(e,{get item(){return a(n).item},get name(){return a(t)},get count(){return a(Y).noteCount[a(n).i]},get open(){return a(n).open},get passes(){return a(r)},onpick:()=>St(a(n).i)})}},s=v(()=>a(n).item.ref.startsWith(`@study`)),c=e=>{{let t=v(()=>lt(a(n).item.ref)),r=v(()=>a(n).item.parent<0||(a(n).item.gy-a(J).items[a(n).item.parent].gy)*a(J).cell*a(z).k>=18),i=v(()=>Re(a(n).i,a(n).open)),o=v(()=>!!a(X)&&!a(n).open&&!a(Le).has(a(n).i));nn(e,{get item(){return a(n).item},get name(){return a(t)},get count(){return a(Y).noteCount[a(n).i]},get open(){return a(n).open},get titled(){return a(r)},get held(){return a(i)},get dim(){return a(o)},onpick:()=>St(a(n).i)})}};t(i,e=>{a(s)?e(o):e(c,-1)}),u(e,r)});var _=h(m,2);{let e=v(()=>[...a(Ke),...a(ze)]);sn(_,{get k(){return a(z).k},get rest(){return a(Me)},get hot(){return a(e)},get counts(){return a(Be)},get sent(){return a(Ye)}})}var x=h(_,2),S=e=>{var r=w(),i=D(r);A(i,17,()=>a(Me),e=>e.key,(e,r)=>{var i=w(),s=D(i),c=e=>{var t=gn(),i=o(t,!0);p(()=>{b(t,1,`count ${a(r).side??``}`,`svelte-14y1y1z`),E(t,`--x:${a(r).mid[0]??``};--y:${a(r).mid[1]??``}`),n(i,a(r).count)}),u(e,t)};t(s,e=>{a(r).label&&e(c)}),u(e,i)}),u(e,r)};t(x,e=>{a(Dt)&&e(S)});var O=h(x,2);A(O,17,()=>a(je),e=>e.item.id,(e,n)=>{let r=v(()=>a(Fe).get(a(n).item.ref)),i=v(()=>a(r)?.mark??``);var o=w(),s=D(o),c=e=>{{let t=v(()=>ct(a(n).item.ref)),r=v(()=>a(F).notes[a(n).item.ref]?.kind??`note`),o=v(()=>C()?.note===a(n).item.ref?C().who:``),s=v(()=>!!a(X)&&!a(i)),c=v(()=>N(a(n).item.ref));pn(e,{get item(){return a(n).item},get title(){return a(t)},get kind(){return a(r)},get mark(){return a(i)},get moment(){return a(o)},get dim(){return a(s)},get href(){return a(c)},onpick:e=>xt(e,a(n).item.ref),onpoint:e=>{g(V,e?a(n).item.ref:a(V)===a(n).item.ref?``:a(V),!0)}})}},l=v(()=>a(n).item.ref.startsWith(`@study`)),d=e=>{{let t=v(()=>ct(a(n).item.ref)),o=v(()=>a(F).notes[a(n).item.ref]?.step??0),s=v(()=>a(r)?.far??0),c=v(()=>a($e).indexOf(a(n).item.ref)+1),l=v(()=>Xe(a(n).item.ref)),u=v(()=>a(Je).includes(a(n).item.ref)),d=v(()=>C()?.note===a(n).item.ref?C().who:``),f=v(()=>!!a(X)&&!a(i)),p=v(()=>N(a(n).item.ref));Zt(e,{get item(){return a(n).item},get title(){return a(t)},get step(){return a(o)},get mark(){return a(i)},get far(){return a(s)},get num(){return a(c)},get iso(){return a(l)},get linked(){return a(u)},get moment(){return a(d)},get dim(){return a(f)},get href(){return a(p)},onpick:e=>xt(e,a(n).item.ref),onpoint:e=>{g(V,e?a(n).item.ref:a(V)===a(n).item.ref?``:a(V),!0)}})}};t(s,e=>{a(l)?e(c):e(d,-1)}),u(e,o)});var M=h(O,2),P=e=>{var r=bn();let i;var l=s(r),d=e=>{var t=_n(),r=s(t),i=o(r,!0);T(t),p(e=>{k(t,`href`,e),k(t,`aria-label`,`${a(Q).title??``}: your note for Iso`),n(i,a(Q).title)},[()=>j(`/draft/[id]`,{id:a(Z).note.slice(7)})]),u(e,t)};t(l,e=>{a(Q).draft&&e(d)});var f=h(l,2),m=e=>{var r=yn(),i=h(D(r),2),l=h(s(i)),d=e=>{var t=c(`Iso is writing`);u(e,t)},f=e=>{var t=vn(),r=h(D(t)),i=o(r,!0);p(e=>n(i,e),[()=>ct(a(We))]),u(e,t)},m=e=>{var t=c(`Iso is thinking`);u(e,t)};t(l,e=>{a(Z).state===`writing`?e(d):a(We)?e(f,1):e(m,-1)}),T(i),u(e,r)};t(f,e=>{a(He)&&e(m)}),T(r),p(()=>{i=b(r,1,`asker svelte-14y1y1z`,null,i,{draft:a(Q).draft}),E(r,`--x:${a(Q).gx??``};--y:${a(Q).gy??``};--w:${a(Q).w??``};--h:${a(Q).h??``}`)}),u(e,r)};t(M,e=>{a(Q)&&e(P)});var I=h(M,2),L=e=>{var n=Sn();let r;var i=h(s(n),2),o=e=>{var t=xn();u(e,t)};t(i,e=>{!a(nt).note&&a(Dt)&&e(o)}),T(n),p(()=>{r=b(n,1,`grasp svelte-14y1y1z`,null,r,{"on-note":!!a(nt).note}),E(n,`--x:${a(nt).gx??``};--y:${a(nt).gy??``};--w:${a(nt).w??``};--h:${a(nt).h??``}`)}),u(e,n)};t(I,e=>{a(nt)&&e(L)}),T(d);var R=h(d,2),B=e=>{{let t=v(()=>a($)?re(a($).text)?`an exercise`:ae(a($).text):``),n=v(()=>a($)?re(a($).text)!==null:!1),r=v(()=>a($e).map(e=>({id:e,title:ct(e),tokens:a(F).notes[e]?.tokens??0}))),i=v(()=>j(`/draft/[id]`,{id:y().slice(7)}));me(e,{get title(){return a(t)},get tests(){return a(n)},get picked(){return a(r)},budget:8e3,get notice(){return a(Qe)},get href(){return a(i)}})}},H=e=>{var t=Cn(),r=o(t,!0);p(()=>n(r,a(Qe))),u(e,t)};t(R,e=>{y()?e(B):a(Qe)&&e(H,1)}),p(e=>{f=b(d,1,`atlas-world svelte-14y1y1z`,null,f,{labels:a(Dt)}),k(d,`data-open`,a(Se)),E(d,`transform: translate(${a(z).x??``}px, ${a(z).y??``}px); --u: ${(a(J)?.cell??7)*a(z).k}px; --k: ${a(z).k??``}; --fs: ${e??``}px; --lines: ${a(z).k<.9?1:2}`)},[()=>(10.5*Math.min(1.5,Math.max(.8,a(z).k))).toFixed(2)]),u(e,r)};t(jt,e=>{a(R)?e(Mt):a(J)&&a(F)&&e(Nt,1)}),T(kt),O(kt,e=>g(W,e),()=>a(W)),p(()=>{At=b(kt,1,`atlas dots svelte-14y1y1z`,null,At,{lit:!!a(X)}),E(kt,`background-position: ${a(z).x??``}px ${a(z).y??``}px`)}),d(`pointerdown`,kt,_t),d(`pointermove`,kt,vt),d(`pointerup`,kt,yt),r(`pointercancel`,kt,yt),d(`click`,kt,Ct),d(`keydown`,kt,wt),d(`contextmenu`,kt,e=>{(a(nt)||rt!==void 0)&&e.preventDefault()}),u(e,kt),S()}l([`pointerdown`,`pointermove`,`pointerup`,`click`,`keydown`,`contextmenu`]);var Dn=e(`<div class="side svelte-1wy8qhs"><button class="icon svelte-1wy8qhs" type="button" aria-label="timeline" title="timeline"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 1v14" stroke="currentColor" stroke-width="1.2" fill="none"></path><rect x="5.5" y="2" width="5" height="3.2" fill="currentColor"></rect><path d="M8 6.3l2.3 2.3L8 10.9 5.7 8.6z" fill="currentColor"></path><rect x="5.5" y="12" width="5" height="3" fill="none" stroke="currentColor" stroke-width="1.2"></rect></svg></button> <!></div>`),On=e(`<div class="map svelte-1wy8qhs"><!> <!></div>`);function kn(e,n){_(n,!0);let r=v(()=>V.url.searchParams.get(`pick`)??new URLSearchParams(V.url.hash.split(`?`)[1]??``).get(`pick`)??``),o=f(m((()=>{try{return localStorage.getItem(`isorite.timeline`)===`1`}catch{return!1}})())),c=f([]),l=f(null),y=e=>P.listing.notes.find(t=>t.id===e)?.title??e.split(`/`).at(-1),b=e=>e.who.startsWith(`iso:`)||e.who.startsWith(`agent:`);async function x(){try{g(c,(await P.api.timeline()).filter(e=>!e.note.startsWith(`@draft/`)))}catch{}}i(()=>{if(!a(o))return;x();let e,t=P.on(t=>{t.type===`journal`&&(clearTimeout(e),e=setTimeout(()=>{x()},300))});return()=>{t(),clearTimeout(e)}});function C(e){M(`${N(e.note)}?at=${encodeURIComponent(z(e))}`)}function w(){g(o,!a(o)),g(l,null);try{localStorage.setItem(`isorite.timeline`,a(o)?`1`:`0`)}catch{}}var E=On(),D=s(E);{let e=v(()=>a(r)?`@draft/${a(r)}`:``),t=v(()=>a(l)?{note:a(l).note,who:b(a(l))?`iso`:`you`}:null);En(D,{get pick(){return a(e)},get moment(){return a(t)}})}var O=h(D,2),A=e=>{var n=Dn(),r=s(n),i=h(r,2),f=e=>{B(e,{get moments(){return a(c)},at:null,get pointed(){return a(l)},leftward:!0,name:`This session's timeline`,label:e=>y(e.note),point:e=>g(l,e),pick:e=>C(e)})};t(i,e=>{a(o)&&e(f)}),T(n),p(()=>k(r,`aria-pressed`,a(o))),d(`click`,r,w),u(e,n)};t(O,e=>{a(r)||e(A)}),T(E),u(e,E),S()}l([`click`]);export{kn as component};
@@ -0,0 +1,2 @@
1
+ import{$ as e,A as t,C as n,E as r,H as i,I as a,J as o,K as s,M as c,N as l,O as u,P as d,Q as f,S as p,V as m,Y as h,Z as g,at as _,b as v,c as y,ct as b,d as x,et as S,f as C,h as w,it as T,k as E,l as D,lt as O,n as k,nt as A,o as j,p as ee,q as M,u as N,x as P}from"../chunks/BC72R-M3.js";import{o as F,t as I}from"../chunks/czZbKOPp.js";import"../chunks/xihTtKlq.js";import{n as L,t as R}from"../chunks/3kOo0zFs.js";import{o as te}from"../chunks/7G70dile.js";import{t as z}from"../chunks/BDArRuPR.js";import"../chunks/BIIfi70-.js";import"../chunks/VWXhPrtT.js";import{a as ne,i as re,o as ie,t as ae}from"../chunks/DZgc09PI.js";var oe=t(`<p class="faint col svelte-nq8rms">opening…</p>`),se=t(`<div class="col svelte-nq8rms"><p class="soft">This note for Iso is not here any more. It was kept as a note, or discarded.</p><p><a>all notes</a></p></div>`),ce=t(`<div class="mark svelte-nq8rms"><i class="dia open svelte-nq8rms" aria-hidden="true"></i><span class="label">for Iso · an exercise, not in your study base yet</span></div> <h1 class="serif title svelte-nq8rms"> </h1>`,1),le=t(`<div class="mark svelte-nq8rms"><i class="dia open svelte-nq8rms" aria-hidden="true"></i><span class="label">for Iso · not in your base yet</span></div> <label class="hidden-label" for="title">Title</label> <textarea id="title" class="serif title svelte-nq8rms" rows="1" placeholder="a title for the note" autocomplete="off"></textarea>`,1),ue=t(`<span class="label">what you want from it · if anything</span>`),de=t(`<!> <!>`,1),fe=t(`<div class="prompt svelte-nq8rms"><p> </p> <button class="link svelte-nq8rms" type="button"> </button></div>`),pe=t(`<div class="prose said svelte-nq8rms"></div>`),me=t(`<span class="faint"> </span>`),he=t(`<!> <div class="foot svelte-nq8rms"><i class="dia svelte-nq8rms" aria-hidden="true"></i> <span class="soft"> <!></span> <span class="grow"></span> <button class="link svelte-nq8rms" type="button">[ stop ]</button></div>`,1),ge=t(`<textarea class="revision svelte-nq8rms" aria-label="Iso's text, to edit"></textarea>`),_e=t(`<h2 class="serif extitle svelte-nq8rms"> </h2> <div class="prose said question svelte-nq8rms"></div> <span class="label">your working</span>`,1),ve=t(`<!> <div aria-live="polite"><!></div>`,1),ye=t(`<p class="bad svelte-nq8rms" role="alert"> </p>`),be=t(`<span class="chip lattice svelte-nq8rms"> <button class="x svelte-nq8rms" type="button">×</button></span>`),xe=t(`<span class="faint">no notes yet</span>`),B=t(`<option> </option>`),Se=t(`<select class="field pickone svelte-nq8rms" aria-label="Add a note to test"><option> </option><!></select>`),Ce=t(`<button type="button" role="radio" class="svelte-nq8rms"> </button>`),we=t(`<div class="row svelte-nq8rms"><span class="label">tests</span> <!> <!> <button class="link svelte-nq8rms" type="button">[ + pick on the atlas ]</button></div> <div class="row svelte-nq8rms"><label class="in soft svelte-nq8rms"><span>in</span> <select class="field svelte-nq8rms" aria-label="Folder"><option>the top of the base</option><!></select></label> <label class="in soft svelte-nq8rms"><span>comes after</span> <select class="field svelte-nq8rms" aria-label="Comes after"><option>nothing</option><!></select></label></div> <div class="row svelte-nq8rms"><button class="btn primary tall" type="button"><i class="dia inverse svelte-nq8rms" aria-hidden="true"></i>send to Iso</button> <span class="tiers svelte-nq8rms" role="radiogroup" aria-label="Tier"></span> <span class="grow"></span> <button class="link faint svelte-nq8rms" type="button">[ discard ]</button></div>`,1),Te=t(`<span class="chip lattice svelte-nq8rms"> </span>`),Ee=t(`<span class="faint">no notes yet: type [[ in what you write, or</span>`),De=t(`<div class="row svelte-nq8rms"><span class="label">linked</span> <!> <button class="link svelte-nq8rms" type="button">[ + pick on the atlas ]</button></div> <div class="row svelte-nq8rms"><button class="btn primary tall" type="button"><i class="dia inverse svelte-nq8rms" aria-hidden="true"></i>send to Iso</button> <span class="tiers svelte-nq8rms" role="radiogroup" aria-label="Tier"></span> <span class="grow"></span> <button class="link faint svelte-nq8rms" type="button">[ discard ]</button></div>`,1),Oe=t(`<button class="btn primary tall" type="button">keep the exercise</button> <span class="soft where svelte-nq8rms"> <!></span>`,1),ke=t(`<option></option>`),Ae=t(`<button class="btn primary tall" type="button">keep as a note</button> <label class="in soft svelte-nq8rms"><span>in</span><input class="field svelte-nq8rms" placeholder="the top of the base" list="folders" autocomplete="off" aria-label="Folder"/><span class="faint">/</span></label> <datalist id="folders"></datalist>`,1),je=t(`<button class="btn edit" type="button">done</button>`),Me=t(`<button class="btn edit" type="button">edit</button>`),Ne=t(`<div class="row svelte-nq8rms"><!> <span class="grow"></span> <!> <button class="btn danger tall" type="button">discard</button></div> <div class="row svelte-nq8rms"><span class="label"> </span> <span class="grow"></span> <button class="link svelte-nq8rms" type="button">[ back to what I wrote ]</button></div>`,1),Pe=t(`<div class="col svelte-nq8rms"><!> <!> <!> <!></div> <div class="deck svelte-nq8rms"><!></div>`,1),Fe=t(`<article class="draft svelte-nq8rms"><!></article>`);function V(e,t){_(t,!0);let l=new re(t.id),p=new ie(l),E=f(``),j=f(!1),z=f(``),V=f(!1),H=S(()=>p.proposals.at(-1)),U=S(()=>a(H)?.text??``),W=S(()=>a(H)&&p.editing?.id===a(H).id?p.editing:null),G=S(()=>!a(H)&&!p.asking),Ie=S(()=>{let e=[...l.body.matchAll(/\]\(\/([^)\s#]+)\.md/g)].map(e=>decodeURIComponent(e[1]));return[...new Set(e)].flatMap(e=>{let t=R.listing.notes.find(t=>t.id===e);return t?[t]:[]})}),Le=S(()=>p.asking?.steps.at(-1)?.said??``),K=S(()=>l.meta?.type===`Exercise`),q=S(()=>a(K)&&l.meta?te(l.meta):[]),J=S(()=>a(K)?String(l.meta?.folder??``):``),Y=S(()=>a(K)?String(l.meta?.after??``):``),X=e=>R.listing.notes.find(t=>t.id===e)?.title??e.split(`/`).at(-1),Re=S(()=>R.listing.notes.filter(e=>e.dir===a(J)&&!a(q).includes(e.id)&&!e.id.startsWith(`@`))),Z=f(null);i(()=>{a(K)&&!a(Z)&&R.api.study().then(e=>g(Z,e),()=>void 0)});let ze=S(()=>a(K)?`An exercise on ${a(q).map(X).join(`, `)||`…`}`:``),Be=S(()=>{let e=/^\s*#[ \t]+(.+)\n?/.exec(a(U));return e?{title:e[1].trim(),question:a(U).slice(e[0].length).trim()}:{title:``,question:a(U).trim()}}),Ve=e=>l.setMeta({tests:e});k(()=>{R.open=t.id,l.open().then(()=>p.open());let e=()=>{l.save()};return addEventListener(`pagehide`,e),()=>{removeEventListener(`pagehide`,e),p.close(),l.close(),R.here=R.open=``,R.studying=!1,R.saving=null}}),i(()=>{R.here=l.loaded===`ready`?a(K)?`an exercise`:l.fields.title||`a new note`:``,R.studying=a(K),R.saving=l.loaded===`ready`&&a(G)?{text:l.saving===`saved`?`saved, outside your base`:l.saving===`failed`?`not saved: ${l.message}`:`saving`,bad:l.saving===`failed`}:null});async function He(){if(a(H)){g(z,``),g(V,!0);try{await l.save(),a(W)&&await p.done(a(H));let e=a(K)?await R.api.keepExercise(t.id,a(H).id):await R.api.keepDraft(t.id,a(H).id,a(E));await R.refresh(),await I(L(e.id))}catch(e){g(z,e.message,!0)}finally{g(V,!1)}}}async function Ue(){await l.save(),await I(`${F(`/atlas`)}?pick=${encodeURIComponent(t.id.slice(7))}`)}async function We(){if(a(K)){await p.send(`exercise`);return}let e=await p.send();e&&(R.watching=e,await I(F(`/atlas`)))}async function Q(){g(V,!0);try{await R.api.discardDraft(t.id),await I(F(a(K)?`/study`:`/notes`))}catch(e){g(z,e.message,!0),g(V,!1)}}var $=Fe(),Ge=s($),Ke=e=>{var t=oe();u(e,t)},qe=e=>{var t=se(),n=h(s(t)),r=o(n);O(t),m(e=>N(r,`href`,e),[()=>F(`/notes`)]),u(e,t)},Je=e=>{var t=Pe(),i=M(t),f=s(i),_=e=>{var t=ce(),n=h(M(t),2),i=o(n,!0);m(()=>r(i,a(ze))),u(e,t)},T=e=>{var t=le(),n=h(M(t),4);A(n),m(()=>{x(n,l.fields.title),n.readOnly=!a(G)}),d(`input`,n,e=>l.setFields({title:e.currentTarget.value.replace(/\s*\n\s*/g,` `)})),d(`keydown`,n,e=>{e.key===`Enter`&&e.preventDefault()}),u(e,t)};n(f,e=>{a(K)?e(_):e(T,-1)});var k=h(f,2),F=e=>{var t=de(),r=M(t),i=e=>{var t=ue();u(e,t)};n(r,e=>{a(K)&&e(i)});var o=h(r,2);{let e=S(()=>a(K)?`Nothing is needed here. Or say what the exercise should ask: a calculation, a proof, your own words, how hard.`:void 0);ae(o,{get note(){return l},source:!1,get placeholder(){return a(e)}})}u(e,t)},I=e=>{var t=ve(),i=M(t),c=e=>{var t=fe(),n=s(t);let i;var c=o(n,!0),f=h(n,2),p=o(f,!0);O(t),m(e=>{i=w(n,1,`serif soft svelte-nq8rms`,null,i,{fold:!a(j)}),r(c,e),r(p,a(j)?`[ fold ]`:`[ show all ]`)},[()=>l.body.trim()]),d(`click`,f,()=>g(j,!a(j))),u(e,t)},f=S(()=>l.body.trim());n(i,e=>{a(f)&&e(c)});var _=h(i,2);let x;var C=s(_),T=e=>{var t=he(),i=M(t),c=e=>{var t=pe();v(t,()=>ne(p.asking.text),!0),O(t),u(e,t)};n(i,e=>{p.asking.text&&e(c)});var l=h(i,2),f=h(s(l),2),g=s(f,!0),_=h(g),y=e=>{var t=me(),n=o(t);m(()=>r(n,`· ${a(Le)??``}`)),u(e,t)};n(_,e=>{a(Le)&&e(y)}),O(f);var b=h(f,4);O(l),m(()=>r(g,p.asking.text?`Iso is writing`:`Iso is thinking`)),d(`click`,b,()=>p.halt()),u(e,t)},E=e=>{var t=ge();A(t),m(e=>N(t,`rows`,e),[()=>Math.max(6,a(W).text.split(`
2
+ `).length+1)]),y(t,()=>a(W).text,e=>a(W).text=e),u(e,t)},D=e=>{var t=_e(),n=M(t),i=o(n,!0),s=h(n,2);v(s,()=>ne(a(Be).question),!0),O(s),b(2),m(()=>r(i,a(Be).title||`an exercise`)),u(e,t)},k=e=>{var t=pe();v(t,()=>ne(a(U)),!0),O(t),u(e,t)};n(C,e=>{p.asking?e(T):a(W)?e(E,1):a(K)?e(D,2):e(k,-1)}),O(_),m(e=>x=w(_,1,`between svelte-nq8rms`,null,x,{working:e}),[()=>!!p.asking]),u(e,t)};n(k,e=>{a(G)?e(F):e(I,-1)});var L=h(k,2),te=e=>{var t=ye(),n=o(t,!0);m(()=>r(n,p.failed.message)),u(e,t)};n(L,e=>{p.failed&&e(te)});var re=h(L,2),ie=e=>{var t=ye(),n=o(t,!0);m(()=>r(n,a(z))),u(e,t)};n(re,e=>{a(z)&&e(ie)}),O(i);var oe=h(i,2),se=s(oe),Fe=e=>{var t=we(),i=M(t),c=h(s(i),2);P(c,16,()=>a(q),e=>e,(e,t)=>{var n=be(),i=s(n,!0),o=h(i);O(n),m((e,t)=>{r(i,e),N(o,`aria-label`,t)},[()=>X(t),()=>`Not ${X(t)}`]),d(`click`,o,()=>Ve(a(q).filter(e=>e!==t))),u(e,n)},e=>{var t=xe();u(e,t)});var f=h(c,2),g=e=>{var t=Se(),n=s(t),i=o(n);n.value=n.__value=``;var c=h(n);P(c,17,()=>a(Re),e=>e.id,(e,t)=>{var n=B(),i=o(n,!0),s={};m(()=>{r(i,a(t).title),s!==(s=a(t).id)&&(n.value=(n.__value=s)??``)}),u(e,n)}),O(t),t.value=t.__value=``,m(()=>r(i,`+ a note in ${(a(J)||`the top of the base`)??``}`)),d(`change`,t,e=>{let t=e.currentTarget.value;e.currentTarget.value=``,t&&Ve([...a(q),t])}),u(e,t)};n(f,e=>{a(Re).length&&e(g)});var _=h(f,2);O(i);var v=h(i,2),y=s(v),b=h(s(y),2),x=s(b);x.value=x.__value=``;var S=h(x);P(S,16,()=>R.listing.dirs,e=>e,(e,t)=>{var n=B(),i=o(n,!0),a={};m(()=>{r(i,t),a!==(a=t)&&(n.value=(n.__value=a)??``)}),u(e,n)}),O(b);var w;C(b),O(y);var T=h(y,2),E=h(s(T),2),D=s(E);D.value=D.__value=``;var k=h(D);P(k,17,()=>a(Z)?.exercises??[],e=>e.id,(e,t)=>{var n=B(),i=o(n,!0),s={};m(e=>{r(i,a(t).title),s!==(s=e)&&(n.value=(n.__value=s)??``)},[()=>a(t).id.slice(7)]),u(e,n)}),O(E);var A;C(E),O(T),O(v);var j=h(v,2),F=s(j),I=h(F,2);P(I,20,()=>[`low`,`mid`,`max`],e=>e,(e,t)=>{var n=Ce(),i=o(n,!0);m(()=>{N(n,`aria-checked`,p.tier===t),r(i,t)}),d(`click`,n,()=>p.setTier(t)),u(e,n)}),O(I);var L=h(I,4);O(j),m(()=>{w!==(w=a(J))&&(b.value=(b.__value=w)??``,ee(b,w)),A!==(A=a(Y))&&(E.value=(E.__value=A)??``,ee(E,A)),F.disabled=!a(q).length,L.disabled=a(V)}),d(`click`,_,Ue),d(`change`,b,e=>l.setMeta({folder:e.currentTarget.value})),d(`change`,E,e=>l.setMeta({after:e.currentTarget.value||null})),d(`click`,F,We),d(`click`,L,Q),u(e,t)},$=e=>{var t=De(),n=M(t),i=h(s(n),2);P(i,17,()=>a(Ie),e=>e.id,(e,t)=>{var n=Te(),i=o(n,!0);m(()=>r(i,a(t).title)),u(e,n)},e=>{var t=Ee();u(e,t)});var c=h(i,2);O(n);var f=h(n,2),g=s(f),_=h(g,2);P(_,20,()=>[`low`,`mid`,`max`],e=>e,(e,t)=>{var n=Ce(),i=o(n,!0);m(()=>{N(n,`aria-checked`,p.tier===t),r(i,t)}),d(`click`,n,()=>p.setTier(t)),u(e,n)}),O(_);var v=h(_,4);O(f),m(e=>{g.disabled=e,v.disabled=a(V)},[()=>!l.body.trim()]),d(`click`,c,Ue),d(`click`,g,We),d(`click`,v,Q),u(e,t)},Ge=e=>{var t=Ne(),i=M(t),l=s(i),f=e=>{var t=Oe(),i=M(t),o=h(i,2),l=s(o),f=h(l),p=e=>{var t=c();m(e=>r(t,`, after ${e??``}`),[()=>a(Z)?.exercises.find(e=>e.id===`@study/${a(Y)}`)?.title??a(Y)]),u(e,t)};n(f,e=>{a(Y)&&e(p)}),O(o),m(()=>{i.disabled=a(V),r(l,`in ${(a(J)||`the top of the base`)??``}`)}),d(`click`,i,He),u(e,t)},_=e=>{var t=Ae(),n=M(t),r=h(n,2),i=h(s(r));D(i),b(),O(r);var o=h(r,2);P(o,20,()=>R.listing.dirs,e=>e,(e,t)=>{var n=ke(),r={};m(()=>{r!==(r=t)&&(n.value=(n.__value=r)??``)}),u(e,n)}),O(o),m(()=>n.disabled=a(V)),d(`click`,n,He),y(i,()=>a(E),e=>g(E,e)),u(e,t)};n(l,e=>{a(K)?e(f):e(_,-1)});var v=h(l,4),x=e=>{var t=je();d(`click`,t,()=>p.done(a(H))),u(e,t)},S=e=>{var t=Me();d(`click`,t,()=>p.edit(a(H))),u(e,t)};n(v,e=>{a(W)?e(x):e(S,-1)});var C=h(v,2);O(i);var w=h(i,2),T=s(w),k=o(T),A=h(T,4);O(w),m(e=>{C.disabled=a(V),r(k,`${e??``}${a(H).notice?` · ${a(H).notice}`:``}`),A.disabled=a(V)},[()=>a(H).cost?`${a(H).cost.tier} · $${a(H).cost.usd.toFixed(3)}`:``]),d(`click`,C,Q),d(`click`,A,()=>p.discard(a(H))),u(e,t)};n(se,e=>{a(G)&&a(K)?e(Fe):a(G)?e($,1):a(H)&&e(Ge,2)}),O(oe),u(e,t)};n(Ge,e=>{l.loaded===`loading`?e(Ke):l.loaded===`ready`?e(Je,-1):e(qe,1)}),O($),u(e,$),T()}l([`input`,`keydown`,`click`,`change`]);function H(t,n){_(n,!1),j();var r=E(),i=M(r);p(i,()=>z.params.id,t=>{{let n=e(()=>`@draft/${z.params.id??``}`);V(t,{get id(){return a(n)}})}}),u(t,r),T()}export{H as component};
@@ -0,0 +1,4 @@
1
+ import{$ as e,A as t,C as n,E as r,F as i,G as a,H as o,I as s,J as c,K as l,M as u,N as d,O as f,P as p,Q as m,S as h,V as g,X as _,Y as v,Z as y,at as b,c as x,ct as S,d as C,et as w,h as T,it as E,j as D,k as O,l as k,lt as A,n as j,nt as ee,o as M,q as N,s as P,u as F,x as I}from"../chunks/BC72R-M3.js";import{o as te,t as ne}from"../chunks/czZbKOPp.js";import"../chunks/xihTtKlq.js";import{n as re,t as L}from"../chunks/3kOo0zFs.js";import{d as ie,f as R,h as z,i as ae,m as B,n as V,r as H,s as U,t as oe,v as se}from"../chunks/7G70dile.js";import{i as ce,n as le,r as ue,t as de}from"../chunks/Cu92X5fL.js";import{t as fe}from"../chunks/BDArRuPR.js";import"../chunks/BIIfi70-.js";import"../chunks/VWXhPrtT.js";import{i as W,n as pe,o as me,r as he,t as ge}from"../chunks/DZgc09PI.js";var _e=e=>e<=0?0:e<=2?1:e<=4?2:3;function ve(e,t){let n=t.length?6:0,r=!1;for(let i of t){let t=e.get(i);n=Math.min(n,t?.squares??0),r||=!!t?.due}return{squares:n,step:_e(n),due:r}}var G=t(`<span class="label ok svelte-1myx1bo" role="status"> </span>`),K=t(`<span class="label bad svelte-1myx1bo" role="status">no terminal agent took it: is isorite term running?</span>`),q=t(`<span class="label bad svelte-1myx1bo" role="alert"> </span>`),J=t(`<div class="send svelte-1myx1bo" role="group" aria-label="Send to the terminal's agent"><span class="label what svelte-1myx1bo"> </span> <input type="text" placeholder="what you want of it (optional)" aria-label="What you want of it" maxlength="4000" class="svelte-1myx1bo"/> <button class="btn primary svelte-1myx1bo" type="button">send to agent</button> <button class="link svelte-1myx1bo" type="button">[ close ]</button> <!></div>`);function ye(e,t){b(t,!0);let i=m(``),a=m(``),o=m(``),u=m(``);async function d(){y(a,`sending`);let e=new Map,n=L.on(t=>{t.type===`agent-received`&&e.set(t.id,t.agent)});try{let{id:n}=await L.api.agentSend({note:t.note,...t.passage?{passage:t.passage}:{},said:s(i)});for(let t=Date.now();!e.has(n)&&Date.now()-t<4e3;)await new Promise(e=>setTimeout(e,100));y(o,oe(e.get(n)),!0),y(a,e.has(n)?`taken`:`none`,!0),s(a)===`taken`&&y(i,``)}catch(e){y(a,`failed`),y(u,e.message,!0)}finally{n()}}var h=J(),_=l(h),S=c(_,!0),C=v(_,2);k(C);var w=v(C,2),T=v(w,2),D=v(T,2),O=e=>{var t=G(),n=c(t);g(()=>r(n,`${s(o)??``} has it, in the terminal`)),f(e,t)},j=e=>{var t=K();f(e,t)},ee=e=>{var t=q(),n=c(t,!0);g(()=>r(n,s(u))),f(e,t)};n(D,e=>{s(a)===`taken`?e(O):s(a)===`none`?e(j,1):s(a)===`failed`&&e(ee,2)}),A(h),g(()=>{r(S,t.passage?`the passage you chose`:`this note`),w.disabled=s(a)===`sending`}),p(`keydown`,C,e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&t.onclose()}),x(C,()=>s(i),e=>y(i,e)),p(`click`,w,d),p(`click`,T,function(...e){t.onclose?.apply(this,e)}),f(e,h),E()}d([`keydown`,`click`]);var Y=e=>`isorite.answer.${e}`;function X(e){try{let t=JSON.parse(localStorage.getItem(Y(e))??`null`);return t&&typeof t.text==`string`&&typeof t.nth==`number`?t:null}catch{return null}}function be(e,t){try{t?localStorage.setItem(Y(e),JSON.stringify(t)):localStorage.removeItem(Y(e))}catch{}}function xe(e){let t=e>0?`+`:e<0?`−`:``,n=Math.abs(e);return n===0?`0`:t+(n===.5?`½`:n===1?`1`:String(n))}var Se=class{note;iso;stop=null;#e=m(null);get answer(){return s(this.#e)}set answer(e){y(this.#e,e)}#t=m(null);get study(){return s(this.#t)}set study(e){y(this.#t,e)}#n=m(null);get marking(){return s(this.#n)}set marking(e){y(this.#n,e,!0)}#r=m(``);get failed(){return s(this.#r)}set failed(e){y(this.#r,e,!0)}#i=m(0);get flash(){return s(this.#i)}set flash(e){y(this.#i,e,!0)}constructor(e,t){this.note=e,this.iso=t,this.answer=X(e.id)}#a=w(()=>V(this.note.text));get ex(){return s(this.#a)}set ex(e){y(this.#a,e)}#o=w(()=>this.note.meta?.type===`Exercise`);get is(){return s(this.#o)}set is(e){y(this.#o,e)}#s=w(()=>{if(!this.answer)return null;let e=U(this.note.text,this.answer);return e&&e.from>=this.ex.from?e:null});get answerAt(){return s(this.#s)}set answerAt(e){y(this.#s,e)}#c=w(()=>{let e=this.iso.cursor;if(!e||e.to<=e.from||e.from<this.ex.from)return null;let{from:t,to:n}=e,r=this.note.text;for(;t<n&&/\s/.test(r[t]);)t++;for(;n>t&&/\s/.test(r[n-1]);)n--;return n>t?{from:t,to:n}:null});get selection(){return s(this.#c)}set selection(e){y(this.#c,e)}#l=w(()=>this.iso.entries.filter(e=>e.kind===`marks`).at(-1)??null);get last(){return s(this.#l)}set last(e){y(this.#l,e)}#u=w(()=>this.last?H(this.note.text,this.last.marks).filter(e=>e.from>=this.ex.from):[]);get marks(){return s(this.#u)}set marks(e){y(this.#u,e)}#d=w(()=>({right:this.marks.filter(e=>e.mark===`right`).length,wrong:this.marks.filter(e=>e.mark===`wrong`).length}));get counts(){return s(this.#d)}set counts(e){y(this.#d,e)}#f=w(()=>{let e=new Map;for(let[t,n]of Object.entries(this.study?.notes??{}))e.set(t,{...n,lapsed:!1,last:null,evidence:[]});return ve(e,this.ex.tests)});get squares(){return s(this.#f)}set squares(e){y(this.#f,e)}#p=w(()=>{let e=this.last;return e?this.ex.tests.flatMap(t=>{let n=this.study?.notes[t]?.evidence.find(t=>t.marks===e.id);return n?[{note:t,by:n.by}]:[]}):[]});get moves(){return s(this.#p)}set moves(e){y(this.#p,e)}async open(){this.stop=L.on(e=>{e.type===`record`&&this.reread(),!this.marking||!(`request`in e)||this.marking&&e.request!==this.marking?e.type===`iso-start`&&this.marking===``&&e.note===this.note.id&&(this.marking=e.request):e.type===`iso-done`?(this.marking=null,this.reread().then(()=>{this.last?.result===`right`&&this.flash++})):e.type===`iso-failed`?(this.marking=null,this.failed=e.message):e.type===`iso-stopped`&&(this.marking=null)}),await this.reread()}close(){this.stop?.()}async reread(){try{this.study=await L.api.study()}catch{}}markAnswer(){let e=this.selection;e&&(this.answer=R(this.note.text,e.from,e.to),be(this.note.id,this.answer))}clearAnswer(){this.answer=null,be(this.note.id,null)}async send(){if(this.marking===null&&this.answerAt){this.failed=``,this.marking=``;try{await this.note.save();let e=this.answerAt;if(!e)throw Error(`the answer you marked is no longer in the working`);let t=R(this.note.text,e.from,e.to),{request:n}=await L.api.ask({note:this.note.id,form:`mark`,answer:t,tier:this.iso.tier});this.marking===``&&(this.marking=n)}catch(e){this.marking=null,this.failed=e.message}}}async windBack(){try{await L.api.windBack(this.note.id),await this.reread()}catch(e){this.failed=e.message}}},Z=t(`<button class="link svelte-1khbtcu" type="button">delete</button>`),Q=t(`<label class="wide svelte-1khbtcu"><span>path</span><input class="mono svelte-1khbtcu" list="dirs" spellcheck="false" autocomplete="off" aria-label="path: change it to move the note"/></label> <!>`,1),Ce=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>`),we=t(`<p class="full problem svelte-1khbtcu" role="alert"> </p>`),Te=t(`<option></option>`),$=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> <datalist id="dirs"></datalist></div>`);function Ee(e,t){b(t,!0);let i=w(()=>[...new Set(L.listing.notes.map(e=>e.type).filter(Boolean))].sort()),a=w(()=>!t.note.id.startsWith(`@`)),o=m(``),d=m(null);async function h(e){let n=e.value.trim().replace(/^\/+|\/+$/g,``).replace(/\.md$/,``);if(!n||n===t.note.id)e.value=t.note.id;else{y(o,``);try{let e=await t.note.move(n);await L.refresh(),await ne(re(e),{replaceState:!0})}catch(n){y(o,n.message,!0),e.value=t.note.id}}}async function _(){y(o,``);try{let e=await L.api.map();y(d,[...new Set(e.model.edges.filter(([e,n])=>n===t.note.id&&e!==t.note.id&&!e.startsWith(`@`)).map(([t])=>e.notes[t]?.title||t))],!0)}catch(e){y(o,e.message,!0)}}async function x(){try{await t.note.remove(),await L.refresh(),await ne(te(`/notes`),{replaceState:!0})}catch(e){y(o,e.message,!0),y(d,null)}}var T=$(),D=l(T),O=v(l(D));k(O),A(D);var j=v(D,2),ee=v(l(j));k(ee),A(j);var M=v(j,2),P=v(l(M));k(P),A(M);var ie=v(M,2),R=e=>{var r=Q(),i=N(r),a=v(l(i));k(a),A(i);var o=v(i,2),c=e=>{var t=Z();p(`click`,t,()=>void _()),f(e,t)};n(o,e=>{s(d)===null&&e(c)}),g(()=>C(a,t.note.id)),p(`change`,a,e=>void h(e.currentTarget)),p(`keydown`,a,e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(e.currentTarget.value=t.note.id,e.currentTarget.blur())}),f(e,r)};n(ie,e=>{s(a)&&e(R)});var z=v(ie,2),ae=e=>{var t=Ce(),i=l(t),a=v(l(i)),o=e=>{var t=u();g(e=>r(t,`${s(d).length===1?`One note links`:`${s(d).length} notes link`} to it (${e??``}); ${s(d).length===1?`its link is`:`their links are`} left broken.`),[()=>s(d).join(`, `)]),f(e,t)},c=e=>{var t=u(`No note links to it.`);f(e,t)};n(a,e=>{s(d).length?e(o):e(c,-1)}),S(),A(i);var m=v(i,2),h=v(m,2);A(t),p(`click`,m,()=>void x()),p(`click`,h,()=>{y(d,null)}),f(e,t)};n(z,e=>{s(d)!==null&&e(ae)});var B=v(z,2),V=e=>{var t=we(),n=c(t,!0);g(()=>r(n,s(o))),f(e,t)};n(B,e=>{s(o)&&e(V)});var H=v(B,2);I(H,20,()=>s(i),e=>e,(e,t)=>{var n=Te(),r={};g(()=>{r!==(r=t)&&(n.value=(n.__value=r)??``)}),f(e,n)}),A(H);var U=v(H,2);I(U,20,()=>L.listing.dirs,e=>e,(e,n)=>{var r=Te(),i={};g(e=>{i!==(i=e)&&(r.value=(r.__value=i)??``)},[()=>`${n}/${t.note.id.split(`/`).at(-1)}`]),f(e,r)}),A(U),A(T),g(e=>{C(O,t.note.fields.type),F(O,`size`,e),C(ee,t.note.fields.tags),C(P,t.note.fields.description)},[()=>Math.max(7,t.note.fields.type.length)]),p(`input`,O,e=>t.note.setFields({type:e.currentTarget.value})),p(`change`,ee,e=>t.note.setFields({tags:e.currentTarget.value})),p(`input`,P,e=>t.note.setFields({description:e.currentTarget.value})),f(e,T),E()}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(e,t){b(t,!0);let i=w(()=>{try{let[e,n,r]=se(t.text);return{title:/^title:\s*(.*)$/m.exec(n??``)?.[1]?.trim().replace(/^["']|["']$/g,``)??``,body:r,lines:e.split(`
2
+ `).length-1}}catch{return{title:``,body:t.text,lines:0}}}),a,u=m(void 0);j(()=>(y(u,pe(a,{doc:s(i).body,onChange:()=>void 0,onSave:()=>void 0,label:`The note as it was`,notes:()=>[],readOnly:!0})),()=>s(u)?.destroy())),o(()=>{let e=t.touched,n=s(i).lines;s(u)?.dispatch({effects:he.of(e?{who:e.who,lines:e.lines.map(e=>e-n)}:null)})});var d=Ae(),p=l(d),h=e=>{var t=De(),n=c(t,!0);g(()=>r(n,s(i).title)),f(e,t)};n(p,e=>{s(i).title&&s(i).title!==t.title&&e(h)});var _=v(p,2),x=e=>{var n=Oe(),i=v(l(n)),a=c(i,!0);A(n),g(()=>r(a,t.asked)),f(e,n)};n(_,e=>{t.asked!==void 0&&e(x)});var S=v(_,2);P(S,e=>a=e,()=>a);var C=v(S,2),T=e=>{var n=ke(),i=l(n),a=c(i,!0);A(n),g(()=>r(a,t.offered)),f(e,n)};n(C,e=>{t.offered!==void 0&&e(T)}),A(d),f(e,d),E()}var Me=e=>{var t=Ne();f(e,t)},Ne=D(`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 1v14" stroke="currentColor" stroke-width="1.2" fill="none"></path><rect x="5.5" y="2" width="5" height="3.2" fill="currentColor"></rect><path d="M8 6.3l2.3 2.3L8 10.9 5.7 8.6z" fill="currentColor"></path><rect x="5.5" y="12" width="5" height="3" fill="none" stroke="currentColor" stroke-width="1.2"></rect></svg>`),Pe=t(`<p class="faint">opening…</p>`),Fe=t(`<p class="soft">There is no note at <span class="faint"> </span>.</p> <p><a>all notes</a></p>`,1),Ie=t(`<p class="bad svelte-18ltlst"> </p>`),Le=t(`<button class="btn" type="button">take theirs</button>`),Re=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>`),ze=t(`<i></i>`),Be=t(`<span class="label">due</span>`),Ve=t(`<div class="evidence label svelte-18ltlst"><span class="by svelte-18ltlst"> </span><span> </span><span class="grow"></span><span> </span></div>`),He=t(`<div class="evidence label svelte-18ltlst">nothing yet</div>`),Ue=t(`<div class="reading svelte-18ltlst"><span class="soft"> </span> <span class="squares svelte-18ltlst"></span> <!></div> <!>`,1),We=t(`<div class="frame why svelte-18ltlst" role="region" aria-label="Iso's read of you"><span class="frame-title">Iso's read of you</span> <!> <div class="row svelte-18ltlst"><span class="label">rated too highly? one square down for each note it tests</span><span class="grow"></span><button class="link svelte-18ltlst" type="button">[ wind back ]</button></div></div>`),Ge=t(`<a> </a>`),Ke=t(`<span class="faint">nothing: name a note in its tests</span>`),qe=t(`<div class="tests svelte-18ltlst"><span class="label"> </span> <!> <span class="grow"></span> <div class="tools svelte-18ltlst"><button class="icon svelte-18ltlst" type="button" aria-label="timeline" title="timeline"><!></button> <button class="btn quiet svelte-18ltlst" type="button">details</button> <button class="btn quiet svelte-18ltlst" type="button">source</button></div></div>`),Je=t(`<label class="hidden-label" for="title">Title</label> <textarea id="title" class="serif title svelte-18ltlst" rows="1" autocomplete="off"></textarea>`,1),Ye=t(`<span class="grow faint"> </span>`),Xe=t(`<button class="icon svelte-18ltlst" type="button" aria-label="timeline" title="timeline"><!></button>`),Ze=t(`<button class="btn quiet svelte-18ltlst" type="button">details</button>`),Qe=t(`<button class="btn quiet svelte-18ltlst" type="button" data-tour="send">send to agent</button>`),$e=t(`<span class="bad svelte-18ltlst" role="alert"> </span>`),et=t(`<div class="margin svelte-18ltlst" role="group" aria-label="Iso's read of you"><span class="squares svelte-18ltlst"></span> <!> <span class="label"> </span> <button class="link svelte-18ltlst" type="button">[ + an exercise ]</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>`),nt=t(`<div class="tl-col svelte-18ltlst"><!></div>`),rt=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),it=t(`<button class="btn" type="button">mark as answer</button>`),at=t(`<span class="label">Iso is marking</span>`),ot=t(`<span class="label">select a part of your working, then mark it as your answer</span>`),st=t(`<span class="label moves svelte-18ltlst">moves: <!></span>`),ct=t(`<span class="label"> </span>`),lt=t(`<div class="foot svelte-18ltlst"><!> <button class="btn primary tall svelte-18ltlst" type="button"> </button> <!> <span class="grow"></span> <!></div>`),ut=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>`),dt=t(`<div class="seed svelte-18ltlst"><button class="field svelte-18ltlst" type="button"><span class="faint">›</span><span class="faint">ask Iso here</span></button></div>`),ft=t(`<!> <!> <!> <!> <!> <!> <!> <div class="live"><!></div> <!> <!> <!>`,1),pt=t(`<article><!></article>`);function mt(e,t){b(t,!0);let d=new W(t.id),x=new me(d),D=ae(t.id)?new Se(d,x):null,O=w(()=>D?.is?D:null),k=m(!1),M={written:`written response`},P=e=>L.listing.notes.find(t=>t.id===e)?.title??e.split(`/`).at(-1),R=!t.id.startsWith(`@`)&&!!L.session?.study,V=m(null),H=m(``),U=w(()=>s(V)?.notes[t.id]),se=w(()=>s(V)?.exercises.filter(e=>e.tests.includes(t.id)).length??0),fe=[`not reached`,`opened`,`worked through`,`understood`];async function pe(){try{y(V,await L.api.study())}catch{}}async function he(){try{let e=await L.api.createExerciseDraft(L.listing.notes.find(e=>e.id===t.id)?.dir??t.id.split(`/`).slice(0,-1).join(`/`),[t.id]);await ne(te(`/draft/[id]`,{id:e.id.slice(7)}))}catch(e){y(H,e.message,!0)}}let _e=e=>{try{return localStorage.getItem(e)===`1`}catch{return!1}},ve=(e,t)=>{try{localStorage.setItem(e,t?`1`:`0`)}catch{}},G=m(_(_e(`isorite.details`))),K=m(!1),q=w(()=>s(K)||d.meta===null),J=m(_(_e(`isorite.timeline`))),Y=m(null),X=m(null),be=m(!1),Z=m(``),Q=w(()=>ie(x.entries)),Ce=e=>e.who.startsWith(`iso:`)||e.who.startsWith(`agent:`),we=e=>e.flatMap(e=>Array.from({length:e.to-e.from},(t,n)=>e.from+n)),Te=w(()=>{if(!s(J)||s(X)||s(q))return null;let e=s(Y)??s(Q).findLast(e=>Ce(e)&&e.what===`kept`);if(!e)return null;let t=we(z(x.entries,e.ids).runs);return t.length?{who:Ce(e)?`iso`:`you`,lines:t}:null}),$=w(()=>{if(!s(X))return null;let e=ce(s(X)),t=B(x.entries,e);if(t===null)return null;let n=x.entries.filter(t=>t.id<=e),r=x.entries.find(e=>e.id===s(X).ids[0]),i=(s(X).what===`offered`||s(X).what===`discarded`)&&r?.kind===`proposal`?r.form===`insert`?r.text:r.regions.map(e=>e.new).join(`
3
+
4
+ `):void 0;return{text:t,touched:{who:Ce(s(X))?`iso`:`you`,lines:we(z(n,s(X).ids).runs)},asked:s(X).asked,offered:i}}),De=new URLSearchParams(location.hash.split(`?`)[1]??``).get(`at`);o(()=>{if(!De)return;let e=s(Q).find(e=>e.ids.includes(De));e&&(De=null,y(J,!0),y(X,e))});function Oe(){y(J,!s(J)),ve(`isorite.timeline`,s(J)),s(J)||(y(X,null),y(Y,null))}function ke(e){y(Z,``),y(X,s(X)===e?null:e)}function Ae(e){if(!s(X))return;let t=s(Q).indexOf(s(X))+e;t>=0&&t<s(Q).length&&y(X,s(Q)[t])}async function Ne(){if(s(X)){y(be,!0),y(Z,``);try{await d.restore(ce(s(X))),y(X,null)}catch(e){y(Z,e.message,!0)}finally{y(be,!1)}}}function mt(e){!s(X)||e.altKey||e.ctrlKey||e.metaKey||e.target instanceof HTMLElement&&(e.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName))||(e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),Ae(-1)):e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),Ae(1)):e.key===`Escape`&&(e.preventDefault(),y(X,null)))}j(()=>{L.open=t.id,d.open().then(()=>x.open()),D?.open();let e=R?L.on(e=>{(e.type===`record`||e.type===`note-changed`&&e.id.startsWith(`@study/`))&&pe()}):null;R&&pe();let n=()=>{d.save()};return addEventListener(`pagehide`,n),document.addEventListener(`visibilitychange`,n),()=>{removeEventListener(`pagehide`,n),e?.(),document.removeEventListener(`visibilitychange`,n),x.close(),D?.close(),L.exercise=null,L.hint=``,d.close(),L.here=``,L.open=``,L.saving=null}}),o(()=>{L.exercise=s(O)?{kind:M[s(O).ex.kind]??s(O).ex.kind,squares:s(O).squares.squares,due:s(O).squares.due,flash:s(O).flash,windBack:()=>void s(O).windBack(),why:()=>y(k,!s(k)),next:s(O).ex.next?`@study/${s(O).ex.next}`:null}:null,L.hint=s(O)?`write as much as you like · only what you mark is your answer`:``});let ht={saved:`saved`,unsaved:`not saved yet`,saving:`saving`,conflict:`changed elsewhere: choose below`,failed:`not saved`};o(()=>{L.here=d.loaded===`ready`?d.fields.title||t.id.split(`/`).at(-1):``,L.saving=d.loaded===`ready`?{text:d.saving===`failed`?`not saved: ${d.message}`:ht[d.saving],bad:d.saving===`failed`||d.saving===`conflict`}:null});let gt=w(()=>[...new Set(x.changes.map(e=>oe(e.proposal.who)||`Iso`))].join(` and `)),_t=m(!1),vt=w(()=>x.cursor&&x.cursor.to>x.cursor.from?d.text.slice(x.cursor.from,x.cursor.to).trim():``);var yt=pt();i(`keydown`,a,mt);let bt;var xt=l(yt),St=e=>{var t=Pe();f(e,t)},Ct=e=>{var n=Fe(),i=N(n),a=v(l(i)),o=c(a,!0);S(),A(i);var s=v(i,2),u=c(s);g(e=>{r(o,t.id),F(u,`href`,e)},[()=>te(`/notes`)]),f(e,n)},wt=e=>{var t=Ie(),n=c(t,!0);g(()=>r(n,d.message)),f(e,t)},Tt=e=>{var i=ft(),a=N(i),o=e=>{var t=Re(),i=v(l(t),2),a=c(i,!0),o=v(i,2),s=l(o),u=v(s,2),m=e=>{var t=Le();p(`click`,t,()=>d.keepTheirs()),f(e,t)};n(u,e=>{d.theirs&&e(m)}),A(o),S(2),A(t),g(()=>r(a,d.theirs===null?`This note was deleted or moved while you were writing.`:`This note was changed somewhere else while you were writing. Nothing here has been saved over it.`)),p(`click`,s,()=>d.keepMine()),f(e,t)};n(a,e=>{d.saving===`conflict`&&e(o)});var m=v(a,2),_=e=>{var t=We(),i=v(l(t),2);I(i,16,()=>s(O).ex.tests,e=>e,(e,t)=>{let i=w(()=>s(O).study?.notes[t]);var a=Ue(),o=N(a),u=l(o),d=c(u,!0),p=v(u,2);I(p,20,()=>[0,1,2,3,4,5],e=>e,(e,t)=>{var n=ze();let r;g(()=>r=T(n,1,`pip`,null,r,{lv:t<(s(i)?.squares??0)})),f(e,n)}),A(p);var m=v(p,2),h=e=>{var t=Be();f(e,t)};n(m,e=>{s(i)?.due&&e(h)}),A(o);var _=v(o,2);I(_,17,()=>[...s(i)?.evidence??[]].reverse(),e=>e.id,(e,t)=>{var n=Ve(),i=l(n),a=c(i,!0),o=v(i),u=c(o,!0),d=v(o,2),p=c(d,!0);A(n),g((e,n)=>{r(a,e),r(u,s(t).event===`wind-back`?`you wound it back`:s(t).why||(s(t).result??``)),r(p,n)},[()=>xe(s(t).by),()=>s(t).at.slice(0,10)]),f(e,n)},e=>{var t=He();f(e,t)}),g(e=>{r(d,e),F(p,`aria-label`,`${s(i)?.squares??0??``} of 6`)},[()=>P(t)]),f(e,a)});var a=v(i,2),o=v(l(a),2);A(a),A(t),p(`click`,o,()=>s(O).windBack()),f(e,t)};n(m,e=>{s(O)&&s(k)&&e(_)});var b=v(m,2),E=e=>{var t=qe(),n=l(t),i=c(n),a=v(n,2);I(a,16,()=>s(O).ex.tests,e=>e,(e,t)=>{var n=Ge(),i=c(n,!0);g((e,t)=>{F(n,`href`,e),r(i,t)},[()=>re(t),()=>P(t)]),f(e,n)},e=>{var t=Ke();f(e,t)});var o=v(a,4),u=l(o);Me(l(u)),A(u);var m=v(u,2),h=v(m,2);A(o),A(t),g(()=>{r(i,`${M[s(O).ex.kind]??s(O).ex.kind??``} · tests`),F(u,`aria-pressed`,s(J)),F(m,`aria-pressed`,s(G)),F(h,`aria-pressed`,s(q)),h.disabled=d.meta===null}),p(`click`,u,Oe),p(`click`,m,()=>{y(G,!s(G)),ve(`isorite.details`,s(G))}),p(`click`,h,()=>y(K,!s(K))),f(e,t)},D=e=>{var i=tt(),a=l(i),o=e=>{var n=Je(),r=v(N(n),2);ee(r),g(e=>{C(r,d.fields.title),F(r,`placeholder`,e)},[()=>t.id.split(`/`).at(-1)]),p(`input`,r,e=>d.setFields({title:e.currentTarget.value.replace(/\s*\n\s*/g,` `)})),p(`keydown`,r,e=>{e.key===`Enter`&&e.preventDefault()}),f(e,n)},u=e=>{var n=Ye(),i=c(n);g(()=>r(i,`${t.id??``}.md${d.meta===null?`: the frontmatter cannot be read, so the file is shown as it is`:``}`)),f(e,n)};n(a,e=>{s(q)?e(u,-1):e(o)});var m=v(a,2),h=l(m),_=l(h),b=e=>{var t=Xe();Me(l(t)),A(t),g(()=>F(t,`aria-pressed`,s(J))),p(`click`,t,Oe),f(e,t)};n(_,e=>{s(q)||e(b)});var x=v(_,2),S=e=>{var t=Ze();g(()=>F(t,`aria-pressed`,s(G))),p(`click`,t,()=>{y(G,!s(G)),ve(`isorite.details`,s(G))}),f(e,t)};n(x,e=>{s(q)||e(S)});var w=v(x,2),E=v(w,2),D=e=>{var t=Qe();g(()=>F(t,`aria-pressed`,s(_t))),p(`click`,t,()=>y(_t,!s(_t))),f(e,t)};n(E,e=>{s(q)||e(D)}),A(h);var O=v(h,2),k=e=>{var i=et(),a=l(i);I(a,20,()=>[0,1,2,3,4,5],e=>e,(e,t)=>{var n=ze();let r;g(()=>r=T(n,1,`pip`,null,r,{lv:t<(s(U)?.squares??0)})),f(e,n)}),A(a);var o=v(a,2),u=e=>{var n=Ge(),i=c(n);g(e=>{F(n,`href`,e),r(i,`${s(se)??``} ${s(se)===1?`exercise`:`exercises`}`)},[()=>`${te(`/study`)}?note=${encodeURIComponent(t.id)}`]),f(e,n)};n(o,e=>{s(se)&&e(u)});var d=v(o,2),m=c(d),h=v(d,2),_=v(h,2),y=e=>{var t=$e(),n=c(t,!0);g(()=>r(n,s(H))),f(e,t)};n(_,e=>{s(H)&&e(y)}),A(i),g(()=>{F(a,`aria-label`,`${s(U)?.squares??0??``} of 6`),r(m,`${fe[s(U)?.step??0]??``}${s(U)?.due?` · due`:``}`)}),p(`click`,h,he),f(e,i)};n(O,e=>{R&&!s(q)&&s(V)&&e(k)}),A(m),A(i),g(()=>{F(w,`aria-pressed`,s(q)),w.disabled=d.meta===null}),p(`click`,w,()=>y(K,!s(K))),f(e,i)};n(b,e=>{s(O)&&!s(q)?e(E):e(D,-1)});var j=v(b,2),ne=e=>{ye(e,{get note(){return t.id},get passage(){return s(vt)},onclose:()=>y(_t,!1)})};n(j,e=>{s(_t)&&!s(q)&&e(ne)});var L=v(j,2),ie=e=>{Ee(e,{get note(){return d}})};n(L,e=>{s(G)&&!s(q)&&e(ie)});var z=v(L,2),ae=e=>{var t=nt(),n=l(t);{let e=w(()=>s(X)?ce(s(X)):null);de(n,{get moments(){return s(Q)},get at(){return s(e)},get pointed(){return s(Y)},point:e=>y(Y,e),pick:ke})}A(t),f(e,t)};n(z,e=>{s(J)&&!s(q)&&e(ae)});var B=v(z,2),oe=e=>{var t=rt(),i=N(t),a=l(i),o=c(a),u=v(a,4),m=e=>{var t=$e(),n=c(t,!0);g(()=>r(n,s(Z))),f(e,t)};n(u,e=>{s(Z)&&e(m)});var _=v(u,2),b=v(_,2);A(i);var x=v(i,2);h(x,()=>ce(s(X)),e=>{je(e,{get text(){return s($).text},get title(){return d.fields.title},get touched(){return s($).touched},get asked(){return s($).asked},get offered(){return s($).offered}})}),g((e,t)=>{r(o,`${e??``} · ${t??``}`),_.disabled=s(be)||s($).text===d.text},[()=>ue(s(X)),()=>le(s(X).at)]),p(`click`,_,Ne),p(`click`,b,()=>y(X,null)),f(e,t)};n(B,e=>{s(X)&&s($)&&e(oe)});var W=v(B,2),pe=l(W);h(pe,()=>s(q),e=>{{let t=w(()=>s(O)??void 0);ge(e,{get note(){return d},get iso(){return x},get exercise(){return s(t)},get source(){return s(q)},get touched(){return s(Te)}})}}),A(W);var me=v(W,2),_e=e=>{var t=lt(),i=l(t),a=e=>{var t=it();p(`mousedown`,t,e=>e.preventDefault()),p(`click`,t,()=>s(O).markAnswer()),f(e,t)};n(i,e=>{s(O).selection&&!(s(O).answerAt&&s(O).answerAt.from===s(O).selection.from&&s(O).answerAt.to===s(O).selection.to)&&e(a)});var o=v(i,2),d=c(o,!0),m=v(o,2),h=e=>{var t=at();f(e,t)},_=e=>{var t=$e(),n=c(t,!0);g(()=>r(n,s(O).failed)),f(e,t)},y=e=>{var t=ot();f(e,t)},b=e=>{var t=st(),n=v(l(t));I(n,19,()=>s(O).moves,e=>e.note,(e,t,n)=>{S();var i=u();g((e,t)=>r(i,`${s(n)?`, `:``}${e??``} ${t??``}`),[()=>P(s(t).note),()=>xe(s(t).by)]),f(e,i)}),A(t),f(e,t)};n(m,e=>{s(O).marking===null?s(O).failed?e(_,1):s(O).answerAt?s(O).last&&e(b,3):e(y,2):e(h)});var x=v(m,4),C=e=>{var t=ct(),n=c(t);g(e=>r(n,`${s(O).last.cost.tier??``} · $${e??``}`),[()=>s(O).last.cost.usd.toFixed(3)]),f(e,t)};n(x,e=>{s(O).last?.cost&&s(O).marking===null&&e(C)}),A(t),g(()=>{o.disabled=!s(O).answerAt||s(O).marking!==null,r(d,s(O).marking===null?s(O).last?`mark it again`:`send for marking`:`marking…`)}),p(`click`,o,()=>s(O).send()),f(e,t)};n(me,e=>{s(O)&&!s(q)&&!s(X)&&e(_e)});var Se=v(me,2),Ce=e=>{var t=ut(),n=v(l(t),2),i=c(n),a=v(n,4),o=v(a,2);A(t),g(()=>{r(i,`${x.changes.length??``} ${x.changes.length===1?`change`:`changes`} from ${s(gt)??``} waiting`),a.disabled=x.busy===`all`,o.disabled=x.busy===`all`}),p(`click`,a,()=>x.settleAll(!0)),p(`click`,o,()=>x.settleAll(!1)),f(e,t)};n(Se,e=>{x.changes.length&&e(Ce)});var we=v(Se,2),De=e=>{var t=dt(),n=c(t);p(`click`,n,()=>x.promptHere()),f(e,t)};n(we,e=>{x.prompt===null&&!x.asking&&e(De)}),g(e=>F(W,`hidden`,e),[()=>!!(s(X)&&s($))]),f(e,i)};n(xt,e=>{d.loaded===`loading`?e(St):d.loaded===`missing`?e(Ct,1):d.loaded===`error`?e(wt,2):e(Tt,-1)}),A(yt),g(()=>bt=T(yt,1,`note svelte-18ltlst`,null,bt,{timed:s(J)&&d.loaded===`ready`&&!s(q)})),f(e,yt),E()}d([`click`,`input`,`keydown`,`mousedown`]);function ht(t,n){b(n,!1),M();var r=O(),i=N(r);h(i,()=>fe.params.id,t=>{{let n=e(()=>fe.params.id??``);mt(t,{get id(){return s(n)}})}}),f(t,r),E()}export{ht as component};