openpond 0.0.63 → 0.0.64

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 (98) hide show
  1. package/dist/chunks/{app-layer-TUAFALOE.js → app-layer-NCSTDSNQ.js} +2 -2
  2. package/dist/chunks/{app-server-runtime-O26LVUYH.js → app-server-runtime-XWIG4OWY.js} +6 -6
  3. package/dist/chunks/{apps-KSZRA7Y2.js → apps-HEG7FEEV.js} +2 -2
  4. package/dist/chunks/{chunk-66KQLYSH.js → chunk-57XKCMOZ.js} +1 -1
  5. package/dist/chunks/{chunk-JTFDOA2P.js → chunk-6FZNXLVN.js} +17 -5
  6. package/dist/chunks/{chunk-IXA5PMXC.js → chunk-BRLUAT6S.js} +1 -1
  7. package/dist/chunks/{chunk-7IFPXSSJ.js → chunk-C7TOCBGY.js} +1 -1
  8. package/dist/chunks/{chunk-6FKBOGA4.js → chunk-EWP6VGHP.js} +1 -1
  9. package/dist/chunks/{chunk-V2CTXKS2.js → chunk-HM6Z3PEC.js} +19 -16
  10. package/dist/chunks/{chunk-KGU437HZ.js → chunk-JMHOO2IG.js} +2 -2
  11. package/dist/chunks/{chunk-7UVEB2AZ.js → chunk-THYIAXOB.js} +2 -2
  12. package/dist/chunks/{chunk-LEL5AQJU.js → chunk-U345JN44.js} +1 -1
  13. package/dist/chunks/{chunk-YDH34BGG.js → chunk-WT3THPTX.js} +32 -32
  14. package/dist/chunks/{cli-LPFU4ULD.js → cli-3BI2QBI2.js} +5 -5
  15. package/dist/chunks/{core-commands-OEOBYFIW.js → core-commands-Y4ZMQXO4.js} +3 -3
  16. package/dist/chunks/{desktop-test-BRLZF3O7.js → desktop-test-YRFKONLO.js} +2 -2
  17. package/dist/chunks/{extension-5BUCIDKG.js → extension-4MFKIC6Q.js} +2 -2
  18. package/dist/chunks/{help-MT6VPW4X.js → help-STXVR4NO.js} +1 -1
  19. package/dist/chunks/{opchat-O4DVKNFW.js → opchat-CCVKI5GH.js} +2 -2
  20. package/dist/chunks/{organizations-ACNOJ57Q.js → organizations-AS76SGLP.js} +4 -4
  21. package/dist/chunks/{profile-7LLWXAJE.js → profile-QNWDNZY3.js} +2 -2
  22. package/dist/chunks/{project-agent-RVYQYTU2.js → project-agent-GPZL7KAL.js} +2 -2
  23. package/dist/chunks/{sandbox-command-QST23BX5.js → sandbox-command-LC63MMAA.js} +2 -2
  24. package/dist/chunks/{sandbox-template-N7UG3P6V.js → sandbox-template-FPQLZ4IP.js} +3 -3
  25. package/dist/chunks/{src-CPM5Q7T5.js → src-6NIBZPH2.js} +3 -3
  26. package/dist/chunks/{src-M37V6NVU.js → src-DQFVZZUR.js} +7 -7
  27. package/dist/chunks/{teams-bot-ITTI47XS.js → teams-bot-YTX7IC2J.js} +2 -2
  28. package/dist/chunks/{workspaces-CYBR37US.js → workspaces-IXF7MIQV.js} +2 -2
  29. package/dist/cli.js +13 -13
  30. package/dist/web/assets/{AppDialog-wIb8mGQ0.js → AppDialog-DacC7BcY.js} +1 -1
  31. package/dist/web/assets/{AppsView-D097dPIV.js → AppsView-mkeAkrvr.js} +1 -1
  32. package/dist/web/assets/{BrowserSidebar-DrD-o_yB.js → BrowserSidebar-1aEC6gsF.js} +1 -1
  33. package/dist/web/assets/{CommandMenu-L5LelA2h.js → CommandMenu-BN6J3ecV.js} +1 -1
  34. package/dist/web/assets/{CommunityView-DUJ8NryS.js → CommunityView-B2v9Q4cw.js} +1 -1
  35. package/dist/web/assets/{ComposerCreateImproveStrip-BP-7DmQG.js → ComposerCreateImproveStrip-BH8Ath1h.js} +1 -1
  36. package/dist/web/assets/{GetStartedView-B7gB6Hii.js → GetStartedView-B-R-KSva.js} +1 -1
  37. package/dist/web/assets/{LabModelVersionDetailPage-CNDz2a6I.js → LabModelVersionDetailPage-Bhfa7T00.js} +1 -1
  38. package/dist/web/assets/{LabSkillSidebar-BImOQcjk.js → LabSkillSidebar-CbYdG0RN.js} +1 -1
  39. package/dist/web/assets/{LabsRoute-BauSK1is.js → LabsRoute-DFV5vV6Z.js} +3 -3
  40. package/dist/web/assets/{MainChatThread-BZvAqQO6.js → MainChatThread-COiXI7ri.js} +2 -2
  41. package/dist/web/assets/MainPane-CQCLhV5C.js +6 -0
  42. package/dist/web/assets/MarkdownText-R3MC5S30.js +9 -0
  43. package/dist/web/assets/{Messages-DijmQL-z.js → Messages-DpZ8mIz8.js} +1 -1
  44. package/dist/web/assets/{NativeSkillSidebar-aCkrdGa0.js → NativeSkillSidebar-BfcMqLHA.js} +1 -1
  45. package/dist/web/assets/{NewProjectDialog-D98WIQzr.js → NewProjectDialog-DqTX1Eeo.js} +1 -1
  46. package/dist/web/assets/{OutputsPage-BA0c6cfy.js → OutputsPage-DfZYswx2.js} +1 -1
  47. package/dist/web/assets/{RightChatPanelStack-DKDEmrEH.js → RightChatPanelStack-DH8QjiDY.js} +1 -1
  48. package/dist/web/assets/{ScheduledWorkPage-DeHi99mv.js → ScheduledWorkPage-DkaVUnwj.js} +1 -1
  49. package/dist/web/assets/SettingsView-BRPrJuP5.css +1 -0
  50. package/dist/web/assets/SettingsView-StVFsSJ6.js +6 -0
  51. package/dist/web/assets/{TeamChatView-D2mCoLZ3.js → TeamChatView-CqZOnQh2.js} +1 -1
  52. package/dist/web/assets/{TerminalOverlay-BHMsVp4L.js → TerminalOverlay-CnFv6FZT.js} +1 -1
  53. package/dist/web/assets/{TrainingCreationPanel-CPnMWgkt.js → TrainingCreationPanel-CWzyzmyT.js} +1 -1
  54. package/dist/web/assets/{TrainingDraftPanel-0scEtzSW.js → TrainingDraftPanel-BVHx0HZ0.js} +1 -1
  55. package/dist/web/assets/{UsageSettingsSection-COoCLLg6.js → UsageSettingsSection-Bdvm66WK.js} +1 -1
  56. package/dist/web/assets/{WorkspaceDiffPanel-BFTwZ_dB.js → WorkspaceDiffPanel-DUCjD1GA.js} +5 -5
  57. package/dist/web/assets/{WorkspaceEnvironmentMenu-DFlkdd9T.js → WorkspaceEnvironmentMenu-DHGrt_ie.js} +1 -1
  58. package/dist/web/assets/{WorkspaceGitDialogs-Dt3LO27Z.js → WorkspaceGitDialogs-hI57yjPL.js} +1 -1
  59. package/dist/web/assets/{WorkspaceMonacoEditor-3g05teoR.js → WorkspaceMonacoEditor-DPv-1uO6.js} +3 -3
  60. package/dist/web/assets/{arrow-up-right-DYGSWA2J.js → arrow-up-right-BDcNd1rt.js} +1 -1
  61. package/dist/web/assets/{chevron-up-4qfvI9iW.js → chevron-up-XTMMnfnf.js} +1 -1
  62. package/dist/web/assets/{cloud-upload-COReKxOy.js → cloud-upload-D6bS8rS2.js} +1 -1
  63. package/dist/web/assets/{cssMode-BbH67BYF.js → cssMode-CvN9o8bP.js} +1 -1
  64. package/dist/web/assets/{folder-open-9OjGqNgP.js → folder-open-8C5l7A93.js} +1 -1
  65. package/dist/web/assets/{folder-plus-DF5E6zr3.js → folder-plus-B9Wqb9yd.js} +1 -1
  66. package/dist/web/assets/{git-branch-eCwyZXMl.js → git-branch-C45ve7zh.js} +1 -1
  67. package/dist/web/assets/{git-commit-horizontal-cPm51DqY.js → git-commit-horizontal-CGoLIyKK.js} +1 -1
  68. package/dist/web/assets/{htmlMode-DD6Oge4x.js → htmlMode-DxLP6j5r.js} +1 -1
  69. package/dist/web/assets/index-BYgrO3wt.js +1 -0
  70. package/dist/web/assets/index-CHqMtVfF.css +1 -0
  71. package/dist/web/assets/{index-BO2W2U23.js → index-LrGasYyx.js} +29 -29
  72. package/dist/web/assets/{info-p1mFpqBI.js → info-DTObFlHw.js} +1 -1
  73. package/dist/web/assets/{jsonMode-C2Xd56A_.js → jsonMode-C3_fOSJu.js} +1 -1
  74. package/dist/web/assets/{lspLanguageFeatures-BjYEk4gJ.js → lspLanguageFeatures-0c-UKStE.js} +1 -1
  75. package/dist/web/assets/{monaco.contribution-quEPEMQZ.js → monaco.contribution-CF1DgPPC.js} +2 -2
  76. package/dist/web/assets/{monaco.contribution-C7WMqwmc.js → monaco.contribution-CFLEc9Ly.js} +2 -2
  77. package/dist/web/assets/{monaco.contribution-Bo-5m7yy.js → monaco.contribution-Cb7KlQ6G.js} +2 -2
  78. package/dist/web/assets/{monaco.contribution-DzWlEgU1.js → monaco.contribution-Dsug_FPj.js} +2 -2
  79. package/dist/web/assets/{play-Ctx-iMqd.js → play-Cbsyrwkw.js} +1 -1
  80. package/dist/web/assets/{python-Cm64qCpk.js → python-DVcVB2lF.js} +1 -1
  81. package/dist/web/assets/{refresh-cw-Bn28jIl0.js → refresh-cw-ChUK_QfF.js} +1 -1
  82. package/dist/web/assets/{save-BM5IQX65.js → save-Doep-KC7.js} +1 -1
  83. package/dist/web/assets/{square-DAGpFfSr.js → square-B5q2aneb.js} +1 -1
  84. package/dist/web/assets/{toggleHighContrast-DLW8Fnck.js → toggleHighContrast-CTZp7RE7.js} +1 -1
  85. package/dist/web/assets/{tsMode-BleUN_8S.js → tsMode-GfNadOOB.js} +1 -1
  86. package/dist/web/assets/{upload-vaAKFfxi.js → upload-DcewuCTa.js} +1 -1
  87. package/dist/web/assets/{useLocalAgentSchedules-Ccenbqf6.js → useLocalAgentSchedules-BwltnId8.js} +1 -1
  88. package/dist/web/assets/{wifi-off-DJA9KReb.js → wifi-off-cXPyKIzd.js} +1 -1
  89. package/dist/web/assets/{workers-CFG-afha.js → workers-CP6kCS63.js} +1 -1
  90. package/dist/web/assets/{yaml-Cs8iZKVC.js → yaml-w0GP6yKf.js} +1 -1
  91. package/dist/web/index.html +2 -2
  92. package/package.json +1 -1
  93. package/dist/web/assets/MainPane-CuhwxMxg.js +0 -6
  94. package/dist/web/assets/MarkdownText-gwAue4u5.js +0 -9
  95. package/dist/web/assets/SettingsView--fL3Ecuy.js +0 -6
  96. package/dist/web/assets/SettingsView-BS5m5vdt.css +0 -1
  97. package/dist/web/assets/index-BRLugX1S.js +0 -1
  98. package/dist/web/assets/index-Y7IoiSlQ.css +0 -1
@@ -1,14 +1,14 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./WorkspaceMonacoEditor-3g05teoR.js","./index-BO2W2U23.js","./index-Y7IoiSlQ.css","./WorkspaceMonacoEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
- import{c as Ee,j as e,i as rt,bk as zs,aK as tn,r,ay as Fe,p as I,bl as $t,aX as Ft,aS as Oe,bm as da,bn as ua,au as fa,bo as pa,av as ha,F as ma,B as sn,d as xa,X as Is,P as ba,a2 as ga,ar as ja,a1 as va,a0 as ka,bp as wa,a4 as Ws,bq as ya,br as ts,bs as Sa,bt as ss,bu as Na,a as Ca,_ as Ra,bv as Qt,bw as $a,bx as ns,b4 as Ne,by as Fa,bz as Bs,bA as Ea,bB as Aa,bC as Os,bD as Pa,bE as La}from"./index-BO2W2U23.js";import{T as Da,F as Ta,A as _a,a as Ma,M as za,b as Ia,u as Us,I as Wa}from"./MarkdownText-gwAue4u5.js";import{R as as}from"./refresh-cw-Bn28jIl0.js";import{t as Ba,a as Oa,m as Ua,s as Ha,d as Va,f as Ka,b as Ga}from"./training-model-data-V8276E5q.js";import{F as yt}from"./folder-open-9OjGqNgP.js";import{I as Hs}from"./info-p1mFpqBI.js";import{S as qa}from"./save-BM5IQX65.js";import{C as Xa}from"./chevron-up-4qfvI9iW.js";const Za=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Qa=Ee("text-align-start",Za);const Ya=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Ja=Ee("chevrons-up",Ya);const ei=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ti=Ee("columns-2",ei);const si=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ni=Ee("eye-off",si);const ai=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],ii=Ee("panel-top",ai);const li=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],ri=Ee("redo-2",li);const oi=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ci=Ee("undo-2",oi);function di({createRuntime:t,goalRuntime:s,subagentRuntime:n=null,onRunSubagentLifecycleAction:a}){const i=t?"Create/Improve Details":"Goal Details",u=t?Z(t.run.state):n?.activeCount?n.label:s?.actionLabel??"No active goal";return e.jsxs("div",{className:"goal-details-view","aria-label":i,children:[e.jsxs("div",{className:"goal-details-header",children:[e.jsxs("div",{className:"goal-details-title",children:[e.jsx(rt,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:i})]}),e.jsx("span",{className:`goal-details-state ${Fi(t?.run.state??null)}`,children:u})]}),e.jsx("div",{className:"goal-details-body",children:t?e.jsx(ui,{runtime:t}):s||n?e.jsx(pi,{goalRuntime:s,subagentRuntime:n,onRunSubagentLifecycleAction:a}):e.jsx($i,{})})]})}function ui({runtime:t}){const s=t.run,n=s.plan,a=zs(n?.metadata)??zs(s.metadata),i=s.questions,u=i.filter(o=>o.status==="pending"),c=s.sourceRefs,f=s.checkRefs,h=s.state,m=s.target.kind==="agent"?s.target.defaultActionKey:null;return e.jsxs(e.Fragment,{children:[e.jsx(V,{title:"Current Work",children:e.jsx(it,{rows:[["State",Z(h)],["Operation",s.operation],["Target",Z(s.target.kind)],["Name",s.target.displayName??s.target.id??"Pending"],["Target ID",s.target.id??"Pending"],["Default action",m??n?.defaultChatAction.key??"Pending"],["Adapter",Z(s.adapter.kind)],["Run",s.id],["Revision",String(s.revision)]]})}),e.jsx(V,{title:"Plan",children:n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"goal-details-summary",children:n.summary}),e.jsx(it,{rows:[["Objective",n.objective],["Context",n.capturedContextSummary],["Status",Z(n.status)],["Plan ID",n.id],["Run ID",n.runId],["Approval",n.approvalId??"Pending"],["Approved",n.approvedAt??"Not approved"]]})]}):u.length?e.jsx("p",{className:"goal-details-summary",children:"Waiting for answers before the model finalizes the Create plan."}):e.jsx("p",{className:"goal-details-summary",children:"The model is preparing the Create plan."})}),a?e.jsxs(V,{title:"Action Shape",children:[e.jsx(it,{rows:[["Mode",a.label],["Default action",a.defaultActionKey??"None"],["Direct action",a.directActionHint??"None planned"],["Artifacts",a.artifactPolicy]]}),e.jsx("p",{className:"goal-details-note",children:a.detail})]}):null,i.length?e.jsx(V,{title:"Questions",children:e.jsx("div",{className:"goal-details-list",children:i.map(o=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.title}),e.jsx("span",{className:`goal-details-inline-state ${o.status}`,children:Z(o.status)})]}),e.jsx("p",{children:o.prompt}),o.answer?e.jsxs("small",{children:["Answer: ",o.answer.label??o.answer.value]}):o.options.length?e.jsxs("small",{children:["Options: ",o.options.map(x=>x.label).join(", ")]}):null]},o.id))})}):null,n?.requirements.length?e.jsx(V,{title:"Setup Requirements",children:e.jsx("div",{className:"goal-details-list",children:n.requirements.map(o=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{className:`goal-details-inline-state ${o.status}`,children:Z(o.status)})]}),e.jsxs("small",{children:[Z(o.kind),o.detail?`: ${o.detail}`:""]})]},`${o.kind}:${o.name}`))})}):null,n?.sourcePlan.length?e.jsx(V,{title:"Source Plan",children:e.jsx(wt,{refs:n.sourcePlan.map(o=>({id:`${o.operation}:${o.path}`,primary:o.path,secondary:`${Z(o.operation)}: ${o.reason}`}))})}):null,n?.checks.length?e.jsx(V,{title:"Checks",children:e.jsx(wt,{refs:n.checks.map(o=>({id:o.name,primary:o.name,secondary:`${o.required?"Required":"Optional"}: ${o.command}`}))})}):null,c.length||f.length?e.jsx(V,{title:"Run Refs",children:e.jsx(wt,{refs:[...c.map(o=>({id:`source:${o}`,primary:o,secondary:"Source ref"})),...f.map(o=>({id:`check:${o}`,primary:o,secondary:"Check ref"}))]})}):null,e.jsx(fi,{run:s}),s.blockedReason?e.jsx(V,{title:"Blocked",children:e.jsxs("div",{className:"goal-details-alert",children:[e.jsx(tn,{size:15}),e.jsx("span",{children:s.blockedReason})]})}):null,e.jsx(V,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify(s,null,2)})]})})]})}function fi({run:t}){const s=[...t.context.attachments.map(i=>({id:`attachment:${i.id??i.name}`,primary:i.name,secondary:i.ref??i.mediaType??"Attachment"})),...t.context.apps.map(i=>({id:`app:${i.id}`,primary:i.name,secondary:i.required?"Required app context":"Optional app context"})),...t.context.tools.map(i=>({id:`tool:${i.name}`,primary:i.name,secondary:i.outputSummary??i.inputSummary??"Tool context"})),...t.context.targetRepoAssumptions.map(i=>({id:`target:${i}`,primary:i,secondary:"Target assumption"}))],n=t.workflowCapture,a=n?[...n.files.map(i=>({id:`workflow-file:${i}`,primary:i,secondary:"Captured file"})),...n.outputArtifacts.map(i=>({id:`workflow-artifact:${i}`,primary:i,secondary:"Output artifact"})),...n.traceRefs.map(i=>({id:`workflow-trace:${i}`,primary:i,secondary:"Trace"}))]:[];return!s.length&&!a.length?null:e.jsx(V,{title:"Context",children:e.jsx(wt,{refs:[...s,...a]})})}function pi({goalRuntime:t,subagentRuntime:s,onRunSubagentLifecycleAction:n}){return e.jsxs(e.Fragment,{children:[t?e.jsxs(V,{title:"Goal",children:[e.jsx("p",{className:"goal-details-summary",children:t.objective}),e.jsx(it,{rows:[["Status",t.actionLabel],["Runtime",t.timeLabel],["Detail",t.detail]]})]}):null,s?e.jsx(hi,{runtime:s,onRunSubagentLifecycleAction:n}):null,e.jsx(V,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify({goalRuntime:t,subagentRuntime:s},null,2)})]})})]})}function hi({runtime:t,onRunSubagentLifecycleAction:s}){const[n,a]=r.useState(null),[i,u]=r.useState(null);Fe(i);const c=async(f,h)=>{if(!s)return;const m=`${f}:${h}`;a(m),u(null);try{await s({runId:f,action:h})}catch(o){u(o instanceof Error?o.message:String(o))}finally{a(o=>o===m?null:o)}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{title:"Subagents",children:[e.jsx(it,{rows:[["Latest update",ki(t)],["Active",String(t.activeCount)],["Completed",String(t.completedCount)],["Failed",String(t.failedCount)],["Cancelled",String(t.cancelledCount)],["Paused",String(t.needsResumeCount)],["Terminal",String(t.terminalCount)],["Usage",wi(t.usage.totalTokens,t.usage.requestCount)],["Evidence",String(t.evidenceRefs.length)],["Checks",String(t.testsRunCount)]]}),t.blockers.length>0?e.jsx("ul",{className:"goal-details-list compact",children:t.blockers.slice(0,4).map(f=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${f.status}`,children:f.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(f.roleId)}),e.jsx("p",{children:f.message})]})]},`${f.runId}:${f.message}`))}):null,e.jsx("ul",{className:"goal-details-list",children:t.runs.slice(0,8).map(f=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${f.status}`,children:f.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(f.roleId)}),e.jsx("p",{children:f.objective}),f.report?.summary?e.jsx("small",{children:f.report.summary}):null,s?e.jsx(xi,{pendingAction:n,run:f,onRun:c}):null]})]},f.id))})]}),t.finalResults.length>0?e.jsx(mi,{results:t.finalResults}):null]})}function mi({results:t}){return e.jsx(V,{title:"Child Results",children:e.jsx("ol",{className:"goal-details-task-graph",children:t.slice(0,6).map(s=>e.jsxs("li",{className:"goal-details-task-node",children:[e.jsxs("div",{className:"goal-details-task-node-header",children:[e.jsx("span",{className:`goal-details-inline-state ${s.status}`,children:s.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(s.roleId)}),e.jsx("small",{children:s.objective})]})]}),e.jsx("p",{children:s.summary}),e.jsxs("div",{className:"goal-details-task-node-meta",children:[e.jsxs("span",{children:[s.refs.length," refs"]}),e.jsxs("span",{children:[s.testsRun.length+s.validationAttempts.length," checks"]}),e.jsxs("span",{children:[s.blockers.length," blockers"]}),e.jsx("span",{children:s.confidence?`${Z(s.confidence)} confidence`:"Confidence unknown"})]}),s.findings.length>0?e.jsxs("small",{children:["Findings: ",Ce(s.findings,3)]}):null,s.changedFiles.length>0?e.jsxs("small",{children:["Files: ",Ce(s.changedFiles,4)]}):null,s.testsRun.length>0?e.jsxs("small",{children:["Tests: ",Ce(s.testsRun,3)]}):null,s.validationAttempts.length>0?e.jsxs("small",{children:["Validation: ",Ce(s.validationAttempts,2)]}):null,s.refs.length>0?e.jsxs("small",{children:["Refs: ",Ce(s.refs.map(yi),4)]}):null,s.blockers.length>0?e.jsxs("small",{children:["Blockers: ",Ce(s.blockers,3)]}):null,s.workspaceRetention?e.jsxs("small",{children:["Workspace: ",Ni(s.workspaceRetention)]}):null,s.importantMessages.length>0?e.jsxs("small",{children:["Messages: ",Ce(s.importantMessages.map(Si),2)]}):null]},s.runId))})})}function xi({pendingAction:t,run:s,onRun:n}){const a=bi(s);return a.length===0?null:e.jsx("div",{className:"goal-details-actions",children:a.map(i=>{const u=`${s.id}:${i}`,c=t===u;return e.jsx("button",{type:"button",disabled:!!t,onClick:()=>{n(s.id,i)},children:c?"Working...":gi(i)},i)})})}function bi(t){const s=[],n=ji(t),a=vi(t);return n&&s.push("cleanup"),a&&s.push("archive"),s}function gi(t){return t==="cleanup"?"Clean":t==="archive"?"Archive":"Clean + archive"}function ji(t){if(!nn(t))return!1;const s=lt(t.metadata);if(!s?.subagentWorkspace&&!s?.workspaceHandoff)return!1;const n=lt(s.lifecycleCleanup),a=lt(n?.workspaceCleanup),i=an(a?.status);return i!=="removed"&&i!=="deleted"&&i!=="retained"&&i!=="skipped"}function vi(t){if(!t.childSessionId||!nn(t))return!1;const s=lt(lt(t.metadata)?.childSessionArchive),n=an(s?.status);return n!=="archived"&&n!=="already_archived"}function nn(t){return t.status==="completed"||t.status==="failed"||t.status==="cancelled"}function ki(t){const s=t.latestMeaningfulUpdate;return s?`${St(s.roleId)} ${s.status}: ${s.message}`:"No structured update"}function wi(t,s){if(t<=0&&s<=0)return"0 tokens";const n=`${s} ${s===1?"request":"requests"}`;return`${Ci(t)} tokens · ${n}`}function St(t){return t.slice(0,1).toUpperCase()+t.slice(1).replace(/[-_]+/g," ")}function yi(t){return`${t.kind}: ${t.label}`}function Si(t){return`${Z(t.kind)}: ${t.body}`}function Ni(t){const s=t.expiresAt?`until ${Ri(t.expiresAt)}`:"for inspection",n=t.trigger?` · ${Z(t.trigger)}`:"";return`retained ${s}${n}`}function Ce(t,s){const n=t.slice(0,s),a=t.length-n.length;return a>0?`${n.join(", ")} +${a}`:n.join(", ")}function Ci(t){if(t<1e3)return String(t);if(t>=1e6){const n=t/1e6;return`${Vs(n,n<10?2:1)}M`}const s=t/1e3;return`${Vs(s,s<10?1:0)}k`}function Ri(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Vs(t,s){return t.toFixed(s).replace(/\.0+$/,"").replace(/(\.\d*?)0+$/,"$1")}function $i(){return e.jsxs("div",{className:"goal-details-empty",children:[e.jsx(rt,{size:18}),e.jsx("span",{children:"No active Goal or Create workflow."})]})}function V({children:t,title:s}){return e.jsxs("section",{className:"goal-details-section",children:[e.jsx("h2",{children:s}),t]})}function it({rows:t}){return e.jsx("dl",{className:"goal-details-grid",children:t.map(([s,n])=>e.jsxs("div",{children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:n})]},s))})}function wt({refs:t}){return e.jsx("ul",{className:"goal-details-ref-list",children:t.map(s=>e.jsxs("li",{children:[e.jsx("code",{title:s.primary,children:s.primary}),e.jsx("span",{children:s.secondary})]},s.id))})}function lt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function an(t){return typeof t=="string"&&t.trim()?t.trim():null}function Z(t){return t.split(/[_-]/g).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Fi(t){return t==="ready_local"||t==="published_hosted"?"success":t==="blocked"||t==="failed"||t==="cancelled"?"danger":t==="awaiting_questions"||t==="awaiting_plan_approval"?"warning":"active"}function Ei({sandboxId:t,connection:s}){const[n,a]=r.useState(null),[i,u]=r.useState([]),[c,f]=r.useState(null),[h,m]=r.useState(null),[o,x]=r.useState(null),[S,k]=r.useState(null);Fe(o,{prefix:"Sandbox"}),Fe(S,{prefix:"Sandbox integrations"});const N=n?.integrationLeases??[],E=r.useMemo(()=>i.filter(j=>j.status==="active"),[i]),_=r.useMemo(()=>Pi(n),[n]),W=r.useCallback(async()=>{if(!s){x("OpenPond App server is not connected.");return}if(!t){a(null),u([]),x(null);return}f("summary"),x(null);try{const j=await I.sandbox(s,t),R=await I.integrationConnections(s,Ks(j.sandbox));a(j.sandbox),u(R.connections),k(null)}catch(j){x(j instanceof Error?j.message:String(j))}finally{f(null)}},[s,t]),K=r.useCallback(async()=>{if(!(!s||!n)){m("load"),k(null);try{const[j,R]=await Promise.all([I.integrationConnections(s,Ks(n)),I.sandboxIntegrationLeases(s,n.id)]);u(j.connections),a(R.sandbox)}catch(j){k(j instanceof Error?j.message:String(j))}finally{m(null)}}},[s,n]),U=r.useCallback(async j=>{if(!s||!n)return;const R=$t(j.provider),T=R?Ft(R):null,M=T?.leasePolicy.allowedCapabilityIds??[];if(!R||!T?.leasePolicy.leaseable||M.length===0){k(`${ae(j.provider)} cannot be attached to this sandbox.`);return}m(`attach:${j.id}`),k(null);try{const A=await I.attachSandboxIntegrationConnection(s,n.id,{connectionId:j.id,provider:j.provider,capabilities:M,...j.scopes.length>0?{scopes:j.scopes}:{},...T.leasePolicy.defaultTtlSeconds?{ttlSeconds:T.leasePolicy.defaultTtlSeconds}:{},required:!1});a(A.sandbox)}catch(A){k(A instanceof Error?A.message:String(A))}finally{m(null)}},[s,n]),B=r.useCallback(async j=>{if(!(!s||!n)){m(`remove:${j}`),k(null);try{const R=await I.removeSandboxIntegrationLease(s,n.id,j);a(R.sandbox)}catch(R){k(R instanceof Error?R.message:String(R))}finally{m(null)}}},[s,n]);return r.useEffect(()=>{W()},[W]),t?e.jsxs("div",{className:"sandbox-summary-tab",children:[e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Sandbox"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[n?e.jsx("span",{children:n.state}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh summary","aria-label":"Refresh summary",disabled:c!==null,onClick:()=>{W()},children:c==="summary"?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(as,{size:14})})]})]}),n?e.jsxs("dl",{className:"sandbox-workspace-kv",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Sandbox"}),e.jsx("dd",{children:Gs(n.id)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Spend"}),e.jsxs("dd",{children:[Yt(n.reservation.capturedUsd)," / ",Yt(n.budget.maxUsd)]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reservation"}),e.jsx("dd",{children:n.reservation.status})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Idle cleanup"}),e.jsx("dd",{children:n.quotas?.idleTimeoutSeconds?`${Math.round(n.quotas.idleTimeoutSeconds/60)} min`:"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:ln(n.updatedAt)})]}),_?e.jsxs("div",{children:[e.jsx("dt",{children:"Receipt"}),e.jsxs("dd",{children:[Gs(_.id)," / ",Yt(_.totalUsd)]})]}):null]}):e.jsxs("div",{className:"sandbox-workspace-loading",children:[c==="summary"?e.jsx(Oe,{className:"spinning",size:16}):null,e.jsx("span",{children:c==="summary"?"Loading sandbox":"Sandbox unavailable"})]})]}),e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Integrations"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[e.jsx("span",{children:N.length}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh integrations","aria-label":"Refresh integrations",disabled:h!==null||!n,onClick:()=>{K()},children:h==="load"?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(as,{size:14})})]})]}),N.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:N.map(j=>e.jsxs("div",{className:"sandbox-workspace-integration-row",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:ae(j.provider)}),e.jsxs("small",{children:[j.required?"required":"optional"," / ",Ti(j)," / ",Ai(j)]})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:`Revoke ${ae(j.provider)} lease`,"aria-label":`Revoke ${ae(j.provider)} lease`,disabled:h!==null,onClick:()=>{B(j.leaseId)},children:h===`remove:${j.leaseId}`?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(Da,{size:14})}),e.jsxs("div",{className:"sandbox-workspace-chip-row",children:[j.capabilities.slice(0,5).map(R=>e.jsx("span",{children:Di(j.provider,R)},R)),j.capabilities.length>5?e.jsxs("span",{children:["+",j.capabilities.length-5]}):null]})]},j.leaseId))}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No active integration leases."}),E.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:E.map(j=>{const R=N.some(A=>A.provider===j.provider),M=Li(j)?.leasePolicy.allowedCapabilityIds.length??0;return e.jsxs("div",{className:"sandbox-workspace-integration-row compact",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:_i(j)}),e.jsx("small",{children:Mi(j,M)})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:R?`${ae(j.provider)} already attached`:`Attach ${ae(j.provider)}`,"aria-label":R?`${ae(j.provider)} already attached`:`Attach ${ae(j.provider)}`,disabled:R||h!==null||M===0,onClick:()=>{U(j)},children:h===`attach:${j.id}`?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(da,{size:14})})]},j.id)})}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No connected accounts available."})]})]}):e.jsx("div",{className:"sandbox-summary-tab",children:e.jsx("p",{className:"sandbox-workspace-empty",children:"No sandbox is attached yet."})})}function Ks(t){return{status:"active"}}function Ai(t){return t.proxyUrl?"runtime proxy available":"metadata only, no runtime proxy"}function Pi(t){return t?.receipts?.at(-1)??null}function Li(t){const s=$t(t.provider);return s?Ft(s):null}function ae(t){const s=$t(t),n=s?Ft(s):null;return n?n.label:t==="microsoft_teams"?"Microsoft Teams":t?t.replace(/_/g," "):"Integration"}function Di(t,s){const n=$t(t);return(n?Ft(n):null)?.capabilities.find(i=>i.id===s)?.label??s}function Ti(t){return t.expiresAt?`expires ${ln(t.expiresAt)}`:"active"}function _i(t){const s=t.providerAccountName?.trim();return s?`${ae(t.provider)} / ${s}`:ae(t.provider)}function Mi(t,s){const n=[];return t.providerWorkspaceName&&n.push(t.providerWorkspaceName),n.push(`${s} lease ${s===1?"capability":"capabilities"}`),t.scopes.length>0&&n.push(`${t.scopes.length} ${t.scopes.length===1?"scope":"scopes"}`),n.join(" / ")}function Gs(t){return t.length>10?`${t.slice(0,8)}...`:t}function ln(t){if(!t)return"-";const s=new Date(t);return Number.isNaN(s.valueOf())?"-":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function Yt(t){const s=Number(t??0);return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:s>=10?2:4}).format(Number.isFinite(s)?s:0)}function zi({summary:t}){const s=Ba(t.taskset),n=t.taskset.learningSignals.demonstrations.filter(c=>c.approved).length,a=t.taskset.tasks.filter(c=>c.split==="frozen_eval").length,i=t.plan?.recipe.method==="sft"||t.plan?.recipe.method==="grpo"?t.plan.recipe:null,u=Oa(t.taskset,t.plan);return e.jsxs("div",{className:"training-sidebar-summary",children:[e.jsxs("header",{children:[e.jsx("h2",{children:Ua(t.taskset.name)}),e.jsx("span",{children:t.job?Ha(t.job.status):t.taskset.readiness?.ready?"Ready to train":"Needs review"})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Run"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Primary recommendation",value:s.toUpperCase()}),e.jsx(O,{label:"Training stage",value:u}),e.jsx(O,{label:"Base model",value:i?.baseModel.id??"Not selected"}),e.jsx(O,{label:"Compute",value:t.plan?Va(t.plan.destinationId):"Not selected"}),e.jsx(O,{label:"Started",value:Ka(t.job?.startedAt??null)}),e.jsx(O,{label:"Duration",value:Ga(t.job?.startedAt??null,t.job?.completedAt??null)})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Data"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Training examples",value:String(n)}),e.jsx(O,{label:"Test examples",value:String(a)}),e.jsx(O,{label:"Dataset sources",value:String(t.taskset.sourceRefs.length)})]})]}),i?e.jsxs("section",{children:[e.jsx("h3",{children:"Recipe"}),e.jsxs("dl",{children:[i.method==="grpo"?e.jsx(O,{label:"RL loss",value:i.loss.method==="gspo-token"?"GSPO-token":i.loss.method.toUpperCase()}):null,e.jsx(O,{label:"LoRA rank",value:String(i.lora.rank)}),e.jsx(O,{label:"Learning rate",value:String(i.optimizer.learningRate)}),e.jsx(O,{label:"Optimizer steps",value:String(i.optimizer.maxSteps)}),e.jsx(O,{label:i.method==="grpo"?"Prompt length":"Sequence length",value:String(i.method==="grpo"?i.dataset.maxPromptTokens:i.dataset.maxSequenceLength)})]})]}):null,e.jsxs("section",{children:[e.jsx("h3",{children:"Result"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Adapter",value:t.lineage?`${u} ready`:"Not created"}),e.jsx(O,{label:"Evaluation",value:t.lineage?.frozenEvaluationArtifactId?"Completed":"Not completed"}),e.jsx(O,{label:"Artifacts",value:String(t.artifacts.length)})]})]})]})}function O({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ii(t){const s=qs("","","folder");for(const n of t){const a=n.endsWith("/"),i=n.split("/").filter(Boolean);if(i.length===0)continue;let u=s,c="";for(let f=0;f<i.length;f+=1){const h=i[f];c=c?`${c}/${h}`:h;const m=!a&&f===i.length-1?"file":"folder",o=`${m}:${h}`;let x=u.childMap.get(o);x||(x=qs(h,c,m),u.childMap.set(o,x),u.children.push(x)),u=x}}return rn(s.children)}function qs(t,s,n){return{name:t,path:s,type:n,children:[],childMap:new Map}}function rn(t){return t.sort((s,n)=>s.type!==n.type?s.type==="folder"?-1:1:s.name.localeCompare(n.name)).map(s=>({name:s.name,path:s.path,type:s.type,children:rn(s.children)}))}function is({className:t,currentStatus:s,onSetStatus:n}){const a=s==="pinned",i=s==="saved_for_later";return e.jsxs("span",{className:`workspace-file-bookmark-actions ${t??"workspace-file-heading-actions"}`,children:[e.jsx("button",{type:"button",className:a?"active":void 0,"data-tooltip":a?"Unpin file":"Pin file","aria-label":a?"Unpin file":"Pin file","aria-pressed":a,onClick:()=>n(a?"none":"pinned"),children:a?e.jsx(ua,{size:14}):e.jsx(fa,{size:14})}),e.jsx("button",{type:"button",className:i?"active":void 0,"data-tooltip":i?"Remove from Save for later":"Save file for later","aria-label":i?"Remove from Save for later":"Save file for later","aria-pressed":i,onClick:()=>n(i?"none":"saved_for_later"),children:i?e.jsx(pa,{size:14}):e.jsx(ha,{size:14})})]})}function Wi({changedByPath:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h}){const m=r.useMemo(()=>Ii(a),[a]);return e.jsxs("div",{className:"workspace-file-tree-view",children:[e.jsxs("div",{className:"workspace-file-tree-header",children:[e.jsx(yt,{size:14}),e.jsx("strong",{title:n??void 0,children:n?n.split("/").at(-1):"Files"}),e.jsx("span",{children:a.length})]}),e.jsx("div",{className:"workspace-file-tree",children:m.map(o=>e.jsx(on,{changedByPath:t,expandedFolderPaths:s,node:o,rootPath:n,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h},`${o.type}:${o.path}`))})]})}function on({changedByPath:t,depth:s=0,expandedFolderPaths:n,node:a,rootPath:i,selectedPath:u,getFileBookmarkStatus:c,onOpenFile:f,onSetFileBookmarkStatus:h,onToggleFolder:m}){const o=i?`${i}/${a.path}`:a.path,x=a.type==="folder"&&n.has(o),S=t.get(o),k=2+s*11;return a.type==="folder"?e.jsxs("div",{className:"workspace-file-tree-node",children:[e.jsxs("button",{type:"button",className:"workspace-file-tree-row folder","aria-expanded":x,style:{paddingLeft:k},onClick:()=>m(o),children:[x?e.jsx(yt,{size:14}):e.jsx(ma,{size:14}),e.jsx("span",{children:a.name})]}),x&&a.children.map(N=>e.jsx(on,{changedByPath:t,depth:s+1,expandedFolderPaths:n,node:N,rootPath:i,selectedPath:u,getFileBookmarkStatus:c,onOpenFile:f,onSetFileBookmarkStatus:h,onToggleFolder:m},`${N.type}:${N.path}`))]}):e.jsxs("div",{className:`workspace-file-tree-row file ${S?"changed":""} ${u===o?"selected":""}`,style:{paddingLeft:k},children:[e.jsxs("button",{type:"button",className:"workspace-file-tree-row-main",title:o,onClick:()=>f(o),children:[e.jsx(Ta,{size:13}),e.jsx("span",{children:a.name}),S&&e.jsxs("small",{children:[e.jsxs("span",{className:"diff-addition",children:["+",S.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",S.deletions]})]})]}),h?e.jsx(is,{className:"workspace-file-tree-bookmark-actions",currentStatus:c?.(o)??null,onSetStatus:N=>h(o,N)}):null]})}function Xs({diff:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h}){const m=t?.files??[],o=r.useMemo(()=>new Map(m.map(k=>[k.path,k])),[m]),x=n?.replace(/^\/+|\/+$/g,"")||null,S=r.useMemo(()=>{if(!x)return a;const k=`${x}/`;return a.filter(N=>N.startsWith(k)).map(N=>N.slice(k.length)).filter(Boolean)},[x,a]);return e.jsx("div",{className:"workspace-diff-files-view",children:e.jsx(Wi,{changedByPath:o,expandedFolderPaths:s,rootPath:x,repoFiles:S,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h})})}function Bi({collapsed:t,editorControlsVisible:s,hideWhiteSpace:n,loadFullFiles:a,renderMarkdown:i,wordDiffs:u,wordWrap:c,onClose:f,onCopyGitApply:h,onRefresh:m,onToggleCollapsed:o,onToggleEditorControlsVisible:x,onToggleHideWhiteSpace:S,onToggleLoadFullFiles:k,onToggleRenderMarkdown:N,onToggleWordDiffs:E,onToggleWordWrap:_}){return e.jsxs("div",{className:"workspace-diff-options-menu",role:"menu",children:[e.jsx(ce,{icon:e.jsx(as,{size:14}),label:"Refresh",onClick:m,onClose:f}),e.jsx(ce,{checked:c,icon:e.jsx(_a,{size:14}),label:"Enable word wrap",onClick:_,onClose:f}),e.jsx(ce,{checked:t,icon:e.jsx(Ja,{size:14}),label:"Collapse all diffs",onClick:o,onClose:f}),e.jsx("div",{className:"workspace-diff-menu-divider"}),e.jsx(ce,{checked:s,icon:e.jsx(ii,{size:14}),label:"Show editor controls",onClick:x,onClose:f}),e.jsx(ce,{checked:i,icon:e.jsx(sn,{size:14}),label:"Render Markdown",onClick:N,onClose:f}),e.jsx(ce,{checked:!a,icon:e.jsx(rt,{size:14}),label:"Show diffs first",onClick:k,onClose:f}),e.jsx(ce,{checked:u,icon:e.jsx(Qa,{size:14}),label:"Enable word diffs",onClick:E,onClose:f}),e.jsx(ce,{checked:n,icon:e.jsx(ni,{size:14}),label:"Hide white space",onClick:S,onClose:f}),e.jsx(ce,{icon:e.jsx(Ma,{size:14}),label:"Copy git apply command",onClick:h,onClose:f})]})}function ce({checked:t,icon:s,label:n,onClick:a,onClose:i}){return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a?.(),i()},children:[s,e.jsx("span",{children:n}),t&&e.jsx(xa,{size:14})]})}function Oi({addMenuOpen:t,expanded:s,filteredFiles:n,dirtyFilePaths:a,openFiles:i,goalDetailsAvailable:u,searchOpen:c,searchQuery:f,selectedPath:h,sideChatTabs:m=[],summaryAvailable:o,sourceStatus:x,sourceSwitcher:S,visibleTab:k,getFileBookmarkStatus:N,onCloseFileTab:E,onCloseSideChat:_,onCloseSearch:W,onOpenFile:K,onOpenBrowser:U,onOpenSearch:B,onOpenSideChat:j,onSearchQueryChange:R,onSetFileBookmarkStatus:T,onSelectFile:M,onSelectFiles:A,onSelectGoal:Q,onSelectSummary:q,onSelectSideChat:z,onToggleAddMenu:H,onToggleExpanded:le}){const re=r.useRef(null);r.useEffect(()=>{if(!t&&!c)return;function w(){t&&H(),c&&W()}function F(de){re.current?.contains(de.target)||w()}function D(de){de.key==="Escape"&&w()}return document.addEventListener("pointerdown",F),document.addEventListener("keydown",D),()=>{document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",D)}},[t,W,H,c]);function Y(w){if(w.key==="Escape"){W();return}w.key==="Enter"&&n[0]&&K(n[0])}function J(w){if(!["ArrowRight","ArrowLeft","Home","End"].includes(w.key))return;const F=w.target;if(!(F instanceof HTMLButtonElement)||F.getAttribute("role")!=="tab")return;const D=Array.from(w.currentTarget.querySelectorAll('button[role="tab"]')),de=D.indexOf(F);if(de<0||D.length===0)return;w.preventDefault();const Et=ya(de,D.length,w.key),Ae=D[Et];if(!Ae)return;Ae.focus(),Ae.click();const X=Ae.id;X&&window.requestAnimationFrame(()=>document.getElementById(X)?.focus())}return e.jsxs("div",{className:"workspace-diff-topbar",children:[e.jsxs("div",{className:"workspace-diff-tabs",role:"tablist","aria-label":"Right sidebar views",onKeyDown:J,children:[u?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="goal"?"active":""}`,role:"tab","aria-selected":k==="goal",onClick:Q,children:[e.jsx(rt,{size:14}),e.jsx("span",{children:"Goal"})]}):null,o&&q?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="summary"?"active":""}`,role:"tab","aria-selected":k==="summary",onClick:q,children:[e.jsx(Hs,{size:14}),e.jsx("span",{children:"Summary"})]}):null,e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="files"?"active":""}`,role:"tab",id:"right-sidebar-files-tab","aria-controls":"right-sidebar-files-panel","aria-selected":k==="files",tabIndex:k==="files"?0:-1,onClick:A,children:[e.jsx(yt,{size:14}),e.jsx("span",{children:"Files"})]}),i.map(w=>e.jsxs("div",{className:`workspace-diff-tab file ${k==="file"&&h===w.path?"active":""}`,children:[e.jsxs("button",{type:"button",className:"workspace-diff-tab-main",role:"tab","aria-selected":k==="file"&&h===w.path,title:w.path,onClick:()=>M(w.path),children:[e.jsx(rt,{className:"workspace-diff-tab-icon",size:13}),a.has(w.path)&&e.jsx("span",{className:"workspace-diff-tab-dirty","aria-hidden":"true"}),e.jsx("span",{children:w.path.split("/").pop()})]}),T?e.jsx(is,{className:"workspace-diff-tab-bookmark-actions",currentStatus:N?.(w.path)??null,onSetStatus:F=>T(w.path,F)}):null,e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${w.path}`,onClick:F=>E(w.path,F),children:e.jsx(Is,{size:12})})]},w.path)),m.map(w=>e.jsxs("div",{className:"workspace-diff-tab right-chat-tab",children:[e.jsxs("button",{type:"button",className:"workspace-diff-tab-main",role:"tab",id:`right-chat-tab-${w.id}`,"aria-controls":`right-chat-panel-${w.id}`,"aria-selected":!1,tabIndex:-1,title:w.title,onClick:()=>z?.(w.id),children:[w.running?e.jsx("span",{className:"right-chat-status-dot","aria-label":"Running"}):null,e.jsx("span",{children:w.title})]}),_?e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${w.title}`,"aria-label":`Close ${w.title}`,onClick:F=>{F.stopPropagation(),_(w.id)},children:e.jsx(Is,{size:12})}):null]},w.id)),e.jsxs("div",{className:"workspace-diff-add-anchor",ref:re,children:[e.jsx("button",{type:"button",className:`workspace-diff-add-tab ${t||c?"active":""}`,title:"Add","aria-label":"Add to right sidebar",onClick:H,children:e.jsx(ba,{size:15})}),t&&e.jsxs("div",{className:"workspace-diff-add-menu",role:"menu",children:[j?e.jsxs("button",{type:"button",role:"menuitem",onClick:j,children:[e.jsx(ga,{size:14}),e.jsx("span",{children:"New task"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:A,children:[e.jsx(yt,{size:14}),e.jsx("span",{children:"Files"}),e.jsx("kbd",{})]}),o&&q?e.jsxs("button",{type:"button",role:"menuitem",onClick:q,children:[e.jsx(Hs,{size:14}),e.jsx("span",{children:"Summary"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:B,children:[e.jsx(ja,{size:14}),e.jsx("span",{children:"Open file"}),e.jsx("kbd",{children:"Ctrl+P"})]}),U?e.jsxs("button",{type:"button",role:"menuitem",onClick:U,children:[e.jsx(va,{size:14}),e.jsx("span",{children:"Browser"}),e.jsx("kbd",{children:"Ctrl+I"})]}):null]}),c&&e.jsxs("div",{className:"workspace-file-search-popover",children:[e.jsx("input",{autoFocus:!0,placeholder:"Search files",value:f,onChange:w=>R(w.target.value),onKeyDown:Y}),e.jsx("span",{children:"Files"}),e.jsx("div",{className:"workspace-file-search-results",children:n.length===0?e.jsx("small",{children:"Type to search for files"}):n.map(w=>e.jsx("button",{type:"button",onClick:()=>K(w),children:w},w))})]})]})]}),S||x?e.jsxs("div",{className:"workspace-diff-source-bar","aria-label":"Workspace source",children:[S?e.jsx("div",{className:"workspace-diff-source-toggle",role:"group","aria-label":"File source",children:S.options.map(w=>e.jsx("button",{type:"button",className:S.value===w.value?"active":"","aria-pressed":S.value===w.value,onClick:()=>S.onChange(w.value),children:w.label},w.value))}):null,x?e.jsx("span",{className:`workspace-diff-source-status ${x.tone}`,children:x.label}):null]}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:s?"Restore files panel":"Expand files panel","aria-label":s?"Restore files panel":"Expand files panel",onClick:le,children:s?e.jsx(za,{size:14}):e.jsx(ka,{size:14})})]})}function Ui({canCheckActiveFile:t,canSaveActiveFile:s,collapsed:n,editorControlsVisible:a,editorDiagnosticStatus:i,editorDiagnosticsChecking:u,hideWhiteSpace:c,loadFullFiles:f,menuOpen:h,renderMarkdown:m,showEditorCommandBar:o,showRenderMarkdownToggle:x,splitView:S,wordDiffs:k,wordWrap:N,onCopyGitApply:E,onEditorCheck:_,onEditorRedo:W,onEditorSave:K,onEditorUndo:U,onRefresh:B,onToggleCollapsed:j,onToggleEditorControlsVisible:R,onToggleHideWhiteSpace:T,onToggleLoadFullFiles:M,onToggleMenu:A,onToggleRenderMarkdown:Q,onToggleSplitView:q,onToggleWordDiffs:z,onToggleWordWrap:H}){return e.jsx("div",{className:"workspace-diff-toolbar",children:e.jsxs("div",{className:"workspace-diff-toolbar-actions",children:[e.jsxs("div",{className:"workspace-diff-menu-anchor",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Diff options","aria-haspopup":"menu","aria-expanded":h,onClick:()=>A(),children:e.jsx(wa,{size:15})}),h&&e.jsx(Bi,{collapsed:n,editorControlsVisible:a,hideWhiteSpace:c,loadFullFiles:f,renderMarkdown:m,wordDiffs:k,wordWrap:N,onClose:()=>A(!1),onCopyGitApply:E,onRefresh:B,onToggleCollapsed:j,onToggleEditorControlsVisible:R,onToggleHideWhiteSpace:T,onToggleLoadFullFiles:M,onToggleRenderMarkdown:Q,onToggleWordDiffs:z,onToggleWordWrap:H})]}),o&&e.jsxs("div",{className:"workspace-editor-command-bar","aria-label":"Editor controls",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Save file","aria-label":"Save file",disabled:!s,onClick:K,children:e.jsx(qa,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Undo","aria-label":"Undo",onClick:U,children:e.jsx(ci,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Redo","aria-label":"Redo",onClick:W,children:e.jsx(ri,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Check file","aria-label":"Check file",disabled:!t,onClick:_,children:u?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(Ws,{size:14})}),i&&e.jsxs("span",{className:`workspace-editor-diagnostic-chip ${i.severity}`,children:[i.severity==="error"||i.severity==="warning"||i.severity==="unavailable"?e.jsx(tn,{size:13}):e.jsx(Ws,{size:13}),e.jsx("span",{children:i.label})]})]}),x&&e.jsx("button",{type:"button",className:`diff-icon-button ${m?"active":""}`,title:m?"Show Markdown source":"Render Markdown","aria-label":m?"Show Markdown source":"Render Markdown","aria-pressed":m,onClick:Q,children:e.jsx(sn,{size:14})}),e.jsx("button",{type:"button",className:`diff-icon-button ${S?"active":""}`,title:S?"Show unified diff":"Show split diff","aria-label":S?"Show unified diff":"Show split diff","aria-pressed":S,onClick:q,children:e.jsx(ti,{size:14})})]})})}const Hi={cjs:"typescript",css:"css",html:"html",js:"typescript",json:"json",jsx:"typescript",md:"markdown",mjs:"typescript",py:"python",sh:"shell",ts:"typescript",tsx:"typescript",yaml:"yaml",yml:"yaml"};function ls(t){const s=t.split("/").pop()?.toLowerCase()??"";if(s==="dockerfile")return"shell";if(s==="readme"||s==="readme.md")return"markdown";const n=s.includes(".")?s.split(".").pop()??"":"";return Hi[n]??"text"}function Vi(t,s){return t?s==="markdown"?Ki(t):s==="json"?$e(t,/("(?:\\.|[^"\\])*"(?=\s*:)|"(?:\\.|[^"\\])*"|[-]?\b\d+(?:\.\d+)?\b|\btrue\b|\bfalse\b|\bnull\b|[{}[\]:,])/g):s==="css"?$e(t,/(\/\*.*?\*\/|#[\da-fA-F]{3,8}\b|--[\w-]+|[.#]?[\w-]+(?=\s*:)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw)?\b|[{}():;,])/g):s==="html"?$e(t,/(<!--.*?-->|<\/?[\w-]+|[\w:-]+(?==)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[<>/=])/g):s==="shell"?$e(t,/(#.*$|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:cd|cp|export|git|npm|pnpm|bun|yarn|rm|mkdir|test|if|then|fi|for|do|done|echo)\b|\$[\w_]+|&&|\|\||[|&;=])/g):s==="python"?$e(t,/(#.*$|"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:class|def|return|if|elif|else|for|while|try|except|finally|with|as|import|from|None|True|False|async|await|lambda|yield)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|.:,()[\]{}]+)/g):$e(t,/(\/\/.*$|\/\*.*?\*\/|`(?:\\.|[^`\\])*`|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:abstract|as|async|await|boolean|break|case|catch|class|const|continue|default|else|enum|export|extends|false|finally|for|from|function|if|import|in|interface|let|new|null|number|of|return|string|switch|throw|true|try|type|undefined|void|while)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|?:.,()[\]{}]+)/g):[{text:" ",kind:"plain"}]}function Ki(t){return/^\s{0,3}#{1,6}\s/.test(t)?[{text:t,kind:"keyword"}]:/^\s*[-*+]\s/.test(t)?[{text:t,kind:"property"}]:$e(t,/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\([^)]+\)|https?:\/\/\S+)/g)}function Gi(t){return/^(\/\/|#|\/\*|<!--)/.test(t)?"comment":/^["'`]/.test(t)?"string":/^[-]?\d/.test(t)||/^#[\da-fA-F]{3,8}\b/.test(t)?"number":/^\b[A-Z]/.test(t)?"type":/^[.#]?[\w-]+$/.test(t)&&t.includes("-")?"property":/^(?:[{}()[\],.:;<>/=+\-*&|!?%]+)$/.test(t)?"operator":/^(?:--|\$)/.test(t)?"property":"keyword"}function $e(t,s){const n=[];let a=0;for(const i of t.matchAll(s)){const u=i.index??0;u>a&&n.push({text:t.slice(a,u),kind:"plain"});const c=i[0];if(n.push({text:c,kind:Gi(c)}),a=u+c.length,/^(\/\/|#|<!--)/.test(c))break}return a<t.length&&n.push({text:t.slice(a),kind:"plain"}),n.length>0?n:[{text:t,kind:"plain"}]}function Nt({language:t,text:s}){return e.jsx(e.Fragment,{children:Vi(s,t).map((n,a)=>e.jsx("span",{className:`syntax-token ${n.kind}`,children:n.text},`${a}-${n.text}`))})}const qi=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./WorkspaceMonacoEditor-DPv-1uO6.js","./index-LrGasYyx.js","./index-CHqMtVfF.css","./WorkspaceMonacoEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
+ import{c as Ee,j as e,i as rt,bk as zs,aK as tn,r,ay as Fe,p as I,bl as $t,aX as Ft,aS as Oe,bm as da,bn as ua,au as fa,bo as pa,av as ha,F as ma,B as sn,d as xa,X as Is,P as ba,a2 as ga,ar as ja,a1 as va,a0 as ka,bp as wa,a4 as Ws,bq as ya,br as ts,bs as Sa,bt as ss,bu as Na,a as Ca,_ as Ra,bv as Qt,bw as $a,bx as ns,b4 as Ne,by as Fa,bz as Bs,bA as Ea,bB as Aa,bC as Os,bD as Pa,bE as La}from"./index-LrGasYyx.js";import{T as Da,F as Ta,c as _a,a as Ma,M as za,b as Ia,u as Us,I as Wa}from"./MarkdownText-R3MC5S30.js";import{R as as}from"./refresh-cw-ChUK_QfF.js";import{t as Ba,a as Oa,m as Ua,s as Ha,d as Va,f as Ka,b as Ga}from"./training-model-data-V8276E5q.js";import{F as yt}from"./folder-open-8C5l7A93.js";import{I as Hs}from"./info-DTObFlHw.js";import{S as qa}from"./save-Doep-KC7.js";import{C as Xa}from"./chevron-up-XTMMnfnf.js";const Za=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Qa=Ee("text-align-start",Za);const Ya=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Ja=Ee("chevrons-up",Ya);const ei=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ti=Ee("columns-2",ei);const si=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ni=Ee("eye-off",si);const ai=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],ii=Ee("panel-top",ai);const li=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],ri=Ee("redo-2",li);const oi=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ci=Ee("undo-2",oi);function di({createRuntime:t,goalRuntime:s,subagentRuntime:n=null,onRunSubagentLifecycleAction:a}){const i=t?"Create/Improve Details":"Goal Details",u=t?Z(t.run.state):n?.activeCount?n.label:s?.actionLabel??"No active goal";return e.jsxs("div",{className:"goal-details-view","aria-label":i,children:[e.jsxs("div",{className:"goal-details-header",children:[e.jsxs("div",{className:"goal-details-title",children:[e.jsx(rt,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:i})]}),e.jsx("span",{className:`goal-details-state ${Fi(t?.run.state??null)}`,children:u})]}),e.jsx("div",{className:"goal-details-body",children:t?e.jsx(ui,{runtime:t}):s||n?e.jsx(pi,{goalRuntime:s,subagentRuntime:n,onRunSubagentLifecycleAction:a}):e.jsx($i,{})})]})}function ui({runtime:t}){const s=t.run,n=s.plan,a=zs(n?.metadata)??zs(s.metadata),i=s.questions,u=i.filter(o=>o.status==="pending"),c=s.sourceRefs,f=s.checkRefs,h=s.state,m=s.target.kind==="agent"?s.target.defaultActionKey:null;return e.jsxs(e.Fragment,{children:[e.jsx(V,{title:"Current Work",children:e.jsx(it,{rows:[["State",Z(h)],["Operation",s.operation],["Target",Z(s.target.kind)],["Name",s.target.displayName??s.target.id??"Pending"],["Target ID",s.target.id??"Pending"],["Default action",m??n?.defaultChatAction.key??"Pending"],["Adapter",Z(s.adapter.kind)],["Run",s.id],["Revision",String(s.revision)]]})}),e.jsx(V,{title:"Plan",children:n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"goal-details-summary",children:n.summary}),e.jsx(it,{rows:[["Objective",n.objective],["Context",n.capturedContextSummary],["Status",Z(n.status)],["Plan ID",n.id],["Run ID",n.runId],["Approval",n.approvalId??"Pending"],["Approved",n.approvedAt??"Not approved"]]})]}):u.length?e.jsx("p",{className:"goal-details-summary",children:"Waiting for answers before the model finalizes the Create plan."}):e.jsx("p",{className:"goal-details-summary",children:"The model is preparing the Create plan."})}),a?e.jsxs(V,{title:"Action Shape",children:[e.jsx(it,{rows:[["Mode",a.label],["Default action",a.defaultActionKey??"None"],["Direct action",a.directActionHint??"None planned"],["Artifacts",a.artifactPolicy]]}),e.jsx("p",{className:"goal-details-note",children:a.detail})]}):null,i.length?e.jsx(V,{title:"Questions",children:e.jsx("div",{className:"goal-details-list",children:i.map(o=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.title}),e.jsx("span",{className:`goal-details-inline-state ${o.status}`,children:Z(o.status)})]}),e.jsx("p",{children:o.prompt}),o.answer?e.jsxs("small",{children:["Answer: ",o.answer.label??o.answer.value]}):o.options.length?e.jsxs("small",{children:["Options: ",o.options.map(x=>x.label).join(", ")]}):null]},o.id))})}):null,n?.requirements.length?e.jsx(V,{title:"Setup Requirements",children:e.jsx("div",{className:"goal-details-list",children:n.requirements.map(o=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{className:`goal-details-inline-state ${o.status}`,children:Z(o.status)})]}),e.jsxs("small",{children:[Z(o.kind),o.detail?`: ${o.detail}`:""]})]},`${o.kind}:${o.name}`))})}):null,n?.sourcePlan.length?e.jsx(V,{title:"Source Plan",children:e.jsx(wt,{refs:n.sourcePlan.map(o=>({id:`${o.operation}:${o.path}`,primary:o.path,secondary:`${Z(o.operation)}: ${o.reason}`}))})}):null,n?.checks.length?e.jsx(V,{title:"Checks",children:e.jsx(wt,{refs:n.checks.map(o=>({id:o.name,primary:o.name,secondary:`${o.required?"Required":"Optional"}: ${o.command}`}))})}):null,c.length||f.length?e.jsx(V,{title:"Run Refs",children:e.jsx(wt,{refs:[...c.map(o=>({id:`source:${o}`,primary:o,secondary:"Source ref"})),...f.map(o=>({id:`check:${o}`,primary:o,secondary:"Check ref"}))]})}):null,e.jsx(fi,{run:s}),s.blockedReason?e.jsx(V,{title:"Blocked",children:e.jsxs("div",{className:"goal-details-alert",children:[e.jsx(tn,{size:15}),e.jsx("span",{children:s.blockedReason})]})}):null,e.jsx(V,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify(s,null,2)})]})})]})}function fi({run:t}){const s=[...t.context.attachments.map(i=>({id:`attachment:${i.id??i.name}`,primary:i.name,secondary:i.ref??i.mediaType??"Attachment"})),...t.context.apps.map(i=>({id:`app:${i.id}`,primary:i.name,secondary:i.required?"Required app context":"Optional app context"})),...t.context.tools.map(i=>({id:`tool:${i.name}`,primary:i.name,secondary:i.outputSummary??i.inputSummary??"Tool context"})),...t.context.targetRepoAssumptions.map(i=>({id:`target:${i}`,primary:i,secondary:"Target assumption"}))],n=t.workflowCapture,a=n?[...n.files.map(i=>({id:`workflow-file:${i}`,primary:i,secondary:"Captured file"})),...n.outputArtifacts.map(i=>({id:`workflow-artifact:${i}`,primary:i,secondary:"Output artifact"})),...n.traceRefs.map(i=>({id:`workflow-trace:${i}`,primary:i,secondary:"Trace"}))]:[];return!s.length&&!a.length?null:e.jsx(V,{title:"Context",children:e.jsx(wt,{refs:[...s,...a]})})}function pi({goalRuntime:t,subagentRuntime:s,onRunSubagentLifecycleAction:n}){return e.jsxs(e.Fragment,{children:[t?e.jsxs(V,{title:"Goal",children:[e.jsx("p",{className:"goal-details-summary",children:t.objective}),e.jsx(it,{rows:[["Status",t.actionLabel],["Runtime",t.timeLabel],["Detail",t.detail]]})]}):null,s?e.jsx(hi,{runtime:s,onRunSubagentLifecycleAction:n}):null,e.jsx(V,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify({goalRuntime:t,subagentRuntime:s},null,2)})]})})]})}function hi({runtime:t,onRunSubagentLifecycleAction:s}){const[n,a]=r.useState(null),[i,u]=r.useState(null);Fe(i);const c=async(f,h)=>{if(!s)return;const m=`${f}:${h}`;a(m),u(null);try{await s({runId:f,action:h})}catch(o){u(o instanceof Error?o.message:String(o))}finally{a(o=>o===m?null:o)}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{title:"Subagents",children:[e.jsx(it,{rows:[["Latest update",ki(t)],["Active",String(t.activeCount)],["Completed",String(t.completedCount)],["Failed",String(t.failedCount)],["Cancelled",String(t.cancelledCount)],["Paused",String(t.needsResumeCount)],["Terminal",String(t.terminalCount)],["Usage",wi(t.usage.totalTokens,t.usage.requestCount)],["Evidence",String(t.evidenceRefs.length)],["Checks",String(t.testsRunCount)]]}),t.blockers.length>0?e.jsx("ul",{className:"goal-details-list compact",children:t.blockers.slice(0,4).map(f=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${f.status}`,children:f.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(f.roleId)}),e.jsx("p",{children:f.message})]})]},`${f.runId}:${f.message}`))}):null,e.jsx("ul",{className:"goal-details-list",children:t.runs.slice(0,8).map(f=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${f.status}`,children:f.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(f.roleId)}),e.jsx("p",{children:f.objective}),f.report?.summary?e.jsx("small",{children:f.report.summary}):null,s?e.jsx(xi,{pendingAction:n,run:f,onRun:c}):null]})]},f.id))})]}),t.finalResults.length>0?e.jsx(mi,{results:t.finalResults}):null]})}function mi({results:t}){return e.jsx(V,{title:"Child Results",children:e.jsx("ol",{className:"goal-details-task-graph",children:t.slice(0,6).map(s=>e.jsxs("li",{className:"goal-details-task-node",children:[e.jsxs("div",{className:"goal-details-task-node-header",children:[e.jsx("span",{className:`goal-details-inline-state ${s.status}`,children:s.status}),e.jsxs("div",{children:[e.jsx("strong",{children:St(s.roleId)}),e.jsx("small",{children:s.objective})]})]}),e.jsx("p",{children:s.summary}),e.jsxs("div",{className:"goal-details-task-node-meta",children:[e.jsxs("span",{children:[s.refs.length," refs"]}),e.jsxs("span",{children:[s.testsRun.length+s.validationAttempts.length," checks"]}),e.jsxs("span",{children:[s.blockers.length," blockers"]}),e.jsx("span",{children:s.confidence?`${Z(s.confidence)} confidence`:"Confidence unknown"})]}),s.findings.length>0?e.jsxs("small",{children:["Findings: ",Ce(s.findings,3)]}):null,s.changedFiles.length>0?e.jsxs("small",{children:["Files: ",Ce(s.changedFiles,4)]}):null,s.testsRun.length>0?e.jsxs("small",{children:["Tests: ",Ce(s.testsRun,3)]}):null,s.validationAttempts.length>0?e.jsxs("small",{children:["Validation: ",Ce(s.validationAttempts,2)]}):null,s.refs.length>0?e.jsxs("small",{children:["Refs: ",Ce(s.refs.map(yi),4)]}):null,s.blockers.length>0?e.jsxs("small",{children:["Blockers: ",Ce(s.blockers,3)]}):null,s.workspaceRetention?e.jsxs("small",{children:["Workspace: ",Ni(s.workspaceRetention)]}):null,s.importantMessages.length>0?e.jsxs("small",{children:["Messages: ",Ce(s.importantMessages.map(Si),2)]}):null]},s.runId))})})}function xi({pendingAction:t,run:s,onRun:n}){const a=bi(s);return a.length===0?null:e.jsx("div",{className:"goal-details-actions",children:a.map(i=>{const u=`${s.id}:${i}`,c=t===u;return e.jsx("button",{type:"button",disabled:!!t,onClick:()=>{n(s.id,i)},children:c?"Working...":gi(i)},i)})})}function bi(t){const s=[],n=ji(t),a=vi(t);return n&&s.push("cleanup"),a&&s.push("archive"),s}function gi(t){return t==="cleanup"?"Clean":t==="archive"?"Archive":"Clean + archive"}function ji(t){if(!nn(t))return!1;const s=lt(t.metadata);if(!s?.subagentWorkspace&&!s?.workspaceHandoff)return!1;const n=lt(s.lifecycleCleanup),a=lt(n?.workspaceCleanup),i=an(a?.status);return i!=="removed"&&i!=="deleted"&&i!=="retained"&&i!=="skipped"}function vi(t){if(!t.childSessionId||!nn(t))return!1;const s=lt(lt(t.metadata)?.childSessionArchive),n=an(s?.status);return n!=="archived"&&n!=="already_archived"}function nn(t){return t.status==="completed"||t.status==="failed"||t.status==="cancelled"}function ki(t){const s=t.latestMeaningfulUpdate;return s?`${St(s.roleId)} ${s.status}: ${s.message}`:"No structured update"}function wi(t,s){if(t<=0&&s<=0)return"0 tokens";const n=`${s} ${s===1?"request":"requests"}`;return`${Ci(t)} tokens · ${n}`}function St(t){return t.slice(0,1).toUpperCase()+t.slice(1).replace(/[-_]+/g," ")}function yi(t){return`${t.kind}: ${t.label}`}function Si(t){return`${Z(t.kind)}: ${t.body}`}function Ni(t){const s=t.expiresAt?`until ${Ri(t.expiresAt)}`:"for inspection",n=t.trigger?` · ${Z(t.trigger)}`:"";return`retained ${s}${n}`}function Ce(t,s){const n=t.slice(0,s),a=t.length-n.length;return a>0?`${n.join(", ")} +${a}`:n.join(", ")}function Ci(t){if(t<1e3)return String(t);if(t>=1e6){const n=t/1e6;return`${Vs(n,n<10?2:1)}M`}const s=t/1e3;return`${Vs(s,s<10?1:0)}k`}function Ri(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Vs(t,s){return t.toFixed(s).replace(/\.0+$/,"").replace(/(\.\d*?)0+$/,"$1")}function $i(){return e.jsxs("div",{className:"goal-details-empty",children:[e.jsx(rt,{size:18}),e.jsx("span",{children:"No active Goal or Create workflow."})]})}function V({children:t,title:s}){return e.jsxs("section",{className:"goal-details-section",children:[e.jsx("h2",{children:s}),t]})}function it({rows:t}){return e.jsx("dl",{className:"goal-details-grid",children:t.map(([s,n])=>e.jsxs("div",{children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:n})]},s))})}function wt({refs:t}){return e.jsx("ul",{className:"goal-details-ref-list",children:t.map(s=>e.jsxs("li",{children:[e.jsx("code",{title:s.primary,children:s.primary}),e.jsx("span",{children:s.secondary})]},s.id))})}function lt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function an(t){return typeof t=="string"&&t.trim()?t.trim():null}function Z(t){return t.split(/[_-]/g).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Fi(t){return t==="ready_local"||t==="published_hosted"?"success":t==="blocked"||t==="failed"||t==="cancelled"?"danger":t==="awaiting_questions"||t==="awaiting_plan_approval"?"warning":"active"}function Ei({sandboxId:t,connection:s}){const[n,a]=r.useState(null),[i,u]=r.useState([]),[c,f]=r.useState(null),[h,m]=r.useState(null),[o,x]=r.useState(null),[S,k]=r.useState(null);Fe(o,{prefix:"Sandbox"}),Fe(S,{prefix:"Sandbox integrations"});const N=n?.integrationLeases??[],E=r.useMemo(()=>i.filter(j=>j.status==="active"),[i]),_=r.useMemo(()=>Pi(n),[n]),W=r.useCallback(async()=>{if(!s){x("OpenPond App server is not connected.");return}if(!t){a(null),u([]),x(null);return}f("summary"),x(null);try{const j=await I.sandbox(s,t),R=await I.integrationConnections(s,Ks(j.sandbox));a(j.sandbox),u(R.connections),k(null)}catch(j){x(j instanceof Error?j.message:String(j))}finally{f(null)}},[s,t]),K=r.useCallback(async()=>{if(!(!s||!n)){m("load"),k(null);try{const[j,R]=await Promise.all([I.integrationConnections(s,Ks(n)),I.sandboxIntegrationLeases(s,n.id)]);u(j.connections),a(R.sandbox)}catch(j){k(j instanceof Error?j.message:String(j))}finally{m(null)}}},[s,n]),U=r.useCallback(async j=>{if(!s||!n)return;const R=$t(j.provider),T=R?Ft(R):null,M=T?.leasePolicy.allowedCapabilityIds??[];if(!R||!T?.leasePolicy.leaseable||M.length===0){k(`${ae(j.provider)} cannot be attached to this sandbox.`);return}m(`attach:${j.id}`),k(null);try{const A=await I.attachSandboxIntegrationConnection(s,n.id,{connectionId:j.id,provider:j.provider,capabilities:M,...j.scopes.length>0?{scopes:j.scopes}:{},...T.leasePolicy.defaultTtlSeconds?{ttlSeconds:T.leasePolicy.defaultTtlSeconds}:{},required:!1});a(A.sandbox)}catch(A){k(A instanceof Error?A.message:String(A))}finally{m(null)}},[s,n]),B=r.useCallback(async j=>{if(!(!s||!n)){m(`remove:${j}`),k(null);try{const R=await I.removeSandboxIntegrationLease(s,n.id,j);a(R.sandbox)}catch(R){k(R instanceof Error?R.message:String(R))}finally{m(null)}}},[s,n]);return r.useEffect(()=>{W()},[W]),t?e.jsxs("div",{className:"sandbox-summary-tab",children:[e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Sandbox"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[n?e.jsx("span",{children:n.state}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh summary","aria-label":"Refresh summary",disabled:c!==null,onClick:()=>{W()},children:c==="summary"?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(as,{size:14})})]})]}),n?e.jsxs("dl",{className:"sandbox-workspace-kv",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Sandbox"}),e.jsx("dd",{children:Gs(n.id)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Spend"}),e.jsxs("dd",{children:[Yt(n.reservation.capturedUsd)," / ",Yt(n.budget.maxUsd)]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reservation"}),e.jsx("dd",{children:n.reservation.status})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Idle cleanup"}),e.jsx("dd",{children:n.quotas?.idleTimeoutSeconds?`${Math.round(n.quotas.idleTimeoutSeconds/60)} min`:"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:ln(n.updatedAt)})]}),_?e.jsxs("div",{children:[e.jsx("dt",{children:"Receipt"}),e.jsxs("dd",{children:[Gs(_.id)," / ",Yt(_.totalUsd)]})]}):null]}):e.jsxs("div",{className:"sandbox-workspace-loading",children:[c==="summary"?e.jsx(Oe,{className:"spinning",size:16}):null,e.jsx("span",{children:c==="summary"?"Loading sandbox":"Sandbox unavailable"})]})]}),e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Integrations"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[e.jsx("span",{children:N.length}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh integrations","aria-label":"Refresh integrations",disabled:h!==null||!n,onClick:()=>{K()},children:h==="load"?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(as,{size:14})})]})]}),N.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:N.map(j=>e.jsxs("div",{className:"sandbox-workspace-integration-row",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:ae(j.provider)}),e.jsxs("small",{children:[j.required?"required":"optional"," / ",Ti(j)," / ",Ai(j)]})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:`Revoke ${ae(j.provider)} lease`,"aria-label":`Revoke ${ae(j.provider)} lease`,disabled:h!==null,onClick:()=>{B(j.leaseId)},children:h===`remove:${j.leaseId}`?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(Da,{size:14})}),e.jsxs("div",{className:"sandbox-workspace-chip-row",children:[j.capabilities.slice(0,5).map(R=>e.jsx("span",{children:Di(j.provider,R)},R)),j.capabilities.length>5?e.jsxs("span",{children:["+",j.capabilities.length-5]}):null]})]},j.leaseId))}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No active integration leases."}),E.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:E.map(j=>{const R=N.some(A=>A.provider===j.provider),M=Li(j)?.leasePolicy.allowedCapabilityIds.length??0;return e.jsxs("div",{className:"sandbox-workspace-integration-row compact",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:_i(j)}),e.jsx("small",{children:Mi(j,M)})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:R?`${ae(j.provider)} already attached`:`Attach ${ae(j.provider)}`,"aria-label":R?`${ae(j.provider)} already attached`:`Attach ${ae(j.provider)}`,disabled:R||h!==null||M===0,onClick:()=>{U(j)},children:h===`attach:${j.id}`?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(da,{size:14})})]},j.id)})}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No connected accounts available."})]})]}):e.jsx("div",{className:"sandbox-summary-tab",children:e.jsx("p",{className:"sandbox-workspace-empty",children:"No sandbox is attached yet."})})}function Ks(t){return{status:"active"}}function Ai(t){return t.proxyUrl?"runtime proxy available":"metadata only, no runtime proxy"}function Pi(t){return t?.receipts?.at(-1)??null}function Li(t){const s=$t(t.provider);return s?Ft(s):null}function ae(t){const s=$t(t),n=s?Ft(s):null;return n?n.label:t==="microsoft_teams"?"Microsoft Teams":t?t.replace(/_/g," "):"Integration"}function Di(t,s){const n=$t(t);return(n?Ft(n):null)?.capabilities.find(i=>i.id===s)?.label??s}function Ti(t){return t.expiresAt?`expires ${ln(t.expiresAt)}`:"active"}function _i(t){const s=t.providerAccountName?.trim();return s?`${ae(t.provider)} / ${s}`:ae(t.provider)}function Mi(t,s){const n=[];return t.providerWorkspaceName&&n.push(t.providerWorkspaceName),n.push(`${s} lease ${s===1?"capability":"capabilities"}`),t.scopes.length>0&&n.push(`${t.scopes.length} ${t.scopes.length===1?"scope":"scopes"}`),n.join(" / ")}function Gs(t){return t.length>10?`${t.slice(0,8)}...`:t}function ln(t){if(!t)return"-";const s=new Date(t);return Number.isNaN(s.valueOf())?"-":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function Yt(t){const s=Number(t??0);return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:s>=10?2:4}).format(Number.isFinite(s)?s:0)}function zi({summary:t}){const s=Ba(t.taskset),n=t.taskset.learningSignals.demonstrations.filter(c=>c.approved).length,a=t.taskset.tasks.filter(c=>c.split==="frozen_eval").length,i=t.plan?.recipe.method==="sft"||t.plan?.recipe.method==="grpo"?t.plan.recipe:null,u=Oa(t.taskset,t.plan);return e.jsxs("div",{className:"training-sidebar-summary",children:[e.jsxs("header",{children:[e.jsx("h2",{children:Ua(t.taskset.name)}),e.jsx("span",{children:t.job?Ha(t.job.status):t.taskset.readiness?.ready?"Ready to train":"Needs review"})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Run"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Primary recommendation",value:s.toUpperCase()}),e.jsx(O,{label:"Training stage",value:u}),e.jsx(O,{label:"Base model",value:i?.baseModel.id??"Not selected"}),e.jsx(O,{label:"Compute",value:t.plan?Va(t.plan.destinationId):"Not selected"}),e.jsx(O,{label:"Started",value:Ka(t.job?.startedAt??null)}),e.jsx(O,{label:"Duration",value:Ga(t.job?.startedAt??null,t.job?.completedAt??null)})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Data"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Training examples",value:String(n)}),e.jsx(O,{label:"Test examples",value:String(a)}),e.jsx(O,{label:"Dataset sources",value:String(t.taskset.sourceRefs.length)})]})]}),i?e.jsxs("section",{children:[e.jsx("h3",{children:"Recipe"}),e.jsxs("dl",{children:[i.method==="grpo"?e.jsx(O,{label:"RL loss",value:i.loss.method==="gspo-token"?"GSPO-token":i.loss.method.toUpperCase()}):null,e.jsx(O,{label:"LoRA rank",value:String(i.lora.rank)}),e.jsx(O,{label:"Learning rate",value:String(i.optimizer.learningRate)}),e.jsx(O,{label:"Optimizer steps",value:String(i.optimizer.maxSteps)}),e.jsx(O,{label:i.method==="grpo"?"Prompt length":"Sequence length",value:String(i.method==="grpo"?i.dataset.maxPromptTokens:i.dataset.maxSequenceLength)})]})]}):null,e.jsxs("section",{children:[e.jsx("h3",{children:"Result"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Adapter",value:t.lineage?`${u} ready`:"Not created"}),e.jsx(O,{label:"Evaluation",value:t.lineage?.frozenEvaluationArtifactId?"Completed":"Not completed"}),e.jsx(O,{label:"Artifacts",value:String(t.artifacts.length)})]})]})]})}function O({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ii(t){const s=qs("","","folder");for(const n of t){const a=n.endsWith("/"),i=n.split("/").filter(Boolean);if(i.length===0)continue;let u=s,c="";for(let f=0;f<i.length;f+=1){const h=i[f];c=c?`${c}/${h}`:h;const m=!a&&f===i.length-1?"file":"folder",o=`${m}:${h}`;let x=u.childMap.get(o);x||(x=qs(h,c,m),u.childMap.set(o,x),u.children.push(x)),u=x}}return rn(s.children)}function qs(t,s,n){return{name:t,path:s,type:n,children:[],childMap:new Map}}function rn(t){return t.sort((s,n)=>s.type!==n.type?s.type==="folder"?-1:1:s.name.localeCompare(n.name)).map(s=>({name:s.name,path:s.path,type:s.type,children:rn(s.children)}))}function is({className:t,currentStatus:s,onSetStatus:n}){const a=s==="pinned",i=s==="saved_for_later";return e.jsxs("span",{className:`workspace-file-bookmark-actions ${t??"workspace-file-heading-actions"}`,children:[e.jsx("button",{type:"button",className:a?"active":void 0,"data-tooltip":a?"Unpin file":"Pin file","aria-label":a?"Unpin file":"Pin file","aria-pressed":a,onClick:()=>n(a?"none":"pinned"),children:a?e.jsx(ua,{size:14}):e.jsx(fa,{size:14})}),e.jsx("button",{type:"button",className:i?"active":void 0,"data-tooltip":i?"Remove from Save for later":"Save file for later","aria-label":i?"Remove from Save for later":"Save file for later","aria-pressed":i,onClick:()=>n(i?"none":"saved_for_later"),children:i?e.jsx(pa,{size:14}):e.jsx(ha,{size:14})})]})}function Wi({changedByPath:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h}){const m=r.useMemo(()=>Ii(a),[a]);return e.jsxs("div",{className:"workspace-file-tree-view",children:[e.jsxs("div",{className:"workspace-file-tree-header",children:[e.jsx(yt,{size:14}),e.jsx("strong",{title:n??void 0,children:n?n.split("/").at(-1):"Files"}),e.jsx("span",{children:a.length})]}),e.jsx("div",{className:"workspace-file-tree",children:m.map(o=>e.jsx(on,{changedByPath:t,expandedFolderPaths:s,node:o,rootPath:n,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h},`${o.type}:${o.path}`))})]})}function on({changedByPath:t,depth:s=0,expandedFolderPaths:n,node:a,rootPath:i,selectedPath:u,getFileBookmarkStatus:c,onOpenFile:f,onSetFileBookmarkStatus:h,onToggleFolder:m}){const o=i?`${i}/${a.path}`:a.path,x=a.type==="folder"&&n.has(o),S=t.get(o),k=2+s*11;return a.type==="folder"?e.jsxs("div",{className:"workspace-file-tree-node",children:[e.jsxs("button",{type:"button",className:"workspace-file-tree-row folder","aria-expanded":x,style:{paddingLeft:k},onClick:()=>m(o),children:[x?e.jsx(yt,{size:14}):e.jsx(ma,{size:14}),e.jsx("span",{children:a.name})]}),x&&a.children.map(N=>e.jsx(on,{changedByPath:t,depth:s+1,expandedFolderPaths:n,node:N,rootPath:i,selectedPath:u,getFileBookmarkStatus:c,onOpenFile:f,onSetFileBookmarkStatus:h,onToggleFolder:m},`${N.type}:${N.path}`))]}):e.jsxs("div",{className:`workspace-file-tree-row file ${S?"changed":""} ${u===o?"selected":""}`,style:{paddingLeft:k},children:[e.jsxs("button",{type:"button",className:"workspace-file-tree-row-main",title:o,onClick:()=>f(o),children:[e.jsx(Ta,{size:13}),e.jsx("span",{children:a.name}),S&&e.jsxs("small",{children:[e.jsxs("span",{className:"diff-addition",children:["+",S.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",S.deletions]})]})]}),h?e.jsx(is,{className:"workspace-file-tree-bookmark-actions",currentStatus:c?.(o)??null,onSetStatus:N=>h(o,N)}):null]})}function Xs({diff:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h}){const m=t?.files??[],o=r.useMemo(()=>new Map(m.map(k=>[k.path,k])),[m]),x=n?.replace(/^\/+|\/+$/g,"")||null,S=r.useMemo(()=>{if(!x)return a;const k=`${x}/`;return a.filter(N=>N.startsWith(k)).map(N=>N.slice(k.length)).filter(Boolean)},[x,a]);return e.jsx("div",{className:"workspace-diff-files-view",children:e.jsx(Wi,{changedByPath:o,expandedFolderPaths:s,rootPath:x,repoFiles:S,selectedPath:i,getFileBookmarkStatus:u,onOpenFile:c,onSetFileBookmarkStatus:f,onToggleFolder:h})})}function Bi({collapsed:t,editorControlsVisible:s,hideWhiteSpace:n,loadFullFiles:a,renderMarkdown:i,wordDiffs:u,wordWrap:c,onClose:f,onCopyGitApply:h,onRefresh:m,onToggleCollapsed:o,onToggleEditorControlsVisible:x,onToggleHideWhiteSpace:S,onToggleLoadFullFiles:k,onToggleRenderMarkdown:N,onToggleWordDiffs:E,onToggleWordWrap:_}){return e.jsxs("div",{className:"workspace-diff-options-menu",role:"menu",children:[e.jsx(ce,{icon:e.jsx(as,{size:14}),label:"Refresh",onClick:m,onClose:f}),e.jsx(ce,{checked:c,icon:e.jsx(_a,{size:14}),label:"Enable word wrap",onClick:_,onClose:f}),e.jsx(ce,{checked:t,icon:e.jsx(Ja,{size:14}),label:"Collapse all diffs",onClick:o,onClose:f}),e.jsx("div",{className:"workspace-diff-menu-divider"}),e.jsx(ce,{checked:s,icon:e.jsx(ii,{size:14}),label:"Show editor controls",onClick:x,onClose:f}),e.jsx(ce,{checked:i,icon:e.jsx(sn,{size:14}),label:"Render Markdown",onClick:N,onClose:f}),e.jsx(ce,{checked:!a,icon:e.jsx(rt,{size:14}),label:"Show diffs first",onClick:k,onClose:f}),e.jsx(ce,{checked:u,icon:e.jsx(Qa,{size:14}),label:"Enable word diffs",onClick:E,onClose:f}),e.jsx(ce,{checked:n,icon:e.jsx(ni,{size:14}),label:"Hide white space",onClick:S,onClose:f}),e.jsx(ce,{icon:e.jsx(Ma,{size:14}),label:"Copy git apply command",onClick:h,onClose:f})]})}function ce({checked:t,icon:s,label:n,onClick:a,onClose:i}){return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a?.(),i()},children:[s,e.jsx("span",{children:n}),t&&e.jsx(xa,{size:14})]})}function Oi({addMenuOpen:t,expanded:s,filteredFiles:n,dirtyFilePaths:a,openFiles:i,goalDetailsAvailable:u,searchOpen:c,searchQuery:f,selectedPath:h,sideChatTabs:m=[],summaryAvailable:o,sourceStatus:x,sourceSwitcher:S,visibleTab:k,getFileBookmarkStatus:N,onCloseFileTab:E,onCloseSideChat:_,onCloseSearch:W,onOpenFile:K,onOpenBrowser:U,onOpenSearch:B,onOpenSideChat:j,onSearchQueryChange:R,onSetFileBookmarkStatus:T,onSelectFile:M,onSelectFiles:A,onSelectGoal:Q,onSelectSummary:q,onSelectSideChat:z,onToggleAddMenu:H,onToggleExpanded:le}){const re=r.useRef(null);r.useEffect(()=>{if(!t&&!c)return;function w(){t&&H(),c&&W()}function F(de){re.current?.contains(de.target)||w()}function D(de){de.key==="Escape"&&w()}return document.addEventListener("pointerdown",F),document.addEventListener("keydown",D),()=>{document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",D)}},[t,W,H,c]);function Y(w){if(w.key==="Escape"){W();return}w.key==="Enter"&&n[0]&&K(n[0])}function J(w){if(!["ArrowRight","ArrowLeft","Home","End"].includes(w.key))return;const F=w.target;if(!(F instanceof HTMLButtonElement)||F.getAttribute("role")!=="tab")return;const D=Array.from(w.currentTarget.querySelectorAll('button[role="tab"]')),de=D.indexOf(F);if(de<0||D.length===0)return;w.preventDefault();const Et=ya(de,D.length,w.key),Ae=D[Et];if(!Ae)return;Ae.focus(),Ae.click();const X=Ae.id;X&&window.requestAnimationFrame(()=>document.getElementById(X)?.focus())}return e.jsxs("div",{className:"workspace-diff-topbar",children:[e.jsxs("div",{className:"workspace-diff-tabs",role:"tablist","aria-label":"Right sidebar views",onKeyDown:J,children:[u?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="goal"?"active":""}`,role:"tab","aria-selected":k==="goal",onClick:Q,children:[e.jsx(rt,{size:14}),e.jsx("span",{children:"Goal"})]}):null,o&&q?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="summary"?"active":""}`,role:"tab","aria-selected":k==="summary",onClick:q,children:[e.jsx(Hs,{size:14}),e.jsx("span",{children:"Summary"})]}):null,e.jsxs("button",{type:"button",className:`workspace-diff-tab ${k==="files"?"active":""}`,role:"tab",id:"right-sidebar-files-tab","aria-controls":"right-sidebar-files-panel","aria-selected":k==="files",tabIndex:k==="files"?0:-1,onClick:A,children:[e.jsx(yt,{size:14}),e.jsx("span",{children:"Files"})]}),i.map(w=>e.jsxs("div",{className:`workspace-diff-tab file ${k==="file"&&h===w.path?"active":""}`,children:[e.jsxs("button",{type:"button",className:"workspace-diff-tab-main",role:"tab","aria-selected":k==="file"&&h===w.path,title:w.path,onClick:()=>M(w.path),children:[e.jsx(rt,{className:"workspace-diff-tab-icon",size:13}),a.has(w.path)&&e.jsx("span",{className:"workspace-diff-tab-dirty","aria-hidden":"true"}),e.jsx("span",{children:w.path.split("/").pop()})]}),T?e.jsx(is,{className:"workspace-diff-tab-bookmark-actions",currentStatus:N?.(w.path)??null,onSetStatus:F=>T(w.path,F)}):null,e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${w.path}`,onClick:F=>E(w.path,F),children:e.jsx(Is,{size:12})})]},w.path)),m.map(w=>e.jsxs("div",{className:"workspace-diff-tab right-chat-tab",children:[e.jsxs("button",{type:"button",className:"workspace-diff-tab-main",role:"tab",id:`right-chat-tab-${w.id}`,"aria-controls":`right-chat-panel-${w.id}`,"aria-selected":!1,tabIndex:-1,title:w.title,onClick:()=>z?.(w.id),children:[w.running?e.jsx("span",{className:"right-chat-status-dot","aria-label":"Running"}):null,e.jsx("span",{children:w.title})]}),_?e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${w.title}`,"aria-label":`Close ${w.title}`,onClick:F=>{F.stopPropagation(),_(w.id)},children:e.jsx(Is,{size:12})}):null]},w.id)),e.jsxs("div",{className:"workspace-diff-add-anchor",ref:re,children:[e.jsx("button",{type:"button",className:`workspace-diff-add-tab ${t||c?"active":""}`,title:"Add","aria-label":"Add to right sidebar",onClick:H,children:e.jsx(ba,{size:15})}),t&&e.jsxs("div",{className:"workspace-diff-add-menu",role:"menu",children:[j?e.jsxs("button",{type:"button",role:"menuitem",onClick:j,children:[e.jsx(ga,{size:14}),e.jsx("span",{children:"New task"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:A,children:[e.jsx(yt,{size:14}),e.jsx("span",{children:"Files"}),e.jsx("kbd",{})]}),o&&q?e.jsxs("button",{type:"button",role:"menuitem",onClick:q,children:[e.jsx(Hs,{size:14}),e.jsx("span",{children:"Summary"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:B,children:[e.jsx(ja,{size:14}),e.jsx("span",{children:"Open file"}),e.jsx("kbd",{children:"Ctrl+P"})]}),U?e.jsxs("button",{type:"button",role:"menuitem",onClick:U,children:[e.jsx(va,{size:14}),e.jsx("span",{children:"Browser"}),e.jsx("kbd",{children:"Ctrl+I"})]}):null]}),c&&e.jsxs("div",{className:"workspace-file-search-popover",children:[e.jsx("input",{autoFocus:!0,placeholder:"Search files",value:f,onChange:w=>R(w.target.value),onKeyDown:Y}),e.jsx("span",{children:"Files"}),e.jsx("div",{className:"workspace-file-search-results",children:n.length===0?e.jsx("small",{children:"Type to search for files"}):n.map(w=>e.jsx("button",{type:"button",onClick:()=>K(w),children:w},w))})]})]})]}),S||x?e.jsxs("div",{className:"workspace-diff-source-bar","aria-label":"Workspace source",children:[S?e.jsx("div",{className:"workspace-diff-source-toggle",role:"group","aria-label":"File source",children:S.options.map(w=>e.jsx("button",{type:"button",className:S.value===w.value?"active":"","aria-pressed":S.value===w.value,onClick:()=>S.onChange(w.value),children:w.label},w.value))}):null,x?e.jsx("span",{className:`workspace-diff-source-status ${x.tone}`,children:x.label}):null]}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:s?"Restore files panel":"Expand files panel","aria-label":s?"Restore files panel":"Expand files panel",onClick:le,children:s?e.jsx(za,{size:14}):e.jsx(ka,{size:14})})]})}function Ui({canCheckActiveFile:t,canSaveActiveFile:s,collapsed:n,editorControlsVisible:a,editorDiagnosticStatus:i,editorDiagnosticsChecking:u,hideWhiteSpace:c,loadFullFiles:f,menuOpen:h,renderMarkdown:m,showEditorCommandBar:o,showRenderMarkdownToggle:x,splitView:S,wordDiffs:k,wordWrap:N,onCopyGitApply:E,onEditorCheck:_,onEditorRedo:W,onEditorSave:K,onEditorUndo:U,onRefresh:B,onToggleCollapsed:j,onToggleEditorControlsVisible:R,onToggleHideWhiteSpace:T,onToggleLoadFullFiles:M,onToggleMenu:A,onToggleRenderMarkdown:Q,onToggleSplitView:q,onToggleWordDiffs:z,onToggleWordWrap:H}){return e.jsx("div",{className:"workspace-diff-toolbar",children:e.jsxs("div",{className:"workspace-diff-toolbar-actions",children:[e.jsxs("div",{className:"workspace-diff-menu-anchor",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Diff options","aria-haspopup":"menu","aria-expanded":h,onClick:()=>A(),children:e.jsx(wa,{size:15})}),h&&e.jsx(Bi,{collapsed:n,editorControlsVisible:a,hideWhiteSpace:c,loadFullFiles:f,renderMarkdown:m,wordDiffs:k,wordWrap:N,onClose:()=>A(!1),onCopyGitApply:E,onRefresh:B,onToggleCollapsed:j,onToggleEditorControlsVisible:R,onToggleHideWhiteSpace:T,onToggleLoadFullFiles:M,onToggleRenderMarkdown:Q,onToggleWordDiffs:z,onToggleWordWrap:H})]}),o&&e.jsxs("div",{className:"workspace-editor-command-bar","aria-label":"Editor controls",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Save file","aria-label":"Save file",disabled:!s,onClick:K,children:e.jsx(qa,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Undo","aria-label":"Undo",onClick:U,children:e.jsx(ci,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Redo","aria-label":"Redo",onClick:W,children:e.jsx(ri,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Check file","aria-label":"Check file",disabled:!t,onClick:_,children:u?e.jsx(Oe,{className:"spinning",size:14}):e.jsx(Ws,{size:14})}),i&&e.jsxs("span",{className:`workspace-editor-diagnostic-chip ${i.severity}`,children:[i.severity==="error"||i.severity==="warning"||i.severity==="unavailable"?e.jsx(tn,{size:13}):e.jsx(Ws,{size:13}),e.jsx("span",{children:i.label})]})]}),x&&e.jsx("button",{type:"button",className:`diff-icon-button ${m?"active":""}`,title:m?"Show Markdown source":"Render Markdown","aria-label":m?"Show Markdown source":"Render Markdown","aria-pressed":m,onClick:Q,children:e.jsx(sn,{size:14})}),e.jsx("button",{type:"button",className:`diff-icon-button ${S?"active":""}`,title:S?"Show unified diff":"Show split diff","aria-label":S?"Show unified diff":"Show split diff","aria-pressed":S,onClick:q,children:e.jsx(ti,{size:14})})]})})}const Hi={cjs:"typescript",css:"css",html:"html",js:"typescript",json:"json",jsx:"typescript",md:"markdown",mjs:"typescript",py:"python",sh:"shell",ts:"typescript",tsx:"typescript",yaml:"yaml",yml:"yaml"};function ls(t){const s=t.split("/").pop()?.toLowerCase()??"";if(s==="dockerfile")return"shell";if(s==="readme"||s==="readme.md")return"markdown";const n=s.includes(".")?s.split(".").pop()??"":"";return Hi[n]??"text"}function Vi(t,s){return t?s==="markdown"?Ki(t):s==="json"?$e(t,/("(?:\\.|[^"\\])*"(?=\s*:)|"(?:\\.|[^"\\])*"|[-]?\b\d+(?:\.\d+)?\b|\btrue\b|\bfalse\b|\bnull\b|[{}[\]:,])/g):s==="css"?$e(t,/(\/\*.*?\*\/|#[\da-fA-F]{3,8}\b|--[\w-]+|[.#]?[\w-]+(?=\s*:)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw)?\b|[{}():;,])/g):s==="html"?$e(t,/(<!--.*?-->|<\/?[\w-]+|[\w:-]+(?==)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[<>/=])/g):s==="shell"?$e(t,/(#.*$|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:cd|cp|export|git|npm|pnpm|bun|yarn|rm|mkdir|test|if|then|fi|for|do|done|echo)\b|\$[\w_]+|&&|\|\||[|&;=])/g):s==="python"?$e(t,/(#.*$|"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:class|def|return|if|elif|else|for|while|try|except|finally|with|as|import|from|None|True|False|async|await|lambda|yield)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|.:,()[\]{}]+)/g):$e(t,/(\/\/.*$|\/\*.*?\*\/|`(?:\\.|[^`\\])*`|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:abstract|as|async|await|boolean|break|case|catch|class|const|continue|default|else|enum|export|extends|false|finally|for|from|function|if|import|in|interface|let|new|null|number|of|return|string|switch|throw|true|try|type|undefined|void|while)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|?:.,()[\]{}]+)/g):[{text:" ",kind:"plain"}]}function Ki(t){return/^\s{0,3}#{1,6}\s/.test(t)?[{text:t,kind:"keyword"}]:/^\s*[-*+]\s/.test(t)?[{text:t,kind:"property"}]:$e(t,/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\([^)]+\)|https?:\/\/\S+)/g)}function Gi(t){return/^(\/\/|#|\/\*|<!--)/.test(t)?"comment":/^["'`]/.test(t)?"string":/^[-]?\d/.test(t)||/^#[\da-fA-F]{3,8}\b/.test(t)?"number":/^\b[A-Z]/.test(t)?"type":/^[.#]?[\w-]+$/.test(t)&&t.includes("-")?"property":/^(?:[{}()[\],.:;<>/=+\-*&|!?%]+)$/.test(t)?"operator":/^(?:--|\$)/.test(t)?"property":"keyword"}function $e(t,s){const n=[];let a=0;for(const i of t.matchAll(s)){const u=i.index??0;u>a&&n.push({text:t.slice(a,u),kind:"plain"});const c=i[0];if(n.push({text:c,kind:Gi(c)}),a=u+c.length,/^(\/\/|#|<!--)/.test(c))break}return a<t.length&&n.push({text:t.slice(a),kind:"plain"}),n.length>0?n:[{text:t,kind:"plain"}]}function Nt({language:t,text:s}){return e.jsx(e.Fragment,{children:Vi(s,t).map((n,a)=>e.jsx("span",{className:`syntax-token ${n.kind}`,children:n.text},`${a}-${n.text}`))})}const qi=`
3
3
 
4
- [file truncated]`,Xi=r.lazy(()=>Ra(()=>import("./WorkspaceMonacoEditor-3g05teoR.js").then(t=>t.jc),__vite__mapDeps([0,1,2,3]),import.meta.url)),Jt=6,Zi=18,Re=22,Zs=44,Qi=160,Qs=12;function Ct({path:t,workspaceName:s,workspaceRootPath:n,onSelectPath:a}){const i=ss(t,n),u=Na(i),c=u?Yi(i):s?.trim()||"Workspace",h=(u&&c!=="/"&&i.startsWith(`${c}/`)?i.slice(c.length+1):i).split("/").filter(Boolean),m=!!(a&&!u);return e.jsxs("span",{className:"workspace-file-breadcrumbs",title:u?i:`${c} > ${i}`,children:[a&&!u?e.jsx("button",{type:"button",onClick:()=>a(null),children:c}):e.jsx("span",{children:c}),h.map((o,x)=>{const S=x===h.length-1,k=h.slice(0,x+1).join("/");return e.jsxs("span",{className:"workspace-file-breadcrumb-segment",children:[e.jsx(Ca,{size:13}),a&&m&&!S?e.jsx("button",{type:"button",onClick:()=>a(k),children:o}):e.jsx("span",{children:o})]},`${x}-${o}`)})]})}function Yi(t){const s=/^[A-Za-z]:\//.exec(t);return s?s[0].slice(0,-1):"/"}function Ji({collapsed:t=!1,diagnostics:s=[],draftContent:n,editable:a=!1,editorRef:i,error:u,file:c,hideWhiteSpace:f=!1,headerActions:h,imageSrc:m,loading:o,loadFullFiles:x,onOpenImage:S,onSelectBreadcrumbPath:k,onDraftContentChange:N,onLspAction:E,onSave:_,renderMarkdown:W,saveError:K,saving:U=!1,splitView:B=!1,wordDiffs:j=!1,wordWrap:R,workspaceName:T,workspaceRootPath:M}){Fe(u,{prefix:"File preview"}),Fe(K,{prefix:"Save failed"});const A=n??c.content??"",Q=r.useMemo(()=>A.split(`
4
+ [file truncated]`,Xi=r.lazy(()=>Ra(()=>import("./WorkspaceMonacoEditor-DPv-1uO6.js").then(t=>t.jc),__vite__mapDeps([0,1,2,3]),import.meta.url)),Jt=6,Zi=18,Re=22,Zs=44,Qi=160,Qs=12;function Ct({path:t,workspaceName:s,workspaceRootPath:n,onSelectPath:a}){const i=ss(t,n),u=Na(i),c=u?Yi(i):s?.trim()||"Workspace",h=(u&&c!=="/"&&i.startsWith(`${c}/`)?i.slice(c.length+1):i).split("/").filter(Boolean),m=!!(a&&!u);return e.jsxs("span",{className:"workspace-file-breadcrumbs",title:u?i:`${c} > ${i}`,children:[a&&!u?e.jsx("button",{type:"button",onClick:()=>a(null),children:c}):e.jsx("span",{children:c}),h.map((o,x)=>{const S=x===h.length-1,k=h.slice(0,x+1).join("/");return e.jsxs("span",{className:"workspace-file-breadcrumb-segment",children:[e.jsx(Ca,{size:13}),a&&m&&!S?e.jsx("button",{type:"button",onClick:()=>a(k),children:o}):e.jsx("span",{children:o})]},`${x}-${o}`)})]})}function Yi(t){const s=/^[A-Za-z]:\//.exec(t);return s?s[0].slice(0,-1):"/"}function Ji({collapsed:t=!1,diagnostics:s=[],draftContent:n,editable:a=!1,editorRef:i,error:u,file:c,hideWhiteSpace:f=!1,headerActions:h,imageSrc:m,loading:o,loadFullFiles:x,onOpenImage:S,onSelectBreadcrumbPath:k,onDraftContentChange:N,onLspAction:E,onSave:_,renderMarkdown:W,saveError:K,saving:U=!1,splitView:B=!1,wordDiffs:j=!1,wordWrap:R,workspaceName:T,workspaceRootPath:M}){Fe(u,{prefix:"File preview"}),Fe(K,{prefix:"Save failed"});const A=n??c.content??"",Q=r.useMemo(()=>A.split(`
5
5
  `).slice(0,800),[A]),q=ls(c.path),z=n!=null||c.content!=null,H=A.endsWith(qi),le=W&&z&&ts(c.path),re=z&&Sa(c.path)&&al(A);return m?e.jsxs("div",{className:"workspace-file-preview",children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(Ct,{path:c.path,workspaceName:T,workspaceRootPath:M,onSelectPath:k}),e.jsxs("span",{className:"diff-addition",children:["+",c.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",c.deletions]})]}),h]}),e.jsx("div",{className:"workspace-file-image-stage",children:e.jsx("button",{type:"button",className:"workspace-file-image-button","aria-label":`Open image preview for ${c.path}`,onClick:S,children:e.jsx("img",{alt:c.path,decoding:"async",src:m})})})]}):!x&&c.patch||!z&&c.patch?B?e.jsx(tl,{collapsed:t,file:c,hideWhiteSpace:f,onSelectBreadcrumbPath:k,wordDiffs:j,wordWrap:R,headerActions:h,workspaceName:T,workspaceRootPath:M}):e.jsx(el,{collapsed:t,file:c,hideWhiteSpace:f,wordWrap:R,workspaceName:T,workspaceRootPath:M,onSelectBreadcrumbPath:k,headerActions:h}):e.jsxs("div",{className:`workspace-file-preview ${R?"wrap":""}`,children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(Ct,{path:c.path,workspaceName:T,workspaceRootPath:M,onSelectPath:k}),e.jsxs("span",{className:"diff-addition",children:["+",c.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",c.deletions]})]}),e.jsxs("span",{className:"workspace-file-heading-end",children:[U?e.jsx("span",{className:"workspace-file-save-state",children:"Saving"}):null,h]})]}),z?le?e.jsx("div",{className:"workspace-markdown-preview",children:e.jsx(Ia,{content:A})}):re?e.jsx(sl,{file:c,contentBase64:A}):a&&!H?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"workspace-diff-code-empty",children:"Loading editor"}),children:e.jsx(Xi,{diagnostics:s,filePath:c.path,onChange:Y=>N?.(Y),onLspAction:E,onSave:()=>_?.(),ref:i,value:A,wordWrap:R})}):e.jsx("div",{className:"workspace-file-code",children:Q.map((Y,J)=>e.jsxs("div",{className:"workspace-file-code-row",children:[e.jsx("span",{children:J+1}),e.jsx("code",{children:e.jsx(Nt,{language:q,text:Y||" "})})]},`${J}-${Y}`))}):e.jsx("div",{className:"workspace-diff-code-empty",children:o?"Loading file content":"No file content available."})]})}function el({collapsed:t=!1,file:s,hideWhiteSpace:n=!1,wordWrap:a,workspaceName:i,workspaceRootPath:u,onSelectBreadcrumbPath:c,headerActions:f}){const h=r.useMemo(()=>dn(s.patch,n),[s.patch,n]),m=ls(s.path);return e.jsxs("div",{className:`workspace-diff-preview ${a?"wrap":""}`,children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(Ct,{path:s.path,workspaceName:i??null,workspaceRootPath:u,onSelectPath:c}),e.jsxs("span",{className:"diff-addition",children:["+",s.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",s.deletions]})]}),f]}),t?e.jsx("div",{className:"workspace-diff-code-empty",children:"Diff collapsed"}):e.jsx(cn,{ariaLabel:`${s.path} diff`,className:"workspace-diff-code",emptyMessage:"No patch available.",rows:h,renderRow:(o,x)=>o.kind==="spacer"?e.jsx("div",{className:"workspace-diff-spacer",role:"row",children:o.label},`${o.label}-${x}`):e.jsxs("div",{className:`workspace-diff-code-row ${o.kind}`,role:"row",children:[e.jsx("span",{className:"workspace-diff-line-number",role:"cell",children:o.newLine||o.oldLine}),e.jsx("code",{role:"cell",children:e.jsx(Nt,{language:m,text:o.newContent||o.oldContent||" "})})]},`${o.oldLine}-${o.newLine}-${x}`),wordWrap:a})]})}function tl({collapsed:t,file:s,hideWhiteSpace:n,wordDiffs:a,wordWrap:i,workspaceName:u,workspaceRootPath:c,onSelectBreadcrumbPath:f,headerActions:h}){const m=r.useMemo(()=>dn(s.patch,n),[s.patch,n]),o=ls(s.path);return e.jsxs("div",{className:`workspace-diff-preview split ${i?"wrap":""} ${a?"word-diffs":""}`,children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(Ct,{path:s.path,workspaceName:u,workspaceRootPath:c,onSelectPath:f}),e.jsxs("span",{className:"diff-addition",children:["+",s.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",s.deletions]})]}),e.jsxs("span",{className:"workspace-file-heading-end",children:[h,e.jsx(Xa,{size:14})]})]}),t?e.jsx("div",{className:"workspace-diff-code-empty",children:"Diff collapsed"}):e.jsx(cn,{ariaLabel:`${s.path} split diff`,className:"workspace-split-code",emptyMessage:"No patch available.",rows:m,renderRow:(x,S)=>x.kind==="spacer"?e.jsx("div",{className:"workspace-diff-spacer split",role:"row",children:x.label},`${x.label}-${S}`):e.jsxs("div",{className:`workspace-split-row ${x.kind}`,role:"row",children:[e.jsx("span",{className:"workspace-diff-line-number old",role:"cell",children:x.oldLine}),e.jsx("code",{className:"old",role:"cell",children:e.jsx(Nt,{language:o,text:x.oldContent||" "})}),e.jsx("span",{className:"workspace-diff-line-number new",role:"cell",children:x.newLine}),e.jsx("code",{className:"new",role:"cell",children:e.jsx(Nt,{language:o,text:x.newContent||" "})})]},`${x.oldLine}-${x.newLine}-${S}`),wordWrap:i})]})}function sl({file:t,contentBase64:s}){const n=r.useMemo(()=>{const a=il(s);if(!a)return null;const i=new Blob([new Uint8Array(a)],{type:nl(t.path)});return URL.createObjectURL(i)},[s,t.path]);return r.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n?e.jsxs("div",{className:"workspace-document-preview",children:[e.jsxs("div",{className:"workspace-document-preview-card",children:[e.jsx("strong",{children:t.path.split("/").pop()}),e.jsx("span",{children:"Word document"}),e.jsx("a",{href:n,download:t.path.split("/").pop()||"document",children:"Download document"})]}),e.jsx("iframe",{src:n,title:`${t.path} preview`})]}):e.jsx("div",{className:"workspace-diff-code-empty",children:"Document preview unavailable."})}function nl(t){return/\.docx$/i.test(t)?"application/vnd.openxmlformats-officedocument.wordprocessingml.document":"application/msword"}function al(t){return t.length>0&&/^[A-Za-z0-9+/=\s]+$/.test(t)}function il(t){try{const s=atob(t.replace(/\s/g,"")),n=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)n[a]=s.charCodeAt(a);return n}catch{return null}}function cn({ariaLabel:t,className:s,emptyMessage:n,rows:a,renderRow:i,wordWrap:u}){const c=!u&&a.length>Qi,{endIndex:f,offsetTop:h,scrollRef:m,startIndex:o,totalHeight:x}=ll(a.length,c);return a.length===0?e.jsx("div",{className:s,role:"table","aria-label":t,children:e.jsx("div",{className:"workspace-diff-code-empty",children:n})}):c?e.jsx("div",{className:`${s} virtualized`,ref:m,role:"table","aria-label":t,"aria-rowcount":a.length,children:e.jsx("div",{className:"workspace-diff-virtual-spacer",style:{height:x},children:e.jsx("div",{className:"workspace-diff-virtual-window",style:{transform:`translateY(${h}px)`},children:a.slice(o,f).map((S,k)=>i(S,o+k))})})}):e.jsx("div",{className:s,role:"table","aria-label":t,children:a.map(i)})}function ll(t,s){const n=r.useRef(null),[a,i]=r.useState({height:Re*Zs,scrollTop:0}),u=r.useCallback(()=>{const m=n.current;m&&i({height:m.clientHeight||Re*Zs,scrollTop:m.scrollTop})},[]);if(r.useEffect(()=>{if(!s)return;const m=n.current;if(!m)return;u();let o=0;const x=()=>{if(typeof window>"u"){u();return}window.cancelAnimationFrame(o),o=window.requestAnimationFrame(u)};m.addEventListener("scroll",x,{passive:!0});const S=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>x());return S?.observe(m),()=>{m.removeEventListener("scroll",x),S?.disconnect(),typeof window<"u"&&window.cancelAnimationFrame(o)}},[s,u]),!s)return{endIndex:t,offsetTop:0,scrollRef:n,startIndex:0,totalHeight:t*Re};const c=Math.ceil(a.height/Re),f=Math.max(0,Math.floor(a.scrollTop/Re)-Qs);return{endIndex:Math.min(t,f+c+Qs*2),offsetTop:f*Re,scrollRef:n,startIndex:f,totalHeight:t*Re}}function dn(t,s){if(!t.trim())return[];const n=[];let a=0,i=0,u=null,c=null,f=!1,h=[];function m(){n.push(...rl(h)),h=[]}function o(){f&&(m(),u=a,c=i,f=!1)}for(const x of t.split(`
6
6
  `)){const S=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(x);if(S){o();const E=Number(S[1]),_=Number(S[2]);if(u!==null&&c!==null){const W=Math.max(E-u,_-c,0);W>0&&n.push({kind:"spacer",label:un(W)})}a=E,i=_,f=!0;continue}if(x.startsWith("diff --git")||x.startsWith("index ")||x.startsWith("--- ")||x.startsWith("+++ ")||!f||x.startsWith("\\ No newline"))continue;const k=x.slice(1)||" ";if(s&&!k.trim())continue;if(x.startsWith("+")){m(),n.push({kind:"addition",oldLine:"",newLine:String(i||""),oldContent:"",newContent:k}),i+=1;continue}if(x.startsWith("-")){m(),n.push({kind:"deletion",oldLine:String(a||""),newLine:"",oldContent:k,newContent:""}),a+=1;continue}const N=x.startsWith(" ")?x.slice(1)||" ":x||" ";s&&!N.trim()||(h.push({kind:"context",oldLine:String(a||""),newLine:String(i||""),oldContent:N,newContent:N}),a+=1,i+=1)}return o(),n}function rl(t){if(t.length<Zi)return t;const s=t.length-Jt*2;return s<=0?t:[...t.slice(0,Jt),{kind:"spacer",label:un(s)},...t.slice(-Jt)]}function un(t){return`${t} unmodified ${t===1?"line":"lines"}`}const Rt=`
7
7
 
8
8
  [file truncated]`,ol="openpond.sandboxSourceReadback.v1";async function cl(t,s,n,a=[]){let i;try{i=await I.sandboxDownloadFile(t,s,n,{maxBytes:256*1024})}catch(c){const f=c instanceof Error?c.message:String(c);if(!dl(f))throw c;const h=pl(a,s,n);if(h)return h;const m=!!rs(a,s)?.artifact,o=await I.sandbox(t,s).catch(()=>null);throw new Error(ul(n,o?.sandbox??null,f,{hasReadbackArtifact:m}))}const u=i.file.isBinary?i.file.contentsBase64||null:`${i.contents}${i.file.truncated?Rt:""}`;return{path:i.file.path,status:"",additions:0,deletions:0,patch:"",content:u}}function dl(t){return t.includes("sandbox_not_ready")&&t.includes("placement_stale")||t.includes("sandbox_not_running")}function ul(t,s,n="sandbox_not_ready:placement_stale",a={}){const i=s?hl(s):null,u=t||"this file";if(a.hasReadbackArtifact)return`Sandbox file content is unavailable because the stopped runtime placement is stale. The latest source checkpoint has a saved readback artifact, but ${u} was not captured as text. Resume the sandbox to inspect it. ${n}`;if(!i)return`Sandbox file content is unavailable because the stopped runtime placement is stale. Resume the sandbox to inspect ${u}. ${n}`;const c=i.preservedSha?i.preservedSha.slice(0,12):null,f=i.sourceRef?` (${i.sourceRef})`:"";return`Sandbox file content is unavailable because the stopped runtime placement is stale. The latest source checkpoint is saved${c?` at ${c}`:""}${f}, but this Desktop app cannot read file bodies from preserved source refs yet. Resume the sandbox to inspect ${u}.`}function fl(t,s){if(!s)return null;const n=rs(t,s);if(!n)return null;const a=pn(n.artifact),i=new Map;for(const f of os(a))i.set(f.path,f);for(const f of hn(n.artifact)){const h=fn(n.artifact,f.path);h&&i.set(f.path,h)}const u=[...i.values()].sort((f,h)=>f.path.localeCompare(h.path)),c=[...new Set(u.map(f=>f.path))].sort((f,h)=>f.localeCompare(h));return{appId:s,repoPath:"",initialized:!0,dirty:!1,filesChanged:u.length,additions:u.reduce((f,h)=>f+h.additions,0),deletions:u.reduce((f,h)=>f+h.deletions,0),repoFiles:c,files:u,error:null,updatedAt:Ue(ie(n.artifact)?.createdAt)??n.event.timestamp}}function pl(t,s,n){if(!s)return null;const a=rs(t,s);return a?fn(a.artifact,n):null}function rs(t,s){for(let n=t.length-1;n>=0;n-=1){const a=t[n];if(a?.name!=="workspace_action_result")continue;const i=ie(a.data),u=ie(i?.sourcePreservation),c=ie(u?.sourceReadbackArtifact);if(c&&c.schemaVersion===ol&&c.sandboxId===s)return{artifact:c,event:a}}return null}function fn(t,s){const n=os(pn(t)).find(u=>u.path===s),a=hn(t).find(u=>u.path===s);if(!n&&!a)return null;const i=typeof a?.content=="string"?`${a.content}${a.truncated?Rt:""}`:null;return{path:a?.path??n?.path??s,status:n?.status??"M",additions:n?.additions??0,deletions:n?.deletions??0,patch:n?.patch??"",content:i}}function pn(t){const s=ie(t.patch);return typeof s?.text=="string"?s.text:""}function hn(t){return(Array.isArray(t.files)?t.files:[]).map(n=>{const a=ie(n),i=Ue(a?.path);return i?{path:i,...typeof a?.content=="string"?{content:a.content}:{},...a?.truncated===!0?{truncated:!0}:{}}:null}).filter(n=>!!n)}function hl(t){const s=ie(t.metadata)??{},n=ie(s.sourcePreservation)??ie(s.sourcePreserve),a=ie(s.sourceChangeDetection),i=Ue(n?.preservedSha)??Ue(a?.preservedSha)??null,u=Ue(n?.sourceRef)??Ue(a?.sourceRef)??(typeof t.repoRef=="string"?t.repoRef:null);return!i&&!u?null:{preservedSha:i,sourceRef:u}}function ie(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ue(t){return typeof t=="string"&&t.trim()?t.trim():null}async function ml(t,s,n,a){const i=await I.sandboxUploadFile(t,s,{path:n,contents:a});return await I.preserveSandboxSource(t,s,{message:"Auto-preserve source after right sidebar save"}),{path:i.file.path,status:"M",additions:0,deletions:0,patch:"",content:a}}function xl(t){return t.filter(s=>s.type==="file").map(s=>s.path).sort((s,n)=>s.localeCompare(n))}function bl(t,s){const n=new Map;for(const a of os(t?.diff??""))n.set(a.path,a);for(const a of gl(s?.porcelain??""))n.has(a.path)||n.set(a.path,a);return[...n.values()].sort((a,i)=>a.path.localeCompare(i.path))}function os(t){const s=[];let n=null;const a=()=>{n&&(s.push({path:n.path,status:n.status,additions:n.additions,deletions:n.deletions,patch:n.patchLines.join(`
9
9
  `),content:null}),n=null)};for(const i of t.split(`
10
10
  `)){if(i.startsWith("diff --git ")){a(),n={path:vl(i)??"changed-file",status:"M",additions:0,deletions:0,patchLines:[i]};continue}if(n){if(n.patchLines.push(i),i.startsWith("+++ ")){const u=Ys(i.slice(4));u&&(n.path=u);continue}if(i.startsWith("--- ")){const u=Ys(i.slice(4));u&&n.path==="changed-file"&&(n.path=u);continue}i.startsWith("new file mode ")&&(n.status="A"),i.startsWith("deleted file mode ")&&(n.status="D"),i.startsWith("rename to ")&&(n.status="R",n.path=i.slice(10).trim()||n.path),i.startsWith("+")&&!i.startsWith("+++")&&(n.additions+=1),i.startsWith("-")&&!i.startsWith("---")&&(n.deletions+=1)}}return a(),s}function gl(t){const s=[];for(const n of t.split(`
11
- `)){if(!n.trim())continue;const a=jl(n);a&&s.push({path:a,status:n.slice(0,2).trim()||"M",additions:0,deletions:0,patch:"",content:null})}return s}function jl(t){const s=t.slice(3).trim();return s?s.split(" -> ").pop()?.trim()||s:null}function vl(t){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(t.trim());return s?.[2]??s?.[1]??null}function Ys(t){const s=t.trim();return!s||s==="/dev/null"?null:s.startsWith("a/")||s.startsWith("b/")?s.slice(2):s}const mn="openpond.workspace.editorControlsVisible";function kl(){try{return window.localStorage.getItem(mn)==="true"}catch{return!1}}function wl(t){try{window.localStorage.setItem(mn,String(t))}catch{}}function yl({activeDiagnostics:t,activeServers:s,editorDiagnosticsChecking:n,editorLspEnabled:a,showEditorCommandBar:i}){if(!i)return null;if(!a)return{label:"LSP off",severity:"unavailable"};if(n)return{label:"Checking",severity:"info"};const u=t.filter(m=>m.severity==="error").length;if(u>0)return{label:`${u} error${u===1?"":"s"}`,severity:"error"};const c=t.filter(m=>m.severity==="warning").length;if(c>0)return{label:`${c} warning${c===1?"":"s"}`,severity:"warning"};const f=t.length;if(f>0)return{label:`${f} note${f===1?"":"s"}`,severity:"info"};if(!s)return null;const h=s.find(m=>m.status!=="connected");return h?{label:h.id==="none"?"No LSP":`${h.id} unavailable`,severity:"unavailable"}:{label:"No issues",severity:"none"}}const Js=3e3,Sl=2e3,en=[],Nl=[];function Il({appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i,diff:u,editorPreferences:c,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S,filesWithPreview:k=!1,openFileRequest:N,readOnly:E=!1,sideChatTabs:_,sourceSwitcher:W,tabRequest:K,viewState:U,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z,sandboxFileSource:H,trainingSummary:le,sidebarFileBookmarks:re=[],sidebarFileSourceSessionId:Y=null,onSetSidebarFileStatus:J}){return e.jsx(El,{appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i??[],diff:u,editorPreferences:c??null,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S??null,filesWithPreview:k,openFileRequest:N,readOnly:E,sideChatTabs:_??[],sourceSwitcher:W??null,tabRequest:K??null,viewState:U??null,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z??null,sandboxFileSource:H??null,trainingSummary:le??null,sidebarFileBookmarks:re,sidebarFileSourceSessionId:Y,onSetSidebarFileStatus:J})}function Cl(t,s,n,a){return t&&s?.content!=null?{...t,content:s.content}:s&&!t&&es(s)?s:t&&es(t)?t:s&&es(s)?s:t??s??n??ns(a)}function es(t){return!!(t.patch||t.content!=null)}function Rl({changedFiles:t,checkpointStatus:s,dirty:n,error:a,loading:i,preservedReadback:u,sandboxMode:c,sourcePending:f}){if(f)return{label:"sandbox pending",tone:"loading"};if(i)return{label:"refreshing",tone:"loading"};if(c&&u&&s)return s;if(a)return{label:"status unavailable",tone:"error"};if(c&&s?.tone==="error"||c&&s&&!n&&t===0)return s;if(n||t>0){const h=Math.max(1,t),m=h===1?"change":"changes";return{label:c?`${h} unpreserved ${m}`:`${h} local ${m}`,tone:"dirty"}}return{label:c?"sandbox clean":"local clean",tone:"clean"}}function $l(t,s){if(!s)return null;for(let n=t.length-1;n>=0;n-=1){const a=t[n];if(a?.name!=="workspace_action_result")continue;const i=a.data&&typeof a.data=="object"&&!Array.isArray(a.data)?a.data:null,u=i?.sourcePreservation&&typeof i.sourcePreservation=="object"&&!Array.isArray(i.sourcePreservation)?i.sourcePreservation:null;if(u?.attempted===!0&&u.sandboxId===s)return u.ok!==!0?{label:"checkpoint failed",tone:"error"}:u.preserved===!0?{label:"checkpoint saved",tone:"clean"}:{label:"checkpoint clean",tone:"clean"}}return null}function Fl(t){const s=t.split("/").filter(Boolean);return s.map((n,a)=>s.slice(0,a+1).join("/"))}function El({appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i,diff:u,editorPreferences:c,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S,filesWithPreview:k,openFileRequest:N,readOnly:E,sideChatTabs:_,sourceSwitcher:W,tabRequest:K,viewState:U,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z,sandboxFileSource:H,trainingSummary:le,sidebarFileBookmarks:re,sidebarFileSourceSessionId:Y,onSetSidebarFileStatus:J}){const w=U??La(),[F,D]=r.useState(w.activeTab),[de,Et]=r.useState(!1),[Ae,X]=r.useState(!1),[xn,se]=r.useState(!1),[At,Pt]=r.useState(""),[ee,He]=r.useState(()=>[...w.openFilePaths]),[b,be]=r.useState(w.selectedPath),[cs,bn]=r.useState(!1),[ds,gn]=r.useState(!1),[Pe,jn]=r.useState(!1),[Lt,vn]=r.useState(!0),[us,kn]=r.useState(kl),[fs,wn]=r.useState(!1),[ps,yn]=r.useState(!1),[hs,Sn]=r.useState(!1),[ne,Le]=r.useState({}),[ot,ct]=r.useState(()=>new Set),[ms,dt]=r.useState({}),[ue,Ve]=r.useState({}),[xs,Dt]=r.useState(()=>new Set),[Ke,Ge]=r.useState(null),[Nn,Tt]=r.useState(!1),[bs,qe]=r.useState(null),[gs,_t]=r.useState({}),[Cn,Mt]=r.useState({}),[Rn,zt]=r.useState(null),[$n,ge]=r.useState(null),[Fn,je]=r.useState(null);Fe(o,{prefix:"Workspace"}),Fe(bs,{prefix:"Sandbox files"});const[It,ut]=r.useState(null),[En,Xe]=r.useState({}),[ft,Wt]=r.useState(null),[De,pt]=r.useState(null),[ht,mt]=r.useState(null),te=c??Aa.editor,js=r.useRef(ne),Bt=r.useRef(Qt(w)),Ot=r.useRef(Qt(w)),vs=r.useRef(null),Ut=r.useRef(B),oe=r.useRef(!1),Ze=r.useRef(null),Qe=r.useRef(0),fe=r.useRef(null),Ye=r.useRef(null),P=H?.sandboxId?.trim()||null,C=!!H,Te=!!le||C&&!!P,xt=C?`sandbox:${P??"pending"}`:`workspace:${t??"none"}`,ks=C?!!P:!!t,ws=r.useRef(xt),pe=!!(z?.createRuntime||z?.goalRuntime||z?.subagentRuntime),_e=r.useCallback(async(l={})=>{if(C){if(!a){Ge(null),qe("OpenPond App server is not connected.");return}if(!P){Ge(null),qe(null);return}l.silent||Tt(!0);try{const[p,d,v]=await Promise.allSettled([I.sandboxFiles(a,P,{recursive:!0,maxEntries:Sl}),I.sandboxGitStatus(a,P),I.sandboxGitDiff(a,P,{})]);if(p.status==="rejected")throw p.reason;const y=xl(p.value.files),g=d.status==="fulfilled"?d.value.status:null,$=v.status==="fulfilled"?v.value.diff:null,L=bl($,g),at=L.reduce((Xt,Zt)=>Xt+Zt.additions,0),ca=L.reduce((Xt,Zt)=>Xt+Zt.deletions,0);Ge({appId:P,repoPath:"",initialized:!0,dirty:g?!g.clean:L.length>0,filesChanged:L.length,additions:at,deletions:ca,repoFiles:y,files:L,error:null,updatedAt:new Date().toISOString()}),qe(null)}catch(p){Ge(null),qe(p instanceof Error?p.message:String(p))}finally{l.silent||Tt(!1)}}},[a,P,C]),ys=r.useMemo(()=>fl(i,P),[i,P]),Ss=!!(Ke&&((Ke.files?.length??0)>0||(Ke.repoFiles?.length??0)>0)),An=C&&!Ss&&!!ys,he=C?Ss?Ke:ys??Ke:u,Je=he?.repoPath??null,Pn=r.useMemo(()=>$l(i,P),[i,P]),Me=he?.files??en,Ns=he?.files??en,ve=r.useMemo(()=>new Map(Ns.map(l=>[l.path,l])),[Ns]),ke=r.useMemo(()=>new Map(Me.map(l=>[l.path,l])),[Me]),ze=he?.repoFiles??(Me.length>0?Me.map(l=>l.path):Nl),Ie=r.useMemo(()=>Me.filter(l=>!$a(l,ze)),[ze,Me]),we=r.useMemo(()=>ht&&!ze.includes(ht)?[ht,...ze]:ze,[ze,ht]),Cs=r.useMemo(()=>ee.map(l=>ve.get(l)??ne[l]??ke.get(l)??ns(l)),[ve,ke,ne,ee]),bt=r.useMemo(()=>{const l={};for(const p of ee){if(Ne(p))continue;const d=ve.get(p)??ne[p]??ke.get(p)??ns(p);d.content!=null&&(l[p]=d.content)}return l},[ve,ke,ne,ee]),We=r.useMemo(()=>{const l=new Set;for(const[p,d]of Object.entries(ue))d.content!==d.savedContent&&l.add(p);return l},[ue]),Ln=r.useMemo(()=>{const l=At.trim().toLowerCase(),p=we;return l?p.filter(d=>d.toLowerCase().includes(l)):p},[we,At]),Ht=r.useMemo(()=>({activeTab:F,openFilePaths:ee,selectedPath:b}),[F,ee,b]);r.useEffect(()=>{js.current=ne},[ne]),r.useEffect(()=>{Ze.current=ft},[ft]),r.useEffect(()=>{Ve(l=>{let p=!1;const d={...l},v=new Set(ee),y=u?.updatedAt?Date.parse(u.updatedAt):null;for(const[g,$]of Object.entries(d))v.has(g)||$.content!==$.savedContent||(delete d[g],p=!0);for(const[g,$]of Object.entries(bt)){const L=d[g];if(!L){d[g]={content:$,savedContent:$},p=!0;continue}if(L.content===L.savedContent&&L.savedContent!==$){if(L.savedAt&&(y===null||y<L.savedAt))continue;d[g]={content:$,savedContent:$},p=!0}}return p?d:l})},[u?.updatedAt,bt,ee]),r.useEffect(()=>{Ut.current=B},[B]),r.useEffect(()=>{if(!U)return;const l=Fa(U,Je);Bs(Bt.current,l)||(Bt.current=l,Ot.current=l,D(l.activeTab),He(l.openFilePaths),be(l.selectedPath))},[U,Je]),r.useEffect(()=>{if(ot.size>0||Bs(Ot.current,Ht))return;const l=Qt(Ht);Ot.current=l,Bt.current=l,M?.(l)},[Ht,M,ot]),r.useEffect(()=>{E||C||!a||!t||!m||u||o||oe.current||(oe.current=!0,Promise.resolve(Ut.current({silent:!0})).catch(()=>{}).finally(()=>{oe.current=!1}))},[t,a,u,E,C,o,m]),r.useEffect(()=>(ws.current!==xt&&(ws.current=xt,fe.current?.abort(new Error("lsp_diagnostics_source_changed")),fe.current=null,He([]),be(null),Le({}),ct(new Set),dt({}),Ve({}),Dt(new Set),Ge(null),qe(null),Tt(!1),_t({}),Mt({}),zt(null),ge(null),je(null),ut(null),Xe({}),Wt(null),pt(null),mt(null)),()=>{fe.current?.abort(new Error("lsp_diagnostics_unmounted")),fe.current=null}),[xt]),r.useEffect(()=>{if(!(!N||vs.current===N.id)&&!(!N.file&&!ks)){if(vs.current=N.id,N.file){Dn(N.file,N.imageUrl);return}gt(N.path)}},[ks,N]),r.useEffect(()=>{if(!C||(_e(),!a||!P))return;let l=!1;async function p(){if(!(l||oe.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){oe.current=!0;try{await _e({silent:!0})}finally{oe.current=!1}}}const d=window.setInterval(()=>{p()},Js),v=()=>{p()};return window.addEventListener("focus",v),()=>{l=!0,window.clearInterval(d),window.removeEventListener("focus",v)}},[a,_e,P,C]),r.useEffect(()=>{if(E||C||!a||!t||!m)return;let l=!1;async function p(){if(!(l||oe.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){oe.current=!0;try{await Ut.current({silent:!0})}catch{}finally{oe.current=!1}}}const d=window.setInterval(()=>{p()},Js),v=()=>{p()};return window.addEventListener("focus",v),()=>{l=!0,window.clearInterval(d),window.removeEventListener("focus",v)}},[t,a,E,C,m]),r.useEffect(()=>{if(C||!a||!t||n==="local_project"){mt(null);return}let l=!1;return I.workspaceTemplateConfig(a,t).then(p=>{l||mt(p.exists?p.configPath??Ea:null)}).catch(()=>{l||mt(null)}),()=>{l=!0}},[t,a,C,n]),r.useEffect(()=>{!b||we.includes(b)||ee.includes(b)||be(Ie[0]?.path??null)},[Ie,ee,we,b]),r.useEffect(()=>{z?.active&&pe&&D("goal")},[z?.active,pe]),r.useEffect(()=>{K&&D(K.tab)},[K]),r.useEffect(()=>{!pe&&F==="goal"&&D("files")},[F,pe]),r.useEffect(()=>{!Te&&F==="summary"&&D("files")},[F,Te]);const G=F==="file"||k&&F==="files"?b:null;r.useEffect(()=>{if(!a||!G)return;if(Ne(G)){je(null),ge(g=>g===G?null:g);return}const l=It?.path===G,p=et(G);if(E&&(p?.content!=null||p?.patch)){je(null),ge(g=>g===G?null:g);return}if(!l&&(p?.content!=null||p?.patch&&!Pe)){je(null),ge(g=>g===G?null:g);return}let d=!1;const v=js.current[G];return v?.content==null&&(Pe||!v?.patch)&&ge(G),je(null),(C?P?cl(a,P,G,i):Promise.reject(new Error(H?.emptyMessage??"No sandbox filesystem is available.")):t?I.workspaceFile(a,t,G):Promise.reject(new Error("Workspace files are unavailable."))).then(g=>{d||Le($=>{const L=$[g.path];return L?.content===g.content&&L.patch===g.patch&&L.status===g.status?$:{...$,[g.path]:g}})}).catch(g=>{d||je(g instanceof Error?g.message:String(g))}).finally(()=>{d||(ge(g=>g===G?null:g),ut(g=>g&&g.id===It?.id&&g.path===G?null:g))}),()=>{d=!0}},[F,t,a,It,Pe,E,i,H?.emptyMessage,P,C,G]);function gt(l){const p=ss(l,Je);p&&(ct(d=>{if(!d.has(p))return d;const v=new Set(d);return v.delete(p),v}),Le(d=>{if(!(p in d))return d;const v={...d};return delete v[p],v}),dt(d=>{if(!(p in d))return d;const v={...d};return delete v[p],v}),ut({id:Date.now(),path:p}),k||He(d=>d.includes(p)?d:[...d,p]),be(p),D(k?"files":"file"),!C&&a&&t&&Ne(p)&&pt(p),X(!1),se(!1),Pt(""))}function Dn(l,p){const d=ss(l.path,Je);if(!d)return;const v={...l,path:d};Le(y=>({...y,[d]:v})),ct(y=>{const g=new Set(y);return g.add(d),g}),dt(y=>{if(!p){if(!(d in y))return y;const g={...y};return delete g[d],g}return y[d]===p?y:{...y,[d]:p}}),ut(null),je(null),ge(null),k||He(y=>y.includes(d)?y:[...y,d]),be(d),D(k?"files":"file"),X(!1),se(!1),Pt("")}const Tn=r.useCallback(()=>{kn(l=>{const p=!l;return wl(p),p})},[]),et=l=>Cl(ve.get(l),ne[l],ke.get(l),l),_n=r.useCallback((l,p)=>{Ve(d=>{const v=d[l],y=v?.savedContent??bt[l]??et(l).content??"";return{...d,[l]:{content:p,savedContent:y,savedAt:v?.savedAt}}}),Xe(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v})},[ve,ke,ne,bt]),Be=r.useCallback(async(l,p={})=>{if(C||!a||!t||Ne(l))return;const d=et(l),v=p.content??ue[l]?.content??d.content??void 0;if(v?.endsWith(Rt))return;const y=Qe.current+1;Qe.current=y,fe.current?.abort(new Error("lsp_diagnostics_superseded"));const g=new AbortController;fe.current=g,zt(l);try{const $=await I.workspaceLspTouch(a,t,{path:l,content:v,waitForDiagnostics:p.waitForDiagnostics??!0},{signal:g.signal});if(y!==Qe.current)return;_t(L=>({...L,[$.path]:$.diagnostics})),Mt(L=>({...L,[$.path]:$.servers}))}catch($){if(g.signal.aborted||y!==Qe.current)return;const L=$ instanceof Error?$.message:String($);_t(at=>({...at,[l]:[]})),Mt(at=>({...at,[l]:[{id:"lsp",root:"",status:"error",message:L}]}))}finally{if(fe.current===g&&(fe.current=null),g.signal.aborted)return;y===Qe.current&&zt($=>$===l?null:$)}},[t,a,ve,ke,ue,ne,C]),Mn=r.useCallback(async l=>{if(C||!a||!t)throw new Error("Workspace LSP is unavailable.");return I.workspaceLspAction(a,t,l)},[t,a,C]),tt=r.useCallback(async l=>{if(!a||!t&&!P||Ze.current===l)return;const p=ue[l];if(!p||p.content===p.savedContent)return;const d=p.content,v=Date.now();Ze.current=l,Wt(l),Xe(y=>{if(!(l in y))return y;const g={...y};return delete g[l],g});try{const y=C?await ml(a,P,l,d):await I.saveWorkspaceFile(a,t,{path:l,content:d});Le(g=>({...g,[y.path]:y})),Ve(g=>{const $=g[l];return $?{...g,[l]:{content:$.content,savedContent:d,savedAt:v}}:g}),te.languageServers!=="off"&&te.checkOnSave&&await Be(l,{content:d,waitForDiagnostics:!0}),C?await _e({silent:!0}):await B({silent:!0})}catch(y){Xe(g=>({...g,[l]:y instanceof Error?y.message:String(y)}))}finally{Ze.current===l&&(Ze.current=null),Wt(y=>y===l?null:y)}},[te.checkOnSave,te.languageServers,t,a,ue,B,Be,_e,P,C]),Rs=b?et(b):null,st=!!(b&&ot.has(b)),ye=b?ue[b]?.content??Rs?.content??null:null,zn=!!(Rs?.patch&&!Pe),Vt=!!(!E&&!st&&F==="file"&&!zn&&b&&ye!=null&&!Ne(b)&&!(Lt&&ts(b))&&!ye.endsWith(Rt));r.useEffect(()=>{if(te.languageServers==="off"||!te.diagnosticsWhileEditing||!b||!Vt||ye==null)return;const l=window.setTimeout(()=>{Be(b,{content:ye,waitForDiagnostics:!0})},700);return()=>window.clearTimeout(l)},[te.diagnosticsWhileEditing,te.languageServers,Be,ye,Vt,b]),r.useEffect(()=>{function l(p){!(p.ctrlKey||p.metaKey)||p.key.toLowerCase()!=="s"||F!=="file"||!b||(p.preventDefault(),We.has(b)&&tt(b))}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[F,We,tt,b]);const In=r.useCallback(()=>{b&&(Ye.current?Ye.current.save():tt(b))},[tt,b]),Wn=r.useCallback(()=>{Ye.current?.undo()},[]),Bn=r.useCallback(()=>{Ye.current?.redo()},[]),On=r.useCallback(()=>{b&&te.languageServers!=="off"&&Be(b,{content:ye??void 0,waitForDiagnostics:!0})},[te.languageServers,Be,ye,b]);function Un(l,p){if(p.stopPropagation(),!(We.has(l)&&!window.confirm(`Discard unsaved changes to ${l}?`))&&(We.has(l)&&(Ve(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),Xe(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v})),He(d=>d.filter(v=>v!==l)),ot.has(l)&&Le(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),dt(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),ct(d=>{if(!d.has(l))return d;const v=new Set(d);return v.delete(l),v}),b===l)){const d=Cs.find(v=>v.path!==l)??null;be(d?.path??Ie[0]?.path??null),d||D("files")}}function Hn(){D("files"),X(!1),se(!1)}function $s(l){Dt(p=>{const d=new Set(p);return d.has(l)?d.delete(l):d.add(l),d})}function Vn(l){l&&Dt(p=>{const d=new Set(p);for(const v of Fl(l))d.add(v);return d}),D("files"),X(!1),se(!1)}function Kn(){const p=`git apply <<'PATCH'
11
+ `)){if(!n.trim())continue;const a=jl(n);a&&s.push({path:a,status:n.slice(0,2).trim()||"M",additions:0,deletions:0,patch:"",content:null})}return s}function jl(t){const s=t.slice(3).trim();return s?s.split(" -> ").pop()?.trim()||s:null}function vl(t){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(t.trim());return s?.[2]??s?.[1]??null}function Ys(t){const s=t.trim();return!s||s==="/dev/null"?null:s.startsWith("a/")||s.startsWith("b/")?s.slice(2):s}const mn="openpond.workspace.editorControlsVisible";function kl(){try{return window.localStorage.getItem(mn)==="true"}catch{return!1}}function wl(t){try{window.localStorage.setItem(mn,String(t))}catch{}}function yl({activeDiagnostics:t,activeServers:s,editorDiagnosticsChecking:n,editorLspEnabled:a,showEditorCommandBar:i}){if(!i)return null;if(!a)return{label:"LSP off",severity:"unavailable"};if(n)return{label:"Checking",severity:"info"};const u=t.filter(m=>m.severity==="error").length;if(u>0)return{label:`${u} error${u===1?"":"s"}`,severity:"error"};const c=t.filter(m=>m.severity==="warning").length;if(c>0)return{label:`${c} warning${c===1?"":"s"}`,severity:"warning"};const f=t.length;if(f>0)return{label:`${f} note${f===1?"":"s"}`,severity:"info"};if(!s)return null;const h=s.find(m=>m.status!=="connected");return h?{label:h.id==="none"?"No LSP":`${h.id} unavailable`,severity:"unavailable"}:{label:"No issues",severity:"none"}}const Js=3e3,Sl=2e3,en=[],Nl=[];function Cl({appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i,diff:u,editorPreferences:c,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S,filesWithPreview:k=!1,openFileRequest:N,readOnly:E=!1,sideChatTabs:_,sourceSwitcher:W,tabRequest:K,viewState:U,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z,sandboxFileSource:H,trainingSummary:le,sidebarFileBookmarks:re=[],sidebarFileSourceSessionId:Y=null,onSetSidebarFileStatus:J}){return e.jsx(Al,{appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i??[],diff:u,editorPreferences:c??null,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S??null,filesWithPreview:k,openFileRequest:N,readOnly:E,sideChatTabs:_??[],sourceSwitcher:W??null,tabRequest:K??null,viewState:U??null,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z??null,sandboxFileSource:H??null,trainingSummary:le??null,sidebarFileBookmarks:re,sidebarFileSourceSessionId:Y,onSetSidebarFileStatus:J})}function Rl(t,s,n,a){return t&&s?.content!=null?{...t,content:s.content}:s&&!t&&es(s)?s:t&&es(t)?t:s&&es(s)?s:t??s??n??ns(a)}function es(t){return!!(t.patch||t.content!=null)}function $l({changedFiles:t,checkpointStatus:s,dirty:n,error:a,loading:i,preservedReadback:u,sandboxMode:c,sourcePending:f}){if(f)return{label:"sandbox pending",tone:"loading"};if(i)return{label:"refreshing",tone:"loading"};if(c&&u&&s)return s;if(a)return{label:"status unavailable",tone:"error"};if(c&&s?.tone==="error"||c&&s&&!n&&t===0)return s;if(n||t>0){const h=Math.max(1,t),m=h===1?"change":"changes";return{label:c?`${h} unpreserved ${m}`:`${h} local ${m}`,tone:"dirty"}}return{label:c?"sandbox clean":"local clean",tone:"clean"}}function Fl(t,s){if(!s)return null;for(let n=t.length-1;n>=0;n-=1){const a=t[n];if(a?.name!=="workspace_action_result")continue;const i=a.data&&typeof a.data=="object"&&!Array.isArray(a.data)?a.data:null,u=i?.sourcePreservation&&typeof i.sourcePreservation=="object"&&!Array.isArray(i.sourcePreservation)?i.sourcePreservation:null;if(u?.attempted===!0&&u.sandboxId===s)return u.ok!==!0?{label:"checkpoint failed",tone:"error"}:u.preserved===!0?{label:"checkpoint saved",tone:"clean"}:{label:"checkpoint clean",tone:"clean"}}return null}function El(t){const s=t.split("/").filter(Boolean);return s.map((n,a)=>s.slice(0,a+1).join("/"))}function Al({appId:t,workspaceId:s,workspaceKind:n,connection:a,runtimeEvents:i,diff:u,editorPreferences:c,loading:f,workspaceName:h,workspaceInitialized:m,workspaceError:o,expanded:x,fileRootPath:S,filesWithPreview:k,openFileRequest:N,readOnly:E,sideChatTabs:_,sourceSwitcher:W,tabRequest:K,viewState:U,onRefresh:B,onResizeStart:j,onToggleExpanded:R,onOpenBrowser:T,onViewStateChange:M,onCloseSideChat:A,onOpenSideChat:Q,onSelectSideChat:q,goalDetails:z,sandboxFileSource:H,trainingSummary:le,sidebarFileBookmarks:re,sidebarFileSourceSessionId:Y,onSetSidebarFileStatus:J}){const w=U??La(),[F,D]=r.useState(w.activeTab),[de,Et]=r.useState(!1),[Ae,X]=r.useState(!1),[xn,se]=r.useState(!1),[At,Pt]=r.useState(""),[ee,He]=r.useState(()=>[...w.openFilePaths]),[b,be]=r.useState(w.selectedPath),[cs,bn]=r.useState(!1),[ds,gn]=r.useState(!1),[Pe,jn]=r.useState(!1),[Lt,vn]=r.useState(!0),[us,kn]=r.useState(kl),[fs,wn]=r.useState(!1),[ps,yn]=r.useState(!1),[hs,Sn]=r.useState(!1),[ne,Le]=r.useState({}),[ot,ct]=r.useState(()=>new Set),[ms,dt]=r.useState({}),[ue,Ve]=r.useState({}),[xs,Dt]=r.useState(()=>new Set),[Ke,Ge]=r.useState(null),[Nn,Tt]=r.useState(!1),[bs,qe]=r.useState(null),[gs,_t]=r.useState({}),[Cn,Mt]=r.useState({}),[Rn,zt]=r.useState(null),[$n,ge]=r.useState(null),[Fn,je]=r.useState(null);Fe(o,{prefix:"Workspace"}),Fe(bs,{prefix:"Sandbox files"});const[It,ut]=r.useState(null),[En,Xe]=r.useState({}),[ft,Wt]=r.useState(null),[De,pt]=r.useState(null),[ht,mt]=r.useState(null),te=c??Aa.editor,js=r.useRef(ne),Bt=r.useRef(Qt(w)),Ot=r.useRef(Qt(w)),vs=r.useRef(null),Ut=r.useRef(B),oe=r.useRef(!1),Ze=r.useRef(null),Qe=r.useRef(0),fe=r.useRef(null),Ye=r.useRef(null),P=H?.sandboxId?.trim()||null,C=!!H,Te=!!le||C&&!!P,xt=C?`sandbox:${P??"pending"}`:`workspace:${t??"none"}`,ks=C?!!P:!!t,ws=r.useRef(xt),pe=!!(z?.createRuntime||z?.goalRuntime||z?.subagentRuntime),_e=r.useCallback(async(l={})=>{if(C){if(!a){Ge(null),qe("OpenPond App server is not connected.");return}if(!P){Ge(null),qe(null);return}l.silent||Tt(!0);try{const[p,d,v]=await Promise.allSettled([I.sandboxFiles(a,P,{recursive:!0,maxEntries:Sl}),I.sandboxGitStatus(a,P),I.sandboxGitDiff(a,P,{})]);if(p.status==="rejected")throw p.reason;const y=xl(p.value.files),g=d.status==="fulfilled"?d.value.status:null,$=v.status==="fulfilled"?v.value.diff:null,L=bl($,g),at=L.reduce((Xt,Zt)=>Xt+Zt.additions,0),ca=L.reduce((Xt,Zt)=>Xt+Zt.deletions,0);Ge({appId:P,repoPath:"",initialized:!0,dirty:g?!g.clean:L.length>0,filesChanged:L.length,additions:at,deletions:ca,repoFiles:y,files:L,error:null,updatedAt:new Date().toISOString()}),qe(null)}catch(p){Ge(null),qe(p instanceof Error?p.message:String(p))}finally{l.silent||Tt(!1)}}},[a,P,C]),ys=r.useMemo(()=>fl(i,P),[i,P]),Ss=!!(Ke&&((Ke.files?.length??0)>0||(Ke.repoFiles?.length??0)>0)),An=C&&!Ss&&!!ys,he=C?Ss?Ke:ys??Ke:u,Je=he?.repoPath??null,Pn=r.useMemo(()=>Fl(i,P),[i,P]),Me=he?.files??en,Ns=he?.files??en,ve=r.useMemo(()=>new Map(Ns.map(l=>[l.path,l])),[Ns]),ke=r.useMemo(()=>new Map(Me.map(l=>[l.path,l])),[Me]),ze=he?.repoFiles??(Me.length>0?Me.map(l=>l.path):Nl),Ie=r.useMemo(()=>Me.filter(l=>!$a(l,ze)),[ze,Me]),we=r.useMemo(()=>ht&&!ze.includes(ht)?[ht,...ze]:ze,[ze,ht]),Cs=r.useMemo(()=>ee.map(l=>ve.get(l)??ne[l]??ke.get(l)??ns(l)),[ve,ke,ne,ee]),bt=r.useMemo(()=>{const l={};for(const p of ee){if(Ne(p))continue;const d=ve.get(p)??ne[p]??ke.get(p)??ns(p);d.content!=null&&(l[p]=d.content)}return l},[ve,ke,ne,ee]),We=r.useMemo(()=>{const l=new Set;for(const[p,d]of Object.entries(ue))d.content!==d.savedContent&&l.add(p);return l},[ue]),Ln=r.useMemo(()=>{const l=At.trim().toLowerCase(),p=we;return l?p.filter(d=>d.toLowerCase().includes(l)):p},[we,At]),Ht=r.useMemo(()=>({activeTab:F,openFilePaths:ee,selectedPath:b}),[F,ee,b]);r.useEffect(()=>{js.current=ne},[ne]),r.useEffect(()=>{Ze.current=ft},[ft]),r.useEffect(()=>{Ve(l=>{let p=!1;const d={...l},v=new Set(ee),y=u?.updatedAt?Date.parse(u.updatedAt):null;for(const[g,$]of Object.entries(d))v.has(g)||$.content!==$.savedContent||(delete d[g],p=!0);for(const[g,$]of Object.entries(bt)){const L=d[g];if(!L){d[g]={content:$,savedContent:$},p=!0;continue}if(L.content===L.savedContent&&L.savedContent!==$){if(L.savedAt&&(y===null||y<L.savedAt))continue;d[g]={content:$,savedContent:$},p=!0}}return p?d:l})},[u?.updatedAt,bt,ee]),r.useEffect(()=>{Ut.current=B},[B]),r.useEffect(()=>{if(!U)return;const l=Fa(U,Je);Bs(Bt.current,l)||(Bt.current=l,Ot.current=l,D(l.activeTab),He(l.openFilePaths),be(l.selectedPath))},[U,Je]),r.useEffect(()=>{if(ot.size>0||Bs(Ot.current,Ht))return;const l=Qt(Ht);Ot.current=l,Bt.current=l,M?.(l)},[Ht,M,ot]),r.useEffect(()=>{E||C||!a||!t||!m||u||o||oe.current||(oe.current=!0,Promise.resolve(Ut.current({silent:!0})).catch(()=>{}).finally(()=>{oe.current=!1}))},[t,a,u,E,C,o,m]),r.useEffect(()=>(ws.current!==xt&&(ws.current=xt,fe.current?.abort(new Error("lsp_diagnostics_source_changed")),fe.current=null,He([]),be(null),Le({}),ct(new Set),dt({}),Ve({}),Dt(new Set),Ge(null),qe(null),Tt(!1),_t({}),Mt({}),zt(null),ge(null),je(null),ut(null),Xe({}),Wt(null),pt(null),mt(null)),()=>{fe.current?.abort(new Error("lsp_diagnostics_unmounted")),fe.current=null}),[xt]),r.useEffect(()=>{if(!(!N||vs.current===N.id)&&!(!N.file&&!ks)){if(vs.current=N.id,N.file){Dn(N.file,N.imageUrl);return}gt(N.path)}},[ks,N]),r.useEffect(()=>{if(!C||(_e(),!a||!P))return;let l=!1;async function p(){if(!(l||oe.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){oe.current=!0;try{await _e({silent:!0})}finally{oe.current=!1}}}const d=window.setInterval(()=>{p()},Js),v=()=>{p()};return window.addEventListener("focus",v),()=>{l=!0,window.clearInterval(d),window.removeEventListener("focus",v)}},[a,_e,P,C]),r.useEffect(()=>{if(E||C||!a||!t||!m)return;let l=!1;async function p(){if(!(l||oe.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){oe.current=!0;try{await Ut.current({silent:!0})}catch{}finally{oe.current=!1}}}const d=window.setInterval(()=>{p()},Js),v=()=>{p()};return window.addEventListener("focus",v),()=>{l=!0,window.clearInterval(d),window.removeEventListener("focus",v)}},[t,a,E,C,m]),r.useEffect(()=>{if(C||!a||!t||n==="local_project"){mt(null);return}let l=!1;return I.workspaceTemplateConfig(a,t).then(p=>{l||mt(p.exists?p.configPath??Ea:null)}).catch(()=>{l||mt(null)}),()=>{l=!0}},[t,a,C,n]),r.useEffect(()=>{!b||we.includes(b)||ee.includes(b)||be(Ie[0]?.path??null)},[Ie,ee,we,b]),r.useEffect(()=>{z?.active&&pe&&D("goal")},[z?.active,pe]),r.useEffect(()=>{K&&D(K.tab)},[K]),r.useEffect(()=>{!pe&&F==="goal"&&D("files")},[F,pe]),r.useEffect(()=>{!Te&&F==="summary"&&D("files")},[F,Te]);const G=F==="file"||k&&F==="files"?b:null;r.useEffect(()=>{if(!a||!G)return;if(Ne(G)){je(null),ge(g=>g===G?null:g);return}const l=It?.path===G,p=et(G);if(E&&(p?.content!=null||p?.patch)){je(null),ge(g=>g===G?null:g);return}if(!l&&(p?.content!=null||p?.patch&&!Pe)){je(null),ge(g=>g===G?null:g);return}let d=!1;const v=js.current[G];return v?.content==null&&(Pe||!v?.patch)&&ge(G),je(null),(C?P?cl(a,P,G,i):Promise.reject(new Error(H?.emptyMessage??"No sandbox filesystem is available.")):t?I.workspaceFile(a,t,G):Promise.reject(new Error("Workspace files are unavailable."))).then(g=>{d||Le($=>{const L=$[g.path];return L?.content===g.content&&L.patch===g.patch&&L.status===g.status?$:{...$,[g.path]:g}})}).catch(g=>{d||je(g instanceof Error?g.message:String(g))}).finally(()=>{d||(ge(g=>g===G?null:g),ut(g=>g&&g.id===It?.id&&g.path===G?null:g))}),()=>{d=!0}},[F,t,a,It,Pe,E,i,H?.emptyMessage,P,C,G]);function gt(l){const p=ss(l,Je);p&&(ct(d=>{if(!d.has(p))return d;const v=new Set(d);return v.delete(p),v}),Le(d=>{if(!(p in d))return d;const v={...d};return delete v[p],v}),dt(d=>{if(!(p in d))return d;const v={...d};return delete v[p],v}),ut({id:Date.now(),path:p}),k||He(d=>d.includes(p)?d:[...d,p]),be(p),D(k?"files":"file"),!C&&a&&t&&Ne(p)&&pt(p),X(!1),se(!1),Pt(""))}function Dn(l,p){const d=ss(l.path,Je);if(!d)return;const v={...l,path:d};Le(y=>({...y,[d]:v})),ct(y=>{const g=new Set(y);return g.add(d),g}),dt(y=>{if(!p){if(!(d in y))return y;const g={...y};return delete g[d],g}return y[d]===p?y:{...y,[d]:p}}),ut(null),je(null),ge(null),k||He(y=>y.includes(d)?y:[...y,d]),be(d),D(k?"files":"file"),X(!1),se(!1),Pt("")}const Tn=r.useCallback(()=>{kn(l=>{const p=!l;return wl(p),p})},[]),et=l=>Rl(ve.get(l),ne[l],ke.get(l),l),_n=r.useCallback((l,p)=>{Ve(d=>{const v=d[l],y=v?.savedContent??bt[l]??et(l).content??"";return{...d,[l]:{content:p,savedContent:y,savedAt:v?.savedAt}}}),Xe(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v})},[ve,ke,ne,bt]),Be=r.useCallback(async(l,p={})=>{if(C||!a||!t||Ne(l))return;const d=et(l),v=p.content??ue[l]?.content??d.content??void 0;if(v?.endsWith(Rt))return;const y=Qe.current+1;Qe.current=y,fe.current?.abort(new Error("lsp_diagnostics_superseded"));const g=new AbortController;fe.current=g,zt(l);try{const $=await I.workspaceLspTouch(a,t,{path:l,content:v,waitForDiagnostics:p.waitForDiagnostics??!0},{signal:g.signal});if(y!==Qe.current)return;_t(L=>({...L,[$.path]:$.diagnostics})),Mt(L=>({...L,[$.path]:$.servers}))}catch($){if(g.signal.aborted||y!==Qe.current)return;const L=$ instanceof Error?$.message:String($);_t(at=>({...at,[l]:[]})),Mt(at=>({...at,[l]:[{id:"lsp",root:"",status:"error",message:L}]}))}finally{if(fe.current===g&&(fe.current=null),g.signal.aborted)return;y===Qe.current&&zt($=>$===l?null:$)}},[t,a,ve,ke,ue,ne,C]),Mn=r.useCallback(async l=>{if(C||!a||!t)throw new Error("Workspace LSP is unavailable.");return I.workspaceLspAction(a,t,l)},[t,a,C]),tt=r.useCallback(async l=>{if(!a||!t&&!P||Ze.current===l)return;const p=ue[l];if(!p||p.content===p.savedContent)return;const d=p.content,v=Date.now();Ze.current=l,Wt(l),Xe(y=>{if(!(l in y))return y;const g={...y};return delete g[l],g});try{const y=C?await ml(a,P,l,d):await I.saveWorkspaceFile(a,t,{path:l,content:d});Le(g=>({...g,[y.path]:y})),Ve(g=>{const $=g[l];return $?{...g,[l]:{content:$.content,savedContent:d,savedAt:v}}:g}),te.languageServers!=="off"&&te.checkOnSave&&await Be(l,{content:d,waitForDiagnostics:!0}),C?await _e({silent:!0}):await B({silent:!0})}catch(y){Xe(g=>({...g,[l]:y instanceof Error?y.message:String(y)}))}finally{Ze.current===l&&(Ze.current=null),Wt(y=>y===l?null:y)}},[te.checkOnSave,te.languageServers,t,a,ue,B,Be,_e,P,C]),Rs=b?et(b):null,st=!!(b&&ot.has(b)),ye=b?ue[b]?.content??Rs?.content??null:null,zn=!!(Rs?.patch&&!Pe),Vt=!!(!E&&!st&&F==="file"&&!zn&&b&&ye!=null&&!Ne(b)&&!(Lt&&ts(b))&&!ye.endsWith(Rt));r.useEffect(()=>{if(te.languageServers==="off"||!te.diagnosticsWhileEditing||!b||!Vt||ye==null)return;const l=window.setTimeout(()=>{Be(b,{content:ye,waitForDiagnostics:!0})},700);return()=>window.clearTimeout(l)},[te.diagnosticsWhileEditing,te.languageServers,Be,ye,Vt,b]),r.useEffect(()=>{function l(p){!(p.ctrlKey||p.metaKey)||p.key.toLowerCase()!=="s"||F!=="file"||!b||(p.preventDefault(),We.has(b)&&tt(b))}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[F,We,tt,b]);const In=r.useCallback(()=>{b&&(Ye.current?Ye.current.save():tt(b))},[tt,b]),Wn=r.useCallback(()=>{Ye.current?.undo()},[]),Bn=r.useCallback(()=>{Ye.current?.redo()},[]),On=r.useCallback(()=>{b&&te.languageServers!=="off"&&Be(b,{content:ye??void 0,waitForDiagnostics:!0})},[te.languageServers,Be,ye,b]);function Un(l,p){if(p.stopPropagation(),!(We.has(l)&&!window.confirm(`Discard unsaved changes to ${l}?`))&&(We.has(l)&&(Ve(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),Xe(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v})),He(d=>d.filter(v=>v!==l)),ot.has(l)&&Le(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),dt(d=>{if(!(l in d))return d;const v={...d};return delete v[l],v}),ct(d=>{if(!d.has(l))return d;const v=new Set(d);return v.delete(l),v}),b===l)){const d=Cs.find(v=>v.path!==l)??null;be(d?.path??Ie[0]?.path??null),d||D("files")}}function Hn(){D("files"),X(!1),se(!1)}function $s(l){Dt(p=>{const d=new Set(p);return d.has(l)?d.delete(l):d.add(l),d})}function Vn(l){l&&Dt(p=>{const d=new Set(p);for(const v of El(l))d.add(v);return d}),D("files"),X(!1),se(!1)}function Kn(){const p=`git apply <<'PATCH'
12
12
  ${Ie.map(d=>d.patch).filter(Boolean).join(`
13
13
  `)}
14
- PATCH`;navigator.clipboard?.writeText(p)}const Gn=Ie.length>0,qn=we.length>0,Xn=ee.length>0,Zn=pe||Te||Gn||qn||Xn,me=F==="goal"&&pe?"goal":F==="summary"&&Te?"summary":F==="file"&&b?"file":"files",Qn=me==="files"?"No files to show":"No local changes",Yn=n==="local_project"&&!m&&!o,Fs=C?Nn:f,Es=C?bs:o,Jn=Rl({changedFiles:he?.filesChanged??Ie.length,checkpointStatus:Pn,dirty:!!he?.dirty,error:Es,loading:Fs,preservedReadback:An,sandboxMode:C,sourcePending:C&&!P}),ea=Fs?"Loading workspace files":Es?"Workspace files are unavailable":C&&!P?H?.emptyMessage??"No sandbox filesystem is available.":Yn?"Loading workspace files":m?Qn:"No local files to show",As=b?ms[b]??null:null,ta=!As&&!C&&b&&Ne(b)?b:null,Ps=De?ms[De]??null:null,sa=!Ps&&!C&&De&&Ne(De)?De:null,na=Us(a,t,ta),aa=Us(a,t,sa),Kt=As??na,Ls=Ps??aa,Ds=me==="file"||k&&me==="files"?b:null,ia=!!(Ds&&ts(Ds)),Ts=b?gs[b]??[]:[],_s=b?Cn[b]??null:null,Gt=!!(b&&Rn===b),qt=us&&Vt,nt=!E&&!st&&!C&&te.languageServers!=="off",la=r.useMemo(()=>yl({activeDiagnostics:Ts,activeServers:_s,editorDiagnosticsChecking:Gt,editorLspEnabled:nt,showEditorCommandBar:qt}),[Ts,_s,Gt,nt,qt]),ra=r.useCallback(async l=>{if(!a)throw new Error("OpenPond server connection is unavailable.");await I.runSubagentLifecycleAction(a,l.runId,{action:l.action,reason:"User requested from Goal details."}),await B({silent:!0})},[a,B]),xe=C?"sandbox":n==="local_project"?"local":null,jt=r.useMemo(()=>{const l=new Map;if(!xe||!s)return l;for(const p of re)p.workspaceKind!==xe||p.workspaceId!==s||l.set(p.path,p);return l},[re,xe,s]),vt=r.useCallback(l=>{try{return jt.get(Os(l))?.status??null}catch{return null}},[jt]),kt=r.useCallback((l,p)=>{if(!xe||!s||!h||!J)return;let d;try{d=Os(l)}catch{return}const v=jt.get(d),y=new Date().toISOString(),g=v??{id:Pa({workspaceKind:xe,workspaceId:s,path:d}),workspaceKind:xe,workspaceId:s,workspaceName:h,path:d,status:"pinned",order:null,sourceSessionId:Y,available:!0,createdAt:y,updatedAt:y};J(g,p)},[J,jt,Y,xe,s,h]),Se=!!(xe&&s&&h&&J),oa=b&&Se&&!st?e.jsx(is,{currentStatus:vt(b),onSetStatus:l=>kt(b,l)}):null,Ms=b?e.jsx(Ji,{diagnostics:nt?gs[b]??[]:[],draftContent:ue[b]?.content,editorRef:Ye,editable:!E&&!st&&!Kt,error:Fn,file:et(b),collapsed:ds,hideWhiteSpace:ps,headerActions:oa,imageSrc:Kt,loading:$n===b,loadFullFiles:Pe,saveError:En[b]??null,saving:ft===b,onOpenImage:()=>{Kt&&pt(b)},onDraftContentChange:l=>_n(b,l),onLspAction:nt?Mn:void 0,onSave:()=>{tt(b)},onSelectBreadcrumbPath:Vn,renderMarkdown:Lt,splitView:hs,wordDiffs:fs,wordWrap:cs,workspaceName:h,workspaceRootPath:Je}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:`workspace-diff-panel ${x?"expanded":""}`,id:"right-sidebar-files-panel",role:"tabpanel","aria-label":"Workspace diffs",children:[!x&&e.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize diff panel",onPointerDown:j}),e.jsx(Oi,{addMenuOpen:Ae,expanded:x,filteredFiles:Ln,openFiles:Cs,dirtyFilePaths:We,goalDetailsAvailable:pe,searchOpen:xn,searchQuery:At,selectedPath:b,sideChatTabs:_,summaryAvailable:Te,sourceStatus:Jn,sourceSwitcher:W,visibleTab:me,getFileBookmarkStatus:Se?vt:void 0,onCloseFileTab:Un,onCloseSideChat:A,onCloseSearch:()=>se(!1),onOpenFile:gt,onOpenBrowser:T?()=>{X(!1),se(!1),T()}:void 0,onOpenSearch:()=>{X(!1),se(!0)},onOpenSideChat:Q?()=>{X(!1),se(!1),Q()}:void 0,onSearchQueryChange:Pt,onSetFileBookmarkStatus:Se?kt:void 0,onSelectFile:l=>{be(l),D("file")},onSelectFiles:Hn,onSelectGoal:()=>D("goal"),onSelectSummary:()=>{D("summary"),X(!1),se(!1)},onSelectSideChat:q,onToggleAddMenu:()=>{X(l=>!l),se(!1)},onToggleExpanded:R}),me==="goal"&&pe?e.jsx(di,{createRuntime:z?.createRuntime??null,goalRuntime:z?.goalRuntime??null,subagentRuntime:z?.subagentRuntime??null,onRunSubagentLifecycleAction:a?ra:void 0}):me==="summary"&&Te?le?e.jsx(zi,{summary:le}):e.jsx(Ei,{sandboxId:P,connection:a}):Zn?e.jsxs(e.Fragment,{children:[e.jsx(Ui,{canSaveActiveFile:!!(!E&&!st&&b&&We.has(b)&&ft!==b),canCheckActiveFile:nt,collapsed:ds,editorControlsVisible:us,editorDiagnosticStatus:la,editorDiagnosticsChecking:Gt,hideWhiteSpace:ps,loadFullFiles:Pe,menuOpen:de,renderMarkdown:Lt,showEditorCommandBar:qt,showRenderMarkdownToggle:ia,splitView:hs,wordDiffs:fs,wordWrap:cs,onCopyGitApply:Kn,onEditorCheck:On,onEditorRedo:Bn,onEditorSave:In,onEditorUndo:Wn,onRefresh:()=>{C?_e():B()},onToggleCollapsed:()=>gn(l=>!l),onToggleEditorControlsVisible:Tn,onToggleHideWhiteSpace:()=>yn(l=>!l),onToggleLoadFullFiles:()=>jn(l=>!l),onToggleMenu:l=>Et(p=>l??!p),onToggleRenderMarkdown:()=>vn(l=>!l),onToggleSplitView:()=>Sn(l=>!l),onToggleWordDiffs:()=>wn(l=>!l),onToggleWordWrap:()=>bn(l=>!l)}),me==="files"&&(k?e.jsxs("div",{className:"workspace-diff-files-preview-layout",children:[e.jsx(Xs,{diff:he,expandedFolderPaths:xs,rootPath:S,repoFiles:we,selectedPath:b,getFileBookmarkStatus:Se?vt:void 0,onOpenFile:gt,onSetFileBookmarkStatus:Se?kt:void 0,onToggleFolder:$s}),Ms??e.jsx("div",{className:"workspace-diff-files-preview-empty",children:"Select a file to review its changes."})]}):e.jsx(Xs,{diff:he,expandedFolderPaths:xs,rootPath:S,repoFiles:we,selectedPath:b,getFileBookmarkStatus:Se?vt:void 0,onOpenFile:gt,onSetFileBookmarkStatus:Se?kt:void 0,onToggleFolder:$s})),me==="file"&&b&&Ms]}):e.jsx("div",{className:"workspace-diff-empty",children:e.jsx("span",{children:ea})})]}),e.jsx(Wa,{open:!!Ls,src:Ls,title:De??"",onClose:()=>pt(null)})]})}export{Il as WorkspaceDiffPanel};
14
+ PATCH`;navigator.clipboard?.writeText(p)}const Gn=Ie.length>0,qn=we.length>0,Xn=ee.length>0,Zn=pe||Te||Gn||qn||Xn,me=F==="goal"&&pe?"goal":F==="summary"&&Te?"summary":F==="file"&&b?"file":"files",Qn=me==="files"?"No files to show":"No local changes",Yn=n==="local_project"&&!m&&!o,Fs=C?Nn:f,Es=C?bs:o,Jn=$l({changedFiles:he?.filesChanged??Ie.length,checkpointStatus:Pn,dirty:!!he?.dirty,error:Es,loading:Fs,preservedReadback:An,sandboxMode:C,sourcePending:C&&!P}),ea=Fs?"Loading workspace files":Es?"Workspace files are unavailable":C&&!P?H?.emptyMessage??"No sandbox filesystem is available.":Yn?"Loading workspace files":m?Qn:"No local files to show",As=b?ms[b]??null:null,ta=!As&&!C&&b&&Ne(b)?b:null,Ps=De?ms[De]??null:null,sa=!Ps&&!C&&De&&Ne(De)?De:null,na=Us(a,t,ta),aa=Us(a,t,sa),Kt=As??na,Ls=Ps??aa,Ds=me==="file"||k&&me==="files"?b:null,ia=!!(Ds&&ts(Ds)),Ts=b?gs[b]??[]:[],_s=b?Cn[b]??null:null,Gt=!!(b&&Rn===b),qt=us&&Vt,nt=!E&&!st&&!C&&te.languageServers!=="off",la=r.useMemo(()=>yl({activeDiagnostics:Ts,activeServers:_s,editorDiagnosticsChecking:Gt,editorLspEnabled:nt,showEditorCommandBar:qt}),[Ts,_s,Gt,nt,qt]),ra=r.useCallback(async l=>{if(!a)throw new Error("OpenPond server connection is unavailable.");await I.runSubagentLifecycleAction(a,l.runId,{action:l.action,reason:"User requested from Goal details."}),await B({silent:!0})},[a,B]),xe=C?"sandbox":n==="local_project"?"local":null,jt=r.useMemo(()=>{const l=new Map;if(!xe||!s)return l;for(const p of re)p.workspaceKind!==xe||p.workspaceId!==s||l.set(p.path,p);return l},[re,xe,s]),vt=r.useCallback(l=>{try{return jt.get(Os(l))?.status??null}catch{return null}},[jt]),kt=r.useCallback((l,p)=>{if(!xe||!s||!h||!J)return;let d;try{d=Os(l)}catch{return}const v=jt.get(d),y=new Date().toISOString(),g=v??{id:Pa({workspaceKind:xe,workspaceId:s,path:d}),workspaceKind:xe,workspaceId:s,workspaceName:h,path:d,status:"pinned",order:null,sourceSessionId:Y,available:!0,createdAt:y,updatedAt:y};J(g,p)},[J,jt,Y,xe,s,h]),Se=!!(xe&&s&&h&&J),oa=b&&Se&&!st?e.jsx(is,{currentStatus:vt(b),onSetStatus:l=>kt(b,l)}):null,Ms=b?e.jsx(Ji,{diagnostics:nt?gs[b]??[]:[],draftContent:ue[b]?.content,editorRef:Ye,editable:!E&&!st&&!Kt,error:Fn,file:et(b),collapsed:ds,hideWhiteSpace:ps,headerActions:oa,imageSrc:Kt,loading:$n===b,loadFullFiles:Pe,saveError:En[b]??null,saving:ft===b,onOpenImage:()=>{Kt&&pt(b)},onDraftContentChange:l=>_n(b,l),onLspAction:nt?Mn:void 0,onSave:()=>{tt(b)},onSelectBreadcrumbPath:Vn,renderMarkdown:Lt,splitView:hs,wordDiffs:fs,wordWrap:cs,workspaceName:h,workspaceRootPath:Je}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:`workspace-diff-panel ${x?"expanded":""}`,id:"right-sidebar-files-panel",role:"tabpanel","aria-label":"Workspace diffs",children:[!x&&e.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize diff panel",onPointerDown:j}),e.jsx(Oi,{addMenuOpen:Ae,expanded:x,filteredFiles:Ln,openFiles:Cs,dirtyFilePaths:We,goalDetailsAvailable:pe,searchOpen:xn,searchQuery:At,selectedPath:b,sideChatTabs:_,summaryAvailable:Te,sourceStatus:Jn,sourceSwitcher:W,visibleTab:me,getFileBookmarkStatus:Se?vt:void 0,onCloseFileTab:Un,onCloseSideChat:A,onCloseSearch:()=>se(!1),onOpenFile:gt,onOpenBrowser:T?()=>{X(!1),se(!1),T()}:void 0,onOpenSearch:()=>{X(!1),se(!0)},onOpenSideChat:Q?()=>{X(!1),se(!1),Q()}:void 0,onSearchQueryChange:Pt,onSetFileBookmarkStatus:Se?kt:void 0,onSelectFile:l=>{be(l),D("file")},onSelectFiles:Hn,onSelectGoal:()=>D("goal"),onSelectSummary:()=>{D("summary"),X(!1),se(!1)},onSelectSideChat:q,onToggleAddMenu:()=>{X(l=>!l),se(!1)},onToggleExpanded:R}),me==="goal"&&pe?e.jsx(di,{createRuntime:z?.createRuntime??null,goalRuntime:z?.goalRuntime??null,subagentRuntime:z?.subagentRuntime??null,onRunSubagentLifecycleAction:a?ra:void 0}):me==="summary"&&Te?le?e.jsx(zi,{summary:le}):e.jsx(Ei,{sandboxId:P,connection:a}):Zn?e.jsxs(e.Fragment,{children:[e.jsx(Ui,{canSaveActiveFile:!!(!E&&!st&&b&&We.has(b)&&ft!==b),canCheckActiveFile:nt,collapsed:ds,editorControlsVisible:us,editorDiagnosticStatus:la,editorDiagnosticsChecking:Gt,hideWhiteSpace:ps,loadFullFiles:Pe,menuOpen:de,renderMarkdown:Lt,showEditorCommandBar:qt,showRenderMarkdownToggle:ia,splitView:hs,wordDiffs:fs,wordWrap:cs,onCopyGitApply:Kn,onEditorCheck:On,onEditorRedo:Bn,onEditorSave:In,onEditorUndo:Wn,onRefresh:()=>{C?_e():B()},onToggleCollapsed:()=>gn(l=>!l),onToggleEditorControlsVisible:Tn,onToggleHideWhiteSpace:()=>yn(l=>!l),onToggleLoadFullFiles:()=>jn(l=>!l),onToggleMenu:l=>Et(p=>l??!p),onToggleRenderMarkdown:()=>vn(l=>!l),onToggleSplitView:()=>Sn(l=>!l),onToggleWordDiffs:()=>wn(l=>!l),onToggleWordWrap:()=>bn(l=>!l)}),me==="files"&&(k?e.jsxs("div",{className:"workspace-diff-files-preview-layout",children:[e.jsx(Xs,{diff:he,expandedFolderPaths:xs,rootPath:S,repoFiles:we,selectedPath:b,getFileBookmarkStatus:Se?vt:void 0,onOpenFile:gt,onSetFileBookmarkStatus:Se?kt:void 0,onToggleFolder:$s}),Ms??e.jsx("div",{className:"workspace-diff-files-preview-empty",children:"Select a file to review its changes."})]}):e.jsx(Xs,{diff:he,expandedFolderPaths:xs,rootPath:S,repoFiles:we,selectedPath:b,getFileBookmarkStatus:Se?vt:void 0,onOpenFile:gt,onSetFileBookmarkStatus:Se?kt:void 0,onToggleFolder:$s})),me==="file"&&b&&Ms]}):e.jsx("div",{className:"workspace-diff-empty",children:e.jsx("span",{children:ea})})]}),e.jsx(Wa,{open:!!Ls,src:Ls,title:De??"",onClose:()=>pt(null)})]})}const Wl=Object.freeze(Object.defineProperty({__proto__:null,WorkspaceDiffPanel:Cl},Symbol.toStringTag,{value:"Module"}));export{ti as C,Cl as W,Wl as a};
@@ -1,4 +1,4 @@
1
- import{c as ut,b6 as Ye,r as m,b7 as Mt,b8 as Ut,j as t,X as mt,b9 as Ae,ba as Lt,bb as Ne,aR as Ot,G as Ft,a4 as at,S as Bt,a5 as Dt,aL as Gt,ay as Tt,bc as kt,bd as st,p as O,aI as Ht,$ as Vt,C as Xt,ar as Jt,d as Kt}from"./index-BO2W2U23.js";import{G as Je}from"./git-branch-eCwyZXMl.js";import{I as Qt}from"./info-p1mFpqBI.js";import{S as Zt,a as Yt}from"./square-DAGpFfSr.js";import{P as $e}from"./play-Ctx-iMqd.js";import{G as Wt}from"./git-commit-horizontal-cPm51DqY.js";import{R as Ke}from"./refresh-cw-Bn28jIl0.js";import{U as rt}from"./upload-vaAKFfxi.js";const en=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],tn=ut("hammer",en);const nn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],an=ut("monitor",nn);function sn(e){const n=te(e?.data),a=te(n.preview);return(typeof a.url=="string"?a.url.trim():"")||null}function rn(){const e=window.open("","_blank");return e?(e.document.write('<!doctype html><title>Opening sandbox preview</title><body style="margin:0;background:#05070a;color:#f5f5f4;font:14px system-ui,sans-serif;display:grid;place-items:center;height:100vh;">Opening sandbox preview...</body>'),e.document.close(),e):null}function ye(e,n){if(!n){e?.close();return}if(e){e.opener=null,e.location.href=n;return}window.open(n,"_blank","noopener,noreferrer")}function pt(e){const n=ln(e),a=on(te(e?.resources)),i=te(te(e?.inputs).schema),g=te(i.properties),u=new Set(ft(i.required)),l=[],x=[];for(const[p,N]of Object.entries(g)){const c=te(N),U=te(c["x-openpond-upload"]??c.xOpenPondUpload),I=typeof c.type=="string"?c.type:"string",H=te(c.items),z=gn(c,U),v=c.format==="file"||U.enabled===!0||I==="array"&&H.format==="file",q=typeof c.title=="string"&&c.title.trim()?c.title.trim():hn(p);if(v){x.push({name:p,label:q,required:u.has(p),multiple:I==="array"||U.multiple===!0,accept:bn(U,c),targetPath:fn(U,p),targetNames:z});continue}(I==="string"||I==="number"||I==="integer"||I==="boolean")&&l.push({name:p,label:q,required:u.has(p),type:I,defaultValue:typeof c.default=="string"||typeof c.default=="number"||typeof c.default=="boolean"?String(c.default):"",targetNames:z})}return{entrypoints:n,scalarInputs:l,fileInputs:x,envInputs:dn(e),resources:a,volumes:cn(e,x),schedules:un(e)}}function Fe(e,n){const a=n.trim();return e.filter(i=>!i.targetNames||i.targetNames.length===0?!0:i.targetNames.includes(a))}function ln(e){return e?Ye(e).flatMap(n=>{if(n.kind==="action")return[];const a=n.name.trim(),i=n.command.trim(),g=Be(n.timeoutSeconds),u=n.ports.flatMap(l=>{const x=Be(l.port);return x?[{port:x,label:typeof l.label=="string"&&l.label.trim()?l.label.trim():"web",access:l.access==="public"?"public":"private",path:typeof l.path=="string"&&l.path.trim()?l.path.trim():"/"}]:[]});return a&&i?[{name:a,command:i,timeoutSeconds:g,ports:u}]:[]}):[]}function on(e){return{cpu:Qe(e.cpu)??1,memoryGb:Qe(e.memoryGb)??1,diskGb:Qe(e.diskGb)??8}}function cn(e,n){const a=Array.isArray(e?.volumes)?e.volumes:[];if(a.length>0)return a.map((u,l)=>{const x=l===0?"volume":`volume-${l+1}`,p=typeof u.name=="string"&&u.name.trim()?u.name.trim():x;return{name:p,mountPath:typeof u.mountPath=="string"&&u.mountPath.trim()?u.mountPath.trim():`/workspace/volumes/${p}`,...Be(u.storageGb)?{storageGb:Be(u.storageGb)??void 0}:{},deleteOnSandboxDelete:u.deleteOnSandboxDelete===!0}});const i=n.find(u=>u.targetPath.startsWith("volumes/"));if(!i)return[];const[,g="volume"]=i.targetPath.split("/");return[{name:g,mountPath:`/workspace/volumes/${g}`,storageGb:8,deleteOnSandboxDelete:!1}]}function dn(e){return(Array.isArray(e?.inputs.env)?e.inputs.env:[]).flatMap(a=>{const i=typeof a.name=="string"?a.name.trim():"";return i?[{name:i,required:a.required===!0,secret:a.secret!==!1,description:typeof a.description=="string"?a.description.trim():""}]:[]})}function un(e){return e?.schedules?.length?e.schedules.flatMap(n=>{const a=typeof n.name=="string"?n.name.trim():"",i=mn(n);if(!a||!i.scheduleExpression)return[];try{return[{name:a,...typeof n.description=="string"&&n.description.trim()?{description:n.description.trim()}:{},enabled:!1,...i,...typeof n.timezone=="string"&&n.timezone.trim()?{timezone:n.timezone.trim()}:{},...typeof n.startAt=="string"&&n.startAt.trim()?{startAt:n.startAt.trim()}:{},...typeof n.endAt=="string"&&n.endAt.trim()?{endAt:n.endAt.trim()}:{},...typeof n.maxRuns=="number"&&Number.isInteger(n.maxRuns)&&n.maxRuns>0?{maxRuns:n.maxRuns}:{},runtimePolicy:n.runtimePolicy,target:pn(e,n),...n.budget?{budget:n.budget}:{},...n.resources?{resources:n.resources}:{},...n.quotas?{quotas:n.quotas}:{},...n.lifecycle?{lifecycle:n.lifecycle}:{},...n.retentionPolicy?{retentionPolicy:n.retentionPolicy}:{},...n.env?{env:n.env}:{},...n.integrationLeases?{integrationLeases:n.integrationLeases}:{},metadata:{...te(n.metadata),manifestScheduleName:a,source:"openpond-app-sandbox-template-start"}}]}catch{return[]}}):[]}function mn(e){return e.scheduleExpression?{scheduleType:e.scheduleType??"cron",scheduleExpression:e.scheduleExpression}:e.rate?{scheduleType:"rate",scheduleExpression:/^rate\(/i.test(e.rate)?e.rate:`rate(${e.rate})`}:e.once?{scheduleType:"once",scheduleExpression:/^at\(/i.test(e.once)?e.once:`at(${e.once})`}:{scheduleType:"cron",scheduleExpression:e.cron??""}}function pn(e,n){const a=n.command??n.target?.command??null;if(a)return{kind:"command",command:a,requiresStart:n.requiresStart??n.target?.requiresStart??!1};const i=n.target?.kind??"action";if(i==="start")return{kind:"command",command:e.start.command,requiresStart:n.requiresStart??n.target?.requiresStart??e.start.requiresStart??!1};if(i==="service"){const l=n.target?.name??"",x=e.services.find(p=>p.name===l);if(!x)throw new Error("schedule_service_target_missing");return{kind:"command",command:x.command,requiresStart:n.requiresStart??n.target?.requiresStart??x.requiresStart??!1}}const g=n.actionName??n.action??n.target?.actionName??(n.target?.kind==="action"?n.target?.name:void 0),u=e.actions.find(l=>l.name===g);if(!u)throw new Error("schedule_action_target_missing");return{kind:"command",command:u.command,requiresStart:n.requiresStart??n.target?.requiresStart??u.requiresStart??!1}}function gt(e,n){return e.flatMap(a=>{const i=(n[a.name]??"").trim();return i?[{name:a.name,secretRef:i}]:[]})}function bt(e,n){const a={};for(const i of e){const g=n[i.name]??"";if(!(!g.trim()&&!i.required))if(i.type==="boolean")a[i.name]=g==="true";else if(i.type==="number"||i.type==="integer"){const u=Number(g);Number.isFinite(u)&&(a[i.name]=i.type==="integer"?Math.trunc(u):u)}else a[i.name]=g}return a}function gn(e,n){const a=e["x-openpond-targets"]??e.xOpenPondTargets??n.targets??n.actions,i=ft(a).map(g=>g.trim()).filter(Boolean);return i.length>0?[...new Set(i)]:null}function bn(e,n){return typeof e.accept=="string"?e.accept.trim():Array.isArray(e.accept)?e.accept.filter(a=>typeof a=="string").join(","):typeof n.accept=="string"?n.accept.trim():""}function fn(e,n){return(typeof e.targetPath=="string"&&e.targetPath.trim()?e.targetPath.trim():typeof e.path=="string"&&e.path.trim()?e.path.trim():`uploads/${n}`).replace(/^\/+/,"").replace(/^workspace\//,"").replace(/\/+$/,"")}function Qe(e){const n=Number(e);return Number.isFinite(n)&&n>0?n:null}function Be(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function xn(e,n){return[n,...e.slice(1)]}function ft(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function hn(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function te(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function jn({busy:e,defaultRepoUrl:n,projectName:a,commitBeforeCreate:i,templateManifest:g,uploadBeforeCreate:u,onClose:l,onSubmit:x}){const p=m.useMemo(()=>pt(g),[g]),N=p.entrypoints[0]??null,[c,U]=m.useState(n),[I,H]=m.useState(N?.name??""),[z,v]=m.useState(N?.command??""),[q,V]=m.useState(N?.timeoutSeconds?String(N.timeoutSeconds):""),[X,b]=m.useState(`Update ${a}`),[j,A]=m.useState("0.05"),[_,F]=m.useState(()=>Object.fromEntries(p.scalarInputs.map(r=>[r.name,r.defaultValue]))),[B,ae]=m.useState(()=>Object.fromEntries(p.envInputs.map(r=>[r.name,""]))),[Z,fe]=m.useState({}),K=p.volumes[0]??null,[Y,o]=m.useState(p.volumes.length>0||p.fileInputs.length>0),[P,w]=m.useState(K?.name??"volume"),[R,$]=m.useState(K?.mountPath??"/workspace/volumes/volume"),[J,ce]=m.useState(String(K?.storageGb??8)),[Pe,de]=m.useState(!(K?.deleteOnSandboxDelete??!1)),[M,ze]=m.useState(p.schedules),qe=p.entrypoints.find(r=>r.name===I)??N,se=qe?.ports??[],re=se[0]??null,[ue,xe]=m.useState(!!re),[Ce,me]=m.useState(re?String(re.port):""),D=Number(Ce),he=Number(j),ie=Number(J),le=Number(q),ke=!q.trim()||Number.isInteger(le)&&le>0&&le<=86400,oe=!ue||Number.isInteger(D)&&D>=Mt&&D<=Ut&&se.some(r=>r.port===D),Ie=Number.isFinite(he)&&he>0,ne=!Y||Number.isInteger(ie)&&ie>0,G=M.every(r=>!r.enabled||!!r.scheduleExpression.trim()),W=Fe(p.scalarInputs,I),je=Fe(p.fileInputs,I),Me=p.envInputs.every(r=>!r.required||!!(B[r.name]??"").trim()),ve=p.envInputs.filter(r=>r.required&&!(B[r.name]??"").trim()),Re=(u||!!c.trim())&&!!z.trim()&&Ie&&ke&&ne&&W.every(r=>!r.required||!!(_[r.name]??"").trim())&&je.every(r=>!r.required||(Z[r.name]?.length??0)>0)&&Me&&G&&oe;function He(r){H(r);const f=p.entrypoints.find(E=>E.name===r);if(!f)return;v(f.command),V(f.timeoutSeconds?String(f.timeoutSeconds):"");const y=f.ports[0]??null;me(y?String(y.port):""),xe(!!y)}function _e(r,f){F(y=>({...y,[r]:f}))}function pe(r,f){ae(y=>({...y,[r]:f}))}function Ve(r,f){const y=Array.from(f.target.files??[]);fe(E=>({...E,[r.name]:r.multiple?y:y.slice(0,1)}))}function ee(r,f){ze(y=>y.map((E,ge)=>ge===r?{...E,...f}:E))}function Ee(r){r.preventDefault(),!(!Re||e)&&x({repoUrl:c.trim(),command:z.trim(),entrypointName:I,commitMessage:X.trim(),budgetUsd:j.trim(),params:bt(W,_),env:gt(p.envInputs,B),timeoutSeconds:q.trim()&&Number.isInteger(le)?le:qe?.timeoutSeconds??null,uploads:je.flatMap(f=>{const y=Z[f.name]??[];return y.length>0?[{inputName:f.name,label:f.label,targetPath:f.targetPath,multiple:f.multiple,files:y}]:[]}),resources:p.resources,volumes:Y?xn(p.volumes,{...P.trim()?{name:P.trim()}:{},...R.trim()?{mountPath:R.trim()}:{},...Number.isInteger(ie)&&ie>0?{storageGb:ie}:{},deleteOnSandboxDelete:!Pe}):[],schedules:M.filter(f=>f.enabled),openPreview:ue,previewPort:ue?D:null,previewLabel:se.find(f=>f.port===D)?.label??"web",previewAccess:se.find(f=>f.port===D)?.access??"private"})}return t.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:t.jsxs("form",{className:"git-dialog run-once-dialog sandbox-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Start sandbox",onSubmit:Ee,children:[t.jsx("button",{className:"git-dialog-close",disabled:e,type:"button",title:"Close","aria-label":"Close",onClick:l,children:t.jsx(mt,{size:15})}),t.jsxs("div",{className:"sandbox-start-dialog-heading",children:[t.jsx("div",{className:"git-dialog-icon",children:t.jsx(Ae,{size:18})}),t.jsx("h2",{children:"Start sandbox"}),t.jsxs("div",{className:"git-dialog-row",children:[t.jsx("span",{children:"Project"}),t.jsx("strong",{children:a})]})]}),t.jsxs("div",{className:"sandbox-start-dialog-body",children:[u?null:t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Repository"}),t.jsx("input",{disabled:e,value:c,onChange:r=>U(r.target.value)})]}),i?t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Commit message"}),t.jsx("input",{disabled:e,value:X,onChange:r=>b(r.target.value)})]}):null,p.entrypoints.length>0?t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Run target"}),t.jsx("select",{disabled:e,value:I,onChange:r=>He(r.target.value),children:p.entrypoints.map(r=>t.jsx("option",{value:r.name,children:r.name},r.name))})]}):null,t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Shell command"}),t.jsx("input",{disabled:e,value:z,onChange:r=>v(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Timeout seconds"}),t.jsx("input",{disabled:e,inputMode:"numeric",value:q,onChange:r=>V(r.target.value)})]}),W.map(r=>r.type==="boolean"?t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:(_[r.name]??"")==="true",disabled:e,type:"checkbox",onChange:f=>_e(r.name,f.target.checked?"true":"false")}),t.jsx("span",{}),r.label]},r.name):t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:r.label}),t.jsx("input",{disabled:e,inputMode:r.type==="number"||r.type==="integer"?"decimal":void 0,value:_[r.name]??"",onChange:f=>_e(r.name,f.target.value)})]},r.name)),je.map(r=>t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:r.label}),t.jsx("input",{accept:r.accept||void 0,disabled:e,multiple:r.multiple,type:"file",onChange:f=>Ve(r,f)})]},r.name)),p.envInputs.length>0?t.jsxs("div",{className:"sandbox-start-env-section",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Environment"}),ve.length>0?t.jsxs("p",{className:"sandbox-start-env-warning",role:"status",children:["Required sandbox secret ref missing: ",ve.map(r=>r.name).join(", ")]}):null,p.envInputs.map(r=>{const f=B[r.name]??"",y=r.required&&!f.trim(),E=`sandbox-env-${r.name}-description`;return t.jsxs("label",{className:"git-dialog-field",children:[t.jsxs("span",{children:[r.name,r.required?" *":""]}),t.jsx("input",{"aria-describedby":E,"aria-invalid":y,disabled:e,placeholder:"openpond://secret/...",value:f,onChange:ge=>pe(r.name,ge.target.value)}),t.jsx("small",{id:E,children:y?"Add a sandbox secret ref before starting.":r.description||"Sandbox secret ref only."})]},r.name)})]}):null,je.length>0||p.volumes.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:Y,disabled:e,type:"checkbox",onChange:r=>o(r.target.checked)}),t.jsx("span",{}),"Mount volume"]}),Y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"run-once-dialog-grid",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Volume"}),t.jsx("input",{disabled:e,value:P,onChange:r=>w(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Storage GiB"}),t.jsx("input",{disabled:e,inputMode:"numeric",value:J,onChange:r=>ce(r.target.value)})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Mount path"}),t.jsx("input",{disabled:e,value:R,onChange:r=>$(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:Pe,disabled:e,type:"checkbox",onChange:r=>de(r.target.checked)}),t.jsx("span",{}),"Keep volume"]})]}):null]}):null,M.length>0?t.jsxs("div",{className:"sandbox-start-schedules",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Schedules"}),M.map((r,f)=>t.jsxs("div",{className:"sandbox-start-schedule-row",children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:r.enabled,disabled:e,type:"checkbox",onChange:y=>ee(f,{enabled:y.target.checked})}),t.jsx("span",{}),r.name]}),t.jsxs("div",{className:"run-once-dialog-grid",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Type"}),t.jsxs("select",{disabled:e||!r.enabled,value:r.scheduleType,onChange:y=>ee(f,{scheduleType:y.target.value}),children:[t.jsx("option",{value:"rate",children:"Rate"}),t.jsx("option",{value:"cron",children:"Cron"}),t.jsx("option",{value:"once",children:"Once"})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Max runs"}),t.jsx("input",{disabled:e||!r.enabled,inputMode:"numeric",value:r.maxRuns??"",onChange:y=>{const E=Number(y.target.value);ee(f,{maxRuns:Number.isInteger(E)&&E>0?E:null})}})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Expression"}),t.jsx("input",{disabled:e||!r.enabled,value:r.scheduleExpression,onChange:y=>ee(f,{scheduleExpression:y.target.value})})]})]},r.name))]}):null,t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Budget"}),t.jsx("input",{disabled:e,inputMode:"decimal",value:j,onChange:r=>A(r.target.value)})]}),se.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:ue,disabled:e,type:"checkbox",onChange:r=>xe(r.target.checked)}),t.jsx("span",{}),"Open preview"]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Preview port"}),t.jsx("select",{disabled:e||!ue,value:Ce,onChange:r=>me(r.target.value),children:se.map(r=>t.jsx("option",{value:r.port,children:r.label?`${r.label} (${r.port})`:r.port},r.port))})]})]}):null]}),t.jsxs("div",{className:"git-dialog-footer sandbox-start-dialog-footer",children:[t.jsx("button",{className:"git-dialog-secondary",disabled:e,type:"button",onClick:l,children:"Cancel"}),t.jsxs("button",{className:"git-dialog-primary",disabled:e||!Re,title:Me?void 0:"Required sandbox secret refs are missing.",type:"submit",children:[t.jsx(Lt,{size:14}),"Start"]})]})]})})}function vn({busy:e,projectName:n,templateManifest:a,onClose:i,onSubmit:g}){const u=m.useMemo(()=>pt(a),[a]),l=m.useMemo(()=>a?Ye(a).filter(o=>o.kind==="action"):[],[a]),x=l[0]??null,[p,N]=m.useState("sandbox"),[c,U]=m.useState(x?.name??""),[I,H]=m.useState(()=>Object.fromEntries(u.scalarInputs.map(o=>[o.name,o.defaultValue]))),[z,v]=m.useState(()=>Object.fromEntries(u.envInputs.map(o=>[o.name,""]))),[q,V]=m.useState({}),X=Fe(u.scalarInputs,c),b=Fe(u.fileInputs,c),j=p==="sandbox"?u.envInputs:[],A=X.every(o=>!o.required||!!(I[o.name]??"").trim()),_=b.every(o=>!o.required||(q[o.name]?.length??0)>0),F=j.every(o=>!o.required||!!(z[o.name]??"").trim()),B=j.filter(o=>o.required&&!(z[o.name]??"").trim()),ae=!!c&&A&&_&&F;function Z(o,P){H(w=>({...w,[o]:P}))}function fe(o,P){v(w=>({...w,[o]:P}))}function K(o,P,w){const R=Array.from(w.target.files??[]);V($=>({...$,[o]:P?R:R.slice(0,1)}))}function Y(o){o.preventDefault(),!(!ae||e)&&g({mode:p,target:c,params:bt(X,I),env:p==="sandbox"?gt(j,z):[],uploads:b.flatMap(P=>{const w=q[P.name]??[];return w.length>0?[{inputName:P.name,label:P.label,targetPath:P.targetPath,multiple:P.multiple,files:w}]:[]})})}return t.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:t.jsxs("form",{className:"git-dialog run-once-dialog sandbox-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Run sandbox action",onSubmit:Y,children:[t.jsx("button",{className:"git-dialog-close",disabled:e,type:"button",title:"Close","aria-label":"Close",onClick:i,children:t.jsx(mt,{size:15})}),t.jsxs("div",{className:"sandbox-start-dialog-heading",children:[t.jsx("div",{className:"git-dialog-icon",children:t.jsx($e,{size:18})}),t.jsx("h2",{children:"Run action"}),t.jsxs("div",{className:"git-dialog-row",children:[t.jsx("span",{children:"Project"}),t.jsx("strong",{children:n})]})]}),t.jsxs("div",{className:"sandbox-start-dialog-body",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Action"}),t.jsx("select",{disabled:e||l.length===0,value:c,onChange:o=>U(o.target.value),children:l.map(o=>t.jsx("option",{value:o.name,children:o.name},o.name))})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Run on"}),t.jsxs("select",{disabled:e,value:p,onChange:o=>N(o.target.value==="local"?"local":"sandbox"),children:[t.jsx("option",{value:"sandbox",children:"Hosted sandbox (start/update)"}),t.jsx("option",{value:"local",children:"Local machine"})]})]}),X.map(o=>o.type==="boolean"?t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:(I[o.name]??"")==="true",disabled:e,type:"checkbox",onChange:P=>Z(o.name,P.target.checked?"true":"false")}),t.jsx("span",{}),o.label]},o.name):t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:o.label}),t.jsx("input",{disabled:e,inputMode:o.type==="number"||o.type==="integer"?"decimal":void 0,value:I[o.name]??"",onChange:P=>Z(o.name,P.target.value)})]},o.name)),b.map(o=>t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:o.label}),t.jsx("input",{accept:o.accept||void 0,disabled:e,multiple:o.multiple,type:"file",onChange:P=>K(o.name,o.multiple,P)})]},o.name)),j.length>0?t.jsxs("div",{className:"sandbox-start-env-section",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Environment"}),B.length>0?t.jsxs("p",{className:"sandbox-start-env-warning",role:"status",children:["Required sandbox secret ref missing: ",B.map(o=>o.name).join(", ")]}):null,j.map(o=>{const P=z[o.name]??"",w=o.required&&!P.trim(),R=`sandbox-action-env-${o.name}-description`;return t.jsxs("label",{className:"git-dialog-field",children:[t.jsxs("span",{children:[o.name,o.required?" *":""]}),t.jsx("input",{"aria-describedby":R,"aria-invalid":w,disabled:e,placeholder:"openpond://secret/...",value:P,onChange:$=>fe(o.name,$.target.value)}),t.jsx("small",{id:R,children:w?"Add a sandbox secret ref before running.":o.description||"Sandbox secret ref only."})]},o.name)})]}):null]}),t.jsxs("div",{className:"git-dialog-footer sandbox-start-dialog-footer",children:[t.jsx("button",{className:"git-dialog-secondary",disabled:e,type:"button",onClick:i,children:"Cancel"}),t.jsxs("button",{className:"git-dialog-primary",disabled:e||!ae,title:F?void 0:"Required sandbox secret refs are missing.",type:"submit",children:[t.jsx($e,{size:14}),"Run"]})]})]})})}function xt(e,n){const a=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent";return n==="cron"?`name: ${a}
1
+ import{c as ut,b6 as Ye,r as m,b7 as Mt,b8 as Ut,j as t,X as mt,b9 as Ae,ba as Lt,bb as Ne,aR as Ot,G as Ft,a4 as at,S as Bt,a5 as Dt,aL as Gt,ay as Tt,bc as kt,bd as st,p as O,aI as Ht,$ as Vt,C as Xt,ar as Jt,d as Kt}from"./index-LrGasYyx.js";import{G as Je}from"./git-branch-C45ve7zh.js";import{I as Qt}from"./info-DTObFlHw.js";import{S as Zt,a as Yt}from"./square-B5q2aneb.js";import{P as $e}from"./play-Cbsyrwkw.js";import{G as Wt}from"./git-commit-horizontal-CGoLIyKK.js";import{R as Ke}from"./refresh-cw-ChUK_QfF.js";import{U as rt}from"./upload-DcewuCTa.js";const en=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],tn=ut("hammer",en);const nn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],an=ut("monitor",nn);function sn(e){const n=te(e?.data),a=te(n.preview);return(typeof a.url=="string"?a.url.trim():"")||null}function rn(){const e=window.open("","_blank");return e?(e.document.write('<!doctype html><title>Opening sandbox preview</title><body style="margin:0;background:#05070a;color:#f5f5f4;font:14px system-ui,sans-serif;display:grid;place-items:center;height:100vh;">Opening sandbox preview...</body>'),e.document.close(),e):null}function ye(e,n){if(!n){e?.close();return}if(e){e.opener=null,e.location.href=n;return}window.open(n,"_blank","noopener,noreferrer")}function pt(e){const n=ln(e),a=on(te(e?.resources)),i=te(te(e?.inputs).schema),g=te(i.properties),u=new Set(ft(i.required)),l=[],x=[];for(const[p,N]of Object.entries(g)){const c=te(N),U=te(c["x-openpond-upload"]??c.xOpenPondUpload),I=typeof c.type=="string"?c.type:"string",H=te(c.items),z=gn(c,U),v=c.format==="file"||U.enabled===!0||I==="array"&&H.format==="file",q=typeof c.title=="string"&&c.title.trim()?c.title.trim():hn(p);if(v){x.push({name:p,label:q,required:u.has(p),multiple:I==="array"||U.multiple===!0,accept:bn(U,c),targetPath:fn(U,p),targetNames:z});continue}(I==="string"||I==="number"||I==="integer"||I==="boolean")&&l.push({name:p,label:q,required:u.has(p),type:I,defaultValue:typeof c.default=="string"||typeof c.default=="number"||typeof c.default=="boolean"?String(c.default):"",targetNames:z})}return{entrypoints:n,scalarInputs:l,fileInputs:x,envInputs:dn(e),resources:a,volumes:cn(e,x),schedules:un(e)}}function Fe(e,n){const a=n.trim();return e.filter(i=>!i.targetNames||i.targetNames.length===0?!0:i.targetNames.includes(a))}function ln(e){return e?Ye(e).flatMap(n=>{if(n.kind==="action")return[];const a=n.name.trim(),i=n.command.trim(),g=Be(n.timeoutSeconds),u=n.ports.flatMap(l=>{const x=Be(l.port);return x?[{port:x,label:typeof l.label=="string"&&l.label.trim()?l.label.trim():"web",access:l.access==="public"?"public":"private",path:typeof l.path=="string"&&l.path.trim()?l.path.trim():"/"}]:[]});return a&&i?[{name:a,command:i,timeoutSeconds:g,ports:u}]:[]}):[]}function on(e){return{cpu:Qe(e.cpu)??1,memoryGb:Qe(e.memoryGb)??1,diskGb:Qe(e.diskGb)??8}}function cn(e,n){const a=Array.isArray(e?.volumes)?e.volumes:[];if(a.length>0)return a.map((u,l)=>{const x=l===0?"volume":`volume-${l+1}`,p=typeof u.name=="string"&&u.name.trim()?u.name.trim():x;return{name:p,mountPath:typeof u.mountPath=="string"&&u.mountPath.trim()?u.mountPath.trim():`/workspace/volumes/${p}`,...Be(u.storageGb)?{storageGb:Be(u.storageGb)??void 0}:{},deleteOnSandboxDelete:u.deleteOnSandboxDelete===!0}});const i=n.find(u=>u.targetPath.startsWith("volumes/"));if(!i)return[];const[,g="volume"]=i.targetPath.split("/");return[{name:g,mountPath:`/workspace/volumes/${g}`,storageGb:8,deleteOnSandboxDelete:!1}]}function dn(e){return(Array.isArray(e?.inputs.env)?e.inputs.env:[]).flatMap(a=>{const i=typeof a.name=="string"?a.name.trim():"";return i?[{name:i,required:a.required===!0,secret:a.secret!==!1,description:typeof a.description=="string"?a.description.trim():""}]:[]})}function un(e){return e?.schedules?.length?e.schedules.flatMap(n=>{const a=typeof n.name=="string"?n.name.trim():"",i=mn(n);if(!a||!i.scheduleExpression)return[];try{return[{name:a,...typeof n.description=="string"&&n.description.trim()?{description:n.description.trim()}:{},enabled:!1,...i,...typeof n.timezone=="string"&&n.timezone.trim()?{timezone:n.timezone.trim()}:{},...typeof n.startAt=="string"&&n.startAt.trim()?{startAt:n.startAt.trim()}:{},...typeof n.endAt=="string"&&n.endAt.trim()?{endAt:n.endAt.trim()}:{},...typeof n.maxRuns=="number"&&Number.isInteger(n.maxRuns)&&n.maxRuns>0?{maxRuns:n.maxRuns}:{},runtimePolicy:n.runtimePolicy,target:pn(e,n),...n.budget?{budget:n.budget}:{},...n.resources?{resources:n.resources}:{},...n.quotas?{quotas:n.quotas}:{},...n.lifecycle?{lifecycle:n.lifecycle}:{},...n.retentionPolicy?{retentionPolicy:n.retentionPolicy}:{},...n.env?{env:n.env}:{},...n.integrationLeases?{integrationLeases:n.integrationLeases}:{},metadata:{...te(n.metadata),manifestScheduleName:a,source:"openpond-app-sandbox-template-start"}}]}catch{return[]}}):[]}function mn(e){return e.scheduleExpression?{scheduleType:e.scheduleType??"cron",scheduleExpression:e.scheduleExpression}:e.rate?{scheduleType:"rate",scheduleExpression:/^rate\(/i.test(e.rate)?e.rate:`rate(${e.rate})`}:e.once?{scheduleType:"once",scheduleExpression:/^at\(/i.test(e.once)?e.once:`at(${e.once})`}:{scheduleType:"cron",scheduleExpression:e.cron??""}}function pn(e,n){const a=n.command??n.target?.command??null;if(a)return{kind:"command",command:a,requiresStart:n.requiresStart??n.target?.requiresStart??!1};const i=n.target?.kind??"action";if(i==="start")return{kind:"command",command:e.start.command,requiresStart:n.requiresStart??n.target?.requiresStart??e.start.requiresStart??!1};if(i==="service"){const l=n.target?.name??"",x=e.services.find(p=>p.name===l);if(!x)throw new Error("schedule_service_target_missing");return{kind:"command",command:x.command,requiresStart:n.requiresStart??n.target?.requiresStart??x.requiresStart??!1}}const g=n.actionName??n.action??n.target?.actionName??(n.target?.kind==="action"?n.target?.name:void 0),u=e.actions.find(l=>l.name===g);if(!u)throw new Error("schedule_action_target_missing");return{kind:"command",command:u.command,requiresStart:n.requiresStart??n.target?.requiresStart??u.requiresStart??!1}}function gt(e,n){return e.flatMap(a=>{const i=(n[a.name]??"").trim();return i?[{name:a.name,secretRef:i}]:[]})}function bt(e,n){const a={};for(const i of e){const g=n[i.name]??"";if(!(!g.trim()&&!i.required))if(i.type==="boolean")a[i.name]=g==="true";else if(i.type==="number"||i.type==="integer"){const u=Number(g);Number.isFinite(u)&&(a[i.name]=i.type==="integer"?Math.trunc(u):u)}else a[i.name]=g}return a}function gn(e,n){const a=e["x-openpond-targets"]??e.xOpenPondTargets??n.targets??n.actions,i=ft(a).map(g=>g.trim()).filter(Boolean);return i.length>0?[...new Set(i)]:null}function bn(e,n){return typeof e.accept=="string"?e.accept.trim():Array.isArray(e.accept)?e.accept.filter(a=>typeof a=="string").join(","):typeof n.accept=="string"?n.accept.trim():""}function fn(e,n){return(typeof e.targetPath=="string"&&e.targetPath.trim()?e.targetPath.trim():typeof e.path=="string"&&e.path.trim()?e.path.trim():`uploads/${n}`).replace(/^\/+/,"").replace(/^workspace\//,"").replace(/\/+$/,"")}function Qe(e){const n=Number(e);return Number.isFinite(n)&&n>0?n:null}function Be(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function xn(e,n){return[n,...e.slice(1)]}function ft(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function hn(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function te(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function jn({busy:e,defaultRepoUrl:n,projectName:a,commitBeforeCreate:i,templateManifest:g,uploadBeforeCreate:u,onClose:l,onSubmit:x}){const p=m.useMemo(()=>pt(g),[g]),N=p.entrypoints[0]??null,[c,U]=m.useState(n),[I,H]=m.useState(N?.name??""),[z,v]=m.useState(N?.command??""),[q,V]=m.useState(N?.timeoutSeconds?String(N.timeoutSeconds):""),[X,b]=m.useState(`Update ${a}`),[j,A]=m.useState("0.05"),[_,F]=m.useState(()=>Object.fromEntries(p.scalarInputs.map(r=>[r.name,r.defaultValue]))),[B,ae]=m.useState(()=>Object.fromEntries(p.envInputs.map(r=>[r.name,""]))),[Z,fe]=m.useState({}),K=p.volumes[0]??null,[Y,o]=m.useState(p.volumes.length>0||p.fileInputs.length>0),[P,w]=m.useState(K?.name??"volume"),[R,$]=m.useState(K?.mountPath??"/workspace/volumes/volume"),[J,ce]=m.useState(String(K?.storageGb??8)),[Pe,de]=m.useState(!(K?.deleteOnSandboxDelete??!1)),[M,ze]=m.useState(p.schedules),qe=p.entrypoints.find(r=>r.name===I)??N,se=qe?.ports??[],re=se[0]??null,[ue,xe]=m.useState(!!re),[Ce,me]=m.useState(re?String(re.port):""),D=Number(Ce),he=Number(j),ie=Number(J),le=Number(q),ke=!q.trim()||Number.isInteger(le)&&le>0&&le<=86400,oe=!ue||Number.isInteger(D)&&D>=Mt&&D<=Ut&&se.some(r=>r.port===D),Ie=Number.isFinite(he)&&he>0,ne=!Y||Number.isInteger(ie)&&ie>0,G=M.every(r=>!r.enabled||!!r.scheduleExpression.trim()),W=Fe(p.scalarInputs,I),je=Fe(p.fileInputs,I),Me=p.envInputs.every(r=>!r.required||!!(B[r.name]??"").trim()),ve=p.envInputs.filter(r=>r.required&&!(B[r.name]??"").trim()),Re=(u||!!c.trim())&&!!z.trim()&&Ie&&ke&&ne&&W.every(r=>!r.required||!!(_[r.name]??"").trim())&&je.every(r=>!r.required||(Z[r.name]?.length??0)>0)&&Me&&G&&oe;function He(r){H(r);const f=p.entrypoints.find(E=>E.name===r);if(!f)return;v(f.command),V(f.timeoutSeconds?String(f.timeoutSeconds):"");const y=f.ports[0]??null;me(y?String(y.port):""),xe(!!y)}function _e(r,f){F(y=>({...y,[r]:f}))}function pe(r,f){ae(y=>({...y,[r]:f}))}function Ve(r,f){const y=Array.from(f.target.files??[]);fe(E=>({...E,[r.name]:r.multiple?y:y.slice(0,1)}))}function ee(r,f){ze(y=>y.map((E,ge)=>ge===r?{...E,...f}:E))}function Ee(r){r.preventDefault(),!(!Re||e)&&x({repoUrl:c.trim(),command:z.trim(),entrypointName:I,commitMessage:X.trim(),budgetUsd:j.trim(),params:bt(W,_),env:gt(p.envInputs,B),timeoutSeconds:q.trim()&&Number.isInteger(le)?le:qe?.timeoutSeconds??null,uploads:je.flatMap(f=>{const y=Z[f.name]??[];return y.length>0?[{inputName:f.name,label:f.label,targetPath:f.targetPath,multiple:f.multiple,files:y}]:[]}),resources:p.resources,volumes:Y?xn(p.volumes,{...P.trim()?{name:P.trim()}:{},...R.trim()?{mountPath:R.trim()}:{},...Number.isInteger(ie)&&ie>0?{storageGb:ie}:{},deleteOnSandboxDelete:!Pe}):[],schedules:M.filter(f=>f.enabled),openPreview:ue,previewPort:ue?D:null,previewLabel:se.find(f=>f.port===D)?.label??"web",previewAccess:se.find(f=>f.port===D)?.access??"private"})}return t.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:t.jsxs("form",{className:"git-dialog run-once-dialog sandbox-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Start sandbox",onSubmit:Ee,children:[t.jsx("button",{className:"git-dialog-close",disabled:e,type:"button",title:"Close","aria-label":"Close",onClick:l,children:t.jsx(mt,{size:15})}),t.jsxs("div",{className:"sandbox-start-dialog-heading",children:[t.jsx("div",{className:"git-dialog-icon",children:t.jsx(Ae,{size:18})}),t.jsx("h2",{children:"Start sandbox"}),t.jsxs("div",{className:"git-dialog-row",children:[t.jsx("span",{children:"Project"}),t.jsx("strong",{children:a})]})]}),t.jsxs("div",{className:"sandbox-start-dialog-body",children:[u?null:t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Repository"}),t.jsx("input",{disabled:e,value:c,onChange:r=>U(r.target.value)})]}),i?t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Commit message"}),t.jsx("input",{disabled:e,value:X,onChange:r=>b(r.target.value)})]}):null,p.entrypoints.length>0?t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Run target"}),t.jsx("select",{disabled:e,value:I,onChange:r=>He(r.target.value),children:p.entrypoints.map(r=>t.jsx("option",{value:r.name,children:r.name},r.name))})]}):null,t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Shell command"}),t.jsx("input",{disabled:e,value:z,onChange:r=>v(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Timeout seconds"}),t.jsx("input",{disabled:e,inputMode:"numeric",value:q,onChange:r=>V(r.target.value)})]}),W.map(r=>r.type==="boolean"?t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:(_[r.name]??"")==="true",disabled:e,type:"checkbox",onChange:f=>_e(r.name,f.target.checked?"true":"false")}),t.jsx("span",{}),r.label]},r.name):t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:r.label}),t.jsx("input",{disabled:e,inputMode:r.type==="number"||r.type==="integer"?"decimal":void 0,value:_[r.name]??"",onChange:f=>_e(r.name,f.target.value)})]},r.name)),je.map(r=>t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:r.label}),t.jsx("input",{accept:r.accept||void 0,disabled:e,multiple:r.multiple,type:"file",onChange:f=>Ve(r,f)})]},r.name)),p.envInputs.length>0?t.jsxs("div",{className:"sandbox-start-env-section",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Environment"}),ve.length>0?t.jsxs("p",{className:"sandbox-start-env-warning",role:"status",children:["Required sandbox secret ref missing: ",ve.map(r=>r.name).join(", ")]}):null,p.envInputs.map(r=>{const f=B[r.name]??"",y=r.required&&!f.trim(),E=`sandbox-env-${r.name}-description`;return t.jsxs("label",{className:"git-dialog-field",children:[t.jsxs("span",{children:[r.name,r.required?" *":""]}),t.jsx("input",{"aria-describedby":E,"aria-invalid":y,disabled:e,placeholder:"openpond://secret/...",value:f,onChange:ge=>pe(r.name,ge.target.value)}),t.jsx("small",{id:E,children:y?"Add a sandbox secret ref before starting.":r.description||"Sandbox secret ref only."})]},r.name)})]}):null,je.length>0||p.volumes.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:Y,disabled:e,type:"checkbox",onChange:r=>o(r.target.checked)}),t.jsx("span",{}),"Mount volume"]}),Y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"run-once-dialog-grid",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Volume"}),t.jsx("input",{disabled:e,value:P,onChange:r=>w(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Storage GiB"}),t.jsx("input",{disabled:e,inputMode:"numeric",value:J,onChange:r=>ce(r.target.value)})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Mount path"}),t.jsx("input",{disabled:e,value:R,onChange:r=>$(r.target.value)})]}),t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:Pe,disabled:e,type:"checkbox",onChange:r=>de(r.target.checked)}),t.jsx("span",{}),"Keep volume"]})]}):null]}):null,M.length>0?t.jsxs("div",{className:"sandbox-start-schedules",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Schedules"}),M.map((r,f)=>t.jsxs("div",{className:"sandbox-start-schedule-row",children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:r.enabled,disabled:e,type:"checkbox",onChange:y=>ee(f,{enabled:y.target.checked})}),t.jsx("span",{}),r.name]}),t.jsxs("div",{className:"run-once-dialog-grid",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Type"}),t.jsxs("select",{disabled:e||!r.enabled,value:r.scheduleType,onChange:y=>ee(f,{scheduleType:y.target.value}),children:[t.jsx("option",{value:"rate",children:"Rate"}),t.jsx("option",{value:"cron",children:"Cron"}),t.jsx("option",{value:"once",children:"Once"})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Max runs"}),t.jsx("input",{disabled:e||!r.enabled,inputMode:"numeric",value:r.maxRuns??"",onChange:y=>{const E=Number(y.target.value);ee(f,{maxRuns:Number.isInteger(E)&&E>0?E:null})}})]})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Expression"}),t.jsx("input",{disabled:e||!r.enabled,value:r.scheduleExpression,onChange:y=>ee(f,{scheduleExpression:y.target.value})})]})]},r.name))]}):null,t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Budget"}),t.jsx("input",{disabled:e,inputMode:"decimal",value:j,onChange:r=>A(r.target.value)})]}),se.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:ue,disabled:e,type:"checkbox",onChange:r=>xe(r.target.checked)}),t.jsx("span",{}),"Open preview"]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Preview port"}),t.jsx("select",{disabled:e||!ue,value:Ce,onChange:r=>me(r.target.value),children:se.map(r=>t.jsx("option",{value:r.port,children:r.label?`${r.label} (${r.port})`:r.port},r.port))})]})]}):null]}),t.jsxs("div",{className:"git-dialog-footer sandbox-start-dialog-footer",children:[t.jsx("button",{className:"git-dialog-secondary",disabled:e,type:"button",onClick:l,children:"Cancel"}),t.jsxs("button",{className:"git-dialog-primary",disabled:e||!Re,title:Me?void 0:"Required sandbox secret refs are missing.",type:"submit",children:[t.jsx(Lt,{size:14}),"Start"]})]})]})})}function vn({busy:e,projectName:n,templateManifest:a,onClose:i,onSubmit:g}){const u=m.useMemo(()=>pt(a),[a]),l=m.useMemo(()=>a?Ye(a).filter(o=>o.kind==="action"):[],[a]),x=l[0]??null,[p,N]=m.useState("sandbox"),[c,U]=m.useState(x?.name??""),[I,H]=m.useState(()=>Object.fromEntries(u.scalarInputs.map(o=>[o.name,o.defaultValue]))),[z,v]=m.useState(()=>Object.fromEntries(u.envInputs.map(o=>[o.name,""]))),[q,V]=m.useState({}),X=Fe(u.scalarInputs,c),b=Fe(u.fileInputs,c),j=p==="sandbox"?u.envInputs:[],A=X.every(o=>!o.required||!!(I[o.name]??"").trim()),_=b.every(o=>!o.required||(q[o.name]?.length??0)>0),F=j.every(o=>!o.required||!!(z[o.name]??"").trim()),B=j.filter(o=>o.required&&!(z[o.name]??"").trim()),ae=!!c&&A&&_&&F;function Z(o,P){H(w=>({...w,[o]:P}))}function fe(o,P){v(w=>({...w,[o]:P}))}function K(o,P,w){const R=Array.from(w.target.files??[]);V($=>({...$,[o]:P?R:R.slice(0,1)}))}function Y(o){o.preventDefault(),!(!ae||e)&&g({mode:p,target:c,params:bt(X,I),env:p==="sandbox"?gt(j,z):[],uploads:b.flatMap(P=>{const w=q[P.name]??[];return w.length>0?[{inputName:P.name,label:P.label,targetPath:P.targetPath,multiple:P.multiple,files:w}]:[]})})}return t.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:t.jsxs("form",{className:"git-dialog run-once-dialog sandbox-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Run sandbox action",onSubmit:Y,children:[t.jsx("button",{className:"git-dialog-close",disabled:e,type:"button",title:"Close","aria-label":"Close",onClick:i,children:t.jsx(mt,{size:15})}),t.jsxs("div",{className:"sandbox-start-dialog-heading",children:[t.jsx("div",{className:"git-dialog-icon",children:t.jsx($e,{size:18})}),t.jsx("h2",{children:"Run action"}),t.jsxs("div",{className:"git-dialog-row",children:[t.jsx("span",{children:"Project"}),t.jsx("strong",{children:n})]})]}),t.jsxs("div",{className:"sandbox-start-dialog-body",children:[t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Action"}),t.jsx("select",{disabled:e||l.length===0,value:c,onChange:o=>U(o.target.value),children:l.map(o=>t.jsx("option",{value:o.name,children:o.name},o.name))})]}),t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:"Run on"}),t.jsxs("select",{disabled:e,value:p,onChange:o=>N(o.target.value==="local"?"local":"sandbox"),children:[t.jsx("option",{value:"sandbox",children:"Hosted sandbox (start/update)"}),t.jsx("option",{value:"local",children:"Local machine"})]})]}),X.map(o=>o.type==="boolean"?t.jsxs("label",{className:"git-dialog-toggle",children:[t.jsx("input",{checked:(I[o.name]??"")==="true",disabled:e,type:"checkbox",onChange:P=>Z(o.name,P.target.checked?"true":"false")}),t.jsx("span",{}),o.label]},o.name):t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:o.label}),t.jsx("input",{disabled:e,inputMode:o.type==="number"||o.type==="integer"?"decimal":void 0,value:I[o.name]??"",onChange:P=>Z(o.name,P.target.value)})]},o.name)),b.map(o=>t.jsxs("label",{className:"git-dialog-field",children:[t.jsx("span",{children:o.label}),t.jsx("input",{accept:o.accept||void 0,disabled:e,multiple:o.multiple,type:"file",onChange:P=>K(o.name,o.multiple,P)})]},o.name)),j.length>0?t.jsxs("div",{className:"sandbox-start-env-section",children:[t.jsx("div",{className:"sandbox-start-section-title",children:"Environment"}),B.length>0?t.jsxs("p",{className:"sandbox-start-env-warning",role:"status",children:["Required sandbox secret ref missing: ",B.map(o=>o.name).join(", ")]}):null,j.map(o=>{const P=z[o.name]??"",w=o.required&&!P.trim(),R=`sandbox-action-env-${o.name}-description`;return t.jsxs("label",{className:"git-dialog-field",children:[t.jsxs("span",{children:[o.name,o.required?" *":""]}),t.jsx("input",{"aria-describedby":R,"aria-invalid":w,disabled:e,placeholder:"openpond://secret/...",value:P,onChange:$=>fe(o.name,$.target.value)}),t.jsx("small",{id:R,children:w?"Add a sandbox secret ref before running.":o.description||"Sandbox secret ref only."})]},o.name)})]}):null]}),t.jsxs("div",{className:"git-dialog-footer sandbox-start-dialog-footer",children:[t.jsx("button",{className:"git-dialog-secondary",disabled:e,type:"button",onClick:i,children:"Cancel"}),t.jsxs("button",{className:"git-dialog-primary",disabled:e||!ae,title:F?void 0:"Required sandbox secret refs are missing.",type:"submit",children:[t.jsx($e,{size:14}),"Run"]})]})]})})}function xt(e,n){const a=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent";return n==="cron"?`name: ${a}
2
2
  version: 0.1.0
3
3
  useCase: scheduled_report
4
4
  start:
@@ -1 +1 @@
1
- import{j as e,G as z,X as _}from"./index-BO2W2U23.js";/* empty css */import{C as D}from"./cloud-upload-COReKxOy.js";import{G as j}from"./git-branch-eCwyZXMl.js";import{G as h}from"./git-commit-horizontal-cPm51DqY.js";import{U as G}from"./upload-vaAKFfxi.js";function F({open:s,branch:l,filesChanged:i,additions:c,deletions:n,message:m,includeUnstaged:g,nextStep:a,draft:p,busy:t,canPush:u,canPublish:b,onMessageChange:f,onIncludeUnstagedChange:C,onNextStepChange:r,onDraftChange:N,onClose:v,onSubmit:k}){return s?e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:e.jsxs("form",{className:"git-dialog commit-dialog","aria-label":"Commit changes",onSubmit:o=>{o.preventDefault(),k()},children:[e.jsx(x,{disabled:t,onClose:v}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(h,{size:18})}),e.jsx("h2",{children:"Commit your changes"}),e.jsxs("div",{className:"git-dialog-row",children:[e.jsx("span",{children:"Branch"}),e.jsxs("strong",{children:[e.jsx(j,{size:14}),l??"No branch"]})]}),e.jsxs("div",{className:"git-dialog-row",children:[e.jsx("span",{children:"Changes"}),e.jsxs("strong",{children:[i," ",i===1?"file":"files",e.jsxs("span",{className:"git-dialog-additions",children:["+",c]}),e.jsxs("span",{className:"git-dialog-deletions",children:["-",n]})]})]}),e.jsxs("label",{className:"git-dialog-toggle",children:[e.jsx("input",{checked:g,disabled:t,type:"checkbox",onChange:o=>C(o.target.checked)}),e.jsx("span",{}),"Include unstaged"]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:["Commit message",e.jsx("small",{children:"Leave blank to use an autogenerated message"})]}),e.jsx("textarea",{value:m,disabled:t,placeholder:"Update workspace",onChange:o=>f(o.target.value)})]}),e.jsxs("fieldset",{className:"git-dialog-next",children:[e.jsx("legend",{children:"Next steps"}),e.jsx(d,{active:a==="commit",icon:e.jsx(h,{size:14}),label:"Commit",disabled:t,onSelect:()=>r("commit")}),e.jsx(d,{active:a==="commit_push",icon:e.jsx(G,{size:14}),label:"Commit & push",disabled:t||!u,onSelect:()=>r("commit_push")}),b&&e.jsx(d,{active:a==="commit_publish",icon:e.jsx(D,{size:14}),label:"Commit & publish",disabled:t,onSelect:()=>r("commit_publish")}),e.jsx(d,{active:a==="commit_pr",icon:e.jsx(z,{size:14}),label:"Commit & create PR",disabled:!0,onSelect:()=>r("commit_pr")})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsxs("label",{className:"git-dialog-toggle draft-toggle",children:[e.jsx("input",{checked:p,disabled:t||a!=="commit_pr",type:"checkbox",onChange:o=>N(o.target.checked)}),e.jsx("span",{}),"Draft"]}),e.jsx("button",{className:"git-dialog-primary",disabled:t||i===0,type:"submit",children:"Continue"})]})]})}):null}function H({open:s,branchName:l,busy:i,onBranchNameChange:c,onSetPrefix:n,onClose:m,onSubmit:g}){return s?e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:e.jsxs("form",{className:"git-dialog branch-dialog","aria-label":"Create branch",onSubmit:a=>{a.preventDefault(),g()},children:[e.jsx(x,{disabled:i,onClose:m}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(j,{size:18})}),e.jsx("h2",{children:"Work here"}),e.jsx("p",{children:"Create a branch to commit changes, push, and create a PR from this worktree."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:["Branch name",e.jsx("button",{className:"git-dialog-inline-action",disabled:i,type:"button",onClick:n,children:"Set prefix"})]}),e.jsx("input",{autoFocus:!0,disabled:i,value:l,onChange:a=>c(a.target.value)})]}),e.jsx("button",{className:"git-dialog-primary full",disabled:i||!l.trim(),type:"submit",children:"Create"})]})}):null}function d({active:s,icon:l,label:i,disabled:c,onSelect:n}){return e.jsxs("button",{"aria-pressed":s,className:s?"active":"",disabled:c,type:"button",onClick:n,children:[l,e.jsx("span",{children:i}),s&&e.jsx("span",{className:"git-dialog-check",children:"✓"})]})}function x({disabled:s,onClose:l}){return e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button",onClick:l,children:e.jsx(_,{size:16})})}export{H as BranchDialog,F as CommitDialog};
1
+ import{j as e,G as z,X as _}from"./index-LrGasYyx.js";/* empty css */import{C as D}from"./cloud-upload-D6bS8rS2.js";import{G as j}from"./git-branch-C45ve7zh.js";import{G as h}from"./git-commit-horizontal-CGoLIyKK.js";import{U as G}from"./upload-DcewuCTa.js";function F({open:s,branch:l,filesChanged:i,additions:c,deletions:n,message:m,includeUnstaged:g,nextStep:a,draft:p,busy:t,canPush:u,canPublish:b,onMessageChange:f,onIncludeUnstagedChange:C,onNextStepChange:r,onDraftChange:N,onClose:v,onSubmit:k}){return s?e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:e.jsxs("form",{className:"git-dialog commit-dialog","aria-label":"Commit changes",onSubmit:o=>{o.preventDefault(),k()},children:[e.jsx(x,{disabled:t,onClose:v}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(h,{size:18})}),e.jsx("h2",{children:"Commit your changes"}),e.jsxs("div",{className:"git-dialog-row",children:[e.jsx("span",{children:"Branch"}),e.jsxs("strong",{children:[e.jsx(j,{size:14}),l??"No branch"]})]}),e.jsxs("div",{className:"git-dialog-row",children:[e.jsx("span",{children:"Changes"}),e.jsxs("strong",{children:[i," ",i===1?"file":"files",e.jsxs("span",{className:"git-dialog-additions",children:["+",c]}),e.jsxs("span",{className:"git-dialog-deletions",children:["-",n]})]})]}),e.jsxs("label",{className:"git-dialog-toggle",children:[e.jsx("input",{checked:g,disabled:t,type:"checkbox",onChange:o=>C(o.target.checked)}),e.jsx("span",{}),"Include unstaged"]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:["Commit message",e.jsx("small",{children:"Leave blank to use an autogenerated message"})]}),e.jsx("textarea",{value:m,disabled:t,placeholder:"Update workspace",onChange:o=>f(o.target.value)})]}),e.jsxs("fieldset",{className:"git-dialog-next",children:[e.jsx("legend",{children:"Next steps"}),e.jsx(d,{active:a==="commit",icon:e.jsx(h,{size:14}),label:"Commit",disabled:t,onSelect:()=>r("commit")}),e.jsx(d,{active:a==="commit_push",icon:e.jsx(G,{size:14}),label:"Commit & push",disabled:t||!u,onSelect:()=>r("commit_push")}),b&&e.jsx(d,{active:a==="commit_publish",icon:e.jsx(D,{size:14}),label:"Commit & publish",disabled:t,onSelect:()=>r("commit_publish")}),e.jsx(d,{active:a==="commit_pr",icon:e.jsx(z,{size:14}),label:"Commit & create PR",disabled:!0,onSelect:()=>r("commit_pr")})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsxs("label",{className:"git-dialog-toggle draft-toggle",children:[e.jsx("input",{checked:p,disabled:t||a!=="commit_pr",type:"checkbox",onChange:o=>N(o.target.checked)}),e.jsx("span",{}),"Draft"]}),e.jsx("button",{className:"git-dialog-primary",disabled:t||i===0,type:"submit",children:"Continue"})]})]})}):null}function H({open:s,branchName:l,busy:i,onBranchNameChange:c,onSetPrefix:n,onClose:m,onSubmit:g}){return s?e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:e.jsxs("form",{className:"git-dialog branch-dialog","aria-label":"Create branch",onSubmit:a=>{a.preventDefault(),g()},children:[e.jsx(x,{disabled:i,onClose:m}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(j,{size:18})}),e.jsx("h2",{children:"Work here"}),e.jsx("p",{children:"Create a branch to commit changes, push, and create a PR from this worktree."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:["Branch name",e.jsx("button",{className:"git-dialog-inline-action",disabled:i,type:"button",onClick:n,children:"Set prefix"})]}),e.jsx("input",{autoFocus:!0,disabled:i,value:l,onChange:a=>c(a.target.value)})]}),e.jsx("button",{className:"git-dialog-primary full",disabled:i||!l.trim(),type:"submit",children:"Create"})]})}):null}function d({active:s,icon:l,label:i,disabled:c,onSelect:n}){return e.jsxs("button",{"aria-pressed":s,className:s?"active":"",disabled:c,type:"button",onClick:n,children:[l,e.jsx("span",{children:i}),s&&e.jsx("span",{className:"git-dialog-check",children:"✓"})]})}function x({disabled:s,onClose:l}){return e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button",onClick:l,children:e.jsx(_,{size:16})})}export{H as BranchDialog,F as CommitDialog};