cognitune 0.3.1 → 0.3.2

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 (75) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/web/assets/Map-DS1CSocK.js +11 -0
  3. package/dist/web/assets/{Practice-DNf-tMjl.js → Practice-I2bYp2SG.js} +3 -3
  4. package/dist/web/assets/{_baseUniq-7KLmbwxc.js → _baseUniq-CgG_mifj.js} +1 -1
  5. package/dist/web/assets/{architectureDiagram-UYN6MBPD-DFK-K3Yp.js → architectureDiagram-UYN6MBPD-QZTspen1.js} +1 -1
  6. package/dist/web/assets/{blockDiagram-ZHA2E4KO-D9jSBc-F.js → blockDiagram-ZHA2E4KO-CbhjZ2S8.js} +1 -1
  7. package/dist/web/assets/{c4Diagram-6F5ED5ID-KAOALvx3.js → c4Diagram-6F5ED5ID-A3b4lbII.js} +1 -1
  8. package/dist/web/assets/channel-BKUyG-l5.js +1 -0
  9. package/dist/web/assets/{chunk-5HRBRIJM-Btr12S8H.js → chunk-5HRBRIJM-ChWRBpuq.js} +1 -1
  10. package/dist/web/assets/{chunk-7U56Z5CX-NWMyaEQ0.js → chunk-7U56Z5CX-Cjcjfrgo.js} +1 -1
  11. package/dist/web/assets/{chunk-ASOPGD6M-DdvxpUSZ.js → chunk-ASOPGD6M-Bhu3AOZc.js} +1 -1
  12. package/dist/web/assets/{chunk-KFBOBJHC-CLK5Qods.js → chunk-KFBOBJHC-BekFNaeo.js} +1 -1
  13. package/dist/web/assets/{chunk-T2TOU4HS-B-nrzheR.js → chunk-T2TOU4HS-B9G0vLnI.js} +1 -1
  14. package/dist/web/assets/{chunk-TMUBEWPD-DCsdC8PC.js → chunk-TMUBEWPD-DSAk9aXZ.js} +1 -1
  15. package/dist/web/assets/classDiagram-LNE6IOMH-zE4bnqcI.js +1 -0
  16. package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-zE4bnqcI.js +1 -0
  17. package/dist/web/assets/clone-BjRjnhL1.js +1 -0
  18. package/dist/web/assets/{dagre-4EVJKHTY-D_09gC0H.js → dagre-4EVJKHTY-CJiQ7M56.js} +1 -1
  19. package/dist/web/assets/{diagram-QW4FP2JN-quH5WQny.js → diagram-QW4FP2JN-BtE9T_jx.js} +1 -1
  20. package/dist/web/assets/{erDiagram-6RL3IURR-BmJHLDew.js → erDiagram-6RL3IURR-BURUFe_9.js} +1 -1
  21. package/dist/web/assets/{flowDiagram-7ASYPVHJ-DNzT7Cua.js → flowDiagram-7ASYPVHJ-CfE3lrqz.js} +1 -1
  22. package/dist/web/assets/{ganttDiagram-NTVNEXSI-6reJ1AIG.js → ganttDiagram-NTVNEXSI-D9d9jWBm.js} +1 -1
  23. package/dist/web/assets/{gitGraph-YCYPL57B-BfipSUJ3.js → gitGraph-YCYPL57B-CJ1V9XJf.js} +1 -1
  24. package/dist/web/assets/{gitGraphDiagram-NRZ2UAAF-BRb9bqzI.js → gitGraphDiagram-NRZ2UAAF-CqaSLfzI.js} +1 -1
  25. package/dist/web/assets/{graph-BHXuL-RR.js → graph-B64LQEXc.js} +1 -1
  26. package/dist/web/assets/{index-CyHGDhfc.js → index-6_jiQxLN.js} +1 -1
  27. package/dist/web/assets/{index-D-DY42g9.js → index-9QHEA9wu.js} +1 -1
  28. package/dist/web/assets/{index-Dl6tJxzv.js → index-B-ZU5R2V.js} +1 -1
  29. package/dist/web/assets/{index-BiiiKqbq.js → index-B2zJKCq3.js} +1 -1
  30. package/dist/web/assets/{index-wnqHtEcu.js → index-B52f3nVk.js} +1 -1
  31. package/dist/web/assets/{index-dA5Y-R2D.js → index-BH0BWKEP.js} +4 -4
  32. package/dist/web/assets/{index-Bsf4UF_h.js → index-BluWHHG-.js} +1 -1
  33. package/dist/web/assets/{index-D_DIS1os.js → index-CUD1JdXZ.js} +1 -1
  34. package/dist/web/assets/{index-C5JoMvch.js → index-CVnYyVgS.js} +1 -1
  35. package/dist/web/assets/{index-B5Tomqy6.js → index-CtDCXRra.js} +1 -1
  36. package/dist/web/assets/{index-TI1LWXRL.js → index-CujTkxIF.js} +1 -1
  37. package/dist/web/assets/{index-BCM7jSxq.js → index-DGSEVmt_.js} +1 -1
  38. package/dist/web/assets/{index-7JDqNzz1.js → index-DQIDx0VL.js} +1 -1
  39. package/dist/web/assets/{index-DXji-ikE.js → index-DYV_a5pR.js} +1 -1
  40. package/dist/web/assets/{index-Bli4383n.js → index-DZX_ApSV.js} +1 -1
  41. package/dist/web/assets/index-DeUkCZCv.css +1 -0
  42. package/dist/web/assets/{index-CQjof-kk.js → index-Dhqj7fLA.js} +1 -1
  43. package/dist/web/assets/{index-DRri1mnd.js → index-GNn9Y8IP.js} +1 -1
  44. package/dist/web/assets/{index-BsH1Ca5H.js → index-ISt4JlWL.js} +1 -1
  45. package/dist/web/assets/{index-BM9KwSU5.js → index-LjQbNYY4.js} +1 -1
  46. package/dist/web/assets/{index-B49g1XNF.js → index-Z72XDUwe.js} +1 -1
  47. package/dist/web/assets/{index-CNViI9C2.js → index-fUwh3MJR.js} +1 -1
  48. package/dist/web/assets/{index-ysHMZpcw.js → index-fcWIc_lJ.js} +1 -1
  49. package/dist/web/assets/{index-C67RtHfG.js → index-nRMB7HRL.js} +1 -1
  50. package/dist/web/assets/{infoDiagram-A4XQUW5V-CE9eDiRA.js → infoDiagram-A4XQUW5V-DMcs4U8y.js} +1 -1
  51. package/dist/web/assets/{journeyDiagram-G5WM74LC-D_iPCzBK.js → journeyDiagram-G5WM74LC-CEds3uag.js} +1 -1
  52. package/dist/web/assets/{kanban-definition-QRCXZQQD-Bxj-EOmZ.js → kanban-definition-QRCXZQQD-yZwdqxsV.js} +1 -1
  53. package/dist/web/assets/{layout-CQ6J22ew.js → layout-DYrE6rew.js} +1 -1
  54. package/dist/web/assets/{layout.worker-Bzrmqu8H.js → layout.worker-Dx5bqvNP.js} +1 -1
  55. package/dist/web/assets/{mermaid.core-27sLJoRM.js → mermaid.core-C4isYGdZ.js} +4 -4
  56. package/dist/web/assets/{min-h0zR_W4w.js → min-D7IE57rG.js} +1 -1
  57. package/dist/web/assets/{mindmap-definition-GWI6TPTV-DiBTVWc8.js → mindmap-definition-GWI6TPTV-BrA9fZLl.js} +28 -28
  58. package/dist/web/assets/{pieDiagram-YF2LJOPJ-BE2VMHC3.js → pieDiagram-YF2LJOPJ-DBLJF-B8.js} +1 -1
  59. package/dist/web/assets/{quadrantDiagram-OS5C2QUG-DkN-8Avj.js → quadrantDiagram-OS5C2QUG-W3e7OODv.js} +1 -1
  60. package/dist/web/assets/{requirementDiagram-MIRIMTAZ-0OCRbKti.js → requirementDiagram-MIRIMTAZ-DmouihuU.js} +1 -1
  61. package/dist/web/assets/{sankeyDiagram-Y46BX6SQ-6v9qBJFv.js → sankeyDiagram-Y46BX6SQ-k_4HmTUK.js} +1 -1
  62. package/dist/web/assets/{sequenceDiagram-G6AWOVSC-CjH7axp-.js → sequenceDiagram-G6AWOVSC-C4Kq2ABe.js} +1 -1
  63. package/dist/web/assets/{stateDiagram-MAYHULR4-Bbbno_Ix.js → stateDiagram-MAYHULR4-C5a59rCP.js} +1 -1
  64. package/dist/web/assets/stateDiagram-v2-4JROLMXI-CeQk6jDo.js +1 -0
  65. package/dist/web/assets/{timeline-definition-U7ZMHBDA-BSIsFSlr.js → timeline-definition-U7ZMHBDA-CtkRQwlM.js} +1 -1
  66. package/dist/web/assets/{xychartDiagram-6QU3TZC5-B12dxFiy.js → xychartDiagram-6QU3TZC5-KKa8nieo.js} +1 -1
  67. package/dist/web/index.html +2 -2
  68. package/package.json +1 -1
  69. package/dist/web/assets/Map-xBJDQ_Xn.js +0 -1
  70. package/dist/web/assets/channel-BW4MllLS.js +0 -1
  71. package/dist/web/assets/classDiagram-LNE6IOMH-D4kEJsvG.js +0 -1
  72. package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-D4kEJsvG.js +0 -1
  73. package/dist/web/assets/clone-C8mTbP7R.js +0 -1
  74. package/dist/web/assets/index-CyhIx47s.css +0 -1
  75. package/dist/web/assets/stateDiagram-v2-4JROLMXI-CvrRdVH2.js +0 -1
@@ -465,10 +465,10 @@ Error generating stack: `+s.message+`
465
465
  * LICENSE.md file in the root directory of this source tree.
466
466
  *
467
467
  * @license MIT
468
- */function pl(){return pl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pl.apply(this,arguments)}function d0(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,s;for(s=0;s<r.length;s++)i=r[s],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function _N(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function $N(e,t){return e.button===0&&(!t||t==="_self")&&!_N(e)}function Nh(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function qN(e,t){let n=Nh(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const BN=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],UN=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],HN="6";try{window.__reactRouterVersion=HN}catch{}function WN(e,t){return J2({basename:void 0,future:pl({},void 0,{v7_prependBasename:!0}),history:b2({window:void 0}),hydrationData:VN(),routes:e,mapRouteProperties:ON,dataStrategy:void 0,patchRoutesOnNavigation:void 0,window:void 0}).initialize()}function VN(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=pl({},t,{errors:QN(t.errors)})),t}function QN(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new wu(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let s=window[i.__subType];if(typeof s=="function")try{let l=new s(i.message);l.stack="",n[r]=l}catch{}}if(n[r]==null){let s=new Error(i.message);s.stack="",n[r]=s}}else n[r]=i;return n}const h0=b.createContext({isTransitioning:!1}),KN=b.createContext(new Map),GN="startTransition",Eg=sk[GN],YN="flushSync",Pg=vj[YN];function XN(e){Eg?Eg(e):e()}function Dl(e){Pg?Pg(e):e()}class JN{constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function ZN(e){let{fallbackElement:t,router:n,future:r}=e,[i,s]=b.useState(n.state),[l,o]=b.useState(),[u,c]=b.useState({isTransitioning:!1}),[d,h]=b.useState(),[p,f]=b.useState(),[m,g]=b.useState(),k=b.useRef(new Map),{v7_startTransition:y}=r||{},x=b.useCallback(M=>{y?XN(M):M()},[y]),v=b.useCallback((M,F)=>{let{deletedFetchers:C,flushSync:O,viewTransitionOpts:A}=F;C.forEach(U=>k.current.delete(U)),M.fetchers.forEach((U,q)=>{U.data!==void 0&&k.current.set(q,U.data)});let V=n.window==null||n.window.document==null||typeof n.window.document.startViewTransition!="function";if(!A||V){O?Dl(()=>s(M)):x(()=>s(M));return}if(O){Dl(()=>{p&&(d&&d.resolve(),p.skipTransition()),c({isTransitioning:!0,flushSync:!0,currentLocation:A.currentLocation,nextLocation:A.nextLocation})});let U=n.window.document.startViewTransition(()=>{Dl(()=>s(M))});U.finished.finally(()=>{Dl(()=>{h(void 0),f(void 0),o(void 0),c({isTransitioning:!1})})}),Dl(()=>f(U));return}p?(d&&d.resolve(),p.skipTransition(),g({state:M,currentLocation:A.currentLocation,nextLocation:A.nextLocation})):(o(M),c({isTransitioning:!0,flushSync:!1,currentLocation:A.currentLocation,nextLocation:A.nextLocation}))},[n.window,p,d,k,x]);b.useLayoutEffect(()=>n.subscribe(v),[n,v]),b.useEffect(()=>{u.isTransitioning&&!u.flushSync&&h(new JN)},[u]),b.useEffect(()=>{if(d&&l&&n.window){let M=l,F=d.promise,C=n.window.document.startViewTransition(async()=>{x(()=>s(M)),await F});C.finished.finally(()=>{h(void 0),f(void 0),o(void 0),c({isTransitioning:!1})}),f(C)}},[x,l,d,n.window]),b.useEffect(()=>{d&&l&&i.location.key===l.location.key&&d.resolve()},[d,p,i.location,l]),b.useEffect(()=>{!u.isTransitioning&&m&&(o(m.state),c({isTransitioning:!0,flushSync:!1,currentLocation:m.currentLocation,nextLocation:m.nextLocation}),g(void 0))},[u.isTransitioning,m]),b.useEffect(()=>{},[]);let j=b.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:M=>n.navigate(M),push:(M,F,C)=>n.navigate(M,{state:F,preventScrollReset:C==null?void 0:C.preventScrollReset}),replace:(M,F,C)=>n.navigate(M,{replace:!0,state:F,preventScrollReset:C==null?void 0:C.preventScrollReset})}),[n]),E=n.basename||"/",w=b.useMemo(()=>({router:n,navigator:j,static:!1,basename:E}),[n,j,E]),N=b.useMemo(()=>({v7_relativeSplatPath:n.future.v7_relativeSplatPath}),[n.future.v7_relativeSplatPath]);return b.useEffect(()=>IN(r,n.future),[r,n.future]),b.createElement(b.Fragment,null,b.createElement(qa.Provider,{value:w},b.createElement(hp.Provider,{value:i},b.createElement(KN.Provider,{value:k.current},b.createElement(h0.Provider,{value:u},b.createElement(DN,{basename:E,location:i.location,navigationType:i.historyAction,navigator:j,future:N},i.initialized||n.future.v7_partialHydration?b.createElement(eS,{routes:n.routes,future:n.future,state:i}):t))))),null)}const eS=b.memo(tS);function tS(e){let{routes:t,future:n,state:r}=e;return bN(t,void 0,r,n)}const nS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",rS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ft=b.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:s,replace:l,state:o,target:u,to:c,preventScrollReset:d,viewTransition:h}=t,p=d0(t,BN),{basename:f}=b.useContext(_r),m,g=!1;if(typeof c=="string"&&rS.test(c)&&(m=c,nS))try{let v=new URL(window.location.href),j=c.startsWith("//")?new URL(v.protocol+c):new URL(c),E=Dr(j.pathname,f);j.origin===v.origin&&E!=null?c=E+j.search+j.hash:g=!0}catch{}let k=yN(c,{relative:i}),y=sS(c,{replace:l,state:o,target:u,preventScrollReset:d,relative:i,viewTransition:h});function x(v){r&&r(v),v.defaultPrevented||y(v)}return b.createElement("a",pl({},p,{href:m||k,onClick:g||s?r:x,ref:n,target:u}))}),Sh=b.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:s="",end:l=!1,style:o,to:u,viewTransition:c,children:d}=t,h=d0(t,UN),p=Zu(u,{relative:h.relative}),f=Si(),m=b.useContext(hp),{navigator:g,basename:k}=b.useContext(_r),y=m!=null&&lS(p)&&c===!0,x=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=f.pathname,j=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;i||(v=v.toLowerCase(),j=j?j.toLowerCase():null,x=x.toLowerCase()),j&&k&&(j=Dr(j,k)||j);const E=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let w=v===x||!l&&v.startsWith(x)&&v.charAt(E)==="/",N=j!=null&&(j===x||!l&&j.startsWith(x)&&j.charAt(x.length)==="/"),M={isActive:w,isPending:N,isTransitioning:y},F=w?r:void 0,C;typeof s=="function"?C=s(M):C=[s,w?"active":null,N?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(M):o;return b.createElement(ft,pl({},h,{"aria-current":F,className:C,ref:n,style:O,to:u,viewTransition:c}),typeof d=="function"?d(M):d)});var Ch;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ch||(Ch={}));var Tg;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Tg||(Tg={}));function iS(e){let t=b.useContext(qa);return t||je(!1),t}function sS(e,t){let{target:n,replace:r,state:i,preventScrollReset:s,relative:l,viewTransition:o}=t===void 0?{}:t,u=gt(),c=Si(),d=Zu(e,{relative:l});return b.useCallback(h=>{if($N(h,n)){h.preventDefault();let p=r!==void 0?r:us(c)===us(d);u(e,{replace:p,state:i,preventScrollReset:s,relative:l,viewTransition:o})}},[c,u,d,r,i,n,e,s,l,o])}function ec(e){let t=b.useRef(Nh(e)),n=b.useRef(!1),r=Si(),i=b.useMemo(()=>qN(r.search,n.current?null:t.current),[r.search]),s=gt(),l=b.useCallback((o,u)=>{const c=Nh(typeof o=="function"?o(i):o);n.current=!0,s("?"+c,u)},[s,i]);return[i,l]}function lS(e,t){t===void 0&&(t={});let n=b.useContext(h0);n==null&&je(!1);let{basename:r}=iS(Ch.useViewTransitionState),i=Zu(e,{relative:t.relative});if(!n.isTransitioning)return!1;let s=Dr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Dr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vu(i.pathname,l)!=null||vu(i.pathname,s)!=null}const Lg=[{title:"Start here",sections:[{id:"start",title:"The idea in one minute",what:"cognitune helps you understand code, not just read it. It asks a model to explain, then makes you answer, explain back and find bugs, and it brings things back when you are about to forget them.",steps:["Open a folder (Projects page). cognitune only reads it. It never changes your files.","Go to Explore. Tick the files you want to understand.","Pick an activity on the right: Lens to read, Quiz or Teach to test yourself.","Wrong answers become Weak spots and review cards. Today shows what to do next."],examples:["First visit: Projects > Open a folder > Explore > tick src/queue.ts > Lens > Explain > Make lens.","Then: Quiz on the same file. Miss a question, and it shows up on Today under Weak spots."],notes:["Each model call takes about 20 to 90 seconds. A bar shows progress; you can keep browsing.","The model reads only the files you tick, plus the notes and context you add. Nothing else leaves your machine."]},{id:"projects",title:"Projects",what:"A project is one folder on your disk. Everything you make (lenses, quizzes, cards) is stored under that project.",steps:["Open a folder with Open folder. Type a path or browse.","Click a project card to enter it. The rail on the left changes to the project pages.","Remove (the button on the project card) takes it off the list. Its data moves to an archive and is deleted after the keep time (Settings > Storage). Opening the same folder again restores it."],examples:["Try the built-in sample: run cognitune with --demo. It opens a tiny queue project with a fake model."]},{id:"keys",title:"Keyboard shortcuts",what:"The short list. Press ? anywhere (outside a text box) to see it in a window.",examples:["Ctrl/Cmd + K : go to a page, file or project, or start an activity on the open file","Ctrl/Cmd + H : this help, opened at the section for the page you are on","? : shortcut list","[ and ] : fold or show the left and right panes","Space : Review, show the answer","1 2 3 4 : Review, rate again / hard / good / easy","Ctrl + Enter : Tutor, send the message","← → : Trace, step back and forward"]},{id:"palette",title:"Quick jump (Ctrl K)",what:"One box to go anywhere or start anything without the mouse.",steps:["Press Ctrl K (Cmd K on Mac).","Type a few letters. Pages, files in this project, other projects and activities are matched.","Press Enter to go. Esc closes."],examples:["Type: rev → Review","Type: queue → files with queue in the path","Type: quiz → start a quiz on the open file"]}]},{title:"Learn a codebase",sections:[{id:"today",title:"Today",what:"What to do now. The page picks the most useful next step so you do not have to decide.",steps:["Read the Suggested next card at the top. Start runs it.","Review cards: how many are due. Start review opens the flashcards.","Weak spots: things you got wrong. Quiz my weak spots builds a quiz from them.","Needs a refresh: files you passed a while ago, or that changed since. Click a file to quiz yourself on it.","Learning path: the next stop of a path you made."],notes:["The flame badge counts days in a row with any practice. Missing a day resets it; one review is enough to keep it."]},{id:"explore",title:"Explore: choose files and an activity",what:"The main workspace. File tree on the left, code in the middle, activities on the right.",steps:["Click a file name to open it and read it.","Tick the box beside a file or a folder to add it to the Context. The model reads only what is in Context.","Use the filter box above the tree to find a file by name.","Pick an activity (Lens, Quiz, Teach, Tutor, Walk, Practice, Bug hunt, Notes) in the right pane."],examples:["Understand one module: tick only src/queue.ts, Lens > Explain.","Understand how two files connect: tick both, Lens > Data flow.","A folder is ticked in one click; keep the selection small (1 to 5 files) for sharper answers."],notes:["Context · 3 means three files are selected. Add lets you pick files from the project or from a context folder (docs, notes, a session folder).","[ and ] fold the side panes to give the code more room."]},{id:"lens",title:"Lens: read an explanation through one question",what:"A lens is a written explanation of your selected files, built around one question. It is like a short blog post about the code, with a walkthrough, pitfalls and a check for each step.",steps:["Tick files in Explore. Open the Lens tab.","Pick a kind of lens (see the list below).","Choose depth: Overview (about 1.5 screens, 3 to 4 steps), Standard (at least 3 screens, enough to change the code safely), Deep (5 to 6 screens, like a long blog post: every branch and failure path). Deep takes several minutes because it is planned first, then written in parts.","Optional: type your own question for the lens to answer.","Click Make lens. A planner model first outlines the lesson, then a writer model writes it in parts. When it is ready, you land on the lens page."],examples:['Explain: "The tour: purpose, main pieces, how they connect." Best first lens for any file.',"Data flow: follow one value from where it enters to where it leaves. Try on a request handler.","State over time: what is stored, who changes it, in which order. Try on a class with fields.","Failure modes: bad input, timeouts, partial writes, retries. Try before changing error handling.","Contracts: inputs, outputs and invariants between parts. Try on an API or a module boundary.","Concepts: the vocabulary first, with the line where each term shows up. Try when the code uses words you do not know.","The change: pick it in Changes with a diff; gives intent, risk and what to check.","Trace a run: step by step through one example input, with the state at each line. Use the arrows to step.","History: what changed over time and why, from the commits."],notes:["On the lens page: Words you need first (click a term to see where it shows up), the walkthrough (each step has a code card, a pitfall and a check question), then gotchas and next steps.","Click open file on a step to jump the code pane to that range. The same file pane stays on the right.","Refresh rebuilds a lens when the code changed. A banner tells you when it did."]},{id:"quiz",title:"Quiz: answer in your own words",what:"Questions about your selected files. You type answers; the model grades each one and says what was missing.",steps:["Tick files. Open the Quiz tab. Choose how many questions (Default, 3, 5 or 8).","Click Make quiz. Answer every question in the box beneath it. Short answers are fine; the core idea is what counts.","Click Grade. Each answer gets a verdict, an explanation and the line it came from.","A wrong answer is saved as a Weak spot and turns into a review card."],examples:['Question: "What happens when pop() is called on an empty queue?" Answer: "It raises IndexError, the caller must catch it."',"Retake: open the quiz from Library > Quizzes. Your best score is kept; at most 20 attempts are stored."],notes:["Empty answers are not counted as misconceptions. They are just unanswered."]},{id:"teach",title:"Teach: explain it back",what:"You write an explanation as if teaching a colleague. The model grades it for what is right, what is missing and what is wrong.",steps:["Tick files. Open Teach.","Write your explanation in your own words. Do not look at the code more than you need.","Submit. You get strengths, gaps and corrections tied to lines.","Gaps become Weak spots, so they come back later."],examples:['"A queue stores items in order. push adds at the tail; pop removes the head. When it is empty, pop raises." Short and specific beats long and vague.']},{id:"tutor",title:"Tutor: get hints, not answers",what:"A chat that helps you reach the answer yourself. Hints come in steps. Ask for the answer when you are stuck.",steps:["Tick files. Open Tutor and type a question.","The tutor replies with a question or a small hint (level 1). Ask again for more help: level 2 is a stronger hint, level 3 nearly gives it away.","At level 4 it tells you directly. Use that when you are really stuck.","Ctrl + Enter sends the message."],examples:['You: "Why does flush() hold the lock while it writes?" Tutor: "What could happen to the buffer if another thread called push() in the middle?"'],notes:["Only the last 200 messages of a chat are kept."]},{id:"walk",title:"Walk: one block at a time",what:"A guided tour of one file in small blocks. After each block you answer a short check before moving on.",steps:["Open a file, tick it, open Walk, click Make walk.","Read the block. Answer the check below it. Press Check.","A right answer unlocks the next block. A wrong one explains and keeps you on the block."],examples:["Use it for a file you must understand fully before changing it, such as a parser or a state machine."]},{id:"practice",title:"Practice: write the key lines back",what:"The code with some lines removed. You type them from memory and get feedback.",steps:["Choose a level: 1 one short hole, 2 a condition and a computation, 3 core logic, 4 whole function bodies.","Click Make practice. Fill the gaps in the editor.","Submit. You see your version next to the real one, with differences explained.","The eye button hides or shows the original. Reset restores the gaps."],examples:["Start at level 1 on a function you read today. Move to level 3 a week later."]},{id:"hunt",title:"Bug hunt: find the planted bugs",what:"cognitune plants bugs in a copy of the code (your files are not touched). You mark the lines you think are wrong.",steps:["Choose difficulty: Easy (one visible bug), Medium (two, one needs the logic), Hard (two or three subtle ones).","Click Make hunt. Read the copy and click lines you think are buggy.","Press Grade. The real bugs show up, with what was wrong and how you did."],notes:["The bugs are hidden until you grade. Reloading the page does not reveal them."]},{id:"notes",title:"Notes",what:"Your own notes on a file or a line. They can be included in prompts so answers match what you already know.",steps:["Open a file. Click a line number, add a note, save.","A mark appears in the margin. Click it to read or edit.","Turn on Settings > Notes in prompts to let the model see your notes."],examples:['"I keep mixing up head and tail here. Head is where pop reads."']},{id:"changes",title:"Changes: learn from a diff",what:"Understand a commit, a branch or uncommitted work before you review or merge it.",steps:["Choose a repo, then what to compare (for example a branch against main, or a single commit).","Tick the changed files you care about.","Use the activity panel: Lens > The change gives intent, risk and what to check."],examples:["Before reviewing a colleague's branch: Changes > main..feature/x > tick the three biggest files > Lens > The change."]}]},{title:"Remember it",sections:[{id:"review",title:"Review: flashcards that come back on time",what:"Cards are spaced: easy ones return later, hard ones sooner (FSRS). Ten minutes a day beats an hour once.",steps:["Open Review (the badge shows how many are due).","Read the question. Say or type your answer in your head. Press Space to show the answer.","Rate yourself: 1 Again (forgot), 2 Hard, 3 Good, 4 Easy. The buttons show when each will return."],examples:["Forgot it completely → 1. It returns in minutes.","Got it but had to think → 2 or 3.","Got it instantly → 4. It goes weeks out."],notes:["Cards come from wrong quiz answers, teach-back gaps and weak spots (Settings > Cards from misses). You can also add a card from the file view with the card button.","Only the last 50 reviews of each card are kept."]},{id:"library",title:"Library: everything you made",what:"One place for every lens, quiz, practice, teach-back, walk, hunt, tutor chat, card, glossary term and note in this project.",steps:["Pick a tab. Use Search this tab to filter.","Click an item to open it. Items you delete go to an archive and are removed after the keep time.","Glossary is the list of terms the lenses defined, across all lenses."],examples:["Looking for the lens you made last week on the scheduler: Library > Lenses > search: scheduler."]},{id:"progress",title:"Progress",what:"What you can show you understand, rolled up from files to folders and git repos.",steps:["At a folder of many repos, each repo is one row with a coverage bar; click a row to go into its folders, then files. The bar at the top goes back up, and its repo picker jumps to a repo.","The cards, the table and the heatmap all follow that scope. Search filters the touched files in it. The scope is in the address, so you can bookmark it.","Levels: new, seen, understood, fading, stale. A file turns fading after a few weeks without practice, and stale when the code changed since you studied it (Settings > fade days).","Click a file to open it in Explore."]}]},{title:"See the shape",sections:[{id:"map",title:"Map: how files connect",what:"Which parts of the code import which. At a folder of many repos each repo is one node; inside a repo, folders; then files.",steps:["Open Map. Square nodes are folders (the number is how many code files they hold), circles are files. A thicker arrow carries more imports.","Click a folder to go into it; the bar at the top goes back up, and its repo picker jumps straight to a repo. Click a file to open it in Explore.","A folder of 8 code files or fewer shows its files directly, so you never drill in for two files.","Colours show your level: grey not yet, blue seen, green understood, amber fading or stale.","The map is read once and kept. Press Refresh after imports change."],examples:["At the top level, a thick arrow from one repo to another shows a real dependency between them. Click the target to see which of its folders are used."],notes:["Import links are found by reading import lines (TypeScript, JavaScript and Python). Aliases from tsconfig paths are followed."]},{id:"paths",title:"Paths: an ordered tour",what:"A learning path is an ordered list of stops: where to start, what next, and how to check each stop.",steps:["Open Paths. Describe your goal, or leave it blank for a general tour.","Click Make a path. Each stop has files, why it matters and an activity.",`A stop's Start button ("Start the lens", "Start the quiz"...) opens Explore with the files ticked and the activity ready.`,"Tick a stop off when done. Today shows the next stop."],examples:['Goal: "I need to add retries to the job runner." The path walks queue, worker, then error handling.']}]},{title:"Settings and storage",sections:[{id:"settings",title:"Settings",what:"Which model runs, how text looks, and what cognitune keeps.",steps:["Planning model (default claude-opus-5-5) plans lenses, quizzes, walks, practice, bug hunts and paths; the model above (default claude-sonnet-5-5) writes them. Plan first can be turned off for one-shot answers.","Model: choose the agent (Auto, Claude Code CLI, Codex CLI, GitHub Copilot CLI, an Anthropic API key, or Demo). Auto uses the first one installed.","Reading font: sans (default) or serif for lens pages.","Cards, progress and notes: switches for turning wrong answers into cards, how fast files fade, and whether notes go to the model.","Recent model calls: the last calls with how long they took and any error."]},{id:"storage",title:"Storage: keeping it small",what:"Everything is plain JSON files in your cognitune folder (shown in Settings). It stays bounded on its own and you can also remove things by hand.",steps:["Automatic: archived items and forgotten projects are removed after the keep time (30 days by default). The reply cache keeps to its size (50 MB). Quiz attempts, card history, tutor chats and the job log are capped.","Clean up now applies those limits at once.","Choose what to remove: open the list, filter by kind, tick the items, press Remove selected, then confirm. Select all shown ticks every row in the current filter."],examples:["Free space fast: Choose what to remove > kind: reply cache > Select all shown > Remove selected. Nothing you made is lost; answers are just asked again later.","Remove one old lens: kind: lenses > tick it > Remove selected."],notes:["Removing is permanent (no archive step). Your project folders are never touched."]}]}];function aS(e){const t=e.match(/^\/p\/[^/]+\/([^/]+)/),n=t==null?void 0:t[1];return e==="/settings"?"settings":e==="/"?"projects":n?{today:"today",explore:"explore",review:"review",map:"map",paths:"paths",path:"paths",library:"library",progress:"progress",changes:"changes",lens:"lens",quiz:"quiz",teach:"teach",tutor:"tutor",walk:"walk",practice:"practice",hunt:"hunt"}[n]??null:null}function oS(){const[e]=ec(),t=Si(),[n,r]=b.useState(""),i=e.get("s"),[s,l]=b.useState(i??"start"),o=b.useMemo(()=>{const c=n.trim().toLowerCase();return c?Lg.map(d=>({...d,sections:d.sections.filter(h=>[h.title,h.what,...h.steps??[],...h.examples??[],...h.notes??[]].join(" ").toLowerCase().includes(c))})).filter(d=>d.sections.length):Lg},[n]);b.useEffect(()=>{i&&(l(i),requestAnimationFrame(()=>{var c;return(c=document.getElementById(`help-${i}`))==null?void 0:c.scrollIntoView({block:"start"})}))},[i,t.key]);const u=c=>{var d;l(c),(d=document.getElementById(`help-${c}`))==null||d.scrollIntoView({behavior:"smooth",block:"start"})};return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"mx-auto flex max-w-6xl gap-10 px-8 py-10",children:[a.jsxs("nav",{className:"sticky top-0 hidden h-fit w-56 shrink-0 lg:block",children:[a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted"}),a.jsx("input",{className:"input h-9 pl-8 text-[14px]",placeholder:"Search help",value:n,onChange:c=>r(c.target.value)})]}),a.jsx("div",{className:"mt-4 space-y-4",children:o.map(c=>a.jsxs("div",{children:[a.jsx("div",{className:"px-2 text-[11px] font-semibold uppercase tracking-wide text-muted",children:c.title}),a.jsx("ul",{className:"mt-1",children:c.sections.map(d=>a.jsx("li",{children:a.jsx("button",{onClick:()=>u(d.id),className:le("w-full rounded-md px-2 py-1.5 text-left text-[14px] hover:bg-raised",s===d.id?"bg-accent/10 font-medium text-accent":"text-ink"),children:d.title.split(":")[0]})},d.id))})]},c.title))})]}),a.jsxs("main",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Help"}),a.jsxs("p",{className:"mt-2 max-w-2xl text-[16px] leading-relaxed text-muted",children:["What every part does, how to use it, and something to try. Press ",a.jsx("span",{className:"kbd",children:"Ctrl H"})," on any page to open this at the matching part."]}),a.jsx("div",{className:"mt-4 lg:hidden",children:a.jsx("input",{className:"input",placeholder:"Search help",value:n,onChange:c=>r(c.target.value)})}),o.map(c=>a.jsxs("div",{children:[a.jsx("h2",{className:"mt-12 border-b border-line pb-2 text-sm font-semibold uppercase tracking-wide text-muted",children:c.title}),c.sections.map(d=>a.jsxs("section",{id:`help-${d.id}`,className:"scroll-mt-6 pt-8",children:[a.jsx("h3",{className:"text-2xl font-semibold tracking-tight",children:d.title}),a.jsx("p",{className:"mt-2 max-w-3xl text-[17px] leading-[1.65]",children:d.what}),d.steps&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-accent",children:"How to use it"}),a.jsx("ol",{className:"mt-2 max-w-3xl list-decimal space-y-2 pl-6 text-[16px] leading-[1.6] marker:text-muted",children:d.steps.map(h=>a.jsx("li",{children:h},h))})]}),d.examples&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-accent",children:"Try this"}),a.jsx("div",{className:"mt-2 max-w-3xl space-y-2",children:d.examples.map(h=>a.jsx("div",{className:"rounded-lg border border-line bg-raised px-4 py-2.5 text-[15px] leading-[1.55]",children:h},h))})]}),d.notes&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-muted",children:"Good to know"}),a.jsx("ul",{className:"mt-2 max-w-3xl list-disc space-y-1.5 pl-6 text-[15px] leading-[1.6] text-muted marker:text-line",children:d.notes.map(h=>a.jsx("li",{children:h},h))})]})]},d.id))]},c.title)),!o.length&&a.jsxs("p",{className:"mt-10 text-muted",children:['Nothing matches "',n,'".']}),a.jsx("div",{className:"h-24"})]})]})})}async function Ba(e,t){const{json:n,...r}=t??{},i=await fetch(`/api${e}`,{...r,headers:{"content-type":"application/json",...r.headers??{}},body:n===void 0?r.body:JSON.stringify(n)}),s=await i.json().catch(()=>({}));if(!i.ok)throw new Error(s.error||`${i.status} ${i.statusText}`);return s}const me=e=>Ba(e),Ci=(e,t={})=>Ba(e,{method:"POST",json:t}),Eh=(e,t)=>Ba(e,{method:"PUT",json:t}),Ua=(e,t)=>Ba(e,{method:"PATCH",json:t}),cs=e=>Ba(e,{method:"DELETE"}),uS=e=>new Promise(t=>setTimeout(t,e)),Ph=new Set;function mn(){const e=Dt(),[t,n]=b.useState(null),[r,i]=b.useState(null),[s,l]=b.useState(0),o=b.useRef(!0);return b.useEffect(()=>()=>void(o.current=!1),[]),b.useEffect(()=>{if((t==null?void 0:t.status)!=="running")return;const c=Date.parse(t.startedAt),d=setInterval(()=>l(Math.round((Date.now()-c)/1e3)),500);return()=>clearInterval(d)},[t==null?void 0:t.status,t==null?void 0:t.startedAt]),{run:b.useCallback(async(c,d,h)=>{i(null),l(0);let p;try{let f=await Ci(c,d);for(p=f.id,Ph.add(p),n(f),e.invalidateQueries({queryKey:["project-jobs"]});f.status==="running";){if(await uS(1e3),!o.current)return;f=await me(`/jobs/${f.id}`),n(f)}f.status==="failed"?i(f.error??"the job failed"):(await e.invalidateQueries(),h==null||h(f))}catch(f){i(f instanceof Error?f.message:String(f)),n(null)}finally{p&&Ph.delete(p)}},[e]),job:t,busy:(t==null?void 0:t.status)==="running",error:r,elapsed:s,clearError:()=>i(null)}}function Tt(e){const t=Math.round((Date.now()-Date.parse(e))/1e3);return t<60?"just now":t<3600?`${Math.round(t/60)} min ago`:t<86400?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} d ago`}function ee({variant:e="secondary",size:t="md",icon:n,className:r,children:i,loading:s,...l}){return a.jsxs("button",{...l,disabled:l.disabled||s,className:le("inline-flex select-none items-center justify-center gap-2 rounded-sm font-medium transition","disabled:cursor-not-allowed disabled:opacity-50","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",t==="sm"&&"h-[22px] px-2 text-xs",t==="md"&&"h-[26px] px-3 text-[13px]",t==="lg"&&"h-8 px-4 text-sm",e==="primary"&&"bg-accent text-accent-ink hover:brightness-110",e==="secondary"&&"border border-muted/40 bg-raised text-ink hover:border-muted/70 hover:brightness-95",e==="ghost"&&"text-muted hover:bg-raised hover:text-ink",e==="danger"&&"border border-bad/30 bg-bad/10 text-bad hover:bg-bad/15",r),children:[s?a.jsx(H1,{className:"h-4 w-4 animate-spin"}):n,i]})}function be({tone:e="muted",children:t,className:n}){return a.jsx("span",{className:le("inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium",e==="muted"&&"bg-raised text-muted",e==="accent"&&"bg-accent/12 text-accent",e==="good"&&"bg-good/12 text-good",e==="warn"&&"bg-warn/15 text-warn",e==="bad"&&"bg-bad/12 text-bad",n),children:t})}function f0({v:e}){return a.jsx(be,{tone:e==="right"?"good":e==="partial"?"warn":"bad",children:e})}function kt({className:e}){return a.jsx(H1,{className:le("h-4 w-4 animate-spin text-muted",e)})}function Ft({icon:e,title:t,children:n,action:r}){return a.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-16 text-center",children:[e&&a.jsx("div",{className:"mb-4 grid h-12 w-12 place-items-center rounded-2xl bg-accent/10 text-accent",children:e}),a.jsx("h3",{className:"text-base font-semibold",children:t}),n&&a.jsx("div",{className:"mt-1.5 max-w-md text-sm text-muted",children:n}),r&&a.jsx("div",{className:"mt-5",children:r})]})}function Ke({error:e,onClose:t}){return a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-bad/30 bg-bad/8 px-3 py-2 text-sm text-bad",children:[a.jsx(op,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("div",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:e}),t&&a.jsx("button",{onClick:t,className:"opacity-60 hover:opacity-100","aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]})}const cS={lens:["Reading the files","Finding the core idea","Writing the lesson"],quiz:["Reading the files","Choosing what matters","Writing questions"],grade:["Reading your answers","Checking against the code","Writing feedback"],practice:["Reading the file","Choosing the key logic","Cutting the holes"],review:["Reading your code","Comparing with the original","Writing feedback"],teachback:["Reading your explanation","Checking it against the code","Writing feedback"],tutor:["Reading the conversation","Thinking of a good question","Writing"],walk:["Reading the file","Finding the reading order","Writing check questions"],walkcheck:["Reading your answer","Checking the block"],hunt:["Reading the file","Choosing where to break it","Planting the bugs"],huntgrade:["Matching your marks","Checking your reasons","Writing feedback"],path:["Reading the repo layout","Ordering the stops","Writing the path"]};function sn({kind:e,elapsed:t}){const n=cS[e]??["Working"],r=Math.min(n.length-1,Math.floor(t/12));return a.jsxs("div",{className:"shimmer card p-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kt,{className:"text-accent"}),a.jsxs("div",{className:"text-sm font-medium",children:[n[r],"..."]}),a.jsxs("div",{className:"ml-auto font-mono text-xs text-muted",children:[t,"s"]})]}),a.jsx("div",{className:"mt-3 flex gap-1.5",children:n.map((i,s)=>a.jsx("div",{className:le("h-1 flex-1 rounded-full transition-colors",s<=r?"bg-accent":"bg-line")},i))}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"Model calls take 20 seconds to 2 minutes. You can leave this page: it keeps running, and the status bar says when it is ready."})]})}function Zt({value:e,onChange:t,options:n}){return a.jsx("div",{className:"inline-flex rounded-sm border border-line bg-raised p-0.5",children:n.map(r=>a.jsx("button",{title:r.title,onClick:()=>t(r.value),className:le("rounded-sm px-2.5 py-0.5 text-xs font-medium transition",r.value===e?"bg-panel text-ink":"text-muted hover:text-ink"),children:r.label},String(r.value)))})}function dS({value:e,onChange:t,tabs:n,className:r,wrap:i=!1}){return a.jsx("div",{className:le("flex border-b border-line bg-side",i?"flex-wrap":"overflow-x-auto",r),children:n.map(s=>a.jsxs("button",{onClick:()=>t(s.value),className:le("relative flex h-[35px] shrink-0 items-center gap-1.5 whitespace-nowrap border-r border-line px-3 text-[13px] transition",i&&"grow justify-center last:border-r-0",s.value===e?"bg-bg text-ink":"text-muted hover:text-ink"),children:[s.icon,s.label,s.count!==void 0&&s.count>0&&a.jsx("span",{className:"rounded-full bg-raised px-1.5 text-[11.5px] text-muted",children:s.count}),s.value===e&&a.jsx("span",{className:"absolute inset-x-0 top-0 h-px bg-accent"})]},s.value))})}function Ca({score:e,size:t="md"}){const n=Math.round(e*100),r=e>=.67?"text-good":e>=.4?"text-warn":"text-bad";return a.jsxs("span",{className:le("font-semibold tabular-nums",r,t==="sm"?"text-xs":"text-sm"),children:[n,"%"]})}function tc({title:e,onClose:t,children:n,footer:r,wide:i}){return a.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4",onClick:t,onKeyDown:s=>s.key==="Escape"&&t(),children:a.jsxs("div",{className:le("card flex max-h-[85vh] w-full flex-col overflow-hidden",i?"max-w-2xl":"max-w-lg"),onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center border-b border-line px-4 py-2",children:[a.jsx("h2",{className:"text-sm font-semibold",children:e}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:t,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:n}),r&&a.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:r})]})})}function nc({back:e,badges:t,title:n,sub:r,actions:i}){return a.jsxs("div",{children:[e,t&&a.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:t}),a.jsxs("div",{className:"mt-2 flex items-start gap-3",children:[a.jsx("h1",{className:"min-w-0 flex-1 text-[20px] font-semibold leading-tight tracking-tight",children:n}),i&&a.jsx("div",{className:"flex shrink-0 gap-2",children:i})]}),r&&a.jsx("div",{className:"mt-1 text-sm text-muted",children:r})]})}function Th(e){const t=Math.max(0,Math.round((Date.parse(e)-Date.now())/1e3));return t<90?"now":t<3600?`${Math.round(t/60)} min`:t<86400?`${Math.round(t/3600)} h`:t<86400*60?`${Math.round(t/86400)} d`:`${Math.round(t/(86400*30))} mo`}const hS={"Go to":og,Do:og,Files:_1,Projects:$1};function p0(e,t){return e.flatMap(n=>n.kind==="file"?[{path:n.path,rel:n.path.startsWith(t+"/")?n.path.slice(t.length+1):n.path}]:p0(n.children??[],t))}function fS({pid:e,root:t,onClose:n,openFile:r}){const i=gt(),[s,l]=b.useState(""),[o,u]=b.useState(0),c=b.useRef(null),d=ye({queryKey:["tree-flat",e],queryFn:()=>me(`/projects/${e}/tree`),enabled:!!e,staleTime:6e4}),h=ye({queryKey:["projects"],queryFn:()=>me("/projects")}),p=b.useMemo(()=>{const g=y=>()=>i(y),k=[];if(e){const y=`/p/${e}`;for(const[x,v]of[["Today","today"],["Explore","explore"],["Changes","changes"],["Review cards","review"],["Map","map"],["Learning paths","paths"],["Library","library"],["Progress","progress"]])k.push({id:`go-${v}`,label:x,group:"Go to",run:g(`${y}/${v}`)});for(const[x,v]of[["Lens on the open file","lens"],["Quiz me on the open file","quiz"],["Teach it back","teach"],["Ask the tutor","tutor"],["Walk through the open file","walk"],["Practice on the open file","practice"],["Bug hunt in the open file","hunt"],["Notes on the open file","notes"]])k.push({id:`do-${v}`,label:x,group:"Do",run:g(`${y}/explore?do=${v}`)});if(d.data&&t)for(const x of p0(d.data,t))k.push({id:`f-${x.path}`,label:x.rel,group:"Files",run:()=>r==null?void 0:r(x.path)})}k.push({id:"go-help",label:"Help (Ctrl H)",group:"Go to",run:g("/help")}),k.push({id:"go-settings",label:"Settings",group:"Go to",run:g("/settings")});for(const y of h.data??[])k.push({id:`p-${y.id}`,label:y.name,hint:y.root,group:"Projects",run:g(`/p/${y.id}/today`)});return k},[e,t,d.data,h.data,i,r]),f=b.useMemo(()=>{const g=s.toLowerCase().split(/\s+/).filter(Boolean);return(g.length?p.filter(y=>g.every(x=>`${y.label} ${y.hint??""} ${y.group}`.toLowerCase().includes(x))):p.filter(y=>y.group!=="Files")).slice(0,60)},[p,s]);b.useEffect(()=>{u(0)},[s]),b.useEffect(()=>{var g,k;(k=(g=c.current)==null?void 0:g.querySelector(`[data-i="${o}"]`))==null||k.scrollIntoView({block:"nearest"})},[o]);const m=g=>{g&&(n(),g.run())};return a.jsxs(tc,{title:"Go to or do",onClose:n,wide:!0,children:[a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-muted"}),a.jsx("input",{autoFocus:!0,className:"input pl-9",placeholder:"Type a page, an activity, a file or a project",value:s,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="ArrowDown"&&(g.preventDefault(),u(k=>Math.min(f.length-1,k+1))),g.key==="ArrowUp"&&(g.preventDefault(),u(k=>Math.max(0,k-1))),g.key==="Enter"&&m(f[o]),g.key==="Escape"&&n()}})]}),a.jsxs("div",{ref:c,className:"mt-3 max-h-[50vh] overflow-auto",children:[f.map((g,k)=>{const y=hS[g.group],x=k===0||f[k-1].group!==g.group;return a.jsxs("div",{children:[x&&a.jsx("div",{className:"px-2 pb-1 pt-2 text-[11.5px] font-semibold uppercase tracking-wide text-muted",children:g.group}),a.jsxs("button",{"data-i":k,onMouseMove:()=>u(k),onClick:()=>m(g),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[14px]",k===o?"bg-accent/12 text-ink":"text-ink/85"),children:[a.jsx(y,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),a.jsx("span",{className:le("min-w-0 flex-1 truncate",g.group==="Files"&&"font-mono text-[13px]"),children:g.label}),g.hint&&a.jsx("span",{className:"truncate text-[12px] text-muted",children:g.hint}),k===o&&a.jsx(t2,{className:"h-3.5 w-3.5 text-muted"})]})]},g.id)}),!f.length&&a.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted",children:"Nothing matches."})]})]})}const pS=[["Ctrl/Cmd + K","Go to a page, file or project; start an activity"],["Ctrl/Cmd + H","Help, opened at the part for this page"],["?","This list"],["[ and ]","Fold or show the left and right panes"],["Space","Review: reveal the answer"],["1 2 3 4","Review: again, hard, good, easy"],["Ctrl + Enter","Tutor: send"],["← →","Trace: step back and forward"]];function mS({onClose:e}){return a.jsx(tc,{title:"Keyboard shortcuts",onClose:e,children:a.jsx("table",{className:"w-full text-sm",children:a.jsx("tbody",{children:pS.map(([t,n])=>a.jsxs("tr",{className:"border-b border-line/60 last:border-0",children:[a.jsx("td",{className:"py-2 pr-4",children:a.jsx("span",{className:"kbd",children:t})}),a.jsx("td",{className:"py-2 text-muted",children:n})]},t))})})})}function m0({className:e}){return a.jsxs("svg",{viewBox:"0 0 32 32",className:e,"aria-hidden":!0,children:[a.jsx("rect",{width:"32",height:"32",rx:"6",fill:"rgb(var(--accent))"}),a.jsx("circle",{cx:"14",cy:"14",r:"6.5",fill:"none",stroke:"white",strokeWidth:"2.8"}),a.jsx("path",{d:"M19 19l6 6",stroke:"white",strokeWidth:"2.8",strokeLinecap:"round"})]})}function wn({to:e,icon:t,label:n,end:r,badge:i}){return a.jsxs(Sh,{to:e,end:r,title:n,"aria-label":n,className:({isActive:s})=>le("relative grid h-12 w-12 shrink-0 place-items-center transition-colors",s?"text-ink before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent":"text-muted hover:text-ink"),children:[t,!!i&&a.jsx("span",{className:"absolute bottom-2 right-1.5 min-w-[16px] rounded-full bg-accent px-1 text-center text-[10px] font-semibold leading-4 text-accent-ink",children:i>99?"99+":i})]})}const gS={system:"light",light:"dark",dark:"system"},Hc={lens:"lens",quiz:"quiz",grade:"grading",practice:"practice",review:"review",teachback:"teach-back",tutor:"tutor reply",walk:"walkthrough",walkcheck:"check",hunt:"bug hunt",huntgrade:"grading",path:"path"},Mg={lens:"lens",quiz:"quiz",practice:"practice",teachback:"teach",tutor:"tutor",walk:"walk",hunt:"hunt",path:"paths"};function xS({pid:e}){const t=gt(),n=ye({queryKey:["project-jobs",e],queryFn:async()=>(await me(`/projects/${e}`)).running,refetchInterval:u=>{var c;return(c=u.state.data)!=null&&c.length?2e3:!1}}),r=n.data??[],i=b.useRef(new Set),[s,l]=b.useState([]);b.useEffect(()=>{const u=new Set(r.map(d=>d.id)),c=[...i.current].filter(d=>!u.has(d)&&!Ph.has(d));i.current=u;for(const d of c)me(`/jobs/${d}`).then(h=>{h.status==="done"&&h.resultId&&Mg[h.kind]&&l(p=>[...p.filter(f=>f.id!==h.id),h])}).catch(()=>{})},[n.dataUpdatedAt]);const o=s[s.length-1];if(r.length){const u=r[0],c=Math.max(0,Math.round((Date.now()-Date.parse(u.startedAt))/1e3));return a.jsxs("span",{className:"flex items-center gap-1.5 px-1.5",title:r.map(d=>Hc[d.kind]).join(", "),children:[a.jsx("span",{className:"[&>svg]:h-3 [&>svg]:w-3",children:a.jsx(kt,{className:"text-accent"})}),r.length===1?`${Hc[u.kind]} running · ${c}s`:`${r.length} jobs running`]})}return o?a.jsxs("span",{className:"flex items-center",children:[a.jsxs("button",{className:"flex items-center gap-1.5 px-1.5 text-good hover:bg-raised",onClick:()=>{l(u=>u.filter(c=>c.id!==o.id)),t(`/p/${e}/${Mg[o.kind]}/${o.resultId}`)},children:[a.jsx(vl,{className:"h-3 w-3"})," ",Hc[o.kind]," ready · open",s.length>1?` (+${s.length-1})`:""]}),a.jsx("button",{className:"px-1 hover:bg-raised hover:text-ink",title:"Dismiss",onClick:()=>l(u=>u.filter(c=>c.id!==o.id)),children:a.jsx(Rn,{className:"h-3 w-3"})})]}):null}function yS(){var g,k,y,x,v;const{pid:e}=$r(),{pref:t,setPref:n}=ly(),r=ye({queryKey:["health"],queryFn:()=>me("/health"),staleTime:6e4}),i=(g=r.data)==null?void 0:g.agent.ready,s=t==="dark"?f2:t==="light"?v2:h2,l=gt(),[o,u]=b.useState(!1),[c,d]=b.useState(!1),h=ye({queryKey:["cards-due",e],queryFn:()=>me(`/projects/${e}/cards/due`),enabled:!!e,staleTime:6e4}),f=(y=(k=ye({queryKey:["projects"],queryFn:()=>me("/projects"),enabled:!!e,staleTime:6e4}).data)==null?void 0:k.find(j=>j.id===e))==null?void 0:y.root;b.useEffect(()=>{const j=E=>{if((E.ctrlKey||E.metaKey)&&E.key.toLowerCase()==="k"){E.preventDefault(),u(N=>!N);return}if((E.ctrlKey||E.metaKey)&&!E.shiftKey&&!E.altKey&&E.key.toLowerCase()==="h"){E.preventDefault();const N=aS(window.location.pathname);l(N?`/help?s=${N}`:"/help");return}!E.target.closest("input, textarea, [contenteditable], .cm-editor")&&E.key==="?"&&d(!0)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const m=i===void 0?"checking model":i?"model ready":"model off";return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsxs("aside",{className:"flex w-12 shrink-0 flex-col items-stretch overflow-y-auto bg-rail",children:[a.jsx(Sh,{to:"/",className:"grid h-12 place-items-center",title:"cognitune: projects","aria-label":"cognitune: projects",children:a.jsx(m0,{className:"h-6 w-6"})}),e?a.jsxs(a.Fragment,{children:[a.jsx(wn,{to:`/p/${e}/today`,icon:a.jsx(w2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Today"}),a.jsx(wn,{to:`/p/${e}/explore`,icon:a.jsx(_a,{className:"h-6 w-6",strokeWidth:1.5}),label:"Explore"}),a.jsx(wn,{to:`/p/${e}/changes`,icon:a.jsx(U1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Changes"}),a.jsx(wn,{to:`/p/${e}/review`,icon:a.jsx(Fr,{className:"h-6 w-6",strokeWidth:1.5}),label:"Review",badge:(x=h.data)==null?void 0:x.length}),a.jsx(wn,{to:`/p/${e}/map`,icon:a.jsx(W1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Map"}),a.jsx(wn,{to:`/p/${e}/paths`,icon:a.jsx(lp,{className:"h-6 w-6",strokeWidth:1.5}),label:"Paths"}),a.jsx(wn,{to:`/p/${e}/library`,icon:a.jsx(Zf,{className:"h-6 w-6",strokeWidth:1.5}),label:"Library"}),a.jsx(wn,{to:`/p/${e}/progress`,icon:a.jsx(z1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Progress"})]}):a.jsx(wn,{to:"/",end:!0,icon:a.jsx(c2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Projects"}),a.jsx("div",{className:"flex-1"}),e&&a.jsx(wn,{to:"/",end:!0,icon:a.jsx($1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Projects"}),a.jsx(wn,{to:"/help",icon:a.jsx(F1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Help"}),a.jsx(wn,{to:"/settings",icon:a.jsx(g2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Settings"})]}),a.jsx("main",{className:"min-w-0 flex-1",children:a.jsx(c0,{})})]}),a.jsxs("footer",{className:"flex h-[22px] shrink-0 items-center gap-1 border-t border-line bg-status px-2 text-[12px] text-muted",children:[f&&a.jsx("span",{className:"px-1.5",title:f,children:f.split("/").filter(Boolean).pop()}),a.jsxs(Sh,{to:"/settings",title:((v=r.data)==null?void 0:v.agent.detail)??"checking the model",className:"flex items-center gap-1.5 px-1.5 hover:bg-raised",children:[a.jsx("span",{className:le("h-2 w-2 rounded-full",i===void 0?"bg-line":i?"bg-good":"bg-bad")}),m]}),e&&a.jsx(xS,{pid:e}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>u(!0),title:"Go to or do (Ctrl/Cmd+K). Press ? for all shortcuts.",className:"flex items-center gap-1 px-1.5 hover:bg-raised",children:[a.jsx(e2,{className:"h-3 w-3"})," Ctrl K"]}),a.jsxs("button",{onClick:()=>n(gS[t]),title:`Theme: ${t} (click to change)`,className:"flex items-center gap-1 px-1.5 hover:bg-raised",children:[a.jsx(s,{className:"h-3 w-3"})," ",a.jsx("span",{className:"capitalize",children:t})]})]}),o&&a.jsx(fS,{pid:e,root:f,onClose:()=>u(!1),openFile:j=>{try{sessionStorage.setItem(`gl.open.${e}`,JSON.stringify(j))}catch{}l(`/p/${e}/explore`),window.dispatchEvent(new CustomEvent("cognitune:open",{detail:j}))}}),c&&a.jsx(mS,{onClose:()=>d(!1)})]})}const g0=b.createContext(null);function Rg(e,t){try{const n=sessionStorage.getItem(e);return n?JSON.parse(n):t}catch{return t}}function zg(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function vS({pid:e,children:t,fallback:n}){const r=ye({queryKey:["project",e],queryFn:()=>me(`/projects/${e}`)}),[i,s]=b.useState(()=>Rg(`gl.sel.${e}`,[])),[l,o]=b.useState(()=>Rg(`gl.open.${e}`,null)),[u,c]=b.useState(null);b.useEffect(()=>zg(`gl.sel.${e}`,i),[e,i]),b.useEffect(()=>{const m=g=>{o(g.detail),c(null)};return window.addEventListener("cognitune:open",m),()=>window.removeEventListener("cognitune:open",m)},[]),b.useEffect(()=>zg(`gl.open.${e}`,l),[e,l]);const d=b.useCallback(m=>s([...new Set(m)]),[]),h=b.useCallback((m,g)=>{s(k=>{const y=k.includes(m);return g??!y?y?k:[...k,m]:k.filter(v=>v!==m)})},[]),p=b.useCallback((m,g)=>{o(m),c(g??null)},[]),f=b.useMemo(()=>{const m=r.data;return m?{project:m,selected:i,toggle:h,setSelected:d,openFile:l,setOpenFile:p,focusLine:u,rel:k=>{if(k.startsWith(m.root+"/"))return k.slice(m.root.length+1);for(const y of m.contexts)if(k.startsWith(y+"/"))return`${y.split("/").pop()}/${k.slice(y.length+1)}`;return k}}:null},[r.data,i,h,d,l,p,u]);return r.error?a.jsx(a.Fragment,{children:n}):f?a.jsx(g0.Provider,{value:f,children:t}):null}function it(){const e=b.useContext(g0);if(!e)throw new Error("useProject outside ProjectProvider");return e}function pp({title:e,start:t,onPick:n,onClose:r,cta:i="Open this folder"}){var h,p;const[s,l]=b.useState(t??""),[o,u]=b.useState(t??""),c=ye({queryKey:["browse",s],queryFn:()=>me(`/browse?path=${encodeURIComponent(s)}`)}),d=((h=c.data)==null?void 0:h.path)??s;return a.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4 backdrop-blur-sm",onClick:r,children:a.jsxs("div",{className:"card flex max-h-[80vh] w-full max-w-xl flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[a.jsx("h2",{className:"text-sm font-semibold",children:e}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:r,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"flex gap-2 border-b border-line p-3",onSubmit:f=>{f.preventDefault(),l(o)},children:[a.jsx("input",{className:"input font-mono text-xs",value:o,onChange:f=>u(f.target.value),placeholder:"/path/to/folder"}),a.jsx(ee,{type:"submit",children:"Go"})]}),a.jsxs("div",{className:"min-h-[240px] flex-1 overflow-auto p-2",children:[c.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),c.error&&a.jsx("div",{className:"p-2",children:a.jsx(Ke,{error:c.error.message})}),c.data&&a.jsxs(a.Fragment,{children:[c.data.parent&&a.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-muted hover:bg-raised",onClick:()=>{l(c.data.parent),u(c.data.parent)},children:[a.jsx(R1,{className:"h-4 w-4"})," .."]}),c.data.dirs.map(f=>{const m=`${c.data.path.replace(/\/$/,"")}/${f}`;return a.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm hover:bg-raised",onDoubleClick:()=>n(m),onClick:()=>{l(m),u(m)},children:[a.jsx(np,{className:"h-4 w-4 text-accent/80"})," ",f]},f)}),!c.data.dirs.length&&a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted",children:"No sub-folders."})]})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-line px-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted",title:d,children:[((p=c.data)==null?void 0:p.isGit)&&a.jsx(rp,{className:"mr-1 inline h-3.5 w-3.5 text-good"}),d]}),a.jsx(ee,{variant:"ghost",onClick:r,children:"Cancel"}),a.jsx(ee,{variant:"primary",disabled:!c.data,onClick:()=>n(d),children:i})]})]})})}const wS=[{icon:_a,title:"Lenses",text:"See code through one question: data flow, state, failure modes, contracts."},{icon:$a,title:"Quizzes",text:"Questions about behaviour, not names. Graded with feedback that names the line."},{icon:Ku,title:"Practice",text:"Key logic cut out of your own code. Write it back, with hints when stuck."},{icon:Zf,title:"Progress",text:"What you understand, per file. A pass goes stale when the code changes."}];function kS(){var u;const e=gt(),t=Dt(),[n,r]=b.useState(!1),i=ye({queryKey:["projects"],queryFn:()=>me("/projects")}),s=vi({mutationFn:c=>Ci("/projects",{root:c}),onSuccess:c=>{t.invalidateQueries({queryKey:["projects"]}),e(`/p/${c.id}/today`)}}),l=vi({mutationFn:c=>cs(`/projects/${c}`),onSuccess:()=>t.invalidateQueries({queryKey:["projects"]})}),o=i.data??[];return a.jsxs("div",{className:"h-full overflow-auto",children:[a.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-12",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(m0,{className:"h-11 w-11"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"cognitune"}),a.jsx("p",{className:"text-sm text-muted",children:"Understand any codebase. Prove it to yourself."})]})]}),a.jsx("div",{className:"mt-10 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:wS.map(({icon:c,title:d,text:h})=>a.jsxs("div",{className:"card p-4",children:[a.jsx("div",{className:"mb-3 grid h-9 w-9 place-items-center rounded-lg bg-accent/10 text-accent",children:a.jsx(c,{className:"h-[18px] w-[18px]"})}),a.jsx("div",{className:"text-sm font-semibold",children:d}),a.jsx("p",{className:"mt-1 text-[14px] leading-snug text-muted",children:h})]},d))}),a.jsxs("div",{className:"mt-12 flex items-end justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Projects"}),a.jsx("p",{className:"text-sm text-muted",children:"A project is a folder of code. Nothing in it is written."})]}),a.jsx(ee,{variant:"primary",size:"lg",icon:a.jsx(q1,{className:"h-4 w-4"}),onClick:()=>r(!0),children:"Open a folder"})]}),s.error&&a.jsx("div",{className:"mt-4",children:a.jsx(Ke,{error:s.error.message})}),a.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-2",children:[o.map(c=>a.jsxs("div",{role:"button",tabIndex:0,onClick:()=>s.mutate(c.root),onKeyDown:d=>d.key==="Enter"&&s.mutate(c.root),className:"card group flex cursor-pointer items-center gap-4 p-4 transition hover:-translate-y-0.5 hover:border-accent/40",children:[a.jsx("div",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-md bg-gradient-to-br from-accent/20 to-fuchsia-500/20 text-sm font-bold uppercase text-accent",children:c.name.slice(0,2)}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate font-medium",children:c.name}),a.jsx("div",{className:"truncate font-mono text-xs text-muted",title:c.root,children:c.root}),a.jsxs("div",{className:"mt-1 text-[12px] text-muted",children:["opened ",Tt(c.openedAt),c.contexts.length>0&&` · ${c.contexts.length} context folder${c.contexts.length>1?"s":""}`]})]}),a.jsx("button",{className:"rounded-md p-1.5 text-muted opacity-0 transition hover:bg-raised hover:text-bad group-hover:opacity-100",title:"Remove from the list (your lenses and quizzes stay on disk)",onClick:d=>{d.stopPropagation(),l.mutate(c.id)},children:a.jsx(pr,{className:"h-4 w-4"})}),a.jsx(Hu,{className:"h-4 w-4 text-muted transition group-hover:translate-x-0.5 group-hover:text-accent"})]},c.id)),!i.isLoading&&!o.length&&a.jsxs("div",{className:"card col-span-full border-dashed p-10 text-center text-sm text-muted",children:["No projects yet. Open a folder, or start from a terminal: ",a.jsx("span",{className:"kbd",children:"npx cognitune ./my-repo"})]})]})]}),n&&a.jsx(pp,{title:"Open a folder",start:((u=o[0])==null?void 0:u.root.split("/").slice(0,-1).join("/"))||void 0,onClose:()=>r(!1),onPick:c=>{r(!1),s.mutate(c)}})]})}function fr(e,t=36){if(e.length<=t)return e;const n=e.split("/"),r=n.pop()??"";return[...n.map(s=>s===""?"":s.startsWith(".")?s.slice(0,2):s[0]),r].join("/")}const bS={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"csharp",c:"c",h:"c",cpp:"cpp",hpp:"cpp",swift:"swift",scala:"scala",sh:"bash",zsh:"bash",bash:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",md:"markdown",html:"html",css:"css",scss:"scss",vue:"vue",svelte:"svelte",tf:"hcl",hcl:"hcl",xml:"xml",ini:"ini",lua:"lua",r:"r",dart:"dart",ex:"elixir",exs:"elixir"};function x0(e){const t=(e.split("/").pop()??"").toLowerCase();if(t==="dockerfile")return"docker";if(t==="makefile")return"make";const n=t.includes(".")?t.slice(t.lastIndexOf(".")+1):"";return bS[n]??"text"}const jS=/\.(ts|tsx|js|jsx|mjs|py|go|rs|java|kt|rb|php|cs|c|h|cpp|swift|scala|sh|sql|vue|svelte|lua|dart|ex)$/i,NS=/\.(md|txt|rst|json|ya?ml|toml|ini|cfg)$/i;function y0(e){return e.kind==="file"?[e.path]:(e.children??[]).flatMap(y0)}function v0(e,t){if(!t)return e;const n=t.toLowerCase(),r=[];for(const i of e)if(i.kind==="file")i.path.toLowerCase().includes(n)&&r.push(i);else{const s=v0(i.children??[],t);s.length&&r.push({...i,children:s})}return r}const SS={new:"",seen:"bg-muted/50",understood:"bg-good",fading:"bg-warn/50",stale:"bg-warn"};function mp({roots:e,selected:t,onToggle:n,openFile:r,onOpen:i,levels:s,meta:l,openAll:o=!1}){const[u,c]=b.useState(""),[d,h]=b.useState(()=>o?new Set:new Set(e.map(g=>g.path))),p=b.useMemo(()=>new Set(t),[t]),f=b.useMemo(()=>v0(e,u.trim()),[e,u]),m=(g,k)=>{var M;const y=u?!0:o?!d.has(g.path):d.has(g.path),x=g.kind==="dir"?y0(g):[g.path],v=x.filter(F=>p.has(F)).length,j=v>0&&v===x.length,E=v>0&&!j,w=s==null?void 0:s.get(g.path),N=g.kind==="dir"?y?q1:np:jS.test(g.name)?os:NS.test(g.name)?s2:_1;return a.jsxs("div",{children:[a.jsxs("div",{className:le("group flex h-[22px] cursor-pointer items-center gap-1 pr-2 text-[13px]",r===g.path?"bg-sel text-ink dark:text-white":"hover:bg-raised"),style:{paddingLeft:k*12+8},onClick:()=>{g.kind==="dir"?h(F=>{const C=new Set(F);return C.has(g.path)?C.delete(g.path):C.add(g.path),C}):i(g.path)},children:[a.jsx(Tr,{className:le("h-3.5 w-3.5 shrink-0 text-muted transition",g.kind==="file"&&"invisible",y&&"rotate-90")}),a.jsx("input",{type:"checkbox",className:"h-3.5 w-3.5 shrink-0 cursor-pointer accent-[rgb(var(--accent))]",checked:j,ref:F=>{F&&(F.indeterminate=E)},onClick:F=>F.stopPropagation(),onChange:()=>n(x,!j),title:g.kind==="dir"?`Tick all ${x.length} files`:"Use as context"}),a.jsx(N,{className:le("h-4 w-4 shrink-0","text-muted")}),a.jsx("span",{className:"truncate",children:g.name}),w&&w!=="new"&&a.jsx("span",{title:w,className:le("ml-auto h-1.5 w-1.5 shrink-0 rounded-full",SS[w])}),l&&g.kind==="file"&&a.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:l(g.path)})]}),g.kind==="dir"&&y&&((M=g.children)==null?void 0:M.map(F=>m(F,k+1)))]},g.path)};return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx("div",{className:"px-2 py-1.5",children:a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2 top-[6px] h-3.5 w-3.5 text-muted"}),a.jsx("input",{className:"input h-[26px] pl-7 text-[13px]",placeholder:"Filter files",value:u,onChange:g=>c(g.target.value)})]})}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto pb-4",children:f.map(g=>m(g,0))})]})}function CS({current:e,onApply:t,onClose:n}){const{project:r}=it(),i=Dt(),[s,l]=b.useState(e),[o,u]=b.useState(null),[c,d]=b.useState(!1),h=ye({queryKey:["tree",r.id,r.contexts],queryFn:()=>me(`/projects/${r.id}/tree`)}),p=vi({mutationFn:f=>Ua(`/projects/${r.id}`,{contexts:[...r.contexts,f]}),onSuccess:()=>i.invalidateQueries()});return a.jsxs("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4 backdrop-blur-sm",onClick:n,children:[a.jsxs("div",{className:"card flex h-[80vh] w-full max-w-xl flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[a.jsx("h2",{className:"text-sm font-semibold",children:"Add context"}),a.jsxs("span",{className:"text-xs text-muted",children:[s.length," ticked"]}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:n,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2 text-xs text-muted",children:[a.jsx("span",{className:"flex-1",children:"Tick files from the project or its context folders. The model reads them next to the change."}),a.jsx(ee,{size:"sm",icon:a.jsx(B1,{className:"h-3.5 w-3.5"}),onClick:()=>d(!0),children:"Add a folder"})]}),p.error&&a.jsx("div",{className:"p-2",children:a.jsx(Ke,{error:p.error.message})}),a.jsxs("div",{className:"min-h-0 flex-1",children:[h.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),h.data&&a.jsx(mp,{roots:h.data,selected:s,onToggle:(f,m)=>l(m?[...new Set([...s,...f])]:s.filter(g=>!f.includes(g))),openFile:o,onOpen:f=>{u(f),l(s.includes(f)?s.filter(m=>m!==f):[...s,f])}})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t border-line px-4 py-3",children:[a.jsx(ee,{variant:"ghost",onClick:n,children:"Cancel"}),a.jsxs(ee,{variant:"primary",onClick:()=>{t(s),n()},children:["Use ",s.length," file",s.length===1?"":"s"]})]})]}),c&&a.jsx("div",{onClick:f=>f.stopPropagation(),children:a.jsx(pp,{title:"Add a context folder",cta:"Add as context",start:r.root.split("/").slice(0,-1).join("/"),onClose:()=>d(!1),onPick:f=>{d(!1),p.mutate(f)}})})]})}const Wc=5,Vc=[{id:"lens",label:"Lens",icon:_a,hint:"Read an explanation through one question"},{id:"quiz",label:"Quiz",icon:$a,hint:"Answer questions in your own words"},{id:"teach",label:"Teach",icon:Qu,hint:"Explain it yourself; get graded"},{id:"tutor",label:"Tutor",icon:Gu,hint:"Ask; get questions and hints back"},{id:"walk",label:"Walk",icon:Vu,hint:"One block at a time, with a check each"},{id:"practice",label:"Practice",icon:Ku,hint:"Write the key lines back"},{id:"hunt",label:"Bug hunt",icon:Wu,hint:"Find the bugs planted in a copy"},{id:"notes",label:"Notes",icon:G1,hint:"Your notes on this file"}],ES=["walk","hunt","notes"],Ag=[{value:1,label:"1",title:"One short hole"},{value:2,label:"2",title:"A condition and a computation"},{value:3,label:"3",title:"Core logic"},{value:4,label:"4",title:"Whole function bodies"}],Ig=[{value:1,label:"Easy",title:"One bug, fairly visible"},{value:2,label:"Medium",title:"Two bugs, one needs the logic"},{value:3,label:"Hard",title:"Two or three subtle bugs"}];function w0({files:e,diff:t,practiceFile:n,onRemove:r,onSetFiles:i}){var Xn,Jn,yr;const{project:s,rel:l,toggle:o,setSelected:u,focusLine:c}=it(),d=r??(Z=>o(Z,!1)),h=i??u,[p,f]=ec(),[m,g]=b.useState(!1),[k,y]=b.useState(!1),x=gt(),[v,j]=b.useState(()=>Vc.some(Z=>Z.id===p.get("do"))?p.get("do"):"lens"),[E,w]=b.useState(t?"change":"explain"),[N,M]=b.useState(""),[F,C]=b.useState(!1),[O,A]=b.useState(""),[V,U]=b.useState(""),[q,G]=b.useState("standard"),[X,z]=b.useState(null),[W,S]=b.useState(2),[D,te]=b.useState(""),[P,ve]=b.useState(1),[Le,we]=b.useState(""),Se=mn(),_t=ye({queryKey:["lens-kinds"],queryFn:()=>me("/lens-kinds"),staleTime:1/0}),an=ye({queryKey:["misconceptions",s.id],queryFn:()=>me(`/projects/${s.id}/misconceptions`)});b.useEffect(()=>{if(!p.get("do"))return;const Z=new URLSearchParams(p);Z.delete("do"),f(Z,{replace:!0})},[]);const Lt=`/projects/${s.id}`,qe=`/p/${s.id}`,lt=e.length===0,zn=ES.includes(v),An=ye({queryKey:["estimate",s.id,e],queryFn:()=>Ci(`${Lt}/estimate`,{files:e}),enabled:!lt&&!zn,staleTime:3e4}),Vt=()=>Se.run(`${Lt}/lenses`,{files:e,kind:N.trim()?"custom":E,question:N.trim()||void 0,diff:t,sketch:F&&O.trim()||void 0,traceInput:E==="trace"?V:void 0,depth:q},Z=>x(`${qe}/lens/${Z.resultId}`)),Gn=(Z=!1)=>Se.run(`${Lt}/quizzes`,Z?{files:[],weak:!0}:{files:e,diff:t,count:X??void 0},Qt=>x(`${qe}/quiz/${Qt.resultId}`)),on=(Z,Qt,vr)=>Se.run(`${Lt}/${Z}`,Qt,Zn=>x(`${qe}/${vr}/${Zn.resultId}`)),Yn=Vc.find(Z=>Z.id===v),xr=((Xn=an.data)==null?void 0:Xn.length)??0;return a.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1 border-b border-line p-2",children:Vc.map(Z=>a.jsxs("button",{onClick:()=>j(Z.id),title:Z.hint,className:le("flex flex-col items-center gap-0.5 rounded-lg px-1 py-1.5 text-[12px] font-medium transition",v===Z.id?"bg-accent/12 text-accent":"text-muted hover:bg-raised hover:text-ink"),children:[a.jsx(Z.icon,{className:"h-4 w-4"}),Z.label]},Z.id))}),a.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-4",children:[a.jsxs("p",{className:"-mb-1 text-xs text-muted",children:[Yn.hint,"."]}),!zn&&a.jsxs("section",{children:[a.jsxs("div",{className:"label flex items-center gap-1",children:[a.jsxs("span",{children:["Context · ",e.length]}),t&&a.jsxs("span",{className:"truncate normal-case tracking-normal",children:["· change ",t.base,"..",t.head||"working tree"]}),a.jsxs("button",{className:"ml-auto inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 normal-case tracking-normal text-accent hover:bg-accent/10",onClick:()=>g(!0),title:"Add files from the project or a context folder (docs, notes, a session)",children:[a.jsx(Q1,{className:"h-3 w-3"})," Add"]})]}),lt?a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"Tick files in the tree, open one, or use Add. The model reads only what you pick."}):a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[(k?e:e.slice(0,Wc)).map(Z=>a.jsxs("span",{className:"group inline-flex max-w-full items-center gap-1 rounded-md bg-raised px-2 py-1 font-mono text-[12px]",title:Z,children:[a.jsx("span",{className:"truncate",children:fr(l(Z))}),a.jsx("button",{className:"text-muted hover:text-bad",onClick:()=>d(Z),"aria-label":"Remove",children:a.jsx(Rn,{className:"h-3 w-3"})})]},Z)),e.length>Wc&&a.jsx("button",{className:"rounded-md px-2 py-1 text-[12px] font-medium text-accent hover:bg-accent/10",onClick:()=>y(Z=>!Z),children:k?"show less":`+${e.length-Wc} more`})]}),An.data&&a.jsxs("div",{className:le("mt-1.5 text-[12px]",An.data.cut?"text-warn":"text-muted"),children:["~",An.data.tokens.toLocaleString()," tokens",An.data.cut&&" · some files do not fit and will be left out"]})]}),zn&&a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"File"}),n?a.jsx("div",{className:"truncate rounded-md bg-raised px-2 py-1.5 font-mono text-xs",title:n,children:l(n)}):a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"Open a file first."})]}),v==="lens"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Pick a lens"}),a.jsx("div",{className:"grid grid-cols-1 gap-1.5",children:(_t.data??[]).map(Z=>a.jsxs("button",{onClick:()=>{w(Z.id),M("")},className:le("rounded-lg border px-3 py-2 text-left transition",E===Z.id&&!N.trim()?"border-accent/60 bg-accent/8 ring-1 ring-accent/30":"border-line hover:border-accent/30 hover:bg-raised"),children:[a.jsx("div",{className:"text-[14px] font-medium",children:Z.label}),a.jsx("div",{className:"text-xs text-muted",children:Z.blurb})]},Z.id))})]}),E==="trace"&&!N.trim()&&a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Input to trace"}),a.jsx("input",{className:"input",placeholder:"e.g. add(3) (empty = the model picks one)",value:V,onChange:Z=>U(Z.target.value)})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Depth"}),a.jsx(Zt,{value:q,onChange:G,options:[{value:"overview",label:"Overview",title:"About 1.5 screens: the big picture, 3-4 steps"},{value:"standard",label:"Standard",title:"At least 3 screens: enough to change it safely, 6-9 steps"},{value:"deep",label:"Deep",title:"5-6 screens, a long blog post: every branch and failure path, 11-15 steps"}]})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Or ask your own question"}),a.jsx("textarea",{className:"input min-h-[64px] resize-y",placeholder:"e.g. Why is the retry here and not in the caller?",value:N,onChange:Z=>M(Z.target.value)})]}),a.jsxs("section",{className:"rounded-lg border border-line p-3",children:[a.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[14px] font-medium",children:[a.jsx("input",{type:"checkbox",className:"accent-[rgb(var(--accent))]",checked:F,onChange:Z=>C(Z.target.checked)}),a.jsx(V1,{className:"h-3.5 w-3.5 text-accent"}),t?"Predict first":"My take first"]}),F&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-2 min-h-[72px] resize-y",placeholder:t?"What behaviour changes, and what test or caller would break?":"In 2-3 lines: what does it do, and how? Where is the risk?",value:O,onChange:Z=>A(Z.target.value)}),a.jsx("p",{className:"mt-1 text-[12px] text-muted",children:"The lens opens with where your take differs. That gap is where the learning is."})]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(ap,{className:"h-4 w-4"}),disabled:lt||Se.busy||F&&!O.trim(),onClick:Vt,children:"Make the lens"})]}),v==="quiz"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Questions"}),a.jsx(Zt,{value:X??0,onChange:Z=>z(Z===0?null:Z),options:[{value:0,label:"Default"},{value:3,label:"3"},{value:5,label:"5"},{value:8,label:"8"}]}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"Free-text answers. Questions ask about behaviour and reasons, not names. Mark each answer sure or guess."})]}),a.jsxs(ee,{variant:"primary",className:"w-full",icon:a.jsx($a,{className:"h-4 w-4"}),disabled:lt||Se.busy,onClick:()=>Gn(),children:["Quiz me on ",e.length||""," file",e.length===1?"":"s"]}),a.jsxs("div",{className:"rounded-lg border border-line p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[14px] font-medium",children:[a.jsx(Ji,{className:"h-3.5 w-3.5 text-bad"})," Weak spots · ",xr]}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"New questions aimed at what you got wrong before, from any file. A right answer clears the weak spot."}),a.jsx(ee,{className:"mt-2 w-full",size:"sm",disabled:!xr||Se.busy,onClick:()=>Gn(!0),children:"Quiz my weak spots"})]})]}),v==="teach"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Explain it to a new teammate"}),a.jsx("textarea",{className:"input min-h-[180px] resize-y",placeholder:"What does this code do, how, and why this way? What would surprise someone? Write it before you look anything up.",value:Le,onChange:Z=>we(Z.target.value)}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"Graded 1-5 against the code: what you got right, what you missed, what is wrong. 4+ counts as understood."})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Qu,{className:"h-4 w-4"}),disabled:lt||Se.busy||Le.trim().length<20,onClick:()=>on("teachbacks",{files:e,text:Le,diff:t},"teach"),children:"Grade my explanation"})]}),v==="tutor"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Your question"}),a.jsx("textarea",{className:"input min-h-[100px] resize-y",placeholder:"e.g. Why does this return early here?",value:Le,onChange:Z=>we(Z.target.value)}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"The tutor answers with a question or a hint first, and gives more each turn. Ask it to just tell you any time."})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Gu,{className:"h-4 w-4"}),disabled:lt||Se.busy||!Le.trim(),onClick:()=>on("threads",{files:e,text:Le,diff:t},"tutor"),children:"Ask the tutor"})]}),v==="walk"&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-xs text-muted",children:"The file in reading order, one block at a time. Answer a short check on each block before the next."}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Vu,{className:"h-4 w-4"}),disabled:!n||Se.busy,onClick:()=>on("walks",{file:n},"walk"),children:"Walk me through it"})]}),v==="practice"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsxs("div",{className:"label",children:["Concept to practise ",a.jsx("span",{className:"normal-case tracking-normal",children:"(optional)"})]}),a.jsx("input",{className:"input",placeholder:"e.g. retry with backoff, how a run resumes",value:D,onChange:Z=>te(Z.target.value)}),a.jsx("p",{className:"mt-1.5 text-xs text-muted",children:"Leave it empty and the model picks the main idea of the files above. Holes can land in any of them."})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Difficulty"}),a.jsx(Zt,{value:W,onChange:S,options:Ag.map(Z=>({...Z}))}),a.jsxs("p",{className:"mt-2 text-xs text-muted",children:[(Jn=Ag.find(Z=>Z.value===W))==null?void 0:Jn.title,". The key lines are cut out of a copy; you write them back here, with hints if you need them. Your folder is not touched."]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Ku,{className:"h-4 w-4"}),disabled:lt||Se.busy,onClick:()=>on("practice",{files:e,level:W,concept:D.trim()||void 0},"practice"),children:"Make the practice"})]}),v==="hunt"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Difficulty"}),a.jsx(Zt,{value:P,onChange:ve,options:Ig.map(Z=>({...Z}))}),a.jsxs("p",{className:"mt-2 text-xs text-muted",children:[(yr=Ig.find(Z=>Z.value===P))==null?void 0:yr.title,". Bugs go into a copy of the file. Click the lines you think are wrong and say why."]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Wu,{className:"h-4 w-4"}),disabled:!n||Se.busy,onClick:()=>on("hunts",{file:n,level:P},"hunt"),children:"Start the hunt"})]}),v==="notes"&&n&&a.jsx(PS,{file:n,line:c}),Se.busy&&Se.job&&a.jsx(sn,{kind:Se.job.kind,elapsed:Se.elapsed}),Se.error&&a.jsx(Ke,{error:Se.error,onClose:Se.clearError})]}),m&&a.jsx(CS,{current:e,onApply:h,onClose:()=>g(!1)})]})}function PS({file:e,line:t}){const{project:n,setOpenFile:r}=it(),i=Dt(),[s,l]=b.useState(""),o=ye({queryKey:["notes",n.id,e],queryFn:()=>me(`/projects/${n.id}/notes?file=${encodeURIComponent(e)}`)}),u=async()=>{await Ci(`/projects/${n.id}/notes`,{file:e,line:t??void 0,text:s}),l(""),i.invalidateQueries({queryKey:["notes",n.id]})},c=[...o.data??[]].sort((d,h)=>(d.line??0)-(h.line??0));return a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsxs("div",{className:"label",children:["New note ",t?`on line ${t}`:"on the file"]}),a.jsx("textarea",{className:"input min-h-[72px] resize-y",placeholder:"Click a line in the code to pin the note there.",value:s,onChange:d=>l(d.target.value)}),a.jsx(ee,{className:"mt-2 w-full",size:"sm",disabled:!s.trim(),onClick:u,children:"Add note"})]}),a.jsxs("section",{className:"space-y-2",children:[c.map(d=>a.jsxs("div",{className:"group rounded-lg border border-line p-2.5 text-[14px]",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[d.line?a.jsxs("button",{className:"font-mono text-[12px] text-accent hover:underline",onClick:()=>r(e,d.line),children:["line ",d.line]}):a.jsx("span",{className:"text-[12px] text-muted",children:"file"}),a.jsx("button",{className:"ml-auto text-muted opacity-0 transition hover:text-bad group-hover:opacity-100",onClick:async()=>{await cs(`/projects/${n.id}/notes/${d.id}`),i.invalidateQueries({queryKey:["notes",n.id]})},"aria-label":"Delete note",children:a.jsx(pr,{className:"h-3.5 w-3.5"})})]}),a.jsx("div",{className:"mt-1 whitespace-pre-wrap",children:d.text})]},d.id)),!c.length&&a.jsx("p",{className:"text-xs text-muted",children:"No notes on this file yet."})]})]})}function Ha({initial:e,onClose:t}){const{project:n,rel:r}=it(),i=Dt(),[s,l]=b.useState(e.front??""),[o,u]=b.useState(e.back??""),[c,d]=b.useState(null),[h,p]=b.useState(!1),f=async()=>{p(!0);try{await Ci(`/projects/${n.id}/cards`,{...e,front:s,back:o}),await i.invalidateQueries(),t()}catch(m){d(m.message),p(!1)}};return a.jsxs(tc,{title:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Fr,{className:"h-4 w-4 text-accent"})," New review card"]}),onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ee,{variant:"ghost",onClick:t,children:"Cancel"}),a.jsx(ee,{variant:"primary",loading:h,disabled:!s.trim()||!o.trim(),onClick:f,children:"Save card"})]}),children:[e.file&&a.jsxs("div",{className:"mb-3 font-mono text-[12px] text-muted",children:[r(e.file),e.line?`:${e.line}`:""]}),a.jsx("label",{className:"label",children:"Question (front)"}),a.jsx("textarea",{className:"input min-h-[72px]",value:s,onChange:m=>l(m.target.value),placeholder:"What should you be able to recall?",autoFocus:!0}),a.jsx("label",{className:"label mt-3",children:"Answer (back)"}),a.jsx("textarea",{className:"input min-h-[96px]",value:o,onChange:m=>u(m.target.value),placeholder:"The answer, in your own words"}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"The card comes back on the Review page: soon at first, then less often as you remember it."}),c&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:c})})]})}const TS=4e3;let LS=null;const MS=()=>LS??(LS=ml(()=>import("./index-CyHGDhfc.js"),[])),RS={docker:"dockerfile",make:"makefile",text:"text"};function zS(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qc(e,t){return`<pre><code>${e.split(`
468
+ */function pl(){return pl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pl.apply(this,arguments)}function d0(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,s;for(s=0;s<r.length;s++)i=r[s],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function _N(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function $N(e,t){return e.button===0&&(!t||t==="_self")&&!_N(e)}function Nh(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function qN(e,t){let n=Nh(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const BN=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],UN=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],HN="6";try{window.__reactRouterVersion=HN}catch{}function WN(e,t){return J2({basename:void 0,future:pl({},void 0,{v7_prependBasename:!0}),history:b2({window:void 0}),hydrationData:VN(),routes:e,mapRouteProperties:ON,dataStrategy:void 0,patchRoutesOnNavigation:void 0,window:void 0}).initialize()}function VN(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=pl({},t,{errors:QN(t.errors)})),t}function QN(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new wu(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let s=window[i.__subType];if(typeof s=="function")try{let l=new s(i.message);l.stack="",n[r]=l}catch{}}if(n[r]==null){let s=new Error(i.message);s.stack="",n[r]=s}}else n[r]=i;return n}const h0=b.createContext({isTransitioning:!1}),KN=b.createContext(new Map),GN="startTransition",Eg=sk[GN],YN="flushSync",Pg=vj[YN];function XN(e){Eg?Eg(e):e()}function Dl(e){Pg?Pg(e):e()}class JN{constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function ZN(e){let{fallbackElement:t,router:n,future:r}=e,[i,s]=b.useState(n.state),[l,o]=b.useState(),[u,c]=b.useState({isTransitioning:!1}),[d,h]=b.useState(),[p,f]=b.useState(),[m,g]=b.useState(),k=b.useRef(new Map),{v7_startTransition:y}=r||{},x=b.useCallback(M=>{y?XN(M):M()},[y]),v=b.useCallback((M,F)=>{let{deletedFetchers:C,flushSync:O,viewTransitionOpts:A}=F;C.forEach(U=>k.current.delete(U)),M.fetchers.forEach((U,q)=>{U.data!==void 0&&k.current.set(q,U.data)});let V=n.window==null||n.window.document==null||typeof n.window.document.startViewTransition!="function";if(!A||V){O?Dl(()=>s(M)):x(()=>s(M));return}if(O){Dl(()=>{p&&(d&&d.resolve(),p.skipTransition()),c({isTransitioning:!0,flushSync:!0,currentLocation:A.currentLocation,nextLocation:A.nextLocation})});let U=n.window.document.startViewTransition(()=>{Dl(()=>s(M))});U.finished.finally(()=>{Dl(()=>{h(void 0),f(void 0),o(void 0),c({isTransitioning:!1})})}),Dl(()=>f(U));return}p?(d&&d.resolve(),p.skipTransition(),g({state:M,currentLocation:A.currentLocation,nextLocation:A.nextLocation})):(o(M),c({isTransitioning:!0,flushSync:!1,currentLocation:A.currentLocation,nextLocation:A.nextLocation}))},[n.window,p,d,k,x]);b.useLayoutEffect(()=>n.subscribe(v),[n,v]),b.useEffect(()=>{u.isTransitioning&&!u.flushSync&&h(new JN)},[u]),b.useEffect(()=>{if(d&&l&&n.window){let M=l,F=d.promise,C=n.window.document.startViewTransition(async()=>{x(()=>s(M)),await F});C.finished.finally(()=>{h(void 0),f(void 0),o(void 0),c({isTransitioning:!1})}),f(C)}},[x,l,d,n.window]),b.useEffect(()=>{d&&l&&i.location.key===l.location.key&&d.resolve()},[d,p,i.location,l]),b.useEffect(()=>{!u.isTransitioning&&m&&(o(m.state),c({isTransitioning:!0,flushSync:!1,currentLocation:m.currentLocation,nextLocation:m.nextLocation}),g(void 0))},[u.isTransitioning,m]),b.useEffect(()=>{},[]);let j=b.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:M=>n.navigate(M),push:(M,F,C)=>n.navigate(M,{state:F,preventScrollReset:C==null?void 0:C.preventScrollReset}),replace:(M,F,C)=>n.navigate(M,{replace:!0,state:F,preventScrollReset:C==null?void 0:C.preventScrollReset})}),[n]),E=n.basename||"/",w=b.useMemo(()=>({router:n,navigator:j,static:!1,basename:E}),[n,j,E]),N=b.useMemo(()=>({v7_relativeSplatPath:n.future.v7_relativeSplatPath}),[n.future.v7_relativeSplatPath]);return b.useEffect(()=>IN(r,n.future),[r,n.future]),b.createElement(b.Fragment,null,b.createElement(qa.Provider,{value:w},b.createElement(hp.Provider,{value:i},b.createElement(KN.Provider,{value:k.current},b.createElement(h0.Provider,{value:u},b.createElement(DN,{basename:E,location:i.location,navigationType:i.historyAction,navigator:j,future:N},i.initialized||n.future.v7_partialHydration?b.createElement(eS,{routes:n.routes,future:n.future,state:i}):t))))),null)}const eS=b.memo(tS);function tS(e){let{routes:t,future:n,state:r}=e;return bN(t,void 0,r,n)}const nS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",rS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ft=b.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:s,replace:l,state:o,target:u,to:c,preventScrollReset:d,viewTransition:h}=t,p=d0(t,BN),{basename:f}=b.useContext(_r),m,g=!1;if(typeof c=="string"&&rS.test(c)&&(m=c,nS))try{let v=new URL(window.location.href),j=c.startsWith("//")?new URL(v.protocol+c):new URL(c),E=Dr(j.pathname,f);j.origin===v.origin&&E!=null?c=E+j.search+j.hash:g=!0}catch{}let k=yN(c,{relative:i}),y=sS(c,{replace:l,state:o,target:u,preventScrollReset:d,relative:i,viewTransition:h});function x(v){r&&r(v),v.defaultPrevented||y(v)}return b.createElement("a",pl({},p,{href:m||k,onClick:g||s?r:x,ref:n,target:u}))}),Sh=b.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:s="",end:l=!1,style:o,to:u,viewTransition:c,children:d}=t,h=d0(t,UN),p=Zu(u,{relative:h.relative}),f=Si(),m=b.useContext(hp),{navigator:g,basename:k}=b.useContext(_r),y=m!=null&&lS(p)&&c===!0,x=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=f.pathname,j=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;i||(v=v.toLowerCase(),j=j?j.toLowerCase():null,x=x.toLowerCase()),j&&k&&(j=Dr(j,k)||j);const E=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let w=v===x||!l&&v.startsWith(x)&&v.charAt(E)==="/",N=j!=null&&(j===x||!l&&j.startsWith(x)&&j.charAt(x.length)==="/"),M={isActive:w,isPending:N,isTransitioning:y},F=w?r:void 0,C;typeof s=="function"?C=s(M):C=[s,w?"active":null,N?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(M):o;return b.createElement(ft,pl({},h,{"aria-current":F,className:C,ref:n,style:O,to:u,viewTransition:c}),typeof d=="function"?d(M):d)});var Ch;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ch||(Ch={}));var Tg;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Tg||(Tg={}));function iS(e){let t=b.useContext(qa);return t||je(!1),t}function sS(e,t){let{target:n,replace:r,state:i,preventScrollReset:s,relative:l,viewTransition:o}=t===void 0?{}:t,u=gt(),c=Si(),d=Zu(e,{relative:l});return b.useCallback(h=>{if($N(h,n)){h.preventDefault();let p=r!==void 0?r:us(c)===us(d);u(e,{replace:p,state:i,preventScrollReset:s,relative:l,viewTransition:o})}},[c,u,d,r,i,n,e,s,l,o])}function ec(e){let t=b.useRef(Nh(e)),n=b.useRef(!1),r=Si(),i=b.useMemo(()=>qN(r.search,n.current?null:t.current),[r.search]),s=gt(),l=b.useCallback((o,u)=>{const c=Nh(typeof o=="function"?o(i):o);n.current=!0,s("?"+c,u)},[s,i]);return[i,l]}function lS(e,t){t===void 0&&(t={});let n=b.useContext(h0);n==null&&je(!1);let{basename:r}=iS(Ch.useViewTransitionState),i=Zu(e,{relative:t.relative});if(!n.isTransitioning)return!1;let s=Dr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Dr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vu(i.pathname,l)!=null||vu(i.pathname,s)!=null}const Lg=[{title:"Start here",sections:[{id:"start",title:"The idea in one minute",what:"cognitune helps you understand code, not just read it. It asks a model to explain, then makes you answer, explain back and find bugs, and it brings things back when you are about to forget them.",steps:["Open a folder (Projects page). cognitune only reads it. It never changes your files.","Go to Explore. Tick the files you want to understand.","Pick an activity on the right: Lens to read, Quiz or Teach to test yourself.","Wrong answers become Weak spots and review cards. Today shows what to do next."],examples:["First visit: Projects > Open a folder > Explore > tick src/queue.ts > Lens > Explain > Make lens.","Then: Quiz on the same file. Miss a question, and it shows up on Today under Weak spots."],notes:["Each model call takes about 20 to 90 seconds. A bar shows progress; you can keep browsing.","The model reads only the files you tick, plus the notes and context you add. Nothing else leaves your machine."]},{id:"projects",title:"Projects",what:"A project is one folder on your disk. Everything you make (lenses, quizzes, cards) is stored under that project.",steps:["Open a folder with Open folder. Type a path or browse.","Click a project card to enter it. The rail on the left changes to the project pages.","Remove (the button on the project card) takes it off the list. Its data moves to an archive and is deleted after the keep time (Settings > Storage). Opening the same folder again restores it."],examples:["Try the built-in sample: run cognitune with --demo. It opens a tiny queue project with a fake model."]},{id:"keys",title:"Keyboard shortcuts",what:"The short list. Press ? anywhere (outside a text box) to see it in a window.",examples:["Ctrl/Cmd + K : go to a page, file or project, or start an activity on the open file","Ctrl/Cmd + H : this help, opened at the section for the page you are on","? : shortcut list","[ and ] : fold or show the left and right panes","Space : Review, show the answer","1 2 3 4 : Review, rate again / hard / good / easy","Ctrl + Enter : Tutor, send the message","← → : Trace, step back and forward"]},{id:"palette",title:"Quick jump (Ctrl K)",what:"One box to go anywhere or start anything without the mouse.",steps:["Press Ctrl K (Cmd K on Mac).","Type a few letters. Pages, files in this project, other projects and activities are matched.","Press Enter to go. Esc closes."],examples:["Type: rev → Review","Type: queue → files with queue in the path","Type: quiz → start a quiz on the open file"]}]},{title:"Learn a codebase",sections:[{id:"today",title:"Today",what:"What to do now. The page picks the most useful next step so you do not have to decide.",steps:["Read the Suggested next card at the top. Start runs it.","Review cards: how many are due. Start review opens the flashcards.","Weak spots: things you got wrong. Quiz my weak spots builds a quiz from them.","Needs a refresh: files you passed a while ago, or that changed since. Click a file to quiz yourself on it.","Learning path: the next stop of a path you made."],notes:["The flame badge counts days in a row with any practice. Missing a day resets it; one review is enough to keep it."]},{id:"explore",title:"Explore: choose files and an activity",what:"The main workspace. File tree on the left, code in the middle, activities on the right.",steps:["Click a file name to open it and read it.","Tick the box beside a file or a folder to add it to the Context. The model reads only what is in Context.","Use the filter box above the tree to find a file by name.","Pick an activity (Lens, Quiz, Teach, Tutor, Walk, Practice, Bug hunt, Notes) in the right pane."],examples:["Understand one module: tick only src/queue.ts, Lens > Explain.","Understand how two files connect: tick both, Lens > Data flow.","A folder is ticked in one click; keep the selection small (1 to 5 files) for sharper answers."],notes:["Context · 3 means three files are selected. Add lets you pick files from the project or from a context folder (docs, notes, a session folder).","[ and ] fold the side panes to give the code more room."]},{id:"lens",title:"Lens: read an explanation through one question",what:"A lens is a written explanation of your selected files, built around one question. It is like a short blog post about the code, with a walkthrough, pitfalls and a check for each step.",steps:["Tick files in Explore. Open the Lens tab.","Pick a kind of lens (see the list below).","Choose depth: Overview (about 1.5 screens, 3 to 4 steps), Standard (at least 3 screens, enough to change the code safely), Deep (5 to 6 screens, like a long blog post: every branch and failure path). Deep takes several minutes because it is planned first, then written in parts.","Optional: type your own question for the lens to answer.","Click Make lens. A planner model first outlines the lesson, then a writer model writes it in parts. When it is ready, you land on the lens page."],examples:['Explain: "The tour: purpose, main pieces, how they connect." Best first lens for any file.',"Data flow: follow one value from where it enters to where it leaves. Try on a request handler.","State over time: what is stored, who changes it, in which order. Try on a class with fields.","Failure modes: bad input, timeouts, partial writes, retries. Try before changing error handling.","Contracts: inputs, outputs and invariants between parts. Try on an API or a module boundary.","Concepts: the vocabulary first, with the line where each term shows up. Try when the code uses words you do not know.","The change: pick it in Changes with a diff; gives intent, risk and what to check.","Trace a run: step by step through one example input, with the state at each line. Use the arrows to step.","History: what changed over time and why, from the commits."],notes:["On the lens page: Words you need first (click a term to see where it shows up), the walkthrough (each step has a code card, a pitfall and a check question), then gotchas and next steps.","Click open file on a step to jump the code pane to that range. The same file pane stays on the right.","Refresh rebuilds a lens when the code changed. A banner tells you when it did."]},{id:"quiz",title:"Quiz: answer in your own words",what:"Questions about your selected files. You type answers; the model grades each one and says what was missing.",steps:["Tick files. Open the Quiz tab. Choose how many questions (Default, 3, 5 or 8).","Click Make quiz. Answer every question in the box beneath it. Short answers are fine; the core idea is what counts.","Click Grade. Each answer gets a verdict, an explanation and the line it came from.","A wrong answer is saved as a Weak spot and turns into a review card."],examples:['Question: "What happens when pop() is called on an empty queue?" Answer: "It raises IndexError, the caller must catch it."',"Retake: open the quiz from Library > Quizzes. Your best score is kept; at most 20 attempts are stored."],notes:["Empty answers are not counted as misconceptions. They are just unanswered."]},{id:"teach",title:"Teach: explain it back",what:"You write an explanation as if teaching a colleague. The model grades it for what is right, what is missing and what is wrong.",steps:["Tick files. Open Teach.","Write your explanation in your own words. Do not look at the code more than you need.","Submit. You get strengths, gaps and corrections tied to lines.","Gaps become Weak spots, so they come back later."],examples:['"A queue stores items in order. push adds at the tail; pop removes the head. When it is empty, pop raises." Short and specific beats long and vague.']},{id:"tutor",title:"Tutor: get hints, not answers",what:"A chat that helps you reach the answer yourself. Hints come in steps. Ask for the answer when you are stuck.",steps:["Tick files. Open Tutor and type a question.","The tutor replies with a question or a small hint (level 1). Ask again for more help: level 2 is a stronger hint, level 3 nearly gives it away.","At level 4 it tells you directly. Use that when you are really stuck.","Ctrl + Enter sends the message."],examples:['You: "Why does flush() hold the lock while it writes?" Tutor: "What could happen to the buffer if another thread called push() in the middle?"'],notes:["Only the last 200 messages of a chat are kept."]},{id:"walk",title:"Walk: one block at a time",what:"A guided tour of one file in small blocks. After each block you answer a short check before moving on.",steps:["Open a file, tick it, open Walk, click Make walk.","Read the block. Answer the check below it. Press Check.","A right answer unlocks the next block. A wrong one explains and keeps you on the block."],examples:["Use it for a file you must understand fully before changing it, such as a parser or a state machine."]},{id:"practice",title:"Practice: write the key lines back",what:"The code with some lines removed. You type them from memory and get feedback.",steps:["Choose a level: 1 one short hole, 2 a condition and a computation, 3 core logic, 4 whole function bodies.","Click Make practice. Fill the gaps in the editor.","Submit. You see your version next to the real one, with differences explained.","The eye button hides or shows the original. Reset restores the gaps."],examples:["Start at level 1 on a function you read today. Move to level 3 a week later."]},{id:"hunt",title:"Bug hunt: find the planted bugs",what:"cognitune plants bugs in a copy of the code (your files are not touched). You mark the lines you think are wrong.",steps:["Choose difficulty: Easy (one visible bug), Medium (two, one needs the logic), Hard (two or three subtle ones).","Click Make hunt. Read the copy and click lines you think are buggy.","Press Grade. The real bugs show up, with what was wrong and how you did."],notes:["The bugs are hidden until you grade. Reloading the page does not reveal them."]},{id:"notes",title:"Notes",what:"Your own notes on a file or a line. They can be included in prompts so answers match what you already know.",steps:["Open a file. Click a line number, add a note, save.","A mark appears in the margin. Click it to read or edit.","Turn on Settings > Notes in prompts to let the model see your notes."],examples:['"I keep mixing up head and tail here. Head is where pop reads."']},{id:"changes",title:"Changes: learn from a diff",what:"Understand a commit, a branch or uncommitted work before you review or merge it.",steps:["Choose a repo, then what to compare (for example a branch against main, or a single commit).","Tick the changed files you care about.","Use the activity panel: Lens > The change gives intent, risk and what to check."],examples:["Before reviewing a colleague's branch: Changes > main..feature/x > tick the three biggest files > Lens > The change."]}]},{title:"Remember it",sections:[{id:"review",title:"Review: flashcards that come back on time",what:"Cards are spaced: easy ones return later, hard ones sooner (FSRS). Ten minutes a day beats an hour once.",steps:["Open Review (the badge shows how many are due).","Read the question. Say or type your answer in your head. Press Space to show the answer.","Rate yourself: 1 Again (forgot), 2 Hard, 3 Good, 4 Easy. The buttons show when each will return."],examples:["Forgot it completely → 1. It returns in minutes.","Got it but had to think → 2 or 3.","Got it instantly → 4. It goes weeks out."],notes:["Cards come from wrong quiz answers, teach-back gaps and weak spots (Settings > Cards from misses). You can also add a card from the file view with the card button.","Only the last 50 reviews of each card are kept."]},{id:"library",title:"Library: everything you made",what:"One place for every lens, quiz, practice, teach-back, walk, hunt, tutor chat, card, glossary term and note in this project.",steps:["Pick a tab. Use Search this tab to filter.","Click an item to open it. Items you delete go to an archive and are removed after the keep time.","Glossary is the list of terms the lenses defined, across all lenses."],examples:["Looking for the lens you made last week on the scheduler: Library > Lenses > search: scheduler."]},{id:"progress",title:"Progress",what:"What you can show you understand, rolled up from files to folders and git repos.",steps:["At a folder of many repos, each repo is one row with a coverage bar; click a row to go into its folders, then files. The bar at the top goes back up, and its repo picker jumps to a repo.","The cards, the table and the heatmap all follow that scope. Search filters the touched files in it. The scope is in the address, so you can bookmark it.","Levels: new, seen, understood, fading, stale. A file turns fading after a few weeks without practice, and stale when the code changed since you studied it (Settings > fade days).","Click a file to open it in Explore."]}]},{title:"See the shape",sections:[{id:"map",title:"Map: how files connect",what:"Which parts of the code import which. At a folder of many repos each repo is one node; inside a repo, folders; then files.",steps:["Open Map. Ringed circles are folders (the number is how many code files they hold), small dots are files. A thicker arrow carries more imports.","Click a folder to go into it; the bar at the top goes back up, and its repo picker jumps straight to a repo. Click a file to read it in a pane beside the map; Ctrl/Cmd+click opens it in Explore.","Drag a dot to move it out of the way. Use + and − (or scroll) to zoom; the fit button resets the view and puts dragged dots back.","A folder of 8 code files or fewer shows its files directly, so you never drill in for two files.","Colours show your level: grey not yet, blue seen, green understood, amber fading or stale.","The map is read once and kept. Press Refresh after imports change."],examples:["At the top level, a thick arrow from one repo to another shows a real dependency between them. Click the target to see which of its folders are used."],notes:["Import links are found by reading import lines (TypeScript, JavaScript and Python). Aliases from tsconfig paths are followed."]},{id:"paths",title:"Paths: an ordered tour",what:"A learning path is an ordered list of stops: where to start, what next, and how to check each stop.",steps:["Open Paths. Describe your goal, or leave it blank for a general tour.","Click Make a path. Each stop has files, why it matters and an activity.",`A stop's Start button ("Start the lens", "Start the quiz"...) opens Explore with the files ticked and the activity ready.`,"Tick a stop off when done. Today shows the next stop."],examples:['Goal: "I need to add retries to the job runner." The path walks queue, worker, then error handling.']}]},{title:"Settings and storage",sections:[{id:"settings",title:"Settings",what:"Which model runs, how text looks, and what cognitune keeps.",steps:["Planning model (default claude-opus-5-5) plans lenses, quizzes, walks, practice, bug hunts and paths; the model above (default claude-sonnet-5-5) writes them. Plan first can be turned off for one-shot answers.","Model: choose the agent (Auto, Claude Code CLI, Codex CLI, GitHub Copilot CLI, an Anthropic API key, or Demo). Auto uses the first one installed.","Reading font: sans (default) or serif for lens pages.","Cards, progress and notes: switches for turning wrong answers into cards, how fast files fade, and whether notes go to the model.","Recent model calls: the last calls with how long they took and any error."]},{id:"storage",title:"Storage: keeping it small",what:"Everything is plain JSON files in your cognitune folder (shown in Settings). It stays bounded on its own and you can also remove things by hand.",steps:["Automatic: archived items and forgotten projects are removed after the keep time (30 days by default). The reply cache keeps to its size (50 MB). Quiz attempts, card history, tutor chats and the job log are capped.","Clean up now applies those limits at once.","Choose what to remove: open the list, filter by kind, tick the items, press Remove selected, then confirm. Select all shown ticks every row in the current filter."],examples:["Free space fast: Choose what to remove > kind: reply cache > Select all shown > Remove selected. Nothing you made is lost; answers are just asked again later.","Remove one old lens: kind: lenses > tick it > Remove selected."],notes:["Removing is permanent (no archive step). Your project folders are never touched."]}]}];function aS(e){const t=e.match(/^\/p\/[^/]+\/([^/]+)/),n=t==null?void 0:t[1];return e==="/settings"?"settings":e==="/"?"projects":n?{today:"today",explore:"explore",review:"review",map:"map",paths:"paths",path:"paths",library:"library",progress:"progress",changes:"changes",lens:"lens",quiz:"quiz",teach:"teach",tutor:"tutor",walk:"walk",practice:"practice",hunt:"hunt"}[n]??null:null}function oS(){const[e]=ec(),t=Si(),[n,r]=b.useState(""),i=e.get("s"),[s,l]=b.useState(i??"start"),o=b.useMemo(()=>{const c=n.trim().toLowerCase();return c?Lg.map(d=>({...d,sections:d.sections.filter(h=>[h.title,h.what,...h.steps??[],...h.examples??[],...h.notes??[]].join(" ").toLowerCase().includes(c))})).filter(d=>d.sections.length):Lg},[n]);b.useEffect(()=>{i&&(l(i),requestAnimationFrame(()=>{var c;return(c=document.getElementById(`help-${i}`))==null?void 0:c.scrollIntoView({block:"start"})}))},[i,t.key]);const u=c=>{var d;l(c),(d=document.getElementById(`help-${c}`))==null||d.scrollIntoView({behavior:"smooth",block:"start"})};return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"mx-auto flex max-w-6xl gap-10 px-8 py-10",children:[a.jsxs("nav",{className:"sticky top-0 hidden h-fit w-56 shrink-0 lg:block",children:[a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted"}),a.jsx("input",{className:"input h-9 pl-8 text-[14px]",placeholder:"Search help",value:n,onChange:c=>r(c.target.value)})]}),a.jsx("div",{className:"mt-4 space-y-4",children:o.map(c=>a.jsxs("div",{children:[a.jsx("div",{className:"px-2 text-[11px] font-semibold uppercase tracking-wide text-muted",children:c.title}),a.jsx("ul",{className:"mt-1",children:c.sections.map(d=>a.jsx("li",{children:a.jsx("button",{onClick:()=>u(d.id),className:le("w-full rounded-md px-2 py-1.5 text-left text-[14px] hover:bg-raised",s===d.id?"bg-accent/10 font-medium text-accent":"text-ink"),children:d.title.split(":")[0]})},d.id))})]},c.title))})]}),a.jsxs("main",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Help"}),a.jsxs("p",{className:"mt-2 max-w-2xl text-[16px] leading-relaxed text-muted",children:["What every part does, how to use it, and something to try. Press ",a.jsx("span",{className:"kbd",children:"Ctrl H"})," on any page to open this at the matching part."]}),a.jsx("div",{className:"mt-4 lg:hidden",children:a.jsx("input",{className:"input",placeholder:"Search help",value:n,onChange:c=>r(c.target.value)})}),o.map(c=>a.jsxs("div",{children:[a.jsx("h2",{className:"mt-12 border-b border-line pb-2 text-sm font-semibold uppercase tracking-wide text-muted",children:c.title}),c.sections.map(d=>a.jsxs("section",{id:`help-${d.id}`,className:"scroll-mt-6 pt-8",children:[a.jsx("h3",{className:"text-2xl font-semibold tracking-tight",children:d.title}),a.jsx("p",{className:"mt-2 max-w-3xl text-[17px] leading-[1.65]",children:d.what}),d.steps&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-accent",children:"How to use it"}),a.jsx("ol",{className:"mt-2 max-w-3xl list-decimal space-y-2 pl-6 text-[16px] leading-[1.6] marker:text-muted",children:d.steps.map(h=>a.jsx("li",{children:h},h))})]}),d.examples&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-accent",children:"Try this"}),a.jsx("div",{className:"mt-2 max-w-3xl space-y-2",children:d.examples.map(h=>a.jsx("div",{className:"rounded-lg border border-line bg-raised px-4 py-2.5 text-[15px] leading-[1.55]",children:h},h))})]}),d.notes&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-5 text-xs font-semibold uppercase tracking-wide text-muted",children:"Good to know"}),a.jsx("ul",{className:"mt-2 max-w-3xl list-disc space-y-1.5 pl-6 text-[15px] leading-[1.6] text-muted marker:text-line",children:d.notes.map(h=>a.jsx("li",{children:h},h))})]})]},d.id))]},c.title)),!o.length&&a.jsxs("p",{className:"mt-10 text-muted",children:['Nothing matches "',n,'".']}),a.jsx("div",{className:"h-24"})]})]})})}async function Ba(e,t){const{json:n,...r}=t??{},i=await fetch(`/api${e}`,{...r,headers:{"content-type":"application/json",...r.headers??{}},body:n===void 0?r.body:JSON.stringify(n)}),s=await i.json().catch(()=>({}));if(!i.ok)throw new Error(s.error||`${i.status} ${i.statusText}`);return s}const me=e=>Ba(e),Ci=(e,t={})=>Ba(e,{method:"POST",json:t}),Eh=(e,t)=>Ba(e,{method:"PUT",json:t}),Ua=(e,t)=>Ba(e,{method:"PATCH",json:t}),cs=e=>Ba(e,{method:"DELETE"}),uS=e=>new Promise(t=>setTimeout(t,e)),Ph=new Set;function mn(){const e=Dt(),[t,n]=b.useState(null),[r,i]=b.useState(null),[s,l]=b.useState(0),o=b.useRef(!0);return b.useEffect(()=>()=>void(o.current=!1),[]),b.useEffect(()=>{if((t==null?void 0:t.status)!=="running")return;const c=Date.parse(t.startedAt),d=setInterval(()=>l(Math.round((Date.now()-c)/1e3)),500);return()=>clearInterval(d)},[t==null?void 0:t.status,t==null?void 0:t.startedAt]),{run:b.useCallback(async(c,d,h)=>{i(null),l(0);let p;try{let f=await Ci(c,d);for(p=f.id,Ph.add(p),n(f),e.invalidateQueries({queryKey:["project-jobs"]});f.status==="running";){if(await uS(1e3),!o.current)return;f=await me(`/jobs/${f.id}`),n(f)}f.status==="failed"?i(f.error??"the job failed"):(await e.invalidateQueries(),h==null||h(f))}catch(f){i(f instanceof Error?f.message:String(f)),n(null)}finally{p&&Ph.delete(p)}},[e]),job:t,busy:(t==null?void 0:t.status)==="running",error:r,elapsed:s,clearError:()=>i(null)}}function Tt(e){const t=Math.round((Date.now()-Date.parse(e))/1e3);return t<60?"just now":t<3600?`${Math.round(t/60)} min ago`:t<86400?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} d ago`}function ee({variant:e="secondary",size:t="md",icon:n,className:r,children:i,loading:s,...l}){return a.jsxs("button",{...l,disabled:l.disabled||s,className:le("inline-flex select-none items-center justify-center gap-2 rounded-sm font-medium transition","disabled:cursor-not-allowed disabled:opacity-50","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",t==="sm"&&"h-[22px] px-2 text-xs",t==="md"&&"h-[26px] px-3 text-[13px]",t==="lg"&&"h-8 px-4 text-sm",e==="primary"&&"bg-accent text-accent-ink hover:brightness-110",e==="secondary"&&"border border-muted/40 bg-raised text-ink hover:border-muted/70 hover:brightness-95",e==="ghost"&&"text-muted hover:bg-raised hover:text-ink",e==="danger"&&"border border-bad/30 bg-bad/10 text-bad hover:bg-bad/15",r),children:[s?a.jsx(H1,{className:"h-4 w-4 animate-spin"}):n,i]})}function be({tone:e="muted",children:t,className:n}){return a.jsx("span",{className:le("inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium",e==="muted"&&"bg-raised text-muted",e==="accent"&&"bg-accent/12 text-accent",e==="good"&&"bg-good/12 text-good",e==="warn"&&"bg-warn/15 text-warn",e==="bad"&&"bg-bad/12 text-bad",n),children:t})}function f0({v:e}){return a.jsx(be,{tone:e==="right"?"good":e==="partial"?"warn":"bad",children:e})}function kt({className:e}){return a.jsx(H1,{className:le("h-4 w-4 animate-spin text-muted",e)})}function Ft({icon:e,title:t,children:n,action:r}){return a.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-16 text-center",children:[e&&a.jsx("div",{className:"mb-4 grid h-12 w-12 place-items-center rounded-2xl bg-accent/10 text-accent",children:e}),a.jsx("h3",{className:"text-base font-semibold",children:t}),n&&a.jsx("div",{className:"mt-1.5 max-w-md text-sm text-muted",children:n}),r&&a.jsx("div",{className:"mt-5",children:r})]})}function Ke({error:e,onClose:t}){return a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-bad/30 bg-bad/8 px-3 py-2 text-sm text-bad",children:[a.jsx(op,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("div",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:e}),t&&a.jsx("button",{onClick:t,className:"opacity-60 hover:opacity-100","aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]})}const cS={lens:["Reading the files","Finding the core idea","Writing the lesson"],quiz:["Reading the files","Choosing what matters","Writing questions"],grade:["Reading your answers","Checking against the code","Writing feedback"],practice:["Reading the file","Choosing the key logic","Cutting the holes"],review:["Reading your code","Comparing with the original","Writing feedback"],teachback:["Reading your explanation","Checking it against the code","Writing feedback"],tutor:["Reading the conversation","Thinking of a good question","Writing"],walk:["Reading the file","Finding the reading order","Writing check questions"],walkcheck:["Reading your answer","Checking the block"],hunt:["Reading the file","Choosing where to break it","Planting the bugs"],huntgrade:["Matching your marks","Checking your reasons","Writing feedback"],path:["Reading the repo layout","Ordering the stops","Writing the path"]};function sn({kind:e,elapsed:t}){const n=cS[e]??["Working"],r=Math.min(n.length-1,Math.floor(t/12));return a.jsxs("div",{className:"shimmer card p-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kt,{className:"text-accent"}),a.jsxs("div",{className:"text-sm font-medium",children:[n[r],"..."]}),a.jsxs("div",{className:"ml-auto font-mono text-xs text-muted",children:[t,"s"]})]}),a.jsx("div",{className:"mt-3 flex gap-1.5",children:n.map((i,s)=>a.jsx("div",{className:le("h-1 flex-1 rounded-full transition-colors",s<=r?"bg-accent":"bg-line")},i))}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"Model calls take 20 seconds to 2 minutes. You can leave this page: it keeps running, and the status bar says when it is ready."})]})}function Zt({value:e,onChange:t,options:n}){return a.jsx("div",{className:"inline-flex rounded-sm border border-line bg-raised p-0.5",children:n.map(r=>a.jsx("button",{title:r.title,onClick:()=>t(r.value),className:le("rounded-sm px-2.5 py-0.5 text-xs font-medium transition",r.value===e?"bg-panel text-ink":"text-muted hover:text-ink"),children:r.label},String(r.value)))})}function dS({value:e,onChange:t,tabs:n,className:r,wrap:i=!1}){return a.jsx("div",{className:le("flex border-b border-line bg-side",i?"flex-wrap":"overflow-x-auto",r),children:n.map(s=>a.jsxs("button",{onClick:()=>t(s.value),className:le("relative flex h-[35px] shrink-0 items-center gap-1.5 whitespace-nowrap border-r border-line px-3 text-[13px] transition",i&&"grow justify-center last:border-r-0",s.value===e?"bg-bg text-ink":"text-muted hover:text-ink"),children:[s.icon,s.label,s.count!==void 0&&s.count>0&&a.jsx("span",{className:"rounded-full bg-raised px-1.5 text-[11.5px] text-muted",children:s.count}),s.value===e&&a.jsx("span",{className:"absolute inset-x-0 top-0 h-px bg-accent"})]},s.value))})}function Ca({score:e,size:t="md"}){const n=Math.round(e*100),r=e>=.67?"text-good":e>=.4?"text-warn":"text-bad";return a.jsxs("span",{className:le("font-semibold tabular-nums",r,t==="sm"?"text-xs":"text-sm"),children:[n,"%"]})}function tc({title:e,onClose:t,children:n,footer:r,wide:i}){return a.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4",onClick:t,onKeyDown:s=>s.key==="Escape"&&t(),children:a.jsxs("div",{className:le("card flex max-h-[85vh] w-full flex-col overflow-hidden",i?"max-w-2xl":"max-w-lg"),onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center border-b border-line px-4 py-2",children:[a.jsx("h2",{className:"text-sm font-semibold",children:e}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:t,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:n}),r&&a.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:r})]})})}function nc({back:e,badges:t,title:n,sub:r,actions:i}){return a.jsxs("div",{children:[e,t&&a.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:t}),a.jsxs("div",{className:"mt-2 flex items-start gap-3",children:[a.jsx("h1",{className:"min-w-0 flex-1 text-[20px] font-semibold leading-tight tracking-tight",children:n}),i&&a.jsx("div",{className:"flex shrink-0 gap-2",children:i})]}),r&&a.jsx("div",{className:"mt-1 text-sm text-muted",children:r})]})}function Th(e){const t=Math.max(0,Math.round((Date.parse(e)-Date.now())/1e3));return t<90?"now":t<3600?`${Math.round(t/60)} min`:t<86400?`${Math.round(t/3600)} h`:t<86400*60?`${Math.round(t/86400)} d`:`${Math.round(t/(86400*30))} mo`}const hS={"Go to":og,Do:og,Files:_1,Projects:$1};function p0(e,t){return e.flatMap(n=>n.kind==="file"?[{path:n.path,rel:n.path.startsWith(t+"/")?n.path.slice(t.length+1):n.path}]:p0(n.children??[],t))}function fS({pid:e,root:t,onClose:n,openFile:r}){const i=gt(),[s,l]=b.useState(""),[o,u]=b.useState(0),c=b.useRef(null),d=ye({queryKey:["tree-flat",e],queryFn:()=>me(`/projects/${e}/tree`),enabled:!!e,staleTime:6e4}),h=ye({queryKey:["projects"],queryFn:()=>me("/projects")}),p=b.useMemo(()=>{const g=y=>()=>i(y),k=[];if(e){const y=`/p/${e}`;for(const[x,v]of[["Today","today"],["Explore","explore"],["Changes","changes"],["Review cards","review"],["Map","map"],["Learning paths","paths"],["Library","library"],["Progress","progress"]])k.push({id:`go-${v}`,label:x,group:"Go to",run:g(`${y}/${v}`)});for(const[x,v]of[["Lens on the open file","lens"],["Quiz me on the open file","quiz"],["Teach it back","teach"],["Ask the tutor","tutor"],["Walk through the open file","walk"],["Practice on the open file","practice"],["Bug hunt in the open file","hunt"],["Notes on the open file","notes"]])k.push({id:`do-${v}`,label:x,group:"Do",run:g(`${y}/explore?do=${v}`)});if(d.data&&t)for(const x of p0(d.data,t))k.push({id:`f-${x.path}`,label:x.rel,group:"Files",run:()=>r==null?void 0:r(x.path)})}k.push({id:"go-help",label:"Help (Ctrl H)",group:"Go to",run:g("/help")}),k.push({id:"go-settings",label:"Settings",group:"Go to",run:g("/settings")});for(const y of h.data??[])k.push({id:`p-${y.id}`,label:y.name,hint:y.root,group:"Projects",run:g(`/p/${y.id}/today`)});return k},[e,t,d.data,h.data,i,r]),f=b.useMemo(()=>{const g=s.toLowerCase().split(/\s+/).filter(Boolean);return(g.length?p.filter(y=>g.every(x=>`${y.label} ${y.hint??""} ${y.group}`.toLowerCase().includes(x))):p.filter(y=>y.group!=="Files")).slice(0,60)},[p,s]);b.useEffect(()=>{u(0)},[s]),b.useEffect(()=>{var g,k;(k=(g=c.current)==null?void 0:g.querySelector(`[data-i="${o}"]`))==null||k.scrollIntoView({block:"nearest"})},[o]);const m=g=>{g&&(n(),g.run())};return a.jsxs(tc,{title:"Go to or do",onClose:n,wide:!0,children:[a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-muted"}),a.jsx("input",{autoFocus:!0,className:"input pl-9",placeholder:"Type a page, an activity, a file or a project",value:s,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="ArrowDown"&&(g.preventDefault(),u(k=>Math.min(f.length-1,k+1))),g.key==="ArrowUp"&&(g.preventDefault(),u(k=>Math.max(0,k-1))),g.key==="Enter"&&m(f[o]),g.key==="Escape"&&n()}})]}),a.jsxs("div",{ref:c,className:"mt-3 max-h-[50vh] overflow-auto",children:[f.map((g,k)=>{const y=hS[g.group],x=k===0||f[k-1].group!==g.group;return a.jsxs("div",{children:[x&&a.jsx("div",{className:"px-2 pb-1 pt-2 text-[11.5px] font-semibold uppercase tracking-wide text-muted",children:g.group}),a.jsxs("button",{"data-i":k,onMouseMove:()=>u(k),onClick:()=>m(g),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[14px]",k===o?"bg-accent/12 text-ink":"text-ink/85"),children:[a.jsx(y,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),a.jsx("span",{className:le("min-w-0 flex-1 truncate",g.group==="Files"&&"font-mono text-[13px]"),children:g.label}),g.hint&&a.jsx("span",{className:"truncate text-[12px] text-muted",children:g.hint}),k===o&&a.jsx(t2,{className:"h-3.5 w-3.5 text-muted"})]})]},g.id)}),!f.length&&a.jsx("div",{className:"px-2 py-6 text-center text-sm text-muted",children:"Nothing matches."})]})]})}const pS=[["Ctrl/Cmd + K","Go to a page, file or project; start an activity"],["Ctrl/Cmd + H","Help, opened at the part for this page"],["?","This list"],["[ and ]","Fold or show the left and right panes"],["Space","Review: reveal the answer"],["1 2 3 4","Review: again, hard, good, easy"],["Ctrl + Enter","Tutor: send"],["← →","Trace: step back and forward"]];function mS({onClose:e}){return a.jsx(tc,{title:"Keyboard shortcuts",onClose:e,children:a.jsx("table",{className:"w-full text-sm",children:a.jsx("tbody",{children:pS.map(([t,n])=>a.jsxs("tr",{className:"border-b border-line/60 last:border-0",children:[a.jsx("td",{className:"py-2 pr-4",children:a.jsx("span",{className:"kbd",children:t})}),a.jsx("td",{className:"py-2 text-muted",children:n})]},t))})})})}function m0({className:e}){return a.jsxs("svg",{viewBox:"0 0 32 32",className:e,"aria-hidden":!0,children:[a.jsx("rect",{width:"32",height:"32",rx:"6",fill:"rgb(var(--accent))"}),a.jsx("circle",{cx:"14",cy:"14",r:"6.5",fill:"none",stroke:"white",strokeWidth:"2.8"}),a.jsx("path",{d:"M19 19l6 6",stroke:"white",strokeWidth:"2.8",strokeLinecap:"round"})]})}function wn({to:e,icon:t,label:n,end:r,badge:i}){return a.jsxs(Sh,{to:e,end:r,title:n,"aria-label":n,className:({isActive:s})=>le("relative grid h-12 w-12 shrink-0 place-items-center transition-colors",s?"text-ink before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent":"text-muted hover:text-ink"),children:[t,!!i&&a.jsx("span",{className:"absolute bottom-2 right-1.5 min-w-[16px] rounded-full bg-accent px-1 text-center text-[10px] font-semibold leading-4 text-accent-ink",children:i>99?"99+":i})]})}const gS={system:"light",light:"dark",dark:"system"},Hc={lens:"lens",quiz:"quiz",grade:"grading",practice:"practice",review:"review",teachback:"teach-back",tutor:"tutor reply",walk:"walkthrough",walkcheck:"check",hunt:"bug hunt",huntgrade:"grading",path:"path"},Mg={lens:"lens",quiz:"quiz",practice:"practice",teachback:"teach",tutor:"tutor",walk:"walk",hunt:"hunt",path:"paths"};function xS({pid:e}){const t=gt(),n=ye({queryKey:["project-jobs",e],queryFn:async()=>(await me(`/projects/${e}`)).running,refetchInterval:u=>{var c;return(c=u.state.data)!=null&&c.length?2e3:!1}}),r=n.data??[],i=b.useRef(new Set),[s,l]=b.useState([]);b.useEffect(()=>{const u=new Set(r.map(d=>d.id)),c=[...i.current].filter(d=>!u.has(d)&&!Ph.has(d));i.current=u;for(const d of c)me(`/jobs/${d}`).then(h=>{h.status==="done"&&h.resultId&&Mg[h.kind]&&l(p=>[...p.filter(f=>f.id!==h.id),h])}).catch(()=>{})},[n.dataUpdatedAt]);const o=s[s.length-1];if(r.length){const u=r[0],c=Math.max(0,Math.round((Date.now()-Date.parse(u.startedAt))/1e3));return a.jsxs("span",{className:"flex items-center gap-1.5 px-1.5",title:r.map(d=>Hc[d.kind]).join(", "),children:[a.jsx("span",{className:"[&>svg]:h-3 [&>svg]:w-3",children:a.jsx(kt,{className:"text-accent"})}),r.length===1?`${Hc[u.kind]} running · ${c}s`:`${r.length} jobs running`]})}return o?a.jsxs("span",{className:"flex items-center",children:[a.jsxs("button",{className:"flex items-center gap-1.5 px-1.5 text-good hover:bg-raised",onClick:()=>{l(u=>u.filter(c=>c.id!==o.id)),t(`/p/${e}/${Mg[o.kind]}/${o.resultId}`)},children:[a.jsx(vl,{className:"h-3 w-3"})," ",Hc[o.kind]," ready · open",s.length>1?` (+${s.length-1})`:""]}),a.jsx("button",{className:"px-1 hover:bg-raised hover:text-ink",title:"Dismiss",onClick:()=>l(u=>u.filter(c=>c.id!==o.id)),children:a.jsx(Rn,{className:"h-3 w-3"})})]}):null}function yS(){var g,k,y,x,v;const{pid:e}=$r(),{pref:t,setPref:n}=ly(),r=ye({queryKey:["health"],queryFn:()=>me("/health"),staleTime:6e4}),i=(g=r.data)==null?void 0:g.agent.ready,s=t==="dark"?f2:t==="light"?v2:h2,l=gt(),[o,u]=b.useState(!1),[c,d]=b.useState(!1),h=ye({queryKey:["cards-due",e],queryFn:()=>me(`/projects/${e}/cards/due`),enabled:!!e,staleTime:6e4}),f=(y=(k=ye({queryKey:["projects"],queryFn:()=>me("/projects"),enabled:!!e,staleTime:6e4}).data)==null?void 0:k.find(j=>j.id===e))==null?void 0:y.root;b.useEffect(()=>{const j=E=>{if((E.ctrlKey||E.metaKey)&&E.key.toLowerCase()==="k"){E.preventDefault(),u(N=>!N);return}if((E.ctrlKey||E.metaKey)&&!E.shiftKey&&!E.altKey&&E.key.toLowerCase()==="h"){E.preventDefault();const N=aS(window.location.pathname);l(N?`/help?s=${N}`:"/help");return}!E.target.closest("input, textarea, [contenteditable], .cm-editor")&&E.key==="?"&&d(!0)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const m=i===void 0?"checking model":i?"model ready":"model off";return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsxs("aside",{className:"flex w-12 shrink-0 flex-col items-stretch overflow-y-auto bg-rail",children:[a.jsx(Sh,{to:"/",className:"grid h-12 place-items-center",title:"cognitune: projects","aria-label":"cognitune: projects",children:a.jsx(m0,{className:"h-6 w-6"})}),e?a.jsxs(a.Fragment,{children:[a.jsx(wn,{to:`/p/${e}/today`,icon:a.jsx(w2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Today"}),a.jsx(wn,{to:`/p/${e}/explore`,icon:a.jsx(_a,{className:"h-6 w-6",strokeWidth:1.5}),label:"Explore"}),a.jsx(wn,{to:`/p/${e}/changes`,icon:a.jsx(U1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Changes"}),a.jsx(wn,{to:`/p/${e}/review`,icon:a.jsx(Fr,{className:"h-6 w-6",strokeWidth:1.5}),label:"Review",badge:(x=h.data)==null?void 0:x.length}),a.jsx(wn,{to:`/p/${e}/map`,icon:a.jsx(W1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Map"}),a.jsx(wn,{to:`/p/${e}/paths`,icon:a.jsx(lp,{className:"h-6 w-6",strokeWidth:1.5}),label:"Paths"}),a.jsx(wn,{to:`/p/${e}/library`,icon:a.jsx(Zf,{className:"h-6 w-6",strokeWidth:1.5}),label:"Library"}),a.jsx(wn,{to:`/p/${e}/progress`,icon:a.jsx(z1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Progress"})]}):a.jsx(wn,{to:"/",end:!0,icon:a.jsx(c2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Projects"}),a.jsx("div",{className:"flex-1"}),e&&a.jsx(wn,{to:"/",end:!0,icon:a.jsx($1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Projects"}),a.jsx(wn,{to:"/help",icon:a.jsx(F1,{className:"h-6 w-6",strokeWidth:1.5}),label:"Help"}),a.jsx(wn,{to:"/settings",icon:a.jsx(g2,{className:"h-6 w-6",strokeWidth:1.5}),label:"Settings"})]}),a.jsx("main",{className:"min-w-0 flex-1",children:a.jsx(c0,{})})]}),a.jsxs("footer",{className:"flex h-[22px] shrink-0 items-center gap-1 border-t border-line bg-status px-2 text-[12px] text-muted",children:[f&&a.jsx("span",{className:"px-1.5",title:f,children:f.split("/").filter(Boolean).pop()}),a.jsxs(Sh,{to:"/settings",title:((v=r.data)==null?void 0:v.agent.detail)??"checking the model",className:"flex items-center gap-1.5 px-1.5 hover:bg-raised",children:[a.jsx("span",{className:le("h-2 w-2 rounded-full",i===void 0?"bg-line":i?"bg-good":"bg-bad")}),m]}),e&&a.jsx(xS,{pid:e}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>u(!0),title:"Go to or do (Ctrl/Cmd+K). Press ? for all shortcuts.",className:"flex items-center gap-1 px-1.5 hover:bg-raised",children:[a.jsx(e2,{className:"h-3 w-3"})," Ctrl K"]}),a.jsxs("button",{onClick:()=>n(gS[t]),title:`Theme: ${t} (click to change)`,className:"flex items-center gap-1 px-1.5 hover:bg-raised",children:[a.jsx(s,{className:"h-3 w-3"})," ",a.jsx("span",{className:"capitalize",children:t})]})]}),o&&a.jsx(fS,{pid:e,root:f,onClose:()=>u(!1),openFile:j=>{try{sessionStorage.setItem(`gl.open.${e}`,JSON.stringify(j))}catch{}l(`/p/${e}/explore`),window.dispatchEvent(new CustomEvent("cognitune:open",{detail:j}))}}),c&&a.jsx(mS,{onClose:()=>d(!1)})]})}const g0=b.createContext(null);function Rg(e,t){try{const n=sessionStorage.getItem(e);return n?JSON.parse(n):t}catch{return t}}function zg(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function vS({pid:e,children:t,fallback:n}){const r=ye({queryKey:["project",e],queryFn:()=>me(`/projects/${e}`)}),[i,s]=b.useState(()=>Rg(`gl.sel.${e}`,[])),[l,o]=b.useState(()=>Rg(`gl.open.${e}`,null)),[u,c]=b.useState(null);b.useEffect(()=>zg(`gl.sel.${e}`,i),[e,i]),b.useEffect(()=>{const m=g=>{o(g.detail),c(null)};return window.addEventListener("cognitune:open",m),()=>window.removeEventListener("cognitune:open",m)},[]),b.useEffect(()=>zg(`gl.open.${e}`,l),[e,l]);const d=b.useCallback(m=>s([...new Set(m)]),[]),h=b.useCallback((m,g)=>{s(k=>{const y=k.includes(m);return g??!y?y?k:[...k,m]:k.filter(v=>v!==m)})},[]),p=b.useCallback((m,g)=>{o(m),c(g??null)},[]),f=b.useMemo(()=>{const m=r.data;return m?{project:m,selected:i,toggle:h,setSelected:d,openFile:l,setOpenFile:p,focusLine:u,rel:k=>{if(k.startsWith(m.root+"/"))return k.slice(m.root.length+1);for(const y of m.contexts)if(k.startsWith(y+"/"))return`${y.split("/").pop()}/${k.slice(y.length+1)}`;return k}}:null},[r.data,i,h,d,l,p,u]);return r.error?a.jsx(a.Fragment,{children:n}):f?a.jsx(g0.Provider,{value:f,children:t}):null}function it(){const e=b.useContext(g0);if(!e)throw new Error("useProject outside ProjectProvider");return e}function pp({title:e,start:t,onPick:n,onClose:r,cta:i="Open this folder"}){var h,p;const[s,l]=b.useState(t??""),[o,u]=b.useState(t??""),c=ye({queryKey:["browse",s],queryFn:()=>me(`/browse?path=${encodeURIComponent(s)}`)}),d=((h=c.data)==null?void 0:h.path)??s;return a.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4 backdrop-blur-sm",onClick:r,children:a.jsxs("div",{className:"card flex max-h-[80vh] w-full max-w-xl flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[a.jsx("h2",{className:"text-sm font-semibold",children:e}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:r,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsxs("form",{className:"flex gap-2 border-b border-line p-3",onSubmit:f=>{f.preventDefault(),l(o)},children:[a.jsx("input",{className:"input font-mono text-xs",value:o,onChange:f=>u(f.target.value),placeholder:"/path/to/folder"}),a.jsx(ee,{type:"submit",children:"Go"})]}),a.jsxs("div",{className:"min-h-[240px] flex-1 overflow-auto p-2",children:[c.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),c.error&&a.jsx("div",{className:"p-2",children:a.jsx(Ke,{error:c.error.message})}),c.data&&a.jsxs(a.Fragment,{children:[c.data.parent&&a.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-muted hover:bg-raised",onClick:()=>{l(c.data.parent),u(c.data.parent)},children:[a.jsx(R1,{className:"h-4 w-4"})," .."]}),c.data.dirs.map(f=>{const m=`${c.data.path.replace(/\/$/,"")}/${f}`;return a.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm hover:bg-raised",onDoubleClick:()=>n(m),onClick:()=>{l(m),u(m)},children:[a.jsx(np,{className:"h-4 w-4 text-accent/80"})," ",f]},f)}),!c.data.dirs.length&&a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted",children:"No sub-folders."})]})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-line px-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted",title:d,children:[((p=c.data)==null?void 0:p.isGit)&&a.jsx(rp,{className:"mr-1 inline h-3.5 w-3.5 text-good"}),d]}),a.jsx(ee,{variant:"ghost",onClick:r,children:"Cancel"}),a.jsx(ee,{variant:"primary",disabled:!c.data,onClick:()=>n(d),children:i})]})]})})}const wS=[{icon:_a,title:"Lenses",text:"See code through one question: data flow, state, failure modes, contracts."},{icon:$a,title:"Quizzes",text:"Questions about behaviour, not names. Graded with feedback that names the line."},{icon:Ku,title:"Practice",text:"Key logic cut out of your own code. Write it back, with hints when stuck."},{icon:Zf,title:"Progress",text:"What you understand, per file. A pass goes stale when the code changes."}];function kS(){var u;const e=gt(),t=Dt(),[n,r]=b.useState(!1),i=ye({queryKey:["projects"],queryFn:()=>me("/projects")}),s=vi({mutationFn:c=>Ci("/projects",{root:c}),onSuccess:c=>{t.invalidateQueries({queryKey:["projects"]}),e(`/p/${c.id}/today`)}}),l=vi({mutationFn:c=>cs(`/projects/${c}`),onSuccess:()=>t.invalidateQueries({queryKey:["projects"]})}),o=i.data??[];return a.jsxs("div",{className:"h-full overflow-auto",children:[a.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-12",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(m0,{className:"h-11 w-11"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"cognitune"}),a.jsx("p",{className:"text-sm text-muted",children:"Understand any codebase. Prove it to yourself."})]})]}),a.jsx("div",{className:"mt-10 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:wS.map(({icon:c,title:d,text:h})=>a.jsxs("div",{className:"card p-4",children:[a.jsx("div",{className:"mb-3 grid h-9 w-9 place-items-center rounded-lg bg-accent/10 text-accent",children:a.jsx(c,{className:"h-[18px] w-[18px]"})}),a.jsx("div",{className:"text-sm font-semibold",children:d}),a.jsx("p",{className:"mt-1 text-[14px] leading-snug text-muted",children:h})]},d))}),a.jsxs("div",{className:"mt-12 flex items-end justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Projects"}),a.jsx("p",{className:"text-sm text-muted",children:"A project is a folder of code. Nothing in it is written."})]}),a.jsx(ee,{variant:"primary",size:"lg",icon:a.jsx(q1,{className:"h-4 w-4"}),onClick:()=>r(!0),children:"Open a folder"})]}),s.error&&a.jsx("div",{className:"mt-4",children:a.jsx(Ke,{error:s.error.message})}),a.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-2",children:[o.map(c=>a.jsxs("div",{role:"button",tabIndex:0,onClick:()=>s.mutate(c.root),onKeyDown:d=>d.key==="Enter"&&s.mutate(c.root),className:"card group flex cursor-pointer items-center gap-4 p-4 transition hover:-translate-y-0.5 hover:border-accent/40",children:[a.jsx("div",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-md bg-gradient-to-br from-accent/20 to-fuchsia-500/20 text-sm font-bold uppercase text-accent",children:c.name.slice(0,2)}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate font-medium",children:c.name}),a.jsx("div",{className:"truncate font-mono text-xs text-muted",title:c.root,children:c.root}),a.jsxs("div",{className:"mt-1 text-[12px] text-muted",children:["opened ",Tt(c.openedAt),c.contexts.length>0&&` · ${c.contexts.length} context folder${c.contexts.length>1?"s":""}`]})]}),a.jsx("button",{className:"rounded-md p-1.5 text-muted opacity-0 transition hover:bg-raised hover:text-bad group-hover:opacity-100",title:"Remove from the list (your lenses and quizzes stay on disk)",onClick:d=>{d.stopPropagation(),l.mutate(c.id)},children:a.jsx(pr,{className:"h-4 w-4"})}),a.jsx(Hu,{className:"h-4 w-4 text-muted transition group-hover:translate-x-0.5 group-hover:text-accent"})]},c.id)),!i.isLoading&&!o.length&&a.jsxs("div",{className:"card col-span-full border-dashed p-10 text-center text-sm text-muted",children:["No projects yet. Open a folder, or start from a terminal: ",a.jsx("span",{className:"kbd",children:"npx cognitune ./my-repo"})]})]})]}),n&&a.jsx(pp,{title:"Open a folder",start:((u=o[0])==null?void 0:u.root.split("/").slice(0,-1).join("/"))||void 0,onClose:()=>r(!1),onPick:c=>{r(!1),s.mutate(c)}})]})}function fr(e,t=36){if(e.length<=t)return e;const n=e.split("/"),r=n.pop()??"";return[...n.map(s=>s===""?"":s.startsWith(".")?s.slice(0,2):s[0]),r].join("/")}const bS={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"csharp",c:"c",h:"c",cpp:"cpp",hpp:"cpp",swift:"swift",scala:"scala",sh:"bash",zsh:"bash",bash:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",md:"markdown",html:"html",css:"css",scss:"scss",vue:"vue",svelte:"svelte",tf:"hcl",hcl:"hcl",xml:"xml",ini:"ini",lua:"lua",r:"r",dart:"dart",ex:"elixir",exs:"elixir"};function x0(e){const t=(e.split("/").pop()??"").toLowerCase();if(t==="dockerfile")return"docker";if(t==="makefile")return"make";const n=t.includes(".")?t.slice(t.lastIndexOf(".")+1):"";return bS[n]??"text"}const jS=/\.(ts|tsx|js|jsx|mjs|py|go|rs|java|kt|rb|php|cs|c|h|cpp|swift|scala|sh|sql|vue|svelte|lua|dart|ex)$/i,NS=/\.(md|txt|rst|json|ya?ml|toml|ini|cfg)$/i;function y0(e){return e.kind==="file"?[e.path]:(e.children??[]).flatMap(y0)}function v0(e,t){if(!t)return e;const n=t.toLowerCase(),r=[];for(const i of e)if(i.kind==="file")i.path.toLowerCase().includes(n)&&r.push(i);else{const s=v0(i.children??[],t);s.length&&r.push({...i,children:s})}return r}const SS={new:"",seen:"bg-muted/50",understood:"bg-good",fading:"bg-warn/50",stale:"bg-warn"};function mp({roots:e,selected:t,onToggle:n,openFile:r,onOpen:i,levels:s,meta:l,openAll:o=!1}){const[u,c]=b.useState(""),[d,h]=b.useState(()=>o?new Set:new Set(e.map(g=>g.path))),p=b.useMemo(()=>new Set(t),[t]),f=b.useMemo(()=>v0(e,u.trim()),[e,u]),m=(g,k)=>{var M;const y=u?!0:o?!d.has(g.path):d.has(g.path),x=g.kind==="dir"?y0(g):[g.path],v=x.filter(F=>p.has(F)).length,j=v>0&&v===x.length,E=v>0&&!j,w=s==null?void 0:s.get(g.path),N=g.kind==="dir"?y?q1:np:jS.test(g.name)?os:NS.test(g.name)?s2:_1;return a.jsxs("div",{children:[a.jsxs("div",{className:le("group flex h-[22px] cursor-pointer items-center gap-1 pr-2 text-[13px]",r===g.path?"bg-sel text-ink dark:text-white":"hover:bg-raised"),style:{paddingLeft:k*12+8},onClick:()=>{g.kind==="dir"?h(F=>{const C=new Set(F);return C.has(g.path)?C.delete(g.path):C.add(g.path),C}):i(g.path)},children:[a.jsx(Tr,{className:le("h-3.5 w-3.5 shrink-0 text-muted transition",g.kind==="file"&&"invisible",y&&"rotate-90")}),a.jsx("input",{type:"checkbox",className:"h-3.5 w-3.5 shrink-0 cursor-pointer accent-[rgb(var(--accent))]",checked:j,ref:F=>{F&&(F.indeterminate=E)},onClick:F=>F.stopPropagation(),onChange:()=>n(x,!j),title:g.kind==="dir"?`Tick all ${x.length} files`:"Use as context"}),a.jsx(N,{className:le("h-4 w-4 shrink-0","text-muted")}),a.jsx("span",{className:"truncate",children:g.name}),w&&w!=="new"&&a.jsx("span",{title:w,className:le("ml-auto h-1.5 w-1.5 shrink-0 rounded-full",SS[w])}),l&&g.kind==="file"&&a.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:l(g.path)})]}),g.kind==="dir"&&y&&((M=g.children)==null?void 0:M.map(F=>m(F,k+1)))]},g.path)};return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx("div",{className:"px-2 py-1.5",children:a.jsxs("div",{className:"relative",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2 top-[6px] h-3.5 w-3.5 text-muted"}),a.jsx("input",{className:"input h-[26px] pl-7 text-[13px]",placeholder:"Filter files",value:u,onChange:g=>c(g.target.value)})]})}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto pb-4",children:f.map(g=>m(g,0))})]})}function CS({current:e,onApply:t,onClose:n}){const{project:r}=it(),i=Dt(),[s,l]=b.useState(e),[o,u]=b.useState(null),[c,d]=b.useState(!1),h=ye({queryKey:["tree",r.id,r.contexts],queryFn:()=>me(`/projects/${r.id}/tree`)}),p=vi({mutationFn:f=>Ua(`/projects/${r.id}`,{contexts:[...r.contexts,f]}),onSuccess:()=>i.invalidateQueries()});return a.jsxs("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/40 p-4 backdrop-blur-sm",onClick:n,children:[a.jsxs("div",{className:"card flex h-[80vh] w-full max-w-xl flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[a.jsx("h2",{className:"text-sm font-semibold",children:"Add context"}),a.jsxs("span",{className:"text-xs text-muted",children:[s.length," ticked"]}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:n,"aria-label":"Close",children:a.jsx(Rn,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2 text-xs text-muted",children:[a.jsx("span",{className:"flex-1",children:"Tick files from the project or its context folders. The model reads them next to the change."}),a.jsx(ee,{size:"sm",icon:a.jsx(B1,{className:"h-3.5 w-3.5"}),onClick:()=>d(!0),children:"Add a folder"})]}),p.error&&a.jsx("div",{className:"p-2",children:a.jsx(Ke,{error:p.error.message})}),a.jsxs("div",{className:"min-h-0 flex-1",children:[h.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),h.data&&a.jsx(mp,{roots:h.data,selected:s,onToggle:(f,m)=>l(m?[...new Set([...s,...f])]:s.filter(g=>!f.includes(g))),openFile:o,onOpen:f=>{u(f),l(s.includes(f)?s.filter(m=>m!==f):[...s,f])}})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t border-line px-4 py-3",children:[a.jsx(ee,{variant:"ghost",onClick:n,children:"Cancel"}),a.jsxs(ee,{variant:"primary",onClick:()=>{t(s),n()},children:["Use ",s.length," file",s.length===1?"":"s"]})]})]}),c&&a.jsx("div",{onClick:f=>f.stopPropagation(),children:a.jsx(pp,{title:"Add a context folder",cta:"Add as context",start:r.root.split("/").slice(0,-1).join("/"),onClose:()=>d(!1),onPick:f=>{d(!1),p.mutate(f)}})})]})}const Wc=5,Vc=[{id:"lens",label:"Lens",icon:_a,hint:"Read an explanation through one question"},{id:"quiz",label:"Quiz",icon:$a,hint:"Answer questions in your own words"},{id:"teach",label:"Teach",icon:Qu,hint:"Explain it yourself; get graded"},{id:"tutor",label:"Tutor",icon:Gu,hint:"Ask; get questions and hints back"},{id:"walk",label:"Walk",icon:Vu,hint:"One block at a time, with a check each"},{id:"practice",label:"Practice",icon:Ku,hint:"Write the key lines back"},{id:"hunt",label:"Bug hunt",icon:Wu,hint:"Find the bugs planted in a copy"},{id:"notes",label:"Notes",icon:G1,hint:"Your notes on this file"}],ES=["walk","hunt","notes"],Ag=[{value:1,label:"1",title:"One short hole"},{value:2,label:"2",title:"A condition and a computation"},{value:3,label:"3",title:"Core logic"},{value:4,label:"4",title:"Whole function bodies"}],Ig=[{value:1,label:"Easy",title:"One bug, fairly visible"},{value:2,label:"Medium",title:"Two bugs, one needs the logic"},{value:3,label:"Hard",title:"Two or three subtle bugs"}];function w0({files:e,diff:t,practiceFile:n,onRemove:r,onSetFiles:i}){var Xn,Jn,yr;const{project:s,rel:l,toggle:o,setSelected:u,focusLine:c}=it(),d=r??(Z=>o(Z,!1)),h=i??u,[p,f]=ec(),[m,g]=b.useState(!1),[k,y]=b.useState(!1),x=gt(),[v,j]=b.useState(()=>Vc.some(Z=>Z.id===p.get("do"))?p.get("do"):"lens"),[E,w]=b.useState(t?"change":"explain"),[N,M]=b.useState(""),[F,C]=b.useState(!1),[O,A]=b.useState(""),[V,U]=b.useState(""),[q,G]=b.useState("standard"),[X,z]=b.useState(null),[W,S]=b.useState(2),[D,te]=b.useState(""),[P,ve]=b.useState(1),[Le,we]=b.useState(""),Se=mn(),_t=ye({queryKey:["lens-kinds"],queryFn:()=>me("/lens-kinds"),staleTime:1/0}),an=ye({queryKey:["misconceptions",s.id],queryFn:()=>me(`/projects/${s.id}/misconceptions`)});b.useEffect(()=>{if(!p.get("do"))return;const Z=new URLSearchParams(p);Z.delete("do"),f(Z,{replace:!0})},[]);const Lt=`/projects/${s.id}`,qe=`/p/${s.id}`,lt=e.length===0,zn=ES.includes(v),An=ye({queryKey:["estimate",s.id,e],queryFn:()=>Ci(`${Lt}/estimate`,{files:e}),enabled:!lt&&!zn,staleTime:3e4}),Vt=()=>Se.run(`${Lt}/lenses`,{files:e,kind:N.trim()?"custom":E,question:N.trim()||void 0,diff:t,sketch:F&&O.trim()||void 0,traceInput:E==="trace"?V:void 0,depth:q},Z=>x(`${qe}/lens/${Z.resultId}`)),Gn=(Z=!1)=>Se.run(`${Lt}/quizzes`,Z?{files:[],weak:!0}:{files:e,diff:t,count:X??void 0},Qt=>x(`${qe}/quiz/${Qt.resultId}`)),on=(Z,Qt,vr)=>Se.run(`${Lt}/${Z}`,Qt,Zn=>x(`${qe}/${vr}/${Zn.resultId}`)),Yn=Vc.find(Z=>Z.id===v),xr=((Xn=an.data)==null?void 0:Xn.length)??0;return a.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1 border-b border-line p-2",children:Vc.map(Z=>a.jsxs("button",{onClick:()=>j(Z.id),title:Z.hint,className:le("flex flex-col items-center gap-0.5 rounded-lg px-1 py-1.5 text-[12px] font-medium transition",v===Z.id?"bg-accent/12 text-accent":"text-muted hover:bg-raised hover:text-ink"),children:[a.jsx(Z.icon,{className:"h-4 w-4"}),Z.label]},Z.id))}),a.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-4",children:[a.jsxs("p",{className:"-mb-1 text-xs text-muted",children:[Yn.hint,"."]}),!zn&&a.jsxs("section",{children:[a.jsxs("div",{className:"label flex items-center gap-1",children:[a.jsxs("span",{children:["Context · ",e.length]}),t&&a.jsxs("span",{className:"truncate normal-case tracking-normal",children:["· change ",t.base,"..",t.head||"working tree"]}),a.jsxs("button",{className:"ml-auto inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 normal-case tracking-normal text-accent hover:bg-accent/10",onClick:()=>g(!0),title:"Add files from the project or a context folder (docs, notes, a session)",children:[a.jsx(Q1,{className:"h-3 w-3"})," Add"]})]}),lt?a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"Tick files in the tree, open one, or use Add. The model reads only what you pick."}):a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[(k?e:e.slice(0,Wc)).map(Z=>a.jsxs("span",{className:"group inline-flex max-w-full items-center gap-1 rounded-md bg-raised px-2 py-1 font-mono text-[12px]",title:Z,children:[a.jsx("span",{className:"truncate",children:fr(l(Z))}),a.jsx("button",{className:"text-muted hover:text-bad",onClick:()=>d(Z),"aria-label":"Remove",children:a.jsx(Rn,{className:"h-3 w-3"})})]},Z)),e.length>Wc&&a.jsx("button",{className:"rounded-md px-2 py-1 text-[12px] font-medium text-accent hover:bg-accent/10",onClick:()=>y(Z=>!Z),children:k?"show less":`+${e.length-Wc} more`})]}),An.data&&a.jsxs("div",{className:le("mt-1.5 text-[12px]",An.data.cut?"text-warn":"text-muted"),children:["~",An.data.tokens.toLocaleString()," tokens",An.data.cut&&" · some files do not fit and will be left out"]})]}),zn&&a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"File"}),n?a.jsx("div",{className:"truncate rounded-md bg-raised px-2 py-1.5 font-mono text-xs",title:n,children:l(n)}):a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"Open a file first."})]}),v==="lens"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Pick a lens"}),a.jsx("div",{className:"grid grid-cols-1 gap-1.5",children:(_t.data??[]).map(Z=>a.jsxs("button",{onClick:()=>{w(Z.id),M("")},className:le("rounded-lg border px-3 py-2 text-left transition",E===Z.id&&!N.trim()?"border-accent/60 bg-accent/8 ring-1 ring-accent/30":"border-line hover:border-accent/30 hover:bg-raised"),children:[a.jsx("div",{className:"text-[14px] font-medium",children:Z.label}),a.jsx("div",{className:"text-xs text-muted",children:Z.blurb})]},Z.id))})]}),E==="trace"&&!N.trim()&&a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Input to trace"}),a.jsx("input",{className:"input",placeholder:"e.g. add(3) (empty = the model picks one)",value:V,onChange:Z=>U(Z.target.value)})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Depth"}),a.jsx(Zt,{value:q,onChange:G,options:[{value:"overview",label:"Overview",title:"About 1.5 screens: the big picture, 3-4 steps"},{value:"standard",label:"Standard",title:"At least 3 screens: enough to change it safely, 6-9 steps"},{value:"deep",label:"Deep",title:"5-6 screens, a long blog post: every branch and failure path, 11-15 steps"}]})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Or ask your own question"}),a.jsx("textarea",{className:"input min-h-[64px] resize-y",placeholder:"e.g. Why is the retry here and not in the caller?",value:N,onChange:Z=>M(Z.target.value)})]}),a.jsxs("section",{className:"rounded-lg border border-line p-3",children:[a.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[14px] font-medium",children:[a.jsx("input",{type:"checkbox",className:"accent-[rgb(var(--accent))]",checked:F,onChange:Z=>C(Z.target.checked)}),a.jsx(V1,{className:"h-3.5 w-3.5 text-accent"}),t?"Predict first":"My take first"]}),F&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-2 min-h-[72px] resize-y",placeholder:t?"What behaviour changes, and what test or caller would break?":"In 2-3 lines: what does it do, and how? Where is the risk?",value:O,onChange:Z=>A(Z.target.value)}),a.jsx("p",{className:"mt-1 text-[12px] text-muted",children:"The lens opens with where your take differs. That gap is where the learning is."})]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(ap,{className:"h-4 w-4"}),disabled:lt||Se.busy||F&&!O.trim(),onClick:Vt,children:"Make the lens"})]}),v==="quiz"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Questions"}),a.jsx(Zt,{value:X??0,onChange:Z=>z(Z===0?null:Z),options:[{value:0,label:"Default"},{value:3,label:"3"},{value:5,label:"5"},{value:8,label:"8"}]}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"Free-text answers. Questions ask about behaviour and reasons, not names. Mark each answer sure or guess."})]}),a.jsxs(ee,{variant:"primary",className:"w-full",icon:a.jsx($a,{className:"h-4 w-4"}),disabled:lt||Se.busy,onClick:()=>Gn(),children:["Quiz me on ",e.length||""," file",e.length===1?"":"s"]}),a.jsxs("div",{className:"rounded-lg border border-line p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[14px] font-medium",children:[a.jsx(Ji,{className:"h-3.5 w-3.5 text-bad"})," Weak spots · ",xr]}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"New questions aimed at what you got wrong before, from any file. A right answer clears the weak spot."}),a.jsx(ee,{className:"mt-2 w-full",size:"sm",disabled:!xr||Se.busy,onClick:()=>Gn(!0),children:"Quiz my weak spots"})]})]}),v==="teach"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Explain it to a new teammate"}),a.jsx("textarea",{className:"input min-h-[180px] resize-y",placeholder:"What does this code do, how, and why this way? What would surprise someone? Write it before you look anything up.",value:Le,onChange:Z=>we(Z.target.value)}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"Graded 1-5 against the code: what you got right, what you missed, what is wrong. 4+ counts as understood."})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Qu,{className:"h-4 w-4"}),disabled:lt||Se.busy||Le.trim().length<20,onClick:()=>on("teachbacks",{files:e,text:Le,diff:t},"teach"),children:"Grade my explanation"})]}),v==="tutor"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Your question"}),a.jsx("textarea",{className:"input min-h-[100px] resize-y",placeholder:"e.g. Why does this return early here?",value:Le,onChange:Z=>we(Z.target.value)}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"The tutor answers with a question or a hint first, and gives more each turn. Ask it to just tell you any time."})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Gu,{className:"h-4 w-4"}),disabled:lt||Se.busy||!Le.trim(),onClick:()=>on("threads",{files:e,text:Le,diff:t},"tutor"),children:"Ask the tutor"})]}),v==="walk"&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-xs text-muted",children:"The file in reading order, one block at a time. Answer a short check on each block before the next."}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Vu,{className:"h-4 w-4"}),disabled:!n||Se.busy,onClick:()=>on("walks",{file:n},"walk"),children:"Walk me through it"})]}),v==="practice"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsxs("div",{className:"label",children:["Concept to practise ",a.jsx("span",{className:"normal-case tracking-normal",children:"(optional)"})]}),a.jsx("input",{className:"input",placeholder:"e.g. retry with backoff, how a run resumes",value:D,onChange:Z=>te(Z.target.value)}),a.jsx("p",{className:"mt-1.5 text-xs text-muted",children:"Leave it empty and the model picks the main idea of the files above. Holes can land in any of them."})]}),a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Difficulty"}),a.jsx(Zt,{value:W,onChange:S,options:Ag.map(Z=>({...Z}))}),a.jsxs("p",{className:"mt-2 text-xs text-muted",children:[(Jn=Ag.find(Z=>Z.value===W))==null?void 0:Jn.title,". The key lines are cut out of a copy; you write them back here, with hints if you need them. Your folder is not touched."]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Ku,{className:"h-4 w-4"}),disabled:lt||Se.busy,onClick:()=>on("practice",{files:e,level:W,concept:D.trim()||void 0},"practice"),children:"Make the practice"})]}),v==="hunt"&&a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsx("div",{className:"label",children:"Difficulty"}),a.jsx(Zt,{value:P,onChange:ve,options:Ig.map(Z=>({...Z}))}),a.jsxs("p",{className:"mt-2 text-xs text-muted",children:[(yr=Ig.find(Z=>Z.value===P))==null?void 0:yr.title,". Bugs go into a copy of the file. Click the lines you think are wrong and say why."]})]}),a.jsx(ee,{variant:"primary",className:"w-full",icon:a.jsx(Wu,{className:"h-4 w-4"}),disabled:!n||Se.busy,onClick:()=>on("hunts",{file:n,level:P},"hunt"),children:"Start the hunt"})]}),v==="notes"&&n&&a.jsx(PS,{file:n,line:c}),Se.busy&&Se.job&&a.jsx(sn,{kind:Se.job.kind,elapsed:Se.elapsed}),Se.error&&a.jsx(Ke,{error:Se.error,onClose:Se.clearError})]}),m&&a.jsx(CS,{current:e,onApply:h,onClose:()=>g(!1)})]})}function PS({file:e,line:t}){const{project:n,setOpenFile:r}=it(),i=Dt(),[s,l]=b.useState(""),o=ye({queryKey:["notes",n.id,e],queryFn:()=>me(`/projects/${n.id}/notes?file=${encodeURIComponent(e)}`)}),u=async()=>{await Ci(`/projects/${n.id}/notes`,{file:e,line:t??void 0,text:s}),l(""),i.invalidateQueries({queryKey:["notes",n.id]})},c=[...o.data??[]].sort((d,h)=>(d.line??0)-(h.line??0));return a.jsxs(a.Fragment,{children:[a.jsxs("section",{children:[a.jsxs("div",{className:"label",children:["New note ",t?`on line ${t}`:"on the file"]}),a.jsx("textarea",{className:"input min-h-[72px] resize-y",placeholder:"Click a line in the code to pin the note there.",value:s,onChange:d=>l(d.target.value)}),a.jsx(ee,{className:"mt-2 w-full",size:"sm",disabled:!s.trim(),onClick:u,children:"Add note"})]}),a.jsxs("section",{className:"space-y-2",children:[c.map(d=>a.jsxs("div",{className:"group rounded-lg border border-line p-2.5 text-[14px]",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[d.line?a.jsxs("button",{className:"font-mono text-[12px] text-accent hover:underline",onClick:()=>r(e,d.line),children:["line ",d.line]}):a.jsx("span",{className:"text-[12px] text-muted",children:"file"}),a.jsx("button",{className:"ml-auto text-muted opacity-0 transition hover:text-bad group-hover:opacity-100",onClick:async()=>{await cs(`/projects/${n.id}/notes/${d.id}`),i.invalidateQueries({queryKey:["notes",n.id]})},"aria-label":"Delete note",children:a.jsx(pr,{className:"h-3.5 w-3.5"})})]}),a.jsx("div",{className:"mt-1 whitespace-pre-wrap",children:d.text})]},d.id)),!c.length&&a.jsx("p",{className:"text-xs text-muted",children:"No notes on this file yet."})]})]})}function Ha({initial:e,onClose:t}){const{project:n,rel:r}=it(),i=Dt(),[s,l]=b.useState(e.front??""),[o,u]=b.useState(e.back??""),[c,d]=b.useState(null),[h,p]=b.useState(!1),f=async()=>{p(!0);try{await Ci(`/projects/${n.id}/cards`,{...e,front:s,back:o}),await i.invalidateQueries(),t()}catch(m){d(m.message),p(!1)}};return a.jsxs(tc,{title:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Fr,{className:"h-4 w-4 text-accent"})," New review card"]}),onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ee,{variant:"ghost",onClick:t,children:"Cancel"}),a.jsx(ee,{variant:"primary",loading:h,disabled:!s.trim()||!o.trim(),onClick:f,children:"Save card"})]}),children:[e.file&&a.jsxs("div",{className:"mb-3 font-mono text-[12px] text-muted",children:[r(e.file),e.line?`:${e.line}`:""]}),a.jsx("label",{className:"label",children:"Question (front)"}),a.jsx("textarea",{className:"input min-h-[72px]",value:s,onChange:m=>l(m.target.value),placeholder:"What should you be able to recall?",autoFocus:!0}),a.jsx("label",{className:"label mt-3",children:"Answer (back)"}),a.jsx("textarea",{className:"input min-h-[96px]",value:o,onChange:m=>u(m.target.value),placeholder:"The answer, in your own words"}),a.jsx("p",{className:"mt-2 text-xs text-muted",children:"The card comes back on the Review page: soon at first, then less often as you remember it."}),c&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:c})})]})}const TS=4e3;let LS=null;const MS=()=>LS??(LS=ml(()=>import("./index-6_jiQxLN.js"),[])),RS={docker:"dockerfile",make:"makefile",text:"text"};function zS(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qc(e,t){return`<pre><code>${e.split(`
469
469
  `).map((n,r)=>`<span class="line ${t(r+1)}" data-line="${r+1}">${zS(n)}</span>`).join(`
470
470
  `)}</code></pre>`}function Wa({text:e,lang:t,focusLine:n,marks:r,className:i,onLineClick:s,firstLine:l=1}){const[o,u]=b.useState(""),c=b.useRef(null),d=b.useRef(null);return b.useEffect(()=>{let h=!0;const p=m=>{const g=m+l-1,k=(r??[]).filter(y=>g>=y.from&&g<=y.to).map(y=>y.cls);return le(k,g===n&&"hl")};if(e.split(`
471
- `).length>TS||t==="text"){u(Qc(e,p));return}return u(m=>m||Qc(e,p)),MS().then(async m=>{const g=RS[t]??t,k=await m.codeToHtml(e,{lang:g in m.bundledLanguages?g:"text",themes:{light:"solarized-light",dark:"dark-plus"},defaultColor:!1,transformers:[{line(y,x){y.properties["data-line"]=x;const v=p(x);v&&this.addClassToHast(y,v)}}]});h&&u(k)}).catch(()=>h&&u(Qc(e,p))),()=>{h=!1}},[e,t,n,r,l]),b.useEffect(()=>{if(!n||!c.current||d.current===n)return;const h=c.current.querySelector(`[data-line="${n-l+1}"]`);h==null||h.scrollIntoView({block:"center",behavior:"smooth"})},[o,n]),a.jsx("div",{ref:c,className:le("code-view font-mono",s&&"clickable",i),style:l>1?{"--line-start":l-1}:void 0,onClick:h=>{var f,m;if((f=window.getSelection())!=null&&f.toString())return;const p=(m=h.target.closest("[data-line]"))==null?void 0:m.dataset.line;if(p&&s){const g=Number(p)+l-1;d.current=g,s(g)}},dangerouslySetInnerHTML:{__html:o}})}function Fg(e,t,n){try{const r=localStorage.getItem(e);return r===null?t:n(r)}catch{return t}}function Dg(e,t){try{localStorage.setItem(e,t)}catch{}}function Kn({id:e,left:t,right:n,initial:r=280,min:i=180,max:s=640,side:l="left",className:o,collapsible:u=!1,startCollapsed:c=!1,openSignal:d}){const h=`cognitune.split.${e}`,[p,f]=b.useState(()=>Fg(h,r,Number)||r),[m,g]=b.useState(()=>u&&Fg(`${h}.collapsed`,c,U=>U==="1")),k=b.useRef(!0);b.useEffect(()=>{if(k.current){k.current=!1;return}d!=null&&g(!1)},[d]);const[y,x]=b.useState(!1),v=b.useRef(null),j=b.useRef();b.useEffect(()=>Dg(h,String(p)),[h,p]),b.useEffect(()=>Dg(`${h}.collapsed`,m?"1":"0"),[h,m]),b.useEffect(()=>{const U=G=>{if(!v.current)return;const X=G.clientX-v.current.x;f(Math.min(s,Math.max(i,v.current.size+(l==="left"?X:-X))))},q=()=>{v.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",q),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",q)}},[i,s,l]);const E=()=>{clearTimeout(j.current),x(!0)},w=()=>{clearTimeout(j.current),j.current=setTimeout(()=>x(!1),250)};b.useEffect(()=>()=>clearTimeout(j.current),[]);const N=l==="left";b.useEffect(()=>{if(!u)return;const U=N?"[":"]",q=G=>{const X=G.target;G.key!==U||G.ctrlKey||G.metaKey||G.altKey||X.closest("input, textarea, select, [contenteditable=true], .cm-editor")||(g(z=>!z),x(!1))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[u,N]);const M=N?xu:Tr,F=N?Tr:xu,C=a.jsxs("div",{className:"group relative w-px shrink-0 cursor-col-resize bg-line",onPointerDown:U=>{U.target.closest("button")||(v.current={x:U.clientX,size:p},document.body.style.cursor="col-resize",document.body.style.userSelect="none")},onDoubleClick:()=>f(r),title:"Drag to resize, double-click to reset",children:[a.jsx("div",{className:"absolute inset-y-0 -left-1.5 -right-1.5 transition group-hover:bg-accent/30"}),u&&a.jsx("button",{onClick:()=>{g(!0),x(!1)},title:`Fold this pane away (key ${N?"[":"]"}); hover the edge to see it again`,className:"absolute top-1/2 z-20 -mt-5 grid h-10 w-5 -translate-x-1/2 place-items-center rounded-full border border-line bg-panel text-muted shadow-sm transition hover:border-accent/50 hover:text-accent",children:a.jsx(M,{className:"h-3 w-3"})})]}),O=a.jsx("div",{onMouseEnter:E,onMouseLeave:w,className:le("group flex w-3 shrink-0 cursor-pointer flex-col items-center justify-center bg-panel transition hover:bg-accent/10",N?"border-r border-line":"border-l border-line"),onClick:()=>{g(!1),x(!1)},title:`Hover to peek, click to pin open (key ${N?"[":"]"})`,children:a.jsx(F,{className:"h-3 w-3 text-muted group-hover:text-accent"})}),A=a.jsx("div",{style:{width:p},onMouseEnter:m?E:void 0,onMouseLeave:m?w:void 0,className:le("min-h-0 shrink-0 overflow-hidden",m&&!y&&"hidden",m&&y&&le("absolute inset-y-0 z-30 shadow-2xl ring-1 ring-line",N?"left-3":"right-3")),children:N?t:n}),V=a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:N?n:t});return a.jsx("div",{className:le("relative flex h-full min-h-0 min-w-0",o),children:N?a.jsxs(a.Fragment,{children:[m&&O,A,!m&&C,V]}):a.jsxs(a.Fragment,{children:[V,!m&&C,A,m&&O]})})}function AS(){var M;const{project:e,selected:t,setSelected:n,toggle:r,openFile:i,setOpenFile:s,focusLine:l,rel:o}=it(),u=Dt(),[c,d]=b.useState(!1),[h,p]=b.useState(!1),f=ye({queryKey:["notes",e.id,i],queryFn:()=>me(`/projects/${e.id}/notes?file=${encodeURIComponent(i)}`),enabled:!!i}),m=b.useMemo(()=>(f.data??[]).filter(F=>F.line).map(F=>({from:F.line,to:F.line,cls:"note"})),[f.data]),g=ye({queryKey:["tree",e.id,e.contexts],queryFn:()=>me(`/projects/${e.id}/tree`)}),k=ye({queryKey:["progress",e.id],queryFn:()=>me(`/projects/${e.id}/progress`)}),y=ye({queryKey:["file",e.id,i],queryFn:()=>me(`/projects/${e.id}/file?path=${encodeURIComponent(i)}`),enabled:!!i}),x=vi({mutationFn:F=>Ua(`/projects/${e.id}`,{contexts:F}),onSuccess:()=>u.invalidateQueries()}),v=b.useMemo(()=>new Map((k.data??[]).map(F=>[F.path,F.level])),[k.data]),j=t.length?t:i?[i]:[],E=i?t.includes(i):!1,w=a.jsxs("div",{className:"flex h-full flex-col bg-side",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-semibold",children:e.name}),a.jsx("div",{className:"truncate font-mono text-[12px] text-muted",title:e.root,children:fr(e.root,30)})]}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(B1,{className:"h-4 w-4"}),title:"Add a context folder (docs, notes, a session folder)",onClick:()=>d(!0)})]}),e.contexts.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 border-b border-line px-3 py-2",children:e.contexts.map(F=>a.jsxs(be,{tone:"accent",className:"max-w-full",children:[a.jsxs("span",{className:"truncate",title:F,children:["+ ",F.split("/").pop()]}),a.jsx("button",{onClick:()=>x.mutate(e.contexts.filter(C=>C!==F)),"aria-label":"Remove context folder",children:a.jsx(Rn,{className:"h-3 w-3"})})]},F))}),t.length>0&&a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-accent/5 px-3 py-1.5 text-xs",children:[a.jsxs("span",{className:"font-medium text-accent",children:[t.length," ticked"]}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:()=>n([]),children:"clear"})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[g.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),g.error&&a.jsx("div",{className:"p-3",children:a.jsx(Ke,{error:g.error.message})}),g.data&&a.jsx(mp,{roots:g.data,selected:t,onToggle:(F,C)=>n(C?[...t,...F]:t.filter(O=>!F.includes(O))),openFile:i,onOpen:F=>s(F),levels:v})]})]}),N=a.jsx("div",{className:"flex h-full flex-col",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-panel px-4 py-2",children:[a.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[14px]",children:o(i)}),y.data&&a.jsx(be,{children:y.data.lang}),v.get(i)&&v.get(i)!=="new"&&a.jsx(be,{tone:v.get(i)==="understood"?"good":v.get(i)==="stale"?"warn":"muted",children:v.get(i)}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(Fr,{className:"h-3.5 w-3.5"}),title:"Make a review card about this file (click a line first to pin it)",onClick:()=>p(!0),children:"Card"}),a.jsx(ee,{size:"sm",variant:E?"primary":"secondary",icon:E?a.jsx(x2,{className:"h-3.5 w-3.5"}):a.jsx(y2,{className:"h-3.5 w-3.5"}),onClick:()=>r(i),children:E?"In context":"Add to context"})]}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto bg-panel",children:[y.isLoading&&a.jsx("div",{className:"p-6",children:a.jsx(kt,{})}),y.error&&a.jsx("div",{className:"p-4",children:a.jsx(Ke,{error:y.error.message})}),y.data&&a.jsx(Wa,{text:y.data.text,lang:y.data.lang,focusLine:l,marks:m,onLineClick:F=>s(i,F)}),((M=y.data)==null?void 0:M.truncated)&&a.jsx("div",{className:"p-3 text-xs text-warn",children:"File cut at 400 KB."})]})]}):a.jsx(Ft,{icon:a.jsx(_a,{className:"h-6 w-6"}),title:"Pick a file to read",children:"Open a file on the left, or tick several to give the model more context. Then choose a lens, a quiz or a practice on the right."})});return a.jsxs(a.Fragment,{children:[a.jsx(Kn,{id:"explore-tree",collapsible:!0,className:"h-full",initial:290,left:w,right:a.jsx(Kn,{id:"explore-panel",collapsible:!0,side:"right",initial:360,min:300,max:560,left:N,right:a.jsx(w0,{files:j,practiceFile:i,onSetFiles:n})})}),h&&i&&a.jsx(Ha,{initial:{kind:"own",file:i,line:l??void 0},onClose:()=>p(!1)}),c&&a.jsx(pp,{title:"Add a context folder",cta:"Add as context",start:e.root.split("/").slice(0,-1).join("/"),onClose:()=>d(!1),onPick:F=>{d(!1),x.mutate([...e.contexts,F])}})]})}function Kc({value:e,options:t,onChange:n,placeholder:r="Pick one",className:i}){const[s,l]=b.useState(!1),[o,u]=b.useState(""),[c,d]=b.useState(0),h=b.useRef(null),p=b.useRef(null),f=t.find(k=>k.value===e),m=b.useMemo(()=>{const k=o.toLowerCase().split(/\s+/).filter(Boolean);return k.length?t.filter(y=>{const x=`${y.label} ${y.hint??""} ${y.group??""}`.toLowerCase();return k.every(v=>x.includes(v))}):t},[t,o]);b.useEffect(()=>{if(!s)return;const k=y=>{var x;return!((x=h.current)!=null&&x.contains(y.target))&&l(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[s]),b.useEffect(()=>d(0),[o,s]),b.useEffect(()=>{var k,y;(y=(k=p.current)==null?void 0:k.querySelector(`[data-i="${c}"]`))==null||y.scrollIntoView({block:"nearest"})},[c]);const g=k=>{n(k),l(!1),u("")};return a.jsxs("div",{ref:h,className:le("relative",i),children:[a.jsxs("button",{type:"button",onClick:()=>l(k=>!k),className:le("input flex h-8 items-center gap-2 py-0 text-left text-xs",s&&"border-accent ring-2 ring-accent/20"),title:f?`${f.label}${f.hint?` · ${f.hint}`:""}`:void 0,children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f?f.label:a.jsx("span",{className:"text-muted",children:r})}),(f==null?void 0:f.hint)&&a.jsx("span",{className:"max-w-[40%] shrink-0 truncate text-[12px] text-muted",children:f.hint}),a.jsx(Xj,{className:"h-3.5 w-3.5 shrink-0 text-muted"})]}),s&&a.jsxs("div",{className:"absolute left-0 right-0 top-full z-40 mt-1 overflow-hidden rounded-lg border border-line bg-panel shadow-xl",children:[a.jsxs("div",{className:"relative border-b border-line",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted"}),a.jsx("input",{autoFocus:!0,value:o,onChange:k=>u(k.target.value),placeholder:"Type to filter",className:"w-full bg-transparent py-2 pl-8 pr-3 text-xs text-ink outline-none placeholder:text-muted/70",onKeyDown:k=>{k.key==="ArrowDown"?(k.preventDefault(),d(y=>Math.min(m.length-1,y+1))):k.key==="ArrowUp"?(k.preventDefault(),d(y=>Math.max(0,y-1))):k.key==="Enter"&&m[c]?(k.preventDefault(),g(m[c].value)):k.key==="Escape"&&l(!1)}})]}),a.jsxs("div",{ref:p,className:"max-h-72 overflow-auto py-1",children:[m.map((k,y)=>{var x;return a.jsxs("div",{children:[k.group&&k.group!==((x=m[y-1])==null?void 0:x.group)&&a.jsx("div",{className:"px-3 pb-1 pt-2 text-[11.5px] font-medium uppercase tracking-wide text-muted",children:k.group}),a.jsxs("button",{type:"button","data-i":y,onMouseEnter:()=>d(y),onClick:()=>g(k.value),className:le("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs",y===c?"bg-accent/10 text-ink":"text-ink/90"),children:[a.jsx(ep,{className:le("h-3.5 w-3.5 shrink-0 text-accent",k.value!==e&&"invisible")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:k.label}),k.hint&&a.jsx("span",{className:"max-w-[45%] shrink-0 truncate text-[12px] text-muted",children:k.hint})]})]},k.value)}),!m.length&&a.jsx("div",{className:"px-3 py-4 text-center text-xs text-muted",children:"No match"})]})]})]})}let IS=null;const FS=()=>IS??(IS=ml(()=>import("./index-CyHGDhfc.js"),[])),DS=4e3;function OS(e){const t=[];let n=0,r=0,i=!1;for(const s of e.split(`
471
+ `).length>TS||t==="text"){u(Qc(e,p));return}return u(m=>m||Qc(e,p)),MS().then(async m=>{const g=RS[t]??t,k=await m.codeToHtml(e,{lang:g in m.bundledLanguages?g:"text",themes:{light:"solarized-light",dark:"dark-plus"},defaultColor:!1,transformers:[{line(y,x){y.properties["data-line"]=x;const v=p(x);v&&this.addClassToHast(y,v)}}]});h&&u(k)}).catch(()=>h&&u(Qc(e,p))),()=>{h=!1}},[e,t,n,r,l]),b.useEffect(()=>{if(!n||!c.current||d.current===n)return;const h=c.current.querySelector(`[data-line="${n-l+1}"]`);h==null||h.scrollIntoView({block:"center",behavior:"smooth"})},[o,n]),a.jsx("div",{ref:c,className:le("code-view font-mono",s&&"clickable",i),style:l>1?{"--line-start":l-1}:void 0,onClick:h=>{var f,m;if((f=window.getSelection())!=null&&f.toString())return;const p=(m=h.target.closest("[data-line]"))==null?void 0:m.dataset.line;if(p&&s){const g=Number(p)+l-1;d.current=g,s(g)}},dangerouslySetInnerHTML:{__html:o}})}function Fg(e,t,n){try{const r=localStorage.getItem(e);return r===null?t:n(r)}catch{return t}}function Dg(e,t){try{localStorage.setItem(e,t)}catch{}}function Kn({id:e,left:t,right:n,initial:r=280,min:i=180,max:s=640,side:l="left",className:o,collapsible:u=!1,startCollapsed:c=!1,openSignal:d}){const h=`cognitune.split.${e}`,[p,f]=b.useState(()=>Fg(h,r,Number)||r),[m,g]=b.useState(()=>u&&Fg(`${h}.collapsed`,c,U=>U==="1")),k=b.useRef(!0);b.useEffect(()=>{if(k.current){k.current=!1;return}d!=null&&g(!1)},[d]);const[y,x]=b.useState(!1),v=b.useRef(null),j=b.useRef();b.useEffect(()=>Dg(h,String(p)),[h,p]),b.useEffect(()=>Dg(`${h}.collapsed`,m?"1":"0"),[h,m]),b.useEffect(()=>{const U=G=>{if(!v.current)return;const X=G.clientX-v.current.x;f(Math.min(s,Math.max(i,v.current.size+(l==="left"?X:-X))))},q=()=>{v.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",q),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",q)}},[i,s,l]);const E=()=>{clearTimeout(j.current),x(!0)},w=()=>{clearTimeout(j.current),j.current=setTimeout(()=>x(!1),250)};b.useEffect(()=>()=>clearTimeout(j.current),[]);const N=l==="left";b.useEffect(()=>{if(!u)return;const U=N?"[":"]",q=G=>{const X=G.target;G.key!==U||G.ctrlKey||G.metaKey||G.altKey||X.closest("input, textarea, select, [contenteditable=true], .cm-editor")||(g(z=>!z),x(!1))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[u,N]);const M=N?xu:Tr,F=N?Tr:xu,C=a.jsxs("div",{className:"group relative w-px shrink-0 cursor-col-resize bg-line",onPointerDown:U=>{U.target.closest("button")||(v.current={x:U.clientX,size:p},document.body.style.cursor="col-resize",document.body.style.userSelect="none")},onDoubleClick:()=>f(r),title:"Drag to resize, double-click to reset",children:[a.jsx("div",{className:"absolute inset-y-0 -left-1.5 -right-1.5 transition group-hover:bg-accent/30"}),u&&a.jsx("button",{onClick:()=>{g(!0),x(!1)},title:`Fold this pane away (key ${N?"[":"]"}); hover the edge to see it again`,className:"absolute top-1/2 z-20 -mt-5 grid h-10 w-5 -translate-x-1/2 place-items-center rounded-full border border-line bg-panel text-muted shadow-sm transition hover:border-accent/50 hover:text-accent",children:a.jsx(M,{className:"h-3 w-3"})})]}),O=a.jsx("div",{onMouseEnter:E,onMouseLeave:w,className:le("group flex w-3 shrink-0 cursor-pointer flex-col items-center justify-center bg-panel transition hover:bg-accent/10",N?"border-r border-line":"border-l border-line"),onClick:()=>{g(!1),x(!1)},title:`Hover to peek, click to pin open (key ${N?"[":"]"})`,children:a.jsx(F,{className:"h-3 w-3 text-muted group-hover:text-accent"})}),A=a.jsx("div",{style:{width:p},onMouseEnter:m?E:void 0,onMouseLeave:m?w:void 0,className:le("min-h-0 shrink-0 overflow-hidden",m&&!y&&"hidden",m&&y&&le("absolute inset-y-0 z-30 shadow-2xl ring-1 ring-line",N?"left-3":"right-3")),children:N?t:n}),V=a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:N?n:t});return a.jsx("div",{className:le("relative flex h-full min-h-0 min-w-0",o),children:N?a.jsxs(a.Fragment,{children:[m&&O,A,!m&&C,V]}):a.jsxs(a.Fragment,{children:[V,!m&&C,A,m&&O]})})}function AS(){var M;const{project:e,selected:t,setSelected:n,toggle:r,openFile:i,setOpenFile:s,focusLine:l,rel:o}=it(),u=Dt(),[c,d]=b.useState(!1),[h,p]=b.useState(!1),f=ye({queryKey:["notes",e.id,i],queryFn:()=>me(`/projects/${e.id}/notes?file=${encodeURIComponent(i)}`),enabled:!!i}),m=b.useMemo(()=>(f.data??[]).filter(F=>F.line).map(F=>({from:F.line,to:F.line,cls:"note"})),[f.data]),g=ye({queryKey:["tree",e.id,e.contexts],queryFn:()=>me(`/projects/${e.id}/tree`)}),k=ye({queryKey:["progress",e.id],queryFn:()=>me(`/projects/${e.id}/progress`)}),y=ye({queryKey:["file",e.id,i],queryFn:()=>me(`/projects/${e.id}/file?path=${encodeURIComponent(i)}`),enabled:!!i}),x=vi({mutationFn:F=>Ua(`/projects/${e.id}`,{contexts:F}),onSuccess:()=>u.invalidateQueries()}),v=b.useMemo(()=>new Map((k.data??[]).map(F=>[F.path,F.level])),[k.data]),j=t.length?t:i?[i]:[],E=i?t.includes(i):!1,w=a.jsxs("div",{className:"flex h-full flex-col bg-side",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-semibold",children:e.name}),a.jsx("div",{className:"truncate font-mono text-[12px] text-muted",title:e.root,children:fr(e.root,30)})]}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(B1,{className:"h-4 w-4"}),title:"Add a context folder (docs, notes, a session folder)",onClick:()=>d(!0)})]}),e.contexts.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 border-b border-line px-3 py-2",children:e.contexts.map(F=>a.jsxs(be,{tone:"accent",className:"max-w-full",children:[a.jsxs("span",{className:"truncate",title:F,children:["+ ",F.split("/").pop()]}),a.jsx("button",{onClick:()=>x.mutate(e.contexts.filter(C=>C!==F)),"aria-label":"Remove context folder",children:a.jsx(Rn,{className:"h-3 w-3"})})]},F))}),t.length>0&&a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-accent/5 px-3 py-1.5 text-xs",children:[a.jsxs("span",{className:"font-medium text-accent",children:[t.length," ticked"]}),a.jsx("button",{className:"ml-auto text-muted hover:text-ink",onClick:()=>n([]),children:"clear"})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[g.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),g.error&&a.jsx("div",{className:"p-3",children:a.jsx(Ke,{error:g.error.message})}),g.data&&a.jsx(mp,{roots:g.data,selected:t,onToggle:(F,C)=>n(C?[...t,...F]:t.filter(O=>!F.includes(O))),openFile:i,onOpen:F=>s(F),levels:v})]})]}),N=a.jsx("div",{className:"flex h-full flex-col",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-panel px-4 py-2",children:[a.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[14px]",children:o(i)}),y.data&&a.jsx(be,{children:y.data.lang}),v.get(i)&&v.get(i)!=="new"&&a.jsx(be,{tone:v.get(i)==="understood"?"good":v.get(i)==="stale"?"warn":"muted",children:v.get(i)}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(Fr,{className:"h-3.5 w-3.5"}),title:"Make a review card about this file (click a line first to pin it)",onClick:()=>p(!0),children:"Card"}),a.jsx(ee,{size:"sm",variant:E?"primary":"secondary",icon:E?a.jsx(x2,{className:"h-3.5 w-3.5"}):a.jsx(y2,{className:"h-3.5 w-3.5"}),onClick:()=>r(i),children:E?"In context":"Add to context"})]}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto bg-panel",children:[y.isLoading&&a.jsx("div",{className:"p-6",children:a.jsx(kt,{})}),y.error&&a.jsx("div",{className:"p-4",children:a.jsx(Ke,{error:y.error.message})}),y.data&&a.jsx(Wa,{text:y.data.text,lang:y.data.lang,focusLine:l,marks:m,onLineClick:F=>s(i,F)}),((M=y.data)==null?void 0:M.truncated)&&a.jsx("div",{className:"p-3 text-xs text-warn",children:"File cut at 400 KB."})]})]}):a.jsx(Ft,{icon:a.jsx(_a,{className:"h-6 w-6"}),title:"Pick a file to read",children:"Open a file on the left, or tick several to give the model more context. Then choose a lens, a quiz or a practice on the right."})});return a.jsxs(a.Fragment,{children:[a.jsx(Kn,{id:"explore-tree",collapsible:!0,className:"h-full",initial:290,left:w,right:a.jsx(Kn,{id:"explore-panel",collapsible:!0,side:"right",initial:360,min:300,max:560,left:N,right:a.jsx(w0,{files:j,practiceFile:i,onSetFiles:n})})}),h&&i&&a.jsx(Ha,{initial:{kind:"own",file:i,line:l??void 0},onClose:()=>p(!1)}),c&&a.jsx(pp,{title:"Add a context folder",cta:"Add as context",start:e.root.split("/").slice(0,-1).join("/"),onClose:()=>d(!1),onPick:F=>{d(!1),x.mutate([...e.contexts,F])}})]})}function Kc({value:e,options:t,onChange:n,placeholder:r="Pick one",className:i}){const[s,l]=b.useState(!1),[o,u]=b.useState(""),[c,d]=b.useState(0),h=b.useRef(null),p=b.useRef(null),f=t.find(k=>k.value===e),m=b.useMemo(()=>{const k=o.toLowerCase().split(/\s+/).filter(Boolean);return k.length?t.filter(y=>{const x=`${y.label} ${y.hint??""} ${y.group??""}`.toLowerCase();return k.every(v=>x.includes(v))}):t},[t,o]);b.useEffect(()=>{if(!s)return;const k=y=>{var x;return!((x=h.current)!=null&&x.contains(y.target))&&l(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[s]),b.useEffect(()=>d(0),[o,s]),b.useEffect(()=>{var k,y;(y=(k=p.current)==null?void 0:k.querySelector(`[data-i="${c}"]`))==null||y.scrollIntoView({block:"nearest"})},[c]);const g=k=>{n(k),l(!1),u("")};return a.jsxs("div",{ref:h,className:le("relative",i),children:[a.jsxs("button",{type:"button",onClick:()=>l(k=>!k),className:le("input flex h-8 items-center gap-2 py-0 text-left text-xs",s&&"border-accent ring-2 ring-accent/20"),title:f?`${f.label}${f.hint?` · ${f.hint}`:""}`:void 0,children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f?f.label:a.jsx("span",{className:"text-muted",children:r})}),(f==null?void 0:f.hint)&&a.jsx("span",{className:"max-w-[40%] shrink-0 truncate text-[12px] text-muted",children:f.hint}),a.jsx(Xj,{className:"h-3.5 w-3.5 shrink-0 text-muted"})]}),s&&a.jsxs("div",{className:"absolute left-0 right-0 top-full z-40 mt-1 overflow-hidden rounded-lg border border-line bg-panel shadow-xl",children:[a.jsxs("div",{className:"relative border-b border-line",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted"}),a.jsx("input",{autoFocus:!0,value:o,onChange:k=>u(k.target.value),placeholder:"Type to filter",className:"w-full bg-transparent py-2 pl-8 pr-3 text-xs text-ink outline-none placeholder:text-muted/70",onKeyDown:k=>{k.key==="ArrowDown"?(k.preventDefault(),d(y=>Math.min(m.length-1,y+1))):k.key==="ArrowUp"?(k.preventDefault(),d(y=>Math.max(0,y-1))):k.key==="Enter"&&m[c]?(k.preventDefault(),g(m[c].value)):k.key==="Escape"&&l(!1)}})]}),a.jsxs("div",{ref:p,className:"max-h-72 overflow-auto py-1",children:[m.map((k,y)=>{var x;return a.jsxs("div",{children:[k.group&&k.group!==((x=m[y-1])==null?void 0:x.group)&&a.jsx("div",{className:"px-3 pb-1 pt-2 text-[11.5px] font-medium uppercase tracking-wide text-muted",children:k.group}),a.jsxs("button",{type:"button","data-i":y,onMouseEnter:()=>d(y),onClick:()=>g(k.value),className:le("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs",y===c?"bg-accent/10 text-ink":"text-ink/90"),children:[a.jsx(ep,{className:le("h-3.5 w-3.5 shrink-0 text-accent",k.value!==e&&"invisible")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:k.label}),k.hint&&a.jsx("span",{className:"max-w-[45%] shrink-0 truncate text-[12px] text-muted",children:k.hint})]})]},k.value)}),!m.length&&a.jsx("div",{className:"px-3 py-4 text-center text-xs text-muted",children:"No match"})]})]})]})}let IS=null;const FS=()=>IS??(IS=ml(()=>import("./index-6_jiQxLN.js"),[])),DS=4e3;function OS(e){const t=[];let n=0,r=0,i=!1;for(const s of e.split(`
472
472
  `)){const l=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(s);if(l){n=Number(l[1]),r=Number(l[2]),i=!0,t.push({kind:"hunk",text:s});continue}if(i)if(s.startsWith("+"))t.push({kind:"add",right:r++,text:s.slice(1)});else if(s.startsWith("-"))t.push({kind:"del",left:n++,text:s.slice(1)});else{if(s.startsWith("\\"))continue;(s.startsWith(" ")||s==="")&&t.push({kind:"ctx",left:n++,right:r++,text:s.slice(1)})}}return t.length&&t[t.length-1].kind==="ctx"&&t[t.length-1].text===""&&t.pop(),t}function _S(e){const t=[];for(let n=0;n<e.length;){const r=e[n];if(r.kind==="hunk")t.push({hunk:r.text}),n++;else if(r.kind==="ctx")t.push({left:r,right:r}),n++;else{const i=[],s=[];for(;n<e.length&&e[n].kind==="del";)i.push(e[n++]);for(;n<e.length&&e[n].kind==="add";)s.push(e[n++]);for(let l=0;l<Math.max(i.length,s.length);l++)t.push({left:i[l],right:s[l]})}}return t}const Lh="w-12 shrink-0 select-none pr-3 text-right text-muted/60",k0="min-w-0 flex-1 whitespace-pre-wrap break-all pr-4";function $S(e,t){const[n,r]=b.useState(new Map);return b.useEffect(()=>{const i=e.filter(l=>l.kind!=="hunk");if(!i.length||t==="text"||i.length>DS){r(new Map);return}let s=!0;return FS().then(async l=>{if(!(t in l.bundledLanguages))return;const o=await l.codeToHtml(i.map(d=>d.text).join(`
473
473
  `),{lang:t,themes:{light:"solarized-light",dark:"dark-plus"},defaultColor:!1}),u=new DOMParser().parseFromString(o,"text/html").querySelectorAll(".line"),c=new Map;i.forEach((d,h)=>u[h]&&c.set(d,u[h].innerHTML)),s&&r(c)}).catch(()=>{}),()=>{s=!1}},[e,t]),n}function qS({patch:e,mode:t,lang:n="text"}){const r=b.useMemo(()=>OS(e),[e]),i=$S(r,n),s=o=>i.has(o)?a.jsx("span",{className:"shiki",dangerouslySetInnerHTML:{__html:i.get(o)}}):o.text,l=!r.some(o=>o.kind==="ctx")&&(!r.some(o=>o.kind==="add")||!r.some(o=>o.kind==="del"));return r.length?t==="unified"||l?a.jsx("div",{className:"min-h-full py-1 font-mono text-[13.5px] leading-6",children:r.map((o,u)=>o.kind==="hunk"?a.jsx("div",{className:"diff-hunk px-4",children:o.text},u):a.jsxs("div",{className:le("flex",o.kind==="add"&&"diff-add",o.kind==="del"&&"diff-del"),children:[a.jsx("span",{className:Lh,children:o.left??""}),a.jsx("span",{className:Lh,children:o.right??""}),a.jsx("span",{className:"w-4 shrink-0 select-none text-muted",children:o.kind==="add"?"+":o.kind==="del"?"-":""}),a.jsx("span",{className:k0,children:s(o)})]},u))}):a.jsx(BS,{rows:_S(r),hl:i}):a.jsx("div",{className:"p-6 text-sm text-muted",children:"No text changes (binary file or mode change)."})}function BS({rows:e,hl:t}){const n=b.useRef(null),[r,i]=b.useState(()=>{try{return Number(localStorage.getItem("cognitune.diff.split"))||50}catch{return 50}});b.useEffect(()=>{try{localStorage.setItem("cognitune.diff.split",String(r))}catch{}},[r]);const s=o=>{var h;const u=(h=n.current)==null?void 0:h.getBoundingClientRect();if(!u)return;o.preventDefault();const c=p=>i(Math.min(85,Math.max(15,(p.clientX-u.left)/u.width*100))),d=()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",d),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",c),window.addEventListener("pointerup",d)},l=(o,u,c)=>a.jsxs("div",{className:le("flex min-w-0",(o==null?void 0:o.kind)==="del"&&"diff-del",(o==null?void 0:o.kind)==="add"&&"diff-add",!o&&"bg-raised/60"),children:[a.jsx("span",{className:Lh,children:o?u===0?o.left:o.right:""}),a.jsx("span",{className:k0,children:o?t.has(o)?a.jsx("span",{className:"shiki",dangerouslySetInnerHTML:{__html:t.get(o)}}):o.text:""})]},c);return a.jsxs("div",{ref:n,className:"relative min-h-full font-mono text-[13.5px] leading-6",children:[a.jsx("div",{className:"grid py-1",style:{gridTemplateColumns:`${r}% ${100-r}%`},children:e.map((o,u)=>o.hunk?a.jsx("div",{className:"diff-hunk col-span-2 whitespace-pre-wrap break-all px-4",children:o.hunk},u):[l(o.left,0,`${u}l`),l(o.right,1,`${u}r`)])}),a.jsx("div",{className:"group absolute inset-y-0 z-10 w-px cursor-col-resize bg-line",style:{left:`${r}%`},onPointerDown:s,onDoubleClick:()=>i(50),title:"Drag to move, double-click to centre",children:a.jsx("div",{className:"absolute inset-y-0 -left-1.5 -right-1.5 transition group-hover:bg-accent/30"})})]})}function US(e,t){const n={name:"",path:e,kind:"dir",children:[]};for(const i of t){if(!i.startsWith(e+"/"))continue;const s=i.slice(e.length+1).split("/");let l=n;s.forEach((o,u)=>{const c=u===s.length-1;l.children??(l.children=[]);let d=l.children.find(h=>h.name===o&&h.kind===(c?"file":"dir"));d||(d={name:o,path:`${l.path}/${o}`,kind:c?"file":"dir",...c?{}:{children:[]}},l.children.push(d)),l=d})}const r=i=>{var o;if(i.kind==="file")return i;let s=i;for(;((o=s.children)==null?void 0:o.length)===1&&s.children[0].kind==="dir";){const u=s.children[0];s={...u,name:`${s.name}/${u.name}`}}const l=(s.children??[]).map(r);return l.sort((u,c)=>u.kind===c.kind?u.name.localeCompare(c.name):u.kind==="dir"?-1:1),{...s,children:l}};return(r(n).children??[]).map(i=>i.name.startsWith("/")?{...i,name:i.name.slice(1)}:i)}const HS={added:"text-good",deleted:"text-bad",modified:"text-warn",renamed:"text-accent"};function WS(){var A,V,U;const{project:e,rel:t}=it(),n=ye({queryKey:["repos",e.id,e.contexts],queryFn:()=>me(`/projects/${e.id}/repos`)}),r=`cognitune.repo.${e.id}`,[i,s]=b.useState(()=>{let q;try{q=sessionStorage.getItem(r)||void 0}catch{}return{repo:q,base:"HEAD",head:""}}),[l,o]=b.useState(null),[u,c]=b.useState(new Set),[d,h]=b.useState([]),[p,f]=b.useState("split"),m=n.data??[],g=m.find(q=>q.path===i.repo)??m[0];b.useEffect(()=>{g&&g.path!==i.repo&&s(q=>({...q,repo:g.path}))},[g,i.repo]);const k=q=>{try{sessionStorage.setItem(r,q)}catch{}s({repo:q,base:"HEAD",head:""})},y=!!g&&i.repo===g.path,x=q=>`/projects/${e.id}/${q}${q.includes("?")?"&":"?"}repo=${encodeURIComponent(i.repo??"")}`,v=ye({queryKey:["refs",e.id,i.repo],queryFn:()=>me(x("refs")),enabled:y}),j=ye({queryKey:["diff",e.id,i],queryFn:()=>me(x(`diff?base=${encodeURIComponent(i.base)}&head=${encodeURIComponent(i.head)}`)),enabled:y}),E=j.data??[];b.useEffect(()=>{c(new Set(E.map(q=>q.path))),o(q=>{var G;return q&&E.some(X=>X.path===q)?q:((G=E[0])==null?void 0:G.path)??null})},[j.data]);const w=b.useMemo(()=>E.find(q=>q.path===l),[E,l]),N=b.useMemo(()=>new Map(E.map(q=>[q.path,q])),[E]),M=b.useMemo(()=>i.repo?US(i.repo,E.map(q=>q.path)):[],[i.repo,E]);if(n.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!m.length)return a.jsx(Ft,{icon:a.jsx(U1,{className:"h-6 w-6"}),title:"No git repositories found",children:"Changes needs git history. No repo was found in this folder or its sub-folders (4 levels down). Explore, lenses and quizzes work without it."});const F=[{value:"HEAD",label:"HEAD",hint:(A=v.data)==null?void 0:A.current,group:"Current"},...(((V=v.data)==null?void 0:V.branches)??[]).map(q=>({value:q,label:q,group:"Branches"})),...(((U=v.data)==null?void 0:U.commits)??[]).map(q=>({value:q.sha,label:`${q.sha} ${q.subject}`,hint:q.when,group:"Recent commits"}))],C=a.jsxs("div",{className:"flex h-full flex-col bg-side",children:[a.jsxs("div",{className:"space-y-2 border-b border-line p-3",children:[m.length>1&&a.jsxs("div",{children:[a.jsxs("div",{className:"label",children:["Repository (",m.length,")"]}),a.jsx(Kc,{value:(g==null?void 0:g.path)??"",onChange:k,options:m.map(q=>({value:q.path,label:q.name,hint:q.branch}))})]}),a.jsxs("div",{children:[a.jsx("div",{className:"label",children:"From"}),a.jsx(Kc,{value:i.base,onChange:q=>s({...i,base:q}),options:F})]}),a.jsxs("div",{children:[a.jsx("div",{className:"label",children:"To"}),a.jsx(Kc,{value:i.head,onChange:q=>s({...i,head:q}),options:[{value:"",label:"Working tree (uncommitted)",group:"Current"},...F]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted",children:[a.jsxs("span",{children:[E.length," files"]}),a.jsxs("span",{className:"text-good",children:["+",E.reduce((q,G)=>q+G.additions,0)]}),a.jsxs("span",{className:"text-bad",children:["-",E.reduce((q,G)=>q+G.deletions,0)]}),a.jsx("button",{className:"ml-auto hover:text-ink",onClick:()=>c(u.size===E.length?new Set:new Set(E.map(q=>q.path))),children:u.size===E.length?"none":"all"})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[j.isLoading&&a.jsx("div",{className:"p-3",children:a.jsx(kt,{})}),j.error&&a.jsx("div",{className:"p-2",children:a.jsx(Ke,{error:j.error.message})}),E.length>0&&a.jsx(mp,{roots:M,openAll:!0,selected:[...u],onToggle:(q,G)=>{const X=new Set(u);for(const z of q)G?X.add(z):X.delete(z);c(X)},openFile:l,onOpen:o,meta:q=>{const G=N.get(q);return G?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"font-mono text-[11.5px] text-good",children:["+",G.additions]}),a.jsxs("span",{className:"font-mono text-[11.5px] text-bad",children:["-",G.deletions]}),a.jsx("span",{className:le("w-3 text-center font-mono text-[12px] font-bold uppercase",HS[G.status]),title:G.status,children:G.status[0]})]}):null}},`${i.repo}|${i.base}|${i.head}`),!j.isLoading&&!E.length&&a.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted",children:"No changes between these two."})]})]}),O=a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-panel px-4 py-2",children:[a.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[14px]",children:w?t(w.path):""}),a.jsx(Zt,{value:p,onChange:f,options:[{value:"split",label:"Split"},{value:"unified",label:"Unified"}]})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-panel",children:w?a.jsx(qS,{patch:w.patch,mode:p,lang:x0(w.path)}):a.jsx(Ft,{title:"Pick a file"})})]});return a.jsx(Kn,{id:"changes-list",collapsible:!0,initial:300,className:"h-full",left:C,right:a.jsx(Kn,{id:"changes-panel",collapsible:!0,side:"right",initial:360,min:300,max:560,left:O,right:a.jsx(w0,{files:[...u,...d],diff:i,onRemove:q=>{c(new Set([...u].filter(G=>G!==q))),h(d.filter(G=>G!==q))},onSetFiles:q=>{const G=new Set(E.map(X=>X.path));c(new Set(q.filter(X=>G.has(X)))),h(q.filter(X=>!G.has(X)))},practiceFile:(w==null?void 0:w.status)!=="deleted"?w==null?void 0:w.path:null})})})}const VS=["lenses","quizzes","practice","teachbacks","walks","hunts","threads","cards","weak","glossary","notes"],QS={quiz:"quiz miss",teachback:"teach-back",walk:"walk check",hunt:"bug hunt"};function KS(){var D,te,P,ve,Le,we,Se,_t,an,Lt,qe,lt,zn,An,Vt,Gn,on,Yn,xr,Xn,Jn,yr,Z,Qt,vr,Zn,_,H,fe,pe,ht,Ce,at;const{project:e,rel:t,setOpenFile:n}=it(),r=Dt(),[i,s]=ec(),l=VS.includes(i.get("tab"))?i.get("tab"):"lenses",o=R=>s({tab:R},{replace:!0}),[u,c]=b.useState(""),[d,h]=b.useState(null),p=`/projects/${e.id}`,f=`/p/${e.id}`,m=R=>ye({queryKey:[R,e.id],queryFn:()=>me(`${p}/${R}`)}),g=m("lenses"),k=m("quizzes"),y=m("practice"),x=m("teachbacks"),v=m("walks"),j=m("hunts"),E=m("threads"),w=m("cards"),N=m("notes"),M=m("misconceptions"),F=gt(),C=mn(),[O,A]=b.useState(null),V=(R,ke)=>{A(ke),C.run(`${p}/quizzes`,{files:[],weak:!0,weakIds:R},Je=>F(`${f}/quiz/${Je.resultId}`))},U=async R=>{await cs(`${p}/misconceptions/${R}`),r.invalidateQueries({queryKey:["misconceptions",e.id]}),r.invalidateQueries({queryKey:["today",e.id]})},q=ye({queryKey:["glossary",e.id],queryFn:()=>me(`${p}/glossary`),enabled:l==="glossary"}),G=b.useMemo(()=>{const R=u.toLowerCase().split(/\s+/).filter(Boolean);return(...ke)=>{const Je=ke.join(" ").toLowerCase();return R.every(vn=>Je.includes(vn))}},[u]),X=R=>a.jsxs("div",{className:"mt-2 truncate font-mono text-[12px] text-muted",children:[R.slice(0,3).map(ke=>fr(t(ke),28)).join(" · "),R.length>3&&` +${R.length-3}`]}),z="card block p-4 transition hover:-translate-y-0.5 hover:border-accent/40",W=R=>a.jsx("span",{className:"ml-auto text-[12px] text-muted",children:Tt(R)}),S=(R,ke,Je)=>a.jsx(Ft,{icon:R,title:ke,children:Je});return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx("div",{className:"border-b border-line bg-panel px-8 pt-6",children:a.jsxs("div",{className:"mx-auto max-w-[72rem]",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Library"}),a.jsxs("p",{className:"text-sm text-muted",children:["Everything made in ",e.name,"."]})]}),a.jsxs("div",{className:"relative w-64",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted"}),a.jsx("input",{className:"input h-8 pl-8 text-[14px]",placeholder:"Search this tab",value:u,onChange:R=>c(R.target.value)})]}),a.jsxs("a",{href:`/api${p}/export`,className:"inline-flex items-center gap-1 rounded-md px-2 py-1.5 text-xs text-muted hover:bg-raised hover:text-ink",title:"Everything for this project as one JSON file",children:[a.jsx(tp,{className:"h-3.5 w-3.5"})," Export all"]})]}),a.jsx(dS,{className:"-mx-2 mt-3 border-b-0",wrap:!0,value:l,onChange:o,tabs:[{value:"lenses",label:"Lenses",count:(D=g.data)==null?void 0:D.length},{value:"quizzes",label:"Quizzes",count:(te=k.data)==null?void 0:te.length},{value:"teachbacks",label:"Teach-backs",count:(P=x.data)==null?void 0:P.length},{value:"walks",label:"Walks",count:(ve=v.data)==null?void 0:ve.length},{value:"practice",label:"Practice",count:(Le=y.data)==null?void 0:Le.length},{value:"hunts",label:"Bug hunts",count:(we=j.data)==null?void 0:we.length},{value:"threads",label:"Tutor",count:(Se=E.data)==null?void 0:Se.length},{value:"cards",label:"Cards",count:(_t=w.data)==null?void 0:_t.length},{value:"weak",label:"Weak spots",count:(an=M.data)==null?void 0:an.length},{value:"glossary",label:"Glossary"},{value:"notes",label:"Notes",count:(Lt=N.data)==null?void 0:Lt.length}]})]})}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-8",children:a.jsxs("div",{className:"mx-auto max-w-[72rem]",children:[l==="weak"&&!!((qe=M.data)!=null&&qe.length)&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("p",{className:"flex-1 text-[14px] text-muted",children:"Wrong beliefs picked up from your answers. Answer a question on one correctly and it goes away; dismiss one the grader got wrong."}),a.jsxs(ee,{size:"sm",variant:"primary",icon:a.jsx(Ji,{className:"h-3.5 w-3.5"}),disabled:C.busy,onClick:()=>V(M.data.slice(0,6).map(R=>R.id),"all"),children:["Quiz me on ",M.data.length>6?"the top 6":"all of them"]})]}),C.busy&&C.job&&O==="all"&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"quiz",elapsed:C.elapsed})}),C.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:C.error,onClose:C.clearError})})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[l==="lenses"&&((lt=g.data)==null?void 0:lt.filter(R=>G(R.title,R.summary,R.kind,...R.files)).map(R=>a.jsxs(ft,{to:`${f}/lens/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(be,{tone:"accent",children:R.kind}),R.diff&&a.jsx(be,{tone:"warn",children:"change"}),R.sketch&&a.jsx(be,{children:"your take first"}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 font-medium leading-snug",children:R.title}),a.jsx("p",{className:"mt-1 line-clamp-2 text-[14px] text-muted",children:R.summary}),X(R.files)]},R.id))),l==="quizzes"&&((zn=k.data)==null?void 0:zn.filter(R=>G(R.title,...R.files)).map(R=>{const ke=R.attempts.length?Math.max(...R.attempts.map(Je=>Je.score)):null;return a.jsxs(ft,{to:`${f}/quiz/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(be,{children:[R.questions.length," questions"]}),ke===null?a.jsx(be,{tone:"warn",children:"not taken"}):a.jsxs("span",{className:"text-xs text-muted",children:["best ",a.jsx(Ca,{score:ke,size:"sm"})," · ",R.attempts.length," tries"]}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 font-medium leading-snug",children:R.title}),X(R.files)]},R.id)})),l==="teachbacks"&&((An=x.data)==null?void 0:An.filter(R=>G(R.text,...R.files)).map(R=>a.jsxs(ft,{to:`${f}/teach/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[R.grade&&a.jsxs(be,{tone:R.grade.score>=4?"good":R.grade.score>=3?"warn":"bad",children:[R.grade.score,"/5"]}),W(R.createdAt)]}),a.jsx("p",{className:"mt-2 line-clamp-3 text-[14px]",children:R.text}),X(R.files)]},R.id))),l==="walks"&&((Vt=v.data)==null?void 0:Vt.filter(R=>G(R.file,...R.blocks.map(ke=>ke.title))).map(R=>{const ke=R.blocks.filter(Je=>Je.verdict).length;return a.jsxs(ft,{to:`${f}/walk/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(be,{tone:ke===R.blocks.length?"good":"warn",children:[ke,"/",R.blocks.length," checked"]}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 truncate font-mono text-sm",children:t(R.file)})]},R.id)})),l==="practice"&&((Gn=y.data)==null?void 0:Gn.filter(R=>G(R.file)).map(R=>{var Je;const ke=(Je=R.review)==null?void 0:Je.holes.filter(vn=>vn.verdict==="right").length;return a.jsxs(ft,{to:`${f}/practice/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(be,{tone:"accent",children:["level ",R.level]}),a.jsxs(be,{children:[R.holes.length," holes"]}),R.review?a.jsxs(be,{tone:ke===R.holes.length?"good":"warn",children:[ke,"/",R.holes.length," right"]}):a.jsx(be,{tone:"warn",children:"open"}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 truncate font-mono text-sm",children:t(R.file)})]},R.id)})),l==="hunts"&&((on=j.data)==null?void 0:on.filter(R=>G(R.file)).map(R=>a.jsxs(ft,{to:`${f}/hunt/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(be,{tone:"bad",children:["","easy","medium","hard"][R.level]}),R.grade?a.jsx("span",{className:"text-xs text-muted",children:a.jsx(Ca,{score:R.grade.score,size:"sm"})}):a.jsx(be,{tone:"warn",children:"open"}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 truncate font-mono text-sm",children:t(R.file)})]},R.id))),l==="threads"&&((Yn=E.data)==null?void 0:Yn.filter(R=>G(R.title,...R.messages.map(ke=>ke.text))).map(R=>a.jsxs(ft,{to:`${f}/tutor/${R.id}`,className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(be,{children:[R.messages.length," messages"]}),W(R.createdAt)]}),a.jsx("div",{className:"mt-2 line-clamp-2 font-medium leading-snug",children:R.title}),X(R.files)]},R.id))),l==="cards"&&((xr=w.data)==null?void 0:xr.filter(R=>G(R.front,R.back,R.file)).map(R=>a.jsxs("div",{className:"card group p-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(be,{tone:R.kind==="miss"?"bad":R.kind==="concept"?"accent":"muted",children:R.kind}),R.suspended?a.jsx(be,{children:"paused"}):a.jsxs("span",{className:"text-[12px] text-muted",children:["due in ",Th(R.fsrs.due)]}),a.jsxs("span",{className:"ml-auto flex gap-1 opacity-0 transition group-hover:opacity-100",children:[a.jsx("button",{className:"text-muted hover:text-ink",title:R.suspended?"Resume":"Pause",onClick:async()=>{await Ua(`${p}/cards/${R.id}`,{suspended:!R.suspended}),r.invalidateQueries({queryKey:["cards",e.id]})},children:R.suspended?a.jsx(Jj,{className:"h-3.5 w-3.5"}):a.jsx(D1,{className:"h-3.5 w-3.5"})}),a.jsx("button",{className:"text-muted hover:text-bad",title:"Archive",onClick:async()=>{await cs(`${p}/cards/${R.id}`),r.invalidateQueries({queryKey:["cards",e.id]})},children:a.jsx(pr,{className:"h-3.5 w-3.5"})})]})]}),a.jsx("div",{className:"mt-2 text-[14.5px] font-medium leading-snug",children:R.front}),a.jsx("p",{className:"mt-1 line-clamp-2 text-[14px] text-muted",children:R.back}),R.file&&a.jsxs("div",{className:"mt-2 truncate font-mono text-[12px] text-muted",children:[t(R.file),R.line?`:${R.line}`:""]})]},R.id))),l==="weak"&&((Xn=M.data)==null?void 0:Xn.filter(R=>G(R.text,R.file)).map(R=>a.jsxs("div",{className:"card flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(be,{tone:"bad",children:QS[R.from]??R.from}),R.seen>1&&a.jsxs(be,{tone:"warn",children:["seen ",R.seen,"×"]}),W(R.createdAt)]}),a.jsx("p",{className:"mt-2 text-[14.5px] leading-snug",children:R.text}),R.file&&a.jsxs(ft,{to:`${f}/explore`,onClick:()=>n(R.file,R.line),className:"mt-2 truncate font-mono text-[12px] text-muted hover:text-accent",children:[t(R.file),R.line?`:${R.line}`:""]}),a.jsxs("div",{className:"mt-3 flex items-center gap-2 pt-1",children:[a.jsx(ee,{size:"sm",icon:a.jsx(Ji,{className:"h-3.5 w-3.5"}),disabled:C.busy,onClick:()=>V([R.id],R.id),children:"Quiz me on this"}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(Rn,{className:"h-3.5 w-3.5"}),onClick:()=>U(R.id),title:"The grader got this wrong, or it no longer applies",children:"Dismiss"})]}),C.busy&&C.job&&O===R.id&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"quiz",elapsed:C.elapsed})})]},R.id))),l==="notes"&&((Jn=N.data)==null?void 0:Jn.filter(R=>G(R.text,R.file)).map(R=>a.jsxs(ft,{to:`${f}/explore`,onClick:()=>R.file&&n(R.file,R.line),className:z,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[R.file&&a.jsxs("span",{className:"truncate font-mono text-[12px] text-accent",children:[t(R.file),R.line?`:${R.line}`:""]}),W(R.createdAt)]}),a.jsx("p",{className:"mt-2 whitespace-pre-wrap text-[14.5px]",children:R.text})]},R.id)))]}),l==="glossary"&&a.jsxs("div",{className:"divide-y divide-line",children:[(yr=q.data)==null?void 0:yr.filter(R=>G(R.term,...R.explains.map(ke=>ke.text))).map(R=>a.jsxs("div",{className:"group py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"text-[16px] font-semibold",children:R.term}),a.jsx("span",{className:"text-[12px] text-muted",children:R.files.slice(0,3).map(ke=>fr(t(ke),24)).join(" · ")}),a.jsx("button",{className:"ml-auto text-muted opacity-0 transition hover:text-accent group-hover:opacity-100",title:"Make a review card",onClick:()=>{var ke;return h({kind:"concept",front:`What is "${R.term}" here, and why does it matter?`,back:((ke=R.explains[0])==null?void 0:ke.text)??"",file:R.files[0]})},children:a.jsx(Fr,{className:"h-3.5 w-3.5"})})]}),R.explains.map((ke,Je)=>a.jsxs("p",{className:"mt-1 text-[14.5px] text-ink/85",children:[ke.text," ",a.jsxs(ft,{to:`${f}/lens/${ke.lensId}`,className:"text-[12px] text-muted hover:text-accent",children:["(",ke.lensTitle,")"]})]},Je))]},R.term)),((Z=q.data)==null?void 0:Z.length)===0&&S(a.jsx(Gj,{className:"h-6 w-6"}),"No terms yet","Every lens adds the concepts it explains here.")]}),l==="lenses"&&((Qt=g.data)==null?void 0:Qt.length)===0&&S(a.jsx(_a,{className:"h-6 w-6"}),"No lenses yet","Open Explore, pick files, choose a lens."),l==="quizzes"&&((vr=k.data)==null?void 0:vr.length)===0&&S(a.jsx($a,{className:"h-6 w-6"}),"No quizzes yet","Quiz yourself from Explore, Changes, or the end of a lens."),l==="teachbacks"&&((Zn=x.data)==null?void 0:Zn.length)===0&&S(a.jsx(Qu,{className:"h-6 w-6"}),"No teach-backs yet","In Explore, pick Teach and explain the code in your own words."),l==="walks"&&((_=v.data)==null?void 0:_.length)===0&&S(a.jsx(Vu,{className:"h-6 w-6"}),"No walkthroughs yet","Open a file in Explore and pick Walk."),l==="practice"&&((H=y.data)==null?void 0:H.length)===0&&S(a.jsx(Ku,{className:"h-6 w-6"}),"No practice yet","Open a file in Explore and pick Practice."),l==="hunts"&&((fe=j.data)==null?void 0:fe.length)===0&&S(a.jsx(Wu,{className:"h-6 w-6"}),"No bug hunts yet","Open a file in Explore and pick Bug hunt."),l==="threads"&&((pe=E.data)==null?void 0:pe.length)===0&&S(a.jsx(Gu,{className:"h-6 w-6"}),"No tutor chats yet","Ask the tutor from Explore or from a missed quiz question."),l==="cards"&&((ht=w.data)==null?void 0:ht.length)===0&&S(a.jsx(Fr,{className:"h-6 w-6"}),"No cards yet","Quiz misses become cards on their own. You can also make one from a lens concept or a code line."),l==="weak"&&((Ce=M.data)==null?void 0:Ce.length)===0&&S(a.jsx(Ji,{className:"h-6 w-6"}),"No weak spots","Wrong answers in quizzes, teach-backs and walks show up here as the belief behind them."),l==="notes"&&((at=N.data)==null?void 0:at.length)===0&&S(a.jsx(G1,{className:"h-6 w-6"}),"No notes yet","In Explore, click a line and add a note from the Notes tab.")]})}),d&&a.jsx(Ha,{initial:d,onClose:()=>h(null)})]})}function kl({file:e,text:t,lang:n,line:r,marks:i,onLineClick:s,title:l,empty:o="Code shows here",onClose:u}){var f,m;const{project:c,rel:d}=it(),h=ye({queryKey:["file",c.id,e],queryFn:()=>me(`/projects/${c.id}/file?path=${encodeURIComponent(e)}`),enabled:!!e&&t===void 0}),p=t??((f=h.data)==null?void 0:f.text);return a.jsx("div",{className:"flex h-full flex-col bg-panel",children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2 font-mono text-[13px] text-muted",children:[a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[l??d(e),r?`:${r}`:""]}),u&&a.jsx("button",{className:"text-xs hover:text-ink",onClick:u,children:"close"})]}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[h.isLoading&&a.jsx("div",{className:"p-4",children:a.jsx(kt,{})}),h.error&&a.jsx("div",{className:"p-3",children:a.jsx(Ke,{error:h.error.message})}),p!==void 0&&a.jsx(Wa,{text:p,lang:n??((m=h.data)==null?void 0:m.lang)??x0(e),focusLine:r,marks:i,onLineClick:s})]})]}):a.jsx(Ft,{title:o})})}function GS(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const YS=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,JS={};function Og(e,t){return(JS.jsx?XS:YS).test(e)}const ZS=/[ \t\n\f\r]/g;function eC(e){return typeof e=="object"?e.type==="text"?_g(e.value):!1:_g(e)}function _g(e){return e.replace(ZS,"")===""}class Va{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Va.prototype.normal={};Va.prototype.property={};Va.prototype.space=void 0;function b0(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Va(n,r,t)}function Mh(e){return e.toLowerCase()}class ln{constructor(t,n){this.attribute=n,this.property=t}}ln.prototype.attribute="";ln.prototype.booleanish=!1;ln.prototype.boolean=!1;ln.prototype.commaOrSpaceSeparated=!1;ln.prototype.commaSeparated=!1;ln.prototype.defined=!1;ln.prototype.mustUseProperty=!1;ln.prototype.number=!1;ln.prototype.overloadedBoolean=!1;ln.prototype.property="";ln.prototype.spaceSeparated=!1;ln.prototype.space=void 0;let tC=0;const ge=gs(),ut=gs(),Rh=gs(),K=gs(),_e=gs(),Zi=gs(),un=gs();function gs(){return 2**++tC}const zh=Object.freeze(Object.defineProperty({__proto__:null,boolean:ge,booleanish:ut,commaOrSpaceSeparated:un,commaSeparated:Zi,number:K,overloadedBoolean:Rh,spaceSeparated:_e},Symbol.toStringTag,{value:"Module"})),Gc=Object.keys(zh);class gp extends ln{constructor(t,n,r,i){let s=-1;if(super(t,n),$g(this,"space",i),typeof r=="number")for(;++s<Gc.length;){const l=Gc[s];$g(this,Gc[s],(r&zh[l])===zh[l])}}}gp.prototype.defined=!0;function $g(e,t,n){n&&(e[t]=n)}function bl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new gp(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Mh(r)]=r,n[Mh(s.attribute)]=r}return new Va(t,n,e.space)}const j0=bl({properties:{ariaActiveDescendant:null,ariaAtomic:ut,ariaAutoComplete:null,ariaBusy:ut,ariaChecked:ut,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:_e,ariaCurrent:null,ariaDescribedBy:_e,ariaDetails:null,ariaDisabled:ut,ariaDropEffect:_e,ariaErrorMessage:null,ariaExpanded:ut,ariaFlowTo:_e,ariaGrabbed:ut,ariaHasPopup:null,ariaHidden:ut,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:_e,ariaLevel:K,ariaLive:null,ariaModal:ut,ariaMultiLine:ut,ariaMultiSelectable:ut,ariaOrientation:null,ariaOwns:_e,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:ut,ariaReadOnly:ut,ariaRelevant:null,ariaRequired:ut,ariaRoleDescription:_e,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:ut,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function N0(e,t){return t in e?e[t]:t}function S0(e,t){return N0(e,t.toLowerCase())}const nC=bl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Zi,acceptCharset:_e,accessKey:_e,action:null,allow:null,allowFullScreen:ge,allowPaymentRequest:ge,allowUserMedia:ge,alpha:ge,alt:null,as:null,async:ge,autoCapitalize:null,autoComplete:_e,autoFocus:ge,autoPlay:ge,blocking:_e,capture:null,charSet:null,checked:ge,cite:null,className:_e,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:ut,controls:ge,controlsList:_e,coords:K|Zi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ge,defer:ge,dir:null,dirName:null,disabled:ge,download:Rh,draggable:ut,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ge,formTarget:null,headers:_e,height:K,hidden:Rh,high:K,href:null,hrefLang:null,htmlFor:_e,httpEquiv:_e,id:null,imageSizes:null,imageSrcSet:null,inert:ge,inputMode:null,integrity:null,is:null,isMap:ge,itemId:null,itemProp:_e,itemRef:_e,itemScope:ge,itemType:_e,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ge,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:ge,muted:ge,name:null,nonce:null,noModule:ge,noValidate:ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ge,optimum:K,pattern:null,ping:_e,placeholder:null,playsInline:ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ge,referrerPolicy:null,rel:_e,required:ge,reversed:ge,rows:K,rowSpan:K,sandbox:_e,scope:null,scoped:ge,seamless:ge,selected:ge,shadowRootClonable:ge,shadowRootCustomElementRegistry:ge,shadowRootDelegatesFocus:ge,shadowRootMode:null,shadowRootSerializable:ge,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:ut,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:ge,useMap:null,value:ut,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:_e,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ge,declare:ge,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:ge,noHref:ge,noShade:ge,noWrap:ge,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:ut,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ge,disablePictureInPicture:ge,disableRemotePlayback:ge,exportParts:Zi,part:_e,prefix:null,property:null,results:K,security:null,unselectable:null},space:"html",transform:S0}),rC=bl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:un,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:_e,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Zi,g2:Zi,glyphName:Zi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:un,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:_e,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:un,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:un,rev:un,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:un,requiredFeatures:un,requiredFonts:un,requiredFormats:un,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:un,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:un,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:un,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:N0}),C0=bl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),E0=bl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:S0}),P0=bl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iC={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},sC=/[A-Z]/g,qg=/-[a-z]/g,lC=/^data[-\w.:]+$/i;function aC(e,t){const n=Mh(t);let r=t,i=ln;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&lC.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(qg,uC);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!qg.test(s)){let l=s.replace(sC,oC);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=gp}return new i(r,t)}function oC(e){return"-"+e.toLowerCase()}function uC(e){return e.charAt(1).toUpperCase()}const cC=b0([j0,nC,C0,E0,P0],"html"),xp=b0([j0,rC,C0,E0,P0],"svg");function dC(e){return e.join(" ").trim()}var Bg=/\/\*(?:[^*]|\*(?!\/))*\*\//g,hC=/\n/g,fC=/^\s*/,pC=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,mC=/^:\s*/,gC=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,xC=/^[;\s]*/,yC=`
474
474
  `,Ug="/",Hg="*",Ol="",vC="comment",wC="declaration";function kC(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var g=m.match(hC);g&&(n+=g.length);var k=m.lastIndexOf(yC);r=~k?m.length-k:r+m.length}function s(){var m={line:n,column:r};return function(g){return g.position=new l(m),c(),g}}function l(m){this.start=m,this.end={line:n,column:r},this.source=t.source}l.prototype.content=e;function o(m){var g=new Error(t.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=t.source,g.line=n,g.column=r,g.source=e,!t.silent)throw g}function u(m){var g=m.exec(e);if(g){var k=g[0];return i(k),e=e.slice(k.length),g}}function c(){u(fC)}function d(m){for(var g;g=h();)m.push(g);return m}function h(){var m=s();if(!(Ug!=e.charAt(0)||Hg!=e.charAt(1))){for(var g=2;Ol!=e.charAt(g)&&(Hg!=e.charAt(g)||Ug!=e.charAt(g+1));)++g;if(g+=2,Ol===e.charAt(g-1))return o("End of comment missing");var k=e.slice(2,g-2);return r+=2,i(k),e=e.slice(g),r+=2,m({type:vC,comment:k})}}function p(){var m=s(),g=u(pC);if(g){if(h(),!u(mC))return o("property missing ':'");var k=u(gC),y=m({type:wC,property:g[0].replace(Bg,Ol).trim(),value:k?k[0].replace(Bg,Ol).trim():Ol});return u(xC),y}}function f(){var m=[];d(m);for(var g;g=p();)m.push(g),d(m);return m}return c(),f()}function bC(e,t){let n=null;if(!e||typeof e!="string")return n;const r=kC(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:l,value:o}=s;i?t(l,o,s):o&&(n=n??{},n[l]=o)}),n}const T0=L0("end"),yp=L0("start");function L0(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function jC(e){const t=yp(e),n=T0(e);if(t&&n)return{start:t,end:n}}function na(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Wg(e.position):"start"in e||"end"in e?Wg(e):"line"in e||"column"in e?Ah(e):""}function Ah(e){return Vg(e&&e.line)+":"+Vg(e&&e.column)}function Wg(e){return Ah(e&&e.start)+"-"+Ah(e&&e.end)}function Vg(e){return e&&typeof e=="number"?e:1}class Ot extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},l=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(l=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?s.ruleId=r:(s.source=r.slice(0,u),s.ruleId=r.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=na(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=l&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ot.prototype.file="";Ot.prototype.name="";Ot.prototype.reason="";Ot.prototype.message="";Ot.prototype.stack="";Ot.prototype.column=void 0;Ot.prototype.line=void 0;Ot.prototype.ancestors=void 0;Ot.prototype.cause=void 0;Ot.prototype.fatal=void 0;Ot.prototype.place=void 0;Ot.prototype.ruleId=void 0;Ot.prototype.source=void 0;const vp={}.hasOwnProperty,NC=new Map,SC=/[A-Z]/g,CC=/-([a-z])/g,EC=new Set(["table","tbody","thead","tfoot","tr"]),PC=new Set(["td","th"]),M0="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function TC(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=DC(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=FC(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xp:cC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=R0(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function R0(e,t,n){if(t.type==="element")return LC(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return MC(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return zC(e,t,n);if(t.type==="mdxjsEsm")return RC(e,t);if(t.type==="root")return AC(e,t,n);if(t.type==="text")return IC(e,t)}function LC(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xp,e.schema=i),e.ancestors.push(t);const s=A0(e,t.tagName,!1),l=OC(e,t);let o=kp(e,t);return EC.has(t.tagName)&&(o=o.filter(function(u){return typeof u=="string"?!eC(u):!0})),z0(e,l,s,t),wp(l,o),e.ancestors.pop(),e.schema=r,e.create(t,s,l,n)}function MC(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Ea(e,t.position)}function RC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ea(e,t.position)}function zC(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xp,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:A0(e,t.name,!0),l=_C(e,t),o=kp(e,t);return z0(e,l,s,t),wp(l,o),e.ancestors.pop(),e.schema=r,e.create(t,s,l,n)}function AC(e,t,n){const r={};return wp(r,kp(e,t)),e.create(t,e.Fragment,r,n)}function IC(e,t){return t.value}function z0(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function FC(e,t,n){return r;function r(i,s,l,o){const c=Array.isArray(l.children)?n:t;return o?c(s,l,o):c(s,l)}}function DC(e,t){return n;function n(r,i,s,l){const o=Array.isArray(s.children),u=yp(r);return t(i,s,l,o,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function OC(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&vp.call(t.properties,i)){const s=$C(e,i,t.properties[i]);if(s){const[l,o]=s;e.tableCellAlignToStyle&&l==="align"&&typeof o=="string"&&PC.has(t.tagName)?r=o:n[l]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function _C(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const l=s.expression;l.type;const o=l.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Ea(e,t.position);else{const{name:i}=r;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else Ea(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function kp(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:NC;for(;++r<t.children.length;){const s=t.children[r];let l;if(e.passKeys){const u=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(u){const c=i.get(u)||0;l=u+"-"+c,i.set(u,c+1)}}const o=R0(e,s,l);o!==void 0&&n.push(o)}return n}function $C(e,t,n){if(n==null||typeof n=="number"&&Number.isNaN(n))return;const r=aC(e.schema,t);return Array.isArray(n)&&(n=r.commaSeparated?GS(n):dC(n)),r.property==="style"?["style",typeof n=="object"?e.stylePropertyNameCase==="dom"?n:BC(n):qC(e,String(n))]:[e.elementAttributeNameCase==="react"&&r.space?iC[r.property]||r.property:r.attribute,n]}function qC(e,t){const n={};try{bC(t,function(r,i){if(r&&i){let s=r;s.slice(0,2)!=="--"&&(s=s.toLowerCase(),e.stylePropertyNameCase==="dom"&&(s.slice(0,4)==="-ms-"&&(s=s.slice(1)),s=s.replace(CC,WC))),n[s]=i}})}catch(r){if(e.ignoreInvalidStyle)return{};const i=r,s=new Ot("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=M0+"#cannot-parse-style-attribute",s}return n}function A0(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,l;for(;++s<i.length;){const o=Og(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};l=l?{type:"MemberExpression",object:l,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=l}else r=Og(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return vp.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ea(e)}function Ea(e,t){const n=new Ot("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=M0+"#cannot-handle-mdx-estrees-without-createevaluater",n}function BC(e){const t={};let n;for(n in e)vp.call(e,n)&&(t[UC(n)]=e[n]);return t}function UC(e){if(e.slice(0,2)==="--")return e;let t=e.replace(SC,HC);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function HC(e){return"-"+e.toLowerCase()}function WC(e,t){return t.toUpperCase()}const Yc={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},VC={};function rc(e,t){const n=VC,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return I0(e,r,i)}function I0(e,t,n){if(QC(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Qg(e.children,t,n)}return Array.isArray(e)?Qg(e,t,n):""}function Qg(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=I0(e[i],t,n);return r.join("")}function QC(e){return!!(e&&typeof e=="object")}const Kg=document.createElement("i");function bp(e){const t="&"+e+";";Kg.innerHTML=t;const n=Kg.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Wn(e,t,n,r){const i=e.length;let s=0,l;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);s<r.length;)l=r.slice(s,s+1e4),l.unshift(t,0),e.splice(...l),s+=1e4,t+=1e4}function En(e,t){return e.length>0?(Wn(e,e.length,0,t),e):t}const Gg={}.hasOwnProperty;function F0(e){const t={};let n=-1;for(;++n<e.length;)KC(t,e[n]);return t}function KC(e,t){let n;for(n in t){const i=(Gg.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let l;if(s)for(l in s){Gg.call(i,l)||(i[l]=[]);const o=s[l];GC(i[l],Array.isArray(o)?o:o?[o]:[])}}}function GC(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Wn(e,0,0,r)}function D0(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Vn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const St=Ei(/[A-Za-z]/),Ct=Ei(/[\dA-Za-z]/),YC=Ei(/[#-'*+\--9=?A-Z^-~]/);function bu(e){return e!==null&&(e<32||e===127)}const Ih=Ei(/\d/),XC=Ei(/[\dA-Fa-f]/),O0=Ei(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function $e(e){return e!==null&&(e<0||e===32)}function Ne(e){return e===-2||e===-1||e===32}const ic=Ei(new RegExp("\\p{P}|\\p{S}","u")),ds=Ei(/\s/);function Ei(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function jl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let l="";if(s===37&&Ct(e.charCodeAt(n+1))&&Ct(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(l=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(l=String.fromCharCode(s,o),i=1):l="�"}else l=String.fromCharCode(s);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+i+1,l=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ae(e,t,n,r){const i=r?r-1:1/0;let s=0;return l;function l(u){return Ne(u)?(e.enter(n),o(u)):t(u)}function o(u){return Ne(u)&&s++<i?(e.consume(u),o):(e.exit(n),t(u))}}function _0(e,t,n,r,i,s){let l=0;return o;function o(d){return Ne(d)?(e.enter(r),u(d)):c(d)}function u(d){return Ne(d)&&l<s?(e.consume(d),l++,u):(e.exit(r),c(d))}function c(d){return l>=i?t(d):n(d)}}const JC={tokenize:ZC};function ZC(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ae(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,l(o)}function l(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return he(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),l)}}let ju=class{constructor(){this.index=new Map,this.map=[]}add(t,n,r){Yg(this,t,n,r,!1)}addBefore(t,n,r){Yg(this,t,n,r,!0)}consume(t){if(this.map.sort(function(s,l){return s[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0,this.index.clear()}};function Yg(e,t,n,r,i){if(n===0&&r.length===0)return;const s=e.index.get(t);if(s){s[1]+=n,i?(r.push(...s[2]),s[2]=r):s[2].push(...r);return}const l=[t,n,r];e.map.push(l),e.index.set(t,l)}const e3={tokenize:t3},Xg={tokenize:n3};function t3(e){const t=this,n=[];let r=0,i,s,l;return o;function o(v){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,u,c)(v)}return c(v)}function u(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const j=t.events.length;let E=j,w;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){w=t.events[E][1].end;break}y(r);let N=j;for(;N<t.events.length;)t.events[N][1].end={...w},N++;const M=new ju;return M.add(E+1,0,t.events.slice(j)),M.add(j,N-j,[]),M.consume(t.events),c(v)}return o(v)}function c(v){if(r===n.length){if(!i)return p(v);if(i.currentConstruct&&i.currentConstruct.concrete)return m(v);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Xg,d,h)(v)}function d(v){return i&&x(),y(r),p(v)}function h(v){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,m(v)}function p(v){return t.containerState={},e.attempt(Xg,f,m)(v)}function f(v){return r++,n.push([t.currentConstruct,t.containerState]),p(v)}function m(v){if(v===null){i&&x(),y(0),e.consume(v);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),g(v)}function g(v){if(v===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return he(v)?(e.consume(v),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(v),g)}function k(v,j){const E=t.sliceStream(v);if(j&&E.push(null),v.previous=s,s&&(s.next=v),s=v,i.defineSkip(v.start),i.write(E),t.parser.lazy[v.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<l&&(!i.events[w][1].end||i.events[w][1].end.offset>l))return;const N=t.events.length;let M=N,F,C;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(F){C=t.events[M][1].end;break}F=!0}for(y(r),w=N;w<t.events.length;)t.events[w][1].end={...C},w++;const O=new ju;O.add(M+1,0,t.events.slice(N)),O.add(N,w-N,[]),O.consume(t.events)}}function y(v){let j=n.length;for(;j-- >v;){const E=n[j];t.containerState=E[1],E[0].exit.call(t,e)}n.length=v}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function n3(e,t,n){return Ae(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wi(e){if(e===null||$e(e)||ds(e))return 1;if(ic(e))return 2}function sc(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Fh={name:"attention",resolveAll:r3,tokenize:i3};function r3(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;const s=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,l={...e[i][1].end},o={...e[n][1].start};Jg(l,-s),Jg(o,s);const u={type:s>1?"strongSequence":"emphasisSequence",start:l,end:{...e[i][1].end}},c={type:s>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:o},d={type:s>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},h={type:s>1?"strong":"emphasis",start:{...u.start},end:{...c.end}};e[i][1].end={...u.start},e[n][1].start={...c.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=En(r,[["enter",e[i][1],t],["exit",e[i][1],t]])),r=En(r,[["enter",h,t],["enter",u,t],["exit",u,t],["enter",d,t]]),r=En(r,sc(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=En(r,[["exit",d,t],["enter",c,t],["exit",c,t],["exit",h,t]]);let p=0;e[n][1].end.offset-e[n][1].start.offset&&(p=2,r=En(r,[["enter",e[n][1],t],["exit",e[n][1],t]])),Wn(e,i-1,n-i+3,r),n=i+r.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function i3(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wi(r);let s;return l;function l(u){return s=u,e.enter("attentionSequence"),o(u)}function o(u){if(u===s)return e.consume(u),o;const c=e.exit("attentionSequence"),d=wi(u),h=!d||d===2&&i||n.includes(u)&&u!==42&&u!==95,p=!i||i===2&&d||n.includes(r)&&r!==42&&r!==95;return c._open=!!(s===42?h:h&&(i||!p)),c._close=!!(s===42?p:p&&(d||!h)),t(u)}}function Jg(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const s3={name:"autolink",tokenize:l3};function l3(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(f){return St(f)?(e.consume(f),l):f===64?n(f):c(f)}function l(f){return f===43||f===45||f===46||Ct(f)?(r=1,o(f)):c(f)}function o(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||Ct(f))&&r++<32?(e.consume(f),o):(r=0,c(f))}function u(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||bu(f)?n(f):(e.consume(f),u)}function c(f){return f===64?(e.consume(f),d):YC(f)?(e.consume(f),c):n(f)}function d(f){return Ct(f)?h(f):n(f)}function h(f){return f===46?(e.consume(f),r=0,d):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):p(f)}function p(f){if((f===45||Ct(f))&&r++<63){const m=f===45?p:h;return e.consume(f),m}return n(f)}}const Qa={partial:!0,tokenize:a3};function a3(e,t,n){return r;function r(s){return Ne(s)?Ae(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||he(s)?t(s):n(s)}}const $0={continuation:{tokenize:u3},exit:c3,name:"blockQuote",tokenize:o3};function o3(e,t,n){const r=this;return i;function i(l){if(l===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),s}return n(l)}function s(l){return Ne(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function u3(e,t,n){const r=this;return i;function i(l){return Ne(l)?Ae(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):s(l)}function s(l){return e.attempt($0,t,n)(l)}}function c3(e){e.exit("blockQuote")}const q0={name:"characterEscape",tokenize:d3};function d3(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return O0(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const B0={name:"characterReference",tokenize:h3};function h3(e,t,n){const r=this;let i=0,s,l;return o;function o(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),u}function u(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,l=Ct,d(h))}function c(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,l=XC,d):(e.enter("characterReferenceValue"),s=7,l=Ih,d(h))}function d(h){if(h===59&&i){const p=e.exit("characterReferenceValue");return l===Ct&&!bp(r.sliceSerialize(p))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(h)&&i++<s?(e.consume(h),d):n(h)}}const Dh={partial:!0,tokenize:f3};function f3(e,t,n){const r=this;return i;function i(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s)}function s(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const Zg={concrete:!0,name:"codeFenced",tokenize:p3};function p3(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,l=0,o;return u;function u(w){return c(w)}function c(w){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,o=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===o?(l++,e.consume(w),d):l<3?n(w):(e.exit("codeFencedFenceSequence"),Ne(w)?Ae(e,h,"whitespace")(w):h(w))}function h(w){return w===null||he(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Dh,g,j)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(w)):Ne(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ae(e,f,"whitespace")(w)):w===96&&w===o?n(w):(e.consume(w),p)}function f(w){return w===null||he(w)?h(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(w)):w===96&&w===o?n(w):(e.consume(w),m)}function g(w){return e.attempt(i,j,k)(w)}function k(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y}function y(w){return s>0&&Ne(w)?Ae(e,x,"linePrefix",s+1)(w):x(w)}function x(w){return w===null||he(w)?e.check(Dh,g,j)(w):(e.enter("codeFlowValue"),v(w))}function v(w){return w===null||he(w)?(e.exit("codeFlowValue"),x(w)):(e.consume(w),v)}function j(w){return e.exit("codeFenced"),t(w)}function E(w,N,M){let F=0;return C;function C(q){return w.enter("lineEnding"),w.consume(q),w.exit("lineEnding"),O}function O(q){return w.enter("codeFencedFence"),Ne(q)?Ae(w,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):A(q)}function A(q){return q===o?(w.enter("codeFencedFenceSequence"),V(q)):M(q)}function V(q){return q===o?(F++,w.consume(q),V):F>=l?(w.exit("codeFencedFenceSequence"),Ne(q)?Ae(w,U,"whitespace")(q):U(q)):M(q)}function U(q){return q===null||he(q)?(w.exit("codeFencedFence"),N(q)):M(q)}}}const Xc={name:"codeIndented",tokenize:g3},m3={partial:!0,tokenize:x3};function g3(e,t,n){return r;function r(o){return e.enter("codeIndented"),_0(e,i,n,"linePrefix",4,4)(o)}function i(o){return o===null?l(o):he(o)?e.attempt(m3,i,l)(o):(e.enter("codeFlowValue"),s(o))}function s(o){return o===null||he(o)?(e.exit("codeFlowValue"),i(o)):(e.consume(o),s)}function l(o){return e.exit("codeIndented"),t(o)}}function x3(e,t,n){const r=this;return i;function i(l){return r.parser.lazy[r.now().line]?n(l):he(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):_0(e,t,s,"linePrefix",4,4)(l)}function s(l){return he(l)?i(l):n(l)}}const y3={name:"codeText",previous:w3,resolve:v3,tokenize:k3};function v3(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function w3(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function k3(e,t,n){let r=0,i,s;return l;function l(h){return e.enter("codeText"),e.enter("codeTextSequence"),o(h)}function o(h){return h===96?(e.consume(h),r++,o):(e.exit("codeTextSequence"),u(h))}function u(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),u):h===96?(s=e.enter("codeTextSequence"),i=0,d(h)):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||he(h)?(e.exit("codeTextData"),u(h)):(e.consume(h),c)}function d(h){return h===96?(e.consume(h),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(s.type="codeTextData",c(h))}}class b3{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&_l(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),_l(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),_l(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);_l(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);_l(this.left,n.reverse())}}}function _l(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function U0(e){const t={};let n=-1,r,i,s,l,o,u,c;const d=new b3(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,j3(d,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(l=d.get(s),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),l[1].type="lineEnding",i=s);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},o=d.slice(i,n),o.unshift(r),d.splice(i,n-i+1,o))}}return Wn(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function j3(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const o=l.events,u=[],c={};let d,h,p=-1,f=n,m=0,g=0;const k=[g];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),h&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(d),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(g=p+1,k.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):k.pop(),p=k.length;p--;){const y=o.slice(k[p],k[p+1]),x=s.pop();u.push([x,x+y.length-1]),e.splice(x,2,y)}for(u.reverse(),p=-1;++p<u.length;)c[m+u[p][0]]=m+u[p][1],m+=u[p][1]-u[p][0]-1;return c}const N3={resolve:C3,tokenize:E3},S3={partial:!0,tokenize:P3};function C3(e){return U0(e),e}function E3(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):he(o)?e.check(S3,l,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function l(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function P3(e,t,n){const r=this;return i;function i(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ae(e,s,"linePrefix")}function s(l){if(l===null||he(l))return n(l);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function H0(e,t,n,r,i,s,l,o,u){const c=u||Number.POSITIVE_INFINITY;let d=0;return h;function h(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),p):y===null||y===32||y===41||bu(y)?n(y):(e.enter(r),e.enter(l),e.enter(o),e.enter("chunkString",{contentType:"string"}),g(y))}function p(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),f(y))}function f(y){return y===62?(e.exit("chunkString"),e.exit(o),p(y)):y===null||y===60||he(y)?n(y):(e.consume(y),y===92?m:f)}function m(y){return y===60||y===62||y===92?(e.consume(y),f):f(y)}function g(y){return!d&&(y===null||y===41||$e(y))?(e.exit("chunkString"),e.exit(o),e.exit(l),e.exit(r),t(y)):d<c&&y===40?(e.consume(y),d++,g):y===41?(e.consume(y),d--,g):y===null||y===32||y===40||bu(y)?n(y):(e.consume(y),y===92?k:g)}function k(y){return y===40||y===41||y===92?(e.consume(y),g):g(y)}}function W0(e,t,n,r,i,s){const l=this;let o=0,u;return c;function c(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),d}function d(f){return o>999||f===null||f===91||f===93&&!u||f===94&&!o&&"_hiddenFootnoteSupport"in l.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):he(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||he(f)||o++>999?(e.exit("chunkString"),d(f)):(e.consume(f),u||(u=!Ne(f)),f===92?p:h)}function p(f){return f===91||f===92||f===93?(e.consume(f),o++,h):h(f)}}function V0(e,t,n,r,i,s){let l;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),l=p===40?41:p,u):n(p)}function u(p){return p===l?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===l?(e.exit(s),u(l)):p===null?n(p):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ae(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===l||p===null||he(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?h:d)}function h(p){return p===l||p===92?(e.consume(p),d):d(p)}}function ra(e,t){let n;return r;function r(i){return he(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ne(i)?Ae(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const T3={name:"definition",tokenize:M3},L3={partial:!0,tokenize:R3};function M3(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),l(f)}function l(f){return W0.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function o(f){return i=Vn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),u):n(f)}function u(f){return $e(f)?ra(e,c)(f):c(f)}function c(f){return H0(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function d(f){return e.attempt(L3,h,h)(f)}function h(f){return Ne(f)?Ae(e,p,"whitespace")(f):p(f)}function p(f){return f===null||he(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function R3(e,t,n){return r;function r(o){return $e(o)?ra(e,i)(o):n(o)}function i(o){return V0(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ne(o)?Ae(e,l,"whitespace")(o):l(o)}function l(o){return o===null||he(o)?t(o):n(o)}}const z3={name:"hardBreakEscape",tokenize:A3};function A3(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return he(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const I3={name:"headingAtx",resolve:F3,tokenize:D3};function F3(e,t){let n=e.length-2,r=3;if(e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r){const i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"};Wn(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])}return e}function D3(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),l(d)}function l(d){return d===35&&r++<6?(e.consume(d),l):d===null||$e(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),u(d)):d===null||he(d)?(e.exit("atxHeading"),t(d)):Ne(d)?Ae(e,o,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function u(d){return d===35?(e.consume(d),u):(e.exit("atxHeadingSequence"),o(d))}function c(d){return d===null||d===35||$e(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),c)}}const Q0=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Oh=["pre","script","style","textarea"],O3={concrete:!0,name:"htmlFlow",resolveTo:$3,tokenize:q3},_3={partial:!0,tokenize:B3};function $3(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function q3(e,t,n){const r=this;let i,s,l,o,u;return c;function c(P){return d(P)}function d(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),h}function h(P){return P===33?(e.consume(P),p):P===47?(e.consume(P),s=!0,g):P===63?(e.consume(P),i=3,r.interrupt?t:S):St(P)?(e.consume(P),l=String.fromCharCode(P),k):n(P)}function p(P){return P===45?(e.consume(P),i=2,f):P===91?(e.consume(P),i=5,o=0,m):St(P)?(e.consume(P),i=4,r.interrupt?t:S):n(P)}function f(P){return P===45?(e.consume(P),r.interrupt?t:S):n(P)}function m(P){const ve="CDATA[";return P===ve.charCodeAt(o++)?(e.consume(P),o===ve.length?r.interrupt?t:A:m):n(P)}function g(P){return St(P)?(e.consume(P),l=String.fromCharCode(P),k):n(P)}function k(P){if(P===null||P===47||P===62||$e(P)){const ve=P===47,Le=l.toLowerCase();return!ve&&!s&&Oh.includes(Le)?(i=1,r.interrupt?t(P):A(P)):Q0.includes(l.toLowerCase())?(i=6,ve?(e.consume(P),y):r.interrupt?t(P):A(P)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(P):s?x(P):v(P))}return P===45||Ct(P)?(e.consume(P),l+=String.fromCharCode(P),k):n(P)}function y(P){return P===62?(e.consume(P),r.interrupt?t:A):n(P)}function x(P){return Ne(P)?(e.consume(P),x):C(P)}function v(P){return P===47?(e.consume(P),C):P===58||P===95||St(P)?(e.consume(P),j):Ne(P)?(e.consume(P),v):C(P)}function j(P){return P===45||P===46||P===58||P===95||Ct(P)?(e.consume(P),j):E(P)}function E(P){return P===61?(e.consume(P),w):Ne(P)?(e.consume(P),E):v(P)}function w(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),u=P,N):Ne(P)?(e.consume(P),w):M(P)}function N(P){return P===u?(e.consume(P),u=null,F):P===null||he(P)?n(P):(e.consume(P),N)}function M(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||$e(P)?E(P):(e.consume(P),M)}function F(P){return P===47||P===62||Ne(P)?v(P):n(P)}function C(P){return P===62?(e.consume(P),O):n(P)}function O(P){return P===null||he(P)?A(P):Ne(P)?(e.consume(P),O):n(P)}function A(P){return P===45&&i===2?(e.consume(P),G):P===60&&i===1?(e.consume(P),X):P===62&&i===4?(e.consume(P),D):P===63&&i===3?(e.consume(P),S):P===93&&i===5?(e.consume(P),W):he(P)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(_3,te,V)(P)):P===null||he(P)?(e.exit("htmlFlowData"),V(P)):(e.consume(P),A)}function V(P){return e.check(Dh,U,te)(P)}function U(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),q}function q(P){return P===null||he(P)?V(P):(e.enter("htmlFlowData"),A(P))}function G(P){return P===45?(e.consume(P),S):A(P)}function X(P){return P===47?(e.consume(P),l="",z):A(P)}function z(P){if(P===62){const ve=l.toLowerCase();return Oh.includes(ve)?(e.consume(P),D):A(P)}return St(P)&&l.length<8?(e.consume(P),l+=String.fromCharCode(P),z):A(P)}function W(P){return P===93?(e.consume(P),S):A(P)}function S(P){return P===62?(e.consume(P),D):P===45&&i===2?(e.consume(P),S):A(P)}function D(P){return P===null||he(P)?(e.exit("htmlFlowData"),te(P)):(e.consume(P),D)}function te(P){return e.exit("htmlFlow"),t(P)}}function B3(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Qa,t,n)}}const U3={name:"htmlText",tokenize:H3};function H3(e,t,n){const r=this;let i,s,l;return o;function o(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),u}function u(S){return S===33?(e.consume(S),c):S===47?(e.consume(S),E):S===63?(e.consume(S),v):St(S)?(e.consume(S),M):n(S)}function c(S){return S===45?(e.consume(S),d):S===91?(e.consume(S),s=0,m):St(S)?(e.consume(S),x):n(S)}function d(S){return S===45?(e.consume(S),f):n(S)}function h(S){return S===null?n(S):S===45?(e.consume(S),p):he(S)?(l=h,X(S)):(e.consume(S),h)}function p(S){return S===45?(e.consume(S),f):h(S)}function f(S){return S===62?G(S):S===45?p(S):h(S)}function m(S){const D="CDATA[";return S===D.charCodeAt(s++)?(e.consume(S),s===D.length?g:m):n(S)}function g(S){return S===null?n(S):S===93?(e.consume(S),k):he(S)?(l=g,X(S)):(e.consume(S),g)}function k(S){return S===93?(e.consume(S),y):g(S)}function y(S){return S===62?G(S):S===93?(e.consume(S),y):g(S)}function x(S){return S===null||S===62?G(S):he(S)?(l=x,X(S)):(e.consume(S),x)}function v(S){return S===null?n(S):S===63?(e.consume(S),j):he(S)?(l=v,X(S)):(e.consume(S),v)}function j(S){return S===62?G(S):v(S)}function E(S){return St(S)?(e.consume(S),w):n(S)}function w(S){return S===45||Ct(S)?(e.consume(S),w):N(S)}function N(S){return he(S)?(l=N,X(S)):Ne(S)?(e.consume(S),N):G(S)}function M(S){return S===45||Ct(S)?(e.consume(S),M):S===47||S===62||$e(S)?F(S):n(S)}function F(S){return S===47?(e.consume(S),G):S===58||S===95||St(S)?(e.consume(S),C):he(S)?(l=F,X(S)):Ne(S)?(e.consume(S),F):G(S)}function C(S){return S===45||S===46||S===58||S===95||Ct(S)?(e.consume(S),C):O(S)}function O(S){return S===61?(e.consume(S),A):he(S)?(l=O,X(S)):Ne(S)?(e.consume(S),O):F(S)}function A(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),i=S,V):he(S)?(l=A,X(S)):Ne(S)?(e.consume(S),A):(e.consume(S),U)}function V(S){return S===i?(e.consume(S),i=void 0,q):S===null?n(S):he(S)?(l=V,X(S)):(e.consume(S),V)}function U(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||$e(S)?F(S):(e.consume(S),U)}function q(S){return S===47||S===62||$e(S)?F(S):n(S)}function G(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function X(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),z}function z(S){return Ne(S)?Ae(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):W(S)}function W(S){return e.enter("htmlTextData"),l(S)}}const jp={name:"labelEnd",resolveAll:K3,resolveTo:G3,tokenize:Y3},W3={tokenize:X3},V3={tokenize:J3},Q3={tokenize:Z3};function K3(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Wn(e,0,e.length,n),e}function G3(e,t){let n=e.length,r=0,i,s,l;for(;n--;){const d=e[n][1];if(i){if(d.type==="link"||d.type==="labelLink"&&d._inactive)break;e[n][0]==="enter"&&d.type==="labelLink"&&(d._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(d.type==="labelImage"||d.type==="labelLink")&&!d._balanced&&(i=n,d.type!=="labelLink")){r=2;break}}else d.type==="labelEnd"&&(s=n)}const o={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[s][1].end}},c={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[s-2][1].start}};return l=[["enter",o,t],["enter",u,t]],l=En(l,e.slice(i+1,i+r+3)),l=En(l,[["enter",c,t]]),l=En(l,sc(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),l=En(l,[["exit",c,t],e[s-2],e[s-1],["exit",u,t]]),l=En(l,e.slice(s+1)),l=En(l,[["exit",o,t]]),Wn(e,i,e.length,l),e}function Y3(e,t,n){const r=this,i=r._labelStarts;let s,l;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();s=i[i.length-1]}return o;function o(p){return s?s._inactive?h(p):(l=r.parser.defined.includes(Vn(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),u):n(p)}function u(p){return p===40?e.attempt(W3,d,l?d:h)(p):p===91?e.attempt(V3,d,l?c:h)(p):l?d(p):h(p)}function c(p){return e.attempt(Q3,d,h)(p)}function d(p){return i.pop(),t(p)}function h(p){return s._balanced=!0,n(p)}}function X3(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return $e(h)?ra(e,s)(h):s(h)}function s(h){return h===41?d(h):H0(e,l,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function l(h){return $e(h)?ra(e,u)(h):d(h)}function o(h){return n(h)}function u(h){return h===34||h===39||h===40?V0(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function c(h){return $e(h)?ra(e,d)(h):d(h)}function d(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function J3(e,t,n){const r=this;return i;function i(o){return W0.call(r,e,s,l,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Vn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function l(o){return n(o)}}function Z3(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const eE={name:"labelStartImage",resolveAll:jp.resolveAll,tokenize:tE};function tE(e,t,n){const r=this;let i;return s;function s(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),i=e.exit("labelImage"),o):n(u)}function o(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(u))}}const nE={name:"labelStartLink",resolveAll:jp.resolveAll,tokenize:rE};function rE(e,t,n){const r=this;let i;return s;function s(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),i=e.exit("labelLink"),l}function l(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(o))}}const Jc={name:"lineEnding",tokenize:iE};function iE(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ae(e,t,"linePrefix")}}const qo={name:"thematicBreak",tokenize:sE};function sE(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),l(c)}function l(c){return i=c,o(c)}function o(c){return c===i?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||he(c))?(e.exit("thematicBreak"),t(c)):n(c)}function u(c){return c===i?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),Ne(c)?Ae(e,o,"whitespace")(c):o(c))}}const Kt={continuation:{tokenize:uE},exit:dE,name:"list",tokenize:oE},lE={partial:!0,tokenize:hE},aE={partial:!0,tokenize:cE};function oE(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,l=0;return o;function o(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Ih(f)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(qo,n,c)(f):c(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(f)}return n(f)}function u(f){return Ih(f)&&++l<10?(e.consume(f),u):(!r.interrupt||l<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),c(f)):n(f)}function c(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(Qa,r.interrupt?n:d,e.attempt(lE,p,h))}function d(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function h(f){return Ne(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function uE(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Qa,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ae(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ne(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(aE,t,l)(o))}function l(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ae(e,e.attempt(Kt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function cE(e,t,n){const r=this;return Ae(e,i,"listItemIndent",r.containerState.size+1);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(s):n(s)}}function dE(e){e.exit(this.containerState.type)}function hE(e,t,n){const r=this;return Ae(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const l=r.events[r.events.length-1];return!Ne(s)&&l&&l[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ex={name:"setextUnderline",resolveTo:fE,tokenize:pE};function fE(e,t){const n=new ju;let r=e.length,i,s,l;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){i=r;break}e[r][1].type==="paragraph"&&(s=r)}else e[r][1].type==="content"&&n.add(r,1,[]),!l&&e[r][1].type==="definition"&&(l=r);const o={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",l?(n.add(s,0,[["enter",o,t]]),n.add(l+1,0,[["exit",e[i][1],t]]),e[i][1].end={...e[l][1].end}):e[i][1]=o,n.add(e.length,0,[["exit",o,t]]),n.consume(e),e}function pE(e,t,n){const r=this;let i;return s;function s(c){let d=r.events.length,h;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){h=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=c,l(c)):n(c)}function l(c){return e.enter("setextHeadingLineSequence"),o(c)}function o(c){return c===i?(e.consume(c),o):(e.exit("setextHeadingLineSequence"),Ne(c)?Ae(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||he(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const mE={tokenize:gE};function gE(e){const t=this,n=e.attempt(Qa,r,e.attempt(this.parser.constructs.flowInitial,i,Ae(e,e.attempt(this.parser.constructs.flow,i,e.attempt(N3,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const xE={resolveAll:G0()},yE=K0("string"),vE=K0("text");function K0(e){return{resolveAll:G0(e==="text"?wE:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,l,o);return l;function l(d){return c(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),u}function u(d){return c(d)?(n.exit("data"),s(d)):(n.consume(d),u)}function c(d){if(d===null)return!0;const h=i[d];let p=-1;if(h)for(;++p<h.length;){const f=h[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function G0(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function wE(e,t){const n=new ju;let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const i=e[r-1][1],s=t.sliceStream(i);let l=s.length,o=-1,u=0,c;for(;l--;){const d=s[l];if(typeof d=="string"){for(o=d.length;d.charCodeAt(o-1)===32;)u++,o--;if(o)break;o=-1}else if(d===-2)c=!0,u++;else if(d!==-1){l++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(u=0),u){const d={type:r===e.length||c||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?o:i.start._bufferIndex+o,_index:i.start._index+l,line:i.end.line,column:i.end.column-u,offset:i.end.offset-u},end:{...i.end}};i.end={...d.start},i.start.offset===i.end.offset?Object.assign(i,d):n.add(r,0,[["enter",d,t],["exit",d,t]])}r++}return n.consume(e),e}const kE={42:Kt,43:Kt,45:Kt,48:Kt,49:Kt,50:Kt,51:Kt,52:Kt,53:Kt,54:Kt,55:Kt,56:Kt,57:Kt,62:$0},bE={91:T3},jE={[-2]:Xc,[-1]:Xc,32:Xc},NE={35:I3,42:qo,45:[ex,qo],60:O3,61:ex,95:qo,96:Zg,126:Zg},SE={38:B0,92:q0},CE={[-5]:Jc,[-4]:Jc,[-3]:Jc,33:eE,38:B0,42:Fh,60:[s3,U3],91:nE,92:[z3,q0],93:jp,95:Fh,96:y3},EE={null:[Fh,xE]},PE={null:[42,95]},TE={null:[]},LE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:PE,contentInitial:bE,disable:TE,document:kE,flow:NE,flowInitial:jE,insideSpan:EE,string:SE,text:CE},Symbol.toStringTag,{value:"Module"}));function ME(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let l=[],o=[];const u={attempt:N(E),check:N(w),consume:x,enter:v,exit:j,interrupt:N(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:f,write:h};let d=t.tokenize.call(c,u);return t.resolveAll&&s.push(t),c;function h(O){return l=En(l,O),k(),l[l.length-1]!==null?[]:(M(t,0),c.events=sc(s,c.events,c),c.events)}function p(O,A){return zE(f(O),A)}function f(O){return RE(l,O)}function m(){const{_bufferIndex:O,_index:A,line:V,column:U,offset:q}=r;return{_bufferIndex:O,_index:A,line:V,column:U,offset:q}}function g(O){i[O.line]=O.column,C()}function k(){for(;r._index<l.length;){const O=l[r._index];if(typeof O=="string"){const A=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===A&&r._bufferIndex<O.length;)y(O.charCodeAt(r._bufferIndex))}else y(O)}}function y(O){d=d(O)}function x(O){he(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,C()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=O}function v(O,A){const V=A||{};return V.type=O,V.start=m(),c.events.push(["enter",V,c]),o.push(V),V}function j(O){const A=o.pop();return A.end=m(),c.events.push(["exit",A,c]),A}function E(O,A){M(O,A.from)}function w(O,A){A.restore()}function N(O,A){return V;function V(U,q,G){let X,z,W,S;return Array.isArray(U)?te(U):"tokenize"in U?te([U]):D(U);function D(we){return Se;function Se(_t){const an=_t!==null&&we[_t],Lt=_t!==null&&we.null,qe=[...Array.isArray(an)?an:an?[an]:[],...Array.isArray(Lt)?Lt:Lt?[Lt]:[]];return te(qe)(_t)}}function te(we){return X=we,z=0,we.length===0?G:P(we[z])}function P(we){return Se;function Se(_t){return S=F(),W=we,we.partial||(c.currentConstruct=we),we.name&&c.parser.constructs.disable.null.includes(we.name)?Le():we.tokenize.call(A?Object.assign(Object.create(c),A):c,u,ve,Le)(_t)}}function ve(we){return O(W,S),q}function Le(we){return S.restore(),++z<X.length?P(X[z]):G}}}function M(O,A){O.resolveAll&&!s.includes(O)&&s.push(O),O.resolve&&Wn(c.events,A,c.events.length-A,O.resolve(c.events.slice(A),c)),O.resolveTo&&(c.events=O.resolveTo(c.events,c))}function F(){const O=m(),A=c.previous,V=c.currentConstruct,U=c.events.length,q=Array.from(o);return{from:U,restore:G};function G(){r=O,c.previous=A,c.currentConstruct=V,c.events.length=U,o=q,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function RE(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let l;if(n===i)l=[e[n].slice(r,s)];else{if(l=e.slice(n,i),r>-1){const o=l[0];typeof o=="string"?l[0]=o.slice(r):l.shift()}s>0&&l.push(e[i].slice(0,s))}return l}function zE(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let l;if(typeof s=="string")l=s;else switch(s){case-5:{l="\r";break}case-4:{l=`
@@ -501,7 +501,7 @@ Error generating stack: `+s.message+`
501
501
  `,...s.current()});const d=c.charCodeAt(0);return(d===9||d===32)&&(c=dw(d)+c.slice(1)),c=c?l+" "+c:l,n.options.closeAtx&&(c+=" "+l),u(),o(),c}pw.peek=mP;function pw(e){return e.value||""}function mP(){return"<"}mw.peek=gP;function mw(e,t,n,r){const i=Lp(n),s=i==='"'?"Quote":"Apostrophe",l=n.enter("image");let o=n.enter("label");const u=n.createTracker(r);let c=u.move("![");return c+=u.move(n.safe(e.alt,{before:c,after:"]",...u.current()})),c+=u.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=u.move("<"),c+=u.move(n.safe(e.url,{before:c,after:">",...u.current()})),c+=u.move(">")):(o=n.enter("destinationRaw"),c+=u.move(n.safe(e.url,{before:c,after:e.title?" ":")",...u.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=u.move(" "+i),c+=u.move(n.safe(e.title,{before:c,after:i,...u.current()})),c+=u.move(i),o()),c+=u.move(")"),l(),c}function gP(){return"!"}gw.peek=xP;function gw(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("![");const c=n.safe(e.alt,{before:u,after:"]",...o.current()});u+=o.move(c+"]["),l();const d=n.stack;n.stack=d.filter(function(p){return p!=="phrasing"}),l=n.enter("reference");const h=n.safe(n.associationId(e),{before:u,after:"]",...o.current()});return l(),n.stack=d,s(),i==="full"||!c||c!==h?u+=o.move(h+"]"):i==="shortcut"?u=u.slice(0,-1):u+=o.move("]"),u}function xP(){return"!"}xw.peek=yP;function xw(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const l=n.unsafe[s],o=n.compilePattern(l);if(!l.atBreak)continue;let u;for(;u=o.exec(r);){let c=u.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(u.index+1)}}return i+r+i}function yP(){return"`"}function yw(e,t){const n=rc(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][+\-.a-z]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}vw.peek=vP;function vw(e,t,n,r){const i=Lp(n),s=i==='"'?"Quote":"Apostrophe",l=n.createTracker(r);if(yw(e,n)){const m=n.stack;n.stack=m.filter(function(y){return y!=="phrasing"});const g=n.enter("autolink");let k=l.move("<");return k+=l.move(n.containerPhrasing(e,{before:k,after:">",...l.current()})),k+=l.move(">"),g(),n.stack=m,k}const o=n.enter("link");let u=n.enter("label"),c=l.move("[");const d=n.containerPhrasing(e,{before:c,after:"](",...l.current()});c+=l.move(d),u(),c+=l.move("](");const h=/[\0- \u007F]/.test(e.url),p=r.before.charAt(r.before.length-1);let f=e.title||void 0;if(!f&&!h&&(p===`
502
502
  `||p==="\r")){let m=0;for(;m<d.length&&d.charCodeAt(m)!==93;)m+=d.charCodeAt(m)===92?2:1;d.charCodeAt(m+1)===58&&(f="")}return!e.url&&typeof f=="string"||h?(u=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(u=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:typeof f=="string"?" ":")",...l.current()}))),u(),typeof f=="string"&&(u=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(f,{before:c,after:i,...l.current()})),c+=l.move(i),u()),c+=l.move(")"),o(),c}function vP(e,t,n){return yw(e,n)?"<":"["}ww.peek=wP;function ww(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("[");const c=n.containerPhrasing(e,{before:u,after:"]",...o.current()});u+=o.move(c+"]["),l();const d=n.stack;n.stack=d.filter(function(p){return p!=="phrasing"}),l=n.enter("reference");const h=n.safe(n.associationId(e),{before:u,after:"]",...o.current()});return l(),n.stack=d,s(),i==="full"||!c||c!==h?u+=o.move(h+"]"):i==="shortcut"?u=u.slice(0,-1):u+=o.move("]"),u}function wP(){return"["}function Ap(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function kP(e){const t=Ap(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function bP(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function kw(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function jP(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let l=e.ordered?bP(n):Ap(n);const o=e.ordered?l==="."?")":".":kP(n);let u=t&&n.bulletLastUsed?l===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((l==="*"||l==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),kw(n)===l&&d){let h=-1;for(;++h<e.children.length;){const p=e.children[h];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(l=o),n.bulletCurrent=l;const c=n.containerFlow(e,r);return n.bulletLastUsed=l,n.bulletCurrent=s,i(),c}function NP(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function SP(e,t,n,r){const i=NP(n);let s=n.bulletCurrent||Ap(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let l=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(l-s.length)),o.shift(l);const u=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),d);return u(),c;function d(h,p,f){return p?(f?"":" ".repeat(l))+h:(f?s:s+" ".repeat(l-s.length))+h}}function CP(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),l=n.containerPhrasing(e,r);return s(),i(),l}function EP(e,t,n,r){if(!e.children.some(function(o){return K5(o)}))return n.containerFlow(e,r);const s=n.enter("phrasing"),l=n.containerPhrasing(e,r);return s(),l}function PP(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ip.attention=bw;Ip.peek=TP;function Ip(e,t,n,r){const i=n.enter("phrasing"),s=Mp(e,bw,n,n.createTracker(r)),l=cc([s],r.before,r.after);return i(),l}function bw(e,t){return{construct:"strong",markers:PP(t)==="*"?["*","_"]:["_","*"],sizes:[2]}}function TP(e,t,n){return n.options.strong||"*"}function LP(e,t,n,r){const i=t?t.children:[],s=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[s+1],beforeNode:i[s-1]})}function MP(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function RP(e,t,n){const r=(kw(n)+(n.options.ruleSpaces?" ":"")).repeat(MP(n));return n.options.ruleSpaces?r.slice(0,-1):r}const jw={blockquote:G5,break:Ex,code:tP,definition:rP,emphasis:zp,hardBreak:Ex,heading:pP,html:pw,image:mw,imageReference:gw,inlineCode:xw,link:vw,linkReference:ww,list:jP,listItem:SP,paragraph:CP,root:EP,strong:Ip,text:LP,thematicBreak:RP};function zP(){return{enter:{table:AP,tableData:Tx,tableHeader:Tx,tableRow:FP},exit:{codeText:DP,table:IP,tableData:ud,tableHeader:ud,tableRow:ud}}}function AP(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[],position:void 0},e),this.data.inTable=!0}function IP(e){this.exit(e),this.data.inTable=void 0}function FP(e){this.enter({type:"tableRow",children:[],position:void 0},e)}function ud(e){this.exit(e)}function Tx(e){this.enter({type:"tableCell",children:[],position:void 0},e)}function DP(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,OP));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function OP(e,t){return t==="|"?t:e}function _P(e){const t=e||{},{tableCellPadding:n,tablePipeAlign:r,stringLength:i}=t,s=n?" ":"|";return{handlers:{inlineCode:p,table:l,tableCell:u,tableRow:o},join:[$P],unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
503
503
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}]};function l(f,m,g,k){const y=d(f,g,k),x=y[0];if(x){let v=f.align?f.align.length:0,j=-1;if(!v)for(;++j<y.length;)y[j].length>v&&(v=y[j].length);for(;x.length<v;)x.push("")}return c(y,f.align)}function o(f,m,g,k){const y=h(f,g,k),x=c([y]);return x.slice(0,x.indexOf(`
504
- `))}function u(f,m,g,k){const y=g.enter("tableCell"),x=g.enter("phrasing"),v=g.containerPhrasing(f,{...k,before:s,after:s});return x(),y(),v}function c(f,m){return V5(f,{align:m,alignDelimiters:r,fillRows:!1,padding:n,stringLength:i})}function d(f,m,g){const{children:k}=f;let y=-1;const x=[],v=m.enter("table");for(;++y<k.length;)x[y]=h(k[y],m,g);return v(),x}function h(f,m,g){const{children:k}=f;let y=-1;const x=[],v=m.enter("tableRow");for(;++y<k.length;)x[y]=u(k[y],f,m,g);return v(),x}function p(f,m,g){const k=jw.inlineCode(f,m,g);if(!g.stack.includes("tableCell"))return k;const y=[];let x=0,v=k.indexOf("|");for(;v!==-1;){let j=v;for(;j>x&&k.charCodeAt(j-1)===92;)j--;y.push(k.slice(x,v)),(v-j)%2===0&&y.push("\\"),x=v,v=k.indexOf("|",v+1)}return y.push(k.slice(x)),y.join("")}}function $P(e,t,n,r){if(e.type==="table"&&n.type==="listItem"&&n.spread===!1&&(t.type==="definition"||t.type==="heading"&&qP(t,r)||t.type==="paragraph"||t.type==="table"))return 1}function qP(e,t){let n=!1;return uc(e,function(r){if(r.type==="break"||"value"in r&&/\r?\n|\r/.test(r.value))return n=!0,sa}),!!((!e.depth||e.depth<3)&&rc(e)&&(t.options.setext||n))}function BP(){return{exit:{taskListCheckValueChecked:Lx,taskListCheckValueUnchecked:Lx,paragraph:HP}}}function UP(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WP}}}function Lx(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HP(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,l;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){l=o;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function WP(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(l);let u=jw.listItem(e,t,n,{...r,...o.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),u;function c(d){return d+l}}function VP(){return[p5(),I5(),_5(),zP(),BP()]}function QP(e){return{extensions:[m5(),F5(e),$5(),_P(e),UP()]}}const KP={tokenize:eT,partial:!0},Nw={tokenize:tT,partial:!0},Sw={tokenize:nT,partial:!0},Cw={tokenize:rT,partial:!0},GP={tokenize:iT,partial:!0},Ew={name:"wwwAutolink",tokenize:JP,previous:Tw},Pw={name:"protocolAutolink",tokenize:ZP,previous:Lw},qr={name:"emailAutolink",tokenize:XP,previous:Mw},gr={};function YP(){return{text:gr}}let Li=48;for(;Li<123;)gr[Li]=qr,Li++,Li===58?Li=65:Li===91&&(Li=97);gr[43]=qr;gr[45]=qr;gr[46]=qr;gr[95]=qr;gr[72]=[qr,Pw];gr[104]=[qr,Pw];gr[87]=[qr,Ew];gr[119]=[qr,Ew];function XP(e,t,n){const r=this;let i,s;return l;function l(h){return!Wh(h)||!Mw.call(r,r.previous)||Fp(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(h))}function o(h){return Wh(h)?(e.consume(h),o):h===64?(e.consume(h),u):n(h)}function u(h){return h===46?e.check(GP,d,c)(h):h===45||h===95||Ct(h)?(s=!0,e.consume(h),u):d(h)}function c(h){return e.consume(h),i=!0,u}function d(h){return s&&i&&St(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function JP(e,t,n){const r=this;return i;function i(l){return l!==87&&l!==119||!Tw.call(r,r.previous)||Fp(r.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(KP,e.attempt(Nw,e.attempt(Sw,s),n),n)(l))}function s(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function ZP(e,t,n){const r=this;let i="",s=!1;return l;function l(h){return(h===72||h===104)&&Lw.call(r,r.previous)&&!Fp(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),o):n(h)}function o(h){if(St(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),o;if(h===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(h),u}return n(h)}function u(h){return h===47?(e.consume(h),s?c:(s=!0,u)):n(h)}function c(h){return h===null||bu(h)||$e(h)||ds(h)||ic(h)?n(h):e.attempt(Nw,e.attempt(Sw,d),n)(h)}function d(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function eT(e,t,n){let r=0;return i;function i(l){return(l===87||l===119)&&r<3?(r++,e.consume(l),i):l===46&&r===3?(e.consume(l),s):n(l)}function s(l){return l===null?n(l):t(l)}}function tT(e,t,n){let r,i,s;return l;function l(c){return c===46||c===95?e.check(Cw,u,o)(c):c===null||$e(c)||ds(c)||c!==45&&ic(c)?u(c):(s=!0,e.consume(c),l)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),l}function u(c){return i||r||!s?n(c):t(c)}}function nT(e,t){let n=0,r=0;return i;function i(l){return l===40?(n++,e.consume(l),i):l===41&&r<n?s(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(Cw,t,s)(l):l===null||$e(l)||ds(l)?t(l):(e.consume(l),i)}function s(l){return l===41&&r++,e.consume(l),i}}function rT(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||$e(o)||ds(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||$e(o)||ds(o)?t(o):r(o)}function s(o){return St(o)?l(o):n(o)}function l(o){return o===59?(e.consume(o),r):St(o)?(e.consume(o),l):n(o)}}function iT(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Ct(s)?n(s):t(s)}}function Tw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||$e(e)}function Lw(e){return!St(e)}function Mw(e){return!(e===47||Wh(e))}function Wh(e){return e===43||e===45||e===46||e===95||Ct(e)}function Fp(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const sT={tokenize:fT,partial:!0};function lT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cT,continuation:{tokenize:dT},exit:hT}},text:{91:{name:"gfmFootnoteCall",tokenize:uT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:aT,resolveTo:oT}}}}function aT(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){l=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return o;function o(u){if(!l||!l._balanced)return n(u);const c=Vn(r.sliceSerialize({start:l.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function oT(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function uT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,l;return o;function o(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),u}function u(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(h){if(s>999||h===93&&!l||h===null||h===91||$e(h))return n(h);if(h===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Vn(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return $e(h)||(l=!0),s++,e.consume(h),h===92?d:c}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function cT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,o;return u;function u(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(l>999||m===93&&!o||m===null||m===91||$e(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return s=Vn(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return $e(m)||(o=!0),l++,e.consume(m),m===92?h:d}function h(m){return m===91||m===92||m===93?(e.consume(m),l++,d):d(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ae(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function dT(e,t,n){return e.check(Qa,t,e.attempt(sT,t,n))}function hT(e){e.exit("gfmFootnoteDefinition")}function fT(e,t,n){const r=this;return Ae(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(s):n(s)}}function pT(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(l,o){let u=-1;for(;++u<l.length;)if(l[u][0]==="enter"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._close){let c=u;for(;c--;)if(l[c][0]==="exit"&&l[c][1].type==="strikethroughSequenceTemporary"&&l[c][1]._open&&l[u][1].end.offset-l[u][1].start.offset===l[c][1].end.offset-l[c][1].start.offset){l[u][1].type="strikethroughSequence",l[c][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},l[c][1].start),end:Object.assign({},l[u][1].end)},h={type:"strikethroughText",start:Object.assign({},l[c][1].end),end:Object.assign({},l[u][1].start)},p=[["enter",d,o],["enter",l[c][1],o],["exit",l[c][1],o],["enter",h,o]],f=o.parser.constructs.insideSpan.null;f&&Wn(p,p.length,0,sc(f,l.slice(c+1,u),o)),Wn(p,p.length,0,[["exit",h,o],["enter",l[u][1],o],["exit",l[u][1],o],["exit",d,o]]),Wn(l,c-1,u-c+3,p),u=c+p.length-2;break}}for(u=-1;++u<l.length;)l[u][1].type==="strikethroughSequenceTemporary"&&(l[u][1].type="data");return l}function s(l,o,u){const c=this.previous,d=this.events;let h=0;return p;function p(m){return c===126&&d[d.length-1][1].type!=="characterEscape"?u(m):(l.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const g=wi(c);if(m===126)return h>1?u(m):(l.consume(m),h++,f);if(h<2&&!n)return u(m);const k=l.exit("strikethroughSequenceTemporary"),y=wi(m);return k._open=!y||y===2&&!!g,k._close=!g||g===2&&!!y,o(m)}}}class mT{constructor(){this.map=[],this.index=new Map}add(t,n,r){gT(this,t,n,r)}consume(t){if(this.map.sort(function(s,l){return s[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0,this.index.clear()}}function gT(e,t,n,r){if(n===0&&r.length===0)return;const i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}const s=[t,n,r];e.map.push(s),e.index.set(t,s)}function xT(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function yT(){return{flow:{null:{name:"table",tokenize:vT,resolveAll:wT}}}}function vT(e,t,n){const r=this;let i=0,s=0,l;return o;function o(C){let O=r.events.length-1;for(;O>-1;){const{type:U}=r.events[O][1];if(U==="lineEnding"||U==="linePrefix")O--;else break}const A=O>-1?r.events[O][1].type:null,V=A==="tableHead"||A==="tableRow"?w:u;return V===w&&r.parser.lazy[r.now().line]?n(C):V(C)}function u(C){return e.enter("tableHead"),e.enter("tableRow"),c(C)}function c(C){return C===124||(l=!0,s+=1),d(C)}function d(C){return C===null?n(C):he(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),f):n(C):Ne(C)?Ae(e,d,"whitespace")(C):(s+=1,l&&(l=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),l=!0,d):(e.enter("data"),h(C)))}function h(C){return C===null||C===124||$e(C)?(e.exit("data"),d(C)):(e.consume(C),C===92?p:h)}function p(C){return C===92||C===124?(e.consume(C),h):h(C)}function f(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),l=!1,Ne(C)?Ae(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?k(C):C===124?(l=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),g):E(C)}function g(C){return Ne(C)?Ae(e,k,"whitespace")(C):k(C)}function k(C){return C===58?(s+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),y):C===45?(s+=1,y(C)):C===null||he(C)?j(C):E(C)}function y(C){return C===45?(e.enter("tableDelimiterFiller"),x(C)):E(C)}function x(C){return C===45?(e.consume(C),x):C===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(C))}function v(C){return Ne(C)?Ae(e,j,"whitespace")(C):j(C)}function j(C){return C===124?m(C):C===null||he(C)?!l||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function w(C){return e.enter("tableRow"),N(C)}function N(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),N):C===null||he(C)?(e.exit("tableRow"),t(C)):Ne(C)?Ae(e,N,"whitespace")(C):(e.enter("data"),M(C))}function M(C){return C===null||C===124||$e(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?F:M)}function F(C){return C===92||C===124?(e.consume(C),M):M(C)}}function wT(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],l=[0,0,0,0],o=!1,u=0,c,d,h;const p=new mT;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(o=!1,u!==0&&(Mx(p,t,u,c,d),d=void 0,u=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,h=void 0,s=[0,0,0,0],l=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],h=So(p,t,s,i,void 0,h),s=[0,0,0,0]),l[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],h=So(p,t,s,i,void 0,h)),s=l,l=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,u=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(u=n,s[1]!==0?(l[0]=l[1],h=So(p,t,s,i,n,h)):l[1]!==0&&(h=So(p,t,l,i,n,h)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(l[3]=n)}for(u!==0&&Mx(p,t,u,c,d),p.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=xT(t.events,n))}return e}function So(e,t,n,r,i,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Ns(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const u=Ns(t.events,n[1]);if(s={type:l,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Ns(t.events,n[2]),d=Ns(t.events,n[3]),h={type:o,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,g=n[3]-n[2]-1;e.add(m,g,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return i!==void 0&&(s.end=Object.assign({},Ns(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Mx(e,t,n,r,i){const s=[],l=Ns(t.events,n);i&&(i.end=Object.assign({},l),s.push(["exit",i,t])),r.end=Object.assign({},l),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ns(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const kT={name:"tasklistCheck",tokenize:jT};function bT(){return{text:{91:kT}}}function jT(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),s)}function s(u){return $e(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),l):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),l):n(u)}function l(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(u)}function o(u){return he(u)?t(u):Ne(u)?e.check({tokenize:NT},t,n)(u):n(u)}}function NT(e,t,n){return Ae(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function ST(e){return F0([YP(),lT(),pT(e),yT(),bT()])}const CT={};function ET(e){const t=this,n=e||CT,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(ST(n)),s.push(VP()),l.push(QP(n))}let PT=null;const TT=()=>PT??(PT=ml(()=>import("./index-CyHGDhfc.js"),[])),LT={sh:"bash",yml:"yaml",ts:"typescript",js:"javascript",py:"python"};function MT(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function RT({lang:e,code:t}){const[n,r]=b.useState(`<pre><code>${MT(t)}</code></pre>`);return b.useEffect(()=>{let i=!0;const s=LT[e]??e;return TT().then(async l=>{const o=await l.codeToHtml(t,{lang:s in l.bundledLanguages?s:"text",themes:{light:"solarized-light",dark:"dark-plus"},defaultColor:!1});i&&r(o)}).catch(()=>{}),()=>{i=!1}},[e,t]),a.jsx("div",{dangerouslySetInnerHTML:{__html:n}})}const zT={background:"#fdf6e3",mainBkg:"#eee8d5",primaryColor:"#eee8d5",primaryTextColor:"#586e75",primaryBorderColor:"#268bd2",nodeBorder:"#268bd2",lineColor:"#839496",secondaryColor:"#eee8d5",tertiaryColor:"#eee8d5",textColor:"#586e75",edgeLabelBackground:"#fdf6e3",clusterBkg:"#eee8d5",clusterBorder:"#ddd6c1",fontSize:"14px"},AT={background:"#1f1f1f",mainBkg:"#2a2d2e",primaryColor:"#2a2d2e",primaryTextColor:"#cccccc",primaryBorderColor:"#3794ff",nodeBorder:"#3794ff",lineColor:"#9d9d9d",secondaryColor:"#2a2d2e",tertiaryColor:"#2a2d2e",textColor:"#cccccc",edgeLabelBackground:"#1f1f1f",clusterBkg:"#2a2d2e",clusterBorder:"#2b2b2b",fontSize:"14px"};let IT=null;const FT=()=>IT??(IT=ml(()=>import("./mermaid.core-27sLJoRM.js").then(e=>e.b6),[]).then(e=>e.default));function DT({code:e}){const t=b.useId().replace(/[^a-zA-Z0-9]/g,""),n=hk(),[r,i]=b.useState(""),[s,l]=b.useState(!1);b.useEffect(()=>{let c=!0;return FT().then(async d=>{d.initialize({startOnLoad:!1,theme:"base",securityLevel:"strict",fontFamily:"system-ui, -apple-system, Segoe UI, Ubuntu, sans-serif",themeVariables:n?AT:zT,flowchart:{useMaxWidth:!0,curve:"basis",nodeSpacing:30,rankSpacing:40,padding:8,htmlLabels:!0}});try{const h=await d.render(`m${t}${n?"d":"l"}`,e);c&&(i(h.svg),l(!1))}catch{c&&l(!0)}}),()=>{c=!1}},[e,n,t]);const[o,u]=b.useState(!1);return b.useEffect(()=>{if(!o)return;const c=d=>{d.key==="Escape"&&u(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[o]),s?a.jsx("pre",{children:e}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative my-6",children:[a.jsx("div",{className:"md-figure flex cursor-zoom-in justify-center rounded-md border border-line bg-panel p-4",title:"Click to enlarge",onClick:()=>u(!0),dangerouslySetInnerHTML:{__html:r}}),a.jsx("span",{className:"pointer-events-none absolute right-3 top-2 text-[11px] text-muted",children:"click to enlarge"})]}),o&&a.jsx("div",{className:"fixed inset-0 z-50 grid cursor-zoom-out place-items-center bg-ink/40 p-6 backdrop-blur-sm",onClick:()=>u(!1),children:a.jsx("div",{className:"md-figure-big max-h-full max-w-full overflow-auto rounded-md border border-line bg-panel p-6",onClick:c=>c.stopPropagation(),dangerouslySetInnerHTML:{__html:r}})})]})}function Rw(e){return e.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((t,n)=>n%2?t:t.replace(/ -> /g," → ")).join("")}const zw=[ET],Aw=b.createContext(void 0),OT={code({className:e,children:t,...n}){var i;const r=(i=/language-(\w+)/.exec(e??""))==null?void 0:i[1];return r==="mermaid"?a.jsx(DT,{code:String(t).trim()}):r?a.jsx(RT,{lang:r,code:String(t).replace(/\n$/,"")}):a.jsx("code",{className:e,...n,children:t})},pre({children:e}){var r;const t=Array.isArray(e)?e[0]:e;return(((r=t==null?void 0:t.props)==null?void 0:r.className)??"").includes("language-")?a.jsx(a.Fragment,{children:e}):a.jsx("pre",{children:e})},a:function({href:t,children:n}){const r=b.useContext(Aw),i=r&&/^codeline:(\d+)-(\d+)$/.exec(t??"");return i?a.jsx("button",{type:"button",className:"codeline",onClick:()=>r(Number(i[1]),Number(i[2])),children:n}):a.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:n})}},_T=e=>e,es=b.memo(function({children:t,className:n,onLineClick:r}){const i=b.useMemo(()=>Rw(t),[t]);return a.jsx("div",{className:n?`prose-g ${n}`:"prose-g",children:a.jsx(Aw.Provider,{value:r,children:a.jsx(aw,{remarkPlugins:zw,urlTransform:r?_T:void 0,components:OT,children:i})})})}),$T={p:({children:e})=>a.jsxs(a.Fragment,{children:[e," "]}),a:({href:e,children:t})=>a.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t})},cr=b.memo(function({children:t,className:n}){const r=b.useMemo(()=>Rw(t),[t]);return a.jsx("span",{className:n?`md-inline ${n}`:"md-inline",children:a.jsx(aw,{remarkPlugins:zw,components:$T,children:r})})});function qT({trace:e,onStep:t}){const{rel:n}=it(),[r,i]=b.useState(0),s=e.steps[r],l=r>0?e.steps[r-1].state:{};b.useEffect(()=>{t(s.file,s.line)},[r]);const o=[...new Set([...Object.keys(l),...Object.keys(s.state)])];return a.jsxs("div",{className:"card overflow-hidden",tabIndex:0,onKeyDown:u=>{u.key==="ArrowRight"&&i(c=>Math.min(e.steps.length-1,c+1)),u.key==="ArrowLeft"&&i(c=>Math.max(0,c-1))},children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-raised/60 px-4 py-2 text-xs",children:[a.jsx(p2,{className:"h-3.5 w-3.5 text-accent"}),a.jsx("span",{className:"text-muted",children:"Input"}),a.jsx("code",{className:"font-mono",children:e.input})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[a.jsx("button",{className:"rounded-md border border-line p-1 hover:bg-raised disabled:opacity-40",disabled:r===0,onClick:()=>i(r-1),"aria-label":"Previous step",children:a.jsx(xu,{className:"h-4 w-4"})}),a.jsx("input",{type:"range",min:0,max:e.steps.length-1,value:r,onChange:u=>i(Number(u.target.value)),className:"flex-1 accent-[rgb(var(--accent))]"}),a.jsx("button",{className:"rounded-md border border-line p-1 hover:bg-raised disabled:opacity-40",disabled:r===e.steps.length-1,onClick:()=>i(r+1),"aria-label":"Next step",children:a.jsx(Tr,{className:"h-4 w-4"})}),a.jsxs("span",{className:"w-16 text-right font-mono text-xs text-muted",children:[r+1,"/",e.steps.length]})]}),a.jsxs("div",{className:"px-4 pb-1 text-[14.5px]",children:[s.file&&a.jsxs("span",{className:"mr-2 font-mono text-[12px] text-accent",children:[n(s.file),s.line?`:${s.line}`:""]}),s.note]}),a.jsx("table",{className:"m-4 mt-2 w-[calc(100%-2rem)] text-[13.5px]",children:a.jsx("tbody",{children:o.map(u=>{const c=l[u],d=s.state[u],h=c!==d;return a.jsxs("tr",{className:"border-b border-line/60 last:border-0",children:[a.jsx("td",{className:"py-1 pr-3 font-mono text-muted",children:u}),a.jsxs("td",{className:le("py-1 font-mono",h&&r>0&&"text-accent"),children:[d??a.jsx("span",{className:"text-muted line-through",children:c}),h&&r>0&&c!==void 0&&d!==void 0&&a.jsxs("span",{className:"ml-2 text-[12px] text-muted",children:["was ",c]})]})]},u)})})}),a.jsx("div",{className:"border-t border-line px-4 py-1.5 text-[12px] text-muted",children:"Arrow keys step when this box has focus. Changed values are coloured."})]})}function BT(e){return e.startLine&&e.endLine?[e.startLine,e.endLine]:e.line?[Math.max(1,e.line-3),e.line+6]:null}function Mi({icon:e,children:t,aside:n}){return a.jsxs("div",{className:"mb-5 mt-16 flex items-center gap-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-[22px] font-semibold tracking-[-0.015em]",children:[e&&a.jsx("span",{className:"text-muted [&>svg]:h-[18px] [&>svg]:w-[18px]",children:e}),t]}),n&&a.jsx("div",{className:"ml-auto",children:n})]})}function UT(){const{id:e=""}=$r(),{project:t,rel:n,selected:r,setOpenFile:i,setSelected:s}=it(),l=gt(),o=mn(),u=mn(),c=mn(),[d,h]=b.useState(""),[p,f]=b.useState(!0),[m,g]=b.useState(null),[k,y]=b.useState(null),[x,v]=b.useState("all"),[j,E]=b.useState(0),w=ye({queryKey:["lens",t.id,e],queryFn:()=>me(`/projects/${t.id}/lenses/${e}`)}),N=w.data,M=b.useMemo(()=>[...new Set([...(N==null?void 0:N.deepDives)??[],...((N==null?void 0:N.followUps)??[]).flatMap(z=>z.deepDives)].map(z=>z.file).filter(z=>!!z))],[N]),F=Uj({queries:M.map(z=>({queryKey:["file",t.id,z],queryFn:()=>me(`/projects/${t.id}/file?path=${encodeURIComponent(z)}`),staleTime:6e4}))}),C=b.useMemo(()=>new Map(M.map((z,W)=>{var S;return[z,(S=F[W])==null?void 0:S.data]})),[M,F]);if(w.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!N)return a.jsx(Ft,{title:"Lens not found"});const O=(z,W)=>{z&&g({file:z,line:W})},A=z=>{s([z]),i(z),l(`/p/${t.id}/explore`)},V=r.filter(z=>!N.files.includes(z)),U=()=>c.run(`/projects/${t.id}/lenses/${N.id}/more`,{question:d,files:p?V:[]},()=>{h(""),w.refetch()}),q=N.deepDives,G=x==="all"?q.map((z,W)=>[z,W]):q[j]?[[q[j],j]]:[],X=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("article",{className:"lens py-10",children:[a.jsxs(ft,{to:`/p/${t.id}/library`,className:"inline-flex items-center gap-1 text-[13px] text-muted hover:text-ink",children:[a.jsx(Jf,{className:"h-3.5 w-3.5"})," Library"]}),a.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-2",children:[a.jsxs(be,{tone:"accent",children:[N.kind," lens"]}),N.depth&&N.depth!=="standard"&&a.jsx(be,{children:N.depth}),N.diff&&a.jsxs(be,{tone:"warn",children:["change ",N.diff.base,"..",N.diff.head||"working tree"]}),a.jsx("span",{className:"text-[13px] text-muted",children:Tt(N.createdAt)}),a.jsxs("a",{href:`/api/projects/${t.id}/lenses/${N.id}/export`,className:"ml-auto inline-flex items-center gap-1 rounded-md px-2 py-1 text-[13px] text-muted hover:bg-raised hover:text-ink",title:"Download as markdown",children:[a.jsx(tp,{className:"h-3.5 w-3.5"})," .md"]})]}),a.jsx("h1",{className:"mt-4 text-[36px] font-bold leading-[1.1] tracking-[-0.02em]",children:N.title}),a.jsx("p",{className:"mt-3 text-[16.5px] leading-relaxed text-muted",children:N.question}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[N.files.slice(0,6).map(z=>a.jsxs("button",{onClick:()=>O(z),title:n(z),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-ink/5 px-2 py-1 font-mono text-[12px] text-muted hover:text-accent",children:[a.jsx(os,{className:"h-3 w-3 shrink-0"})," ",a.jsx("span",{className:"truncate",children:fr(n(z),64)})]},z)),N.files.length>6&&a.jsxs("span",{className:"px-1 py-1 text-[12px] text-muted",children:["+",N.files.length-6," more"]})]}),N.changed.length>0&&a.jsxs("div",{className:"mt-6 flex items-center gap-3 rounded-md border border-warn/40 bg-warn/8 px-4 py-3 text-[14px]",children:[a.jsx(a2,{className:"h-4 w-4 shrink-0 text-warn"}),a.jsxs("div",{className:"min-w-0 flex-1",children:["The code changed since this lens was made (",N.changed.map(z=>n(z)).join(", "),"). It may be out of date."]}),a.jsx(ee,{size:"sm",icon:a.jsx(m2,{className:"h-3.5 w-3.5"}),disabled:u.busy,onClick:()=>u.run(`/projects/${t.id}/lenses/${N.id}/refresh`,{},z=>l(`/p/${t.id}/lens/${z.resultId}`,{replace:!0})),children:"Refresh"})]}),u.busy&&u.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"lens",elapsed:u.elapsed})}),u.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:u.error,onClose:u.clearError})}),a.jsxs("div",{className:"mt-10 border-l-[3px] border-accent py-1 pl-5",children:[a.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-[0.08em] text-accent",children:"The idea in one sentence"}),a.jsx("p",{className:"read-lead mt-2",children:a.jsx(cr,{children:N.tldr||N.summary})})]}),N.whyItMatters&&a.jsxs("p",{className:"read mt-6",children:[a.jsx("strong",{children:"Why it matters."})," ",a.jsx(cr,{children:N.whyItMatters})]}),N.tldr&&N.summary&&a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:N.summary})}),N.sketch&&a.jsxs("div",{className:"mt-8 rounded-md bg-raised/70 p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-semibold",children:[a.jsx(V1,{className:"h-4 w-4 text-accent"})," ",N.diff?"Your prediction":"Your take",", and where it differs"]}),a.jsxs("p",{className:"read mt-3 italic text-muted",children:["“",N.sketch,"”"]}),N.differences&&N.differences.length>0&&a.jsx("ul",{className:"read mt-4 space-y-2",children:N.differences.map((z,W)=>a.jsxs("li",{className:"flex gap-2.5",children:[a.jsx("span",{className:"mt-0.5 text-accent",children:"→"}),a.jsx("span",{children:a.jsx(cr,{children:z})})]},W))})]}),N.concepts.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(Zf,{className:"h-5 w-5"}),children:"Words you need first"}),a.jsx("div",{className:"wide lens-concepts grid gap-5",children:N.concepts.map(z=>a.jsx(HT,{c:z,onShow:()=>O(z.file,z.line),onCard:()=>y({kind:"concept",front:`What is "${z.term}" in this code, and why does it matter?`,back:z.explain,file:z.file??N.files[0],source:{lensId:N.id}})},z.term))})]}),N.trace&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{children:"Trace a run"}),a.jsx("div",{className:"wide",children:a.jsx(qT,{trace:N.trace,onStep:(z,W)=>O(z??N.files[0],W)})})]}),N.intuition&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(ip,{className:"h-5 w-5"}),children:"The intuition"}),a.jsx(es,{children:N.intuition})]}),q.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs(Mi,{aside:a.jsx(Zt,{value:x,onChange:z=>{v(z),E(0)},options:[{value:"all",label:"All steps"},{value:"step",label:"One at a time"}]}),children:["Walkthrough ",a.jsxs("span",{className:"text-[15px] font-normal text-muted",children:["· ",q.length," steps"]})]}),x==="step"&&a.jsx("div",{className:"mb-6 flex items-center gap-1.5",children:q.map((z,W)=>a.jsx("button",{title:z.title,onClick:()=>E(W),className:le("h-1.5 flex-1 rounded-full transition",W<j?"bg-accent/50":W===j?"bg-accent":"bg-line")},W))}),a.jsx("ol",{className:"space-y-12 [&>li+li]:border-t [&>li+li]:border-line [&>li+li]:pt-10",children:G.map(([z,W])=>a.jsx(Rx,{d:z,n:W+1,text:z.file?C.get(z.file):void 0,rel:n,onShow:O},W))}),x==="step"&&a.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(xu,{className:"h-4 w-4"}),disabled:j===0,onClick:()=>E(j-1),children:"Back"}),a.jsxs("span",{className:"text-[13px] text-muted",children:["Step ",j+1," of ",q.length]}),a.jsxs(ee,{size:"sm",variant:j<q.length-1?"primary":"secondary",disabled:j===q.length-1,onClick:()=>E(j+1),children:["Next ",a.jsx(Tr,{className:"h-4 w-4"})]})]})]}),N.gotchas&&N.gotchas.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(op,{className:"h-5 w-5"}),children:"Gotchas"}),a.jsx("ul",{className:"read space-y-3",children:N.gotchas.map((z,W)=>a.jsxs("li",{className:"flex gap-3",children:[a.jsx("span",{className:"mt-[0.55em] h-1.5 w-1.5 shrink-0 rounded-full bg-warn"}),a.jsx("span",{children:a.jsx(cr,{children:z})})]},W))})]}),N.nextSteps&&N.nextSteps.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(Hu,{className:"h-5 w-5"}),children:"Read next"}),a.jsx("div",{className:"space-y-2",children:N.nextSteps.map(z=>a.jsxs("button",{onClick:()=>A(z.file),className:"card flex w-full items-start gap-3 px-4 py-3 text-left transition hover:border-accent/40",children:[a.jsx(os,{className:"mt-1 h-4 w-4 shrink-0 text-accent"}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block font-mono text-[13px]",children:n(z.file)}),a.jsx("span",{className:"read block text-muted",children:a.jsx(cr,{children:z.why})})]})]},z.file))})]}),(N.followUps??[]).length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(n2,{className:"h-5 w-5"}),children:"Follow-ups"}),a.jsx("div",{className:"space-y-14",children:N.followUps.map((z,W)=>a.jsxs("div",{children:[a.jsxs("div",{className:"border-l-[3px] border-accent/60 py-1 pl-5",children:[a.jsxs("div",{className:"text-[11.5px] font-semibold uppercase tracking-[0.08em] text-accent",children:["You asked · ",Tt(z.at)]}),a.jsx("p",{className:"read mt-1 font-medium",children:z.question}),z.files.length>0&&a.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:z.files.map(S=>a.jsxs("button",{onClick:()=>O(S),title:n(S),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-ink/5 px-2 py-0.5 font-mono text-[11.5px] text-muted hover:text-accent",children:["+ ",a.jsx("span",{className:"truncate",children:fr(n(S),64)})]},S))})]}),a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:z.answer})}),z.deepDives.length>0&&a.jsx("ol",{className:"mt-10 space-y-12 [&>li+li]:border-t [&>li+li]:border-line [&>li+li]:pt-10",children:z.deepDives.map((S,D)=>a.jsx(Rx,{d:S,n:D+1,text:S.file?C.get(S.file):void 0,rel:n,onShow:O},D))})]},W))})]}),a.jsxs("section",{className:"mt-16 rounded-md border border-line p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[17px] font-semibold",children:[a.jsx(ag,{className:"h-4 w-4 text-accent"})," Ask more about this"]}),a.jsx("p",{className:"read mt-1 text-muted",children:"The answer is added to this lens, not a new one. New terms and gotchas join the lists above."}),a.jsx("textarea",{className:"input mt-4 min-h-[84px] resize-y text-[14px]",placeholder:"e.g. How would this change if the caller were an IAM user instead of a role? Ctrl+Enter to send.",value:d,onChange:z=>h(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.ctrlKey||z.metaKey)&&d.trim()&&!c.busy&&U()}}),V.length>0&&a.jsxs("label",{className:"mt-2 flex cursor-pointer items-center gap-2 text-[13px] text-muted",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:z=>f(z.target.checked)}),"Also use ",V.length===1?fr(n(V[0]),48):`the ${V.length} ticked files`," as context"]}),a.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[a.jsx(ee,{variant:"primary",icon:a.jsx(ag,{className:"h-4 w-4"}),disabled:c.busy||!d.trim(),onClick:U,children:"Add to lens"}),V.length===0&&a.jsx("span",{className:"text-[12.5px] text-muted",children:"Tick files in Explore to add them as extra context."})]}),c.busy&&c.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"lens",elapsed:c.elapsed})}),c.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:c.error,onClose:c.clearError})})]}),a.jsxs("section",{className:"mt-16 rounded-md border border-line bg-raised/40 p-6",children:[a.jsx("div",{className:"text-[17px] font-semibold",children:"Did it land?"}),a.jsx("p",{className:"read mt-1 text-muted",children:"Reading feels like understanding. A quiz on the same files tells you if it is."}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsx(ee,{variant:"primary",icon:a.jsx($a,{className:"h-4 w-4"}),disabled:o.busy,onClick:()=>o.run(`/projects/${t.id}/quizzes`,{lensId:N.id,files:N.files,diff:N.diff},z=>l(`/p/${t.id}/quiz/${z.resultId}`)),children:"Quiz me on this"}),a.jsx(ee,{variant:"ghost",icon:a.jsx(pr,{className:"h-4 w-4"}),onClick:async()=>{await cs(`/projects/${t.id}/lenses/${N.id}`),l(`/p/${t.id}/library`)},children:"Archive"})]}),o.busy&&o.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"quiz",elapsed:o.elapsed})}),o.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:o.error,onClose:o.clearError})}),k&&a.jsx(Ha,{initial:k,onClose:()=>y(null)})]})]})});return a.jsx(Kn,{id:"lens-file",collapsible:!0,startCollapsed:!0,openSignal:m,side:"right",initial:520,min:320,max:900,className:"h-full",left:X,right:a.jsx(kl,{file:m==null?void 0:m.file,line:m==null?void 0:m.line,empty:"Click a file, a step or a line link to see the whole file here."})})}function HT({c:e,onShow:t,onCard:n}){var o;const[r,i]=b.useState(!1),s=e.explain.length+(((o=e.example)==null?void 0:o.length)??0)>340,l=u=>a.jsxs(a.Fragment,{children:[a.jsx("p",{className:le("read-sm mt-2",u&&"line-clamp-5"),children:a.jsx(cr,{children:e.explain})}),e.example&&a.jsxs("div",{className:le("read-sm mt-3 rounded-lg bg-raised/70 px-3.5 py-2.5 text-muted",u&&"max-h-[9.5rem] overflow-hidden"),children:[a.jsx("div",{className:"mb-1 text-[11.5px] font-semibold uppercase tracking-[0.08em] text-ink/70",children:"Example"}),a.jsx(WT,{text:e.example})]})]});return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"card group flex flex-col p-5 transition duration-150 hover:-translate-y-0.5 hover:border-accent/40 hover:shadow-soft",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("div",{className:"flex-1 text-[16px] font-semibold tracking-tight",children:e.term}),e.file&&a.jsx("button",{className:"rounded bg-raised px-1.5 py-0.5 font-mono text-[11.5px] text-muted hover:text-accent",onClick:t,title:"Show in the code",children:e.line?`line ${e.line}`:"code"}),a.jsx("button",{className:"self-center text-muted opacity-0 transition hover:text-accent group-hover:opacity-100",title:"Make a review card",onClick:n,children:a.jsx(Fr,{className:"h-4 w-4"})}),a.jsx("button",{className:le("self-center text-muted transition hover:text-accent",s?"opacity-100":"opacity-0 group-hover:opacity-100"),title:"Open to read","aria-label":"Open to read",onClick:()=>i(!0),children:a.jsx(d2,{className:"h-4 w-4"})})]}),l(s),s&&a.jsx("button",{className:"mt-2 self-start text-[12.5px] text-accent hover:underline",onClick:()=>i(!0),children:"Read all"})]}),r&&a.jsx(tc,{wide:!0,title:e.term,onClose:()=>i(!1),footer:a.jsxs(a.Fragment,{children:[e.file&&a.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>{i(!1),t()},children:"Show in the code"}),a.jsx(ee,{size:"sm",onClick:()=>{i(!1),n()},children:"Make a review card"})]}),children:a.jsx("div",{className:"[&_.read-sm]:!text-[16px] [&_.read-sm]:!leading-[1.65]",children:l(!1)})})]})}function WT({text:e}){const t=e.split(/(`[^`]{36,}`)/g).filter(n=>n.replace(/[\s.,;:]+/g,""));return a.jsx(a.Fragment,{children:t.map((n,r)=>/^`[^`]{36,}`$/.test(n)?a.jsx("pre",{className:"my-2 whitespace-pre-wrap break-words rounded-md border border-line/70 bg-panel px-3 py-2 font-mono text-[12.5px] leading-[1.6] text-ink",children:n.slice(1,-1)},r):a.jsx("p",{children:a.jsx(cr,{children:n})},r))})}function VT(e){return e.split("/").slice(-2).join("/")}function QT(e,t,n){const r=s=>{var l;return((l=/^\s*/.exec(s))==null?void 0:l[0].length)??0},i=r(e[n-1]??"");for(let s=t;s>=Math.max(1,t-25);s--){const l=e[s-1]??"";if(!l.trim())continue;if(/^\s*(def |async def |class |@|function |export |const |func |fn |pub |public |private )/.test(l)&&r(l)<=i||r(l)===0)return s}return t}function Rx({d:e,n:t,text:n,rel:r,onShow:i}){const[s,l]=b.useState(!1),o=BT(e),u=b.useMemo(()=>{if(!n||!o)return null;const d=n.text.split(`
504
+ `))}function u(f,m,g,k){const y=g.enter("tableCell"),x=g.enter("phrasing"),v=g.containerPhrasing(f,{...k,before:s,after:s});return x(),y(),v}function c(f,m){return V5(f,{align:m,alignDelimiters:r,fillRows:!1,padding:n,stringLength:i})}function d(f,m,g){const{children:k}=f;let y=-1;const x=[],v=m.enter("table");for(;++y<k.length;)x[y]=h(k[y],m,g);return v(),x}function h(f,m,g){const{children:k}=f;let y=-1;const x=[],v=m.enter("tableRow");for(;++y<k.length;)x[y]=u(k[y],f,m,g);return v(),x}function p(f,m,g){const k=jw.inlineCode(f,m,g);if(!g.stack.includes("tableCell"))return k;const y=[];let x=0,v=k.indexOf("|");for(;v!==-1;){let j=v;for(;j>x&&k.charCodeAt(j-1)===92;)j--;y.push(k.slice(x,v)),(v-j)%2===0&&y.push("\\"),x=v,v=k.indexOf("|",v+1)}return y.push(k.slice(x)),y.join("")}}function $P(e,t,n,r){if(e.type==="table"&&n.type==="listItem"&&n.spread===!1&&(t.type==="definition"||t.type==="heading"&&qP(t,r)||t.type==="paragraph"||t.type==="table"))return 1}function qP(e,t){let n=!1;return uc(e,function(r){if(r.type==="break"||"value"in r&&/\r?\n|\r/.test(r.value))return n=!0,sa}),!!((!e.depth||e.depth<3)&&rc(e)&&(t.options.setext||n))}function BP(){return{exit:{taskListCheckValueChecked:Lx,taskListCheckValueUnchecked:Lx,paragraph:HP}}}function UP(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WP}}}function Lx(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HP(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,l;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){l=o;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function WP(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(l);let u=jw.listItem(e,t,n,{...r,...o.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),u;function c(d){return d+l}}function VP(){return[p5(),I5(),_5(),zP(),BP()]}function QP(e){return{extensions:[m5(),F5(e),$5(),_P(e),UP()]}}const KP={tokenize:eT,partial:!0},Nw={tokenize:tT,partial:!0},Sw={tokenize:nT,partial:!0},Cw={tokenize:rT,partial:!0},GP={tokenize:iT,partial:!0},Ew={name:"wwwAutolink",tokenize:JP,previous:Tw},Pw={name:"protocolAutolink",tokenize:ZP,previous:Lw},qr={name:"emailAutolink",tokenize:XP,previous:Mw},gr={};function YP(){return{text:gr}}let Li=48;for(;Li<123;)gr[Li]=qr,Li++,Li===58?Li=65:Li===91&&(Li=97);gr[43]=qr;gr[45]=qr;gr[46]=qr;gr[95]=qr;gr[72]=[qr,Pw];gr[104]=[qr,Pw];gr[87]=[qr,Ew];gr[119]=[qr,Ew];function XP(e,t,n){const r=this;let i,s;return l;function l(h){return!Wh(h)||!Mw.call(r,r.previous)||Fp(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(h))}function o(h){return Wh(h)?(e.consume(h),o):h===64?(e.consume(h),u):n(h)}function u(h){return h===46?e.check(GP,d,c)(h):h===45||h===95||Ct(h)?(s=!0,e.consume(h),u):d(h)}function c(h){return e.consume(h),i=!0,u}function d(h){return s&&i&&St(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function JP(e,t,n){const r=this;return i;function i(l){return l!==87&&l!==119||!Tw.call(r,r.previous)||Fp(r.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(KP,e.attempt(Nw,e.attempt(Sw,s),n),n)(l))}function s(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function ZP(e,t,n){const r=this;let i="",s=!1;return l;function l(h){return(h===72||h===104)&&Lw.call(r,r.previous)&&!Fp(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),o):n(h)}function o(h){if(St(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),o;if(h===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(h),u}return n(h)}function u(h){return h===47?(e.consume(h),s?c:(s=!0,u)):n(h)}function c(h){return h===null||bu(h)||$e(h)||ds(h)||ic(h)?n(h):e.attempt(Nw,e.attempt(Sw,d),n)(h)}function d(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function eT(e,t,n){let r=0;return i;function i(l){return(l===87||l===119)&&r<3?(r++,e.consume(l),i):l===46&&r===3?(e.consume(l),s):n(l)}function s(l){return l===null?n(l):t(l)}}function tT(e,t,n){let r,i,s;return l;function l(c){return c===46||c===95?e.check(Cw,u,o)(c):c===null||$e(c)||ds(c)||c!==45&&ic(c)?u(c):(s=!0,e.consume(c),l)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),l}function u(c){return i||r||!s?n(c):t(c)}}function nT(e,t){let n=0,r=0;return i;function i(l){return l===40?(n++,e.consume(l),i):l===41&&r<n?s(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(Cw,t,s)(l):l===null||$e(l)||ds(l)?t(l):(e.consume(l),i)}function s(l){return l===41&&r++,e.consume(l),i}}function rT(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||$e(o)||ds(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||$e(o)||ds(o)?t(o):r(o)}function s(o){return St(o)?l(o):n(o)}function l(o){return o===59?(e.consume(o),r):St(o)?(e.consume(o),l):n(o)}}function iT(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Ct(s)?n(s):t(s)}}function Tw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||$e(e)}function Lw(e){return!St(e)}function Mw(e){return!(e===47||Wh(e))}function Wh(e){return e===43||e===45||e===46||e===95||Ct(e)}function Fp(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const sT={tokenize:fT,partial:!0};function lT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cT,continuation:{tokenize:dT},exit:hT}},text:{91:{name:"gfmFootnoteCall",tokenize:uT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:aT,resolveTo:oT}}}}function aT(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){l=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return o;function o(u){if(!l||!l._balanced)return n(u);const c=Vn(r.sliceSerialize({start:l.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function oT(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function uT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,l;return o;function o(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),u}function u(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(h){if(s>999||h===93&&!l||h===null||h===91||$e(h))return n(h);if(h===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Vn(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return $e(h)||(l=!0),s++,e.consume(h),h===92?d:c}function d(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function cT(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,o;return u;function u(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(l>999||m===93&&!o||m===null||m===91||$e(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return s=Vn(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return $e(m)||(o=!0),l++,e.consume(m),m===92?h:d}function h(m){return m===91||m===92||m===93?(e.consume(m),l++,d):d(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ae(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function dT(e,t,n){return e.check(Qa,t,e.attempt(sT,t,n))}function hT(e){e.exit("gfmFootnoteDefinition")}function fT(e,t,n){const r=this;return Ae(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(s):n(s)}}function pT(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(l,o){let u=-1;for(;++u<l.length;)if(l[u][0]==="enter"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._close){let c=u;for(;c--;)if(l[c][0]==="exit"&&l[c][1].type==="strikethroughSequenceTemporary"&&l[c][1]._open&&l[u][1].end.offset-l[u][1].start.offset===l[c][1].end.offset-l[c][1].start.offset){l[u][1].type="strikethroughSequence",l[c][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},l[c][1].start),end:Object.assign({},l[u][1].end)},h={type:"strikethroughText",start:Object.assign({},l[c][1].end),end:Object.assign({},l[u][1].start)},p=[["enter",d,o],["enter",l[c][1],o],["exit",l[c][1],o],["enter",h,o]],f=o.parser.constructs.insideSpan.null;f&&Wn(p,p.length,0,sc(f,l.slice(c+1,u),o)),Wn(p,p.length,0,[["exit",h,o],["enter",l[u][1],o],["exit",l[u][1],o],["exit",d,o]]),Wn(l,c-1,u-c+3,p),u=c+p.length-2;break}}for(u=-1;++u<l.length;)l[u][1].type==="strikethroughSequenceTemporary"&&(l[u][1].type="data");return l}function s(l,o,u){const c=this.previous,d=this.events;let h=0;return p;function p(m){return c===126&&d[d.length-1][1].type!=="characterEscape"?u(m):(l.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const g=wi(c);if(m===126)return h>1?u(m):(l.consume(m),h++,f);if(h<2&&!n)return u(m);const k=l.exit("strikethroughSequenceTemporary"),y=wi(m);return k._open=!y||y===2&&!!g,k._close=!g||g===2&&!!y,o(m)}}}class mT{constructor(){this.map=[],this.index=new Map}add(t,n,r){gT(this,t,n,r)}consume(t){if(this.map.sort(function(s,l){return s[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0,this.index.clear()}}function gT(e,t,n,r){if(n===0&&r.length===0)return;const i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}const s=[t,n,r];e.map.push(s),e.index.set(t,s)}function xT(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function yT(){return{flow:{null:{name:"table",tokenize:vT,resolveAll:wT}}}}function vT(e,t,n){const r=this;let i=0,s=0,l;return o;function o(C){let O=r.events.length-1;for(;O>-1;){const{type:U}=r.events[O][1];if(U==="lineEnding"||U==="linePrefix")O--;else break}const A=O>-1?r.events[O][1].type:null,V=A==="tableHead"||A==="tableRow"?w:u;return V===w&&r.parser.lazy[r.now().line]?n(C):V(C)}function u(C){return e.enter("tableHead"),e.enter("tableRow"),c(C)}function c(C){return C===124||(l=!0,s+=1),d(C)}function d(C){return C===null?n(C):he(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),f):n(C):Ne(C)?Ae(e,d,"whitespace")(C):(s+=1,l&&(l=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),l=!0,d):(e.enter("data"),h(C)))}function h(C){return C===null||C===124||$e(C)?(e.exit("data"),d(C)):(e.consume(C),C===92?p:h)}function p(C){return C===92||C===124?(e.consume(C),h):h(C)}function f(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),l=!1,Ne(C)?Ae(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?k(C):C===124?(l=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),g):E(C)}function g(C){return Ne(C)?Ae(e,k,"whitespace")(C):k(C)}function k(C){return C===58?(s+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),y):C===45?(s+=1,y(C)):C===null||he(C)?j(C):E(C)}function y(C){return C===45?(e.enter("tableDelimiterFiller"),x(C)):E(C)}function x(C){return C===45?(e.consume(C),x):C===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(C))}function v(C){return Ne(C)?Ae(e,j,"whitespace")(C):j(C)}function j(C){return C===124?m(C):C===null||he(C)?!l||i!==s?E(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):E(C)}function E(C){return n(C)}function w(C){return e.enter("tableRow"),N(C)}function N(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),N):C===null||he(C)?(e.exit("tableRow"),t(C)):Ne(C)?Ae(e,N,"whitespace")(C):(e.enter("data"),M(C))}function M(C){return C===null||C===124||$e(C)?(e.exit("data"),N(C)):(e.consume(C),C===92?F:M)}function F(C){return C===92||C===124?(e.consume(C),M):M(C)}}function wT(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],l=[0,0,0,0],o=!1,u=0,c,d,h;const p=new mT;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(o=!1,u!==0&&(Mx(p,t,u,c,d),d=void 0,u=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,h=void 0,s=[0,0,0,0],l=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],h=So(p,t,s,i,void 0,h),s=[0,0,0,0]),l[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],h=So(p,t,s,i,void 0,h)),s=l,l=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,u=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(u=n,s[1]!==0?(l[0]=l[1],h=So(p,t,s,i,n,h)):l[1]!==0&&(h=So(p,t,l,i,n,h)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(l[3]=n)}for(u!==0&&Mx(p,t,u,c,d),p.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=xT(t.events,n))}return e}function So(e,t,n,r,i,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Ns(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const u=Ns(t.events,n[1]);if(s={type:l,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Ns(t.events,n[2]),d=Ns(t.events,n[3]),h={type:o,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,g=n[3]-n[2]-1;e.add(m,g,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return i!==void 0&&(s.end=Object.assign({},Ns(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Mx(e,t,n,r,i){const s=[],l=Ns(t.events,n);i&&(i.end=Object.assign({},l),s.push(["exit",i,t])),r.end=Object.assign({},l),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ns(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const kT={name:"tasklistCheck",tokenize:jT};function bT(){return{text:{91:kT}}}function jT(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),s)}function s(u){return $e(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),l):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),l):n(u)}function l(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(u)}function o(u){return he(u)?t(u):Ne(u)?e.check({tokenize:NT},t,n)(u):n(u)}}function NT(e,t,n){return Ae(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function ST(e){return F0([YP(),lT(),pT(e),yT(),bT()])}const CT={};function ET(e){const t=this,n=e||CT,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(ST(n)),s.push(VP()),l.push(QP(n))}let PT=null;const TT=()=>PT??(PT=ml(()=>import("./index-6_jiQxLN.js"),[])),LT={sh:"bash",yml:"yaml",ts:"typescript",js:"javascript",py:"python"};function MT(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function RT({lang:e,code:t}){const[n,r]=b.useState(`<pre><code>${MT(t)}</code></pre>`);return b.useEffect(()=>{let i=!0;const s=LT[e]??e;return TT().then(async l=>{const o=await l.codeToHtml(t,{lang:s in l.bundledLanguages?s:"text",themes:{light:"solarized-light",dark:"dark-plus"},defaultColor:!1});i&&r(o)}).catch(()=>{}),()=>{i=!1}},[e,t]),a.jsx("div",{dangerouslySetInnerHTML:{__html:n}})}const zT={background:"#fdf6e3",mainBkg:"#eee8d5",primaryColor:"#eee8d5",primaryTextColor:"#586e75",primaryBorderColor:"#268bd2",nodeBorder:"#268bd2",lineColor:"#839496",secondaryColor:"#eee8d5",tertiaryColor:"#eee8d5",textColor:"#586e75",edgeLabelBackground:"#fdf6e3",clusterBkg:"#eee8d5",clusterBorder:"#ddd6c1",fontSize:"14px"},AT={background:"#1f1f1f",mainBkg:"#2a2d2e",primaryColor:"#2a2d2e",primaryTextColor:"#cccccc",primaryBorderColor:"#3794ff",nodeBorder:"#3794ff",lineColor:"#9d9d9d",secondaryColor:"#2a2d2e",tertiaryColor:"#2a2d2e",textColor:"#cccccc",edgeLabelBackground:"#1f1f1f",clusterBkg:"#2a2d2e",clusterBorder:"#2b2b2b",fontSize:"14px"};let IT=null;const FT=()=>IT??(IT=ml(()=>import("./mermaid.core-C4isYGdZ.js").then(e=>e.b6),[]).then(e=>e.default));function DT({code:e}){const t=b.useId().replace(/[^a-zA-Z0-9]/g,""),n=hk(),[r,i]=b.useState(""),[s,l]=b.useState(!1);b.useEffect(()=>{let c=!0;return FT().then(async d=>{d.initialize({startOnLoad:!1,theme:"base",securityLevel:"strict",fontFamily:"system-ui, -apple-system, Segoe UI, Ubuntu, sans-serif",themeVariables:n?AT:zT,flowchart:{useMaxWidth:!0,curve:"basis",nodeSpacing:30,rankSpacing:40,padding:8,htmlLabels:!0}});try{const h=await d.render(`m${t}${n?"d":"l"}`,e);c&&(i(h.svg),l(!1))}catch{c&&l(!0)}}),()=>{c=!1}},[e,n,t]);const[o,u]=b.useState(!1);return b.useEffect(()=>{if(!o)return;const c=d=>{d.key==="Escape"&&u(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[o]),s?a.jsx("pre",{children:e}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative my-6",children:[a.jsx("div",{className:"md-figure flex cursor-zoom-in justify-center rounded-md border border-line bg-panel p-4",title:"Click to enlarge",onClick:()=>u(!0),dangerouslySetInnerHTML:{__html:r}}),a.jsx("span",{className:"pointer-events-none absolute right-3 top-2 text-[11px] text-muted",children:"click to enlarge"})]}),o&&a.jsx("div",{className:"fixed inset-0 z-50 grid cursor-zoom-out place-items-center bg-ink/40 p-6 backdrop-blur-sm",onClick:()=>u(!1),children:a.jsx("div",{className:"md-figure-big max-h-full max-w-full overflow-auto rounded-md border border-line bg-panel p-6",onClick:c=>c.stopPropagation(),dangerouslySetInnerHTML:{__html:r}})})]})}function Rw(e){return e.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((t,n)=>n%2?t:t.replace(/ -> /g," → ")).join("")}const zw=[ET],Aw=b.createContext(void 0),OT={code({className:e,children:t,...n}){var i;const r=(i=/language-(\w+)/.exec(e??""))==null?void 0:i[1];return r==="mermaid"?a.jsx(DT,{code:String(t).trim()}):r?a.jsx(RT,{lang:r,code:String(t).replace(/\n$/,"")}):a.jsx("code",{className:e,...n,children:t})},pre({children:e}){var r;const t=Array.isArray(e)?e[0]:e;return(((r=t==null?void 0:t.props)==null?void 0:r.className)??"").includes("language-")?a.jsx(a.Fragment,{children:e}):a.jsx("pre",{children:e})},a:function({href:t,children:n}){const r=b.useContext(Aw),i=r&&/^codeline:(\d+)-(\d+)$/.exec(t??"");return i?a.jsx("button",{type:"button",className:"codeline",onClick:()=>r(Number(i[1]),Number(i[2])),children:n}):a.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:n})}},_T=e=>e,es=b.memo(function({children:t,className:n,onLineClick:r}){const i=b.useMemo(()=>Rw(t),[t]);return a.jsx("div",{className:n?`prose-g ${n}`:"prose-g",children:a.jsx(Aw.Provider,{value:r,children:a.jsx(aw,{remarkPlugins:zw,urlTransform:r?_T:void 0,components:OT,children:i})})})}),$T={p:({children:e})=>a.jsxs(a.Fragment,{children:[e," "]}),a:({href:e,children:t})=>a.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t})},cr=b.memo(function({children:t,className:n}){const r=b.useMemo(()=>Rw(t),[t]);return a.jsx("span",{className:n?`md-inline ${n}`:"md-inline",children:a.jsx(aw,{remarkPlugins:zw,components:$T,children:r})})});function qT({trace:e,onStep:t}){const{rel:n}=it(),[r,i]=b.useState(0),s=e.steps[r],l=r>0?e.steps[r-1].state:{};b.useEffect(()=>{t(s.file,s.line)},[r]);const o=[...new Set([...Object.keys(l),...Object.keys(s.state)])];return a.jsxs("div",{className:"card overflow-hidden",tabIndex:0,onKeyDown:u=>{u.key==="ArrowRight"&&i(c=>Math.min(e.steps.length-1,c+1)),u.key==="ArrowLeft"&&i(c=>Math.max(0,c-1))},children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-raised/60 px-4 py-2 text-xs",children:[a.jsx(p2,{className:"h-3.5 w-3.5 text-accent"}),a.jsx("span",{className:"text-muted",children:"Input"}),a.jsx("code",{className:"font-mono",children:e.input})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[a.jsx("button",{className:"rounded-md border border-line p-1 hover:bg-raised disabled:opacity-40",disabled:r===0,onClick:()=>i(r-1),"aria-label":"Previous step",children:a.jsx(xu,{className:"h-4 w-4"})}),a.jsx("input",{type:"range",min:0,max:e.steps.length-1,value:r,onChange:u=>i(Number(u.target.value)),className:"flex-1 accent-[rgb(var(--accent))]"}),a.jsx("button",{className:"rounded-md border border-line p-1 hover:bg-raised disabled:opacity-40",disabled:r===e.steps.length-1,onClick:()=>i(r+1),"aria-label":"Next step",children:a.jsx(Tr,{className:"h-4 w-4"})}),a.jsxs("span",{className:"w-16 text-right font-mono text-xs text-muted",children:[r+1,"/",e.steps.length]})]}),a.jsxs("div",{className:"px-4 pb-1 text-[14.5px]",children:[s.file&&a.jsxs("span",{className:"mr-2 font-mono text-[12px] text-accent",children:[n(s.file),s.line?`:${s.line}`:""]}),s.note]}),a.jsx("table",{className:"m-4 mt-2 w-[calc(100%-2rem)] text-[13.5px]",children:a.jsx("tbody",{children:o.map(u=>{const c=l[u],d=s.state[u],h=c!==d;return a.jsxs("tr",{className:"border-b border-line/60 last:border-0",children:[a.jsx("td",{className:"py-1 pr-3 font-mono text-muted",children:u}),a.jsxs("td",{className:le("py-1 font-mono",h&&r>0&&"text-accent"),children:[d??a.jsx("span",{className:"text-muted line-through",children:c}),h&&r>0&&c!==void 0&&d!==void 0&&a.jsxs("span",{className:"ml-2 text-[12px] text-muted",children:["was ",c]})]})]},u)})})}),a.jsx("div",{className:"border-t border-line px-4 py-1.5 text-[12px] text-muted",children:"Arrow keys step when this box has focus. Changed values are coloured."})]})}function BT(e){return e.startLine&&e.endLine?[e.startLine,e.endLine]:e.line?[Math.max(1,e.line-3),e.line+6]:null}function Mi({icon:e,children:t,aside:n}){return a.jsxs("div",{className:"mb-5 mt-16 flex items-center gap-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-[22px] font-semibold tracking-[-0.015em]",children:[e&&a.jsx("span",{className:"text-muted [&>svg]:h-[18px] [&>svg]:w-[18px]",children:e}),t]}),n&&a.jsx("div",{className:"ml-auto",children:n})]})}function UT(){const{id:e=""}=$r(),{project:t,rel:n,selected:r,setOpenFile:i,setSelected:s}=it(),l=gt(),o=mn(),u=mn(),c=mn(),[d,h]=b.useState(""),[p,f]=b.useState(!0),[m,g]=b.useState(null),[k,y]=b.useState(null),[x,v]=b.useState("all"),[j,E]=b.useState(0),w=ye({queryKey:["lens",t.id,e],queryFn:()=>me(`/projects/${t.id}/lenses/${e}`)}),N=w.data,M=b.useMemo(()=>[...new Set([...(N==null?void 0:N.deepDives)??[],...((N==null?void 0:N.followUps)??[]).flatMap(z=>z.deepDives)].map(z=>z.file).filter(z=>!!z))],[N]),F=Uj({queries:M.map(z=>({queryKey:["file",t.id,z],queryFn:()=>me(`/projects/${t.id}/file?path=${encodeURIComponent(z)}`),staleTime:6e4}))}),C=b.useMemo(()=>new Map(M.map((z,W)=>{var S;return[z,(S=F[W])==null?void 0:S.data]})),[M,F]);if(w.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!N)return a.jsx(Ft,{title:"Lens not found"});const O=(z,W)=>{z&&g({file:z,line:W})},A=z=>{s([z]),i(z),l(`/p/${t.id}/explore`)},V=r.filter(z=>!N.files.includes(z)),U=()=>c.run(`/projects/${t.id}/lenses/${N.id}/more`,{question:d,files:p?V:[]},()=>{h(""),w.refetch()}),q=N.deepDives,G=x==="all"?q.map((z,W)=>[z,W]):q[j]?[[q[j],j]]:[],X=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("article",{className:"lens py-10",children:[a.jsxs(ft,{to:`/p/${t.id}/library`,className:"inline-flex items-center gap-1 text-[13px] text-muted hover:text-ink",children:[a.jsx(Jf,{className:"h-3.5 w-3.5"})," Library"]}),a.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-2",children:[a.jsxs(be,{tone:"accent",children:[N.kind," lens"]}),N.depth&&N.depth!=="standard"&&a.jsx(be,{children:N.depth}),N.diff&&a.jsxs(be,{tone:"warn",children:["change ",N.diff.base,"..",N.diff.head||"working tree"]}),a.jsx("span",{className:"text-[13px] text-muted",children:Tt(N.createdAt)}),a.jsxs("a",{href:`/api/projects/${t.id}/lenses/${N.id}/export`,className:"ml-auto inline-flex items-center gap-1 rounded-md px-2 py-1 text-[13px] text-muted hover:bg-raised hover:text-ink",title:"Download as markdown",children:[a.jsx(tp,{className:"h-3.5 w-3.5"})," .md"]})]}),a.jsx("h1",{className:"mt-4 text-[36px] font-bold leading-[1.1] tracking-[-0.02em]",children:N.title}),a.jsx("p",{className:"mt-3 text-[16.5px] leading-relaxed text-muted",children:N.question}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[N.files.slice(0,6).map(z=>a.jsxs("button",{onClick:()=>O(z),title:n(z),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-ink/5 px-2 py-1 font-mono text-[12px] text-muted hover:text-accent",children:[a.jsx(os,{className:"h-3 w-3 shrink-0"})," ",a.jsx("span",{className:"truncate",children:fr(n(z),64)})]},z)),N.files.length>6&&a.jsxs("span",{className:"px-1 py-1 text-[12px] text-muted",children:["+",N.files.length-6," more"]})]}),N.changed.length>0&&a.jsxs("div",{className:"mt-6 flex items-center gap-3 rounded-md border border-warn/40 bg-warn/8 px-4 py-3 text-[14px]",children:[a.jsx(a2,{className:"h-4 w-4 shrink-0 text-warn"}),a.jsxs("div",{className:"min-w-0 flex-1",children:["The code changed since this lens was made (",N.changed.map(z=>n(z)).join(", "),"). It may be out of date."]}),a.jsx(ee,{size:"sm",icon:a.jsx(m2,{className:"h-3.5 w-3.5"}),disabled:u.busy,onClick:()=>u.run(`/projects/${t.id}/lenses/${N.id}/refresh`,{},z=>l(`/p/${t.id}/lens/${z.resultId}`,{replace:!0})),children:"Refresh"})]}),u.busy&&u.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"lens",elapsed:u.elapsed})}),u.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:u.error,onClose:u.clearError})}),a.jsxs("div",{className:"mt-10 border-l-[3px] border-accent py-1 pl-5",children:[a.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-[0.08em] text-accent",children:"The idea in one sentence"}),a.jsx("p",{className:"read-lead mt-2",children:a.jsx(cr,{children:N.tldr||N.summary})})]}),N.whyItMatters&&a.jsxs("p",{className:"read mt-6",children:[a.jsx("strong",{children:"Why it matters."})," ",a.jsx(cr,{children:N.whyItMatters})]}),N.tldr&&N.summary&&a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:N.summary})}),N.sketch&&a.jsxs("div",{className:"mt-8 rounded-md bg-raised/70 p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-semibold",children:[a.jsx(V1,{className:"h-4 w-4 text-accent"})," ",N.diff?"Your prediction":"Your take",", and where it differs"]}),a.jsxs("p",{className:"read mt-3 italic text-muted",children:["“",N.sketch,"”"]}),N.differences&&N.differences.length>0&&a.jsx("ul",{className:"read mt-4 space-y-2",children:N.differences.map((z,W)=>a.jsxs("li",{className:"flex gap-2.5",children:[a.jsx("span",{className:"mt-0.5 text-accent",children:"→"}),a.jsx("span",{children:a.jsx(cr,{children:z})})]},W))})]}),N.concepts.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(Zf,{className:"h-5 w-5"}),children:"Words you need first"}),a.jsx("div",{className:"wide lens-concepts grid gap-5",children:N.concepts.map(z=>a.jsx(HT,{c:z,onShow:()=>O(z.file,z.line),onCard:()=>y({kind:"concept",front:`What is "${z.term}" in this code, and why does it matter?`,back:z.explain,file:z.file??N.files[0],source:{lensId:N.id}})},z.term))})]}),N.trace&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{children:"Trace a run"}),a.jsx("div",{className:"wide",children:a.jsx(qT,{trace:N.trace,onStep:(z,W)=>O(z??N.files[0],W)})})]}),N.intuition&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(ip,{className:"h-5 w-5"}),children:"The intuition"}),a.jsx(es,{children:N.intuition})]}),q.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs(Mi,{aside:a.jsx(Zt,{value:x,onChange:z=>{v(z),E(0)},options:[{value:"all",label:"All steps"},{value:"step",label:"One at a time"}]}),children:["Walkthrough ",a.jsxs("span",{className:"text-[15px] font-normal text-muted",children:["· ",q.length," steps"]})]}),x==="step"&&a.jsx("div",{className:"mb-6 flex items-center gap-1.5",children:q.map((z,W)=>a.jsx("button",{title:z.title,onClick:()=>E(W),className:le("h-1.5 flex-1 rounded-full transition",W<j?"bg-accent/50":W===j?"bg-accent":"bg-line")},W))}),a.jsx("ol",{className:"space-y-12 [&>li+li]:border-t [&>li+li]:border-line [&>li+li]:pt-10",children:G.map(([z,W])=>a.jsx(Rx,{d:z,n:W+1,text:z.file?C.get(z.file):void 0,rel:n,onShow:O},W))}),x==="step"&&a.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(xu,{className:"h-4 w-4"}),disabled:j===0,onClick:()=>E(j-1),children:"Back"}),a.jsxs("span",{className:"text-[13px] text-muted",children:["Step ",j+1," of ",q.length]}),a.jsxs(ee,{size:"sm",variant:j<q.length-1?"primary":"secondary",disabled:j===q.length-1,onClick:()=>E(j+1),children:["Next ",a.jsx(Tr,{className:"h-4 w-4"})]})]})]}),N.gotchas&&N.gotchas.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(op,{className:"h-5 w-5"}),children:"Gotchas"}),a.jsx("ul",{className:"read space-y-3",children:N.gotchas.map((z,W)=>a.jsxs("li",{className:"flex gap-3",children:[a.jsx("span",{className:"mt-[0.55em] h-1.5 w-1.5 shrink-0 rounded-full bg-warn"}),a.jsx("span",{children:a.jsx(cr,{children:z})})]},W))})]}),N.nextSteps&&N.nextSteps.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(Hu,{className:"h-5 w-5"}),children:"Read next"}),a.jsx("div",{className:"space-y-2",children:N.nextSteps.map(z=>a.jsxs("button",{onClick:()=>A(z.file),className:"card flex w-full items-start gap-3 px-4 py-3 text-left transition hover:border-accent/40",children:[a.jsx(os,{className:"mt-1 h-4 w-4 shrink-0 text-accent"}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block font-mono text-[13px]",children:n(z.file)}),a.jsx("span",{className:"read block text-muted",children:a.jsx(cr,{children:z.why})})]})]},z.file))})]}),(N.followUps??[]).length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Mi,{icon:a.jsx(n2,{className:"h-5 w-5"}),children:"Follow-ups"}),a.jsx("div",{className:"space-y-14",children:N.followUps.map((z,W)=>a.jsxs("div",{children:[a.jsxs("div",{className:"border-l-[3px] border-accent/60 py-1 pl-5",children:[a.jsxs("div",{className:"text-[11.5px] font-semibold uppercase tracking-[0.08em] text-accent",children:["You asked · ",Tt(z.at)]}),a.jsx("p",{className:"read mt-1 font-medium",children:z.question}),z.files.length>0&&a.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:z.files.map(S=>a.jsxs("button",{onClick:()=>O(S),title:n(S),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-ink/5 px-2 py-0.5 font-mono text-[11.5px] text-muted hover:text-accent",children:["+ ",a.jsx("span",{className:"truncate",children:fr(n(S),64)})]},S))})]}),a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:z.answer})}),z.deepDives.length>0&&a.jsx("ol",{className:"mt-10 space-y-12 [&>li+li]:border-t [&>li+li]:border-line [&>li+li]:pt-10",children:z.deepDives.map((S,D)=>a.jsx(Rx,{d:S,n:D+1,text:S.file?C.get(S.file):void 0,rel:n,onShow:O},D))})]},W))})]}),a.jsxs("section",{className:"mt-16 rounded-md border border-line p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[17px] font-semibold",children:[a.jsx(ag,{className:"h-4 w-4 text-accent"})," Ask more about this"]}),a.jsx("p",{className:"read mt-1 text-muted",children:"The answer is added to this lens, not a new one. New terms and gotchas join the lists above."}),a.jsx("textarea",{className:"input mt-4 min-h-[84px] resize-y text-[14px]",placeholder:"e.g. How would this change if the caller were an IAM user instead of a role? Ctrl+Enter to send.",value:d,onChange:z=>h(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.ctrlKey||z.metaKey)&&d.trim()&&!c.busy&&U()}}),V.length>0&&a.jsxs("label",{className:"mt-2 flex cursor-pointer items-center gap-2 text-[13px] text-muted",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:z=>f(z.target.checked)}),"Also use ",V.length===1?fr(n(V[0]),48):`the ${V.length} ticked files`," as context"]}),a.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[a.jsx(ee,{variant:"primary",icon:a.jsx(ag,{className:"h-4 w-4"}),disabled:c.busy||!d.trim(),onClick:U,children:"Add to lens"}),V.length===0&&a.jsx("span",{className:"text-[12.5px] text-muted",children:"Tick files in Explore to add them as extra context."})]}),c.busy&&c.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"lens",elapsed:c.elapsed})}),c.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:c.error,onClose:c.clearError})})]}),a.jsxs("section",{className:"mt-16 rounded-md border border-line bg-raised/40 p-6",children:[a.jsx("div",{className:"text-[17px] font-semibold",children:"Did it land?"}),a.jsx("p",{className:"read mt-1 text-muted",children:"Reading feels like understanding. A quiz on the same files tells you if it is."}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsx(ee,{variant:"primary",icon:a.jsx($a,{className:"h-4 w-4"}),disabled:o.busy,onClick:()=>o.run(`/projects/${t.id}/quizzes`,{lensId:N.id,files:N.files,diff:N.diff},z=>l(`/p/${t.id}/quiz/${z.resultId}`)),children:"Quiz me on this"}),a.jsx(ee,{variant:"ghost",icon:a.jsx(pr,{className:"h-4 w-4"}),onClick:async()=>{await cs(`/projects/${t.id}/lenses/${N.id}`),l(`/p/${t.id}/library`)},children:"Archive"})]}),o.busy&&o.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"quiz",elapsed:o.elapsed})}),o.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:o.error,onClose:o.clearError})}),k&&a.jsx(Ha,{initial:k,onClose:()=>y(null)})]})]})});return a.jsx(Kn,{id:"lens-file",collapsible:!0,startCollapsed:!0,openSignal:m,side:"right",initial:520,min:320,max:900,className:"h-full",left:X,right:a.jsx(kl,{file:m==null?void 0:m.file,line:m==null?void 0:m.line,empty:"Click a file, a step or a line link to see the whole file here."})})}function HT({c:e,onShow:t,onCard:n}){var o;const[r,i]=b.useState(!1),s=e.explain.length+(((o=e.example)==null?void 0:o.length)??0)>340,l=u=>a.jsxs(a.Fragment,{children:[a.jsx("p",{className:le("read-sm mt-2",u&&"line-clamp-5"),children:a.jsx(cr,{children:e.explain})}),e.example&&a.jsxs("div",{className:le("read-sm mt-3 rounded-lg bg-raised/70 px-3.5 py-2.5 text-muted",u&&"max-h-[9.5rem] overflow-hidden"),children:[a.jsx("div",{className:"mb-1 text-[11.5px] font-semibold uppercase tracking-[0.08em] text-ink/70",children:"Example"}),a.jsx(WT,{text:e.example})]})]});return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"card group flex flex-col p-5 transition duration-150 hover:-translate-y-0.5 hover:border-accent/40 hover:shadow-soft",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("div",{className:"flex-1 text-[16px] font-semibold tracking-tight",children:e.term}),e.file&&a.jsx("button",{className:"rounded bg-raised px-1.5 py-0.5 font-mono text-[11.5px] text-muted hover:text-accent",onClick:t,title:"Show in the code",children:e.line?`line ${e.line}`:"code"}),a.jsx("button",{className:"self-center text-muted opacity-0 transition hover:text-accent group-hover:opacity-100",title:"Make a review card",onClick:n,children:a.jsx(Fr,{className:"h-4 w-4"})}),a.jsx("button",{className:le("self-center text-muted transition hover:text-accent",s?"opacity-100":"opacity-0 group-hover:opacity-100"),title:"Open to read","aria-label":"Open to read",onClick:()=>i(!0),children:a.jsx(d2,{className:"h-4 w-4"})})]}),l(s),s&&a.jsx("button",{className:"mt-2 self-start text-[12.5px] text-accent hover:underline",onClick:()=>i(!0),children:"Read all"})]}),r&&a.jsx(tc,{wide:!0,title:e.term,onClose:()=>i(!1),footer:a.jsxs(a.Fragment,{children:[e.file&&a.jsx(ee,{size:"sm",variant:"ghost",onClick:()=>{i(!1),t()},children:"Show in the code"}),a.jsx(ee,{size:"sm",onClick:()=>{i(!1),n()},children:"Make a review card"})]}),children:a.jsx("div",{className:"[&_.read-sm]:!text-[16px] [&_.read-sm]:!leading-[1.65]",children:l(!1)})})]})}function WT({text:e}){const t=e.split(/(`[^`]{36,}`)/g).filter(n=>n.replace(/[\s.,;:]+/g,""));return a.jsx(a.Fragment,{children:t.map((n,r)=>/^`[^`]{36,}`$/.test(n)?a.jsx("pre",{className:"my-2 whitespace-pre-wrap break-words rounded-md border border-line/70 bg-panel px-3 py-2 font-mono text-[12.5px] leading-[1.6] text-ink",children:n.slice(1,-1)},r):a.jsx("p",{children:a.jsx(cr,{children:n})},r))})}function VT(e){return e.split("/").slice(-2).join("/")}function QT(e,t,n){const r=s=>{var l;return((l=/^\s*/.exec(s))==null?void 0:l[0].length)??0},i=r(e[n-1]??"");for(let s=t;s>=Math.max(1,t-25);s--){const l=e[s-1]??"";if(!l.trim())continue;if(/^\s*(def |async def |class |@|function |export |const |func |fn |pub |public |private )/.test(l)&&r(l)<=i||r(l)===0)return s}return t}function Rx({d:e,n:t,text:n,rel:r,onShow:i}){const[s,l]=b.useState(!1),o=BT(e),u=b.useMemo(()=>{if(!n||!o)return null;const d=n.text.split(`
505
505
  `),h=Math.min(o[1],d.length),p=QT(d,Math.min(o[0],d.length),e.line??o[0]),f=d.slice(p-1,h),m=Math.min(...f.filter(k=>k.trim()).map(k=>{var y;return((y=/^\s*/.exec(k))==null?void 0:y[0].length)??0})),g=f.map(k=>k.slice(Number.isFinite(m)?m:0)).join(`
506
506
  `);return{first:p,last:h,body:g}},[n,o==null?void 0:o[0],o==null?void 0:o[1],e.line]),c=b.useMemo(()=>e.line?[{from:e.line,to:e.line,cls:"hl"}]:[],[e.line]);return a.jsxs("li",{className:"lens-step",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("span",{className:"font-mono text-[13px] font-semibold tabular-nums text-accent/80",children:String(t).padStart(2,"0")}),a.jsx("h3",{className:"text-[18px] font-semibold leading-[1.3] tracking-tight",children:e.title})]}),a.jsx("div",{className:"mt-3",children:a.jsx(es,{children:e.body})})]}),u&&e.file&&a.jsxs("div",{className:"min-w-0 overflow-hidden rounded-md border border-line bg-panel",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line bg-raised/60 px-3 py-1.5 font-mono text-[12px] text-muted",children:[a.jsxs("span",{className:"truncate",title:r(e.file),children:[VT(r(e.file)),":",u.first,"–",u.last]}),a.jsx("button",{className:"shrink-0 font-sans hover:text-accent",onClick:()=>i(e.file,e.line),children:"open file"})]}),a.jsx("div",{className:"lens-step-code",children:a.jsx(Wa,{text:u.body,lang:n.lang,firstLine:u.first,marks:c,onLineClick:d=>i(e.file,d)})})]}),e.pitfall&&a.jsxs("p",{className:"read-sm flex gap-2.5 rounded-r-lg border-l-[3px] border-warn bg-warn/5 px-4 py-3",children:[a.jsx(op,{className:"mt-[0.25em] h-4 w-4 shrink-0 text-warn"}),a.jsxs("span",{children:[a.jsx("strong",{children:"Pitfall."})," ",a.jsx(cr,{children:e.pitfall})]})]}),e.check&&a.jsxs("div",{className:"read-sm rounded-r-lg border-l-[3px] border-accent bg-accent/5 px-4 py-3",children:[a.jsxs("p",{children:[a.jsx("strong",{className:"text-accent",children:"Check yourself."})," ",a.jsx(cr,{children:e.check.q})]}),s?a.jsx("p",{className:"mt-3 border-t border-line/70 pt-3 text-ink/85",children:a.jsx(cr,{children:e.check.a})}):a.jsxs("button",{className:"mt-2 inline-flex items-center gap-1.5 font-sans text-[13px] text-muted hover:text-ink",onClick:()=>l(!0),children:[a.jsx(O1,{className:"h-3.5 w-3.5"})," Think first, then show the answer"]})]})]})}function KT(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=mn(),s=ye({queryKey:["quiz",t.id,e],queryFn:()=>me(`/projects/${t.id}/quizzes/${e}`)}),[l,o]=b.useState({}),[u,c]=b.useState(!1),[d,h]=b.useState(null),[p,f]=b.useState(null),[m,g]=b.useState(null),k=mn(),y=ye({queryKey:["file",t.id,p==null?void 0:p.file],queryFn:()=>me(`/projects/${t.id}/file?path=${encodeURIComponent(p.file)}`),enabled:!!p}),x=s.data,v=(x==null?void 0:x.attempts)??[],j=v[v.length-1],E=u?void 0:d!==null?v[d]:j,w=`cognitune.quiz.${e}`;b.useEffect(()=>{try{const A=sessionStorage.getItem(w);A&&o(JSON.parse(A))}catch{}},[w]),b.useEffect(()=>{try{sessionStorage.setItem(w,JSON.stringify(l))}catch{}},[w,l]);const N=b.useMemo(()=>Object.values(l).filter(A=>A.answer.trim()).length,[l]);if(s.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!x)return a.jsx(Ft,{title:"Quiz not found"});const M=(A,V)=>o(U=>({...U,[A]:{...U[A]??{qid:A,answer:"",sure:!1},...V}})),F=()=>i.run(`/projects/${t.id}/quizzes/${x.id}/attempts`,{answers:Object.values(l)},()=>{c(!1),h(null),o({});try{sessionStorage.removeItem(w)}catch{}}),C=E?E.grades.filter(A=>{var V;return A.verdict==="wrong"&&((V=E.answers.find(U=>U.qid===A.qid))==null?void 0:V.sure)}).length:0,O=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsxs(ft,{to:`/p/${t.id}/library`,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-ink",children:[a.jsx(Jf,{className:"h-3.5 w-3.5"})," Library"]}),a.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[a.jsx(be,{tone:"accent",children:"quiz"}),x.diff&&a.jsx(be,{tone:"warn",children:"change"}),x.questions.some(A=>A.misconceptionId)&&a.jsxs(be,{tone:"bad",children:[a.jsx(Ji,{className:"h-3 w-3"})," weak spots"]}),a.jsxs("a",{href:`/api/projects/${t.id}/quizzes/${x.id}/export`,className:"ml-auto inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs text-muted hover:bg-raised hover:text-ink",title:"Download as markdown",children:[a.jsx(tp,{className:"h-3.5 w-3.5"})," .md"]}),a.jsxs("span",{className:"text-xs text-muted",children:[x.questions.length," questions · ",Tt(x.createdAt)]})]}),a.jsx("h1",{className:"mt-2 text-[20px] font-semibold leading-tight tracking-tight",children:x.title}),a.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[x.files.slice(0,6).map(A=>a.jsxs("button",{onClick:()=>f({file:A}),title:n(A),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-raised px-2 py-1 font-mono text-[12px] hover:text-accent",children:[a.jsx(os,{className:"h-3 w-3 shrink-0"})," ",a.jsx("span",{className:"truncate",children:fr(n(A),64)})]},A)),x.files.length>6&&a.jsxs("span",{className:"px-1 py-1 text-[12px] text-muted",children:["+",x.files.length-6," more"]})]}),E&&a.jsxs("div",{className:"card mt-6 flex flex-wrap items-center gap-4 p-4",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs uppercase tracking-wide text-muted",children:"Score"}),a.jsx("div",{className:"text-3xl",children:a.jsx(Ca,{score:E.score})})]}),a.jsxs("div",{className:"text-sm text-muted",children:[E.grades.filter(A=>A.verdict==="right").length," right · ",E.grades.filter(A=>A.verdict==="partial").length," partial ·"," ",E.grades.filter(A=>A.verdict==="wrong").length," wrong",C>0&&a.jsxs("div",{className:"text-bad",children:[C," wrong while sure: the best ones to look at."]})]}),v.length>1&&a.jsx("div",{className:"ml-auto",children:a.jsx(Zt,{value:d??v.length-1,onChange:A=>h(A),options:v.map((A,V)=>({value:V,label:`#${V+1}`,title:`${Math.round(A.score*100)}% · ${Tt(A.at)}`}))})})]}),a.jsx("ol",{className:"mt-6 space-y-4",children:x.questions.map((A,V)=>{const U=E==null?void 0:E.grades.find(X=>X.qid===A.id),q=E==null?void 0:E.answers.find(X=>X.qid===A.id),G=l[A.id];return a.jsxs("li",{className:le("card p-5",U&&(U.verdict==="right"?"border-good/30":U.verdict==="partial"?"border-warn/30":"border-bad/30")),children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-full bg-accent/10 text-sm font-semibold text-accent",children:V+1}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-[16px] font-medium leading-snug",children:A.prompt}),A.file&&a.jsxs("button",{className:"mt-1 font-mono text-[12px] text-muted hover:text-accent",onClick:()=>f({file:A.file,line:A.line}),children:[n(A.file),A.line?`:${A.line}`:""]})]}),U&&a.jsx(f0,{v:U.verdict})]}),E?a.jsxs("div",{className:"mt-4 space-y-3 pl-10",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"label flex items-center gap-2",children:["Your answer ",q!=null&&q.sure?a.jsx(be,{tone:"accent",children:"sure"}):a.jsx(be,{children:"guess"})]}),a.jsx("div",{className:"whitespace-pre-wrap rounded-lg bg-raised px-3 py-2 text-sm",children:(q==null?void 0:q.answer)||a.jsx("span",{className:"text-muted",children:"(no answer)"})})]}),(U==null?void 0:U.feedback)&&a.jsx("p",{className:"reading",children:U.feedback}),(U==null?void 0:U.modelAnswer)&&a.jsxs("div",{className:"reading rounded-lg border border-line px-4 py-3",children:[a.jsx("span",{className:"font-sans text-sm font-medium text-muted",children:"A good answer: "}),U.modelAnswer]}),(U==null?void 0:U.misconception)&&a.jsxs("div",{className:"flex gap-2 rounded-lg border border-bad/25 bg-bad/5 px-3 py-2 text-[14px]",children:[a.jsx(Ji,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-bad"}),a.jsxs("span",{children:[a.jsx("span",{className:"font-medium",children:"Saved as a weak spot: "}),U.misconception]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[A.focus&&a.jsxs("span",{className:"text-xs text-muted",children:["Tests: ",A.focus]}),U&&U.verdict!=="right"&&a.jsxs("span",{className:"ml-auto flex gap-1",children:[a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(Gu,{className:"h-3.5 w-3.5"}),disabled:k.busy,onClick:()=>k.run(`/projects/${t.id}/threads`,{files:x.files,text:`I got this quiz question ${U.verdict}:
507
507
 
@@ -511,4 +511,4 @@ My answer was: ${(q==null?void 0:q.answer)||"(none)"}
511
511
 
512
512
  Help me see what I missed, without just telling me.`},X=>r(`/p/${t.id}/tutor/${X.resultId}`)),children:"Ask the tutor"}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(Fr,{className:"h-3.5 w-3.5"}),onClick:()=>g({kind:"miss",front:A.prompt,back:U.modelAnswer,file:A.file,line:A.line,source:{quizId:x.id,qid:A.id}}),children:"Card"})]})]})]}):a.jsxs("div",{className:"mt-4 pl-10",children:[a.jsx("textarea",{className:"input min-h-[88px] resize-y",placeholder:"Your answer, in your own words",value:(G==null?void 0:G.answer)??"",onChange:X=>M(A.id,{answer:X.target.value})}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:a.jsx(Zt,{value:G!=null&&G.sure?"sure":"guess",onChange:X=>M(A.id,{sure:X==="sure"}),options:[{value:"guess",label:a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(F1,{className:"h-3.5 w-3.5"}),"Guess"]})},{value:"sure",label:a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(vl,{className:"h-3.5 w-3.5"}),"Sure"]})}]})})]})]},A.id)})}),a.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-2",children:[E?a.jsx(ee,{variant:"primary",icon:a.jsx(sp,{className:"h-4 w-4"}),onClick:()=>c(!0),children:"Try again"}):a.jsxs(a.Fragment,{children:[a.jsxs(ee,{variant:"primary",icon:a.jsx(K1,{className:"h-4 w-4"}),loading:i.busy,disabled:N===0,onClick:F,children:["Grade my answers (",N,"/",x.questions.length,")"]}),u&&a.jsx(ee,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"})]}),a.jsx(ee,{variant:"ghost",className:"ml-auto",icon:a.jsx(pr,{className:"h-4 w-4"}),onClick:async()=>{await cs(`/projects/${t.id}/quizzes/${x.id}`),r(`/p/${t.id}/library`)},children:"Archive"})]}),i.busy&&i.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"grade",elapsed:i.elapsed})}),k.busy&&k.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"tutor",elapsed:k.elapsed})}),k.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:k.error,onClose:k.clearError})}),m&&a.jsx(Ha,{initial:m,onClose:()=>g(null)}),i.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:i.error,onClose:i.clearError})})]})});return p?a.jsx(Kn,{id:"quiz-code",side:"right",initial:480,min:300,max:900,className:"h-full",left:O,right:a.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[a.jsxs("div",{className:"flex items-center border-b border-line px-4 py-2 font-mono text-[13px] text-muted",children:[a.jsxs("span",{className:"flex-1 truncate",children:[n(p.file),p.line?`:${p.line}`:""]}),a.jsx("button",{className:"text-xs hover:text-ink",onClick:()=>f(null),children:"close"})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:y.data&&a.jsx(Wa,{text:y.data.text,lang:y.data.lang,focusLine:p.line})})]})}):O}const GT=()=>({new:0,seen:0,understood:0,fading:0,stale:0}),qi=e=>e.total-e.counts.new,Sr=(e,t)=>t.startsWith(e.endsWith("/")?e:`${e}/`);function Vh(e,t,n,r){const i=t.filter(u=>Sr(e,u)),s=r.filter(u=>Sr(e,u.path)),l=new Map;for(const u of i){const c=s.find(g=>Sr(g.path,u)),d=u.slice(e.length+1),h=d.indexOf("/"),p=c?c.path:h<0?u:`${e}/${d.slice(0,h)}`;let f=l.get(p);f||(f={path:p,label:p.slice(e.length+1),kind:c?"repo":p===u?"file":"dir",total:0,counts:GT(),lastRetrieval:null},l.set(p,f));const m=n.get(u);f.total++,f.counts[(m==null?void 0:m.level)??"new"]++,m!=null&&m.lastRetrieval&&(!f.lastRetrieval||m.lastRetrieval>f.lastRetrieval)&&(f.lastRetrieval=m.lastRetrieval),f.kind==="file"&&(f.file=m)}const o=[...l.values()];for(const u of o)if(u.kind==="dir")for(;;){const c=Vh(u.path,i,n,[]);if(c.length!==1||c[0].kind!=="dir")break;u.path=c[0].path,u.label=u.path.slice(e.length+1)}return o.sort((u,c)=>(u.kind==="file"?1:0)-(c.kind==="file"?1:0)||qi(c)-qi(u)||u.label.localeCompare(c.label))}const Qh={new:"bg-line/70",seen:"bg-accent/35",understood:"bg-good",fading:"bg-warn/60",stale:"bg-warn"},Eu=["understood","fading","stale","seen","new"];function Kh({counts:e,total:t,className:n}){return a.jsx("div",{className:le("flex h-1.5 overflow-hidden rounded-full bg-line/50",n),children:Eu.map(r=>e[r]>0&&a.jsx("div",{className:Qh[r],style:{width:`${e[r]/Math.max(t,1)*100}%`,minWidth:r==="new"?0:4}},r))})}function YT({repos:e,current:t,onPick:n}){var d;const[r,i]=b.useState(!1),[s,l]=b.useState(""),o=b.useRef(null);b.useEffect(()=>{if(!r)return;const h=p=>{var f;return!((f=o.current)!=null&&f.contains(p.target))&&i(!1)};return window.addEventListener("mousedown",h),()=>window.removeEventListener("mousedown",h)},[r]);const u=e.filter(h=>h.label.toLowerCase().includes(s.toLowerCase())),c=(d=e.find(h=>h.path===t))==null?void 0:d.label;return a.jsxs("div",{ref:o,className:"relative",children:[a.jsxs("button",{onClick:()=>i(h=>!h),className:le("flex items-center gap-1.5 rounded-md px-2 py-1 font-mono text-[13px] transition hover:bg-raised",c?"text-ink":"text-muted"),children:[a.jsx(rp,{className:"h-3.5 w-3.5 text-accent"})," ",c??`all ${e.length} repos`," ",a.jsx(Yj,{className:"h-3.5 w-3.5 text-muted"})]}),r&&a.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1 w-[34rem] rounded-md border border-line bg-panel p-2 shadow-soft",children:[a.jsx("input",{className:"input mb-2",placeholder:"Filter repos",value:s,onChange:h=>l(h.target.value),autoFocus:!0}),a.jsxs("div",{className:"max-h-80 overflow-auto",children:[t&&a.jsx("button",{className:"w-full rounded px-2 py-1.5 text-left text-[13px] text-muted hover:bg-raised",onClick:()=>{n(null),i(!1)},children:"All repos"}),u.map(h=>a.jsxs("button",{onClick:()=>{n(h.path),i(!1)},className:le("grid w-full grid-cols-[1fr_5rem_4.5rem] items-center gap-3 rounded px-2 py-1.5 text-left hover:bg-raised",h.path===t&&"bg-raised"),children:[a.jsx("span",{className:"truncate font-mono text-[12.5px]",children:h.label}),a.jsx(Kh,{counts:h.counts,total:h.total}),a.jsxs("span",{className:"text-right text-[11.5px] tabular-nums text-muted",children:[qi(h)," / ",h.total]})]},h.path))]})]})]})}function XT({root:e,rootLabel:t,scope:n,repos:r,repoRows:i,onScope:s,children:l,className:o}){const u=r.find(p=>p.path===n||Sr(p.path,n))??null,c=u&&u.path!==e?u.path:e,d=(n===c?[]:n.slice(c.length+1).split("/")).map((p,f,m)=>({label:p,path:`${c}/${m.slice(0,f+1).join("/")}`})),h=i.length>0&&!u;return a.jsxs("div",{className:le("flex flex-wrap items-center gap-1 rounded-md border border-line bg-panel px-2 py-1.5",o),children:[a.jsx("button",{onClick:()=>s(null),className:le("rounded-md px-2 py-1 text-[13px] font-medium hover:bg-raised",n===e?"text-ink":"text-muted"),children:t}),i.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Tr,{className:"h-3.5 w-3.5 text-muted"}),a.jsx(YT,{repos:i,current:(u==null?void 0:u.path)??null,onPick:s})]}),(h?[]:d).map(p=>a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Tr,{className:"h-3.5 w-3.5 text-muted"}),a.jsx("button",{onClick:()=>s(p.path),className:le("rounded-md px-1.5 py-1 font-mono text-[13px] hover:bg-raised",p.path===n?"text-ink":"text-muted"),children:p.label})]},p.path)),h&&n!==e&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Tr,{className:"h-3.5 w-3.5 text-muted"}),a.jsx("span",{className:"px-1.5 py-1 font-mono text-[13px]",children:n.slice(e.length+1)})]}),l&&a.jsx("div",{className:"ml-auto flex items-center gap-2",children:l})]})}const zx=[{level:"understood",label:"Understood",tone:"good",text:"A check passed (quiz, teach-back 4+, walk, hunt, practice) on the code as it is now."},{level:"fading",label:"Fading",tone:"warn",text:"Understood, but nothing recalled for a while. A quick quiz or card keeps it."},{level:"stale",label:"Stale",tone:"warn",text:"You passed once, then the code changed. Check it again."},{level:"seen",label:"Seen",tone:"muted",text:"Touched by a lens or an activity, no pass yet."}];function Iw(e){return e.flatMap(t=>t.kind==="file"?[t.path]:Iw(t.children??[]))}const JT=e=>e==="understood"?"good":e==="stale"||e==="fading"?"warn":"muted";function ZT({groups:e,levels:t,onOpen:n,label:r}){return a.jsxs("div",{className:"card mt-4 p-4",children:[a.jsx("div",{className:"mb-3 flex flex-wrap gap-3 text-[12px] text-muted",children:Eu.map(i=>a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("span",{className:le("h-2.5 w-2.5 rounded-sm",Qh[i])}),i==="new"?"not yet":i]},i))}),a.jsx("div",{className:"space-y-2",children:e.map(([i,s])=>a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-56 shrink-0 truncate pt-0.5 text-right font-mono text-[12px] text-muted",title:i,children:i}),a.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(l=>a.jsx("button",{title:`${r(l)} · ${t.get(l)??"not yet"}`,onClick:()=>n(l),className:le("h-3.5 w-3.5 rounded-sm transition hover:scale-125 hover:ring-2 hover:ring-accent/50",Qh[t.get(l)??"new"])},l))})]},i))})]})}function eL(){const{project:e,setOpenFile:t,setSelected:n}=it(),r=gt(),[i,s]=ec(),l=e.root.replace(/\/$/,""),o=(i.get("in")??"").replace(/^\/+|\/+$/g,""),u=o?`${l}/${o}`:l,c=i.get("q")??"",d=i.get("level")??null,h=i.get("view")==="map"?"map":"table",[p,f]=b.useState(!1),m=(D,te=!1)=>{const P=new URLSearchParams(i);for(const[ve,Le]of Object.entries(D))Le?P.set(ve,Le):P.delete(ve);s(P,{replace:te})},g=D=>{f(!1),m({in:D&&D!==l?D.slice(l.length+1):null,q:null})},k=ye({queryKey:["progress",e.id],queryFn:()=>me(`/projects/${e.id}/progress`)}),y=ye({queryKey:["tree",e.id,e.contexts],queryFn:()=>me(`/projects/${e.id}/tree`)}),x=ye({queryKey:["repos",e.id,e.contexts],queryFn:()=>me(`/projects/${e.id}/repos`)}),v=b.useMemo(()=>x.data??[],[x.data]),j=b.useMemo(()=>new Map((k.data??[]).map(D=>[D.path,D])),[k.data]),E=b.useMemo(()=>new Map((k.data??[]).map(D=>[D.path,D.level])),[k.data]),w=b.useMemo(()=>[...new Set([...Iw(y.data??[]),...j.keys()])].filter(D=>Sr(l,D)),[y.data,j,l]),N=b.useMemo(()=>Vh(u,w,j,v),[u,w,j,v]),M=b.useMemo(()=>v.length>1?Vh(l,w,j,v).filter(D=>D.kind==="repo"):[],[v,l,w,j]),F=b.useMemo(()=>(k.data??[]).filter(D=>Sr(u,D.path)||D.path===u),[k.data,u]),C=b.useMemo(()=>Object.fromEntries(zx.map(D=>[D.level,F.filter(te=>te.level===D.level).length])),[F]),O=D=>Sr(u,D)?D.slice(u.length+1):D,A=D=>{t(D),n([D]),r(`/p/${e.id}/explore`)},V=c.toLowerCase().split(/\s+/).filter(Boolean),U=V.length?F.filter(D=>V.every(te=>O(D.path).toLowerCase().includes(te))&&(!d||D.level===d)):[],q=N.filter(D=>d?D.counts[d]>0:qi(D)>0),G=d?[]:N.filter(D=>qi(D)===0),X=b.useMemo(()=>{const D=new Map;for(const te of w){if(!Sr(u,te))continue;const P=N.find(Le=>Le.path===te||Sr(Le.path,te)),ve=P&&P.kind!=="file"?P.label:".";D.set(ve,[...D.get(ve)??[],te])}return[...D].sort((te,P)=>te[0]==="."?-1:P[0]==="."?1:te[0].localeCompare(P[0]))},[w,N,u]),z=N.reduce((D,te)=>D+te.total,0),W=N.reduce((D,te)=>D+qi(te),0),S=({r:D})=>D.kind==="file"?a.jsxs("tr",{className:"cursor-pointer border-b border-line/60 last:border-0 hover:bg-raised",onClick:()=>A(D.path),children:[a.jsx("td",{className:"max-w-0 px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-2 truncate font-mono text-[13px]",title:D.label,children:[a.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-muted"})," ",a.jsx("span",{className:"truncate",children:D.label})]})}),a.jsx("td",{className:"px-4 py-2",children:D.file?a.jsx(be,{tone:JT(D.file.level),children:D.file.level}):a.jsx("span",{className:"text-[12px] text-muted",children:"not yet"})}),a.jsx("td",{className:"px-4 py-2 text-right text-[12.5px] text-muted",children:D.file&&a.jsxs("span",{title:"best quiz · lenses · quizzes · other activities",children:[D.file.bestScore!==null&&a.jsxs(a.Fragment,{children:[a.jsx(Ca,{score:D.file.bestScore,size:"sm"})," · "]}),D.file.lenses," lens",D.file.lenses===1?"":"es"," · ",D.file.quizzes," quiz",D.file.quizzes===1?"":"zes",D.file.practices+D.file.other>0&&` · ${D.file.practices+D.file.other} other`]})}),a.jsx("td",{className:"px-4 py-2 text-right text-xs text-muted",children:D.lastRetrieval?Tt(D.lastRetrieval):"-"})]}):a.jsxs("tr",{className:"cursor-pointer border-b border-line/60 last:border-0 hover:bg-raised",onClick:()=>g(D.path),children:[a.jsx("td",{className:"max-w-0 px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[13px]",title:D.label,children:[D.kind==="repo"?a.jsx(rp,{className:"h-3.5 w-3.5 shrink-0 text-accent"}):a.jsx(np,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),a.jsx("span",{className:"truncate",children:D.label}),a.jsx(Tr,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-muted"})]})}),a.jsx("td",{className:"px-4 py-2",children:a.jsx(Kh,{counts:D.counts,total:D.total,className:"w-32"})}),a.jsxs("td",{className:"whitespace-nowrap px-4 py-2 text-right text-[12.5px] tabular-nums text-muted",children:[Eu.slice(0,3).map(te=>D.counts[te]>0&&a.jsxs("span",{className:le("mr-2",te==="understood"?"text-good":"text-warn"),children:[D.counts[te]," ",te]},te)),a.jsxs("span",{children:[qi(D)," / ",D.total," files"]})]}),a.jsx("td",{className:"px-4 py-2 text-right text-xs text-muted",children:D.lastRetrieval?Tt(D.lastRetrieval):"-"})]});return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"mx-auto max-w-5xl px-8 py-8",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Progress"}),a.jsx("p",{className:"text-sm text-muted",children:"Reading feels like understanding. Only a passed check counts here."})]}),a.jsx(Zt,{value:h,onChange:D=>m({view:D==="map"?"map":null}),options:[{value:"table",label:"Table"},{value:"map",label:"Heatmap"}]})]}),a.jsx(XT,{className:"mt-5",root:l,rootLabel:e.name,scope:u,repos:v,repoRows:M,onScope:g,children:a.jsxs("div",{className:"relative w-60",children:[a.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-2 h-3.5 w-3.5 text-muted"}),a.jsx("input",{className:"input h-8 pl-8 pr-7 text-[13px]",placeholder:u===l?"Search touched files":"Search in here",value:c,onChange:D=>m({q:D.target.value||null},!0)}),c&&a.jsx("button",{className:"absolute right-2 top-2 text-muted hover:text-ink",onClick:()=>m({q:null},!0),"aria-label":"Clear search",children:a.jsx(Rn,{className:"h-3.5 w-3.5"})})]})}),a.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-4",children:zx.map(D=>a.jsxs("button",{onClick:()=>m({level:d===D.level?null:D.level}),className:le("card p-4 text-left transition hover:border-accent/40",d===D.level&&"ring-2 ring-accent/30"),children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:D.label}),a.jsx(be,{tone:D.tone,children:D.level})]}),a.jsx("div",{className:"mt-2 text-3xl font-semibold tabular-nums",children:C[D.level]??0}),a.jsx("div",{className:"mt-1 text-xs text-muted",children:D.text})]},D.level))}),h==="map"?y.data?a.jsx(ZT,{groups:X,levels:E,onOpen:A,label:O}):null:(k.data??[]).length===0&&!k.isLoading?a.jsx(Ft,{icon:a.jsx(z1,{className:"h-6 w-6"}),title:"Nothing yet",children:"Make a lens or take a quiz in Explore. Files show up here as you go."}):a.jsxs("div",{className:"card mt-4 overflow-hidden",children:[a.jsxs("div",{className:"flex items-center gap-3 border-b border-line px-4 py-2.5 text-sm",children:[V.length?a.jsxs("span",{className:"font-medium",children:[U.length," touched file",U.length===1?"":"s"," match “",c,"”"]}):a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"font-medium",children:[W," of ",z," files touched"]}),a.jsx(Kh,{counts:N.reduce((D,te)=>(Eu.forEach(P=>D[P]+=te.counts[P]),D),{new:0,seen:0,understood:0,fading:0,stale:0}),total:z,className:"w-40"})]}),d&&a.jsxs("button",{className:"ml-auto flex items-center gap-1 text-xs text-muted hover:text-ink",onClick:()=>m({level:null}),children:["only ",d," ",a.jsx(Rn,{className:"h-3 w-3"})]})]}),a.jsxs("table",{className:"w-full table-fixed text-sm",children:[a.jsxs("colgroup",{children:[a.jsx("col",{}),a.jsx("col",{className:"w-36"}),a.jsx("col",{className:"w-[22rem]"}),a.jsx("col",{className:"w-24"})]}),a.jsxs("tbody",{children:[V.length?U.map(D=>a.jsx(S,{r:{path:D.path,label:O(D.path),kind:"file",total:1,counts:{new:0,seen:0,understood:0,fading:0,stale:0,[D.level]:1},lastRetrieval:D.lastRetrieval,file:D}},D.path)):q.map(D=>a.jsx(S,{r:D},D.path)),!V.length&&q.length===0&&a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-6 text-center text-sm text-muted",children:d?`Nothing ${d} in here.`:"Nothing touched in here yet."})}),!V.length&&p&&G.map(D=>a.jsx(S,{r:D},D.path))]})]}),!V.length&&G.length>0&&a.jsxs("button",{className:"w-full border-t border-line px-4 py-2 text-left text-[12.5px] text-muted hover:bg-raised hover:text-ink",onClick:()=>f(D=>!D),children:[p?"Hide":"Show"," ",G.length," untouched ",G.every(D=>D.kind==="file")?"files":"items"]})]})]})})}const tL=[{id:"auto",label:"Auto",text:"Claude Code, then Codex, then Copilot, then API key."},{id:"claude",label:"Claude Code CLI",text:"claude -p with read-only tools. Default."},{id:"codex",label:"Codex CLI",text:"codex exec in the read-only sandbox."},{id:"copilot",label:"GitHub Copilot CLI",text:"copilot -p with only the read tool."},{id:"sdk",label:"Anthropic API key",text:"ANTHROPIC_API_KEY from the environment."},{id:"fake",label:"Demo",text:"Canned answers, no model."}],la=e=>e<1024*1024?`${Math.max(1,Math.round(e/1024))} KB`:`${(e/1024/1024).toFixed(1)} MB`;function nL(){const e=Dt(),t=ye({queryKey:["storage"],queryFn:()=>me("/storage")}),n=vi({mutationFn:()=>Ci("/storage/prune"),onSuccess:i=>e.setQueryData(["storage"],i.usage)});if(!t.data)return null;const r=Math.max(1,...t.data.parts.map(i=>i.bytes));return a.jsxs("div",{className:"card mt-6 p-5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(o2,{className:"h-4 w-4 text-accent"}),a.jsx("div",{className:"text-sm font-semibold",children:"Storage"}),a.jsx("span",{className:"text-sm text-muted",children:la(t.data.totalBytes)}),a.jsx(ee,{size:"sm",className:"ml-auto shrink-0 whitespace-nowrap",loading:n.isPending,onClick:()=>n.mutate(),children:"Clean up now"})]}),a.jsx("div",{className:"mt-0.5 break-all font-mono text-[12px] text-muted",children:t.data.home}),a.jsx("p",{className:"mt-1 text-xs text-muted",children:"Plain JSON files, one per item. Archived items and forgotten projects are removed after the keep time below, the reply cache keeps to its size, and long lists (quiz attempts, card history, tutor chats, jobs) are capped. Cleanup runs at start and every 6 hours."}),a.jsx("div",{className:"mt-3 space-y-1.5",children:t.data.parts.map(i=>a.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[a.jsx("span",{className:"w-32 shrink-0 capitalize text-muted",children:i.name}),a.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-raised",children:a.jsx("div",{className:"h-full bg-accent/60",style:{width:`${i.bytes/r*100}%`}})}),a.jsxs("span",{className:"w-28 shrink-0 text-right tabular-nums text-muted",children:[la(i.bytes)," · ",i.files," file",i.files===1?"":"s"]})]},i.name))}),a.jsx("div",{className:"mt-3 text-[12px] text-muted",children:n.data?`Removed ${n.data.removed} item${n.data.removed===1?"":"s"}, freed ${la(n.data.freedBytes)}.`:t.data.lastPrune?`Last cleanup ${Tt(t.data.lastPrune.at)}: removed ${t.data.lastPrune.removed}.`:""}),a.jsx(rL,{})]})}function rL(){const e=Dt(),t=ye({queryKey:["storage-items"],queryFn:()=>me("/storage/items")}),[n,r]=b.useState(!1),[i,s]=b.useState(new Set),[l,o]=b.useState("all"),[u,c]=b.useState(!1),d=vi({mutationFn:()=>Ci("/storage/remove",{ids:[...i]}),onSuccess:x=>{e.setQueryData(["storage"],x.usage),e.invalidateQueries({queryKey:["storage-items"]}),e.invalidateQueries(),s(new Set),c(!1)}}),h=t.data??[],p=[...new Set(h.map(x=>x.group))].sort(),f=l==="all"?h:h.filter(x=>x.group===l),m=h.filter(x=>i.has(x.id)).reduce((x,v)=>x+v.bytes,0),g=f.length>0&&f.every(x=>i.has(x.id)),k=x=>s(v=>{const j=new Set(v);return j.has(x)?j.delete(x):j.add(x),j}),y=()=>s(x=>{const v=new Set(x);for(const j of f)g?v.delete(j.id):v.add(j.id);return v});return a.jsxs("div",{className:"mt-4 border-t border-line pt-4",children:[a.jsx("button",{className:"text-sm font-medium text-accent hover:underline",onClick:()=>r(!n),children:n?"Hide the list":`Choose what to remove (${h.length} items)`}),n&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("select",{className:"input h-8 w-auto py-0 text-xs",value:l,onChange:x=>o(x.target.value),children:[a.jsx("option",{value:"all",children:"All kinds"}),p.map(x=>a.jsx("option",{value:x,children:x},x))]}),a.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted",children:[a.jsx("input",{type:"checkbox",checked:g,onChange:y})," Select all shown"]}),a.jsxs("span",{className:"ml-auto text-xs text-muted",children:[i.size," selected · ",la(m)]}),u?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-bad",children:"This cannot be undone."}),a.jsx(ee,{size:"sm",onClick:()=>c(!1),children:"Cancel"}),a.jsxs(ee,{size:"sm",variant:"danger",loading:d.isPending,onClick:()=>d.mutate(),children:["Remove ",i.size]})]}):a.jsx(ee,{size:"sm",variant:"danger",disabled:!i.size,onClick:()=>c(!0),children:"Remove selected"})]}),a.jsxs("ul",{className:"mt-3 max-h-[26rem] divide-y divide-line/60 overflow-auto rounded-lg border border-line",children:[f.map(x=>a.jsx("li",{children:a.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-3 py-2 text-sm hover:bg-raised",children:[a.jsx("input",{type:"checkbox",className:"mt-1",checked:i.has(x.id),onChange:()=>k(x.id)}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate",children:x.label}),a.jsxs("span",{className:"block text-[12px] text-muted",children:[x.group,x.project?` · ${x.project}`:""," · ",Tt(x.at)]})]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted",children:la(x.bytes)})]})},x.id)),!f.length&&a.jsx("li",{className:"px-3 py-6 text-center text-sm text-muted",children:"Nothing here."})]}),d.error&&a.jsx(Ke,{error:d.error.message})]})]})}function iL(){const t=(ye({queryKey:["jobs"],queryFn:()=>me("/jobs")}).data??[]).slice(0,12);if(!t.length)return null;const n=r=>r.endedAt?Math.round((Date.parse(r.endedAt)-Date.parse(r.startedAt))/1e3):null;return a.jsxs("div",{className:"card mt-6 p-5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[a.jsx(u2,{className:"h-4 w-4 text-accent"})," Recent model calls"]}),a.jsx("table",{className:"mt-3 w-full text-xs",children:a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{className:"border-b border-line/60 last:border-0",children:[a.jsx("td",{className:"py-1.5 pr-3 font-medium",children:r.kind}),a.jsx("td",{className:le("py-1.5 pr-3",r.status==="failed"?"text-bad":r.status==="running"?"text-accent":"text-good"),children:r.status}),a.jsx("td",{className:"py-1.5 pr-3 tabular-nums text-muted",children:n(r)!==null?`${n(r)} s`:""}),a.jsx("td",{className:"max-w-[320px] truncate py-1.5 pr-3 text-muted",title:r.error,children:r.error??""}),a.jsx("td",{className:"py-1.5 text-right text-muted",children:Tt(r.startedAt)})]},r.id))})})]})}function xt({label:e,hint:t,children:n}){return a.jsxs("div",{className:"grid gap-1.5 py-4 sm:grid-cols-[220px_1fr] sm:gap-6",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:e}),t&&a.jsx("div",{className:"mt-0.5 text-xs text-muted",children:t})]}),a.jsx("div",{children:n})]})}function sL(){var p;const e=Dt(),t=ye({queryKey:["settings"],queryFn:()=>me("/settings")}),[n,r]=b.useState(null),{pref:i,setPref:s}=ly(),{font:l,setFont:o}=fk();b.useEffect(()=>{t.data&&!n&&r(t.data.settings)},[t.data,n]);const u=vi({mutationFn:f=>Eh("/settings",f),onSuccess:f=>{e.setQueryData(["settings"],f),e.invalidateQueries({queryKey:["health"]}),r(f.settings)}});if(!t.data||!n)return null;const c=(f,m)=>r({...n,[f]:m}),d=JSON.stringify(n)!==JSON.stringify(t.data.settings),h=((p=u.data)==null?void 0:p.agent)??t.data.agent;return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"mx-auto max-w-5xl px-8 py-10",children:[a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Settings"}),a.jsxs("p",{className:"mt-1 text-sm text-muted",children:["Saved in ",a.jsxs("span",{className:"font-mono",children:[t.data.home,"/settings.json"]})]}),a.jsxs("div",{className:le("card mt-6 flex items-start gap-3 p-4",h.ready?"border-good/30":"border-bad/30"),children:[a.jsx("div",{className:le("grid h-9 w-9 shrink-0 place-items-center rounded-lg",h.ready?"bg-good/12 text-good":"bg-bad/12 text-bad"),children:a.jsx(r2,{className:"h-[18px] w-[18px]"})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-semibold",children:h.ready?`Model ready: ${h.name}`:"No model available"}),a.jsx("div",{className:"text-sm text-muted",children:h.detail})]})]}),a.jsxs("div",{className:"card mt-6 divide-y divide-line px-5",children:[a.jsx(xt,{label:"Theme",children:a.jsx(Zt,{value:i,onChange:s,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]})}),a.jsx(xt,{label:"Reading font",hint:"For lessons, feedback and tutor replies. Buttons and labels stay in the system UI font.",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Zt,{value:l,onChange:o,options:[{value:"sans",label:"Sans"},{value:"serif",label:"Serif"}]}),a.jsx("span",{className:"reading text-muted",children:"Read the code, then explain it."})]})}),a.jsx(xt,{label:"Model access",hint:"CLIs use their own saved login, so cognitune never needs or stores a key. Auto picks the first one found.",children:a.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:tL.map(f=>{var k;const m=(k=h.available)==null?void 0:k[f.id],g=n["agent.mode"]===f.id;return a.jsxs("button",{onClick:()=>c("agent.mode",f.id),className:le("rounded-lg border px-3 py-2 text-left transition",g?"border-accent/60 bg-accent/8 ring-1 ring-accent/30":"border-line hover:bg-raised"),children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[f.label,f.id!=="auto"&&f.id!=="fake"&&a.jsx("span",{className:le("ml-auto shrink-0 whitespace-nowrap rounded-full px-1.5 text-[11.5px]",m?"bg-good/12 text-good":"bg-raised text-muted"),children:m?"found":"not found"})]}),a.jsx("div",{className:"text-xs text-muted",children:f.text})]},f.id)})})}),a.jsx(xt,{label:"Claude",hint:"Command and model for the Claude Code CLI (model also used by the API key mode).",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{className:"input w-36 font-mono",value:n["agent.claudeCommand"],onChange:f=>c("agent.claudeCommand",f.target.value)}),a.jsx("input",{className:"input font-mono",placeholder:"CLI default",value:n["agent.model"],onChange:f=>c("agent.model",f.target.value)})]})}),a.jsx(xt,{label:"Planning model",hint:"Plans every lens, quiz, walk, practice, bug hunt and path first (outline, steps, what each must cover). The model above then writes from that plan, in parts. Works with the Claude CLI and the API key; empty = the writer plans too.",children:a.jsx("input",{className:"input font-mono",placeholder:"same as the writer",value:n["agent.planModel"],onChange:f=>c("agent.planModel",f.target.value)})}),a.jsx(xt,{label:"Plan first",hint:"On: plan, then write in parts (slower, much better). Off: one model call per item.",children:a.jsx(Zt,{value:n["generate.plan"]?"on":"off",onChange:f=>c("generate.plan",f==="on"),options:[{value:"on",label:"On"},{value:"off",label:"Off"}]})}),a.jsx(xt,{label:"Codex",hint:"Command and model for the OpenAI Codex CLI. Empty model = its default.",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{className:"input w-36 font-mono",value:n["agent.codexCommand"],onChange:f=>c("agent.codexCommand",f.target.value)}),a.jsx("input",{className:"input font-mono",placeholder:"CLI default",value:n["agent.codexModel"],onChange:f=>c("agent.codexModel",f.target.value)})]})}),a.jsx(xt,{label:"Copilot",hint:"Command and model for the GitHub Copilot CLI. Empty model = its default.",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{className:"input w-36 font-mono",value:n["agent.copilotCommand"],onChange:f=>c("agent.copilotCommand",f.target.value)}),a.jsx("input",{className:"input font-mono",placeholder:"CLI default",value:n["agent.copilotModel"],onChange:f=>c("agent.copilotModel",f.target.value)})]})}),a.jsx(xt,{label:"Timeout",hint:"Seconds per model call.",children:a.jsx("input",{type:"number",min:30,className:"input w-32",value:n["agent.timeoutSec"],onChange:f=>c("agent.timeoutSec",Number(f.target.value))})}),a.jsx(xt,{label:"Questions per quiz",children:a.jsx("input",{type:"number",min:1,max:10,className:"input w-32",value:n["quiz.questions"],onChange:f=>c("quiz.questions",Number(f.target.value))})}),a.jsx(xt,{label:"Pass mark",hint:"Share of points to count a file as understood (partial = half).",children:a.jsx("input",{type:"number",min:.1,max:1,step:.01,className:"input w-32",value:n["quiz.passMark"],onChange:f=>c("quiz.passMark",Number(f.target.value))})}),a.jsx(xt,{label:"Context size",hint:"Most bytes of code sent in one prompt.",children:a.jsx("input",{type:"number",min:1e4,step:1e4,className:"input w-40",value:n["context.maxBytes"],onChange:f=>c("context.maxBytes",Number(f.target.value))})}),a.jsx(xt,{label:"Cards from misses",hint:"Each wrong or partial quiz answer becomes a review card.",children:a.jsx(Zt,{value:n["cards.fromMisses"]?"on":"off",onChange:f=>c("cards.fromMisses",f==="on"),options:[{value:"on",label:"On"},{value:"off",label:"Off"}]})}),a.jsx(xt,{label:"Fade after",hint:"Days without recall before an understood file shows as fading. 0 = never.",children:a.jsx("input",{type:"number",min:0,className:"input w-32",value:n["progress.fadeDays"],onChange:f=>c("progress.fadeDays",Number(f.target.value))})}),a.jsx(xt,{label:"Notes in prompts",hint:"Send your margin notes on a file with its code, so lenses and the tutor can use them.",children:a.jsx(Zt,{value:n["notes.inPrompts"]?"on":"off",onChange:f=>c("notes.inPrompts",f==="on"),options:[{value:"on",label:"On"},{value:"off",label:"Off"}]})}),a.jsx(xt,{label:"Keep archive",hint:"Days an archived item or forgotten project is kept before it is removed for good. 0 = forever.",children:a.jsx("input",{type:"number",min:0,className:"input w-32",value:n["storage.archiveDays"],onChange:f=>c("storage.archiveDays",Number(f.target.value))})}),a.jsx(xt,{label:"Reply cache",hint:"Most MB of saved model replies (the same lens twice is free). Oldest go first.",children:a.jsx("input",{type:"number",min:0,className:"input w-32",value:n["storage.cacheMB"],onChange:f=>c("storage.cacheMB",Number(f.target.value))})}),a.jsx(xt,{label:"Attempts per quiz",hint:"Older graded attempts are dropped; the best one is always kept.",children:a.jsx("input",{type:"number",min:1,className:"input w-32",value:n["storage.maxAttempts"],onChange:f=>c("storage.maxAttempts",Number(f.target.value))})})]}),u.error&&a.jsx("div",{className:"mt-4",children:a.jsx(Ke,{error:u.error.message})}),a.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[u.isSuccess&&!d&&a.jsxs("span",{className:"flex items-center gap-1 text-sm text-good",children:[a.jsx(ep,{className:"h-4 w-4"})," Saved"]}),a.jsx(ee,{variant:"ghost",disabled:!d,onClick:()=>r(t.data.settings),children:"Reset"}),a.jsx(ee,{variant:"primary",disabled:!d,loading:u.isPending,onClick:()=>u.mutate(n),children:"Save"})]}),a.jsx(nL,{}),a.jsx(iL,{})]})})}function Ga({to:e="library",label:t="Library"}){const{project:n}=it();return a.jsxs(ft,{to:`/p/${n.id}/${e}`,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-ink",children:[a.jsx(Jf,{className:"h-3.5 w-3.5"})," ",t]})}function dc(e){const{project:t}=it();return async n=>{await fetch(`/api/projects/${t.id}/${e}`,{method:"DELETE"}),n(`/p/${t.id}/library`)}}const lL={lens:"Read a lens",walk:"Walk through",quiz:"Quiz",teachback:"Teach back"},Fw={lens:"Start the lens",walk:"Start the walk",quiz:"Start the quiz",teachback:"Start the teach-back"};function aL(){var l;const{project:e}=it(),t=gt(),n=mn(),[r,i]=b.useState(""),s=ye({queryKey:["paths",e.id],queryFn:()=>me(`/projects/${e.id}/paths`)});return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Learning paths"}),a.jsx("p",{className:"text-sm text-muted",children:"An ordered tour of the repo: where to start, what next, and how to check each stop. Stops tick off as you do them."}),a.jsxs("div",{className:"card mt-6 p-5",children:[a.jsx("div",{className:"label",children:"What do you want to be able to do? (optional)"}),a.jsx("input",{className:"input",placeholder:"e.g. change how retries work, or review PRs to the scheduler",value:r,onChange:o=>i(o.target.value)}),a.jsx(ee,{variant:"primary",className:"mt-3",icon:a.jsx(ap,{className:"h-4 w-4"}),disabled:n.busy,onClick:()=>n.run(`/projects/${e.id}/paths`,{goal:r},o=>t(`/p/${e.id}/paths/${o.resultId}`)),children:"Make a path"}),n.busy&&n.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"path",elapsed:n.elapsed})}),n.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:n.error,onClose:n.clearError})})]}),a.jsx("div",{className:"mt-6 space-y-2",children:(l=s.data)==null?void 0:l.map(o=>{const u=o.done.filter(Boolean).length;return a.jsxs(ft,{to:`/p/${e.id}/paths/${o.id}`,className:"card flex items-center gap-3 p-4 transition hover:border-accent/40",children:[a.jsx(lp,{className:"h-5 w-5 text-good"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"font-medium",children:o.title}),a.jsxs("div",{className:"text-xs text-muted",children:[o.stops.length," stops · ",Tt(o.createdAt)]})]}),a.jsx("div",{className:"h-1.5 w-28 overflow-hidden rounded-full bg-line",children:a.jsx("div",{className:"h-full bg-good",style:{width:`${u/o.stops.length*100}%`}})}),a.jsxs("span",{className:"w-10 text-right text-xs tabular-nums text-muted",children:[u,"/",o.stops.length]})]},o.id)})})]})})}function oL(){const{id:e=""}=$r(),{project:t,rel:n,setSelected:r,setOpenFile:i}=it(),s=gt(),l=Dt(),o=ye({queryKey:["path",t.id,e],queryFn:()=>me(`/projects/${t.id}/paths/${e}`)}),u=vi({mutationFn:f=>Ua(`/projects/${t.id}/paths/${e}`,{stops:f}),onSuccess:f=>l.setQueryData(["path",t.id,e],f)});if(o.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!o.data)return a.jsx(Ft,{title:"Path not found"});const c=o.data,d=c.done.findIndex(f=>!f),h=(f,m)=>{const g=[...c.stops],[k]=g.splice(f,1);g.splice(f+m,0,k),u.mutate(g)},p=f=>{r(f.files),i(f.files[0]),s(`/p/${t.id}/explore?do=${f.activity==="teachback"?"teach":f.activity}`)};return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{to:"paths",label:"Paths"}),badges:a.jsxs(a.Fragment,{children:[a.jsx(be,{tone:"good",children:"path"}),a.jsxs("span",{className:"text-xs text-muted",children:[c.done.filter(Boolean).length,"/",c.stops.length," done · ",Tt(c.createdAt)]})]}),title:c.title,actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:async()=>{await cs(`/projects/${t.id}/paths/${c.id}`),s(`/p/${t.id}/paths`)},children:"Archive"})}),a.jsx("ol",{className:"relative mt-8 space-y-3 border-l-2 border-line pl-6",children:c.stops.map((f,m)=>a.jsxs("li",{className:"relative",children:[a.jsx("span",{className:le("absolute -left-[35px] top-4 grid h-5 w-5 place-items-center rounded-full bg-bg",c.done[m]?"text-good":m===d?"text-accent":"text-muted"),children:c.done[m]?a.jsx(vl,{className:"h-5 w-5"}):a.jsx(Zj,{className:"h-5 w-5"})}),a.jsxs("div",{className:le("card group p-4",m===d&&"ring-1 ring-accent/40"),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"text-xs text-muted",children:["Stop ",m+1," · ",lL[f.activity]??f.activity]}),a.jsx("div",{className:"font-medium",children:f.title})]}),a.jsxs("div",{className:"flex gap-0.5 opacity-0 transition group-hover:opacity-100",children:[a.jsx("button",{className:"rounded p-1 text-muted hover:bg-raised hover:text-ink disabled:opacity-30",disabled:m===0,onClick:()=>h(m,-1),"aria-label":"Move up",children:a.jsx(R1,{className:"h-3.5 w-3.5"})}),a.jsx("button",{className:"rounded p-1 text-muted hover:bg-raised hover:text-ink disabled:opacity-30",disabled:m===c.stops.length-1,onClick:()=>h(m,1),"aria-label":"Move down",children:a.jsx(Kj,{className:"h-3.5 w-3.5"})}),a.jsx("button",{className:"rounded p-1 text-muted hover:bg-raised hover:text-bad",onClick:()=>u.mutate(c.stops.filter((g,k)=>k!==m)),"aria-label":"Remove stop",children:a.jsx(Rn,{className:"h-3.5 w-3.5"})})]})]}),a.jsx("p",{className:"mt-1 text-[14.5px] text-muted",children:f.why}),a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[f.files.map(g=>a.jsx("span",{className:"rounded bg-raised px-1.5 py-0.5 font-mono text-[12px]",children:n(g)},g)),a.jsx(ee,{size:"sm",variant:m===d?"primary":"secondary",className:"ml-auto",onClick:()=>p(f),children:c.done[m]?"Do it again":Fw[f.activity]??"Start"})]})]})]},`${m}-${f.title}`))})]})})}function uL(){const{project:e,rel:t,setSelected:n,setOpenFile:r}=it(),i=gt(),s=mn(),l=ye({queryKey:["today",e.id],queryFn:()=>me(`/projects/${e.id}/today`)}),o=`/p/${e.id}`;if(l.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!l.data)return l.error?a.jsx("div",{className:"p-8",children:a.jsx(Ke,{error:l.error.message})}):null;const u=l.data,c=(d,h)=>{if(h==="review")return i(`${o}/review`);if(h==="weak")return s.run(`/projects/${e.id}/quizzes`,{files:[],weak:!0},f=>i(`${o}/quiz/${f.resultId}`));n(d),d[0]&&r(d[0]),i(`${o}/explore?do=${h==="teachback"?"teach":h}`)};return a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"mx-auto max-w-4xl px-8 py-8",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Today"}),a.jsx("span",{className:"text-sm text-muted",children:e.name}),u.streak>0&&a.jsxs(be,{tone:"warn",className:"ml-auto",children:[a.jsx(l2,{className:"h-3.5 w-3.5"})," ",u.streak," day",u.streak===1?"":"s"," in a row"]})]}),u.suggestion&&a.jsxs("div",{className:"card mt-6 flex items-center gap-4 border-accent/30 bg-accent/5 p-5",children:[a.jsx("div",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-md bg-accent/15 text-accent",children:a.jsx(ap,{className:"h-5 w-5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-accent",children:"Suggested next, about 10 minutes"}),a.jsx("div",{className:"mt-0.5 text-[16px]",children:u.suggestion.text})]}),a.jsx(ee,{variant:"primary",icon:a.jsx(Hu,{className:"h-4 w-4"}),disabled:s.busy,onClick:()=>c(u.suggestion.files,u.suggestion.activity),children:"Start"})]}),s.busy&&s.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:s.job.kind,elapsed:s.elapsed})}),s.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:s.error,onClose:s.clearError})}),a.jsxs("div",{className:"mt-6 grid gap-4 md:grid-cols-2",children:[a.jsxs("section",{className:"card p-5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[a.jsx(Fr,{className:"h-4 w-4 text-accent"})," Review cards"]}),a.jsxs("div",{className:"mt-3 flex items-end gap-3",children:[a.jsx("div",{className:"text-4xl font-semibold tabular-nums",children:u.due}),a.jsxs("div",{className:"pb-1 text-sm text-muted",children:["due now",u.newCards?` · ${u.newCards} never seen`:""]})]}),a.jsx(ee,{className:"mt-4",size:"sm",disabled:!u.due,onClick:()=>i(`${o}/review`),children:"Start review"})]}),a.jsxs("section",{className:"card p-5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[a.jsx(Ji,{className:"h-4 w-4 text-bad"})," Weak spots"]}),u.weak.length?a.jsx("ul",{className:"mt-3 space-y-2",children:u.weak.map(d=>a.jsxs("li",{className:"text-[14px] leading-snug",children:[d.text,a.jsxs("span",{className:"ml-1 text-[12px] text-muted",children:[d.file&&`· ${t(d.file)}`,d.seen>1&&` · seen ${d.seen}×`]})]},d.id))}):a.jsx("p",{className:"mt-3 text-sm text-muted",children:"None open. Wrong answers in quizzes, teach-backs and walkthroughs show up here."}),a.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[a.jsx(ee,{size:"sm",disabled:!u.weak.length||s.busy,onClick:()=>c([],"weak"),children:"Quiz my weak spots"}),u.weak.length>0&&a.jsx(ft,{to:`${o}/library?tab=weak`,className:"text-xs text-muted hover:text-ink",children:"manage"})]})]}),a.jsxs("section",{className:"card p-5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[a.jsx(k2,{className:"h-4 w-4 text-warn"})," Needs a refresh"]}),u.attention.length?a.jsx("ul",{className:"mt-3 space-y-1.5",children:u.attention.map(d=>a.jsxs("li",{className:"flex items-center gap-2 text-[14px]",children:[a.jsx("button",{className:"min-w-0 flex-1 truncate text-left font-mono text-[13px] hover:text-accent",onClick:()=>c([d.path],"quiz"),children:t(d.path)}),a.jsx(be,{tone:"warn",children:d.level}),d.lastRetrieval&&a.jsx("span",{className:"text-[12px] text-muted",children:Tt(d.lastRetrieval)})]},d.path))}):a.jsx("p",{className:"mt-3 text-sm text-muted",children:"Nothing stale or fading. Files you passed come back here when the code changes or a few weeks go by."})]}),a.jsxs("section",{className:"card p-5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[a.jsx(lp,{className:"h-4 w-4 text-good"})," Learning path"]}),u.nextStop?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mt-3 text-xs text-muted",children:[u.nextStop.title," · stop ",u.nextStop.index+1]}),a.jsx("div",{className:"mt-0.5 text-[16px] font-medium",children:u.nextStop.stop.title}),a.jsx("p",{className:"mt-1 text-[14px] text-muted",children:u.nextStop.stop.why}),a.jsxs("div",{className:"mt-4 flex gap-2",children:[a.jsx(ee,{size:"sm",variant:"primary",onClick:()=>c(u.nextStop.stop.files,u.nextStop.stop.activity),children:Fw[u.nextStop.stop.activity]??"Start"}),a.jsx(ft,{to:`${o}/paths/${u.nextStop.pathId}`,className:"inline-flex items-center text-xs text-muted hover:text-ink",children:"see the path"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"mt-3 text-sm text-muted",children:"A path is an ordered tour of the repo: where to start, what next, and how to check each stop."}),a.jsxs("div",{className:"mt-4 flex gap-2",children:[a.jsx(ee,{size:"sm",onClick:()=>i(`${o}/paths`),children:"Make a path"}),a.jsx(ee,{size:"sm",variant:"ghost",icon:a.jsx(W1,{className:"h-3.5 w-3.5"}),onClick:()=>i(`${o}/map`),children:"See the map"})]})]})]})]})]})})}const Ax=[{r:"again",label:"Again",key:"1",cls:"border-bad/40 text-bad hover:bg-bad/10"},{r:"hard",label:"Hard",key:"2",cls:"border-warn/40 text-warn hover:bg-warn/10"},{r:"good",label:"Good",key:"3",cls:"border-good/40 text-good hover:bg-good/10"},{r:"easy",label:"Easy",key:"4",cls:"border-accent/40 text-accent hover:bg-accent/10"}],cL={miss:"from a quiz miss",concept:"concept",own:"your card"};function dL(){var E,w,N,M,F,C,O;const{project:e,rel:t}=it(),n=Dt(),r=ye({queryKey:["cards-due",e.id],queryFn:()=>me(`/projects/${e.id}/cards/due`)}),i=ye({queryKey:["cards",e.id],queryFn:()=>me(`/projects/${e.id}/cards`)}),[s,l]=b.useState(!1),[o,u]=b.useState(""),[c,d]=b.useState(0),[h,p]=b.useState(!1),[f,m]=b.useState(!1),g=(E=r.data)==null?void 0:E[0];b.useEffect(()=>{l(!1),u(""),m(!1)},[g==null?void 0:g.id]);const k=async A=>{g&&(await Ci(`/projects/${e.id}/cards/${g.id}/review`,{rating:A}),d(V=>V+1),await n.invalidateQueries({queryKey:["cards-due",e.id]}),n.invalidateQueries({queryKey:["today",e.id]}),n.invalidateQueries({queryKey:["cards",e.id]}))};if(b.useEffect(()=>{const A=V=>{if(V.target.closest("textarea, input"))return;V.key===" "&&!s&&(V.preventDefault(),l(!0));const U=Ax.find(q=>q.key===V.key);U&&s&&k(U.r)};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)}),r.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});const y=((w=i.data)==null?void 0:w.length)??0,x=((N=i.data)==null?void 0:N.filter(A=>A.suspended).length)??0,v=(M=i.data)==null?void 0:M.filter(A=>!A.suspended).map(A=>A.fsrs.due).sort()[0],j=a.jsxs("div",{className:"h-full overflow-auto",children:[a.jsxs("div",{className:"page",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Review"}),a.jsxs(be,{tone:"accent",children:[((F=r.data)==null?void 0:F.length)??0," due"]}),c>0&&a.jsxs(be,{tone:"good",children:[c," done"]}),a.jsx(ee,{size:"sm",variant:"ghost",className:"ml-auto",icon:a.jsx(Q1,{className:"h-3.5 w-3.5"}),onClick:()=>p(!0),children:"New card"})]}),a.jsx("p",{className:"text-sm text-muted",children:"Recall before you reveal. Cards you know come back less often; cards you miss come back soon."}),g?a.jsxs("div",{className:"card mt-6 p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[a.jsx(Fr,{className:"h-3.5 w-3.5"})," ",cL[g.kind],g.file&&a.jsxs("button",{className:"ml-1 font-mono hover:text-accent",onClick:()=>m(A=>!A),children:[t(g.file),g.line?`:${g.line}`:""]}),a.jsx("span",{className:"ml-auto",children:g.fsrs.reps?`${g.fsrs.reps} reviews · ${g.fsrs.lapses} lapses`:"new"})]}),a.jsx("div",{className:"mt-3 text-[17px] font-medium leading-snug",children:g.front}),s?a.jsxs(a.Fragment,{children:[o.trim()&&a.jsxs("div",{className:"mt-4",children:[a.jsx("div",{className:"label",children:"You wrote"}),a.jsx("div",{className:"whitespace-pre-wrap rounded-lg bg-raised px-3 py-2 text-sm",children:o})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("div",{className:"label",children:"Answer"}),a.jsx("div",{className:"reading whitespace-pre-wrap rounded-lg border border-good/30 bg-good/5 px-4 py-3",children:g.back})]}),a.jsx("div",{className:"mt-5 grid grid-cols-4 gap-2",children:Ax.map(A=>a.jsxs("button",{onClick:()=>k(A.r),className:le("rounded-lg border px-2 py-2 text-center transition",A.cls),children:[a.jsxs("div",{className:"text-sm font-semibold",children:[A.label," ",a.jsx("span",{className:"kbd ml-0.5",children:A.key})]}),a.jsx("div",{className:"text-[12px] opacity-80",children:Th(g.next[A.r])})]},A.r))}),a.jsxs("div",{className:"mt-3 flex items-center justify-end gap-4",children:[(((C=g.source)==null?void 0:C.lensId)||((O=g.source)==null?void 0:O.quizId))&&a.jsxs(ft,{className:"mr-auto inline-flex items-center gap-1 text-xs text-muted hover:text-accent",to:g.source.lensId?`/p/${e.id}/lens/${g.source.lensId}`:`/p/${e.id}/quiz/${g.source.quizId}`,title:"Open what this card was made from",children:[a.jsx(i2,{className:"h-3.5 w-3.5"})," From ",g.source.lensId?"a lens":"a quiz"]}),a.jsxs("button",{className:"inline-flex items-center gap-1 text-xs text-muted hover:text-ink",title:"Stop showing this card",onClick:async()=>{await Ua(`/projects/${e.id}/cards/${g.id}`,{suspended:!0}),n.invalidateQueries()},children:[a.jsx(D1,{className:"h-3.5 w-3.5"})," Pause this card"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-4 min-h-[88px]",placeholder:"Type your answer (optional), then reveal",value:o,onChange:A=>u(A.target.value)}),a.jsxs(ee,{variant:"primary",className:"mt-3",icon:a.jsx(O1,{className:"h-4 w-4"}),onClick:()=>l(!0),children:["Reveal ",a.jsx("span",{className:"kbd ml-1",children:"space"})]})]})]}):a.jsx(Ft,{icon:a.jsx(vl,{className:"h-6 w-6"}),title:c?"All done for now":"Nothing due",children:y?a.jsxs(a.Fragment,{children:["You have ",y," card",y===1?"":"s",x?` (${x} paused)`:"",".",v&&` The next one is due in ${Th(v)}.`]}):a.jsx(a.Fragment,{children:"Cards come from quiz misses (on their own), lens concepts and your own. Take a quiz or make a card to start."})}),a.jsxs("p",{className:"mt-6 text-center text-xs text-muted",children:["All cards are in the ",a.jsx(ft,{className:"text-accent hover:underline",to:`/p/${e.id}/library?tab=cards`,children:"Library"}),"."]})]}),h&&a.jsx(Ha,{initial:{kind:"own"},onClose:()=>p(!1)})]});return!f||!(g!=null&&g.file)?j:a.jsx(Kn,{id:"review-code",side:"right",initial:480,min:300,max:900,className:"h-full",left:j,right:a.jsx(kl,{file:g.file,line:g.line,onClose:()=>m(!1)})})}const hL=["","Mostly wrong or empty","Some right, big gaps","Right but shallow","Right, covers what matters","Right, with the why and the edges"];function fL(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=mn(),s=dc(`teachbacks/${e}`),[l,o]=b.useState(null),[u,c]=b.useState(null),d=ye({queryKey:["teachback",t.id,e],queryFn:()=>me(`/projects/${t.id}/teachbacks/${e}`)});if(d.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!d.data)return a.jsx(Ft,{title:"Teach-back not found"});const h=d.data,p=h.grade,f=(g,k,y,x)=>k.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:`mb-2 flex items-center gap-1.5 text-sm font-semibold ${x}`,children:[y," ",g]}),a.jsx("ul",{className:"space-y-1.5",children:k.map((v,j)=>a.jsx("li",{className:"card reading px-4 py-2.5",children:v},j))})]}),m=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{}),badges:a.jsxs(a.Fragment,{children:[a.jsx(be,{tone:"accent",children:"teach-back"}),a.jsx("span",{className:"text-xs text-muted",children:Tt(h.createdAt)})]}),title:"Your explanation",actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>s(r),children:"Archive"})}),a.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[h.files.slice(0,6).map(g=>a.jsxs("button",{onClick:()=>o(g),title:n(g),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-raised px-2 py-1 font-mono text-[12px] hover:text-accent",children:[a.jsx(os,{className:"h-3 w-3 shrink-0"})," ",a.jsx("span",{className:"truncate",children:fr(n(g),64)})]},g)),h.files.length>6&&a.jsxs("span",{className:"px-1 py-1 text-[12px] text-muted",children:["+",h.files.length-6," more"]})]}),p&&a.jsxs("div",{className:"card mt-6 flex items-center gap-5 p-5",children:[a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:`text-4xl font-semibold ${p.score>=4?"text-good":p.score>=3?"text-warn":"text-bad"}`,children:[p.score,a.jsx("span",{className:"text-lg text-muted",children:"/5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:hL[p.score]}),a.jsx("div",{className:"text-sm text-muted",children:p.summary}),p.score>=4&&a.jsx("div",{className:"mt-1 text-xs text-good",children:"Counts as understood for these files."})]})]}),a.jsxs("section",{className:"mt-6",children:[a.jsx("div",{className:"label",children:"What you wrote"}),a.jsx("div",{className:"reading whitespace-pre-wrap rounded-lg bg-raised px-4 py-3",children:h.text})]}),p&&f("Wrong",p.wrong,a.jsx(A1,{className:"h-4 w-4"}),"text-bad"),p&&f("Missing",p.missing,a.jsx(I1,{className:"h-4 w-4"}),"text-warn"),p&&f("Right",p.right,a.jsx(vl,{className:"h-4 w-4"}),"text-good"),a.jsxs("section",{className:"mt-10 rounded-md border border-line bg-raised/50 p-5",children:[a.jsx("div",{className:"text-sm font-semibold",children:"Explain it again"}),a.jsx("p",{className:"mt-0.5 text-sm text-muted",children:"Close this page in your head: write it fresh, without copying the feedback."}),u===null?a.jsx(ee,{className:"mt-3",icon:a.jsx(sp,{className:"h-4 w-4"}),onClick:()=>c(""),children:"Try again"}):a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-3 min-h-[160px]",value:u,onChange:g=>c(g.target.value),autoFocus:!0}),a.jsx(ee,{variant:"primary",className:"mt-2",icon:a.jsx(Qu,{className:"h-4 w-4"}),disabled:i.busy||u.trim().length<20,onClick:()=>i.run(`/projects/${t.id}/teachbacks`,{files:h.files,text:u,diff:h.diff},g=>{c(null),r(`/p/${t.id}/teach/${g.resultId}`)}),children:"Grade this one"})]}),i.busy&&i.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"teachback",elapsed:i.elapsed})}),i.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:i.error,onClose:i.clearError})})]})]})});return l?a.jsx(Kn,{id:"teach-code",side:"right",initial:480,min:300,max:900,className:"h-full",left:m,right:a.jsx(kl,{file:l,onClose:()=>o(null)})}):m}const pL=/\blines?\s+(\d+(?:\s*(?:[-–]|to|,|and)\s*\d+)*)/gi,mL=/(\d+)|([-–]|to|,|and)/gi;function cd(e){return/^[a-z]+$/i.test(e)?` ${e} `:e===","?", ":e}function gL(e){return e.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((t,n)=>n%2?t:t.replace(pL,(r,i)=>{var u;const s=r.slice(0,r.length-i.length),l=[...i.matchAll(mL)];let o="";for(let c=0;c<l.length;c++){const d=l[c][1];if(!d)continue;const h=l[c+1];if(h&&!h[1]&&/^(-|–|to)$/i.test(h[2]??"")&&((u=l[c+2])!=null&&u[1])){const f=l[c+2][1];o+=`[${d}${cd(h[2])}${f}](codeline:${d}-${f})`,c+=2;const m=l[c+1];m&&!m[1]&&(o+=cd(m[2]))}else o+=`[${d}](codeline:${d}-${d})`,h&&(o+=cd(h[2]))}return s+o})).join("")}const xL=["","nudge","hint","walk-through","answer"];function yL(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=mn(),s=dc(`threads/${e}`),[l,o]=b.useState(""),[u,c]=b.useState(null),d=b.useRef(null),h=ye({queryKey:["thread",t.id,e],queryFn:()=>me(`/projects/${t.id}/threads/${e}`)}),p=h.data;if(b.useEffect(()=>{var y;(y=d.current)==null||y.scrollIntoView({behavior:"smooth"})},[p==null?void 0:p.messages.length,i.busy]),b.useEffect(()=>{p&&!u&&c({file:p.files[0]})},[p,u]),h.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!p)return a.jsx(Ft,{title:"Conversation not found"});const f=(y=!1)=>i.run(`/projects/${t.id}/threads/${p.id}/messages`,{text:l,tell:y},()=>o("")),m=(y,x)=>c(v=>({file:(v==null?void 0:v.file)??p.files[0],line:y,to:x})),g=a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"border-b border-line bg-panel px-4 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ga,{}),a.jsx(ee,{variant:"ghost",size:"sm",className:"ml-auto",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>s(r),children:"Archive"})]}),a.jsx("div",{className:"mt-0.5 truncate text-[13px] font-semibold",children:p.title}),a.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[p.files.slice(0,6).map(y=>a.jsxs("button",{onClick:()=>c({file:y}),title:n(y),className:"inline-flex max-w-full items-center gap-1 rounded-md bg-raised px-1.5 py-0.5 font-mono text-[11.5px] hover:text-accent",children:[a.jsx(os,{className:"h-3 w-3 shrink-0"})," ",a.jsx("span",{className:"truncate",children:fr(n(y),64)})]},y)),p.files.length>6&&a.jsxs("span",{className:"px-1 py-0.5 text-[11.5px] text-muted",children:["+",p.files.length-6," more"]})]})]}),a.jsxs("div",{className:"chat-area min-h-0 flex-1 overflow-auto px-[6%] py-3 [scrollbar-gutter:stable]",children:[p.messages.map((y,x)=>{const v=y.role==="user",j=x===0||p.messages[x-1].role!==y.role;return a.jsx("div",{className:le("flex",v?"justify-end":"justify-start",x>0&&(j?"mt-3":"mt-0.5")),children:a.jsxs("div",{className:le("chat-bubble",v?"chat-me":"chat-them",j&&"chat-first"),children:[!v&&y.hintLevel&&a.jsxs("div",{className:le("chat-label",y.hintLevel>=4?"text-warn":"text-accent"),children:[a.jsx(ip,{className:"h-3 w-3"})," Tutor · ",xL[y.hintLevel]]}),v?a.jsxs("div",{className:"whitespace-pre-wrap",children:[y.text,a.jsx("span",{className:"chat-spacer"})]}):a.jsx(es,{className:"chat-msg",onLineClick:m,children:gL(y.text)}),a.jsx("span",{className:"chat-time",children:new Date(y.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})},x)}),i.busy&&i.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"tutor",elapsed:i.elapsed})}),i.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:i.error,onClose:i.clearError})}),a.jsx("div",{ref:d})]}),a.jsxs("div",{className:"flex items-end gap-2 border-t border-line bg-panel px-3 py-2",children:[a.jsx("textarea",{rows:1,className:"max-h-40 min-h-[36px] flex-1 resize-none rounded-lg bg-raised px-3 py-2 text-[14px] leading-[1.4] text-ink outline-none [field-sizing:content] placeholder:text-muted/70 focus:ring-1 focus:ring-accent/50",placeholder:"Your answer or next question — try first, each reply gives a bit more. Ctrl+Enter to send.",value:l,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.ctrlKey||y.metaKey)&&l.trim()&&!i.busy&&f()}}),a.jsx(ee,{variant:"ghost",size:"md",className:"mb-[5px]",disabled:i.busy,onClick:()=>f(!0),children:"Just tell me"}),a.jsx("button",{className:"mb-[2px] grid h-8 w-8 shrink-0 place-items-center rounded-full bg-accent text-accent-ink transition hover:brightness-110 disabled:opacity-40",disabled:i.busy||!l.trim(),onClick:()=>f(),title:"Send (Ctrl+Enter)",children:a.jsx(K1,{className:"h-4 w-4"})})]})]}),k=u!=null&&u.to&&u.to!==u.line?[{from:u.line,to:u.to,cls:"hl"}]:void 0;return a.jsx(Kn,{id:"tutor-code",collapsible:!0,side:"right",initial:520,min:300,max:900,className:"h-full",left:g,right:a.jsx(kl,{file:u==null?void 0:u.file,line:u==null?void 0:u.line,marks:k})})}function vL(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=mn(),s=dc(`walks/${e}`),l=ye({queryKey:["walk",t.id,e],queryFn:()=>me(`/projects/${t.id}/walks/${e}`)}),o=l.data,u=ye({queryKey:["file",t.id,o==null?void 0:o.file],enabled:!!o,queryFn:()=>me(`/projects/${t.id}/file?path=${encodeURIComponent(o.file)}`)}),c=o?Math.max(0,o.blocks.findIndex(N=>!N.verdict)):0,[d,h]=b.useState(null),p=d??c,[f,m]=b.useState(""),[g,k]=b.useState(!1);b.useEffect(()=>{m(""),k(!1)},[p]);const y=b.useMemo(()=>{const N=o==null?void 0:o.blocks[p];if(!N||!u.data)return null;const M=u.data.text.split(`
513
513
  `),F=M.slice(N.startLine-1,Math.min(N.endLine,M.length)),C=Math.min(...F.filter(O=>O.trim()).map(O=>{var A;return((A=/^\s*/.exec(O))==null?void 0:A[0].length)??0}));return F.map(O=>O.slice(Number.isFinite(C)?C:0)).join(`
514
- `)},[o,p,u.data]),x=b.useMemo(()=>o?[{from:o.blocks[p].startLine,to:o.blocks[p].endLine,cls:"block"}]:[],[o,p]);if(l.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!o)return a.jsx(Ft,{title:"Walkthrough not found"});const v=o.blocks[p],j=o.blocks.filter(N=>N.verdict).length,E=o.blocks.reduce((N,M)=>N+(M.verdict==="right"?1:M.verdict==="partial"?.5:0),0),w=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{}),badges:a.jsxs(a.Fragment,{children:[a.jsx(be,{tone:"accent",children:"walkthrough"}),a.jsxs("span",{className:"text-xs text-muted",children:[j,"/",o.blocks.length," checked · ",Tt(o.createdAt)]})]}),title:a.jsx("span",{className:"font-mono text-[20px]",children:n(o.file)}),actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>s(r),children:"Archive"})}),a.jsx("div",{className:"mt-5 flex gap-1",children:o.blocks.map((N,M)=>a.jsx("button",{title:N.title,onClick:()=>h(M),className:le("h-2 flex-1 rounded-full transition",N.verdict==="right"?"bg-good":N.verdict==="partial"?"bg-warn":N.verdict==="wrong"?"bg-bad":"bg-line",M===p&&"ring-2 ring-accent/40 ring-offset-2 ring-offset-bg")},M))}),a.jsxs("div",{className:"card mt-6 p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:["Block ",p+1," of ",o.blocks.length," · lines ",v.startLine,"-",v.endLine,v.verdict&&a.jsx("span",{className:"ml-auto",children:a.jsx(f0,{v:v.verdict})})]}),a.jsx("h2",{className:"mt-1 text-lg font-semibold",children:v.title||`Block ${p+1}`}),a.jsx("p",{className:"reading mt-1 text-muted",children:v.why}),y!==null&&a.jsxs("div",{className:"mt-5 min-w-0 overflow-hidden rounded-md border border-line bg-panel",children:[a.jsxs("div",{className:"border-b border-line bg-raised/60 px-3 py-1.5 font-mono text-[12px] text-muted",children:[n(o.file).split("/").slice(-2).join("/"),":",v.startLine,"–",v.endLine]}),a.jsx("div",{className:"lens-step-code",children:a.jsx(Wa,{text:y,lang:u.data.lang,firstLine:v.startLine})})]}),v.explain&&a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:v.explain})}),v.example&&a.jsxs("div",{className:"mt-5 rounded-r-lg border-l-[3px] border-good bg-good/5 px-4 py-3",children:[a.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-good",children:[a.jsx(ip,{className:"h-3.5 w-3.5"})," Try it with real values"]}),a.jsx(es,{children:v.example})]}),a.jsx("div",{className:"mt-5 rounded-lg border border-accent/25 bg-accent/5 p-3 text-[15.5px] font-medium",children:v.question}),v.verdict&&a.jsxs("div",{className:le("mt-4 space-y-2",g&&"opacity-70"),children:[g&&a.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Your last answer"}),a.jsx("div",{className:"whitespace-pre-wrap rounded-lg bg-raised px-3 py-2 text-sm",children:v.answer||a.jsx("span",{className:"text-muted",children:"(no answer)"})}),v.feedback&&a.jsx("p",{className:"reading",children:v.feedback}),v.verdict!=="right"&&!g&&!i.busy&&a.jsx(ee,{size:"sm",icon:a.jsx(sp,{className:"h-3.5 w-3.5"}),onClick:()=>k(!0),children:"Try again"})]}),(!v.verdict||g)&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-4 min-h-[88px]",placeholder:g?"Answer again, in your own words (don't copy the feedback)":"Your answer, from the block on the right",value:f,onChange:N=>m(N.target.value),autoFocus:g}),a.jsx(ee,{variant:"primary",className:"mt-3",icon:a.jsx(ep,{className:"h-4 w-4"}),disabled:i.busy||!f.trim(),onClick:()=>{h(p),i.run(`/projects/${t.id}/walks/${o.id}/blocks/${p}`,{answer:f},()=>{k(!1),m("")})},children:"Check"})]}),i.busy&&i.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"walkcheck",elapsed:i.elapsed})}),i.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:i.error,onClose:i.clearError})}),a.jsx("div",{className:"mt-5 flex justify-end",children:p<o.blocks.length-1&&a.jsx(ee,{size:"sm",icon:a.jsx(Hu,{className:"h-3.5 w-3.5"}),onClick:()=>h(p+1),children:"Next block"})})]}),j===o.blocks.length&&a.jsxs("div",{className:"card mt-6 flex items-center gap-3 border-good/30 p-4",children:[a.jsx(Vu,{className:"h-5 w-5 text-good"}),a.jsxs("div",{className:"text-sm",children:["Walk done: ",Math.round(E/o.blocks.length*100),"% of the checks right. Next, try explaining the file in your own words (Teach) or hunt a bug in it."]})]})]})});return a.jsx(Kn,{id:"walk-code",collapsible:!0,side:"right",initial:560,min:320,max:960,className:"h-full",left:w,right:a.jsx(kl,{file:o.file,line:v.startLine,marks:x})})}const wL=["","easy","medium","hard"];function kL(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=Dt(),s=mn(),l=dc(`hunts/${e}`),o=ye({queryKey:["hunt",t.id,e],queryFn:()=>me(`/projects/${t.id}/hunts/${e}`)}),u=o.data,[c,d]=b.useState(null),[h,p]=b.useState(null),f=b.useRef();b.useEffect(()=>{u&&c===null&&d(u.marks)},[u,c]);const m=c??[],g=!!(u!=null&&u.grade),k=w=>{d(w),clearTimeout(f.current),f.current=setTimeout(()=>Eh(`/projects/${t.id}/hunts/${e}/marks`,{marks:w}).catch(()=>{}),400)},y=w=>{if(g)return p(w);p(w),m.some(N=>N.line===w)||k([...m,{line:w,why:""}].sort((N,M)=>N.line-M.line))},x=b.useMemo(()=>{if(!u)return[];const w=m.map(N=>({from:N.line,to:N.line,cls:"marked"}));if(u.grade)for(const N of u.planted)N&&w.push({from:N.line,to:N.line,cls:"bug"});return w},[u,m]);if(o.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!u)return a.jsx(Ft,{title:"Bug hunt not found"});const v=u.grade,j=u.planted.length,E=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{}),badges:a.jsxs(a.Fragment,{children:[a.jsxs(be,{tone:"bad",children:[a.jsx(Wu,{className:"h-3 w-3"})," bug hunt · ",wL[u.level]]}),a.jsxs("span",{className:"text-xs text-muted",children:[j," bug",j===1?"":"s"," planted · ",Tt(u.createdAt)]})]}),title:a.jsx("span",{className:"font-mono text-[20px]",children:n(u.file)}),actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>l(r),children:"Archive"})}),!v&&a.jsxs("p",{className:"mt-3 text-sm text-muted",children:["The code on the right is a copy with ",j," planted bug",j===1?"":"s",". Click a line you think is wrong, then say what it breaks. Your folder is not touched."]}),v&&a.jsxs("div",{className:"card mt-6 flex flex-wrap items-center gap-4 p-4",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs uppercase tracking-wide text-muted",children:"Score"}),a.jsx("div",{className:"text-3xl",children:a.jsx(Ca,{score:v.score})})]}),a.jsxs("div",{className:"text-sm text-muted",children:[v.found.length," found · ",v.missed.length," missed · ",v.falseAlarms.length," false alarm",v.falseAlarms.length===1?"":"s"]})]}),!v&&a.jsxs("section",{className:"mt-6 space-y-2",children:[a.jsxs("div",{className:"label",children:["Your marks · ",m.length]}),m.map((w,N)=>a.jsxs("div",{className:"card p-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>p(w.line),children:["line ",w.line]}),a.jsx("button",{className:"ml-auto text-muted hover:text-bad","aria-label":"Remove mark",onClick:()=>k(m.filter(M=>M.line!==w.line)),children:a.jsx(Rn,{className:"h-3.5 w-3.5"})})]}),a.jsx("input",{className:"input mt-2",placeholder:"What is wrong, and what does it break?",value:w.why,onChange:M=>k(m.map((F,C)=>C===N?{...F,why:M.target.value}:F))})]},w.line)),!m.length&&a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"No marks yet. Click a line in the code."}),a.jsx(ee,{variant:"primary",className:"mt-2",icon:a.jsx(ms,{className:"h-4 w-4"}),disabled:s.busy||!m.length,onClick:async()=>{clearTimeout(f.current),await Eh(`/projects/${t.id}/hunts/${e}/marks`,{marks:m}),s.run(`/projects/${t.id}/hunts/${e}/grade`,{},()=>i.invalidateQueries({queryKey:["hunt",t.id,e]}))},children:"Check my hunt"})]}),v&&a.jsxs(a.Fragment,{children:[v.found.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-good",children:[a.jsx(vl,{className:"h-4 w-4"})," Found"]}),v.found.map(w=>a.jsx(Ix,{h:u,line:w.line,what:w.what,feedback:w.feedback,onShow:p},w.line))]}),v.missed.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-bad",children:[a.jsx(I1,{className:"h-4 w-4"})," Missed"]}),v.missed.map(w=>a.jsx(Ix,{h:u,line:w.line,what:w.what,onShow:p},w.line))]}),v.falseAlarms.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-warn",children:[a.jsx(A1,{className:"h-4 w-4"})," False alarms"]}),v.falseAlarms.map(w=>a.jsxs("div",{className:"card mb-2 p-3 text-[14.5px]",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>p(w.line),children:["line ",w.line]}),a.jsx("div",{className:"mt-1",children:w.feedback||"This line is fine."})]},w.line))]})]}),s.busy&&s.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"huntgrade",elapsed:s.elapsed})}),s.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:s.error,onClose:s.clearError})})]})});return a.jsx(Kn,{id:"hunt-code",collapsible:!0,side:"right",initial:600,min:320,max:1e3,className:"h-full",left:E,right:a.jsx(kl,{file:u.file,text:u.text,title:`${n(u.file)} (copy with bugs)`,line:h,marks:x,onLineClick:y})})}function Ix({h:e,line:t,what:n,feedback:r,onShow:i}){const s=e.planted.find(l=>(l==null?void 0:l.line)===t);return a.jsxs("div",{className:"card mb-2 p-3 text-[14.5px]",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>i(t),children:["line ",t]}),s&&a.jsxs("div",{className:"mt-2 overflow-x-auto rounded-md bg-raised font-mono text-[13px]",children:[a.jsxs("div",{className:"whitespace-pre px-2 py-1 text-bad",children:["bug ",s.buggy.trim()]}),a.jsxs("div",{className:"whitespace-pre px-2 py-1 text-good",children:["real ",s.original.trim()]})]}),a.jsx("div",{className:"mt-2",children:n}),r&&a.jsx("div",{className:"mt-1 text-muted",children:r})]})}const bL=b.lazy(()=>ml(()=>import("./Map-xBJDQ_Xn.js"),[]).then(e=>({default:e.MapPage}))),jL=b.lazy(()=>ml(()=>import("./Practice-DNf-tMjl.js").then(e=>e.K),[]).then(e=>({default:e.PracticePage})));oy();const NL=new Aj({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function SL(){return a.jsx(Ft,{title:"Project not found",action:a.jsx(ee,{onClick:()=>location.href="/",children:"Back to projects"}),children:"It may have been removed from the list. Open its folder again."})}function CL(){const{pid:e=""}=$r();return a.jsx(vS,{pid:e,fallback:a.jsx(SL,{}),children:a.jsx(c0,{})},e)}const EL=WN([{element:a.jsx(yS,{}),children:[{path:"/",element:a.jsx(kS,{})},{path:"/settings",element:a.jsx(sL,{})},{path:"/help",element:a.jsx(oS,{})},{path:"/p/:pid",element:a.jsx(CL,{}),children:[{index:!0,element:a.jsx(FN,{to:"today",replace:!0})},{path:"today",element:a.jsx(uL,{})},{path:"explore",element:a.jsx(AS,{})},{path:"review",element:a.jsx(dL,{})},{path:"map",element:a.jsx(b.Suspense,{fallback:null,children:a.jsx(bL,{})})},{path:"paths",element:a.jsx(aL,{})},{path:"paths/:id",element:a.jsx(oL,{})},{path:"teach/:id",element:a.jsx(fL,{})},{path:"tutor/:id",element:a.jsx(yL,{})},{path:"walk/:id",element:a.jsx(vL,{})},{path:"hunt/:id",element:a.jsx(kL,{})},{path:"changes",element:a.jsx(WS,{})},{path:"library",element:a.jsx(KS,{})},{path:"progress",element:a.jsx(eL,{})},{path:"lens/:id",element:a.jsx(UT,{})},{path:"quiz/:id",element:a.jsx(KT,{})},{path:"practice/:id",element:a.jsx(b.Suspense,{fallback:null,children:a.jsx(jL,{})})}]},{path:"*",element:a.jsx(Ft,{title:"Page not found"})}]}]);c1(document.getElementById("root")).render(a.jsx(b.StrictMode,{children:a.jsx($j,{client:NL,children:a.jsx(ZN,{router:EL})})}));export{Jf as A,ee as B,ep as C,sp as D,Ft as E,np as F,rp as G,cs as H,Kn as I,sn as J,Eh as K,ft as L,W1 as M,eC as N,xp as O,cC as P,aC as Q,m2 as R,XT as S,pr as T,GS as U,f0 as V,dC as W,Nx as X,ml as _,it as a,gt as b,Dt as c,ec as d,ye as e,Vh as f,Tt as g,os as h,be as i,a as j,me as k,TL as l,Gh as m,J as n,$r as o,hk as p,mn as q,b as r,kt as s,Wa as t,Sr as u,ip as v,le as w,Ke as x,K1 as y,O1 as z};
514
+ `)},[o,p,u.data]),x=b.useMemo(()=>o?[{from:o.blocks[p].startLine,to:o.blocks[p].endLine,cls:"block"}]:[],[o,p]);if(l.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!o)return a.jsx(Ft,{title:"Walkthrough not found"});const v=o.blocks[p],j=o.blocks.filter(N=>N.verdict).length,E=o.blocks.reduce((N,M)=>N+(M.verdict==="right"?1:M.verdict==="partial"?.5:0),0),w=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{}),badges:a.jsxs(a.Fragment,{children:[a.jsx(be,{tone:"accent",children:"walkthrough"}),a.jsxs("span",{className:"text-xs text-muted",children:[j,"/",o.blocks.length," checked · ",Tt(o.createdAt)]})]}),title:a.jsx("span",{className:"font-mono text-[20px]",children:n(o.file)}),actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>s(r),children:"Archive"})}),a.jsx("div",{className:"mt-5 flex gap-1",children:o.blocks.map((N,M)=>a.jsx("button",{title:N.title,onClick:()=>h(M),className:le("h-2 flex-1 rounded-full transition",N.verdict==="right"?"bg-good":N.verdict==="partial"?"bg-warn":N.verdict==="wrong"?"bg-bad":"bg-line",M===p&&"ring-2 ring-accent/40 ring-offset-2 ring-offset-bg")},M))}),a.jsxs("div",{className:"card mt-6 p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:["Block ",p+1," of ",o.blocks.length," · lines ",v.startLine,"-",v.endLine,v.verdict&&a.jsx("span",{className:"ml-auto",children:a.jsx(f0,{v:v.verdict})})]}),a.jsx("h2",{className:"mt-1 text-lg font-semibold",children:v.title||`Block ${p+1}`}),a.jsx("p",{className:"reading mt-1 text-muted",children:v.why}),y!==null&&a.jsxs("div",{className:"mt-5 min-w-0 overflow-hidden rounded-md border border-line bg-panel",children:[a.jsxs("div",{className:"border-b border-line bg-raised/60 px-3 py-1.5 font-mono text-[12px] text-muted",children:[n(o.file).split("/").slice(-2).join("/"),":",v.startLine,"–",v.endLine]}),a.jsx("div",{className:"lens-step-code",children:a.jsx(Wa,{text:y,lang:u.data.lang,firstLine:v.startLine})})]}),v.explain&&a.jsx("div",{className:"mt-5",children:a.jsx(es,{children:v.explain})}),v.example&&a.jsxs("div",{className:"mt-5 rounded-r-lg border-l-[3px] border-good bg-good/5 px-4 py-3",children:[a.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-good",children:[a.jsx(ip,{className:"h-3.5 w-3.5"})," Try it with real values"]}),a.jsx(es,{children:v.example})]}),a.jsx("div",{className:"mt-5 rounded-lg border border-accent/25 bg-accent/5 p-3 text-[15.5px] font-medium",children:v.question}),v.verdict&&a.jsxs("div",{className:le("mt-4 space-y-2",g&&"opacity-70"),children:[g&&a.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Your last answer"}),a.jsx("div",{className:"whitespace-pre-wrap rounded-lg bg-raised px-3 py-2 text-sm",children:v.answer||a.jsx("span",{className:"text-muted",children:"(no answer)"})}),v.feedback&&a.jsx("p",{className:"reading",children:v.feedback}),v.verdict!=="right"&&!g&&!i.busy&&a.jsx(ee,{size:"sm",icon:a.jsx(sp,{className:"h-3.5 w-3.5"}),onClick:()=>k(!0),children:"Try again"})]}),(!v.verdict||g)&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"input mt-4 min-h-[88px]",placeholder:g?"Answer again, in your own words (don't copy the feedback)":"Your answer, from the block on the right",value:f,onChange:N=>m(N.target.value),autoFocus:g}),a.jsx(ee,{variant:"primary",className:"mt-3",icon:a.jsx(ep,{className:"h-4 w-4"}),disabled:i.busy||!f.trim(),onClick:()=>{h(p),i.run(`/projects/${t.id}/walks/${o.id}/blocks/${p}`,{answer:f},()=>{k(!1),m("")})},children:"Check"})]}),i.busy&&i.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"walkcheck",elapsed:i.elapsed})}),i.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:i.error,onClose:i.clearError})}),a.jsx("div",{className:"mt-5 flex justify-end",children:p<o.blocks.length-1&&a.jsx(ee,{size:"sm",icon:a.jsx(Hu,{className:"h-3.5 w-3.5"}),onClick:()=>h(p+1),children:"Next block"})})]}),j===o.blocks.length&&a.jsxs("div",{className:"card mt-6 flex items-center gap-3 border-good/30 p-4",children:[a.jsx(Vu,{className:"h-5 w-5 text-good"}),a.jsxs("div",{className:"text-sm",children:["Walk done: ",Math.round(E/o.blocks.length*100),"% of the checks right. Next, try explaining the file in your own words (Teach) or hunt a bug in it."]})]})]})});return a.jsx(Kn,{id:"walk-code",collapsible:!0,side:"right",initial:560,min:320,max:960,className:"h-full",left:w,right:a.jsx(kl,{file:o.file,line:v.startLine,marks:x})})}const wL=["","easy","medium","hard"];function kL(){const{id:e=""}=$r(),{project:t,rel:n}=it(),r=gt(),i=Dt(),s=mn(),l=dc(`hunts/${e}`),o=ye({queryKey:["hunt",t.id,e],queryFn:()=>me(`/projects/${t.id}/hunts/${e}`)}),u=o.data,[c,d]=b.useState(null),[h,p]=b.useState(null),f=b.useRef();b.useEffect(()=>{u&&c===null&&d(u.marks)},[u,c]);const m=c??[],g=!!(u!=null&&u.grade),k=w=>{d(w),clearTimeout(f.current),f.current=setTimeout(()=>Eh(`/projects/${t.id}/hunts/${e}/marks`,{marks:w}).catch(()=>{}),400)},y=w=>{if(g)return p(w);p(w),m.some(N=>N.line===w)||k([...m,{line:w,why:""}].sort((N,M)=>N.line-M.line))},x=b.useMemo(()=>{if(!u)return[];const w=m.map(N=>({from:N.line,to:N.line,cls:"marked"}));if(u.grade)for(const N of u.planted)N&&w.push({from:N.line,to:N.line,cls:"bug"});return w},[u,m]);if(o.isLoading)return a.jsx("div",{className:"p-8",children:a.jsx(kt,{})});if(!u)return a.jsx(Ft,{title:"Bug hunt not found"});const v=u.grade,j=u.planted.length,E=a.jsx("div",{className:"h-full overflow-auto",children:a.jsxs("div",{className:"page",children:[a.jsx(nc,{back:a.jsx(Ga,{}),badges:a.jsxs(a.Fragment,{children:[a.jsxs(be,{tone:"bad",children:[a.jsx(Wu,{className:"h-3 w-3"})," bug hunt · ",wL[u.level]]}),a.jsxs("span",{className:"text-xs text-muted",children:[j," bug",j===1?"":"s"," planted · ",Tt(u.createdAt)]})]}),title:a.jsx("span",{className:"font-mono text-[20px]",children:n(u.file)}),actions:a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(pr,{className:"h-3.5 w-3.5"}),onClick:()=>l(r),children:"Archive"})}),!v&&a.jsxs("p",{className:"mt-3 text-sm text-muted",children:["The code on the right is a copy with ",j," planted bug",j===1?"":"s",". Click a line you think is wrong, then say what it breaks. Your folder is not touched."]}),v&&a.jsxs("div",{className:"card mt-6 flex flex-wrap items-center gap-4 p-4",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs uppercase tracking-wide text-muted",children:"Score"}),a.jsx("div",{className:"text-3xl",children:a.jsx(Ca,{score:v.score})})]}),a.jsxs("div",{className:"text-sm text-muted",children:[v.found.length," found · ",v.missed.length," missed · ",v.falseAlarms.length," false alarm",v.falseAlarms.length===1?"":"s"]})]}),!v&&a.jsxs("section",{className:"mt-6 space-y-2",children:[a.jsxs("div",{className:"label",children:["Your marks · ",m.length]}),m.map((w,N)=>a.jsxs("div",{className:"card p-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>p(w.line),children:["line ",w.line]}),a.jsx("button",{className:"ml-auto text-muted hover:text-bad","aria-label":"Remove mark",onClick:()=>k(m.filter(M=>M.line!==w.line)),children:a.jsx(Rn,{className:"h-3.5 w-3.5"})})]}),a.jsx("input",{className:"input mt-2",placeholder:"What is wrong, and what does it break?",value:w.why,onChange:M=>k(m.map((F,C)=>C===N?{...F,why:M.target.value}:F))})]},w.line)),!m.length&&a.jsx("p",{className:"rounded-lg border border-dashed border-line p-3 text-[14px] text-muted",children:"No marks yet. Click a line in the code."}),a.jsx(ee,{variant:"primary",className:"mt-2",icon:a.jsx(ms,{className:"h-4 w-4"}),disabled:s.busy||!m.length,onClick:async()=>{clearTimeout(f.current),await Eh(`/projects/${t.id}/hunts/${e}/marks`,{marks:m}),s.run(`/projects/${t.id}/hunts/${e}/grade`,{},()=>i.invalidateQueries({queryKey:["hunt",t.id,e]}))},children:"Check my hunt"})]}),v&&a.jsxs(a.Fragment,{children:[v.found.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-good",children:[a.jsx(vl,{className:"h-4 w-4"})," Found"]}),v.found.map(w=>a.jsx(Ix,{h:u,line:w.line,what:w.what,feedback:w.feedback,onShow:p},w.line))]}),v.missed.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-bad",children:[a.jsx(I1,{className:"h-4 w-4"})," Missed"]}),v.missed.map(w=>a.jsx(Ix,{h:u,line:w.line,what:w.what,onShow:p},w.line))]}),v.falseAlarms.length>0&&a.jsxs("section",{className:"mt-6",children:[a.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-sm font-semibold text-warn",children:[a.jsx(A1,{className:"h-4 w-4"})," False alarms"]}),v.falseAlarms.map(w=>a.jsxs("div",{className:"card mb-2 p-3 text-[14.5px]",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>p(w.line),children:["line ",w.line]}),a.jsx("div",{className:"mt-1",children:w.feedback||"This line is fine."})]},w.line))]})]}),s.busy&&s.job&&a.jsx("div",{className:"mt-3",children:a.jsx(sn,{kind:"huntgrade",elapsed:s.elapsed})}),s.error&&a.jsx("div",{className:"mt-3",children:a.jsx(Ke,{error:s.error,onClose:s.clearError})})]})});return a.jsx(Kn,{id:"hunt-code",collapsible:!0,side:"right",initial:600,min:320,max:1e3,className:"h-full",left:E,right:a.jsx(kl,{file:u.file,text:u.text,title:`${n(u.file)} (copy with bugs)`,line:h,marks:x,onLineClick:y})})}function Ix({h:e,line:t,what:n,feedback:r,onShow:i}){const s=e.planted.find(l=>(l==null?void 0:l.line)===t);return a.jsxs("div",{className:"card mb-2 p-3 text-[14.5px]",children:[a.jsxs("button",{className:"font-mono text-xs text-accent hover:underline",onClick:()=>i(t),children:["line ",t]}),s&&a.jsxs("div",{className:"mt-2 overflow-x-auto rounded-md bg-raised font-mono text-[13px]",children:[a.jsxs("div",{className:"whitespace-pre px-2 py-1 text-bad",children:["bug ",s.buggy.trim()]}),a.jsxs("div",{className:"whitespace-pre px-2 py-1 text-good",children:["real ",s.original.trim()]})]}),a.jsx("div",{className:"mt-2",children:n}),r&&a.jsx("div",{className:"mt-1 text-muted",children:r})]})}const bL=b.lazy(()=>ml(()=>import("./Map-DS1CSocK.js"),[]).then(e=>({default:e.MapPage}))),jL=b.lazy(()=>ml(()=>import("./Practice-I2bYp2SG.js").then(e=>e.K),[]).then(e=>({default:e.PracticePage})));oy();const NL=new Aj({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function SL(){return a.jsx(Ft,{title:"Project not found",action:a.jsx(ee,{onClick:()=>location.href="/",children:"Back to projects"}),children:"It may have been removed from the list. Open its folder again."})}function CL(){const{pid:e=""}=$r();return a.jsx(vS,{pid:e,fallback:a.jsx(SL,{}),children:a.jsx(c0,{})},e)}const EL=WN([{element:a.jsx(yS,{}),children:[{path:"/",element:a.jsx(kS,{})},{path:"/settings",element:a.jsx(sL,{})},{path:"/help",element:a.jsx(oS,{})},{path:"/p/:pid",element:a.jsx(CL,{}),children:[{index:!0,element:a.jsx(FN,{to:"today",replace:!0})},{path:"today",element:a.jsx(uL,{})},{path:"explore",element:a.jsx(AS,{})},{path:"review",element:a.jsx(dL,{})},{path:"map",element:a.jsx(b.Suspense,{fallback:null,children:a.jsx(bL,{})})},{path:"paths",element:a.jsx(aL,{})},{path:"paths/:id",element:a.jsx(oL,{})},{path:"teach/:id",element:a.jsx(fL,{})},{path:"tutor/:id",element:a.jsx(yL,{})},{path:"walk/:id",element:a.jsx(vL,{})},{path:"hunt/:id",element:a.jsx(kL,{})},{path:"changes",element:a.jsx(WS,{})},{path:"library",element:a.jsx(KS,{})},{path:"progress",element:a.jsx(eL,{})},{path:"lens/:id",element:a.jsx(UT,{})},{path:"quiz/:id",element:a.jsx(KT,{})},{path:"practice/:id",element:a.jsx(b.Suspense,{fallback:null,children:a.jsx(jL,{})})}]},{path:"*",element:a.jsx(Ft,{title:"Page not found"})}]}]);c1(document.getElementById("root")).render(a.jsx(b.StrictMode,{children:a.jsx($j,{client:NL,children:a.jsx(ZN,{router:EL})})}));export{Jf as A,ee as B,kl as C,K1 as D,Ft as E,np as F,rp as G,O1 as H,sp as I,sn as J,cs as K,ft as L,W1 as M,Eh as N,eC as O,Q1 as P,xp as Q,m2 as R,XT as S,pr as T,cC as U,f0 as V,aC as W,GS as X,dC as Y,Nx as Z,ml as _,it as a,gt as b,J as c,Dt as d,ec as e,ye as f,Vh as g,Tt as h,Kn as i,a as j,os as k,be as l,me as m,TL as n,Gh as o,$r as p,hk as q,b as r,mn as s,kt as t,Sr as u,ep as v,Wa as w,ip as x,le as y,Ke as z};