keating 4.0.2 → 4.0.3

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 (108) hide show
  1. package/bin/keating.js +1 -1
  2. package/dist/src/core/version.js +1 -1
  3. package/package.json +1 -1
  4. package/web/.output/nitro.json +1 -1
  5. package/web/.output/public/assets/{AnimationPlayer-Bj9E6XAF.js → AnimationPlayer-CYbhLL_R.js} +1 -1
  6. package/web/.output/public/assets/{AssistantChatPanel-CPiSdBQo.js → AssistantChatPanel-DQSKpGWP.js} +122 -122
  7. package/web/.output/public/assets/{CategoricalChart-ZCOId7ho.js → CategoricalChart-BVb9-7_N.js} +1 -1
  8. package/web/.output/public/assets/{Chat-BPuDBuv7.js → Chat-C6p8yxAr.js} +2 -2
  9. package/web/.output/public/assets/{CodeHighlighter-CUd-nVJG.js → CodeHighlighter-DhI0IV5H.js} +1 -1
  10. package/web/.output/public/assets/{ComingUp-BM3f_QSf.js → ComingUp-DFaRgEbt.js} +1 -1
  11. package/web/.output/public/assets/{CourseJoin--37EPPeg.js → CourseJoin-DMZ6foZO.js} +1 -1
  12. package/web/.output/public/assets/CourseWorkspace-l_bPGNhE.js +25 -0
  13. package/web/.output/public/assets/{Courses-DgryGTWV.js → Courses-DIqulPB-.js} +1 -1
  14. package/web/.output/public/assets/{EvolutionDetail-BHwyObAD.js → EvolutionDetail-C-NYL1qL.js} +1 -1
  15. package/web/.output/public/assets/{FlashcardRenderer-hzqoLbnQ.js → FlashcardRenderer-iDgfcwk4.js} +1 -1
  16. package/web/.output/public/assets/{FlashcardShaderField-pDI9y_r4.js → FlashcardShaderField-JGgL2kgp.js} +1 -1
  17. package/web/.output/public/assets/{FlashcardTimer-BANuXJze.js → FlashcardTimer-vPNL9_0N.js} +1 -1
  18. package/web/.output/public/assets/{HyperframesPlayer-BQFYx43N.js → HyperframesPlayer-DEtdwGBR.js} +1 -1
  19. package/web/.output/public/assets/KeatingBench-XnWxgfUC.js +2 -0
  20. package/web/.output/public/assets/{LearningInsightsHeader-Do3bROTu.js → LearningInsightsHeader-DWj2-1xb.js} +1 -1
  21. package/web/.output/public/assets/{Live-HZjRDq-V.js → Live-BasKZMuE.js} +1 -1
  22. package/web/.output/public/assets/{MarkdownBlock-KUcDESQo.js → MarkdownBlock-C89ecD-M.js} +3 -3
  23. package/web/.output/public/assets/ModelSelector-B_EaHvVz.js +1 -0
  24. package/web/.output/public/assets/{Nav-GcfPhZc3.js → Nav-DQ-5KEsA.js} +1 -1
  25. package/web/.output/public/assets/{NotOrganicAccessPromptDialog-CKb6iTFn.js → NotOrganicAccessPromptDialog-DS7PLMx4.js} +1 -1
  26. package/web/.output/public/assets/{NotOrganicCallback-DWbhlP2j.js → NotOrganicCallback-BxKOsisT.js} +1 -1
  27. package/web/.output/public/assets/{OAuthCallback-D15ohKxE.js → OAuthCallback-dk2EQnAU.js} +1 -1
  28. package/web/.output/public/assets/OpenUIPreview-BrBXAEt4.js +1 -0
  29. package/web/.output/public/assets/PatternDigestPanel-jmxcLCUX.js +1 -0
  30. package/web/.output/public/assets/Plus-RIb_ldNd.js +1 -0
  31. package/web/.output/public/assets/{QuizRenderer-CLQqGwub.js → QuizRenderer-DaPQ7ySS.js} +1 -1
  32. package/web/.output/public/assets/{RenderingSmoke-DRHji-yz.js → RenderingSmoke-D3aD8prv.js} +1 -1
  33. package/web/.output/public/assets/{Select-BE2GfDud.js → Select-BYfJxqbI.js} +1 -1
  34. package/web/.output/public/assets/{SharedSession-DAM8ydVu.js → SharedSession-CEsTcr4j.js} +3 -3
  35. package/web/.output/public/assets/{ThemeToggle-BdGijxoN.js → ThemeToggle-BZH64Rpu.js} +1 -1
  36. package/web/.output/public/assets/{TrainingData-7EbVIzmQ.js → TrainingData-DujNU5sy.js} +3 -3
  37. package/web/.output/public/assets/TrajectoryReview-OjkaW6a6.js +35 -0
  38. package/web/.output/public/assets/TrajectoryReviewIndex-C5QAijKT.js +1 -0
  39. package/web/.output/public/assets/TrajectoryReviewWorkspace-DSn96Dxb.js +1 -0
  40. package/web/.output/public/assets/{Usage-BU1OfvzO.js → Usage-C5HU0Yc5.js} +1 -1
  41. package/web/.output/public/assets/activity-DdJDHeam.js +1 -0
  42. package/web/.output/public/assets/{anthropic-messages-rElikI6M.js → anthropic-messages-ZiHu59Q7.js} +1 -1
  43. package/web/.output/public/assets/{azure-openai-responses-yppPdVFy.js → azure-openai-responses-BHgsWKby.js} +1 -1
  44. package/web/.output/public/assets/calibration-7gf-WNR5.js +1 -0
  45. package/web/.output/public/assets/circle-question-mark-CK-DUGIA.js +1 -0
  46. package/web/.output/public/assets/clipboard-list-CRJvmiKL.js +1 -0
  47. package/web/.output/public/assets/{course-assembly-BIf5lrcx.js → course-assembly-CQE_9Vh4.js} +3 -3
  48. package/web/.output/public/assets/{course-submission-judgement-m2Gj1AKW.js → course-submission-judgement-Dmmw__tF.js} +1 -1
  49. package/web/.output/public/assets/{custom-tts-DapOpVQe.js → custom-tts-DqDZf3aF.js} +1 -1
  50. package/web/.output/public/assets/desktop-offline-IzFtwAhh.js +3 -0
  51. package/web/.output/public/assets/{dist-BudWH94z.js → dist-Dq5mGdi-.js} +1 -1
  52. package/web/.output/public/assets/file-text-CANyHShy.js +1 -0
  53. package/web/.output/public/assets/{from-study-plan-XEoNCZH-.js → from-study-plan-D14XtwuX.js} +2 -2
  54. package/web/.output/public/assets/{gemini-live-C2U-Xfzz.js → gemini-live-CGEtXm6j.js} +1 -1
  55. package/web/.output/public/assets/{google-generative-ai-8HY6m7rq.js → google-generative-ai-DcqlQJ6d.js} +1 -1
  56. package/web/.output/public/assets/{google-vertex-DnCA4qzU.js → google-vertex-C5RXjS_e.js} +1 -1
  57. package/web/.output/public/assets/{gpt-live-CEMTjMri.js → gpt-live-C4ltEjG_.js} +1 -1
  58. package/web/.output/public/assets/{index-C8C76R86.js → index-DCgpDQKf.js} +30 -30
  59. package/web/.output/public/assets/info-CGMF4Cdc.js +1 -0
  60. package/web/.output/public/assets/keating-stream-g73cFcJe.js +11 -0
  61. package/web/.output/public/assets/{learner-context-D0BfhTjc.js → learner-context-CpkZOwpe.js} +1 -1
  62. package/web/.output/public/assets/{library-pPmUSBEY.js → library-Dt_HrttW.js} +5 -5
  63. package/web/.output/public/assets/{live-context-CYuoXPUI.js → live-context-D5leiub7.js} +1 -1
  64. package/web/.output/public/assets/{mistral-conversations-BehK5A17.js → mistral-conversations-BSUNv6T_.js} +1 -1
  65. package/web/.output/public/assets/{openai-codex-responses-vVGnXFbc.js → openai-codex-responses-BEjWFOsh.js} +1 -1
  66. package/web/.output/public/assets/{openai-completions-SUIeYkEW.js → openai-completions-XWr91hin.js} +1 -1
  67. package/web/.output/public/assets/{openai-realtime-BSeGY5DQ.js → openai-realtime-BERRi9aO.js} +1 -1
  68. package/web/.output/public/assets/{openai-responses-DzgNIiYy.js → openai-responses-DeNWT5uB.js} +1 -1
  69. package/web/.output/public/assets/{openai-responses-shared-CHf6ek3_.js → openai-responses-shared-BdPh5feu.js} +1 -1
  70. package/web/.output/public/assets/{openai-tts-DRXdgxDT.js → openai-tts-ChGSz4r8.js} +1 -1
  71. package/web/.output/public/assets/{operation-BMdkNnIS.js → operation-kDIu8RLw.js} +2 -2
  72. package/web/.output/public/assets/{pi-messages-CpI94BCF.js → pi-messages-pzwJsgas.js} +1 -1
  73. package/web/.output/public/assets/{public-client-KRBnkgBr.js → public-client-CqivHtfG.js} +1 -1
  74. package/web/.output/public/assets/{recipes-BcSW8MlI.js → recipes-lg2hVa6Q.js} +1 -1
  75. package/web/.output/public/assets/{renderer-CKD_Hn-d.js → renderer-Cx1jCM2v.js} +1 -1
  76. package/web/.output/public/assets/{segments-nMdXcVhb.js → segments-BuQ4O8Bd.js} +1 -1
  77. package/web/.output/public/assets/{shared-actions-Bj56xHM3.js → shared-actions-B9eYiZAR.js} +1 -1
  78. package/web/.output/public/assets/{shared-renderer-C-yYfXvq.js → shared-renderer-hMxAoPZb.js} +7 -7
  79. package/web/.output/public/assets/shared-sessions-CwS3OLWR.js +5 -0
  80. package/web/.output/public/assets/{srs-WAeRnL8v.js → srs-BBTX4fCR.js} +1 -1
  81. package/web/.output/public/assets/{tavus-live-CVb9mE_J.js → tavus-live-HpBIH49i.js} +1 -1
  82. package/web/.output/public/assets/{topic-categorization-DHcL_IrS.js → topic-categorization-DfJaArmq.js} +1 -1
  83. package/web/.output/public/assets/trajectory-artifacts-EvNqJEHH.js +3 -0
  84. package/web/.output/public/assets/trajectory-store-C3qzwrr6.js +2 -0
  85. package/web/.output/public/assets/{transformers.web-CUMRYLoV.js → transformers.web-CrNvRfsr.js} +1 -1
  86. package/web/.output/public/assets/use-review-passes-DmWsvYdF.js +8 -0
  87. package/web/.output/public/assets/{use-sessions-C33USzrV.js → use-sessions-3UElISPk.js} +1 -1
  88. package/web/.output/public/assets/{useCoursesAccess-Zfb1Jqw-.js → useCoursesAccess-BgOspZex.js} +1 -1
  89. package/web/.output/public/assets/user-DEmM1U0O.js +1 -0
  90. package/web/.output/public/index.html +7 -7
  91. package/web/.output/public/sw.js +1 -1
  92. package/web/.output/server/_chunks/renderer-template.mjs +1 -1
  93. package/web/.output/server/_libs/h3+rou3+srvx.mjs +1 -1
  94. package/web/.output/server/index.mjs +1191 -1112
  95. package/web/.output/public/assets/CourseWorkspace-McgEEARK.js +0 -25
  96. package/web/.output/public/assets/ModelSelector-CiiiT7sM.js +0 -1
  97. package/web/.output/public/assets/OpenUIPreview-C8sgkYAj.js +0 -1
  98. package/web/.output/public/assets/PatternDigestPanel-Ctm7smvT.js +0 -1
  99. package/web/.output/public/assets/TrajectoryReview-DkC_NtyR.js +0 -35
  100. package/web/.output/public/assets/TrajectoryReviewIndex-C7pg9K9U.js +0 -1
  101. package/web/.output/public/assets/TrajectoryReviewWorkspace-D80QHrDn.js +0 -1
  102. package/web/.output/public/assets/calibration-B8NNSy6-.js +0 -1
  103. package/web/.output/public/assets/desktop-offline-BOKnmvYX.js +0 -2
  104. package/web/.output/public/assets/keating-stream-DeWgIdIv.js +0 -11
  105. package/web/.output/public/assets/shared-sessions-B2FsK7oM.js +0 -5
  106. package/web/.output/public/assets/trajectory-artifacts-B47xntcj.js +0 -3
  107. package/web/.output/public/assets/trajectory-store-CFat_se9.js +0 -2
  108. package/web/.output/public/assets/use-review-passes-BTc5nGD9.js +0 -8
@@ -1,4 +1,4 @@
1
- import{s as e}from"./rolldown-runtime-BG2f4sTM.js";import{T as t}from"./syntax-highlighter-Buac5fmw.js";import{_t as n,bt as r,gt as i,ht as a,mt as o,n as s,t as c,vt as l,wt as u}from"./operation-BMdkNnIS.js";import{r as d}from"./desktop-offline-BOKnmvYX.js";import{C as f,D as p,E as m,O as h,S as g,T as _,a as v,b as ee,c as te,d as y,f as ne,g as re,h as ie,i as b,l as ae,m as x,n as oe,o as S,p as se,s as C,t as ce,u as w,v as le,w as ue,x as de,y as fe}from"./AssistantChatPanel-CPiSdBQo.js";import{$ as T,Ct as E,Et as D,H as O,Kt as pe,M as k,N as A,Q as me,Tt as he,Un as ge,Ut as _e,Wt as j,c as ve,et as ye,ni as be,ri as xe,s as Se,tt as Ce,u as M,wt as we,xr as Te}from"./index-C8C76R86.js";import{K as Ee,X as De}from"./shared-renderer-C-yYfXvq.js";import{E as Oe,_ as ke,b as Ae,c as je,d as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,n as Re,p as ze,r as Be,s as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./nodepod-runtime-DjuxBODo.js";import{t as qe}from"./createLucideIcon-C_7xXnHN.js";import{t as Je}from"./layers-CAYsIN-0.js";import{a as Ye,n as Xe}from"./FlashcardShaderField-pDI9y_r4.js";import{r as Ze}from"./NotOrganicAccessPromptDialog-CKb6iTFn.js";import{a as Qe,i as $e,o as et,t as tt}from"./MarkdownBlock-KUcDESQo.js";import{n as nt,t as rt}from"./OpenUIPreview-C8sgkYAj.js";import{t as it}from"./book-open-Cii8hRKD.js";import{t as at}from"./check-BQLdkQGc.js";import{t as ot}from"./chevron-right-CtU0hmKY.js";import{i as st,o as ct}from"./HyperframesPlayer-BQFYx43N.js";import{t as lt}from"./download-Cu2Egmxp.js";import{t as ut}from"./git-compare-arrows-Bzjo_UJp.js";import{t as dt}from"./ThemeToggle-BdGijxoN.js";import{c as ft,t as pt}from"./Select-BE2GfDud.js";import{t as mt}from"./FlashcardRenderer-hzqoLbnQ.js";import{t as ht}from"./search-DkD407V9.js";import{t as gt}from"./x-dksMGet2.js";import{n as N}from"./Check-C4euVM-9.js";import{a as _t,c as vt,i as yt,l as bt,n as xt,o as St,s as Ct,u as wt}from"./sandbox-git-W6-9y8RP.js";import"./ModelSelector-CiiiT7sM.js";import{n as Tt}from"./browser-download-DzX_pBaq.js";import{_ as Et,y as P}from"./trajectory-store-CFat_se9.js";import{a as Dt,i as Ot,r as kt}from"./anki-package-BWx15W_D.js";import{t as At}from"./useSeo-fXJau5mP.js";import{t as jt}from"./AnimationPlayer-Bj9E6XAF.js";import{n as Mt,r as Nt,t as Pt}from"./Refresh-CMJ753fv.js";import{n as Ft,t as It}from"./sandbox-export-Cl8U49Iq.js";var Lt=qe(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),F=qe(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Rt=qe(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),zt=qe(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),Bt=qe(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Vt=qe(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Ht=qe(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),I=e(t(),1),Ut=new Set([`default`,`marked`,`leech`,`suspended`,`buried`,`duplicate`,`untagged`,`misc`,`miscellaneous`,`other`,`inbox`,`todo`,`new`,`imported`,`import`,`temp`,`test`,`cards`,`deck`,`notes`]),Wt=3,Gt=60;function Kt(e){return e.replace(/[_-]+/gu,` `).replace(/\s+/gu,` `).trim()}function qt(e){return e.length<Wt||e.length>Gt||Ut.has(e.toLowerCase())||!/\p{L}/u.test(e)?!1:!/^(?:\p{L}+\s+)?\d+$/u.test(e)}function Jt(e){let t=new Map,n=(e,n,r)=>{let i=Kt(e);if(!qt(i))return;let a=i.toLowerCase(),o=t.get(a);o?o.cardCount+=n:t.set(a,{label:i,cardCount:n,evidence:r})};for(let t of e){let e=t.cards?.length??0;for(let r of(t.title??``).split(`::`))n(r,e,`Imported Anki deck "${t.title}"`);let r=new Map;for(let e of t.cards??[])for(let t of e.tags??[])for(let e of t.split(`::`)){let t=Kt(e);if(!t)continue;let n=t.toLowerCase(),i=r.get(n);i?i.count+=1:r.set(n,{label:t,count:1})}for(let{label:e,count:t}of r.values())n(e,t,`Tagged on ${t} imported card${t===1?``:`s`}`)}return Object.freeze([...t.values()].sort((e,t)=>t.cardCount-e.cardCount||e.label.localeCompare(t.label)).map(e=>Object.freeze({label:e.label,cardCount:e.cardCount,evidence:e.evidence})))}function Yt(e,t={}){let n=Math.max(0,t.limit??8);return Object.freeze(Jt(e).slice(0,n).map(e=>Object.freeze({field:`interests`,value:e.label,evidence:e.evidence,confidence:null,source:`anki-import`})))}function Xt(e){return new TextDecoder().decode(e)}async function Zt(e,t){let n=e.name.toLowerCase().endsWith(`.apkg`)?await Ot(e.bytes,t.now):Dt(Xt(e.bytes),e.name,t.now),r=0,i=0,a=0;for(let e of n.decks){let n=kt(await t.store.getDeck(e.id),e);await t.store.saveDeck(n.deck),r+=n.added,i+=n.updated,a+=n.unchanged}return Object.freeze({deckCount:n.decks.length,cardsAdded:r,cardsUpdated:i,cardsUnchanged:a,warnings:Object.freeze([...n.warnings]),proposals:Yt(n.decks,{limit:t.limit})})}function Qt(e){let t=e.cardsAdded+e.cardsUpdated+e.cardsUnchanged,n=`${e.deckCount} deck${e.deckCount===1?``:`s`}`,r=`${t} card${t===1?``:`s`}`;return e.cardsUpdated===0&&e.cardsUnchanged===0?`Imported ${r} across ${n}.`:`Imported ${r} across ${n} · ${e.cardsAdded} new, ${e.cardsUpdated} updated, ${e.cardsUnchanged} already up to date.`}var L=we();function $t({onImported:e,store:t}){let n=(0,I.useRef)(null),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),l=async n=>{i(!0),c(``),o(`Reading your collection…`);try{t||await _e();let r=await Zt({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())},{store:t??j});o(Qt(r)),e(r.proposals)}catch(e){c(e instanceof Error?e.message:`That file could not be read as an Anki collection.`),o(``)}finally{i(!1)}};return(0,L.jsxs)(`section`,{className:`anki-import`,children:[(0,L.jsx)(O,{size:56,state:r?`importing`:`greeting`,label:``}),(0,L.jsxs)(`div`,{className:`anki-import__body`,children:[(0,L.jsx)(`p`,{className:`anki-import__ask`,children:`Do you use Anki?`}),(0,L.jsx)(`p`,{children:`Bring your decks and they keep their scheduling. What you have been drilling also tells me what you study — I will show you what I read from it before anything is kept.`}),a&&(0,L.jsx)(`p`,{className:`anki-import__status`,role:`status`,children:a}),s&&(0,L.jsx)(`p`,{className:`anki-import__error`,role:`alert`,children:s}),(0,L.jsx)(`input`,{ref:n,type:`file`,className:`anki-import__file`,accept:`.apkg,.txt,.csv,.tsv`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&l(t)}}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:r,onClick:()=>n.current?.click(),children:r?`Importing…`:`Choose an .apkg file`})]})]})}var en=Object.freeze([Object.freeze({id:`name`,ask:`What should I call you?`,hint:`A first name or a nickname — whatever you would like to be called.`,fields:Object.freeze([]),verbatim:`preferredName`}),Object.freeze({id:`goal`,ask:`What are you hoping to understand?`,hint:`One subject is plenty. “Why enzymes speed reactions up” beats “chemistry”.`,fields:Object.freeze([`motivation`,`educationStage`]),verbatim:`goalText`}),Object.freeze({id:`teaching`,ask:`When something finally clicked for you, what made it click?`,hint:`Being walked through it, being asked about it, seeing it drawn — whatever it was.`,fields:Object.freeze([`socraticIntensity`,`hintLevel`,`depth`])}),Object.freeze({id:`tone`,ask:`And how should I talk to you when you get something wrong?`,hint:`Straight about it, gently, or somewhere in between.`,fields:Object.freeze([`tone`,`ageBand`])})]),tn=e=>en.find(t=>t.id===e);function nn(e){let t={};for(let n of e){let e=tn(n.promptId)?.verbatim,r=n.text.trim();!e||!r||(t[e]=r)}return t}async function rn(e,t={}){let n=t.call??c({runtime:s(),accept:()=>!0}),r=[],a=0;for(let s of e){let e=tn(s.promptId)?.fields??o;if(e.length===0||!s.text.trim())continue;a+=1;let c=await i(s.text,e,n,{signal:t.signal});for(let e of c){let t=l(e,s.source);if(!t)continue;let n=r.findIndex(e=>e.field===t.field);n>=0&&r.splice(n,1),r.push(t)}}return Object.freeze({proposals:Object.freeze(r),abstainedEntirely:a>0&&r.length===0})}function an(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var on=()=>an()!==null;function sn({onDone:e,onUseForm:t}){let[n,r]=(0,I.useState)(0),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)([]),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),f=(0,I.useRef)(!1),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=en[n],g=n>=en.length;(0,I.useEffect)(()=>{m.current?.focus()},[n]),(0,I.useEffect)(()=>()=>{try{p.current?.stop()}catch{}},[]);function _(){if(c){try{p.current?.stop()}catch{}return}let e=an();if(!e)return;let t=new e;t.lang=document.documentElement.lang||`en-US`,t.continuous=!0,t.interimResults=!1,t.onresult=e=>{let t=Array.from(e.results,e=>e[0]?.transcript??``).join(` `).trim();t&&(f.current=!0,a(e=>e.trim()?`${e.trim()} ${t}`:t))},t.onend=()=>l(!1),t.onerror=()=>l(!1),p.current=t;try{t.start(),l(!0)}catch{l(!1)}}async function v(t){if(n+1<en.length){r(n+1),a(``),f.current=!1;return}d(!0);let{proposals:i}=await rn(t);r(en.length),e({proposals:i,verbatim:nn(t),answers:t})}function ee(){try{p.current?.stop()}catch{}let e=i.trim(),t=f.current?`speech`:`conversation`,n=e?[...o,{promptId:h.id,text:e,source:t}]:o;s(n),v(n)}return g?(0,L.jsxs)(`section`,{className:`intake-chat`,"aria-live":`polite`,children:[(0,L.jsx)(O,{size:72,state:u?`sorting`:`settled`,label:``}),(0,L.jsx)(`p`,{className:`intake-chat__reading`,children:u?`Reading back what you told me…`:`Thank you.`})]}):(0,L.jsxs)(`section`,{className:`intake-chat`,"aria-labelledby":`intake-chat-ask`,children:[(0,L.jsx)(`div`,{className:`intake-chat__said`,children:o.map(e=>(0,L.jsx)(`p`,{className:`intake-chat__answer`,"data-source":e.source,children:e.text},e.promptId))}),(0,L.jsxs)(`div`,{className:`intake-chat__turn`,children:[(0,L.jsx)(O,{size:64,state:c?`listening-voice`:`greeting`,label:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`intake-chat__ask`,id:`intake-chat-ask`,ref:m,tabIndex:-1,children:h.ask}),(0,L.jsx)(`p`,{className:`intake-chat__hint`,children:h.hint})]})]},h.id),(0,L.jsxs)(`label`,{className:`intake-chat__compose`,children:[(0,L.jsx)(`span`,{className:`intake-chat__label`,children:`Your answer`}),(0,L.jsx)(`textarea`,{value:i,rows:3,placeholder:c?`Listening…`:`Type, or use the microphone.`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ee())}})]}),(0,L.jsxs)(`footer`,{className:`intake-chat__actions`,children:[(0,L.jsxs)(`div`,{children:[on()&&(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__mic`,"aria-pressed":c,onClick:_,children:c?`Stop listening`:`Answer out loud`}),t&&(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__plain`,onClick:t,children:`Fill a form instead`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__plain`,onClick:()=>{a(``),f.current=!1,v(o)},children:n+1===en.length?`Skip and finish`:`Skip`}),(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__next`,disabled:!i.trim(),onClick:ee,children:n+1===en.length?`Done`:`Next`})]})]}),(0,L.jsxs)(`p`,{className:`intake-chat__progress`,role:`status`,children:[`Question `,n+1,` of `,en.length,` · every one is optional`]})]})}function cn(e,t,n){return e.map((e,r)=>r===t?e===n?`pending`:n:e)}function ln(e,t){return e.filter((e,n)=>t[n]===`accepted`)}function un(e){return e.field===`interests`?e.value:e.value.replace(/-/gu,` `)}function dn(e){if(e.field===`interests`)return`Interest`;try{return n(e.field).asks.replace(/^the learner['’]s /iu,``).replace(/^their /iu,``)}catch{return e.field}}var fn={conversation:`from what you typed`,speech:`from what you said`,"anki-import":`from your imported decks`};function pn({proposals:e,onApply:t,onDismiss:n,heading:r=`Here is what I picked up.`}){let[i,o]=(0,I.useState)(()=>e.map(()=>`pending`)),s=(0,I.useMemo)(()=>ln(e,i),[e,i]),c=i.filter(e=>e!==`pending`).length;if(e.length===0)return null;let l=(e,t)=>{o(n=>cn(n,e,t))};return(0,L.jsxs)(`section`,{className:`proposal-review`,"aria-labelledby":`proposal-review-title`,children:[(0,L.jsxs)(`header`,{className:`proposal-review__head`,children:[(0,L.jsx)(O,{size:56,state:`sorting`,label:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{id:`proposal-review-title`,children:r}),(0,L.jsx)(`p`,{children:`Nothing is saved until you say so. Keep what fits, drop the rest — you can change any of it later in Settings → Learning.`})]})]}),(0,L.jsx)(`ul`,{className:`proposal-review__list`,children:e.map((e,t)=>{let n=i[t]??`pending`;return(0,L.jsxs)(`li`,{"data-verdict":n,style:{animationDelay:`${Math.min(t,8)*45}ms`},children:[(0,L.jsxs)(`div`,{className:`proposal-review__claim`,children:[(0,L.jsx)(`span`,{className:`proposal-review__field`,children:dn(e)}),(0,L.jsx)(`strong`,{className:`proposal-review__value`,children:un(e)})]}),(0,L.jsxs)(`blockquote`,{className:`proposal-review__evidence`,children:[e.evidence,(0,L.jsx)(`cite`,{children:fn[e.source]})]}),(0,L.jsxs)(`div`,{className:`proposal-review__verdict`,children:[(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,"aria-pressed":n===`accepted`,onClick:()=>l(t,`accepted`),children:`Keep`}),(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,"aria-pressed":n===`discarded`,onClick:()=>l(t,`discarded`),children:`Drop`})]})]},`${e.field}:${e.value}:${t}`)})}),(0,L.jsxs)(`footer`,{className:`proposal-review__actions`,children:[(0,L.jsx)(`p`,{className:`proposal-review__count`,role:`status`,children:s.length===0?`Nothing kept yet · ${c} of ${e.length} reviewed`:`Keeping ${s.length} of ${e.length}`}),(0,L.jsxs)(`div`,{children:[n&&(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,onClick:n,children:`Not now`}),(0,L.jsx)(`button`,{type:`button`,className:`proposal-review__apply dialog-compact-button`,onClick:()=>t(s,a(s)),children:s.length===0?`Save nothing`:`Save ${s.length}`})]})]})]})}function mn(e){return{profile_fields_filled:r(e).length,profile_groups_skipped:e.skippedGroups.length,profile_has_goal:e.goalText.trim().length>0}}var hn=new Set([`step_id`,`step_index`,`step_count`,`skipped`,`steps_visible`,`profile_fields_filled`,`profile_groups_skipped`,`profile_has_goal`]);function gn(e){let t={};for(let[n,r]of Object.entries(e))hn.has(n)&&(typeof r==`number`&&Number.isFinite(r)||typeof r==`boolean`||typeof r==`string`&&/^[a-z0-9][a-z0-9_-]{0,39}$/.test(r))&&(t[n]=r);return t}function _n(){let e=be();return(0,I.useCallback)((t,n={})=>{if(e)try{e.capture(t,gn(n))}catch{}},[e])}var vn=`keating:onboarding:v1`;function yn(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function bn(e){try{let t=JSON.parse(e?.getItem(`keating:onboarding:v1`)??`null`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function xn(e=yn()){let t=bn(e);return!t||t.version!==1&&t.version!==2?!1:t.outcome===`completed`||t.outcome===`skipped`}function Sn(e=yn()){let t=bn(e);if(!t||t.version!==2||t.outcome!==`in-progress`)return 0;let n=typeof t.step==`number`&&Number.isInteger(t.step)?t.step:0;return Math.min(Math.max(n,0),wn.length-1)}function Cn(e,t=yn(),n=0){try{return t?(t.setItem(vn,JSON.stringify({version:2,outcome:e,step:n,completedAt:e===`in-progress`?null:new Date().toISOString()})),!0):!1}catch{return!1}}var wn=[{id:`welcome`,label:`Welcome`},{id:`access`,label:`Model access`},{id:`setup`,label:`Setup`},{id:`identity`,label:`About you`,group:`identity`},{id:`learning`,label:`Your learning`,group:`goals`},{id:`teaching`,label:`How to teach you`,group:`pedagogy`},{id:`accessibility`,label:`Accessibility`,group:`accessibility`},{id:`finish`,label:`You are set`}],Tn=wn.length-1,En=new Set([`learning`,`teaching`,`accessibility`]);function Dn(e,t){let n=new Set((e??[]).map(e=>`${e.field}:${e.value.toLowerCase()}`));return Object.freeze([...e??[],...t.filter(e=>{let t=`${e.field}:${e.value.toLowerCase()}`;return n.has(t)?!1:(n.add(t),!0)})])}function On(e){return e===`conversation`?wn.filter(e=>!En.has(e.id)):wn}var kn={welcome:`greeting`,access:`thinking`,setup:`loading`,identity:`listening`,learning:`understanding`,teaching:`reading`,accessibility:`connecting`,finish:`settled`},An={welcome:`Keating teaches by asking.`,identity:`Tell Keating who it is talking to.`,learning:`What would you like to understand?`,teaching:`How should Keating teach you?`,accessibility:`Anything that would make this easier?`,finish:`You are set.`},jn={welcome:`Rather than hand you answers, Keating works through a question with you — then checks what stuck. Ask it anything in the composer at the bottom; it can pull up diagrams, quizzes and plans beside the conversation as you go.`,identity:`All optional, all stored only in this browser, and all changeable later in Settings → Learning.`,learning:`Just a starting point for today — not a commitment. You can change direction whenever you like, and Keating follows what you actually ask about. We will put this in the composer for you to review and send.`,teaching:`These are preferences, not a test. Keating follows them.`,accessibility:`Keating treats these as requirements, not suggestions.`,finish:`Your profile is saved on this device. Change any of it in Settings → Learning → Your profile.`};function Mn({onUseKeating:e,onConnectAccount:t,onChooseModel:n,onComplete:r,onSkip:i,onStartTour:a,initialStep:o}){let[s,c]=(0,I.useState)(()=>o??Sn()),[l,p]=(0,I.useState)(`keating`),[m,h]=(0,I.useState)(()=>Se()),[_,v]=(0,I.useState)(!1),[te,y]=(0,I.useState)(``),ne=(0,I.useRef)(null),ie=(0,I.useRef)(!1),[b,ae]=(0,I.useState)(`form`),[x,oe]=(0,I.useState)(null),S=On(b),se=S.length-1,C=S[s]??S[0],ce=_n();(0,I.useEffect)(()=>{ne.current?.focus({preventScroll:!0})},[s]),(0,I.useEffect)(()=>{ce(`onboarding_viewed`,{step_id:C.id,step_index:s,step_count:S.length})},[C.id,s,ce]);let w=(0,I.useCallback)(e=>h(t=>({...t,...e})),[]),ue=(0,I.useCallback)(e=>{try{M(m)}catch{}Cn(`in-progress`,yn(),e)},[m]);function T(){if(ie.current)return;ie.current=!0;let e=u(m);try{M(e)}catch{}Cn(`skipped`,yn(),s),ce(`onboarding_skipped`,{step_id:C.id,step_index:s,...mn(e)}),i()}function E(){if(ie.current)return;ie.current=!0;let e=u(m);try{M(e)}catch{}Cn(`completed`,yn(),Tn),ce(`onboarding_completed`,{step_count:S.length,intake_mode:b,...mn(e)}),r(e.goalText.trim()||void 0)}async function D(e){v(!0),y(``);try{await e()}catch{y(`That setup couldn’t open. Try again, or continue to chat and set it up later.`)}finally{v(!1)}}function pe(e){ue(e),ie.current||c(e)}function k(){C.group&&ve(C.group),ce(`onboarding_step_completed`,{step_id:C.id,step_index:s,skipped:!0}),y(``),pe(Math.min(s+1,se))}async function A(){if(!_){if(y(``),C.id===`access`&&l===`keating`){v(!0);try{await e()}catch{y(`Keating’s model couldn’t be selected. Try again, or choose your own provider.`);return}finally{v(!1)}}ce(`onboarding_step_completed`,{step_id:C.id,step_index:s,skipped:!1}),pe(Math.min(s+1,se))}}let me=l===`keating`?`Make yourself at home.`:l===`offline`?`Set up your offline tutor.`:`Connect your model.`,he=l===`keating`?`${ge.name} is selected. Connect or create a Not Organic account to use Keating’s hosted model.`:l===`offline`?`Download the model once, then chat on this device without an account or internet connection.`:`Choose a model and add your provider key. A Not Organic account isn’t required.`,_e={profile:m,onChange:w,idPrefix:`onboarding`};return(0,L.jsxs)(`section`,{className:`chat-onboarding`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`chat-onboarding-title`,"aria-describedby":`chat-onboarding-description`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),T())},children:[(0,L.jsxs)(`header`,{className:`chat-onboarding__top`,children:[(0,L.jsx)(`span`,{children:`Welcome to Keating`}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__skip`,onClick:T,children:`Go straight to chat`})]}),(0,L.jsxs)(`div`,{className:`chat-onboarding__intro`,children:[(0,L.jsx)(O,{size:88,state:kn[C.id]??`idle`,label:``}),(0,L.jsxs)(`div`,{className:`chat-onboarding__progress`,children:[(0,L.jsxs)(`p`,{className:`chat-onboarding__progress-label`,children:[s+1,` of `,S.length,` · `,C.label]}),(0,L.jsx)(`ol`,{className:`chat-onboarding__track`,"aria-hidden":`true`,children:S.map((e,t)=>(0,L.jsx)(`li`,{"data-state":t<s?`done`:t===s?`current`:`ahead`},e.id))})]})]}),(0,L.jsx)(`h2`,{ref:ne,tabIndex:-1,id:`chat-onboarding-title`,children:C.id===`access`?`How would you like to chat?`:C.id===`setup`?me:An[C.id]}),(0,L.jsx)(`p`,{id:`chat-onboarding-description`,children:C.id===`access`?`Choose how to run your model. You can change this later.`:C.id===`setup`?he:jn[C.id]}),(0,L.jsxs)(`div`,{className:`chat-onboarding__step`,children:[C.id===`welcome`&&(0,L.jsxs)(`ul`,{className:`chat-onboarding__tips`,children:[(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`The composer`}),` at the bottom is where you ask. Plain questions work best.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`The side panel`}),` opens on its own when Keating draws a diagram, sets a quiz or writes a plan.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`Sessions`}),` in the left rail keep each subject separate, and Keating remembers what you covered.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`Settings → Learning`}),` is where you change your profile, the teacher’s persona and voice.`]})]}),C.id===`welcome`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__doors`,children:[(0,L.jsx)(`p`,{className:`chat-onboarding__doors-ask`,children:`First, how should I get to know you?`}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`chat-onboarding__door`,"aria-pressed":b===`form`,onClick:()=>ae(`form`),children:[(0,L.jsx)(`strong`,{children:`Fill a short form`}),(0,L.jsx)(`span`,{children:`Four screens of questions, all skippable.`})]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-onboarding__door`,"aria-pressed":b===`conversation`,onClick:()=>ae(`conversation`),children:[(0,L.jsx)(`strong`,{children:`Talk it through`}),(0,L.jsx)(`span`,{children:`Four open questions, typed or spoken. I read your answers back before keeping anything.`})]})]})]}),C.id===`access`&&(0,L.jsxs)(`fieldset`,{className:`chat-onboarding__access`,disabled:_,children:[(0,L.jsx)(`legend`,{children:`Model access`}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`keating`,checked:l===`keating`,onChange:()=>{p(`keating`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Use Keating`}),(0,L.jsxs)(`span`,{children:[ge.name,` · Default`]})]})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`byok`,checked:l===`byok`,onChange:()=>{p(`byok`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Bring your own key`}),(0,L.jsx)(`span`,{children:`Your provider, your choice of model`})]})]}),d()&&(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`offline`,checked:l===`offline`,onChange:()=>{p(`offline`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Use an offline tutor`}),(0,L.jsx)(`span`,{children:`Optional 1.55 GB download · No account needed`})]})]})]}),C.id===`setup`&&l===`keating`&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,disabled:_,onClick:()=>void D(t),children:_?`Opening…`:`Connect or create an account`}),C.id===`setup`&&l===`byok`&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,disabled:_,onClick:()=>void D(n),children:_?`Opening…`:`Choose a model and provider`}),C.id===`setup`&&l===`offline`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(re,{}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>void D(n),children:`Choose the offline model`})]}),C.id===`identity`&&b===`form`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__fields`,children:[(0,L.jsx)(de,{..._e}),(0,L.jsx)(g,{..._e})]}),C.id===`identity`&&(b===`form`||x!==null)&&(0,L.jsx)($t,{onImported:e=>oe(t=>Dn(t,e))}),C.id===`identity`&&b===`form`&&x!==null&&x.length>0&&(0,L.jsx)(pn,{proposals:x,heading:`From your decks.`,onDismiss:()=>oe(null),onApply:(e,t)=>{w(t),oe(null)}}),C.id===`identity`&&b===`conversation`&&x?.length===0&&(0,L.jsxs)(`div`,{className:`chat-onboarding__doors`,children:[(0,L.jsx)(`p`,{className:`chat-onboarding__doors-ask`,children:`I did not want to guess.`}),(0,L.jsx)(`p`,{children:`Nothing in those answers was clear enough for me to propose, so I have kept none of it. You can fill the form instead, or carry on — I will learn as we talk.`}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,onClick:()=>{oe(null),ae(`form`)},children:`Fill the form instead`})]}),C.id===`identity`&&b===`conversation`&&x?.length!==0&&(x===null?(0,L.jsx)(sn,{onUseForm:()=>ae(`form`),onDone:e=>{w(e.verbatim),oe(e.proposals)}}):(0,L.jsx)(pn,{proposals:x,heading:`Here is what I picked up.`,onDismiss:()=>{oe(null),pe(Math.min(s+1,se))},onApply:(e,t)=>{w(t),pe(Math.min(s+1,se))}})),C.id===`learning`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__fields`,children:[(0,L.jsx)(ee,{..._e}),(0,L.jsx)(fe,{..._e})]}),C.id===`teaching`&&(0,L.jsx)(`div`,{className:`chat-onboarding__fields`,children:(0,L.jsx)(f,{..._e})}),C.id===`accessibility`&&(0,L.jsx)(`div`,{className:`chat-onboarding__fields`,children:(0,L.jsx)(le,{..._e})}),C.id===`finish`&&a&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,onClick:()=>{E(),a()},children:`Show me around first`}),te&&(0,L.jsx)(`p`,{className:`chat-onboarding__error`,role:`alert`,children:te})]},C.id),(0,L.jsxs)(`footer`,{className:`chat-onboarding__navigation`,children:[(0,L.jsx)(`div`,{children:s>0&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>{y(``),pe(s-1)},children:`Back`})}),(0,L.jsxs)(`div`,{className:`chat-onboarding__advance`,children:[C.group&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__skip`,disabled:_,onClick:k,children:`Skip this`}),!(C.id===`identity`&&b===`conversation`&&x===null)&&(s<se?(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>void A(),children:_&&C.id===`access`?`Selecting…`:`Next`}):(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,onClick:E,children:`Start chatting`}))]})]})]})}var Nn={width:320,height:190};function Pn(e){if(typeof document>`u`)return null;try{return document.querySelector(e)}catch{return null}}function Fn(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!1;try{return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||document.documentElement.getAttribute(`data-reduce-motion`)===`true`}catch{return!1}}function In({steps:e=v,onFinish:t,onSkip:n,initialStep:r,resolveAnchor:i=Pn}){let a=(0,I.useMemo)(()=>y(e,e=>i(e)!==null),[e,i]),o=a.length,[s,c]=(0,I.useState)(()=>{let e=r??te(void 0,Math.max(o,1));return o===0?0:Math.min(Math.max(e,0),o-1)}),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(Nn),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=(0,I.useRef)(!1),g=a[s],_=_n(),ee=(0,I.useRef)(!1);(0,I.useEffect)(()=>{ee.current||o===0||(ee.current=!0,_(`interface_tour_started`,{steps_visible:o}))},[o,_]);let ne=(0,I.useCallback)(()=>{if(!g){u(null);return}let e=i(g.anchor);if(!e){u(null);return}let t=e.getBoundingClientRect();u({top:t.top,left:t.left,width:t.width,height:t.height})},[i,g]);(0,I.useEffect)(()=>{if(!g)return;let e=i(g.anchor);e&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`,behavior:Fn()?`auto`:`smooth`}),ne(),m.current?.focus({preventScroll:!0})},[ne,i,g]),(0,I.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>ne();return window.addEventListener(`resize`,e,{passive:!0}),window.addEventListener(`scroll`,e,{passive:!0,capture:!0}),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,{capture:!0})}},[ne]),(0,I.useLayoutEffect)(()=>{let e=p.current?.getBoundingClientRect();e&&(Math.abs(e.width-d.width)<2&&Math.abs(e.height-d.height)<2||f({width:e.width,height:e.height}))},[d.height,d.width,s,g]);let re=(0,I.useCallback)(e=>{h.current||(h.current=!0,C(e,void 0,e===`completed`?Math.max(o-1,0):s),_(e===`completed`?`interface_tour_completed`:`interface_tour_skipped`,{step_index:s,steps_visible:o}),(e===`completed`?t:n)())},[s,t,n,o,_]),ie=(0,I.useCallback)(e=>{if(h.current)return;if(e>=o){re(`completed`);return}let t=Math.min(Math.max(e,0),Math.max(o-1,0));C(`in-progress`,void 0,t),c(t)},[re,o]);if((0,I.useEffect)(()=>{o===0&&!h.current&&(h.current=!0,C(`completed`,void 0,0),t())},[t,o]),!g)return null;let b={width:typeof window>`u`?1024:window.innerWidth,height:typeof window>`u`?768:window.innerHeight},ae=l?w({anchor:l,viewport:b,card:d}):{top:Math.max(12,b.height/2-d.height/2),left:Math.max(12,b.width/2-d.width/2),placement:`below`};return(0,L.jsxs)(`div`,{className:`tour-spotlight`,children:[l&&(0,L.jsx)(`div`,{className:`tour-spotlight__ring`,"aria-hidden":`true`,style:{top:l.top-4,left:l.left-4,width:l.width+8,height:l.height+8}}),(0,L.jsxs)(`div`,{ref:p,className:`tour-spotlight__card`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`tour-spotlight-title`,"aria-describedby":`tour-spotlight-body`,"data-placement":ae.placement,style:{top:ae.top,left:ae.left},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),re(`skipped`)),e.key===`ArrowRight`&&(e.preventDefault(),ie(s+1)),e.key===`ArrowLeft`&&(e.preventDefault(),ie(s-1))},children:[(0,L.jsxs)(`p`,{className:`tour-spotlight__progress`,children:[s+1,` of `,o]}),(0,L.jsx)(`h2`,{id:`tour-spotlight-title`,ref:m,tabIndex:-1,children:g.title}),(0,L.jsx)(`p`,{id:`tour-spotlight-body`,children:g.body}),(0,L.jsxs)(`div`,{className:`tour-spotlight__actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__skip`,onClick:()=>re(`skipped`),children:`Skip tour`}),(0,L.jsxs)(`div`,{className:`tour-spotlight__advance`,children:[s>0&&(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__secondary`,onClick:()=>ie(s-1),children:`Back`}),(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__primary`,onClick:()=>ie(s+1),children:s===o-1?`Done`:`Next`})]})]})]})]})}var Ln=e(xe(),1),Rn={plan:`user`,map:`user`,animation:`user`,deck:`user`,verification:`user`,benchmark:`agent`,evolution:`agent`,"prompt-evolution":`agent`,improvement:`agent`},zn={plan:{label:`Lesson Plan`,icon:(0,L.jsx)(it,{size:14})},map:{label:`Concept Map`,icon:(0,L.jsx)(zt,{size:14})},animation:{label:`Animation`,icon:(0,L.jsx)(ft,{size:14})},deck:{label:`Flashcards`,icon:(0,L.jsx)(Je,{size:14})},verification:{label:`Verification`,icon:(0,L.jsx)(ot,{size:14})},benchmark:{label:`Benchmark`,icon:(0,L.jsx)(Ye,{size:14})},evolution:{label:`Evolution`,icon:(0,L.jsx)(st,{size:14})},"prompt-evolution":{label:`Prompt Evo`,icon:(0,L.jsx)(Ye,{size:14})},improvement:{label:`Improvement`,icon:(0,L.jsx)(h,{size:14})}},Bn=`keating:artifact-show-agent`;function Vn(){if(typeof localStorage>`u`)return!1;try{return localStorage.getItem(Bn)===`1`}catch{return!1}}function Hn(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Bn,e?`1`:`0`)}catch{}}function Un(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?`Just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a===1?`Yesterday`:a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Wn(e){let t=e.data;switch(e.type){case`plan`:return`Phases: ${t?.metadata?.phaseCount??`—`} | Domain: ${t?.metadata?.domain??`—`}`;case`map`:return t?.mmdContent?`${String(t.mmdContent).split(`
1
+ import{s as e}from"./rolldown-runtime-BG2f4sTM.js";import{T as t}from"./syntax-highlighter-Buac5fmw.js";import{_t as n,bt as r,gt as i,ht as a,mt as o,n as s,t as c,vt as l,wt as u}from"./operation-kDIu8RLw.js";import{a as d}from"./desktop-offline-IzFtwAhh.js";import{C as f,D as p,E as m,O as h,S as g,T as _,a as v,b as ee,c as te,d as y,f as ne,g as re,h as ie,i as b,l as ae,m as x,n as oe,o as S,p as se,s as C,t as ce,u as w,v as le,w as ue,x as de,y as fe}from"./AssistantChatPanel-DQSKpGWP.js";import{$ as T,Ct as E,Et as D,H as O,Kt as pe,M as k,N as A,Q as me,Tt as he,Un as ge,Ut as _e,Wt as j,c as ve,et as ye,ni as be,ri as xe,s as Se,tt as Ce,u as M,wt as we,xr as Te}from"./index-DCgpDQKf.js";import{K as Ee,X as De}from"./shared-renderer-hMxAoPZb.js";import{E as Oe,_ as ke,b as Ae,c as je,d as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,n as Re,p as ze,r as Be,s as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./nodepod-runtime-DjuxBODo.js";import{t as qe}from"./createLucideIcon-C_7xXnHN.js";import{t as Je}from"./layers-CAYsIN-0.js";import{a as Ye,n as Xe}from"./FlashcardShaderField-JGgL2kgp.js";import{r as Ze}from"./NotOrganicAccessPromptDialog-DS7PLMx4.js";import{a as Qe,i as $e,o as et,t as tt}from"./MarkdownBlock-C89ecD-M.js";import{n as nt,t as rt}from"./OpenUIPreview-BrBXAEt4.js";import{t as it}from"./book-open-Cii8hRKD.js";import{t as at}from"./check-BQLdkQGc.js";import{t as ot}from"./chevron-right-CtU0hmKY.js";import{i as st,o as ct}from"./HyperframesPlayer-DEtdwGBR.js";import{t as lt}from"./download-Cu2Egmxp.js";import{t as ut}from"./git-compare-arrows-Bzjo_UJp.js";import{t as dt}from"./ThemeToggle-BZH64Rpu.js";import{c as ft,t as pt}from"./Select-BYfJxqbI.js";import{t as mt}from"./FlashcardRenderer-iDgfcwk4.js";import{t as ht}from"./search-DkD407V9.js";import{t as gt}from"./x-dksMGet2.js";import{n as N}from"./Check-C4euVM-9.js";import{a as _t,c as vt,i as yt,l as bt,n as xt,o as St,s as Ct,u as wt}from"./sandbox-git-W6-9y8RP.js";import"./ModelSelector-B_EaHvVz.js";import{n as Tt}from"./browser-download-DzX_pBaq.js";import{r as P,t as Et}from"./Plus-RIb_ldNd.js";import{a as Dt,i as Ot,r as kt}from"./anki-package-BWx15W_D.js";import{t as At}from"./useSeo-fXJau5mP.js";import{t as jt}from"./AnimationPlayer-CYbhLL_R.js";import{n as Mt,r as Nt,t as Pt}from"./Refresh-CMJ753fv.js";import{n as Ft,t as It}from"./sandbox-export-Cl8U49Iq.js";var Lt=qe(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),F=qe(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Rt=qe(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),zt=qe(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),Bt=qe(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Vt=qe(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Ht=qe(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),I=e(t(),1),Ut=new Set([`default`,`marked`,`leech`,`suspended`,`buried`,`duplicate`,`untagged`,`misc`,`miscellaneous`,`other`,`inbox`,`todo`,`new`,`imported`,`import`,`temp`,`test`,`cards`,`deck`,`notes`]),Wt=3,Gt=60;function Kt(e){return e.replace(/[_-]+/gu,` `).replace(/\s+/gu,` `).trim()}function qt(e){return e.length<Wt||e.length>Gt||Ut.has(e.toLowerCase())||!/\p{L}/u.test(e)?!1:!/^(?:\p{L}+\s+)?\d+$/u.test(e)}function Jt(e){let t=new Map,n=(e,n,r)=>{let i=Kt(e);if(!qt(i))return;let a=i.toLowerCase(),o=t.get(a);o?o.cardCount+=n:t.set(a,{label:i,cardCount:n,evidence:r})};for(let t of e){let e=t.cards?.length??0;for(let r of(t.title??``).split(`::`))n(r,e,`Imported Anki deck "${t.title}"`);let r=new Map;for(let e of t.cards??[])for(let t of e.tags??[])for(let e of t.split(`::`)){let t=Kt(e);if(!t)continue;let n=t.toLowerCase(),i=r.get(n);i?i.count+=1:r.set(n,{label:t,count:1})}for(let{label:e,count:t}of r.values())n(e,t,`Tagged on ${t} imported card${t===1?``:`s`}`)}return Object.freeze([...t.values()].sort((e,t)=>t.cardCount-e.cardCount||e.label.localeCompare(t.label)).map(e=>Object.freeze({label:e.label,cardCount:e.cardCount,evidence:e.evidence})))}function Yt(e,t={}){let n=Math.max(0,t.limit??8);return Object.freeze(Jt(e).slice(0,n).map(e=>Object.freeze({field:`interests`,value:e.label,evidence:e.evidence,confidence:null,source:`anki-import`})))}function Xt(e){return new TextDecoder().decode(e)}async function Zt(e,t){let n=e.name.toLowerCase().endsWith(`.apkg`)?await Ot(e.bytes,t.now):Dt(Xt(e.bytes),e.name,t.now),r=0,i=0,a=0;for(let e of n.decks){let n=kt(await t.store.getDeck(e.id),e);await t.store.saveDeck(n.deck),r+=n.added,i+=n.updated,a+=n.unchanged}return Object.freeze({deckCount:n.decks.length,cardsAdded:r,cardsUpdated:i,cardsUnchanged:a,warnings:Object.freeze([...n.warnings]),proposals:Yt(n.decks,{limit:t.limit})})}function Qt(e){let t=e.cardsAdded+e.cardsUpdated+e.cardsUnchanged,n=`${e.deckCount} deck${e.deckCount===1?``:`s`}`,r=`${t} card${t===1?``:`s`}`;return e.cardsUpdated===0&&e.cardsUnchanged===0?`Imported ${r} across ${n}.`:`Imported ${r} across ${n} · ${e.cardsAdded} new, ${e.cardsUpdated} updated, ${e.cardsUnchanged} already up to date.`}var L=we();function $t({onImported:e,store:t}){let n=(0,I.useRef)(null),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),l=async n=>{i(!0),c(``),o(`Reading your collection…`);try{t||await _e();let r=await Zt({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())},{store:t??j});o(Qt(r)),e(r.proposals)}catch(e){c(e instanceof Error?e.message:`That file could not be read as an Anki collection.`),o(``)}finally{i(!1)}};return(0,L.jsxs)(`section`,{className:`anki-import`,children:[(0,L.jsx)(O,{size:56,state:r?`importing`:`greeting`,label:``}),(0,L.jsxs)(`div`,{className:`anki-import__body`,children:[(0,L.jsx)(`p`,{className:`anki-import__ask`,children:`Do you use Anki?`}),(0,L.jsx)(`p`,{children:`Bring your decks and they keep their scheduling. What you have been drilling also tells me what you study — I will show you what I read from it before anything is kept.`}),a&&(0,L.jsx)(`p`,{className:`anki-import__status`,role:`status`,children:a}),s&&(0,L.jsx)(`p`,{className:`anki-import__error`,role:`alert`,children:s}),(0,L.jsx)(`input`,{ref:n,type:`file`,className:`anki-import__file`,accept:`.apkg,.txt,.csv,.tsv`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&l(t)}}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:r,onClick:()=>n.current?.click(),children:r?`Importing…`:`Choose an .apkg file`})]})]})}var en=Object.freeze([Object.freeze({id:`name`,ask:`What should I call you?`,hint:`A first name or a nickname — whatever you would like to be called.`,fields:Object.freeze([]),verbatim:`preferredName`}),Object.freeze({id:`goal`,ask:`What are you hoping to understand?`,hint:`One subject is plenty. “Why enzymes speed reactions up” beats “chemistry”.`,fields:Object.freeze([`motivation`,`educationStage`]),verbatim:`goalText`}),Object.freeze({id:`teaching`,ask:`When something finally clicked for you, what made it click?`,hint:`Being walked through it, being asked about it, seeing it drawn — whatever it was.`,fields:Object.freeze([`socraticIntensity`,`hintLevel`,`depth`])}),Object.freeze({id:`tone`,ask:`And how should I talk to you when you get something wrong?`,hint:`Straight about it, gently, or somewhere in between.`,fields:Object.freeze([`tone`,`ageBand`])})]),tn=e=>en.find(t=>t.id===e);function nn(e){let t={};for(let n of e){let e=tn(n.promptId)?.verbatim,r=n.text.trim();!e||!r||(t[e]=r)}return t}async function rn(e,t={}){let n=t.call??c({runtime:s(),accept:()=>!0}),r=[],a=0;for(let s of e){let e=tn(s.promptId)?.fields??o;if(e.length===0||!s.text.trim())continue;a+=1;let c=await i(s.text,e,n,{signal:t.signal});for(let e of c){let t=l(e,s.source);if(!t)continue;let n=r.findIndex(e=>e.field===t.field);n>=0&&r.splice(n,1),r.push(t)}}return Object.freeze({proposals:Object.freeze(r),abstainedEntirely:a>0&&r.length===0})}function an(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var on=()=>an()!==null;function sn({onDone:e,onUseForm:t}){let[n,r]=(0,I.useState)(0),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)([]),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),f=(0,I.useRef)(!1),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=en[n],g=n>=en.length;(0,I.useEffect)(()=>{m.current?.focus()},[n]),(0,I.useEffect)(()=>()=>{try{p.current?.stop()}catch{}},[]);function _(){if(c){try{p.current?.stop()}catch{}return}let e=an();if(!e)return;let t=new e;t.lang=document.documentElement.lang||`en-US`,t.continuous=!0,t.interimResults=!1,t.onresult=e=>{let t=Array.from(e.results,e=>e[0]?.transcript??``).join(` `).trim();t&&(f.current=!0,a(e=>e.trim()?`${e.trim()} ${t}`:t))},t.onend=()=>l(!1),t.onerror=()=>l(!1),p.current=t;try{t.start(),l(!0)}catch{l(!1)}}async function v(t){if(n+1<en.length){r(n+1),a(``),f.current=!1;return}d(!0);let{proposals:i}=await rn(t);r(en.length),e({proposals:i,verbatim:nn(t),answers:t})}function ee(){try{p.current?.stop()}catch{}let e=i.trim(),t=f.current?`speech`:`conversation`,n=e?[...o,{promptId:h.id,text:e,source:t}]:o;s(n),v(n)}return g?(0,L.jsxs)(`section`,{className:`intake-chat`,"aria-live":`polite`,children:[(0,L.jsx)(O,{size:72,state:u?`sorting`:`settled`,label:``}),(0,L.jsx)(`p`,{className:`intake-chat__reading`,children:u?`Reading back what you told me…`:`Thank you.`})]}):(0,L.jsxs)(`section`,{className:`intake-chat`,"aria-labelledby":`intake-chat-ask`,children:[(0,L.jsx)(`div`,{className:`intake-chat__said`,children:o.map(e=>(0,L.jsx)(`p`,{className:`intake-chat__answer`,"data-source":e.source,children:e.text},e.promptId))}),(0,L.jsxs)(`div`,{className:`intake-chat__turn`,children:[(0,L.jsx)(O,{size:64,state:c?`listening-voice`:`greeting`,label:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`intake-chat__ask`,id:`intake-chat-ask`,ref:m,tabIndex:-1,children:h.ask}),(0,L.jsx)(`p`,{className:`intake-chat__hint`,children:h.hint})]})]},h.id),(0,L.jsxs)(`label`,{className:`intake-chat__compose`,children:[(0,L.jsx)(`span`,{className:`intake-chat__label`,children:`Your answer`}),(0,L.jsx)(`textarea`,{value:i,rows:3,placeholder:c?`Listening…`:`Type, or use the microphone.`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ee())}})]}),(0,L.jsxs)(`footer`,{className:`intake-chat__actions`,children:[(0,L.jsxs)(`div`,{children:[on()&&(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__mic`,"aria-pressed":c,onClick:_,children:c?`Stop listening`:`Answer out loud`}),t&&(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__plain`,onClick:t,children:`Fill a form instead`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__plain`,onClick:()=>{a(``),f.current=!1,v(o)},children:n+1===en.length?`Skip and finish`:`Skip`}),(0,L.jsx)(`button`,{type:`button`,className:`intake-chat__next`,disabled:!i.trim(),onClick:ee,children:n+1===en.length?`Done`:`Next`})]})]}),(0,L.jsxs)(`p`,{className:`intake-chat__progress`,role:`status`,children:[`Question `,n+1,` of `,en.length,` · every one is optional`]})]})}function cn(e,t,n){return e.map((e,r)=>r===t?e===n?`pending`:n:e)}function ln(e,t){return e.filter((e,n)=>t[n]===`accepted`)}function un(e){return e.field===`interests`?e.value:e.value.replace(/-/gu,` `)}function dn(e){if(e.field===`interests`)return`Interest`;try{return n(e.field).asks.replace(/^the learner['’]s /iu,``).replace(/^their /iu,``)}catch{return e.field}}var fn={conversation:`from what you typed`,speech:`from what you said`,"anki-import":`from your imported decks`};function pn({proposals:e,onApply:t,onDismiss:n,heading:r=`Here is what I picked up.`}){let[i,o]=(0,I.useState)(()=>e.map(()=>`pending`)),s=(0,I.useMemo)(()=>ln(e,i),[e,i]),c=i.filter(e=>e!==`pending`).length;if(e.length===0)return null;let l=(e,t)=>{o(n=>cn(n,e,t))};return(0,L.jsxs)(`section`,{className:`proposal-review`,"aria-labelledby":`proposal-review-title`,children:[(0,L.jsxs)(`header`,{className:`proposal-review__head`,children:[(0,L.jsx)(O,{size:56,state:`sorting`,label:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{id:`proposal-review-title`,children:r}),(0,L.jsx)(`p`,{children:`Nothing is saved until you say so. Keep what fits, drop the rest — you can change any of it later in Settings → Learning.`})]})]}),(0,L.jsx)(`ul`,{className:`proposal-review__list`,children:e.map((e,t)=>{let n=i[t]??`pending`;return(0,L.jsxs)(`li`,{"data-verdict":n,style:{animationDelay:`${Math.min(t,8)*45}ms`},children:[(0,L.jsxs)(`div`,{className:`proposal-review__claim`,children:[(0,L.jsx)(`span`,{className:`proposal-review__field`,children:dn(e)}),(0,L.jsx)(`strong`,{className:`proposal-review__value`,children:un(e)})]}),(0,L.jsxs)(`blockquote`,{className:`proposal-review__evidence`,children:[e.evidence,(0,L.jsx)(`cite`,{children:fn[e.source]})]}),(0,L.jsxs)(`div`,{className:`proposal-review__verdict`,children:[(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,"aria-pressed":n===`accepted`,onClick:()=>l(t,`accepted`),children:`Keep`}),(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,"aria-pressed":n===`discarded`,onClick:()=>l(t,`discarded`),children:`Drop`})]})]},`${e.field}:${e.value}:${t}`)})}),(0,L.jsxs)(`footer`,{className:`proposal-review__actions`,children:[(0,L.jsx)(`p`,{className:`proposal-review__count`,role:`status`,children:s.length===0?`Nothing kept yet · ${c} of ${e.length} reviewed`:`Keeping ${s.length} of ${e.length}`}),(0,L.jsxs)(`div`,{children:[n&&(0,L.jsx)(`button`,{type:`button`,className:`dialog-compact-button`,onClick:n,children:`Not now`}),(0,L.jsx)(`button`,{type:`button`,className:`proposal-review__apply dialog-compact-button`,onClick:()=>t(s,a(s)),children:s.length===0?`Save nothing`:`Save ${s.length}`})]})]})]})}function mn(e){return{profile_fields_filled:r(e).length,profile_groups_skipped:e.skippedGroups.length,profile_has_goal:e.goalText.trim().length>0}}var hn=new Set([`step_id`,`step_index`,`step_count`,`skipped`,`steps_visible`,`profile_fields_filled`,`profile_groups_skipped`,`profile_has_goal`]);function gn(e){let t={};for(let[n,r]of Object.entries(e))hn.has(n)&&(typeof r==`number`&&Number.isFinite(r)||typeof r==`boolean`||typeof r==`string`&&/^[a-z0-9][a-z0-9_-]{0,39}$/.test(r))&&(t[n]=r);return t}function _n(){let e=be();return(0,I.useCallback)((t,n={})=>{if(e)try{e.capture(t,gn(n))}catch{}},[e])}var vn=`keating:onboarding:v1`;function yn(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function bn(e){try{let t=JSON.parse(e?.getItem(`keating:onboarding:v1`)??`null`);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}function xn(e=yn()){let t=bn(e);return!t||t.version!==1&&t.version!==2?!1:t.outcome===`completed`||t.outcome===`skipped`}function Sn(e=yn()){let t=bn(e);if(!t||t.version!==2||t.outcome!==`in-progress`)return 0;let n=typeof t.step==`number`&&Number.isInteger(t.step)?t.step:0;return Math.min(Math.max(n,0),wn.length-1)}function Cn(e,t=yn(),n=0){try{return t?(t.setItem(vn,JSON.stringify({version:2,outcome:e,step:n,completedAt:e===`in-progress`?null:new Date().toISOString()})),!0):!1}catch{return!1}}var wn=[{id:`welcome`,label:`Welcome`},{id:`access`,label:`Model access`},{id:`setup`,label:`Setup`},{id:`identity`,label:`About you`,group:`identity`},{id:`learning`,label:`Your learning`,group:`goals`},{id:`teaching`,label:`How to teach you`,group:`pedagogy`},{id:`accessibility`,label:`Accessibility`,group:`accessibility`},{id:`finish`,label:`You are set`}],Tn=wn.length-1,En=new Set([`learning`,`teaching`,`accessibility`]);function Dn(e,t){let n=new Set((e??[]).map(e=>`${e.field}:${e.value.toLowerCase()}`));return Object.freeze([...e??[],...t.filter(e=>{let t=`${e.field}:${e.value.toLowerCase()}`;return n.has(t)?!1:(n.add(t),!0)})])}function On(e){return e===`conversation`?wn.filter(e=>!En.has(e.id)):wn}var kn={welcome:`greeting`,access:`thinking`,setup:`loading`,identity:`listening`,learning:`understanding`,teaching:`reading`,accessibility:`connecting`,finish:`settled`},An={welcome:`Keating teaches by asking.`,identity:`Tell Keating who it is talking to.`,learning:`What would you like to understand?`,teaching:`How should Keating teach you?`,accessibility:`Anything that would make this easier?`,finish:`You are set.`},jn={welcome:`Rather than hand you answers, Keating works through a question with you — then checks what stuck. Ask it anything in the composer at the bottom; it can pull up diagrams, quizzes and plans beside the conversation as you go.`,identity:`All optional, all stored only in this browser, and all changeable later in Settings → Learning.`,learning:`Just a starting point for today — not a commitment. You can change direction whenever you like, and Keating follows what you actually ask about. We will put this in the composer for you to review and send.`,teaching:`These are preferences, not a test. Keating follows them.`,accessibility:`Keating treats these as requirements, not suggestions.`,finish:`Your profile is saved on this device. Change any of it in Settings → Learning → Your profile.`};function Mn({onUseKeating:e,onConnectAccount:t,onChooseModel:n,onComplete:r,onSkip:i,onStartTour:a,initialStep:o}){let[s,c]=(0,I.useState)(()=>o??Sn()),[l,p]=(0,I.useState)(`keating`),[m,h]=(0,I.useState)(()=>Se()),[_,v]=(0,I.useState)(!1),[te,y]=(0,I.useState)(``),ne=(0,I.useRef)(null),ie=(0,I.useRef)(!1),[b,ae]=(0,I.useState)(`form`),[x,oe]=(0,I.useState)(null),S=On(b),se=S.length-1,C=S[s]??S[0],ce=_n();(0,I.useEffect)(()=>{ne.current?.focus({preventScroll:!0})},[s]),(0,I.useEffect)(()=>{ce(`onboarding_viewed`,{step_id:C.id,step_index:s,step_count:S.length})},[C.id,s,ce]);let w=(0,I.useCallback)(e=>h(t=>({...t,...e})),[]),ue=(0,I.useCallback)(e=>{try{M(m)}catch{}Cn(`in-progress`,yn(),e)},[m]);function T(){if(ie.current)return;ie.current=!0;let e=u(m);try{M(e)}catch{}Cn(`skipped`,yn(),s),ce(`onboarding_skipped`,{step_id:C.id,step_index:s,...mn(e)}),i()}function E(){if(ie.current)return;ie.current=!0;let e=u(m);try{M(e)}catch{}Cn(`completed`,yn(),Tn),ce(`onboarding_completed`,{step_count:S.length,intake_mode:b,...mn(e)}),r(e.goalText.trim()||void 0)}async function D(e){v(!0),y(``);try{await e()}catch{y(`That setup couldn’t open. Try again, or continue to chat and set it up later.`)}finally{v(!1)}}function pe(e){ue(e),ie.current||c(e)}function k(){C.group&&ve(C.group),ce(`onboarding_step_completed`,{step_id:C.id,step_index:s,skipped:!0}),y(``),pe(Math.min(s+1,se))}async function A(){if(!_){if(y(``),C.id===`access`&&l===`keating`){v(!0);try{await e()}catch{y(`Keating’s model couldn’t be selected. Try again, or choose your own provider.`);return}finally{v(!1)}}ce(`onboarding_step_completed`,{step_id:C.id,step_index:s,skipped:!1}),pe(Math.min(s+1,se))}}let me=l===`keating`?`Make yourself at home.`:l===`offline`?`Set up your offline tutor.`:`Connect your model.`,he=l===`keating`?`${ge.name} is selected. Connect or create a Not Organic account to use Keating’s hosted model.`:l===`offline`?`Download the model once, then chat on this device without an account or internet connection.`:`Choose a model and add your provider key. A Not Organic account isn’t required.`,_e={profile:m,onChange:w,idPrefix:`onboarding`};return(0,L.jsxs)(`section`,{className:`chat-onboarding`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`chat-onboarding-title`,"aria-describedby":`chat-onboarding-description`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),T())},children:[(0,L.jsxs)(`header`,{className:`chat-onboarding__top`,children:[(0,L.jsx)(`span`,{children:`Welcome to Keating`}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__skip`,onClick:T,children:`Go straight to chat`})]}),(0,L.jsxs)(`div`,{className:`chat-onboarding__intro`,children:[(0,L.jsx)(O,{size:88,state:kn[C.id]??`idle`,label:``}),(0,L.jsxs)(`div`,{className:`chat-onboarding__progress`,children:[(0,L.jsxs)(`p`,{className:`chat-onboarding__progress-label`,children:[s+1,` of `,S.length,` · `,C.label]}),(0,L.jsx)(`ol`,{className:`chat-onboarding__track`,"aria-hidden":`true`,children:S.map((e,t)=>(0,L.jsx)(`li`,{"data-state":t<s?`done`:t===s?`current`:`ahead`},e.id))})]})]}),(0,L.jsx)(`h2`,{ref:ne,tabIndex:-1,id:`chat-onboarding-title`,children:C.id===`access`?`How would you like to chat?`:C.id===`setup`?me:An[C.id]}),(0,L.jsx)(`p`,{id:`chat-onboarding-description`,children:C.id===`access`?`Choose how to run your model. You can change this later.`:C.id===`setup`?he:jn[C.id]}),(0,L.jsxs)(`div`,{className:`chat-onboarding__step`,children:[C.id===`welcome`&&(0,L.jsxs)(`ul`,{className:`chat-onboarding__tips`,children:[(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`The composer`}),` at the bottom is where you ask. Plain questions work best.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`The side panel`}),` opens on its own when Keating draws a diagram, sets a quiz or writes a plan.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`Sessions`}),` in the left rail keep each subject separate, and Keating remembers what you covered.`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`Settings → Learning`}),` is where you change your profile, the teacher’s persona and voice.`]})]}),C.id===`welcome`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__doors`,children:[(0,L.jsx)(`p`,{className:`chat-onboarding__doors-ask`,children:`First, how should I get to know you?`}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`chat-onboarding__door`,"aria-pressed":b===`form`,onClick:()=>ae(`form`),children:[(0,L.jsx)(`strong`,{children:`Fill a short form`}),(0,L.jsx)(`span`,{children:`Four screens of questions, all skippable.`})]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-onboarding__door`,"aria-pressed":b===`conversation`,onClick:()=>ae(`conversation`),children:[(0,L.jsx)(`strong`,{children:`Talk it through`}),(0,L.jsx)(`span`,{children:`Four open questions, typed or spoken. I read your answers back before keeping anything.`})]})]})]}),C.id===`access`&&(0,L.jsxs)(`fieldset`,{className:`chat-onboarding__access`,disabled:_,children:[(0,L.jsx)(`legend`,{children:`Model access`}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`keating`,checked:l===`keating`,onChange:()=>{p(`keating`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Use Keating`}),(0,L.jsxs)(`span`,{children:[ge.name,` · Default`]})]})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`byok`,checked:l===`byok`,onChange:()=>{p(`byok`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Bring your own key`}),(0,L.jsx)(`span`,{children:`Your provider, your choice of model`})]})]}),d()&&(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`radio`,name:`onboarding-access`,value:`offline`,checked:l===`offline`,onChange:()=>{p(`offline`),y(``)}}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Use an offline tutor`}),(0,L.jsx)(`span`,{children:`Optional 1.55 GB download · No account needed`})]})]})]}),C.id===`setup`&&l===`keating`&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,disabled:_,onClick:()=>void D(t),children:_?`Opening…`:`Connect or create an account`}),C.id===`setup`&&l===`byok`&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,disabled:_,onClick:()=>void D(n),children:_?`Opening…`:`Choose a model and provider`}),C.id===`setup`&&l===`offline`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(re,{}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>void D(n),children:`Choose the offline model`})]}),C.id===`identity`&&b===`form`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__fields`,children:[(0,L.jsx)(de,{..._e}),(0,L.jsx)(g,{..._e})]}),C.id===`identity`&&(b===`form`||x!==null)&&(0,L.jsx)($t,{onImported:e=>oe(t=>Dn(t,e))}),C.id===`identity`&&b===`form`&&x!==null&&x.length>0&&(0,L.jsx)(pn,{proposals:x,heading:`From your decks.`,onDismiss:()=>oe(null),onApply:(e,t)=>{w(t),oe(null)}}),C.id===`identity`&&b===`conversation`&&x?.length===0&&(0,L.jsxs)(`div`,{className:`chat-onboarding__doors`,children:[(0,L.jsx)(`p`,{className:`chat-onboarding__doors-ask`,children:`I did not want to guess.`}),(0,L.jsx)(`p`,{children:`Nothing in those answers was clear enough for me to propose, so I have kept none of it. You can fill the form instead, or carry on — I will learn as we talk.`}),(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,onClick:()=>{oe(null),ae(`form`)},children:`Fill the form instead`})]}),C.id===`identity`&&b===`conversation`&&x?.length!==0&&(x===null?(0,L.jsx)(sn,{onUseForm:()=>ae(`form`),onDone:e=>{w(e.verbatim),oe(e.proposals)}}):(0,L.jsx)(pn,{proposals:x,heading:`Here is what I picked up.`,onDismiss:()=>{oe(null),pe(Math.min(s+1,se))},onApply:(e,t)=>{w(t),pe(Math.min(s+1,se))}})),C.id===`learning`&&(0,L.jsxs)(`div`,{className:`chat-onboarding__fields`,children:[(0,L.jsx)(ee,{..._e}),(0,L.jsx)(fe,{..._e})]}),C.id===`teaching`&&(0,L.jsx)(`div`,{className:`chat-onboarding__fields`,children:(0,L.jsx)(f,{..._e})}),C.id===`accessibility`&&(0,L.jsx)(`div`,{className:`chat-onboarding__fields`,children:(0,L.jsx)(le,{..._e})}),C.id===`finish`&&a&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,onClick:()=>{E(),a()},children:`Show me around first`}),te&&(0,L.jsx)(`p`,{className:`chat-onboarding__error`,role:`alert`,children:te})]},C.id),(0,L.jsxs)(`footer`,{className:`chat-onboarding__navigation`,children:[(0,L.jsx)(`div`,{children:s>0&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>{y(``),pe(s-1)},children:`Back`})}),(0,L.jsxs)(`div`,{className:`chat-onboarding__advance`,children:[C.group&&(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__skip`,disabled:_,onClick:k,children:`Skip this`}),!(C.id===`identity`&&b===`conversation`&&x===null)&&(s<se?(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__secondary`,disabled:_,onClick:()=>void A(),children:_&&C.id===`access`?`Selecting…`:`Next`}):(0,L.jsx)(`button`,{type:`button`,className:`chat-onboarding__primary`,onClick:E,children:`Start chatting`}))]})]})]})}var Nn={width:320,height:190};function Pn(e){if(typeof document>`u`)return null;try{return document.querySelector(e)}catch{return null}}function Fn(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!1;try{return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||document.documentElement.getAttribute(`data-reduce-motion`)===`true`}catch{return!1}}function In({steps:e=v,onFinish:t,onSkip:n,initialStep:r,resolveAnchor:i=Pn}){let a=(0,I.useMemo)(()=>y(e,e=>i(e)!==null),[e,i]),o=a.length,[s,c]=(0,I.useState)(()=>{let e=r??te(void 0,Math.max(o,1));return o===0?0:Math.min(Math.max(e,0),o-1)}),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(Nn),p=(0,I.useRef)(null),m=(0,I.useRef)(null),h=(0,I.useRef)(!1),g=a[s],_=_n(),ee=(0,I.useRef)(!1);(0,I.useEffect)(()=>{ee.current||o===0||(ee.current=!0,_(`interface_tour_started`,{steps_visible:o}))},[o,_]);let ne=(0,I.useCallback)(()=>{if(!g){u(null);return}let e=i(g.anchor);if(!e){u(null);return}let t=e.getBoundingClientRect();u({top:t.top,left:t.left,width:t.width,height:t.height})},[i,g]);(0,I.useEffect)(()=>{if(!g)return;let e=i(g.anchor);e&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`,behavior:Fn()?`auto`:`smooth`}),ne(),m.current?.focus({preventScroll:!0})},[ne,i,g]),(0,I.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>ne();return window.addEventListener(`resize`,e,{passive:!0}),window.addEventListener(`scroll`,e,{passive:!0,capture:!0}),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,{capture:!0})}},[ne]),(0,I.useLayoutEffect)(()=>{let e=p.current?.getBoundingClientRect();e&&(Math.abs(e.width-d.width)<2&&Math.abs(e.height-d.height)<2||f({width:e.width,height:e.height}))},[d.height,d.width,s,g]);let re=(0,I.useCallback)(e=>{h.current||(h.current=!0,C(e,void 0,e===`completed`?Math.max(o-1,0):s),_(e===`completed`?`interface_tour_completed`:`interface_tour_skipped`,{step_index:s,steps_visible:o}),(e===`completed`?t:n)())},[s,t,n,o,_]),ie=(0,I.useCallback)(e=>{if(h.current)return;if(e>=o){re(`completed`);return}let t=Math.min(Math.max(e,0),Math.max(o-1,0));C(`in-progress`,void 0,t),c(t)},[re,o]);if((0,I.useEffect)(()=>{o===0&&!h.current&&(h.current=!0,C(`completed`,void 0,0),t())},[t,o]),!g)return null;let b={width:typeof window>`u`?1024:window.innerWidth,height:typeof window>`u`?768:window.innerHeight},ae=l?w({anchor:l,viewport:b,card:d}):{top:Math.max(12,b.height/2-d.height/2),left:Math.max(12,b.width/2-d.width/2),placement:`below`};return(0,L.jsxs)(`div`,{className:`tour-spotlight`,children:[l&&(0,L.jsx)(`div`,{className:`tour-spotlight__ring`,"aria-hidden":`true`,style:{top:l.top-4,left:l.left-4,width:l.width+8,height:l.height+8}}),(0,L.jsxs)(`div`,{ref:p,className:`tour-spotlight__card`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`tour-spotlight-title`,"aria-describedby":`tour-spotlight-body`,"data-placement":ae.placement,style:{top:ae.top,left:ae.left},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),re(`skipped`)),e.key===`ArrowRight`&&(e.preventDefault(),ie(s+1)),e.key===`ArrowLeft`&&(e.preventDefault(),ie(s-1))},children:[(0,L.jsxs)(`p`,{className:`tour-spotlight__progress`,children:[s+1,` of `,o]}),(0,L.jsx)(`h2`,{id:`tour-spotlight-title`,ref:m,tabIndex:-1,children:g.title}),(0,L.jsx)(`p`,{id:`tour-spotlight-body`,children:g.body}),(0,L.jsxs)(`div`,{className:`tour-spotlight__actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__skip`,onClick:()=>re(`skipped`),children:`Skip tour`}),(0,L.jsxs)(`div`,{className:`tour-spotlight__advance`,children:[s>0&&(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__secondary`,onClick:()=>ie(s-1),children:`Back`}),(0,L.jsx)(`button`,{type:`button`,className:`tour-spotlight__primary`,onClick:()=>ie(s+1),children:s===o-1?`Done`:`Next`})]})]})]})]})}var Ln=e(xe(),1),Rn={plan:`user`,map:`user`,animation:`user`,deck:`user`,verification:`user`,benchmark:`agent`,evolution:`agent`,"prompt-evolution":`agent`,improvement:`agent`},zn={plan:{label:`Lesson Plan`,icon:(0,L.jsx)(it,{size:14})},map:{label:`Concept Map`,icon:(0,L.jsx)(zt,{size:14})},animation:{label:`Animation`,icon:(0,L.jsx)(ft,{size:14})},deck:{label:`Flashcards`,icon:(0,L.jsx)(Je,{size:14})},verification:{label:`Verification`,icon:(0,L.jsx)(ot,{size:14})},benchmark:{label:`Benchmark`,icon:(0,L.jsx)(Ye,{size:14})},evolution:{label:`Evolution`,icon:(0,L.jsx)(st,{size:14})},"prompt-evolution":{label:`Prompt Evo`,icon:(0,L.jsx)(Ye,{size:14})},improvement:{label:`Improvement`,icon:(0,L.jsx)(h,{size:14})}},Bn=`keating:artifact-show-agent`;function Vn(){if(typeof localStorage>`u`)return!1;try{return localStorage.getItem(Bn)===`1`}catch{return!1}}function Hn(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Bn,e?`1`:`0`)}catch{}}function Un(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?`Just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a===1?`Yesterday`:a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Wn(e){let t=e.data;switch(e.type){case`plan`:return`Phases: ${t?.metadata?.phaseCount??`—`} | Domain: ${t?.metadata?.domain??`—`}`;case`map`:return t?.mmdContent?`${String(t.mmdContent).split(`
2
2
  `).length} nodes`:`Concept map`;case`animation`:return`Storyboard + scene`;case`deck`:return`${t.cards.length} cards`;case`benchmark`:return`Score: ${t.score.toFixed(1)}/100`;case`evolution`:return`Best: ${t.bestScore.toFixed(1)}/100`;case`verification`:return t?.checklist?`${String(t.checklist).split(`
3
3
  `).filter(e=>e.startsWith(`- [`)).length} checks`:`Checklist`;case`prompt-evolution`:return`Best score: ${t.bestScore.toFixed(1)}`;case`improvement`:return t.accepted?`Accepted`:`Rejected`;default:return``}}function Gn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`artifact`}function Kn(e){let t=`keating-${e.type}-${Gn(e.label)}`;switch(e.type){case`plan`:return{filename:`${t}.md`,content:e.data.content,type:`text/markdown;charset=utf-8`};case`map`:{let n=e.data;return{filename:`${t}.${n.svgContent?`svg`:`mmd`}`,content:n.svgContent??n.mmdContent,type:n.svgContent?`image/svg+xml;charset=utf-8`:`text/plain;charset=utf-8`}}case`animation`:{let n=e.data;return{filename:`${t}.json`,content:`${JSON.stringify({topic:n.topic,storyboard:n.storyboard,scene:n.scene,manifest:qn(n.manifest),renderer:n.renderer,createdAt:n.createdAt},null,2)}\n`,type:`application/json;charset=utf-8`}}case`deck`:return{filename:`${t}.json`,content:`${JSON.stringify(e.data,null,2)}\n`,type:`application/json;charset=utf-8`};case`benchmark`:return{filename:`${t}.md`,content:e.data.report,type:`text/markdown;charset=utf-8`};case`evolution`:return{filename:`${t}.md`,content:e.data.report,type:`text/markdown;charset=utf-8`};case`verification`:return{filename:`${t}.md`,content:e.data.checklist,type:`text/markdown;charset=utf-8`};case`prompt-evolution`:return{filename:`${t}.md`,content:e.data.report,type:`text/markdown;charset=utf-8`};case`improvement`:return{filename:`${t}.md`,content:Jn(e.data),type:`text/markdown;charset=utf-8`}}}function qn(e){try{return JSON.parse(e)}catch{return e}}function Jn(e){return`# Improvement Attempt
4
4
 
@@ -52,4 +52,4 @@ ${s.join(`
52
52
  `),r=t.replace(/\r\n/g,`
53
53
  `).split(`
54
54
  `),i=[],a=0,o=0;for(;a<n.length||o<r.length;)if(a<n.length&&o<r.length&&n[a]===r[o])i.push({lineNumber:a+1,type:`unchanged`,content:n[a]}),a++,o++;else if(a<n.length&&(!r[o]||n[a]!==r[o])){let e=r.slice(o).findIndex(e=>e===n[a]);if(e===-1||e>3)i.push({lineNumber:a+1,type:`removed`,content:n[a]}),a++;else{for(let t=0;t<e;t++)i.push({lineNumber:o+1,type:`added`,content:r[o+t]});o+=e}}else i.push({lineNumber:o+1,type:`added`,content:r[o]}),o++;return i}function Pf(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ff(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function If(){return`ev-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Lf(e){switch(e){case`browser-nodepod`:return`NodePod · local`;case`browser-only`:return`This browser`;case`host`:return`Host machine`;case`remote`:return`Remote server`;case`cloud`:return`Cloud container`;default:return`Unknown`}}var $={panel:`runtime-panel`,header:`runtime-header`,minW0:`runtime-min-w0`,flexCenter:`runtime-flex-center`,body:`runtime-body`,grid2:`runtime-grid2`,grid3:`runtime-grid3`,card:`runtime-card`,textXsMuted:`runtime-text-xs-muted`,text10Muted:`runtime-text10-muted`,semiboldXs:`runtime-semibold-xs`,mono:`runtime-mono`,monoXs:`runtime-mono-xs`,primaryButtonSm:`runtime-primary-button-sm`,primaryButton:`runtime-primary-button`,outlineButtonSmBg:`runtime-outline-button-sm-bg`,outlineButton:`runtime-outline-button`,inputBase:`runtime-input-base`,inputMono:`runtime-input-mono`,hidden:`runtime-hidden`};function Rf({size:e=16}){return(0,L.jsx)(P,{icon:Pt,size:e,className:`runtime-spinner`})}function zf({open:e,onClose:t}){let n=(0,I.useRef)(null),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(`status`),[p,m]=(0,I.useTransition)(),[h,g]=(0,I.useState)([]),[v,ee]=(0,I.useState)(null),[te,y]=(0,I.useState)(!1),[re,b]=(0,I.useState)(!1),ae=()=>{if(te){b(!0);return}b(!1),t()},[S,C]=(0,I.useState)(null),[ce,w]=(0,I.useState)(`/workspace`),[le,ue]=(0,I.useState)([]),[de,fe]=(0,I.useState)(!1),[T,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(``),[pe,me]=(0,I.useState)(!1),[he,ge]=(0,I.useState)(!1),[_e,j]=(0,I.useState)([]),[ve,ye]=(0,I.useState)(!1),[be,xe]=(0,I.useState)(``),[Se,Ce]=(0,I.useState)(`file`),M=(0,I.useRef)(null),[we,Te]=(0,I.useState)(!1),[Ee,De]=(0,I.useState)(()=>Be()),[qe,Je]=(0,I.useState)([]),[Ye,Xe]=(0,I.useState)(!1),[Ze,Qe]=(0,I.useState)(!1),[$e,et]=(0,I.useState)([]),[tt,nt]=(0,I.useState)([]),[rt,it]=(0,I.useState)(`main`),[at,ot]=(0,I.useState)(``),[st,ct]=(0,I.useState)(``),[lt,ut]=(0,I.useState)(!1),[dt,ft]=(0,I.useState)(null),[mt,ht]=(0,I.useState)(!1),gt=(0,I.useRef)(null),[N,Tt]=(0,I.useState)(`config`),[Dt,Ot]=(0,I.useState)(`{}`),[kt,At]=(0,I.useState)(!1),jt=(0,I.useRef)(null),Lt=(0,I.useMemo)(()=>[{id:`status`,label:`Overview`,icon:(0,L.jsx)(P,{icon:Mr,size:17})},{id:`vfs`,label:`Files`,icon:(0,L.jsx)(P,{icon:Fr,size:17}),disabled:!s},{id:`shell`,label:`Terminal`,icon:(0,L.jsx)(P,{icon:Ur,size:17}),disabled:!s},{id:`log`,label:`Activity`,icon:(0,L.jsx)(P,{icon:Or,size:17})}],[s]);(0,I.useEffect)(()=>{if(!e)return;let t=n.current;return t?.showModal(),Rt(),()=>{t?.close()}},[e]),(0,I.useEffect)(()=>{Ue().then(Je).catch(()=>Je([]))},[]),(0,I.useEffect)(()=>{if(!e||!s||d!==`shell`)return;let t=Pe(),n=M.current;if(!t||!n)return;t.attach(n);let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{t.fit(),Te(!0)})};i();let a=new ResizeObserver(i);return a.observe(n),()=>{a.disconnect(),cancelAnimationFrame(r)}},[e,d,s]);let F=(0,I.useCallback)((e,t,n,r,i)=>{let a={id:If(),timestamp:Date.now(),tab:e,operation:t,ok:n,output:r,durationMs:i};g(e=>[a,...e].slice(0,500)),jt.current&&(jt.current.scrollTop=0)},[]);async function Rt(){await zt(),s&&(await Bt(),await nn()),Vt()}let zt=(0,I.useCallback)(async()=>{try{let e=await ne(!0);if(o(``),i(e),_(e)){c(!1);return}let t=Ie();c(t),(t||Be().length>0)&&C(await ke().catch(()=>null))}catch(e){o(e instanceof Error?e.message:`The workspace could not connect.`)}},[]),Bt=(0,I.useCallback)(async()=>{fe(!0);try{ue(await Ae(ce).catch(()=>[]))}catch{ue([])}finally{fe(!1)}},[ce]);(0,I.useEffect)(()=>{e&&s&&d===`vfs`&&Bt()},[e,s,d,Bt]);let Vt=(0,I.useCallback)(()=>{De(Be())},[]),Ht=(0,I.useCallback)(async()=>{u(!0);let e=performance.now();try{if(!await Re())throw Error(`NodePod could not start. Try again or check Activity.`);let t=Le({Terminal:lf,FitAddon:ff,SerializeAddon:jf});t&&(M.current&&(t.attach(M.current),t.fit()),Te(!0)),await zt(),F(`status`,`bootNodePod`,!0,{mode:`booted`},Math.round(performance.now()-e))}catch(t){F(`status`,`bootNodePod`,!1,{error:t instanceof Error?t.message:String(t)},Math.round(performance.now()-e))}finally{u(!1)}},[F,zt]),Ut=(0,I.useCallback)(async()=>{let e=performance.now();Me(),Te(!1),await Oe(),c(!1),f(`status`),await zt(),C(null),ue([]),E(null),O(``),F(`status`,`teardownNodePod`,!0,{mode:`torn down`},Math.round(performance.now()-e))},[F,zt]),Wt=(0,I.useCallback)(e=>{w(e)},[]),Gt=(0,I.useCallback)(()=>{let e=ce.split(`/`).filter(Boolean);e.pop(),Wt(e.length===0?`/workspace`:`/${e.join(`/`)}`)},[ce,Wt]),Kt=(0,I.useCallback)(async e=>{E(e),ge(!1),j([]);try{O(await Ke(e)),me(!1)}catch(e){O(`// Error reading file:
55
- // `+(e instanceof Error?e.message:String(e))),me(!1)}},[]),qt=(0,I.useCallback)(async()=>{if(T){ye(!0);try{let e=await Ne(T);e&&e.baseline!==void 0?j(Nf(e.baseline,e.current)):j([])}catch{j([])}finally{ye(!1)}}},[T]),Jt=(0,I.useCallback)(async()=>{if(T)try{await We(T,D),me(!1),F(`vfs`,`write ${T}`,!0,{bytes:D.length}),Bt()}catch(e){F(`vfs`,`write ${T}`,!1,{error:e instanceof Error?e.message:String(e)})}},[T,D,F,Bt]),Yt=(0,I.useCallback)(async(e,t)=>{try{await He(e,t),T===e&&(E(null),O(``)),F(`vfs`,`delete ${e}`,!0,{}),Bt()}catch(t){F(`vfs`,`delete ${e}`,!1,{error:t instanceof Error?t.message:String(t)})}},[T,F,Bt]),Xt=(0,I.useCallback)(async()=>{if(be.trim())try{await Ve(ce,be.trim(),Se===`dir`),F(`vfs`,`create ${Se} ${be}`,!0,{}),xe(``),Bt()}catch(e){F(`vfs`,`create ${Se} ${be}`,!1,{error:e instanceof Error?e.message:String(e)})}},[be,ce,Se,F,Bt]),Zt=(0,I.useCallback)(()=>{let e=Pe();e&&e.clear()},[]),Qt=(0,I.useCallback)(()=>{let e=Pe();e&&requestAnimationFrame(()=>e.fit())},[]),$t=(0,I.useCallback)(async()=>{try{Je(await Ue())}catch{Je([])}},[]),en=(0,I.useCallback)(async()=>{Xe(!0);let e=performance.now();try{F(`snapshots`,`snapshot.create`,!0,{id:(await je(`manual-${Date.now()}`)).id},Math.round(performance.now()-e)),Vt(),await $t()}catch(t){F(`snapshots`,`snapshot.create`,!1,{error:t instanceof Error?t.message:String(t)},Math.round(performance.now()-e))}finally{Xe(!1)}},[F,Vt,$t]),tn=(0,I.useCallback)(async e=>{let t=performance.now();try{await Ge(e),F(`snapshots`,`snapshot.restore`,!0,{},Math.round(performance.now()-t)),Bt()}catch(e){F(`snapshots`,`snapshot.restore`,!1,{error:e instanceof Error?e.message:String(e)},Math.round(performance.now()-t))}},[F,Bt]),nn=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([vt(),bt()]),n=await(await xt()).activeBranchId();et(e),nt(t),it(n)}catch{et([]),nt([])}},[]),rn=(0,I.useCallback)(async()=>{if(st.trim()){ut(!0);try{await St(st.trim()),ct(``),await nn(),F(`vc`,`branch.create`,!0,{name:st.trim()})}catch(e){F(`vc`,`branch.create`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}}},[st,nn,F]),an=(0,I.useCallback)(async e=>{ut(!0);try{await yt(e),await nn(),F(`vc`,`branch.switch`,!0,{branchId:e})}catch(e){F(`vc`,`branch.switch`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}},[nn,F]),on=(0,I.useCallback)(async()=>{let e=at.trim()||`checkpoint-${Date.now()}`;ut(!0);try{let t=await Fe(),n=await _t(t,e);ot(``),await nn(),F(`vc`,`commit`,!0,{commitId:n,files:t.length})}catch(e){F(`vc`,`commit`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}},[at,nn,F]),sn=(0,I.useCallback)(async(e,t)=>{ut(!0);try{ft({fromCommit:e,toCommit:t,changes:await Ct(e,t)})}catch{ft(null)}finally{ut(!1)}},[]),cn=(0,I.useCallback)(async e=>{let t=performance.now();ut(!0);try{let n=await wt(e);for(let e of n)await We(e.path,e.content);await Bt(),F(`vc`,`commit.restore`,!0,{commitId:e,files:n.length},Math.round(performance.now()-t))}catch(e){F(`vc`,`commit.restore`,!1,{error:e instanceof Error?e.message:String(e)},Math.round(performance.now()-t))}finally{ut(!1)}},[F,Bt]),ln=(0,I.useCallback)(async()=>{ht(!0);try{let e=await It(),t=`${JSON.stringify(e,null,2)}\n`,n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`keating-sandbox-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),F(`vc`,`portable.export`,!0,{files:e.nodepod.files.length,snapshots:e.nodepod.snapshots.length,gitObjects:Object.keys(e.vc.objects).length})}catch(e){F(`vc`,`portable.export`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ht(!1)}},[F]),un=(0,I.useCallback)(async e=>{ht(!0);try{let t=await e.text(),n=await Ft(JSON.parse(t));await Promise.all([nn(),$t()]),await Bt(),F(`vc`,`portable.import`,!0,n)}catch(e){F(`vc`,`portable.import`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ht(!1),gt.current&&(gt.current.value=``)}},[F,$t,nn,Bt]),dn=(0,I.useCallback)(async()=>{At(!0);let e=performance.now(),t={};try{let n=await ne(!0);if(i(n),N===`config`){t={ok:!0,output:n,durationMs:Math.round(performance.now()-e)},F(`probes`,`agent_runtime.config`,!0,t.output);return}if(n.mode===`browser-only`||!n.executionEndpoint){t={reason:`No execution endpoint is configured.`,mode:n.mode,fallback:n.fallback},F(`probes`,`probe.${N}`,!1,t,Math.round(performance.now()-e));return}let r;try{r=Dt.trim()?JSON.parse(Dt):{}}catch(e){throw Error(`Probe payload is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}if(n.executionEndpoint===`nodepod://local`){let t=await ze(N,r),n=!(t&&typeof t==`object`&&`ok`in t&&t.ok===!1);F(`probes`,`probe.${N}`,n,t,Math.round(performance.now()-e));return}let a=await fetch(`${n.executionEndpoint}/execute`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({operation:N,payload:r})}),o=a.headers.get(`content-type`)?.includes(`application/json`)?await a.json().catch(()=>null):await a.text();F(`probes`,`probe.${N}`,a.ok,o,Math.round(performance.now()-e))}catch(t){F(`probes`,`probe.${N}`,!1,{error:t instanceof Error?t.message:String(t)},Math.round(performance.now()-e))}finally{At(!1)}},[N,Dt,F]),fn=(0,I.useCallback)(async()=>{let e=h.find(e=>e.tab===`probes`);if(!e)return;let t=Pf(e.output);await navigator.clipboard.writeText(t),ee(h.indexOf(e)),window.setTimeout(()=>ee(null),1200)},[h]);if(!e)return null;let pn=se(r,s),mn=l?`Starting…`:s?`Running`:r?.executionEndpoint?`Configured`:`Stopped`,hn=[`snapshots`,`vc`,`probes`].includes(d)?d:``;return(0,L.jsx)(`dialog`,{ref:n,className:`sandbox-runtime`,"aria-labelledby":`runtime-title`,onCancel:e=>{e.preventDefault(),ae()},onClick:e=>{e.target===e.currentTarget&&ae()},children:(0,L.jsxs)(`div`,{className:$.panel,children:[(0,L.jsxs)(`header`,{className:$.header,children:[(0,L.jsxs)(`div`,{className:`runtime-heading`,children:[(0,L.jsx)(`span`,{className:`runtime-mark`,children:(0,L.jsx)(P,{icon:Mr,size:24,active:s})}),(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`h2`,{id:`runtime-title`,children:_(r)?`Desktop workspace`:`Runtime`}),(0,L.jsx)(`p`,{children:a?`Workspace unavailable`:_(r)?`Native files and processes`:r?Lf(r.mode):`Loading environment…`})]})]}),(0,L.jsx)(`button`,{type:`button`,className:`runtime-icon-button`,"aria-label":`Close runtime`,onClick:ae,autoFocus:!0,children:(0,L.jsx)(P,{icon:Gr,size:20})})]}),re&&(0,L.jsxs)(`div`,{className:`desktop-workspace-close`,role:`alert`,children:[(0,L.jsx)(`p`,{children:`Your file has unsaved edits.`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>b(!1),children:`Keep editing`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{b(!1),y(!1),t()},children:`Discard and close`})]})]}),a?(0,L.jsxs)(`div`,{className:`runtime-body`,children:[(0,L.jsx)(`div`,{className:`runtime-error`,role:`alert`,children:a}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void Rt(),children:`Retry connection`})]}):_(r)&&r?.projectRoot?(0,L.jsx)(Jr,{workspacePath:r.projectRoot,onDirtyChange:y}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`runtime-control-bar`,children:[(0,L.jsxs)(`span`,{className:`runtime-state`,"data-running":s,role:`status`,children:[(0,L.jsx)(`span`,{className:`runtime-state-dot`}),mn]}),(0,L.jsxs)(`div`,{className:`runtime-controls`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:Rt,className:`runtime-icon-button`,"aria-label":`Refresh runtime`,title:`Refresh runtime`,children:(0,L.jsx)(P,{icon:Pt,size:18})}),pn===`stop`?(0,L.jsxs)(`button`,{type:`button`,onClick:Ut,className:`runtime-stop`,children:[(0,L.jsx)(P,{icon:Vr,size:17}),`Stop`]}):pn===`boot`?(0,L.jsxs)(`button`,{type:`button`,onClick:Ht,disabled:l,"aria-label":l?`Starting NodePod`:`Start NodePod`,className:$.primaryButton,children:[l?(0,L.jsx)(Rf,{}):(0,L.jsx)(P,{icon:Br,size:17}),l?`Starting…`:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`runtime-start-full`,children:`Start NodePod`}),(0,L.jsx)(`span`,{className:`runtime-start-short`,children:`Start`})]})]}):null]})]}),(0,L.jsxs)(`nav`,{className:`runtime-navigation`,"aria-label":`Runtime views`,children:[Lt.map(e=>(0,L.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>m(()=>f(e.id)),"aria-pressed":d===e.id,className:`runtime-nav-button`,title:e.disabled?`Start NodePod to open `+e.label.toLowerCase():void 0,children:[e.icon,(0,L.jsx)(`span`,{children:e.label})]},e.id)),(0,L.jsxs)(pt,{"aria-label":`More runtime views`,className:`runtime-more`,"data-active":!!hn,value:``,onValueChange:e=>m(()=>f(e)),children:[(0,L.jsx)(`option`,{value:``,disabled:!0,children:`More`}),(0,L.jsx)(`option`,{value:`snapshots`,disabled:!s,children:`Snapshots`}),(0,L.jsx)(`option`,{value:`vc`,disabled:!s,children:`History`}),(0,L.jsx)(`option`,{value:`probes`,children:`Diagnostics`})]})]}),(0,L.jsx)(`div`,{className:$.body,"data-view":d,"aria-busy":p,children:gn()})]})]})});function gn(){switch(d){case`status`:return _n();case`vfs`:return vn();case`shell`:return yn();case`snapshots`:return bn();case`vc`:return xn();case`log`:return Sn();case`probes`:return Cn();default:return null}}function _n(){let e=S?.memoryStats,t=h.slice(0,3),n=!r||r.mode===`browser-only`||r.mode===`browser-nodepod`,i=h[0]&&!h[0].ok?h[0]:null;return(0,L.jsxs)(`div`,{className:`runtime-overview`,children:[i&&(0,L.jsxs)(`div`,{className:`runtime-error`,role:`alert`,children:[(0,L.jsx)(P,{icon:kr,size:18}),(0,L.jsx)(`span`,{children:typeof i.output==`object`&&i.output&&`error`in i.output?String(i.output.error):`An operation failed. Open Activity for details.`})]}),(0,L.jsxs)(`section`,{className:`runtime-intro`,children:[(0,L.jsx)(`p`,{className:`runtime-eyebrow`,children:n?`Local environment`:`Execution environment`}),(0,L.jsx)(`h3`,{children:s?`Ready to run.`:n?`Your browser workspace.`:Lf(r.mode)}),(0,L.jsx)(`p`,{children:s?`JavaScript, TypeScript, and your files. All in this browser.`:n?`Start NodePod to run code, edit files, and save your experiments.`:`Use diagnostics to check the connection and inspect runtime output.`})]}),s&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`dl`,{className:`runtime-metrics`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Files`}),(0,L.jsx)(`dd`,{children:e?.vfs.fileCount??`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Storage`}),(0,L.jsx)(`dd`,{children:e?Ff(e.vfs.totalBytes):`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Snapshots`}),(0,L.jsx)(`dd`,{children:Ee.length})]})]}),(0,L.jsxs)(`div`,{className:`runtime-shortcuts`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>f(`vfs`),children:[(0,L.jsx)(P,{icon:Fr,size:22}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Browse files`}),(0,L.jsx)(`small`,{children:`Open your workspace`})]}),(0,L.jsx)(P,{icon:jr,size:16,className:`runtime-next`})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>f(`shell`),children:[(0,L.jsx)(P,{icon:Ur,size:22}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Open terminal`}),(0,L.jsx)(`small`,{children:`Run a command`})]}),(0,L.jsx)(P,{icon:jr,size:16,className:`runtime-next`})]})]})]}),(0,L.jsxs)(`section`,{className:`runtime-recent`,children:[(0,L.jsxs)(`div`,{className:`runtime-section-heading`,children:[(0,L.jsx)(`h3`,{children:`Recent activity`}),h.length>0&&(0,L.jsxs)(`button`,{type:`button`,className:`runtime-text-button`,onClick:()=>f(`log`),children:[`View all `,(0,L.jsx)(`span`,{children:h.length})]})]}),t.length===0?(0,L.jsx)(`p`,{className:`runtime-empty-inline`,children:`Your runs and workspace changes will appear here.`}):t.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:`runtime-event-row`,onClick:()=>f(`log`),children:[(0,L.jsx)(P,{icon:e.ok?Ar:kr,size:18,className:e.ok?`runtime-success`:`runtime-failure`}),(0,L.jsx)(`span`,{children:e.operation===`bootNodePod`?`NodePod started`:e.operation===`teardownNodePod`?`NodePod stopped`:e.operation}),(0,L.jsx)(`time`,{dateTime:new Date(e.timestamp).toISOString(),children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]},e.id))]}),(0,L.jsxs)(`details`,{className:`runtime-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:Mr,size:18}),`Environment details`]}),(0,L.jsxs)(`dl`,{className:`runtime-facts`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Environment`}),(0,L.jsx)(`dd`,{children:r?Lf(r.mode):`Loading…`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Endpoint`}),(0,L.jsx)(`dd`,{children:r?.executionEndpoint??`No execution endpoint`})]}),S&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Instance`}),(0,L.jsx)(`dd`,{children:S.instanceId})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Shared memory`}),(0,L.jsx)(`dd`,{children:S.sabEnabled?`Available`:`Unavailable`})]})]}),e&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Heap memory`}),(0,L.jsx)(`dd`,{children:e.heap?`${e.heap.usedMB.toFixed(1)} / ${e.heap.limitMB.toFixed(1)} MB`:`Unavailable`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Cached modules`}),(0,L.jsx)(`dd`,{children:e.engine.moduleCacheSize})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Cached transforms`}),(0,L.jsx)(`dd`,{children:e.engine.transformCacheSize})]})]})]}),r&&(0,L.jsx)(`div`,{className:`runtime-capabilities`,children:[{label:`File access`,available:s||r.capabilities.remoteSandbox||r.capabilities.hostProjectAccess},{label:`Shell`,available:s||r.capabilities.remoteSandbox||r.capabilities.localCommandExecution},{label:`Snapshots`,available:s||r.capabilities.durableCompute},{label:`Native binaries`,available:r.capabilities.nativeBinaries}].map(e=>(0,L.jsxs)(`span`,{"data-available":e.available,children:[(0,L.jsx)(P,{icon:e.available?Ar:Gr,size:15}),e.label,(0,L.jsxs)(`span`,{className:`runtime-sr-only`,children:[`: `,e.available?`available`:`unavailable`]})]},e.label))})]}),(0,L.jsxs)(`details`,{className:`runtime-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:Lr,size:18}),`Choose an environment`]}),(0,L.jsxs)(`div`,{className:`runtime-environment-guide`,children:[(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`NodePod · in your browser`}),(0,L.jsx)(`p`,{children:`JavaScript, files, and snapshots. No native binaries or hard security boundary.`}),(0,L.jsx)(`code`,{children:`keating web --browser-only-agent 3000`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Host · your own machine`}),(0,L.jsx)(`p`,{children:`Installed tools and local files. Use for trusted code.`}),(0,L.jsx)(`code`,{children:`keating web --host 3000 --allow-local-exec --root=/path/to/project`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Remote · an external service`}),(0,L.jsx)(`p`,{children:`Provider isolation and native tools, through your configured gateway.`}),(0,L.jsx)(`code`,{children:`keating web --remote 3000 --remote-provider=daytona --remote-endpoint=https://sandbox.example`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Cloud · a hosted runtime`}),(0,L.jsx)(`p`,{children:`Your deployment supplies execution and credentials.`}),(0,L.jsx)(`code`,{children:`keating web --cloud 3000 --cloud-endpoint=https://keating.help`})]})]})]})]})}function vn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsxs)(`div`,{className:$.flexCenter,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>Wt(`/workspace`),className:A({display:`inline-flex`,height:`1.75rem`,width:`1.75rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,_hover:{background:`var(--accent)`}}),"aria-label":`Go to workspace`,title:`Go to /workspace`,children:(0,L.jsx)(P,{icon:Rr,size:13})}),(0,L.jsx)(`button`,{type:`button`,onClick:Gt,className:A({display:`inline-flex`,height:`1.75rem`,width:`1.75rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,_hover:{background:`var(--accent)`}}),"aria-label":`Go to parent folder`,title:`Go up`,children:(0,L.jsx)(P,{icon:jr,size:13})}),(0,L.jsx)(`span`,{className:`runtime-file-path runtime-mono-xs`,children:ce})]}),de?(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsx)(Rf,{size:13}),` Loading…`]}):(0,L.jsx)(`div`,{className:$.card,children:le.length===0?(0,L.jsx)(`div`,{className:A({padding:`0.75rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:`Empty directory`}):le.map(e=>(0,L.jsxs)(`div`,{"data-file-row":!0,className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,borderBottomWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`,fontSize:`0.75rem`,_last:{borderBottomWidth:0},_hover:{background:`rgb(from var(--muted) r g b / 0.3)`}}),children:[(0,L.jsx)(`span`,{className:A({flexShrink:0}),children:e.isDir?(0,L.jsx)(P,{icon:Fr,size:14,className:A({color:`var(--primary)`})}):(0,L.jsx)(P,{icon:Pr,size:14,className:A({color:`var(--muted-foreground)`})})}),(0,L.jsx)(`button`,{type:`button`,className:A({minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,textAlign:`left`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,_hover:{color:`var(--primary)`}}),onClick:()=>e.isDir?Wt(e.path):Kt(e.path),children:e.name}),(0,L.jsx)(`span`,{className:A({marginLeft:`auto`,flexShrink:0,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:e.isDir?`dir`:Ff(e.size)}),(0,L.jsx)(`button`,{type:`button`,className:A({flexShrink:0,color:`rgb(from var(--destructive) r g b / 0.7)`,_hover:{color:`var(--destructive)`}}),"aria-label":`Delete ${e.name}`,onClick:()=>Yt(e.path,e.isDir),children:(0,L.jsx)(P,{icon:x,size:12})})]},e.path))}),(0,L.jsxs)(`div`,{className:`runtime-create-item`,children:[(0,L.jsx)(`input`,{className:A({flex:1,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.375rem 0.5rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`}),"aria-label":`New file or folder name`,placeholder:`new_name.js`,value:be,onChange:e=>xe(e.target.value),onKeyDown:e=>e.key===`Enter`&&Xt()}),(0,L.jsxs)(pt,{"aria-label":`New item type`,className:k(`runtime-item-type`,A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.375rem 0.5rem`,fontSize:`0.75rem`})),value:Se,onValueChange:e=>Ce(e),children:[(0,L.jsx)(`option`,{value:`file`,children:`File`}),(0,L.jsx)(`option`,{value:`dir`,children:`Folder`})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Xt,className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Et,size:12}),` Add`]})]}),T&&(0,L.jsxs)(`div`,{className:$.card,children:[(0,L.jsxs)(`div`,{className:`runtime-file-toolbar`,children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:T}),(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.25rem`}),children:[pe&&(0,L.jsx)(`span`,{className:A({fontSize:`0.75rem`,color:`#d97706`,_dark:{color:`#fcd34d`}}),children:`unsaved`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{ge(e=>!e),he||qt()},className:k(A({display:`inline-flex`,height:`1.75rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,paddingInline:`0.5rem`,fontSize:`0.75rem`}),A(he?{borderColor:`var(--secondary)`,background:`var(--secondary)`,color:`var(--secondary-foreground)`}:{borderColor:`var(--border)`,_hover:{background:`var(--accent)`}})),children:[(0,L.jsx)(P,{icon:Ir,size:12}),` `,he?`Hide diff`:`Show diff`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Jt,className:$.primaryButtonSm,children:[(0,L.jsx)(P,{icon:Mt,size:12}),` Save`]})]})]}),he?(0,L.jsx)(`div`,{className:A({minHeight:`12rem`,width:`100%`,overflow:`auto`,background:`var(--background)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),children:ve?(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsx)(Rf,{size:13}),` Computing diff…`]}):_e.length===0?(0,L.jsx)(`div`,{className:A({color:`var(--muted-foreground)`}),children:`No changes — file matches baseline.`}):(0,L.jsx)(`div`,{className:A({display:`grid`,gap:0}),children:_e.map((e,t)=>(0,L.jsxs)(`div`,{className:k(A({display:`flex`,gap:`0.5rem`,paddingInline:`0.25rem`}),e.type===`removed`?A({background:`rgb(239 68 68 / 0.1)`,color:`#b91c1c`,_dark:{color:`#fca5a5`}}):e.type===`added`?A({background:`rgb(34 197 94 / 0.1)`,color:`#15803d`,_dark:{color:`#86efac`}}):A({color:`var(--muted-foreground)`})),children:[(0,L.jsx)(`span`,{className:A({width:`1rem`,flexShrink:0,userSelect:`none`,textAlign:`center`,fontSize:`10px`,opacity:.5}),children:e.type===`removed`?`-`:e.type===`added`?`+`:` `}),(0,L.jsx)(`span`,{className:A({wordBreak:`break-all`}),children:e.content})]},t))})}):(0,L.jsx)(`textarea`,{className:A({minHeight:`12rem`,width:`100%`,resize:`vertical`,background:`var(--background)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),spellCheck:!1,"aria-label":`Edit ${T}`,value:D,onChange:e=>{O(e.target.value),me(!0)}})]})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use the file system.`})}function yn(){return s?(0,L.jsxs)(`div`,{className:`runtime-terminal-view`,children:[(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:`Terminal`}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.25rem`}),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:Zt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Hr,size:12}),`Clear`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Qt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:zr,size:12}),`Fit`]})]})]}),(0,L.jsx)(`div`,{ref:M,className:A({width:`100%`,overflow:`hidden`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`black`}),style:{flex:1,minHeight:`18rem`}}),!we&&(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Booting terminal…`})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use the shell.`})}function bn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsx)(`div`,{className:`runtime-view-intro`,children:(0,L.jsx)(`h3`,{children:`Snapshots`})}),(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.75rem`}),children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:Ze?`Saved (${qe.length})`:`Session (${Ee.length})`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>Qe(e=>!e),className:A({fontSize:`10px`,color:`var(--muted-foreground)`,textDecorationLine:`underline`,_hover:{color:`var(--foreground)`}}),children:Ze?`Show session`:`Show saved`})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.25rem`}),children:[Ze&&(0,L.jsxs)(`button`,{type:`button`,onClick:$t,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Pt,size:12}),` Refresh`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:en,disabled:Ye,className:$.primaryButtonSm,children:[Ye?(0,L.jsx)(Rf,{size:12}):(0,L.jsx)(P,{icon:Et,size:12}),`Create`]})]})]}),Ze?qe.length===0?(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No saved snapshots yet. Create one to return to this workspace later.`}):(0,L.jsx)(`div`,{className:$.grid2,children:qe.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`div`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id}),(0,L.jsxs)(`div`,{className:$.text10Muted,children:[e.instanceId,` · `,new Date(e.createdAt).toLocaleString()]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>tn(e.data),className:A({marginLeft:`0.5rem`,display:`inline-flex`,height:`1.75rem`,flexShrink:0,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Hr,size:12}),` Restore`]})]},e.id))}):Ee.length===0?(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Save a snapshot before your next experiment.`}):(0,L.jsx)(`div`,{className:$.grid2,children:Ee.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`div`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id}),(0,L.jsxs)(`div`,{className:$.text10Muted,children:[e.instanceId,` · `,new Date(e.createdAt).toLocaleString()]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>tn(e.data),className:A({marginLeft:`0.5rem`,display:`inline-flex`,height:`1.75rem`,flexShrink:0,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Hr,size:12}),` Restore`]})]},e.id))})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use snapshots.`})}function xn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsx)(`div`,{className:`runtime-view-intro`,children:(0,L.jsx)(`h3`,{children:`History`})}),(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsxs)(`span`,{className:$.semiboldXs,children:[`Branch: `,(0,L.jsx)(`span`,{className:$.mono,children:rt})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.375rem`}),children:[(0,L.jsx)(`input`,{ref:gt,type:`file`,accept:`application/json,.json`,className:$.hidden,onChange:e=>{let t=e.target.files?.[0];t&&un(t)}}),(0,L.jsxs)(`button`,{type:`button`,onClick:ln,disabled:mt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Nr,size:12}),` Export`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>gt.current?.click(),disabled:mt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Wr,size:12}),` Import`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:nn,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Pt,size:12}),` Refresh`]})]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.5rem`}),children:[(0,L.jsx)(`input`,{className:$.inputMono,"aria-label":`New branch name`,placeholder:`experiment-name`,value:st,onChange:e=>ct(e.target.value)}),(0,L.jsxs)(`button`,{type:`button`,onClick:rn,disabled:lt||!st.trim(),className:$.primaryButton,children:[(0,L.jsx)(P,{icon:ie,size:13}),` Branch`]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.5rem`}),children:[(0,L.jsx)(`input`,{className:k($.inputBase,A({flex:1})),"aria-label":`Commit message`,placeholder:`Describe your changes`,value:at,onChange:e=>ot(e.target.value)}),(0,L.jsxs)(`button`,{type:`button`,onClick:on,disabled:lt,className:$.primaryButton,children:[(0,L.jsx)(P,{icon:Mt,size:13}),` Commit`]})]}),$e.length>0&&(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.25rem`}),children:[(0,L.jsx)(`span`,{className:A({fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.025em`,color:`var(--muted-foreground)`}),children:`Branches`}),$e.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.375rem 0.75rem`}),children:[(0,L.jsx)(`span`,{className:$.monoXs,children:e.name}),e.id!==rt&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>an(e.id),disabled:lt,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`},_disabled:{opacity:.5}}),children:[(0,L.jsx)(P,{icon:Hr,size:10}),` Switch`]})]},e.id))]}),tt.length>0?(0,L.jsxs)(`div`,{className:$.grid2,children:[(0,L.jsx)(`span`,{className:A({fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.025em`,color:`var(--muted-foreground)`}),children:`Commits`}),tt.map((e,t)=>(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsx)(`span`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id.slice(0,24)}),(0,L.jsxs)(`span`,{className:$.text10Muted,children:[e.fileCount,` files`]})]}),(0,L.jsx)(`div`,{className:A({marginTop:`0.125rem`,fontSize:`0.75rem`}),children:e.message}),(0,L.jsx)(`div`,{className:$.text10Muted,children:new Date(e.createdAt).toLocaleString()}),(0,L.jsxs)(`div`,{className:A({marginTop:`0.375rem`,display:`flex`,flexWrap:`wrap`,gap:`0.25rem`}),children:[t<tt.length-1&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>sn(e.id,tt[t+1].id),className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Ir,size:10}),` Diff with next`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>cn(e.id),disabled:lt,title:`Write this commit's files back into the sandbox`,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`},_disabled:{opacity:.5}}),children:[(0,L.jsx)(P,{icon:Hr,size:10}),` Restore`]})]})]},e.id))]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No commits yet. Edit a file, then commit to save a version.`}),dt&&(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.1)`,padding:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({marginBottom:`0.5rem`,display:`flex`,alignItems:`center`,justifyContent:`space-between`}),children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:`Diff`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:A({fontSize:`10px`,color:`var(--muted-foreground)`,_hover:{color:`var(--foreground)`}}),children:`Close`})]}),(0,L.jsxs)(`div`,{className:A({display:`grid`,maxHeight:`15rem`,gap:`0.25rem`,overflow:`auto`}),children:[dt.changes.filter(e=>e.status!==`unchanged`).map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`}),children:[(0,L.jsx)(`span`,{className:k(A({width:`4rem`,flexShrink:0,fontSize:`10px`,fontWeight:700}),e.status===`added`?A({color:`#16a34a`}):e.status===`removed`?A({color:`#dc2626`}):A({color:`#d97706`})),children:e.status.toUpperCase()}),(0,L.jsx)(`span`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),children:e.path})]},e.path)),dt.changes.filter(e=>e.status!==`unchanged`).length===0&&(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No changes`})]})]})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use version control.`})}function Sn(){return(0,L.jsxs)(`div`,{className:`runtime-activity`,ref:jt,children:[(0,L.jsxs)(`div`,{className:`runtime-section-heading`,children:[(0,L.jsx)(`h3`,{children:`Activity`}),(0,L.jsxs)(`span`,{className:`runtime-count`,children:[h.length,` `,h.length===1?`event`:`events`]})]}),h.length===0?(0,L.jsxs)(`div`,{className:`runtime-empty`,children:[(0,L.jsx)(P,{icon:Or,size:30}),(0,L.jsx)(`h4`,{children:`No activity yet`}),(0,L.jsx)(`p`,{children:`Run a command or edit a file. Its result will appear here.`})]}):h.map(e=>(0,L.jsxs)(`details`,{className:`runtime-log-entry`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:e.ok?Ar:kr,size:19,className:e.ok?`runtime-success`:`runtime-failure`}),(0,L.jsxs)(`span`,{className:`runtime-log-title`,children:[(0,L.jsx)(`strong`,{children:e.operation}),(0,L.jsxs)(`small`,{children:[new Date(e.timestamp).toLocaleTimeString(),` · `,e.ok?`Completed`:`Failed`,e.durationMs==null?``:` · ${e.durationMs} ms`]})]})]}),(0,L.jsx)(`div`,{className:`runtime-log-output`,children:(0,L.jsx)(oe,{value:e.output,maxHeight:`22rem`})})]},e.id))]})}function Cn(){return(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsxs)(`div`,{className:`runtime-view-intro`,children:[(0,L.jsx)(`h3`,{children:`Diagnostics`}),(0,L.jsx)(`p`,{children:`Check the runtime and inspect its response.`})]}),(0,L.jsx)(`label`,{htmlFor:`runtime-probe-operation`,children:`Operation`}),(0,L.jsxs)(pt,{className:A({marginBottom:`0.25rem`,width:`100%`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.5rem`,fontSize:`0.75rem`}),id:`runtime-probe-operation`,value:N,onValueChange:Tt,children:[(0,L.jsx)(`option`,{value:`config`,children:`Read configuration`}),(0,L.jsx)(`option`,{value:`runtime.ping`,children:`Ping runtime`}),(0,L.jsx)(`option`,{value:`shell.exec`,children:`Run shell command`}),(0,L.jsx)(`option`,{value:`snapshot.create`,children:`Create snapshot`})]}),(0,L.jsx)(`label`,{htmlFor:`runtime-probe-payload`,children:`Payload · JSON`}),(0,L.jsx)(`textarea`,{className:A({minHeight:`7rem`,width:`100%`,resize:`vertical`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.2)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),spellCheck:!1,id:`runtime-probe-payload`,value:Dt,onChange:e=>Ot(e.target.value)}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0.5rem`}),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:dn,disabled:kt,className:$.primaryButton,children:[kt?(0,L.jsx)(Rf,{size:15}):(0,L.jsx)(P,{icon:Br,size:15}),`Run check`]}),h.some(e=>e.tab===`probes`)&&(0,L.jsxs)(`button`,{type:`button`,onClick:fn,className:$.outlineButton,children:[(0,L.jsx)(P,{icon:Nt,size:14}),` `,v===null?`Copy latest`:`Copied`]})]}),h.filter(e=>e.tab===`probes`).length>0&&(0,L.jsxs)(`div`,{className:k(`runtime-probe-output`,A({marginTop:`0.5rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.2)`,padding:`0.75rem`})),children:[(0,L.jsx)(`h3`,{className:A({marginBottom:`0.5rem`,fontSize:`0.75rem`,fontWeight:600}),children:`Latest probe result`}),(0,L.jsx)(oe,{value:h.find(e=>e.tab===`probes`)?.output??null,maxHeight:`18rem`,title:`Probe Result`})]})]})}}function Bf(e){let t=typeof e.course==`string`&&e.course.trim()?e.course.trim():void 0;return t?{mode:`edit`,activeCourseId:t}:e.courseMode===`create`?{mode:`create`}:void 0}function Vf(e){return e.mode===`edit`?[{label:`Plan`,domain:`course`,text:`Inspect this course with me. Identify the most important gap, then ask before changing anything.`},{label:`Plan`,domain:`course`,text:`Help me revise this course's sequence, prerequisites, and pacing. Start by showing me what is there now.`},{label:`Create`,domain:`course`,text:`Help me add the right quiz, artifact, or assignment to this course. Ask what it should assess first.`}]:[{label:`Plan`,domain:`course`,text:`Help me design a course. Start by asking about the learners, outcomes, pace, and material I already have.`},{label:`Plan`,domain:`course`,text:`Turn what we have discussed into a course outline. Show me the outline and let me revise it before creating the course.`},{label:`Create`,domain:`course`,text:`Help me assemble a course from my saved lesson plans, quizzes, visuals, documents, and flashcards.`}]}var Hf=`https://github.com/Diogenesoftoronto/keating/issues/new`,Uf=A({maxWidth:`none`,"& p":{marginBlock:`0.75rem`},"& ul, & ol":{marginBlock:`0.75rem`,paddingInlineStart:`1.5rem`},"& code":{fontFamily:`var(--mono-body)`,fontSize:`0.875em`}}),Wf=A({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,color:`var(--muted-foreground)`,transitionProperty:`color, background-color, border-color, opacity`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}}),Gf=A({display:`inline-flex`,flexShrink:0,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,fontSize:`0.875rem`,fontWeight:500,transitionProperty:`color, background-color, border-color, opacity`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`},_disabled:{pointerEvents:`none`,opacity:.5}}),Kf=A({display:`flex`,alignItems:`center`,gap:`0.5rem`,borderRadius:`0.375rem`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`,textAlign:`left`,fontSize:`0.875rem`,transitionProperty:`color, background-color, border-color`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}}),qf={plan:{label:`Lesson Plan`,icon:(0,L.jsx)(it,{size:14})},map:{label:`Concept Map`,icon:(0,L.jsx)(zt,{size:14})},animation:{label:`Animation`,icon:(0,L.jsx)(ft,{size:14})},deck:{label:`Flashcards`,icon:(0,L.jsx)(ct,{size:14})},verification:{label:`Verification`,icon:(0,L.jsx)(ot,{size:14})},benchmark:{label:`Benchmark`,icon:(0,L.jsx)(Ye,{size:14})},evolution:{label:`Evolution`,icon:(0,L.jsx)(Ye,{size:14})},"prompt-evolution":{label:`Prompt Evo`,icon:(0,L.jsx)(Ye,{size:14})},improvement:{label:`Improvement`,icon:(0,L.jsx)(h,{size:14})}},Jf=/```mermaid[^\n]*\n([\s\S]*?)```/gi;function Yf(e){let t=[],n=0;for(let r of e.matchAll(Jf)){let i=r.index??0,a=e.slice(n,i);a.trim()&&t.push({type:`markdown`,content:a}),t.push({type:`mermaid`,content:r[1].trim()}),n=i+r[0].length}let r=e.slice(n);return r.trim()&&t.push({type:`markdown`,content:r}),t}function Xf({source:e}){return(0,L.jsx)(`div`,{className:A({marginBlock:`0.75rem`,overflow:`auto`,borderRadius:`0.5rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 30%, transparent)`,padding:`1rem`}),children:(0,L.jsx)(Qe,{content:e})})}function Zf({content:e}){let t=Yf(e);return t.length===0?(0,L.jsx)(`div`,{className:Uf,children:(0,L.jsx)(tt,{content:e})}):(0,L.jsx)(`div`,{className:A({display:`grid`,gap:`0.75rem`}),children:t.map((e,t)=>e.type===`mermaid`?(0,L.jsx)(Xf,{source:e.content},t):(0,L.jsx)(`div`,{className:Uf,children:(0,L.jsx)(tt,{content:e.content})},t))})}function Qf({artifact:e,onDismiss:t,onOpenInBrowser:n}){let[r,i]=(0,I.useState)(!0),a=qf[e.type],o=(()=>{switch(e.type){case`plan`:return e.data.topic;case`map`:return e.data.topic;case`animation`:return e.data.topic;case`deck`:return e.data.title;case`verification`:return e.data.topic;case`benchmark`:return e.data.topic??`general`;case`evolution`:return e.data.topic??`general`;case`prompt-evolution`:return e.data.promptName;case`improvement`:return e.data.proposalId}})(),s=(()=>{switch(e.type){case`benchmark`:return`Score ${e.data.score.toFixed(2)}`;case`evolution`:return`Best score ${e.data.bestScore.toFixed(2)}`;case`prompt-evolution`:return`Best score ${e.data.bestScore.toFixed(2)}`;case`improvement`:return`${e.data.accepted?`Accepted`:`Rejected`} · Δ${(e.data.scoreDelta??0).toFixed(2)}`;case`deck`:return`${e.data.cards.length} cards`;case`verification`:return`${e.data.checklist.match(/- \[ \]/g)?.length??0} checks`;default:return null}})();return(0,L.jsxs)(`article`,{className:A({borderRadius:`0.5rem`,border:`1px solid var(--border)`,backgroundColor:`var(--card)`,color:`var(--card-foreground)`,boxShadow:`var(--shadow-card)`}),children:[(0,L.jsxs)(`header`,{className:A({display:`flex`,alignItems:`flex-start`,gap:`0.75rem`,borderBottom:`1px solid var(--border)`,paddingInline:`1rem`,paddingBlock:`0.75rem`}),children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:k(Wf,A({marginTop:`0.125rem`,width:`1.5rem`,height:`1.5rem`,flexShrink:0})),"aria-label":r?`Collapse artifact`:`Expand artifact`,"aria-expanded":r,children:r?(0,L.jsx)(De,{size:14}):(0,L.jsx)(ot,{size:14})}),(0,L.jsxs)(`div`,{className:A({minWidth:0,flex:1}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,fontWeight:500,color:`var(--muted-foreground)`}),children:[(0,L.jsxs)(`span`,{className:A({display:`inline-flex`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 40%, transparent)`,paddingInline:`0.5rem`,paddingBlock:`0.125rem`}),children:[a.icon,a.label]}),s&&(0,L.jsxs)(`span`,{className:A({color:`var(--muted-foreground)`}),children:[`· `,s]})]}),(0,L.jsx)(`h3`,{className:A({marginTop:`0.125rem`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`0.875rem`,fontWeight:600}),children:o})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.25rem`}),children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,className:k(Wf,A({height:`1.75rem`,border:`1px solid var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`})),title:`Open in artifact browser`,children:`Open`}),(0,L.jsx)(`button`,{type:`button`,onClick:t,className:k(Wf,A({width:`1.75rem`,height:`1.75rem`})),"aria-label":`Dismiss artifact`,title:`Dismiss`,children:(0,L.jsx)(gt,{size:14})})]})]}),r&&(0,L.jsx)(`div`,{className:A({paddingInline:`1rem`,paddingBlock:`0.75rem`,fontSize:`0.875rem`}),children:$f(e)})]})}function $f(e){switch(e.type){case`plan`:return(0,L.jsx)(Zf,{content:e.data.content});case`map`:return(0,L.jsx)(Xf,{source:e.data.mmdContent});case`animation`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 20%, transparent)`,padding:`0.75rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[e.data.scene?`Scene ready`:`Storyboard only`,` ·`,` `,e.data.manifest?`manifest attached`:`no manifest`]}),(0,L.jsx)(Zf,{content:e.data.storyboard})]});case`deck`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.5rem`}),children:[(0,L.jsxs)(`p`,{className:A({fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[e.data.cards.length,` cards · open in the browser for spaced repetition review.`]}),(0,L.jsxs)(`ul`,{className:A({display:`grid`,gap:`0.25rem`,fontSize:`0.875rem`}),children:[e.data.cards.slice(0,5).map(e=>(0,L.jsxs)(`li`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:[(0,L.jsx)(`div`,{className:A({fontSize:`0.75rem`,textTransform:`uppercase`,color:`var(--muted-foreground)`}),children:e.front}),(0,L.jsx)(`div`,{className:A({fontSize:`0.875rem`}),children:e.back})]},e.id)),e.data.cards.length>5&&(0,L.jsxs)(`li`,{className:A({fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[`+`,e.data.cards.length-5,` more…`]})]})]});case`verification`:return(0,L.jsx)(Zf,{content:e.data.checklist});case`benchmark`:return(0,L.jsx)(Zf,{content:e.data.report});case`evolution`:return(0,L.jsx)(Zf,{content:e.data.report});case`prompt-evolution`:return(0,L.jsx)(Zf,{content:e.data.report});case`improvement`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.5rem`}),children:[(0,L.jsx)(`p`,{className:A({fontSize:`0.875rem`}),children:e.data.hypothesis}),(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,padding:`0.75rem`,fontSize:`0.75rem`}),children:[(0,L.jsx)(`div`,{className:A({fontWeight:500}),children:`Targets`}),(0,L.jsx)(`div`,{className:A({marginTop:`0.25rem`,color:`var(--muted-foreground)`}),children:e.data.targets||`(unspecified)`})]})]})}}function ep({artifacts:e,onDismiss:t,onOpenInBrowser:n}){return e.length===0?null:(0,L.jsx)(`section`,{"aria-label":`Inline artifacts`,className:A({borderTop:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 20%, transparent)`,paddingInline:`0.75rem`,paddingBlock:`0.75rem`,sm:{paddingInline:`1rem`}}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexDirection:`column`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsxs)(`span`,{className:A({fontWeight:500}),children:[e.length,` inline artifact`,e.length===1?``:`s`]}),(0,L.jsx)(`span`,{children:`Rendered directly in the chat page`})]}),e.map(e=>(0,L.jsx)(Qf,{artifact:e,onDismiss:()=>t(e.id),onOpenInBrowser:()=>n(e.id)},`${e.type}:${e.id}`))]})})}async function tp(e,t){return e.length?t?e.find(e=>e.id===t)??null:e.slice().sort((e,t)=>t.createdAt-e.createdAt)[0]:null}async function np(e,t){switch(e){case`plan`:{let e=await tp(await j.getLessonPlans(),t);return e?{id:e.id,type:`plan`,createdAt:e.createdAt,data:e}:null}case`map`:{let e=await tp(await j.getLessonMaps(),t);return e?{id:e.id,type:`map`,createdAt:e.createdAt,data:e}:null}case`animation`:{let e=await tp(await j.getAnimations(),t);return e?{id:e.id,type:`animation`,createdAt:e.createdAt,data:e}:null}case`deck`:{let e=await tp(await j.getDecks(),t);return e?{id:e.id,type:`deck`,createdAt:e.updatedAt,data:e}:null}case`verification`:{let e=await tp(await j.getVerifications(),t);return e?{id:e.id,type:`verification`,createdAt:e.createdAt,data:e}:null}case`benchmark`:{let e=await tp(await j.getBenchmarks(),t);return e?{id:e.id,type:`benchmark`,createdAt:e.createdAt,data:e}:null}case`evolution`:{let e=await tp(await j.getEvolutions(),t);return e?{id:e.id,type:`evolution`,createdAt:e.createdAt,data:e}:null}case`prompt-evolution`:{let e=await tp(await j.getPromptEvolutions(),t);return e?{id:e.id,type:`prompt-evolution`,createdAt:e.createdAt,data:e}:null}case`improvement`:{let e=await tp(await j.getImprovementAttempts(),t);return e?{id:e.id,type:`improvement`,createdAt:e.createdAt,data:e}:null}}}async function rp(e){let t=typeof e.id==`string`?e.id:void 0,n=typeof e.type==`string`?e.type:void 0,r=typeof e.toolName==`string`?e.toolName:void 0,i=e.result&&typeof e.result==`object`?e.result:void 0,a=(i&&typeof i.id==`string`?i.id:void 0)??(i&&typeof i.artifactId==`string`?i.artifactId:void 0),o={plan:`plan`,map:`map`,animate:`animation`,animation:`animation`,verify:`verification`,bench:`benchmark`,benchmark:`benchmark`,evolve:`evolution`,evolution:`evolution`,prompt_evolve:`prompt-evolution`,"prompt-evolve":`prompt-evolution`,quiz:`plan`,deck:`deck`,auto_improve:`improvement`,improvement:`improvement`},s=[];n&&o[n]&&s.push({type:o[n],id:t}),r&&o[r]&&s.push({type:o[r],id:a});for(let e of s){let t=await np(e.type,e.id);if(t)return t}return null}function ip(){let e=p();At({title:`Keating Chat — Socratic AI Tutor Session`,description:`Start a Socratic tutoring session with Keating. Diagnose what you know, reconstruct understanding from memory, and test transfer to new contexts.`,canonical:`https://keating.help/chat`});let t=be(),n=he(),r=D({strict:!1}),[i,a]=(0,I.useState)(),o=r.ask?.trim()||i,[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>ae(()=>u(!0)),[]),(0,I.useEffect)(()=>{if(xn()||r.ask||r.course)return;let e=!1;return _e().then(()=>pe.getAllMetadata()).then(t=>{!e&&!xn()&&t.length===0&&c(!0)}).catch(()=>{}),()=>{e=!0}},[r.ask,r.course]);let d=(0,I.useMemo)(()=>Bf(r),[r.course,r.courseMode]),f=(0,I.useMemo)(()=>d?Vf(d):void 0,[d]),{isPending:h,openSettings:g,modelLabel:_,openModelSelector:v,chooseKeatingModel:ee,newSession:te,shareSession:y,chatPanelRef:ne,dialogs:re,sessionSidebar:ie,speechEnabled:x,persistentStorageStatus:oe,persistentBannerDismissed:se,retryPersistentStorage:C,dismissPersistentBanner:w,toggleSpeech:le,forkingSessionId:ue,forkInfo:de,openOriginalSession:fe,mobileSidebarOpen:O,toggleMobileSidebar:ge,activeSessionId:j,teachingAdjustment:ve,responseComparison:xe,chooseResponse:Se}=b({courseContext:d}),[M,we]=(0,I.useState)(!1),Te=Xe(`(min-width: 1024px)`),[Ee,Oe]=(0,I.useState)(()=>me()),[ke,Ae]=(0,I.useState)(`idle`),[je,Me]=(0,I.useState)(null),[Ne,Pe]=(0,I.useState)(null),[Fe,Ie]=(0,I.useState)(!1),[Le,Re]=(0,I.useState)(!1),ze=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=j,n=!1;t.capture(`chat_composer_viewed`,{session_id:e,activation_wait_ms:45e3});let r=t=>{let r=t.detail;(!r?.sessionId||r.sessionId===e)&&(n=!0)};window.addEventListener(`keating:message-sent`,r);let i=window.setTimeout(()=>{n||document.visibilityState!==`visible`||t.capture(`chat_activation_stalled`,{session_id:e,wait_ms:45e3,survey_trigger:`activation_blocker`})},45e3);return()=>{window.removeEventListener(`keating:message-sent`,r),window.clearTimeout(i)}},[j,t]),(0,I.useEffect)(()=>{if(!Fe)return;let e=e=>{e.key===`Escape`&&Ie(!1)},t=e=>{ze.current&&!ze.current.contains(e.target)&&Ie(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[Fe]),(0,I.useEffect)(()=>Ce(Oe),[]),(0,I.useEffect)(()=>{if(!(typeof document>`u`))return document.body.classList.add(`chat-shell-active`),()=>document.body.classList.remove(`chat-shell-active`)},[]);let[Be,Ve]=(0,I.useState)(void 0),[He,Ue]=(0,I.useState)([]);(0,I.useEffect)(()=>{we(!1),Ve(void 0),Ue([])},[j]);let We=n=>{e&&we(e=>{let r=!e;return r||Ve(void 0),t.capture(r?`artifact_browser_opened`:`artifact_browser_closed`,{source:n,canvas_enabled:!0}),r})};(0,I.useEffect)(()=>{if(!e){we(!1),Ve(void 0),Ue([]);return}let t=()=>{Ee.autoOpenArtifacts&&we(!0)},n=e=>{let t=e.detail;t?.id&&(Ve(t.id),we(!0))},r=async e=>{let t=await rp(e.detail??{});t&&(Ue(e=>e.some(e=>e.id===t.id&&e.type===t.type)?e:Ee.limitInlineArtifactPreviews?[t]:[...e,t]),Ee.autoOpenArtifacts&&we(!0))};return window.addEventListener(`keating:artifact-created`,t),window.addEventListener(`keating:artifact-created`,r),window.addEventListener(`keating:open-artifact`,n),()=>{window.removeEventListener(`keating:artifact-created`,t),window.removeEventListener(`keating:artifact-created`,r),window.removeEventListener(`keating:open-artifact`,n)}},[e,Ee.autoOpenArtifacts,Ee.limitInlineArtifactPreviews]);let Ge=async()=>{Ae(`sharing`),Pe(null),Me(null);try{let e=await y();Me(e.url),Pe(`${e.mode===`portable-short`?`Portable share link`:e.mode===`compressed-hash`?`Snapshot share link`:`Local share link`} ready${e.fallback?` after portable storage was unavailable`:``}. It was copied if your browser allowed clipboard access.`),Ae(`copied`),t.capture(`session_shared`,{share_mode:e.mode,fallback:e.fallback,session_id:j}),window.setTimeout(()=>Ae(`idle`),1600)}catch(e){console.warn(`Failed to share session:`,e),Pe(e instanceof Error?e.message:`Could not create a share link yet.`),Ae(`error`),window.setTimeout(()=>Ae(`idle`),2200)}},Ke=async()=>{let e=me();if(ye(e.shareLinkMode)&&!e.trajectoryShareWarningAcknowledged){Me(null),Pe(`This link publishes the visible conversation, safe session artifacts, and any finalized review feedback. It excludes drafts, hidden tool traffic, and unsupported or oversized artifacts. Anyone with the link can read it. Share again to confirm.`),Ae(`confirm`);return}await Ge()},qe=async()=>{let e=me();e.trajectoryShareWarningAcknowledged||T({...e,shareWarningAcknowledged:!0,trajectoryShareWarningAcknowledged:!0}),await Ge()},Je=k(`chat-action-button`,Gf),Ye=oe===`declined`&&!se;return(0,L.jsxs)(`div`,{className:k(`chat-page-shell`,ue?`session-forking`:``,A({display:`flex`,width:`100%`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--background)`,color:`var(--foreground)`})),children:[(0,L.jsxs)(`nav`,{className:k(`chat-header`,A({position:`relative`,display:`flex`,height:`3.5rem`,flexShrink:0,alignItems:`center`,gap:`0.5rem`,borderBottom:`1px solid var(--border)`,paddingInline:`0.5rem`,paddingBlock:`0.5rem`,sm:{paddingInline:`1rem`}})),"aria-label":`Chat navigation`,children:[(0,L.jsx)(`button`,{type:`button`,className:k(Je,A({display:`inline-flex`,lg:{display:`none`}})),title:O?`Close sessions panel`:`Open sessions panel`,"aria-label":O?`Close sessions panel`:`Open sessions panel`,"aria-pressed":O,onClick:ge,children:O?(0,L.jsx)(Lt,{size:16}):(0,L.jsx)(F,{size:16})}),(0,L.jsx)(E,{to:`/`,className:k(`chat-brand`,A({display:`inline-flex`,minWidth:0,flexShrink:0,alignItems:`center`,gap:`0.5rem`,borderRadius:`0.375rem`,paddingInline:`0.5rem`,paddingBlock:`0.25rem`})),"aria-label":`Go to Keating home`,children:(0,L.jsx)(`img`,{src:`/brand/logo-lockup-compact.avif`,alt:`Keating`,className:A({height:`1.5rem`,width:`auto`,objectFit:`contain`})})}),(0,L.jsxs)(`button`,{type:`button`,onClick:v,title:`Model: ${_}`,"aria-label":`Change model. Current model: ${_}`,className:k(`chat-model-button`,A({display:`inline-flex`,minWidth:0,maxWidth:`11rem`,flexShrink:1,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.5rem`,paddingInline:`0.5rem`,paddingBlock:`0.25rem`,fontSize:`0.8125rem`,fontWeight:500,color:`var(--muted-foreground)`,cursor:`pointer`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}})),children:[(0,L.jsx)(`span`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),children:_}),(0,L.jsx)(De,{size:13,className:A({flexShrink:0})})]}),(0,L.jsx)(`span`,{className:`chat-mode-badge chat-only-desktop`,children:`MODE: SOCRATIC`}),(0,L.jsxs)(`div`,{className:k(`chat-actions`,A({marginLeft:`auto`,display:`flex`,minWidth:0,alignItems:`center`,justifyContent:`flex-end`,gap:`0.25rem`,overflow:`hidden`,sm:{flex:1}})),children:[(0,L.jsx)(`button`,{className:Je,"aria-label":`Settings`,title:`Settings`,onClick:g,children:(0,L.jsx)(Ht,{size:16})}),e&&(0,L.jsx)(`button`,{className:Je,"aria-label":M?`Close materials`:`Open materials`,"aria-pressed":M,onClick:()=>We(`toolbar`),children:(0,L.jsx)(ct,{size:16})}),(0,L.jsx)(`button`,{className:Je,title:`Menu`,"aria-label":`More menu`,"aria-expanded":Fe,"aria-haspopup":`true`,onClick:()=>Ie(e=>!e),children:Fe?(0,L.jsx)(gt,{size:16}):(0,L.jsx)(Bt,{size:16})})]}),Fe&&(0,L.jsx)(`div`,{ref:ze,role:`navigation`,"aria-label":`Chat actions`,className:k(`font-terminal`,A({position:`absolute`,right:`0.5rem`,top:`100%`,zIndex:50,marginTop:`0.25rem`,width:`16rem`,maxHeight:`min(70dvh, 36rem)`,overflowY:`auto`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,boxShadow:`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,fontSize:`0.875rem`})),children:(0,L.jsxs)(`div`,{className:A({display:`flex`,flexDirection:`column`,padding:`0.25rem`}),children:[(0,L.jsx)(`button`,{className:k(Kf,``),disabled:h,onClick:()=>{Ie(!1),te()},children:`New session`}),(0,L.jsx)(`button`,{className:k(Kf,``,ke===`copied`?A({color:`var(--primary)`}):``,ke===`error`?A({color:`var(--destructive)`}):``),onClick:()=>{Ie(!1),ke===`confirm`?qe():Ke()},disabled:h||ke===`sharing`,children:ke===`copied`?`Link copied`:ke===`confirm`?`Confirm public share`:`Share session`}),(0,L.jsx)(`button`,{className:k(Kf,``,x?A({color:`var(--primary)`}):``),onClick:()=>{Ie(!1),t.capture(`speech_toggled`,{enabled:!x}),le()},children:x?`Disable speech`:`Enable speech`}),(0,L.jsx)(dt,{className:``,variant:`menu`,onToggled:()=>Ie(!1)}),(0,L.jsx)(E,{to:`/courses`,className:Kf,onClick:()=>Ie(!1),children:`Courses`}),!1,(0,L.jsx)(`button`,{className:k(Kf,``),onClick:()=>{Ie(!1),n({to:`/usage`})},children:`Learning usage`}),(0,L.jsx)(`button`,{className:Kf,onClick:()=>{Ie(!1),n(j?{to:`/review/sessions/$sessionId`,params:{sessionId:j}}:{to:`/review`})},children:`Review session`}),(0,L.jsx)(`div`,{className:k(``,A({marginBlock:`0.25rem`,borderTop:`1px solid var(--border)`}))}),(0,L.jsx)(E,{to:`/`,className:Kf,onClick:()=>Ie(!1),children:`Home`}),(0,L.jsx)(`a`,{href:`https://docs.keating.help/`,target:`_blank`,rel:`noopener noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`Documentation`}),(0,L.jsx)(`a`,{href:`https://blog.keating.help/`,target:`_blank`,rel:`noopener noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`Blog`}),(0,L.jsx)(E,{to:`/paper`,className:Kf,onClick:()=>Ie(!1),children:`Paper`}),(0,L.jsx)(`a`,{href:`https://github.com/Diogenesoftoronto/keating`,target:`_blank`,rel:`noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`GitHub`}),(0,L.jsx)(`a`,{href:Hf,target:`_blank`,rel:`noreferrer`,className:k(Kf,``),onClick:()=>Ie(!1),children:`Report issue`})]})})]}),d&&(0,L.jsx)(`section`,{"aria-label":`Course collaboration context`,className:A({flexShrink:0,borderBottom:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--primary) 8%, var(--background))`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,minWidth:0,alignItems:`center`,gap:`0.55rem`}),children:[(0,L.jsx)(it,{size:16,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:A({minWidth:0}),children:[(0,L.jsx)(`p`,{className:A({fontSize:`0.8rem`,fontWeight:650}),children:d.mode===`create`?`Design a course with Keating`:`Keating is working in this course`}),(0,L.jsx)(`p`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`0.7rem`,color:`var(--muted-foreground)`}),children:`Agree on the shape first, then Keating can create and revise the durable workspace.`})]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`}),children:[d.activeCourseId&&(0,L.jsx)(E,{to:`/courses/$courseId`,params:{courseId:d.activeCourseId},className:A({fontWeight:650,textDecoration:`underline`,textUnderlineOffset:`3px`}),children:`Open course`}),(0,L.jsx)(E,{to:`/chat`,className:A({color:`var(--muted-foreground)`}),children:`Leave course mode`})]})]})}),de&&(0,L.jsx)(Dr,{parentTitle:de.parentTitle,onOpenOriginal:fe}),Ye&&(0,L.jsx)(`div`,{className:A({flexShrink:0,borderBottom:`1px solid var(--border)`,backgroundColor:`rgb(245 158 11 / 0.1)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`48rem`,alignItems:`center`,justifyContent:`space-between`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,fontWeight:500,color:`rgb(146 64 14)`,_dark:{color:`rgb(253 230 138)`}}),children:[(0,L.jsx)(`span`,{className:A({display:`none`,sm:{display:`inline`}}),children:`Browser storage persistence is not enabled. Sessions still save locally, but the browser may clear them under storage pressure.`}),(0,L.jsx)(`span`,{className:A({sm:{display:`none`}}),children:`Storage persistence is not enabled.`})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.5rem`}),children:[(0,L.jsx)(`button`,{type:`button`,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,borderRadius:`0.25rem`,backgroundColor:`var(--primary)`,paddingInline:`0.5rem`,fontSize:`10px`,fontWeight:500,color:`var(--primary-foreground)`,_hover:{backgroundColor:`color-mix(in srgb, var(--primary) 90%, transparent)`}}),onClick:C,children:`Try again`}),(0,L.jsx)(`button`,{type:`button`,className:k(Wf,A({width:`1.5rem`,height:`1.5rem`})),onClick:w,"aria-label":`Dismiss persistence warning`,children:(0,L.jsx)(gt,{size:12})})]})]})}),(0,L.jsx)(m,{sessionId:j,teachingAdjustment:ve}),s&&(0,L.jsx)(`div`,{className:A({flex:1,minHeight:0,overflowY:`auto`,paddingInline:`1rem`}),children:(0,L.jsx)(Mn,{onUseKeating:ee,onConnectAccount:async()=>{await Ze({allowSignIn:!0})},onChooseModel:v,onSkip:()=>c(!1),onComplete:e=>{a(e),c(!1)},...S()?{}:{onStartTour:()=>u(!0)}})}),(0,L.jsxs)(`div`,{className:A({display:`flex`,minHeight:0,flex:1,overflow:`hidden`}),style:s?{display:`none`}:void 0,children:[ie,(0,L.jsx)(ce,{ref:ne,className:k(`chat-page-panel`,A({minWidth:0,flex:1})),speechEnabled:x,initialPrompts:f,...o?{pendingPrompt:o}:{},emptyStateTitle:d?.mode===`create`?`What course should we build together?`:d?`What should we change in this course?`:void 0,emptyStateDescription:d?`Choose a starting point or describe the learners and the change you have in mind. Keating will inspect, propose, and wait for your direction before writing.`:void 0,responseComparison:xe?(0,L.jsx)(vr,{comparison:xe,onChoose:Se}):null}),e&&Te&&M&&(0,L.jsx)(`div`,{className:k(`artifact-side-panel`,A({height:`100%`,flexShrink:0,borderLeft:`1px solid var(--border)`})),children:(0,L.jsx)(gr,{open:M,artifactId:Be,onClose:()=>{we(!1),Ve(void 0)}})})]}),l&&!s&&(0,L.jsx)(In,{onFinish:()=>u(!1),onSkip:()=>u(!1)}),e&&He.length>0&&(0,L.jsx)(ep,{artifacts:He,onDismiss:e=>Ue(t=>t.filter(t=>t.id!==e)),onOpenInBrowser:e=>{Ve(e),we(!0)}}),(je||Ne)&&(0,L.jsx)(`div`,{className:A({borderTop:`1px solid var(--border)`,backgroundColor:`var(--background)`,paddingInline:`1rem`,paddingBlock:`0.75rem`,fontSize:`0.875rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexDirection:`column`,gap:`0.5rem`,sm:{flexDirection:`row`,alignItems:`center`}}),children:[(0,L.jsx)(`span`,{className:A(ke===`error`?{color:`var(--destructive)`}:{color:`var(--muted-foreground)`}),children:Ne}),je&&(0,L.jsx)(`input`,{className:A({minWidth:0,flex:1,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--muted)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`,fontFamily:`var(--mono-body)`,fontSize:`0.75rem`,color:`var(--foreground)`}),readOnly:!0,value:je,onFocus:e=>e.currentTarget.select()}),ke===`confirm`&&(0,L.jsx)(`button`,{className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--primary)`,paddingInline:`0.75rem`,fontSize:`0.75rem`,color:`var(--primary-foreground)`,_hover:{backgroundColor:`color-mix(in srgb, var(--primary) 90%, transparent)`}}),onClick:qe,children:`Share publicly`}),(0,L.jsx)(`button`,{className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,paddingInline:`0.75rem`,fontSize:`0.75rem`,_hover:{backgroundColor:`var(--accent)`}}),onClick:()=>{Ae(`idle`),Me(null),Pe(null)},children:ke===`confirm`?`Cancel`:`Dismiss`})]})}),(0,L.jsx)(lr,{open:e&&M&&!Te,artifactId:Be,onClose:()=>{we(!1),Ve(void 0)}}),(0,L.jsx)(zf,{open:Le,onClose:()=>Re(!1)}),re]})}function ap(){return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:k(`chat-page-shell`,A({display:`flex`,width:`100%`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--background)`,color:`var(--foreground)`})),children:(0,L.jsx)(`div`,{className:A({display:`flex`,flex:1,alignItems:`center`,justifyContent:`center`,fontSize:`0.875rem`,color:`var(--muted-foreground)`}),children:`Initializing…`})}),children:(0,L.jsx)(ip,{})})}export{ap as Chat};
55
+ // `+(e instanceof Error?e.message:String(e))),me(!1)}},[]),qt=(0,I.useCallback)(async()=>{if(T){ye(!0);try{let e=await Ne(T);e&&e.baseline!==void 0?j(Nf(e.baseline,e.current)):j([])}catch{j([])}finally{ye(!1)}}},[T]),Jt=(0,I.useCallback)(async()=>{if(T)try{await We(T,D),me(!1),F(`vfs`,`write ${T}`,!0,{bytes:D.length}),Bt()}catch(e){F(`vfs`,`write ${T}`,!1,{error:e instanceof Error?e.message:String(e)})}},[T,D,F,Bt]),Yt=(0,I.useCallback)(async(e,t)=>{try{await He(e,t),T===e&&(E(null),O(``)),F(`vfs`,`delete ${e}`,!0,{}),Bt()}catch(t){F(`vfs`,`delete ${e}`,!1,{error:t instanceof Error?t.message:String(t)})}},[T,F,Bt]),Xt=(0,I.useCallback)(async()=>{if(be.trim())try{await Ve(ce,be.trim(),Se===`dir`),F(`vfs`,`create ${Se} ${be}`,!0,{}),xe(``),Bt()}catch(e){F(`vfs`,`create ${Se} ${be}`,!1,{error:e instanceof Error?e.message:String(e)})}},[be,ce,Se,F,Bt]),Zt=(0,I.useCallback)(()=>{let e=Pe();e&&e.clear()},[]),Qt=(0,I.useCallback)(()=>{let e=Pe();e&&requestAnimationFrame(()=>e.fit())},[]),$t=(0,I.useCallback)(async()=>{try{Je(await Ue())}catch{Je([])}},[]),en=(0,I.useCallback)(async()=>{Xe(!0);let e=performance.now();try{F(`snapshots`,`snapshot.create`,!0,{id:(await je(`manual-${Date.now()}`)).id},Math.round(performance.now()-e)),Vt(),await $t()}catch(t){F(`snapshots`,`snapshot.create`,!1,{error:t instanceof Error?t.message:String(t)},Math.round(performance.now()-e))}finally{Xe(!1)}},[F,Vt,$t]),tn=(0,I.useCallback)(async e=>{let t=performance.now();try{await Ge(e),F(`snapshots`,`snapshot.restore`,!0,{},Math.round(performance.now()-t)),Bt()}catch(e){F(`snapshots`,`snapshot.restore`,!1,{error:e instanceof Error?e.message:String(e)},Math.round(performance.now()-t))}},[F,Bt]),nn=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([vt(),bt()]),n=await(await xt()).activeBranchId();et(e),nt(t),it(n)}catch{et([]),nt([])}},[]),rn=(0,I.useCallback)(async()=>{if(st.trim()){ut(!0);try{await St(st.trim()),ct(``),await nn(),F(`vc`,`branch.create`,!0,{name:st.trim()})}catch(e){F(`vc`,`branch.create`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}}},[st,nn,F]),an=(0,I.useCallback)(async e=>{ut(!0);try{await yt(e),await nn(),F(`vc`,`branch.switch`,!0,{branchId:e})}catch(e){F(`vc`,`branch.switch`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}},[nn,F]),on=(0,I.useCallback)(async()=>{let e=at.trim()||`checkpoint-${Date.now()}`;ut(!0);try{let t=await Fe(),n=await _t(t,e);ot(``),await nn(),F(`vc`,`commit`,!0,{commitId:n,files:t.length})}catch(e){F(`vc`,`commit`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ut(!1)}},[at,nn,F]),sn=(0,I.useCallback)(async(e,t)=>{ut(!0);try{ft({fromCommit:e,toCommit:t,changes:await Ct(e,t)})}catch{ft(null)}finally{ut(!1)}},[]),cn=(0,I.useCallback)(async e=>{let t=performance.now();ut(!0);try{let n=await wt(e);for(let e of n)await We(e.path,e.content);await Bt(),F(`vc`,`commit.restore`,!0,{commitId:e,files:n.length},Math.round(performance.now()-t))}catch(e){F(`vc`,`commit.restore`,!1,{error:e instanceof Error?e.message:String(e)},Math.round(performance.now()-t))}finally{ut(!1)}},[F,Bt]),ln=(0,I.useCallback)(async()=>{ht(!0);try{let e=await It(),t=`${JSON.stringify(e,null,2)}\n`,n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`keating-sandbox-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),F(`vc`,`portable.export`,!0,{files:e.nodepod.files.length,snapshots:e.nodepod.snapshots.length,gitObjects:Object.keys(e.vc.objects).length})}catch(e){F(`vc`,`portable.export`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ht(!1)}},[F]),un=(0,I.useCallback)(async e=>{ht(!0);try{let t=await e.text(),n=await Ft(JSON.parse(t));await Promise.all([nn(),$t()]),await Bt(),F(`vc`,`portable.import`,!0,n)}catch(e){F(`vc`,`portable.import`,!1,{error:e instanceof Error?e.message:String(e)})}finally{ht(!1),gt.current&&(gt.current.value=``)}},[F,$t,nn,Bt]),dn=(0,I.useCallback)(async()=>{At(!0);let e=performance.now(),t={};try{let n=await ne(!0);if(i(n),N===`config`){t={ok:!0,output:n,durationMs:Math.round(performance.now()-e)},F(`probes`,`agent_runtime.config`,!0,t.output);return}if(n.mode===`browser-only`||!n.executionEndpoint){t={reason:`No execution endpoint is configured.`,mode:n.mode,fallback:n.fallback},F(`probes`,`probe.${N}`,!1,t,Math.round(performance.now()-e));return}let r;try{r=Dt.trim()?JSON.parse(Dt):{}}catch(e){throw Error(`Probe payload is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}if(n.executionEndpoint===`nodepod://local`){let t=await ze(N,r),n=!(t&&typeof t==`object`&&`ok`in t&&t.ok===!1);F(`probes`,`probe.${N}`,n,t,Math.round(performance.now()-e));return}let a=await fetch(`${n.executionEndpoint}/execute`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({operation:N,payload:r})}),o=a.headers.get(`content-type`)?.includes(`application/json`)?await a.json().catch(()=>null):await a.text();F(`probes`,`probe.${N}`,a.ok,o,Math.round(performance.now()-e))}catch(t){F(`probes`,`probe.${N}`,!1,{error:t instanceof Error?t.message:String(t)},Math.round(performance.now()-e))}finally{At(!1)}},[N,Dt,F]),fn=(0,I.useCallback)(async()=>{let e=h.find(e=>e.tab===`probes`);if(!e)return;let t=Pf(e.output);await navigator.clipboard.writeText(t),ee(h.indexOf(e)),window.setTimeout(()=>ee(null),1200)},[h]);if(!e)return null;let pn=se(r,s),mn=l?`Starting…`:s?`Running`:r?.executionEndpoint?`Configured`:`Stopped`,hn=[`snapshots`,`vc`,`probes`].includes(d)?d:``;return(0,L.jsx)(`dialog`,{ref:n,className:`sandbox-runtime`,"aria-labelledby":`runtime-title`,onCancel:e=>{e.preventDefault(),ae()},onClick:e=>{e.target===e.currentTarget&&ae()},children:(0,L.jsxs)(`div`,{className:$.panel,children:[(0,L.jsxs)(`header`,{className:$.header,children:[(0,L.jsxs)(`div`,{className:`runtime-heading`,children:[(0,L.jsx)(`span`,{className:`runtime-mark`,children:(0,L.jsx)(P,{icon:Mr,size:24,active:s})}),(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`h2`,{id:`runtime-title`,children:_(r)?`Desktop workspace`:`Runtime`}),(0,L.jsx)(`p`,{children:a?`Workspace unavailable`:_(r)?`Native files and processes`:r?Lf(r.mode):`Loading environment…`})]})]}),(0,L.jsx)(`button`,{type:`button`,className:`runtime-icon-button`,"aria-label":`Close runtime`,onClick:ae,autoFocus:!0,children:(0,L.jsx)(P,{icon:Gr,size:20})})]}),re&&(0,L.jsxs)(`div`,{className:`desktop-workspace-close`,role:`alert`,children:[(0,L.jsx)(`p`,{children:`Your file has unsaved edits.`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>b(!1),children:`Keep editing`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{b(!1),y(!1),t()},children:`Discard and close`})]})]}),a?(0,L.jsxs)(`div`,{className:`runtime-body`,children:[(0,L.jsx)(`div`,{className:`runtime-error`,role:`alert`,children:a}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void Rt(),children:`Retry connection`})]}):_(r)&&r?.projectRoot?(0,L.jsx)(Jr,{workspacePath:r.projectRoot,onDirtyChange:y}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`runtime-control-bar`,children:[(0,L.jsxs)(`span`,{className:`runtime-state`,"data-running":s,role:`status`,children:[(0,L.jsx)(`span`,{className:`runtime-state-dot`}),mn]}),(0,L.jsxs)(`div`,{className:`runtime-controls`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:Rt,className:`runtime-icon-button`,"aria-label":`Refresh runtime`,title:`Refresh runtime`,children:(0,L.jsx)(P,{icon:Pt,size:18})}),pn===`stop`?(0,L.jsxs)(`button`,{type:`button`,onClick:Ut,className:`runtime-stop`,children:[(0,L.jsx)(P,{icon:Vr,size:17}),`Stop`]}):pn===`boot`?(0,L.jsxs)(`button`,{type:`button`,onClick:Ht,disabled:l,"aria-label":l?`Starting NodePod`:`Start NodePod`,className:$.primaryButton,children:[l?(0,L.jsx)(Rf,{}):(0,L.jsx)(P,{icon:Br,size:17}),l?`Starting…`:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`runtime-start-full`,children:`Start NodePod`}),(0,L.jsx)(`span`,{className:`runtime-start-short`,children:`Start`})]})]}):null]})]}),(0,L.jsxs)(`nav`,{className:`runtime-navigation`,"aria-label":`Runtime views`,children:[Lt.map(e=>(0,L.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>m(()=>f(e.id)),"aria-pressed":d===e.id,className:`runtime-nav-button`,title:e.disabled?`Start NodePod to open `+e.label.toLowerCase():void 0,children:[e.icon,(0,L.jsx)(`span`,{children:e.label})]},e.id)),(0,L.jsxs)(pt,{"aria-label":`More runtime views`,className:`runtime-more`,"data-active":!!hn,value:``,onValueChange:e=>m(()=>f(e)),children:[(0,L.jsx)(`option`,{value:``,disabled:!0,children:`More`}),(0,L.jsx)(`option`,{value:`snapshots`,disabled:!s,children:`Snapshots`}),(0,L.jsx)(`option`,{value:`vc`,disabled:!s,children:`History`}),(0,L.jsx)(`option`,{value:`probes`,children:`Diagnostics`})]})]}),(0,L.jsx)(`div`,{className:$.body,"data-view":d,"aria-busy":p,children:gn()})]})]})});function gn(){switch(d){case`status`:return _n();case`vfs`:return vn();case`shell`:return yn();case`snapshots`:return bn();case`vc`:return xn();case`log`:return Sn();case`probes`:return Cn();default:return null}}function _n(){let e=S?.memoryStats,t=h.slice(0,3),n=!r||r.mode===`browser-only`||r.mode===`browser-nodepod`,i=h[0]&&!h[0].ok?h[0]:null;return(0,L.jsxs)(`div`,{className:`runtime-overview`,children:[i&&(0,L.jsxs)(`div`,{className:`runtime-error`,role:`alert`,children:[(0,L.jsx)(P,{icon:kr,size:18}),(0,L.jsx)(`span`,{children:typeof i.output==`object`&&i.output&&`error`in i.output?String(i.output.error):`An operation failed. Open Activity for details.`})]}),(0,L.jsxs)(`section`,{className:`runtime-intro`,children:[(0,L.jsx)(`p`,{className:`runtime-eyebrow`,children:n?`Local environment`:`Execution environment`}),(0,L.jsx)(`h3`,{children:s?`Ready to run.`:n?`Your browser workspace.`:Lf(r.mode)}),(0,L.jsx)(`p`,{children:s?`JavaScript, TypeScript, and your files. All in this browser.`:n?`Start NodePod to run code, edit files, and save your experiments.`:`Use diagnostics to check the connection and inspect runtime output.`})]}),s&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`dl`,{className:`runtime-metrics`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Files`}),(0,L.jsx)(`dd`,{children:e?.vfs.fileCount??`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Storage`}),(0,L.jsx)(`dd`,{children:e?Ff(e.vfs.totalBytes):`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Snapshots`}),(0,L.jsx)(`dd`,{children:Ee.length})]})]}),(0,L.jsxs)(`div`,{className:`runtime-shortcuts`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>f(`vfs`),children:[(0,L.jsx)(P,{icon:Fr,size:22}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Browse files`}),(0,L.jsx)(`small`,{children:`Open your workspace`})]}),(0,L.jsx)(P,{icon:jr,size:16,className:`runtime-next`})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>f(`shell`),children:[(0,L.jsx)(P,{icon:Ur,size:22}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:`Open terminal`}),(0,L.jsx)(`small`,{children:`Run a command`})]}),(0,L.jsx)(P,{icon:jr,size:16,className:`runtime-next`})]})]})]}),(0,L.jsxs)(`section`,{className:`runtime-recent`,children:[(0,L.jsxs)(`div`,{className:`runtime-section-heading`,children:[(0,L.jsx)(`h3`,{children:`Recent activity`}),h.length>0&&(0,L.jsxs)(`button`,{type:`button`,className:`runtime-text-button`,onClick:()=>f(`log`),children:[`View all `,(0,L.jsx)(`span`,{children:h.length})]})]}),t.length===0?(0,L.jsx)(`p`,{className:`runtime-empty-inline`,children:`Your runs and workspace changes will appear here.`}):t.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:`runtime-event-row`,onClick:()=>f(`log`),children:[(0,L.jsx)(P,{icon:e.ok?Ar:kr,size:18,className:e.ok?`runtime-success`:`runtime-failure`}),(0,L.jsx)(`span`,{children:e.operation===`bootNodePod`?`NodePod started`:e.operation===`teardownNodePod`?`NodePod stopped`:e.operation}),(0,L.jsx)(`time`,{dateTime:new Date(e.timestamp).toISOString(),children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]},e.id))]}),(0,L.jsxs)(`details`,{className:`runtime-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:Mr,size:18}),`Environment details`]}),(0,L.jsxs)(`dl`,{className:`runtime-facts`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Environment`}),(0,L.jsx)(`dd`,{children:r?Lf(r.mode):`Loading…`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Endpoint`}),(0,L.jsx)(`dd`,{children:r?.executionEndpoint??`No execution endpoint`})]}),S&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Instance`}),(0,L.jsx)(`dd`,{children:S.instanceId})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Shared memory`}),(0,L.jsx)(`dd`,{children:S.sabEnabled?`Available`:`Unavailable`})]})]}),e&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Heap memory`}),(0,L.jsx)(`dd`,{children:e.heap?`${e.heap.usedMB.toFixed(1)} / ${e.heap.limitMB.toFixed(1)} MB`:`Unavailable`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Cached modules`}),(0,L.jsx)(`dd`,{children:e.engine.moduleCacheSize})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Cached transforms`}),(0,L.jsx)(`dd`,{children:e.engine.transformCacheSize})]})]})]}),r&&(0,L.jsx)(`div`,{className:`runtime-capabilities`,children:[{label:`File access`,available:s||r.capabilities.remoteSandbox||r.capabilities.hostProjectAccess},{label:`Shell`,available:s||r.capabilities.remoteSandbox||r.capabilities.localCommandExecution},{label:`Snapshots`,available:s||r.capabilities.durableCompute},{label:`Native binaries`,available:r.capabilities.nativeBinaries}].map(e=>(0,L.jsxs)(`span`,{"data-available":e.available,children:[(0,L.jsx)(P,{icon:e.available?Ar:Gr,size:15}),e.label,(0,L.jsxs)(`span`,{className:`runtime-sr-only`,children:[`: `,e.available?`available`:`unavailable`]})]},e.label))})]}),(0,L.jsxs)(`details`,{className:`runtime-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:Lr,size:18}),`Choose an environment`]}),(0,L.jsxs)(`div`,{className:`runtime-environment-guide`,children:[(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`NodePod · in your browser`}),(0,L.jsx)(`p`,{children:`JavaScript, files, and snapshots. No native binaries or hard security boundary.`}),(0,L.jsx)(`code`,{children:`keating web --browser-only-agent 3000`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Host · your own machine`}),(0,L.jsx)(`p`,{children:`Installed tools and local files. Use for trusted code.`}),(0,L.jsx)(`code`,{children:`keating web --host 3000 --allow-local-exec --root=/path/to/project`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Remote · an external service`}),(0,L.jsx)(`p`,{children:`Provider isolation and native tools, through your configured gateway.`}),(0,L.jsx)(`code`,{children:`keating web --remote 3000 --remote-provider=daytona --remote-endpoint=https://sandbox.example`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h4`,{children:`Cloud · a hosted runtime`}),(0,L.jsx)(`p`,{children:`Your deployment supplies execution and credentials.`}),(0,L.jsx)(`code`,{children:`keating web --cloud 3000 --cloud-endpoint=https://keating.help`})]})]})]})]})}function vn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsxs)(`div`,{className:$.flexCenter,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>Wt(`/workspace`),className:A({display:`inline-flex`,height:`1.75rem`,width:`1.75rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,_hover:{background:`var(--accent)`}}),"aria-label":`Go to workspace`,title:`Go to /workspace`,children:(0,L.jsx)(P,{icon:Rr,size:13})}),(0,L.jsx)(`button`,{type:`button`,onClick:Gt,className:A({display:`inline-flex`,height:`1.75rem`,width:`1.75rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,_hover:{background:`var(--accent)`}}),"aria-label":`Go to parent folder`,title:`Go up`,children:(0,L.jsx)(P,{icon:jr,size:13})}),(0,L.jsx)(`span`,{className:`runtime-file-path runtime-mono-xs`,children:ce})]}),de?(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsx)(Rf,{size:13}),` Loading…`]}):(0,L.jsx)(`div`,{className:$.card,children:le.length===0?(0,L.jsx)(`div`,{className:A({padding:`0.75rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:`Empty directory`}):le.map(e=>(0,L.jsxs)(`div`,{"data-file-row":!0,className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,borderBottomWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`,fontSize:`0.75rem`,_last:{borderBottomWidth:0},_hover:{background:`rgb(from var(--muted) r g b / 0.3)`}}),children:[(0,L.jsx)(`span`,{className:A({flexShrink:0}),children:e.isDir?(0,L.jsx)(P,{icon:Fr,size:14,className:A({color:`var(--primary)`})}):(0,L.jsx)(P,{icon:Pr,size:14,className:A({color:`var(--muted-foreground)`})})}),(0,L.jsx)(`button`,{type:`button`,className:A({minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,textAlign:`left`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,_hover:{color:`var(--primary)`}}),onClick:()=>e.isDir?Wt(e.path):Kt(e.path),children:e.name}),(0,L.jsx)(`span`,{className:A({marginLeft:`auto`,flexShrink:0,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:e.isDir?`dir`:Ff(e.size)}),(0,L.jsx)(`button`,{type:`button`,className:A({flexShrink:0,color:`rgb(from var(--destructive) r g b / 0.7)`,_hover:{color:`var(--destructive)`}}),"aria-label":`Delete ${e.name}`,onClick:()=>Yt(e.path,e.isDir),children:(0,L.jsx)(P,{icon:x,size:12})})]},e.path))}),(0,L.jsxs)(`div`,{className:`runtime-create-item`,children:[(0,L.jsx)(`input`,{className:A({flex:1,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.375rem 0.5rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`}),"aria-label":`New file or folder name`,placeholder:`new_name.js`,value:be,onChange:e=>xe(e.target.value),onKeyDown:e=>e.key===`Enter`&&Xt()}),(0,L.jsxs)(pt,{"aria-label":`New item type`,className:k(`runtime-item-type`,A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.375rem 0.5rem`,fontSize:`0.75rem`})),value:Se,onValueChange:e=>Ce(e),children:[(0,L.jsx)(`option`,{value:`file`,children:`File`}),(0,L.jsx)(`option`,{value:`dir`,children:`Folder`})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Xt,className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Et,size:12}),` Add`]})]}),T&&(0,L.jsxs)(`div`,{className:$.card,children:[(0,L.jsxs)(`div`,{className:`runtime-file-toolbar`,children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:T}),(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.25rem`}),children:[pe&&(0,L.jsx)(`span`,{className:A({fontSize:`0.75rem`,color:`#d97706`,_dark:{color:`#fcd34d`}}),children:`unsaved`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{ge(e=>!e),he||qt()},className:k(A({display:`inline-flex`,height:`1.75rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,paddingInline:`0.5rem`,fontSize:`0.75rem`}),A(he?{borderColor:`var(--secondary)`,background:`var(--secondary)`,color:`var(--secondary-foreground)`}:{borderColor:`var(--border)`,_hover:{background:`var(--accent)`}})),children:[(0,L.jsx)(P,{icon:Ir,size:12}),` `,he?`Hide diff`:`Show diff`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Jt,className:$.primaryButtonSm,children:[(0,L.jsx)(P,{icon:Mt,size:12}),` Save`]})]})]}),he?(0,L.jsx)(`div`,{className:A({minHeight:`12rem`,width:`100%`,overflow:`auto`,background:`var(--background)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),children:ve?(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsx)(Rf,{size:13}),` Computing diff…`]}):_e.length===0?(0,L.jsx)(`div`,{className:A({color:`var(--muted-foreground)`}),children:`No changes — file matches baseline.`}):(0,L.jsx)(`div`,{className:A({display:`grid`,gap:0}),children:_e.map((e,t)=>(0,L.jsxs)(`div`,{className:k(A({display:`flex`,gap:`0.5rem`,paddingInline:`0.25rem`}),e.type===`removed`?A({background:`rgb(239 68 68 / 0.1)`,color:`#b91c1c`,_dark:{color:`#fca5a5`}}):e.type===`added`?A({background:`rgb(34 197 94 / 0.1)`,color:`#15803d`,_dark:{color:`#86efac`}}):A({color:`var(--muted-foreground)`})),children:[(0,L.jsx)(`span`,{className:A({width:`1rem`,flexShrink:0,userSelect:`none`,textAlign:`center`,fontSize:`10px`,opacity:.5}),children:e.type===`removed`?`-`:e.type===`added`?`+`:` `}),(0,L.jsx)(`span`,{className:A({wordBreak:`break-all`}),children:e.content})]},t))})}):(0,L.jsx)(`textarea`,{className:A({minHeight:`12rem`,width:`100%`,resize:`vertical`,background:`var(--background)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),spellCheck:!1,"aria-label":`Edit ${T}`,value:D,onChange:e=>{O(e.target.value),me(!0)}})]})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use the file system.`})}function yn(){return s?(0,L.jsxs)(`div`,{className:`runtime-terminal-view`,children:[(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:`Terminal`}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.25rem`}),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:Zt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Hr,size:12}),`Clear`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:Qt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:zr,size:12}),`Fit`]})]})]}),(0,L.jsx)(`div`,{ref:M,className:A({width:`100%`,overflow:`hidden`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`black`}),style:{flex:1,minHeight:`18rem`}}),!we&&(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Booting terminal…`})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use the shell.`})}function bn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsx)(`div`,{className:`runtime-view-intro`,children:(0,L.jsx)(`h3`,{children:`Snapshots`})}),(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.75rem`}),children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:Ze?`Saved (${qe.length})`:`Session (${Ee.length})`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>Qe(e=>!e),className:A({fontSize:`10px`,color:`var(--muted-foreground)`,textDecorationLine:`underline`,_hover:{color:`var(--foreground)`}}),children:Ze?`Show session`:`Show saved`})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.25rem`}),children:[Ze&&(0,L.jsxs)(`button`,{type:`button`,onClick:$t,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Pt,size:12}),` Refresh`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:en,disabled:Ye,className:$.primaryButtonSm,children:[Ye?(0,L.jsx)(Rf,{size:12}):(0,L.jsx)(P,{icon:Et,size:12}),`Create`]})]})]}),Ze?qe.length===0?(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No saved snapshots yet. Create one to return to this workspace later.`}):(0,L.jsx)(`div`,{className:$.grid2,children:qe.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`div`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id}),(0,L.jsxs)(`div`,{className:$.text10Muted,children:[e.instanceId,` · `,new Date(e.createdAt).toLocaleString()]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>tn(e.data),className:A({marginLeft:`0.5rem`,display:`inline-flex`,height:`1.75rem`,flexShrink:0,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Hr,size:12}),` Restore`]})]},e.id))}):Ee.length===0?(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Save a snapshot before your next experiment.`}):(0,L.jsx)(`div`,{className:$.grid2,children:Ee.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:$.minW0,children:[(0,L.jsx)(`div`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id}),(0,L.jsxs)(`div`,{className:$.text10Muted,children:[e.instanceId,` · `,new Date(e.createdAt).toLocaleString()]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>tn(e.data),className:A({marginLeft:`0.5rem`,display:`inline-flex`,height:`1.75rem`,flexShrink:0,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Hr,size:12}),` Restore`]})]},e.id))})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use snapshots.`})}function xn(){return s?(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsx)(`div`,{className:`runtime-view-intro`,children:(0,L.jsx)(`h3`,{children:`History`})}),(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsxs)(`span`,{className:$.semiboldXs,children:[`Branch: `,(0,L.jsx)(`span`,{className:$.mono,children:rt})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.375rem`}),children:[(0,L.jsx)(`input`,{ref:gt,type:`file`,accept:`application/json,.json`,className:$.hidden,onChange:e=>{let t=e.target.files?.[0];t&&un(t)}}),(0,L.jsxs)(`button`,{type:`button`,onClick:ln,disabled:mt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Nr,size:12}),` Export`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>gt.current?.click(),disabled:mt,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Wr,size:12}),` Import`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:nn,className:$.outlineButtonSmBg,children:[(0,L.jsx)(P,{icon:Pt,size:12}),` Refresh`]})]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.5rem`}),children:[(0,L.jsx)(`input`,{className:$.inputMono,"aria-label":`New branch name`,placeholder:`experiment-name`,value:st,onChange:e=>ct(e.target.value)}),(0,L.jsxs)(`button`,{type:`button`,onClick:rn,disabled:lt||!st.trim(),className:$.primaryButton,children:[(0,L.jsx)(P,{icon:ie,size:13}),` Branch`]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,gap:`0.5rem`}),children:[(0,L.jsx)(`input`,{className:k($.inputBase,A({flex:1})),"aria-label":`Commit message`,placeholder:`Describe your changes`,value:at,onChange:e=>ot(e.target.value)}),(0,L.jsxs)(`button`,{type:`button`,onClick:on,disabled:lt,className:$.primaryButton,children:[(0,L.jsx)(P,{icon:Mt,size:13}),` Commit`]})]}),$e.length>0&&(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.25rem`}),children:[(0,L.jsx)(`span`,{className:A({fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.025em`,color:`var(--muted-foreground)`}),children:`Branches`}),$e.map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.375rem 0.75rem`}),children:[(0,L.jsx)(`span`,{className:$.monoXs,children:e.name}),e.id!==rt&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>an(e.id),disabled:lt,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`},_disabled:{opacity:.5}}),children:[(0,L.jsx)(P,{icon:Hr,size:10}),` Switch`]})]},e.id))]}),tt.length>0?(0,L.jsxs)(`div`,{className:$.grid2,children:[(0,L.jsx)(`span`,{className:A({fontSize:`10px`,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.025em`,color:`var(--muted-foreground)`}),children:`Commits`}),tt.map((e,t)=>(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,padding:`0.5rem 0.75rem`}),children:[(0,L.jsxs)(`div`,{className:`runtime-wrap-toolbar`,children:[(0,L.jsx)(`span`,{className:A({fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,fontWeight:500}),children:e.id.slice(0,24)}),(0,L.jsxs)(`span`,{className:$.text10Muted,children:[e.fileCount,` files`]})]}),(0,L.jsx)(`div`,{className:A({marginTop:`0.125rem`,fontSize:`0.75rem`}),children:e.message}),(0,L.jsx)(`div`,{className:$.text10Muted,children:new Date(e.createdAt).toLocaleString()}),(0,L.jsxs)(`div`,{className:A({marginTop:`0.375rem`,display:`flex`,flexWrap:`wrap`,gap:`0.25rem`}),children:[t<tt.length-1&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>sn(e.id,tt[t+1].id),className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`}}),children:[(0,L.jsx)(P,{icon:Ir,size:10}),` Diff with next`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>cn(e.id),disabled:lt,title:`Write this commit's files back into the sandbox`,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,paddingInline:`0.5rem`,fontSize:`10px`,_hover:{background:`var(--accent)`},_disabled:{opacity:.5}}),children:[(0,L.jsx)(P,{icon:Hr,size:10}),` Restore`]})]})]},e.id))]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No commits yet. Edit a file, then commit to save a version.`}),dt&&(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.1)`,padding:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({marginBottom:`0.5rem`,display:`flex`,alignItems:`center`,justifyContent:`space-between`}),children:[(0,L.jsx)(`span`,{className:$.semiboldXs,children:`Diff`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:A({fontSize:`10px`,color:`var(--muted-foreground)`,_hover:{color:`var(--foreground)`}}),children:`Close`})]}),(0,L.jsxs)(`div`,{className:A({display:`grid`,maxHeight:`15rem`,gap:`0.25rem`,overflow:`auto`}),children:[dt.changes.filter(e=>e.status!==`unchanged`).map(e=>(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`}),children:[(0,L.jsx)(`span`,{className:k(A({width:`4rem`,flexShrink:0,fontSize:`10px`,fontWeight:700}),e.status===`added`?A({color:`#16a34a`}):e.status===`removed`?A({color:`#dc2626`}):A({color:`#d97706`})),children:e.status.toUpperCase()}),(0,L.jsx)(`span`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),children:e.path})]},e.path)),dt.changes.filter(e=>e.status!==`unchanged`).length===0&&(0,L.jsx)(`div`,{className:$.textXsMuted,children:`No changes`})]})]})]}):(0,L.jsx)(`div`,{className:$.textXsMuted,children:`Start NodePod to use version control.`})}function Sn(){return(0,L.jsxs)(`div`,{className:`runtime-activity`,ref:jt,children:[(0,L.jsxs)(`div`,{className:`runtime-section-heading`,children:[(0,L.jsx)(`h3`,{children:`Activity`}),(0,L.jsxs)(`span`,{className:`runtime-count`,children:[h.length,` `,h.length===1?`event`:`events`]})]}),h.length===0?(0,L.jsxs)(`div`,{className:`runtime-empty`,children:[(0,L.jsx)(P,{icon:Or,size:30}),(0,L.jsx)(`h4`,{children:`No activity yet`}),(0,L.jsx)(`p`,{children:`Run a command or edit a file. Its result will appear here.`})]}):h.map(e=>(0,L.jsxs)(`details`,{className:`runtime-log-entry`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(P,{icon:e.ok?Ar:kr,size:19,className:e.ok?`runtime-success`:`runtime-failure`}),(0,L.jsxs)(`span`,{className:`runtime-log-title`,children:[(0,L.jsx)(`strong`,{children:e.operation}),(0,L.jsxs)(`small`,{children:[new Date(e.timestamp).toLocaleTimeString(),` · `,e.ok?`Completed`:`Failed`,e.durationMs==null?``:` · ${e.durationMs} ms`]})]})]}),(0,L.jsx)(`div`,{className:`runtime-log-output`,children:(0,L.jsx)(oe,{value:e.output,maxHeight:`22rem`})})]},e.id))]})}function Cn(){return(0,L.jsxs)(`div`,{className:$.grid3,children:[(0,L.jsxs)(`div`,{className:`runtime-view-intro`,children:[(0,L.jsx)(`h3`,{children:`Diagnostics`}),(0,L.jsx)(`p`,{children:`Check the runtime and inspect its response.`})]}),(0,L.jsx)(`label`,{htmlFor:`runtime-probe-operation`,children:`Operation`}),(0,L.jsxs)(pt,{className:A({marginBottom:`0.25rem`,width:`100%`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`var(--background)`,padding:`0.5rem`,fontSize:`0.75rem`}),id:`runtime-probe-operation`,value:N,onValueChange:Tt,children:[(0,L.jsx)(`option`,{value:`config`,children:`Read configuration`}),(0,L.jsx)(`option`,{value:`runtime.ping`,children:`Ping runtime`}),(0,L.jsx)(`option`,{value:`shell.exec`,children:`Run shell command`}),(0,L.jsx)(`option`,{value:`snapshot.create`,children:`Create snapshot`})]}),(0,L.jsx)(`label`,{htmlFor:`runtime-probe-payload`,children:`Payload · JSON`}),(0,L.jsx)(`textarea`,{className:A({minHeight:`7rem`,width:`100%`,resize:`vertical`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.2)`,padding:`0.5rem 0.75rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`,fontSize:`0.75rem`,lineHeight:1.625}),spellCheck:!1,id:`runtime-probe-payload`,value:Dt,onChange:e=>Ot(e.target.value)}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0.5rem`}),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:dn,disabled:kt,className:$.primaryButton,children:[kt?(0,L.jsx)(Rf,{size:15}):(0,L.jsx)(P,{icon:Br,size:15}),`Run check`]}),h.some(e=>e.tab===`probes`)&&(0,L.jsxs)(`button`,{type:`button`,onClick:fn,className:$.outlineButton,children:[(0,L.jsx)(P,{icon:Nt,size:14}),` `,v===null?`Copy latest`:`Copied`]})]}),h.filter(e=>e.tab===`probes`).length>0&&(0,L.jsxs)(`div`,{className:k(`runtime-probe-output`,A({marginTop:`0.5rem`,borderRadius:`0.375rem`,borderWidth:`1px`,borderColor:`var(--border)`,background:`rgb(from var(--muted) r g b / 0.2)`,padding:`0.75rem`})),children:[(0,L.jsx)(`h3`,{className:A({marginBottom:`0.5rem`,fontSize:`0.75rem`,fontWeight:600}),children:`Latest probe result`}),(0,L.jsx)(oe,{value:h.find(e=>e.tab===`probes`)?.output??null,maxHeight:`18rem`,title:`Probe Result`})]})]})}}function Bf(e){let t=typeof e.course==`string`&&e.course.trim()?e.course.trim():void 0;return t?{mode:`edit`,activeCourseId:t}:e.courseMode===`create`?{mode:`create`}:void 0}function Vf(e){return e.mode===`edit`?[{label:`Plan`,domain:`course`,text:`Inspect this course with me. Identify the most important gap, then ask before changing anything.`},{label:`Plan`,domain:`course`,text:`Help me revise this course's sequence, prerequisites, and pacing. Start by showing me what is there now.`},{label:`Create`,domain:`course`,text:`Help me add the right quiz, artifact, or assignment to this course. Ask what it should assess first.`}]:[{label:`Plan`,domain:`course`,text:`Help me design a course. Start by asking about the learners, outcomes, pace, and material I already have.`},{label:`Plan`,domain:`course`,text:`Turn what we have discussed into a course outline. Show me the outline and let me revise it before creating the course.`},{label:`Create`,domain:`course`,text:`Help me assemble a course from my saved lesson plans, quizzes, visuals, documents, and flashcards.`}]}var Hf=`https://github.com/Diogenesoftoronto/keating/issues/new`,Uf=A({maxWidth:`none`,"& p":{marginBlock:`0.75rem`},"& ul, & ol":{marginBlock:`0.75rem`,paddingInlineStart:`1.5rem`},"& code":{fontFamily:`var(--mono-body)`,fontSize:`0.875em`}}),Wf=A({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,color:`var(--muted-foreground)`,transitionProperty:`color, background-color, border-color, opacity`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}}),Gf=A({display:`inline-flex`,flexShrink:0,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,fontSize:`0.875rem`,fontWeight:500,transitionProperty:`color, background-color, border-color, opacity`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`},_disabled:{pointerEvents:`none`,opacity:.5}}),Kf=A({display:`flex`,alignItems:`center`,gap:`0.5rem`,borderRadius:`0.375rem`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`,textAlign:`left`,fontSize:`0.875rem`,transitionProperty:`color, background-color, border-color`,transitionDuration:`150ms`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}}),qf={plan:{label:`Lesson Plan`,icon:(0,L.jsx)(it,{size:14})},map:{label:`Concept Map`,icon:(0,L.jsx)(zt,{size:14})},animation:{label:`Animation`,icon:(0,L.jsx)(ft,{size:14})},deck:{label:`Flashcards`,icon:(0,L.jsx)(ct,{size:14})},verification:{label:`Verification`,icon:(0,L.jsx)(ot,{size:14})},benchmark:{label:`Benchmark`,icon:(0,L.jsx)(Ye,{size:14})},evolution:{label:`Evolution`,icon:(0,L.jsx)(Ye,{size:14})},"prompt-evolution":{label:`Prompt Evo`,icon:(0,L.jsx)(Ye,{size:14})},improvement:{label:`Improvement`,icon:(0,L.jsx)(h,{size:14})}},Jf=/```mermaid[^\n]*\n([\s\S]*?)```/gi;function Yf(e){let t=[],n=0;for(let r of e.matchAll(Jf)){let i=r.index??0,a=e.slice(n,i);a.trim()&&t.push({type:`markdown`,content:a}),t.push({type:`mermaid`,content:r[1].trim()}),n=i+r[0].length}let r=e.slice(n);return r.trim()&&t.push({type:`markdown`,content:r}),t}function Xf({source:e}){return(0,L.jsx)(`div`,{className:A({marginBlock:`0.75rem`,overflow:`auto`,borderRadius:`0.5rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 30%, transparent)`,padding:`1rem`}),children:(0,L.jsx)(Qe,{content:e})})}function Zf({content:e}){let t=Yf(e);return t.length===0?(0,L.jsx)(`div`,{className:Uf,children:(0,L.jsx)(tt,{content:e})}):(0,L.jsx)(`div`,{className:A({display:`grid`,gap:`0.75rem`}),children:t.map((e,t)=>e.type===`mermaid`?(0,L.jsx)(Xf,{source:e.content},t):(0,L.jsx)(`div`,{className:Uf,children:(0,L.jsx)(tt,{content:e.content})},t))})}function Qf({artifact:e,onDismiss:t,onOpenInBrowser:n}){let[r,i]=(0,I.useState)(!0),a=qf[e.type],o=(()=>{switch(e.type){case`plan`:return e.data.topic;case`map`:return e.data.topic;case`animation`:return e.data.topic;case`deck`:return e.data.title;case`verification`:return e.data.topic;case`benchmark`:return e.data.topic??`general`;case`evolution`:return e.data.topic??`general`;case`prompt-evolution`:return e.data.promptName;case`improvement`:return e.data.proposalId}})(),s=(()=>{switch(e.type){case`benchmark`:return`Score ${e.data.score.toFixed(2)}`;case`evolution`:return`Best score ${e.data.bestScore.toFixed(2)}`;case`prompt-evolution`:return`Best score ${e.data.bestScore.toFixed(2)}`;case`improvement`:return`${e.data.accepted?`Accepted`:`Rejected`} · Δ${(e.data.scoreDelta??0).toFixed(2)}`;case`deck`:return`${e.data.cards.length} cards`;case`verification`:return`${e.data.checklist.match(/- \[ \]/g)?.length??0} checks`;default:return null}})();return(0,L.jsxs)(`article`,{className:A({borderRadius:`0.5rem`,border:`1px solid var(--border)`,backgroundColor:`var(--card)`,color:`var(--card-foreground)`,boxShadow:`var(--shadow-card)`}),children:[(0,L.jsxs)(`header`,{className:A({display:`flex`,alignItems:`flex-start`,gap:`0.75rem`,borderBottom:`1px solid var(--border)`,paddingInline:`1rem`,paddingBlock:`0.75rem`}),children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:k(Wf,A({marginTop:`0.125rem`,width:`1.5rem`,height:`1.5rem`,flexShrink:0})),"aria-label":r?`Collapse artifact`:`Expand artifact`,"aria-expanded":r,children:r?(0,L.jsx)(De,{size:14}):(0,L.jsx)(ot,{size:14})}),(0,L.jsxs)(`div`,{className:A({minWidth:0,flex:1}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,fontWeight:500,color:`var(--muted-foreground)`}),children:[(0,L.jsxs)(`span`,{className:A({display:`inline-flex`,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 40%, transparent)`,paddingInline:`0.5rem`,paddingBlock:`0.125rem`}),children:[a.icon,a.label]}),s&&(0,L.jsxs)(`span`,{className:A({color:`var(--muted-foreground)`}),children:[`· `,s]})]}),(0,L.jsx)(`h3`,{className:A({marginTop:`0.125rem`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`0.875rem`,fontWeight:600}),children:o})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.25rem`}),children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,className:k(Wf,A({height:`1.75rem`,border:`1px solid var(--border)`,paddingInline:`0.5rem`,fontSize:`0.75rem`})),title:`Open in artifact browser`,children:`Open`}),(0,L.jsx)(`button`,{type:`button`,onClick:t,className:k(Wf,A({width:`1.75rem`,height:`1.75rem`})),"aria-label":`Dismiss artifact`,title:`Dismiss`,children:(0,L.jsx)(gt,{size:14})})]})]}),r&&(0,L.jsx)(`div`,{className:A({paddingInline:`1rem`,paddingBlock:`0.75rem`,fontSize:`0.875rem`}),children:$f(e)})]})}function $f(e){switch(e.type){case`plan`:return(0,L.jsx)(Zf,{content:e.data.content});case`map`:return(0,L.jsx)(Xf,{source:e.data.mmdContent});case`animation`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 20%, transparent)`,padding:`0.75rem`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[e.data.scene?`Scene ready`:`Storyboard only`,` ·`,` `,e.data.manifest?`manifest attached`:`no manifest`]}),(0,L.jsx)(Zf,{content:e.data.storyboard})]});case`deck`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.5rem`}),children:[(0,L.jsxs)(`p`,{className:A({fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[e.data.cards.length,` cards · open in the browser for spaced repetition review.`]}),(0,L.jsxs)(`ul`,{className:A({display:`grid`,gap:`0.25rem`,fontSize:`0.875rem`}),children:[e.data.cards.slice(0,5).map(e=>(0,L.jsxs)(`li`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:[(0,L.jsx)(`div`,{className:A({fontSize:`0.75rem`,textTransform:`uppercase`,color:`var(--muted-foreground)`}),children:e.front}),(0,L.jsx)(`div`,{className:A({fontSize:`0.875rem`}),children:e.back})]},e.id)),e.data.cards.length>5&&(0,L.jsxs)(`li`,{className:A({fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[`+`,e.data.cards.length-5,` more…`]})]})]});case`verification`:return(0,L.jsx)(Zf,{content:e.data.checklist});case`benchmark`:return(0,L.jsx)(Zf,{content:e.data.report});case`evolution`:return(0,L.jsx)(Zf,{content:e.data.report});case`prompt-evolution`:return(0,L.jsx)(Zf,{content:e.data.report});case`improvement`:return(0,L.jsxs)(`div`,{className:A({display:`grid`,gap:`0.5rem`}),children:[(0,L.jsx)(`p`,{className:A({fontSize:`0.875rem`}),children:e.data.hypothesis}),(0,L.jsxs)(`div`,{className:A({borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,padding:`0.75rem`,fontSize:`0.75rem`}),children:[(0,L.jsx)(`div`,{className:A({fontWeight:500}),children:`Targets`}),(0,L.jsx)(`div`,{className:A({marginTop:`0.25rem`,color:`var(--muted-foreground)`}),children:e.data.targets||`(unspecified)`})]})]})}}function ep({artifacts:e,onDismiss:t,onOpenInBrowser:n}){return e.length===0?null:(0,L.jsx)(`section`,{"aria-label":`Inline artifacts`,className:A({borderTop:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--muted) 20%, transparent)`,paddingInline:`0.75rem`,paddingBlock:`0.75rem`,sm:{paddingInline:`1rem`}}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexDirection:`column`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,justifyContent:`space-between`,fontSize:`0.75rem`,color:`var(--muted-foreground)`}),children:[(0,L.jsxs)(`span`,{className:A({fontWeight:500}),children:[e.length,` inline artifact`,e.length===1?``:`s`]}),(0,L.jsx)(`span`,{children:`Rendered directly in the chat page`})]}),e.map(e=>(0,L.jsx)(Qf,{artifact:e,onDismiss:()=>t(e.id),onOpenInBrowser:()=>n(e.id)},`${e.type}:${e.id}`))]})})}async function tp(e,t){return e.length?t?e.find(e=>e.id===t)??null:e.slice().sort((e,t)=>t.createdAt-e.createdAt)[0]:null}async function np(e,t){switch(e){case`plan`:{let e=await tp(await j.getLessonPlans(),t);return e?{id:e.id,type:`plan`,createdAt:e.createdAt,data:e}:null}case`map`:{let e=await tp(await j.getLessonMaps(),t);return e?{id:e.id,type:`map`,createdAt:e.createdAt,data:e}:null}case`animation`:{let e=await tp(await j.getAnimations(),t);return e?{id:e.id,type:`animation`,createdAt:e.createdAt,data:e}:null}case`deck`:{let e=await tp(await j.getDecks(),t);return e?{id:e.id,type:`deck`,createdAt:e.updatedAt,data:e}:null}case`verification`:{let e=await tp(await j.getVerifications(),t);return e?{id:e.id,type:`verification`,createdAt:e.createdAt,data:e}:null}case`benchmark`:{let e=await tp(await j.getBenchmarks(),t);return e?{id:e.id,type:`benchmark`,createdAt:e.createdAt,data:e}:null}case`evolution`:{let e=await tp(await j.getEvolutions(),t);return e?{id:e.id,type:`evolution`,createdAt:e.createdAt,data:e}:null}case`prompt-evolution`:{let e=await tp(await j.getPromptEvolutions(),t);return e?{id:e.id,type:`prompt-evolution`,createdAt:e.createdAt,data:e}:null}case`improvement`:{let e=await tp(await j.getImprovementAttempts(),t);return e?{id:e.id,type:`improvement`,createdAt:e.createdAt,data:e}:null}}}async function rp(e){let t=typeof e.id==`string`?e.id:void 0,n=typeof e.type==`string`?e.type:void 0,r=typeof e.toolName==`string`?e.toolName:void 0,i=e.result&&typeof e.result==`object`?e.result:void 0,a=(i&&typeof i.id==`string`?i.id:void 0)??(i&&typeof i.artifactId==`string`?i.artifactId:void 0),o={plan:`plan`,map:`map`,animate:`animation`,animation:`animation`,verify:`verification`,bench:`benchmark`,benchmark:`benchmark`,evolve:`evolution`,evolution:`evolution`,prompt_evolve:`prompt-evolution`,"prompt-evolve":`prompt-evolution`,quiz:`plan`,deck:`deck`,auto_improve:`improvement`,improvement:`improvement`},s=[];n&&o[n]&&s.push({type:o[n],id:t}),r&&o[r]&&s.push({type:o[r],id:a});for(let e of s){let t=await np(e.type,e.id);if(t)return t}return null}function ip(){let e=p();At({title:`Keating Chat — Socratic AI Tutor Session`,description:`Start a Socratic tutoring session with Keating. Diagnose what you know, reconstruct understanding from memory, and test transfer to new contexts.`,canonical:`https://keating.help/chat`});let t=be(),n=he(),r=D({strict:!1}),[i,a]=(0,I.useState)(),o=r.ask?.trim()||i,[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>ae(()=>u(!0)),[]),(0,I.useEffect)(()=>{if(xn()||r.ask||r.course)return;let e=!1;return _e().then(()=>pe.getAllMetadata()).then(t=>{!e&&!xn()&&t.length===0&&c(!0)}).catch(()=>{}),()=>{e=!0}},[r.ask,r.course]);let d=(0,I.useMemo)(()=>Bf(r),[r.course,r.courseMode]),f=(0,I.useMemo)(()=>d?Vf(d):void 0,[d]),{isPending:h,openSettings:g,modelLabel:_,openModelSelector:v,chooseKeatingModel:ee,newSession:te,shareSession:y,chatPanelRef:ne,dialogs:re,sessionSidebar:ie,speechEnabled:x,persistentStorageStatus:oe,persistentBannerDismissed:se,retryPersistentStorage:C,dismissPersistentBanner:w,toggleSpeech:le,forkingSessionId:ue,forkInfo:de,openOriginalSession:fe,mobileSidebarOpen:O,toggleMobileSidebar:ge,activeSessionId:j,teachingAdjustment:ve,responseComparison:xe,chooseResponse:Se}=b({courseContext:d}),[M,we]=(0,I.useState)(!1),Te=Xe(`(min-width: 1024px)`),[Ee,Oe]=(0,I.useState)(()=>me()),[ke,Ae]=(0,I.useState)(`idle`),[je,Me]=(0,I.useState)(null),[Ne,Pe]=(0,I.useState)(null),[Fe,Ie]=(0,I.useState)(!1),[Le,Re]=(0,I.useState)(!1),ze=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=j,n=!1;t.capture(`chat_composer_viewed`,{session_id:e,activation_wait_ms:45e3});let r=t=>{let r=t.detail;(!r?.sessionId||r.sessionId===e)&&(n=!0)};window.addEventListener(`keating:message-sent`,r);let i=window.setTimeout(()=>{n||document.visibilityState!==`visible`||t.capture(`chat_activation_stalled`,{session_id:e,wait_ms:45e3,survey_trigger:`activation_blocker`})},45e3);return()=>{window.removeEventListener(`keating:message-sent`,r),window.clearTimeout(i)}},[j,t]),(0,I.useEffect)(()=>{if(!Fe)return;let e=e=>{e.key===`Escape`&&Ie(!1)},t=e=>{ze.current&&!ze.current.contains(e.target)&&Ie(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[Fe]),(0,I.useEffect)(()=>Ce(Oe),[]),(0,I.useEffect)(()=>{if(!(typeof document>`u`))return document.body.classList.add(`chat-shell-active`),()=>document.body.classList.remove(`chat-shell-active`)},[]);let[Be,Ve]=(0,I.useState)(void 0),[He,Ue]=(0,I.useState)([]);(0,I.useEffect)(()=>{we(!1),Ve(void 0),Ue([])},[j]);let We=n=>{e&&we(e=>{let r=!e;return r||Ve(void 0),t.capture(r?`artifact_browser_opened`:`artifact_browser_closed`,{source:n,canvas_enabled:!0}),r})};(0,I.useEffect)(()=>{if(!e){we(!1),Ve(void 0),Ue([]);return}let t=()=>{Ee.autoOpenArtifacts&&we(!0)},n=e=>{let t=e.detail;t?.id&&(Ve(t.id),we(!0))},r=async e=>{let t=await rp(e.detail??{});t&&(Ue(e=>e.some(e=>e.id===t.id&&e.type===t.type)?e:Ee.limitInlineArtifactPreviews?[t]:[...e,t]),Ee.autoOpenArtifacts&&we(!0))};return window.addEventListener(`keating:artifact-created`,t),window.addEventListener(`keating:artifact-created`,r),window.addEventListener(`keating:open-artifact`,n),()=>{window.removeEventListener(`keating:artifact-created`,t),window.removeEventListener(`keating:artifact-created`,r),window.removeEventListener(`keating:open-artifact`,n)}},[e,Ee.autoOpenArtifacts,Ee.limitInlineArtifactPreviews]);let Ge=async()=>{Ae(`sharing`),Pe(null),Me(null);try{let e=await y();Me(e.url),Pe(`${e.mode===`portable-short`?`Portable share link`:e.mode===`compressed-hash`?`Snapshot share link`:`Local share link`} ready${e.fallback?` after portable storage was unavailable`:``}. It was copied if your browser allowed clipboard access.`),Ae(`copied`),t.capture(`session_shared`,{share_mode:e.mode,fallback:e.fallback,session_id:j}),window.setTimeout(()=>Ae(`idle`),1600)}catch(e){console.warn(`Failed to share session:`,e),Pe(e instanceof Error?e.message:`Could not create a share link yet.`),Ae(`error`),window.setTimeout(()=>Ae(`idle`),2200)}},Ke=async()=>{let e=me();if(ye(e.shareLinkMode)&&!e.trajectoryShareWarningAcknowledged){Me(null),Pe(`This link publishes the visible conversation, safe session artifacts, and any finalized review feedback. It excludes drafts, hidden tool traffic, and unsupported or oversized artifacts. Anyone with the link can read it. Share again to confirm.`),Ae(`confirm`);return}await Ge()},qe=async()=>{let e=me();e.trajectoryShareWarningAcknowledged||T({...e,shareWarningAcknowledged:!0,trajectoryShareWarningAcknowledged:!0}),await Ge()},Je=k(`chat-action-button`,Gf),Ye=oe===`declined`&&!se;return(0,L.jsxs)(`div`,{className:k(`chat-page-shell`,ue?`session-forking`:``,A({display:`flex`,width:`100%`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--background)`,color:`var(--foreground)`})),children:[(0,L.jsxs)(`nav`,{className:k(`chat-header`,A({position:`relative`,display:`flex`,height:`3.5rem`,flexShrink:0,alignItems:`center`,gap:`0.5rem`,borderBottom:`1px solid var(--border)`,paddingInline:`0.5rem`,paddingBlock:`0.5rem`,sm:{paddingInline:`1rem`}})),"aria-label":`Chat navigation`,children:[(0,L.jsx)(`button`,{type:`button`,className:k(Je,A({display:`inline-flex`,lg:{display:`none`}})),title:O?`Close sessions panel`:`Open sessions panel`,"aria-label":O?`Close sessions panel`:`Open sessions panel`,"aria-pressed":O,onClick:ge,children:O?(0,L.jsx)(Lt,{size:16}):(0,L.jsx)(F,{size:16})}),(0,L.jsx)(E,{to:`/`,className:k(`chat-brand`,A({display:`inline-flex`,minWidth:0,flexShrink:0,alignItems:`center`,gap:`0.5rem`,borderRadius:`0.375rem`,paddingInline:`0.5rem`,paddingBlock:`0.25rem`})),"aria-label":`Go to Keating home`,children:(0,L.jsx)(`img`,{src:`/brand/logo-lockup-compact.avif`,alt:`Keating`,className:A({height:`1.5rem`,width:`auto`,objectFit:`contain`})})}),(0,L.jsxs)(`button`,{type:`button`,onClick:v,title:`Model: ${_}`,"aria-label":`Change model. Current model: ${_}`,className:k(`chat-model-button`,A({display:`inline-flex`,minWidth:0,maxWidth:`11rem`,flexShrink:1,alignItems:`center`,gap:`0.25rem`,borderRadius:`0.5rem`,paddingInline:`0.5rem`,paddingBlock:`0.25rem`,fontSize:`0.8125rem`,fontWeight:500,color:`var(--muted-foreground)`,cursor:`pointer`,_hover:{backgroundColor:`var(--accent)`,color:`var(--accent-foreground)`}})),children:[(0,L.jsx)(`span`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}),children:_}),(0,L.jsx)(De,{size:13,className:A({flexShrink:0})})]}),(0,L.jsx)(`span`,{className:`chat-mode-badge chat-only-desktop`,children:`MODE: SOCRATIC`}),(0,L.jsxs)(`div`,{className:k(`chat-actions`,A({marginLeft:`auto`,display:`flex`,minWidth:0,alignItems:`center`,justifyContent:`flex-end`,gap:`0.25rem`,overflow:`hidden`,sm:{flex:1}})),children:[(0,L.jsx)(`button`,{className:Je,"aria-label":`Settings`,title:`Settings`,onClick:g,children:(0,L.jsx)(Ht,{size:16})}),e&&(0,L.jsx)(`button`,{className:Je,"aria-label":M?`Close materials`:`Open materials`,"aria-pressed":M,onClick:()=>We(`toolbar`),children:(0,L.jsx)(ct,{size:16})}),(0,L.jsx)(`button`,{className:Je,title:`Menu`,"aria-label":`More menu`,"aria-expanded":Fe,"aria-haspopup":`true`,onClick:()=>Ie(e=>!e),children:Fe?(0,L.jsx)(gt,{size:16}):(0,L.jsx)(Bt,{size:16})})]}),Fe&&(0,L.jsx)(`div`,{ref:ze,role:`navigation`,"aria-label":`Chat actions`,className:k(`font-terminal`,A({position:`absolute`,right:`0.5rem`,top:`100%`,zIndex:50,marginTop:`0.25rem`,width:`16rem`,maxHeight:`min(70dvh, 36rem)`,overflowY:`auto`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--background)`,boxShadow:`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,fontSize:`0.875rem`})),children:(0,L.jsxs)(`div`,{className:A({display:`flex`,flexDirection:`column`,padding:`0.25rem`}),children:[(0,L.jsx)(`button`,{className:k(Kf,``),disabled:h,onClick:()=>{Ie(!1),te()},children:`New session`}),(0,L.jsx)(`button`,{className:k(Kf,``,ke===`copied`?A({color:`var(--primary)`}):``,ke===`error`?A({color:`var(--destructive)`}):``),onClick:()=>{Ie(!1),ke===`confirm`?qe():Ke()},disabled:h||ke===`sharing`,children:ke===`copied`?`Link copied`:ke===`confirm`?`Confirm public share`:`Share session`}),(0,L.jsx)(`button`,{className:k(Kf,``,x?A({color:`var(--primary)`}):``),onClick:()=>{Ie(!1),t.capture(`speech_toggled`,{enabled:!x}),le()},children:x?`Disable speech`:`Enable speech`}),(0,L.jsx)(dt,{className:``,variant:`menu`,onToggled:()=>Ie(!1)}),(0,L.jsx)(E,{to:`/courses`,className:Kf,onClick:()=>Ie(!1),children:`Courses`}),!1,(0,L.jsx)(`button`,{className:k(Kf,``),onClick:()=>{Ie(!1),n({to:`/usage`})},children:`Learning usage`}),(0,L.jsx)(E,{to:`/bench`,className:Kf,onClick:()=>Ie(!1),children:`Model benchmark`}),(0,L.jsx)(E,{to:`/coming-up`,className:Kf,onClick:()=>Ie(!1),children:`Coming up`}),(0,L.jsx)(E,{to:`/live`,className:Kf,onClick:()=>Ie(!1),children:`Live sessions`}),(0,L.jsx)(`button`,{className:Kf,onClick:()=>{Ie(!1),n(j?{to:`/review/sessions/$sessionId`,params:{sessionId:j}}:{to:`/review`})},children:`Review session`}),(0,L.jsx)(`div`,{className:k(``,A({marginBlock:`0.25rem`,borderTop:`1px solid var(--border)`}))}),(0,L.jsx)(E,{to:`/`,className:Kf,onClick:()=>Ie(!1),children:`Home`}),(0,L.jsx)(`a`,{href:`https://docs.keating.help/`,target:`_blank`,rel:`noopener noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`Documentation`}),(0,L.jsx)(`a`,{href:`https://blog.keating.help/`,target:`_blank`,rel:`noopener noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`Blog`}),(0,L.jsx)(E,{to:`/paper`,className:Kf,onClick:()=>Ie(!1),children:`Paper`}),(0,L.jsx)(`a`,{href:`https://github.com/Diogenesoftoronto/keating`,target:`_blank`,rel:`noreferrer`,className:Kf,onClick:()=>Ie(!1),children:`GitHub`}),(0,L.jsx)(`a`,{href:Hf,target:`_blank`,rel:`noreferrer`,className:k(Kf,``),onClick:()=>Ie(!1),children:`Report issue`})]})})]}),d&&(0,L.jsx)(`section`,{"aria-label":`Course collaboration context`,className:A({flexShrink:0,borderBottom:`1px solid var(--border)`,backgroundColor:`color-mix(in srgb, var(--primary) 8%, var(--background))`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,minWidth:0,alignItems:`center`,gap:`0.55rem`}),children:[(0,L.jsx)(it,{size:16,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:A({minWidth:0}),children:[(0,L.jsx)(`p`,{className:A({fontSize:`0.8rem`,fontWeight:650}),children:d.mode===`create`?`Design a course with Keating`:`Keating is working in this course`}),(0,L.jsx)(`p`,{className:A({overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`0.7rem`,color:`var(--muted-foreground)`}),children:`Agree on the shape first, then Keating can create and revise the durable workspace.`})]})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`}),children:[d.activeCourseId&&(0,L.jsx)(E,{to:`/courses/$courseId`,params:{courseId:d.activeCourseId},className:A({fontWeight:650,textDecoration:`underline`,textUnderlineOffset:`3px`}),children:`Open course`}),(0,L.jsx)(E,{to:`/chat`,className:A({color:`var(--muted-foreground)`}),children:`Leave course mode`})]})]})}),de&&(0,L.jsx)(Dr,{parentTitle:de.parentTitle,onOpenOriginal:fe}),Ye&&(0,L.jsx)(`div`,{className:A({flexShrink:0,borderBottom:`1px solid var(--border)`,backgroundColor:`rgb(245 158 11 / 0.1)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`48rem`,alignItems:`center`,justifyContent:`space-between`,gap:`0.75rem`}),children:[(0,L.jsxs)(`div`,{className:A({display:`flex`,alignItems:`center`,gap:`0.5rem`,fontSize:`0.75rem`,fontWeight:500,color:`rgb(146 64 14)`,_dark:{color:`rgb(253 230 138)`}}),children:[(0,L.jsx)(`span`,{className:A({display:`none`,sm:{display:`inline`}}),children:`Browser storage persistence is not enabled. Sessions still save locally, but the browser may clear them under storage pressure.`}),(0,L.jsx)(`span`,{className:A({sm:{display:`none`}}),children:`Storage persistence is not enabled.`})]}),(0,L.jsxs)(`div`,{className:A({display:`flex`,flexShrink:0,alignItems:`center`,gap:`0.5rem`}),children:[(0,L.jsx)(`button`,{type:`button`,className:A({display:`inline-flex`,height:`1.5rem`,alignItems:`center`,borderRadius:`0.25rem`,backgroundColor:`var(--primary)`,paddingInline:`0.5rem`,fontSize:`10px`,fontWeight:500,color:`var(--primary-foreground)`,_hover:{backgroundColor:`color-mix(in srgb, var(--primary) 90%, transparent)`}}),onClick:C,children:`Try again`}),(0,L.jsx)(`button`,{type:`button`,className:k(Wf,A({width:`1.5rem`,height:`1.5rem`})),onClick:w,"aria-label":`Dismiss persistence warning`,children:(0,L.jsx)(gt,{size:12})})]})]})}),(0,L.jsx)(m,{sessionId:j,teachingAdjustment:ve}),s&&(0,L.jsx)(`div`,{className:A({flex:1,minHeight:0,overflowY:`auto`,paddingInline:`1rem`}),children:(0,L.jsx)(Mn,{onUseKeating:ee,onConnectAccount:async()=>{await Ze({allowSignIn:!0})},onChooseModel:v,onSkip:()=>c(!1),onComplete:e=>{a(e),c(!1)},...S()?{}:{onStartTour:()=>u(!0)}})}),(0,L.jsxs)(`div`,{className:A({display:`flex`,minHeight:0,flex:1,overflow:`hidden`}),style:s?{display:`none`}:void 0,children:[ie,(0,L.jsx)(ce,{ref:ne,className:k(`chat-page-panel`,A({minWidth:0,flex:1})),speechEnabled:x,initialPrompts:f,...o?{pendingPrompt:o}:{},emptyStateTitle:d?.mode===`create`?`What course should we build together?`:d?`What should we change in this course?`:void 0,emptyStateDescription:d?`Choose a starting point or describe the learners and the change you have in mind. Keating will inspect, propose, and wait for your direction before writing.`:void 0,responseComparison:xe?(0,L.jsx)(vr,{comparison:xe,onChoose:Se}):null}),e&&Te&&M&&(0,L.jsx)(`div`,{className:k(`artifact-side-panel`,A({height:`100%`,flexShrink:0,borderLeft:`1px solid var(--border)`})),children:(0,L.jsx)(gr,{open:M,artifactId:Be,onClose:()=>{we(!1),Ve(void 0)}})})]}),l&&!s&&(0,L.jsx)(In,{onFinish:()=>u(!1),onSkip:()=>u(!1)}),e&&He.length>0&&(0,L.jsx)(ep,{artifacts:He,onDismiss:e=>Ue(t=>t.filter(t=>t.id!==e)),onOpenInBrowser:e=>{Ve(e),we(!0)}}),(je||Ne)&&(0,L.jsx)(`div`,{className:A({borderTop:`1px solid var(--border)`,backgroundColor:`var(--background)`,paddingInline:`1rem`,paddingBlock:`0.75rem`,fontSize:`0.875rem`}),children:(0,L.jsxs)(`div`,{className:A({marginInline:`auto`,display:`flex`,maxWidth:`56rem`,flexDirection:`column`,gap:`0.5rem`,sm:{flexDirection:`row`,alignItems:`center`}}),children:[(0,L.jsx)(`span`,{className:A(ke===`error`?{color:`var(--destructive)`}:{color:`var(--muted-foreground)`}),children:Ne}),je&&(0,L.jsx)(`input`,{className:A({minWidth:0,flex:1,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--muted)`,paddingInline:`0.75rem`,paddingBlock:`0.5rem`,fontFamily:`var(--mono-body)`,fontSize:`0.75rem`,color:`var(--foreground)`}),readOnly:!0,value:je,onFocus:e=>e.currentTarget.select()}),ke===`confirm`&&(0,L.jsx)(`button`,{className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,backgroundColor:`var(--primary)`,paddingInline:`0.75rem`,fontSize:`0.75rem`,color:`var(--primary-foreground)`,_hover:{backgroundColor:`color-mix(in srgb, var(--primary) 90%, transparent)`}}),onClick:qe,children:`Share publicly`}),(0,L.jsx)(`button`,{className:A({display:`inline-flex`,height:`2rem`,alignItems:`center`,justifyContent:`center`,borderRadius:`0.375rem`,border:`1px solid var(--border)`,paddingInline:`0.75rem`,fontSize:`0.75rem`,_hover:{backgroundColor:`var(--accent)`}}),onClick:()=>{Ae(`idle`),Me(null),Pe(null)},children:ke===`confirm`?`Cancel`:`Dismiss`})]})}),(0,L.jsx)(lr,{open:e&&M&&!Te,artifactId:Be,onClose:()=>{we(!1),Ve(void 0)}}),(0,L.jsx)(zf,{open:Le,onClose:()=>Re(!1)}),re]})}function ap(){return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:k(`chat-page-shell`,A({display:`flex`,width:`100%`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--background)`,color:`var(--foreground)`})),children:(0,L.jsx)(`div`,{className:A({display:`flex`,flex:1,alignItems:`center`,justifyContent:`center`,fontSize:`0.875rem`,color:`var(--muted-foreground)`}),children:`Initializing…`})}),children:(0,L.jsx)(ip,{})})}export{ap as Chat};
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./syntax-highlighter-Buac5fmw.js";import{wt as p}from"./index-C8C76R86.js";var m=p();c.registerLanguage(`tsx`,r),c.registerLanguage(`jsx`,r),c.registerLanguage(`javascript`,n),c.registerLanguage(`js`,n),c.registerLanguage(`typescript`,f),c.registerLanguage(`ts`,f),c.registerLanguage(`python`,a),c.registerLanguage(`py`,a),c.registerLanguage(`bash`,t),c.registerLanguage(`sh`,t),c.registerLanguage(`shell`,t),c.registerLanguage(`json`,u),c.registerLanguage(`css`,s),c.registerLanguage(`html`,e),c.registerLanguage(`yaml`,i),c.registerLanguage(`yml`,i),c.registerLanguage(`rust`,l),c.registerLanguage(`rs`,l),c.registerLanguage(`go`,o),c.registerLanguage(`golang`,o);function h({code:e,language:t}){return(0,m.jsx)(c,{language:t,style:d,showLineNumbers:!0,lineNumberStyle:{minWidth:`2.2em`,paddingRight:`1em`,color:`#6e7681`,fontSize:`0.75em`},customStyle:{margin:0,borderRadius:0,fontSize:`0.82rem`,lineHeight:1.55,background:`#0d1117`},children:e.replace(/\n$/,``)})}export{h as default};
1
+ import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./syntax-highlighter-Buac5fmw.js";import{wt as p}from"./index-DCgpDQKf.js";var m=p();c.registerLanguage(`tsx`,r),c.registerLanguage(`jsx`,r),c.registerLanguage(`javascript`,n),c.registerLanguage(`js`,n),c.registerLanguage(`typescript`,f),c.registerLanguage(`ts`,f),c.registerLanguage(`python`,a),c.registerLanguage(`py`,a),c.registerLanguage(`bash`,t),c.registerLanguage(`sh`,t),c.registerLanguage(`shell`,t),c.registerLanguage(`json`,u),c.registerLanguage(`css`,s),c.registerLanguage(`html`,e),c.registerLanguage(`yaml`,i),c.registerLanguage(`yml`,i),c.registerLanguage(`rust`,l),c.registerLanguage(`rs`,l),c.registerLanguage(`go`,o),c.registerLanguage(`golang`,o);function h({code:e,language:t}){return(0,m.jsx)(c,{language:t,style:d,showLineNumbers:!0,lineNumberStyle:{minWidth:`2.2em`,paddingRight:`1em`,color:`#6e7681`,fontSize:`0.75em`},customStyle:{margin:0,borderRadius:0,fontSize:`0.82rem`,lineHeight:1.55,background:`#0d1117`},children:e.replace(/\n$/,``)})}export{h as default};