@knowsuchagency/fulcrum 4.4.2 → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/fulcrum.js CHANGED
@@ -46744,7 +46744,7 @@ async function runMcpServer(urlOverride, portOverride) {
46744
46744
  const client = new FulcrumClient(urlOverride, portOverride);
46745
46745
  const server = new McpServer({
46746
46746
  name: "fulcrum",
46747
- version: "4.4.2"
46747
+ version: "4.4.4"
46748
46748
  });
46749
46749
  registerTools(server, client);
46750
46750
  const transport = new StdioServerTransport;
@@ -49093,7 +49093,7 @@ var marketplace_default = `{
49093
49093
  "name": "fulcrum",
49094
49094
  "source": "./",
49095
49095
  "description": "Task orchestration for Claude Code",
49096
- "version": "4.4.2",
49096
+ "version": "4.4.4",
49097
49097
  "skills": [
49098
49098
  "./skills/fulcrum"
49099
49099
  ],
@@ -49116,7 +49116,7 @@ var marketplace_default = `{
49116
49116
  var plugin_default = `{
49117
49117
  "name": "fulcrum",
49118
49118
  "description": "Fulcrum task orchestration for Claude Code",
49119
- "version": "4.4.2",
49119
+ "version": "4.4.4",
49120
49120
  "author": {
49121
49121
  "name": "Fulcrum"
49122
49122
  },
@@ -50221,7 +50221,7 @@ function compareVersions(v1, v2) {
50221
50221
  var package_default = {
50222
50222
  name: "@knowsuchagency/fulcrum",
50223
50223
  private: true,
50224
- version: "4.4.2",
50224
+ version: "4.4.4",
50225
50225
  description: "Harness Attention. Orchestrate Agents. Ship.",
50226
50226
  license: "PolyForm-Perimeter-1.0.0",
50227
50227
  type: "module",
@@ -318,7 +318,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
318
318
 
319
319
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
320
320
  `},b0e=aZt(uZt)(xje),dZt={config:lZt},fZt=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(i){return n.reduceRight(function(s,a){return a(s)},i)}};function _je(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],_je(e[n],t[n]))}),p0e(p0e({},e),t)}var hZt={type:"cancelation",msg:"operation is manually canceled"};function wB(e){var t=!1,n=new Promise(function(r,i){e.then(function(s){return t?i(hZt):r(s)}),e.catch(i)});return n.cancel=function(){return t=!0},n}var pZt=["monaco"],mZt=iZt.create({config:sZt,isInitialized:!1,resolve:null,reject:null,monaco:null}),Sje=$Xt(mZt,2),Ak=Sje[0],yj=Sje[1];function gZt(e){var t=dZt.config(e),n=t.monaco,r=FXt(t,pZt);yj(function(i){return{config:_je(i.config,r),monaco:n}})}function bZt(){var e=Ak(function(t){var n=t.monaco,r=t.isInitialized,i=t.resolve;return{monaco:n,isInitialized:r,resolve:i}});if(!e.isInitialized){if(yj({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),wB(EB);if(window.monaco&&window.monaco.editor)return wje(window.monaco),e.resolve(window.monaco),wB(EB);fZt(yZt,xZt)(_Zt)}return wB(EB)}function yZt(e){return document.body.appendChild(e)}function vZt(e){var t=document.createElement("script");return e&&(t.src=e),t}function xZt(e){var t=Ak(function(r){var i=r.config,s=r.reject;return{config:i,reject:s}}),n=vZt("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function _Zt(){var e=Ak(function(n){var r=n.config,i=n.resolve,s=n.reject;return{config:r,resolve:i,reject:s}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){var r=n.m||n;wje(r),e.resolve(r)},function(n){e.reject(n)})}function wje(e){Ak().monaco||yj({monaco:e})}function SZt(){return Ak(function(e){var t=e.monaco;return t})}var EB=new Promise(function(e,t){return yj({resolve:e,reject:t})}),HJ={config:gZt,init:bZt,__getMonacoInstance:SZt},wZt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},CB=wZt,EZt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},CZt=EZt;function kZt({children:e}){return Z.createElement("div",{style:CZt.container},e)}var TZt=kZt,AZt=TZt;function NZt({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:s,wrapperProps:a}){return Z.createElement("section",{style:{...CB.wrapper,width:e,height:t},...a},!n&&Z.createElement(AZt,null,r),Z.createElement("div",{ref:i,style:{...CB.fullWidth,...!n&&CB.hide},className:s}))}var OZt=NZt,Eje=x.memo(OZt);function RZt(e){x.useEffect(e,[])}var Cje=RZt;function IZt(e,t,n=!0){let r=x.useRef(!0);x.useEffect(r.current||!n?()=>{r.current=!1}:e,t)}var kc=IZt;function dE(){}function L0(e,t,n,r){return DZt(e,r)||jZt(e,t,n,r)}function DZt(e,t){return e.editor.getModel(kje(e,t))}function jZt(e,t,n,r){return e.editor.createModel(t,n,r?kje(e,r):void 0)}function kje(e,t){return e.Uri.parse(t)}function PZt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:s,modifiedModelPath:a,keepCurrentOriginalModel:o=!1,keepCurrentModifiedModel:l=!1,theme:u="light",loading:d="Loading...",options:f={},height:h="100%",width:m="100%",className:b,wrapperProps:y={},beforeMount:v=dE,onMount:_=dE}){let[w,E]=x.useState(!1),[T,k]=x.useState(!0),S=x.useRef(null),A=x.useRef(null),R=x.useRef(null),I=x.useRef(_),D=x.useRef(v),j=x.useRef(!1);Cje(()=>{let M=HJ.init();return M.then(P=>(A.current=P)&&k(!1)).catch(P=>P?.type!=="cancelation"&&console.error("Monaco initialization: error:",P)),()=>S.current?L():M.cancel()}),kc(()=>{if(S.current&&A.current){let M=S.current.getOriginalEditor(),P=L0(A.current,e||"",r||n||"text",s||"");P!==M.getModel()&&M.setModel(P)}},[s],w),kc(()=>{if(S.current&&A.current){let M=S.current.getModifiedEditor(),P=L0(A.current,t||"",i||n||"text",a||"");P!==M.getModel()&&M.setModel(P)}},[a],w),kc(()=>{let M=S.current.getModifiedEditor();M.getOption(A.current.editor.EditorOption.readOnly)?M.setValue(t||""):t!==M.getValue()&&(M.executeEdits("",[{range:M.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),M.pushUndoStop())},[t],w),kc(()=>{S.current?.getModel()?.original.setValue(e||"")},[e],w),kc(()=>{let{original:M,modified:P}=S.current.getModel();A.current.editor.setModelLanguage(M,r||n||"text"),A.current.editor.setModelLanguage(P,i||n||"text")},[n,r,i],w),kc(()=>{A.current?.editor.setTheme(u)},[u],w),kc(()=>{S.current?.updateOptions(f)},[f],w);let B=x.useCallback(()=>{if(!A.current)return;D.current(A.current);let M=L0(A.current,e||"",r||n||"text",s||""),P=L0(A.current,t||"",i||n||"text",a||"");S.current?.setModel({original:M,modified:P})},[n,t,i,e,r,s,a]),F=x.useCallback(()=>{!j.current&&R.current&&(S.current=A.current.editor.createDiffEditor(R.current,{automaticLayout:!0,...f}),B(),A.current?.editor.setTheme(u),E(!0),j.current=!0)},[f,u,B]);x.useEffect(()=>{w&&I.current(S.current,A.current)},[w]),x.useEffect(()=>{!T&&!w&&F()},[T,w,F]);function L(){let M=S.current?.getModel();o||M?.original?.dispose(),l||M?.modified?.dispose(),S.current?.dispose()}return Z.createElement(Eje,{width:m,height:h,isEditorReady:w,loading:d,_ref:R,className:b,wrapperProps:y})}var LZt=PZt;x.memo(LZt);function MZt(e){let t=x.useRef();return x.useEffect(()=>{t.current=e},[e]),t.current}var FZt=MZt,kN=new Map;function BZt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:s,theme:a="light",line:o,loading:l="Loading...",options:u={},overrideServices:d={},saveViewState:f=!0,keepCurrentModel:h=!1,width:m="100%",height:b="100%",className:y,wrapperProps:v={},beforeMount:_=dE,onMount:w=dE,onChange:E,onValidate:T=dE}){let[k,S]=x.useState(!1),[A,R]=x.useState(!0),I=x.useRef(null),D=x.useRef(null),j=x.useRef(null),B=x.useRef(w),F=x.useRef(_),L=x.useRef(),M=x.useRef(r),P=FZt(s),U=x.useRef(!1),W=x.useRef(!1);Cje(()=>{let Y=HJ.init();return Y.then(X=>(I.current=X)&&R(!1)).catch(X=>X?.type!=="cancelation"&&console.error("Monaco initialization: error:",X)),()=>D.current?q():Y.cancel()}),kc(()=>{let Y=L0(I.current,e||r||"",t||i||"",s||n||"");Y!==D.current?.getModel()&&(f&&kN.set(P,D.current?.saveViewState()),D.current?.setModel(Y),f&&D.current?.restoreViewState(kN.get(s)))},[s],k),kc(()=>{D.current?.updateOptions(u)},[u],k),kc(()=>{!D.current||r===void 0||(D.current.getOption(I.current.editor.EditorOption.readOnly)?D.current.setValue(r):r!==D.current.getValue()&&(W.current=!0,D.current.executeEdits("",[{range:D.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),D.current.pushUndoStop(),W.current=!1))},[r],k),kc(()=>{let Y=D.current?.getModel();Y&&i&&I.current?.editor.setModelLanguage(Y,i)},[i],k),kc(()=>{o!==void 0&&D.current?.revealLine(o)},[o],k),kc(()=>{I.current?.editor.setTheme(a)},[a],k);let G=x.useCallback(()=>{if(!(!j.current||!I.current)&&!U.current){F.current(I.current);let Y=s||n,X=L0(I.current,r||e||"",t||i||"",Y||"");D.current=I.current?.editor.create(j.current,{model:X,automaticLayout:!0,...u},d),f&&D.current.restoreViewState(kN.get(Y)),I.current.editor.setTheme(a),o!==void 0&&D.current.revealLine(o),S(!0),U.current=!0}},[e,t,n,r,i,s,u,d,f,a,o]);x.useEffect(()=>{k&&B.current(D.current,I.current)},[k]),x.useEffect(()=>{!A&&!k&&G()},[A,k,G]),M.current=r,x.useEffect(()=>{k&&E&&(L.current?.dispose(),L.current=D.current?.onDidChangeModelContent(Y=>{W.current||E(D.current.getValue(),Y)}))},[k,E]),x.useEffect(()=>{if(k){let Y=I.current.editor.onDidChangeMarkers(X=>{let z=D.current.getModel()?.uri;if(z&&X.find(J=>J.path===z.path)){let J=I.current.editor.getModelMarkers({resource:z});T?.(J)}});return()=>{Y?.dispose()}}return()=>{}},[k,T]);function q(){L.current?.dispose(),h?f&&kN.set(s,D.current.saveViewState()):D.current.getModel()?.dispose(),D.current.dispose()}return Z.createElement(Eje,{width:m,height:b,isEditorReady:k,loading:l,_ref:j,className:y,wrapperProps:v})}var $Zt=BZt,UZt=x.memo($Zt),zZt=UZt;HJ.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}});function HZt(e){const t=e.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"scss",less:"less",html:"html",htm:"html",md:"markdown",mdx:"markdown",yaml:"yaml",yml:"yaml",toml:"ini",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",py:"python",rs:"rust",go:"go",sql:"sql",xml:"xml",svg:"xml",txt:"plaintext",log:"plaintext",gitignore:"plaintext",dockerignore:"plaintext",env:"plaintext",dockerfile:"dockerfile",makefile:"makefile",c:"c",h:"c",cpp:"cpp",hpp:"cpp",java:"java",kt:"kotlin",swift:"swift",rb:"ruby",php:"php",lua:"lua",r:"r",graphql:"graphql",gql:"graphql"}[t]||"plaintext"}function ZH({filePath:e,content:t,onChange:n,readOnly:r=!1,onEditorReady:i}){const{resolvedTheme:s}=tc(),a=x.useRef(null),o=x.useCallback(f=>{a.current=f,i?.({triggerFind:()=>{f.getAction("actions.find")?.run()},triggerFindReplace:()=>{f.getAction("editor.action.startFindReplaceAction")?.run()}})},[i]),l=x.useCallback(f=>{f!==void 0&&n(f)},[n]),u=HZt(e),d=s==="light"?"vs-light":"vs-dark";return c.jsx(zZt,{height:"100%",language:u,value:t,theme:d,onChange:l,onMount:o,loading:c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."}),options:{readOnly:r,accessibilitySupport:"off",minimap:{enabled:!1},fontSize:12,fontFamily:"'JetBrains Mono', monospace",lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,insertSpaces:!0,folding:!0,lineDecorationsWidth:0,lineNumbersMinChars:3,renderLineHighlight:"line",selectOnLineNumbers:!0,padding:{top:8,bottom:8},scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:10,horizontalScrollbarSize:10},overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,contextmenu:!0,quickSuggestions:!1,suggestOnTriggerCharacters:!1,acceptSuggestionOnEnter:"off",snippetSuggestions:"none",wordBasedSuggestions:"off"}})}function VZt(e,t){if(e.startsWith("/")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:"))return e;const n=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",r=n?n.split("/"):[],i=e.split("/");for(const s of i)s===".."?r.pop():s!=="."&&r.push(s);return r.join("/")}function WZt(e,t,n){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("/api/"))return e;const r=VZt(e,n);return`/api/fs/image?${new URLSearchParams({path:r,root:t})}`}function qZt({content:e,worktreePath:t,filePath:n}){const{resolvedTheme:r}=tc(),i=x.useMemo(()=>({img:({src:s,alt:a,...o})=>{if(!s)return null;const l=WZt(s,t,n);return c.jsx("img",{src:l,alt:a||"",loading:"lazy",style:{maxWidth:"100%"},...o})},a:({href:s,children:a,...o})=>c.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",...o,children:a})}),[t,n]);return c.jsx(Lf,{className:"h-full",children:c.jsx("div",{className:"p-4","data-color-mode":r==="light"?"light":"dark",children:c.jsx(Lh,{source:e,style:{backgroundColor:"transparent",fontSize:"14px"},components:i})})})}function GZt({open:e,fileName:t,onKeepChanges:n,onReload:r}){return c.jsx(ql,{open:e,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:"File Changed Externally"}),c.jsxs(Zl,{children:['The file "',t,'" has been modified outside the editor. You have unsaved changes. What would you like to do?']})]}),c.jsxs(Yl,{children:[c.jsx(Ql,{onClick:n,children:"Keep my changes"}),c.jsx(xg,{onClick:r,children:"Reload file"})]})]})})}const KZt=1e3,YZt=By(function({onBack:t}){const{onFileSaved:n}=x.useContext(VJ),{worktreePath:r,readOnly:i,selectedFile:s,currentFile:a,isLoading:o,isSaving:l,loadError:u,isDirty:d,updateContent:f,saveFile:h,reloadFile:m,closeFile:b,toggleMarkdownView:y}=q2e(),v=x.useRef(null),_=x.useRef(null),{hasExternalChange:w,isConflict:E,resetExternalChange:T}=DXt({worktreePath:r,filePath:s,currentMtime:a?.mtime??null,isDirty:d,enabled:!!a&&!o&&a.isEditable&&!d});x.useEffect(()=>{w&&!d&&s&&m(s).then(()=>{T()})},[w,d,s,m,T]);const k=x.useCallback(()=>{T()},[T]),S=x.useCallback(()=>{s&&(v.current&&(clearTimeout(v.current),v.current=null),m(s).then(()=>{T()}))},[s,m,T]);x.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const A=x.useCallback(F=>{!s||i||(f(s,F),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{h(s).then(()=>{n?.(s)}).catch(L=>{console.error("Auto-save failed:",L)})},KZt))},[s,i,f,h,n]),R=x.useCallback(()=>{s&&(v.current&&(clearTimeout(v.current),v.current=null),b(s)),t?.()},[s,b,t]),I=x.useCallback(()=>{s&&y(s)},[s,y]);if(!s)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Select a file to view"});if(o)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading file..."});if(u)return c.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:u});if(!a)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Unable to load file"});if(a.isPdf){const F=`/api/fs/raw?path=${encodeURIComponent(s)}&root=${encodeURIComponent(r||"")}`;return c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1.5 bg-card border-b border-border text-xs",children:[c.jsx("span",{className:"text-muted-foreground truncate",title:s,children:s.split("/").pop()||s}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-muted-foreground",children:[(a.size/1024).toFixed(1)," KB"]}),c.jsx("button",{onClick:R,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2})})]})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx("iframe",{src:F,className:"w-full h-full border-0",title:s})})]})}if(a.isBinary)return c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1.5 bg-card border-b border-border text-xs",children:[c.jsx("span",{className:"text-muted-foreground truncate",title:s,children:s.split("/").pop()||s}),c.jsx("button",{onClick:R,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[c.jsx("p",{children:"Binary file"}),c.jsxs("p",{className:"text-xs",children:[(a.size/1024).toFixed(1)," KB"]})]})]});if(a.isImage)return c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1.5 bg-card border-b border-border text-xs",children:[c.jsx("span",{className:"text-muted-foreground truncate",title:s,children:s.split("/").pop()||s}),c.jsx("button",{onClick:R,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted",children:c.jsx("img",{src:a.content,alt:s,className:"block mx-auto"})})]});const D=s.split("/").pop()||s,j=a.isMarkdown,B=j&&a.isMarkdownView;return c.jsxs(c.Fragment,{children:[c.jsx(GZt,{open:E,fileName:D,onKeepChanges:k,onReload:S}),c.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[c.jsxs("span",{className:"text-muted-foreground truncate flex-1 flex items-center gap-1",title:s,children:[D,!i&&d&&c.jsx("span",{className:"text-amber-500",children:"*"}),!i&&l&&c.jsx("span",{className:"text-muted-foreground italic",children:"(saving...)"})]}),a.truncated&&c.jsxs("span",{className:"text-destructive",children:["Truncated (",a.lineCount.toLocaleString()," lines)"]}),c.jsxs("span",{className:"text-muted-foreground",children:[(a.size/1024).toFixed(1)," KB"]}),j&&c.jsx("button",{onClick:I,className:Oe("p-1 rounded hover:bg-muted/50 transition-colors",B?"text-primary":"text-muted-foreground hover:text-foreground"),title:B?"Show code":"Preview markdown",children:c.jsx(Q,{icon:B?X$e:cW,size:14,strokeWidth:2})}),!B&&c.jsx("button",{onClick:()=>_.current?.triggerFind(),className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Find (Ctrl+F)",children:c.jsx(Q,{icon:cp,size:14,strokeWidth:2})}),c.jsx("button",{onClick:R,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:"Close file",children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:B?c.jsx(qZt,{content:a.content,worktreePath:r||"",filePath:s}):c.jsx(ZH,{filePath:s,content:a.content,onChange:A,readOnly:i||!a.isEditable,onEditorReady:F=>{_.current=F}})})]})]})}),VJ=x.createContext({}),XZt=By(function(){const{onFileChange:t}=x.useContext(VJ),{worktreePath:n,selectedFile:r,expandedDirs:i,fileTree:s,isLoadingTree:a,treeError:o,selectFile:l,loadFile:u,toggleDir:d,collapseAll:f,updateFileTree:h}=q2e();NXt({worktreePath:n,currentTree:s,onTreeChanged:h,enabled:!a});const m=x.useCallback(v=>{l(v),u(v),t?.(v)},[l,u,t]),b=x.useCallback(v=>{d(v)},[d]),y=x.useCallback(()=>{l(null),t?.(null)},[l,t]);return a?c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading files..."}):o?c.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:o}):r?c.jsx("div",{className:"flex h-full flex-col",style:{background:"var(--gradient-card)"},children:c.jsx(YZt,{onBack:y})}):c.jsx(RXt,{entries:s||[],selectedFile:r,expandedDirs:i,onSelectFile:m,onToggleDir:b,onCollapseAll:f})});function i3({worktreePath:e,readOnly:t=!1,initialSelectedFile:n,onFileChange:r,onFileSaved:i}){const s=Est(e,t,n);return e?c.jsx(W2e.Provider,{value:s,children:c.jsx(VJ.Provider,{value:{onFileChange:r,onFileSaved:i},children:c.jsx(XZt,{})})}):c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"})}function ZZt({task:e}){return c.jsx("div",{className:"flex h-full min-h-0 flex-col",children:c.jsx(iNe,{task:e})})}function y0e({task:e}){const t=I1(),n=pwe(),r=mwe(),[i,s]=x.useState(!1),[a,o]=x.useState(e.title),[l,u]=x.useState(!1),[d,f]=x.useState(e.description||""),[h,m]=x.useState(!1),[b,y]=x.useState(e.notes||""),[v,_]=x.useState(""),[w,E]=x.useState(new Set),[T,k]=x.useState(e.prUrl||""),[S,A]=x.useState(!1),R=!!e.worktreePath,{data:I,isLoading:D}=oD(R&&e.repoPath||null),j=()=>{d!==(e.description||"")&&t.mutate({taskId:e.id,updates:{description:d||null}}),u(!1)},B=()=>{b!==(e.notes||"")&&t.mutate({taskId:e.id,updates:{notes:b||null}}),m(!1)},F=ee=>{t.mutate({taskId:e.id,updates:{dueDate:ee}})},L=ee=>{t.mutate({taskId:e.id,updates:{timeEstimate:ee}})},M=ee=>{t.mutate({taskId:e.id,updates:{priority:ee}})},P=()=>{const ee=v.trim();ee&&!e.tags.includes(ee)&&(n.mutate({taskId:e.id,tag:ee}),_(""))},U=ee=>{E(oe=>new Set(oe).add(ee)),r.mutate({taskId:e.id,tag:ee})},W=ee=>{ee.key==="Enter"&&(ee.preventDefault(),P())},G=()=>{const ee=T.trim();ee!==(e.prUrl||"")&&t.mutate({taskId:e.id,updates:{prUrl:ee||null}}),A(!1)},q=ee=>{ee.key==="Enter"?(ee.preventDefault(),G()):ee.key==="Escape"&&(k(e.prUrl||""),A(!1))},Y=ee=>{ee&&t.mutate({taskId:e.id,updates:{baseBranch:ee}})},X=ee=>{t.mutate({taskId:e.id,updates:{pinned:ee}})},z=()=>{const ee=a.trim();ee&&ee!==e.title&&t.mutate({taskId:e.id,updates:{title:ee}}),s(!1)},J=ee=>{ee.key==="Enter"?(ee.preventDefault(),z()):ee.key==="Escape"&&(o(e.title),s(!1))},te=g5(e.dueDate,e.status);return c.jsx("div",{className:"h-full overflow-auto p-4",style:{background:"var(--gradient-card)"},children:c.jsxs("div",{className:"max-w-2xl space-y-4",children:[c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Title"}),!i&&c.jsx(we,{variant:"ghost",size:"sm",onClick:()=>{o(e.title),s(!0)},className:"text-xs h-7",children:"Edit"})]}),i?c.jsxs("div",{className:"space-y-2",children:[c.jsx(Tt,{value:a,onChange:ee=>o(ee.target.value),onKeyDown:J,onBlur:z,placeholder:"Task title",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(we,{variant:"outline",size:"sm",onClick:()=>{o(e.title),s(!1)},children:"Cancel"}),c.jsx(we,{size:"sm",onClick:z,children:"Save"})]})]}):c.jsx("p",{className:"text-sm font-medium cursor-pointer hover:text-primary transition-colors",onClick:()=>{o(e.title),s(!0)},title:"Click to edit title",children:e.title})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),!l&&c.jsx(we,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"text-xs h-7",children:"Edit"})]}),l?c.jsxs("div",{className:"space-y-2",children:[c.jsx(hW,{value:d,onValueChange:f,placeholder:"Add a description...",rows:4}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(we,{variant:"outline",size:"sm",onClick:()=>{f(e.description||""),u(!1)},children:"Cancel"}),c.jsx(we,{size:"sm",onClick:j,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.description?c.jsx("p",{className:"whitespace-pre-wrap text-sm",children:e.description}):c.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No description"})})]}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Tags"}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.tags.map(ee=>{const oe=w.has(ee);return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-card px-2 py-0.5 text-xs font-medium",children:[ee,c.jsx("button",{type:"button",onClick:()=>U(ee),disabled:oe,className:"text-muted-foreground hover:text-foreground disabled:opacity-50",children:c.jsx(Q,{icon:oe?At:Tn,size:10,className:oe?"animate-spin":""})})]},ee)}),c.jsx("input",{type:"text",value:v,onChange:ee=>_(ee.target.value),onKeyDown:W,onBlur:P,placeholder:e.tags.length===0?"Add tag...":"+",className:"w-16 bg-transparent text-xs outline-none placeholder:text-muted-foreground"})]})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Due Date"}),c.jsx(VW,{value:e.dueDate,onChange:F,isOverdue:!!te})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Estimate"}),c.jsx(WW,{value:e.timeEstimate,onChange:L})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Priority"}),c.jsx(qW,{value:e.priority,onChange:M})]})]}),R&&c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Pull Request"}),!S&&e.prUrl&&c.jsx(we,{variant:"ghost",size:"sm",onClick:()=>A(!0),className:"text-xs h-7",children:"Edit"})]}),S?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Tt,{value:T,onChange:ee=>k(ee.target.value),onKeyDown:q,placeholder:"https://github.com/owner/repo/pull/123",className:"flex-1",autoFocus:!0}),c.jsx(we,{size:"sm",onClick:G,children:"Save"})]}):e.prUrl?c.jsxs("button",{onClick:()=>jl(e.prUrl),className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[c.jsx(Q,{icon:hd,size:14,strokeWidth:2}),c.jsxs("span",{children:["#",e.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]}),c.jsx(Q,{icon:N_e,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsx(we,{variant:"outline",size:"sm",onClick:()=>A(!0),className:"text-xs",children:"Link PR"})]}),R&&c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Base Branch"}),c.jsxs(_r,{value:e.baseBranch||"",onValueChange:Y,disabled:D,children:[c.jsx(wr,{className:"w-full",children:c.jsx(Sr,{children:e.baseBranch||c.jsx("span",{className:"text-muted-foreground",children:D?"Loading branches...":"Select branch"})})}),c.jsxs(Er,{children:[I?.branches&&I.branches.length>0&&c.jsxs(fx,{children:[(I.remoteBranches?.length??0)>0&&c.jsx(hx,{children:"Local"}),I.branches.map(ee=>c.jsx(Nt,{value:ee,children:ee},ee))]}),(I?.remoteBranches?.length??0)>0&&c.jsxs(fx,{children:[c.jsx(hx,{children:"Remote"}),I.remoteBranches.map(ee=>c.jsx(Nt,{value:ee,children:ee},ee))]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"Used for diff comparisons, rebase, merge, and PR creation."})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(ai,{id:"pin-task",checked:e.pinned??!1,onCheckedChange:X}),c.jsx("label",{htmlFor:"pin-task",className:"text-sm cursor-pointer",children:"Pin task (show at top of lists)"})]}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Pinned tasks appear first in their kanban column and calendar day list."})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Dependencies"}),c.jsx(nNe,{taskId:e.id})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Links"}),c.jsx(tNe,{taskId:e.id,links:e.links||[]})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Notes"}),!h&&c.jsx(we,{variant:"ghost",size:"sm",onClick:()=>m(!0),className:"text-xs h-7",children:"Edit"})]}),h?c.jsxs("div",{className:"space-y-2",children:[c.jsx("textarea",{value:b,onChange:ee=>y(ee.target.value),placeholder:"Add notes...",rows:3,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(we,{variant:"outline",size:"sm",onClick:()=>{y(e.notes||""),m(!1)},children:"Cancel"}),c.jsx(we,{size:"sm",onClick:B,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.notes?c.jsx("p",{className:"whitespace-pre-wrap text-sm",children:e.notes}):c.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No notes"})})]}),c.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Attachments"}),c.jsx(rNe,{taskId:e.id})]})]})})}const QH=_a("/tasks/$taskId")({component:JZt,validateSearch:e=>({tab:["diff","browser","files","details"].includes(e.tab)?e.tab:void 0,file:typeof e.file=="string"?e.file:void 0})}),TN={TO_DO:"To Do",IN_PROGRESS:"In Progress",IN_REVIEW:"In Review",DONE:"Done",CANCELED:"Canceled"},v0e={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function QZt(e){switch(e){case"pr":return hd;case"issue":return Y$e;case"docs":return E_e;case"design":return V$e;default:return Dy}}function JZt(){const{t:e}=Ot("common"),{taskId:t}=QH.useParams(),n=QH.useSearch(),r=Ai(),i=g6e(),{data:s,isLoading:a}=uwe(t),o=I1(),{viewState:l,setActiveTab:u,setFilesViewState:d}=UJ(t),f=jZ(),h=PZ(),m=LZ(),b=MZ(),y=FZ(),v=BZ(),{data:_}=cD(),{data:w}=uD(),{data:E}=dD(),{data:T}=AW(),{data:k}=P1(),{data:S}=wwe(),{data:A=[]}=fg(),R=A.find(We=>We.path===s?.repoPath),I=s?.opencodeModel??R?.opencodeModel??k,D=i.state,j=s?.aiMode??D?.aiMode,B=s?.description??D?.description,F=x.useRef(void 0);F.current===void 0&&D?.focusTerminal!==void 0&&(F.current=D.focusTerminal);const L=F.current??!1,[M,P]=x.useState(!1),[U,W]=x.useState("terminal"),[G,q]=x.useState(0),[Y,X]=x.useState(null),z=h5(),[J,te]=x.useState(!1),[ee,oe]=x.useState(""),[ae,re]=x.useState(null),ce=x.useRef(null),pe=x.useRef(null),ue=!!s?.worktreePath&&s?.type!=="scratch",_e=s?.type==="scratch",je=ue||_e,de=_e?"files":l.activeTab,fe=n.tab??de,he=_e&&fe==="diff"?"files":fe,ve=n.file??l.filesViewState.selectedFile,Ae=x.useRef(null);x.useEffect(()=>{Ae.current===t||n.tab||(Ae.current=t,l.activeTab&&r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:l.activeTab==="diff"?void 0:l.activeTab,file:l.filesViewState.selectedFile||void 0},replace:!0}))},[t,n.tab,l.activeTab,l.filesViewState.selectedFile,r]);const Te=x.useCallback(We=>{const lt=We;u(lt),r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:lt==="diff"?void 0:lt,file:lt==="files"&&ve||void 0},replace:!0})},[t,r,u,ve]),ye=x.useCallback(We=>{d({selectedFile:We}),r({to:"/tasks/$taskId",params:{taskId:t},search:{tab:"files",file:We||void 0},replace:!0})},[t,r,d]),{terminals:De,sendInputToTerminal:Ce,destroyTerminal:Pe}=zJ(),Ve=Fy(),Re=De.find(We=>s?.worktreePath&&We.cwd.startsWith(s.worktreePath));x.useEffect(()=>Y?_x(()=>Ve.terminals.items.some(lt=>lt.id===Y),lt=>{lt||(X(null),q(ke=>ke+1))},{fireImmediately:!0}):void 0,[Y,Ve]),x.useEffect(()=>{J&&ce.current&&(ce.current.focus(),ce.current.select())},[J]);const Me=()=>{s&&(pe.current&&re(pe.current.offsetWidth),oe(s.title),te(!0))},se=()=>{if(!s)return;const We=ee.trim();We&&We!==s.title&&o.mutate({taskId:s.id,updates:{title:We}}),te(!1)},qe=()=>{te(!1),oe("")},ht=We=>{We.key==="Enter"?(We.preventDefault(),se()):We.key==="Escape"&&(We.preventDefault(),qe())},kt=()=>{if(!s?.worktreePath)return;const We=Ve.terminals.items.find(lt=>lt.cwd.startsWith(s.worktreePath));We?(X(We.id),Pe(We.id,{force:!0,reason:"retry"})):q(lt=>lt+1)},Ze=We=>{Re?(Ce(Re.id,We),it.info(e("git.sentToClaude"))):it.error(e("git.noTerminal"))},ot=async()=>{if(!(!s?.repoPath||!s?.worktreePath))try{await f.mutateAsync({repoPath:s.repoPath,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0}),it.success(e("git.syncedFromMain"))}catch(We){const lt=We instanceof Error?We.message:"Sync failed",ke=s.baseBranch||"main";it.error(lt,{action:Re?{label:"Resolve with Claude",onClick:()=>Ze(`Rebase this worktree onto the parent repo's ${ke} branch. Error: "${lt}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${s.repoPath}) to ensure ${ke} is current, 3) git rebase ${ke} (in worktree), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) If stashed, git stash pop. Worktree: ${s.worktreePath}, Parent repo: ${s.repoPath}.`)}:void 0})}},Ge=async()=>{if(!(!s?.repoPath||!s?.worktreePath))try{await h.mutateAsync({repoPath:s.repoPath,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0}),it.success(e("git.mergedToMain")),v.mutate(s.id),o.mutate({taskId:s.id,updates:{status:"DONE"}})}catch(We){const lt=We instanceof Error?We.message:"Merge failed",ke=s.baseBranch||"main";it.error(lt,{action:Re?{label:"Resolve with Claude",onClick:()=>Ze(`Merge this worktree's branch into the parent repo's ${ke}. Error: "${lt}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${s.repoPath}, checkout ${ke} and pull latest from origin, 3) Squash merge the worktree branch into ${ke} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${ke} to origin. Worktree: ${s.worktreePath}, Parent repo: ${s.repoPath}.`)}:void 0})}},xt=async()=>{if(s?.worktreePath)try{await m.mutateAsync({worktreePath:s.worktreePath}),it.success(e("git.pushedToOrigin"))}catch(We){const lt=We instanceof Error?We.message:"Push failed";it.error(lt,{action:Re?{label:"Resolve with Claude",onClick:()=>Ze(`Push this worktree's branch to origin. Error: "${lt}". Steps: 1) Check for uncommitted changes and commit them, 2) If push is rejected, pull the latest changes first and resolve any conflicts, 3) Push to origin again. Worktree: ${s.worktreePath}.`)}:void 0})}},Ue=async()=>{if(s?.repoPath)try{await b.mutateAsync({repoPath:s.repoPath,baseBranch:s.baseBranch??void 0}),it.success(e("git.parentSynced"))}catch(We){const lt=We instanceof Error?We.message:"Sync parent failed",ke=s.baseBranch||"main";it.error(lt,{action:Re?{label:"Resolve with Claude",onClick:()=>Ze(`Sync the parent repo's ${ke} branch with origin. Error: "${lt}". Steps: 1) git fetch origin, 2) git pull origin ${ke} --ff-only, 3) If that fails, rebase with git rebase origin/${ke}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${ke}. Work in the parent repo at ${s.repoPath}, not the worktree.`)}:void 0})}},Qe=()=>{Re&&Ce(Re.id,"commit")},ft=async()=>{if(s?.worktreePath)try{const We=await y.mutateAsync({worktreePath:s.worktreePath,title:s.title,baseBranch:s.baseBranch??void 0});o.mutate({taskId:s.id,updates:{prUrl:We.prUrl}}),it.success(e("git.prCreated"),{action:{label:"View PR",onClick:()=>jl(We.prUrl)}})}catch(We){const lt=We instanceof Error?We.message:"Failed to create PR",ke=We&&typeof We=="object"&&"existingPrUrl"in We?We.existingPrUrl:void 0;if(ke){o.mutate({taskId:s.id,updates:{prUrl:ke}}),it.info(e("git.prExists"),{action:{label:"View PR",onClick:()=>jl(ke)}});return}const Ie=lt.split(`
321
- `).filter(Boolean).pop()||lt;it.error(Ie,{action:{label:"Resolve with Claude",onClick:()=>Ze(`Create a PR for this task. Error: "${lt}". After creating, link it using: fulcrum current-task pr <url>. Worktree: ${s.worktreePath}.`)}})}},st=()=>{if(!s?.worktreePath)return;const We=lq(s.worktreePath,_,w,E);jl(We)},mt=We=>{s&&o.mutate({taskId:s.id,updates:{status:We}})};return a?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx("p",{className:"text-muted-foreground",children:"Loading task..."})}):s?je?c.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[c.jsxs("div",{className:"film-grain relative shrink-0 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex flex-col gap-1 sm:hidden",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[J?c.jsx("input",{ref:ce,type:"text",value:ee,onChange:We=>oe(We.target.value),onKeyDown:ht,onBlur:se,className:"min-w-0 flex-1 truncate text-sm font-medium bg-transparent border-b border-primary outline-none",style:{minWidth:ae?`${ae}px`:void 0}}):c.jsx("h1",{ref:pe,className:"min-w-0 flex-1 truncate text-sm font-medium cursor-pointer hover:text-primary transition-colors",onClick:Me,title:"Click to edit title",children:s.title}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${v0e[s.status]}`}),children:c.jsxs("span",{className:"flex items-center gap-1",children:[o.isPending&&o.variables?.updates?.status&&c.jsx(Q,{icon:At,size:12,className:"animate-spin"}),TN[s.status]]})}),c.jsx(fd,{align:"end",children:c.jsx(wR,{value:s.status,onValueChange:mt,children:Object.entries(TN).map(([We,lt])=>c.jsx(ER,{value:We,children:lt},We))})})]}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),children:c.jsx(Q,{icon:UN,size:16,strokeWidth:2})}),c.jsx(fd,{align:"end",children:!_e&&c.jsxs(c.Fragment,{children:[c.jsxs(ti,{onClick:ot,disabled:f.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:EE,size:14,strokeWidth:2}),"Pull from ",s.baseBranch]}),c.jsxs(ti,{onClick:Ge,disabled:h.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:wE,size:14,strokeWidth:2}),"Merge to ",s.baseBranch]}),c.jsxs(ti,{onClick:xt,disabled:m.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:CE,size:14,strokeWidth:2}),"Push to origin"]}),c.jsxs(ti,{onClick:Ue,disabled:b.isPending||!s.repoPath,children:[c.jsx(Q,{icon:TE,size:14,strokeWidth:2}),"Sync parent"]}),c.jsxs(ti,{onClick:Qe,disabled:!Re,children:[c.jsx(Q,{icon:kE,size:14,strokeWidth:2}),"Commit"]}),!s.prUrl&&c.jsxs(ti,{onClick:ft,disabled:y.isPending,children:[c.jsx(Q,{icon:hd,size:14,strokeWidth:2,className:y.isPending?"animate-pulse":""}),"Create PR"]})]})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>P(!0),children:c.jsx(Q,{icon:Ps,size:16,strokeWidth:2})})]}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:kt,title:"New task terminal",children:c.jsx(Q,{icon:sse,size:14,strokeWidth:2})}),!_e&&c.jsxs(c.Fragment,{children:[R?c.jsxs(Ur,{to:"/repositories/$repoId",params:{repoId:R.id},className:"flex items-center gap-1 hover:text-primary",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),c.jsx("span",{className:"hover:underline",children:s.repoName})]}):c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),s.repoName]}),s.baseBranch&&c.jsxs("span",{className:"text-muted-foreground/70 font-mono truncate",children:["from ",s.baseBranch]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Qw,{worktreePath:s.worktreePath})})]})]})]}),c.jsxs("div",{className:"hidden items-center gap-3 sm:flex",children:[c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[J?c.jsx("input",{ref:ce,type:"text",value:ee,onChange:We=>oe(We.target.value),onKeyDown:ht,onBlur:se,className:"text-sm font-medium bg-transparent border-b border-primary outline-none",style:{minWidth:ae?`${ae}px`:200}}):c.jsx("h1",{ref:pe,className:"text-sm font-medium cursor-pointer hover:text-primary transition-colors",onClick:Me,title:"Click to edit title",children:s.title}),c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:kt,title:"New task terminal",children:c.jsx(Q,{icon:sse,size:14,strokeWidth:2})}),s.links&&s.links.length>0&&c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"Task links"}),children:c.jsx(Q,{icon:Dy,size:14,strokeWidth:2})}),c.jsx(fd,{align:"start",className:"w-auto",children:s.links.map(We=>c.jsxs(ti,{onClick:()=>jl(We.url),children:[c.jsx(Q,{icon:QZt(We.type),size:14,strokeWidth:2}),c.jsx("span",{children:We.label})]},We.id))})]})]}),!_e&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[R?c.jsxs(Ur,{to:"/repositories/$repoId",params:{repoId:R.id},className:"flex items-center gap-1 hover:text-primary",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),c.jsx("span",{className:"hover:underline",children:s.repoName})]}):c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),s.repoName]}),c.jsx(Q,{icon:Z3,size:12,strokeWidth:2}),c.jsx("span",{className:"font-mono",children:s.branch}),s.baseBranch&&c.jsxs("span",{className:"text-muted-foreground/70 font-mono",children:["from ",s.baseBranch]}),s.prUrl&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/50",children:"•"}),c.jsxs("a",{href:s.prUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:We=>We.stopPropagation(),children:[c.jsx(Q,{icon:hd,size:14,strokeWidth:2}),c.jsxs("span",{children:["#",s.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]})]})]})]})]}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${v0e[s.status]}`}),children:c.jsxs("span",{className:"flex items-center gap-1",children:[o.isPending&&o.variables?.updates?.status&&c.jsx(Q,{icon:At,size:12,className:"animate-spin"}),TN[s.status]]})}),c.jsx(fd,{align:"end",children:c.jsx(wR,{value:s.status,onValueChange:mt,children:Object.entries(TN).map(([We,lt])=>c.jsx(ER,{value:We,children:lt},We))})})]}),c.jsxs("div",{className:"flex items-center gap-0",children:[!_e&&c.jsxs(c.Fragment,{children:[c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:ot,disabled:f.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Pull from ${s.baseBranch}`,children:c.jsx(Q,{icon:EE,size:16,strokeWidth:2,className:f.isPending?"animate-spin":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Ge,disabled:h.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Merge to ${s.baseBranch}`,children:c.jsx(Q,{icon:wE,size:16,strokeWidth:2,className:h.isPending?"animate-pulse":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:xt,disabled:m.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Push to origin",children:c.jsx(Q,{icon:CE,size:16,strokeWidth:2,className:m.isPending?"animate-pulse":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Ue,disabled:b.isPending||!s.repoPath,className:"text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:c.jsx(Q,{icon:TE,size:16,strokeWidth:2,className:b.isPending?"animate-spin":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Qe,disabled:!Re,className:"text-muted-foreground hover:text-foreground",title:"Commit",children:c.jsx(Q,{icon:kE,size:16,strokeWidth:2})}),!s.prUrl&&c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:ft,disabled:y.isPending,className:"text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:c.jsx(Q,{icon:hd,size:16,strokeWidth:2,className:y.isPending?"animate-pulse":""})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:st,disabled:!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Open in editor",children:c.jsx(Q,{icon:$_e,size:16,strokeWidth:2})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>P(!0),children:c.jsx(Q,{icon:Ps,size:16,strokeWidth:2})})]})]}),z?c.jsxs(il,{value:U,onValueChange:We=>W(We),className:"flex min-h-0 flex-1 flex-col",children:[c.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:c.jsxs(sl,{className:"w-full",children:[c.jsx(Dn,{value:"terminal",className:"flex-1",children:"Terminal"}),c.jsx(Dn,{value:"details",className:"flex-1",children:"Details"})]})}),c.jsx(Mn,{value:"terminal",className:"flex-1 min-h-0",children:c.jsx(l0e,{taskName:s.title,cwd:s.worktreePath,taskId:s.id,agent:s.agent,aiMode:j,description:B,startupScript:_e?S??void 0:s.startupScript,agentOptions:s.agentOptions,opencodeModel:I,serverPort:T,autoFocus:L},G)}),c.jsx(Mn,{value:"details",className:"flex-1 min-h-0 bg-background",children:c.jsxs(il,{value:he,onValueChange:Te,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex items-center justify-between shrink-0 border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs(sl,{variant:"line",children:[!_e&&c.jsxs(Dn,{value:"diff",children:[c.jsx(Q,{icon:c$,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),c.jsxs(Dn,{value:"browser",children:[c.jsx(Q,{icon:UO,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),c.jsxs(Dn,{value:"files",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]}),c.jsxs(Dn,{value:"details",children:[c.jsx(Q,{icon:UN,size:14,strokeWidth:2,"data-slot":"icon"}),"Details"]})]}),!_e&&c.jsx(Qw,{worktreePath:s.worktreePath})]}),!_e&&c.jsx(Mn,{value:"diff",className:"flex-1 overflow-hidden",children:c.jsx(c0e,{taskId:s.id,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0})}),c.jsx(Mn,{value:"browser",className:"flex-1 overflow-hidden",children:c.jsx(u0e,{taskId:s.id})}),c.jsx(Mn,{value:"files",className:"flex-1 overflow-hidden",children:c.jsx(i3,{worktreePath:s.worktreePath,initialSelectedFile:ve,onFileChange:ye})}),c.jsx(Mn,{value:"details",className:"flex-1 overflow-hidden",children:c.jsx(y0e,{task:s})})]})})]}):c.jsxs(gb,{direction:"horizontal",className:"min-h-0 flex-1",children:[c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsx(l0e,{taskName:s.title,cwd:s.worktreePath,taskId:s.id,agent:s.agent,aiMode:j,description:B,startupScript:_e?S??void 0:s.startupScript,agentOptions:s.agentOptions,opencodeModel:I,serverPort:T,autoFocus:L},G)}),c.jsx(bb,{withHandle:!0}),c.jsx(lu,{defaultSize:50,minSize:30,className:"bg-background",children:c.jsxs(il,{value:he,onValueChange:Te,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex items-center justify-between shrink-0 border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs(sl,{variant:"line",children:[!_e&&c.jsxs(Dn,{value:"diff",children:[c.jsx(Q,{icon:c$,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),c.jsxs(Dn,{value:"browser",children:[c.jsx(Q,{icon:UO,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),c.jsxs(Dn,{value:"files",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]}),c.jsxs(Dn,{value:"details",children:[c.jsx(Q,{icon:UN,size:14,strokeWidth:2,"data-slot":"icon"}),"Details"]})]}),!_e&&c.jsx(Qw,{worktreePath:s.worktreePath})]}),!_e&&c.jsx(Mn,{value:"diff",className:"flex-1 overflow-hidden",children:c.jsx(c0e,{taskId:s.id,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0})}),c.jsx(Mn,{value:"browser",className:"flex-1 overflow-hidden",children:c.jsx(u0e,{taskId:s.id})}),c.jsx(Mn,{value:"files",className:"flex-1 overflow-hidden",children:c.jsx(i3,{worktreePath:s.worktreePath,initialSelectedFile:ve,onFileChange:ye})}),c.jsx(Mn,{value:"details",className:"flex-1 overflow-hidden",children:c.jsx(y0e,{task:s})})]})})]}),c.jsx(i2,{task:s,open:M,onOpenChange:P,onDeleted:()=>r({to:"/tasks"})})]}):c.jsx(ZZt,{task:s}):c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx("p",{className:"text-muted-foreground",children:"Task not found"}),c.jsx(Ur,{to:"/tasks",children:c.jsx(we,{variant:"outline",children:"Back to Tasks"})})]})}function eQt({repoPath:e,repoDisplayName:t,activeTab:n,file:r,onFileChange:i,onFileSaved:s}){const{t:a}=Ot("repositories"),o=h5(),[l,u]=x.useState("terminal"),[d,f]=x.useState(null),[h,m]=x.useState(!1),[b,y]=x.useState(!1),[v,_]=x.useState(!1),w=x.useRef(null),E=x.useRef(null),T=x.useRef(!1),k=x.useRef(!1),{terminals:S,terminalsLoaded:A,connected:R,createTerminal:I,recreateTerminal:D,attachXterm:j,resizeTerminal:B,setupImagePaste:F,writeToTerminal:L}=zJ(),P=(d?S.find(te=>te.id===d):null)?.status;x.useEffect(()=>{Xt.repoTerminal.info("WorkspacePanel mounted",{repoPath:e,activeTab:n})},[e,n]),x.useEffect(()=>{Xt.repoTerminal.debug("WorkspacePanel state changed",{terminalId:d,xtermReady:b,containerReady:v,connected:R,terminalsLoaded:A,terminalCount:S.length,repoPath:e})},[d,b,v,R,A,S.length,e]),x.useEffect(()=>{T.current=!1,k.current=!1,f(null),m(!1)},[e]),x.useEffect(()=>{if(!R||!e||!A||n!=="workspace"||!b){Xt.repoTerminal.debug("find/create: waiting",{connected:R,repoPath:e,terminalsLoaded:A,activeTab:n,xtermReady:b});return}const te=S.find(ee=>ee.cwd===e&&ee.status==="running");if(te){Xt.repoTerminal.info("found existing terminal",{id:te.id,cwd:te.cwd}),f(te.id);return}if(!T.current&&w.current){T.current=!0,m(!0);const{cols:ee,rows:oe}=w.current;Xt.repoTerminal.info("creating terminal",{name:t,cwd:e,cols:ee,rows:oe}),I({name:t,cols:ee,rows:oe,cwd:e})}},[R,e,t,A,S,n,I,b]),x.useEffect(()=>{if(!e)return;const te=S.find(oe=>oe.cwd===e&&oe.status==="running");if(!te)return;const ee=d&&S.some(oe=>oe.id===d);(!d||!ee)&&(f(te.id),m(!1),d&&!ee&&(k.current=!1))},[S,e,d]);const U=x.useCallback(te=>{Xt.repoTerminal.info("xterm ready"),w.current=te,y(!0)},[]),W=x.useCallback((te,ee)=>{d&&B(d,te,ee)},[d,B]),G=x.useCallback(te=>{Xt.repoTerminal.info("container ready"),E.current=te,_(!0)},[]),q=x.useCallback(te=>{d&&L(d,te)},[d,L]),Y=x.useCallback(()=>{d&&(k.current=!1,T.current=!1,f(null),D(d))},[d,D]);x.useEffect(()=>{if(!d||!b||!v){Xt.repoTerminal.debug("attach effect: waiting",{terminalId:d,xtermReady:b,containerReady:v});return}if(!w.current||!E.current){Xt.repoTerminal.warn("attach effect: refs not set despite ready states",{terminalId:d});return}if(k.current){Xt.repoTerminal.debug("attach effect: already attached",{terminalId:d});return}return Xt.repoTerminal.info("attaching terminal",{terminalId:d}),j(d,w.current),F(E.current,d),k.current=!0,()=>{Xt.repoTerminal.debug("detaching terminal",{terminalId:d}),k.current=!1}},[d,b,v,j,F]);const X=()=>!h||d?null:c.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(Q,{icon:At,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),c.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:a("detailView.workspace.initializingTerminal")})]})}),z=()=>R?null:c.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:a("detailView.workspace.connectingToTerminal")}),J=()=>!d||!P||P==="running"?null:c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/95",children:c.jsxs("div",{className:"flex flex-col items-center gap-4",children:[c.jsx("span",{className:"text-sm text-destructive",children:a("detailView.workspace.terminalConnectionFailed")}),c.jsx(we,{onClick:Y,variant:"outline",children:a("detailView.workspace.recreateTerminal")})]})});return o?c.jsxs(il,{value:l,onValueChange:te=>u(te),className:"flex min-h-0 flex-1 flex-col h-full",children:[c.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:c.jsxs(sl,{className:"w-full",children:[c.jsx(Dn,{value:"terminal",className:"flex-1",children:a("detailView.mobileWorkspace.terminal")}),c.jsx(Dn,{value:"files",className:"flex-1",children:a("detailView.mobileWorkspace.files")})]})}),c.jsx(Mn,{value:"terminal",className:"flex-1 min-h-0",children:c.jsxs("div",{className:"relative h-full flex flex-col",children:[z(),X(),J(),c.jsx(zU,{className:"flex-1",onReady:U,onResize:W,onContainerReady:G,terminalId:d??void 0,setupImagePaste:F,onSend:q})]})}),c.jsx(Mn,{value:"files",className:"flex-1 min-h-0",children:c.jsx(i3,{worktreePath:e,initialSelectedFile:r,onFileChange:i,onFileSaved:s})})]}):c.jsxs(gb,{direction:"horizontal",className:"h-full",children:[c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsxs("div",{className:"relative h-full flex flex-col",children:[z(),X(),J(),c.jsx(zU,{className:"flex-1",onReady:U,onResize:W,onContainerReady:G,terminalId:d??void 0,setupImagePaste:F,onSend:q})]})}),c.jsx(bb,{withHandle:!0}),c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsx(i3,{worktreePath:e,initialSelectedFile:r,onFileChange:i,onFileSaved:s})})]})}function x0e({step:e,currentStep:t,label:n,status:r}){const i=["docker","traefik","complete"],s=i.indexOf(e),a=i.indexOf(t),o=e===t,l=s<a||r==="complete";return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:Oe("flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium",l&&"bg-green-500 text-white",o&&"bg-primary text-primary-foreground",!l&&!o&&"bg-muted text-muted-foreground",r==="error"&&"bg-destructive text-destructive-foreground"),children:l?c.jsx(Q,{icon:ur,size:14,strokeWidth:2}):r==="error"?c.jsx(Q,{icon:Tn,size:14,strokeWidth:2}):s+1}),c.jsx("span",{className:Oe("text-sm",o&&"font-medium",!l&&!o&&"text-muted-foreground"),children:n})]})}function tQt({onComplete:e}){const{data:t,isLoading:n,refetch:r}=$2e(),i=uJe(),[s,a]=x.useState("docker"),o=()=>!t||!t.docker.installed||!t.docker.running?"docker":!t.traefik.detected&&t.traefik.type==="none"?"traefik":"complete",l=["docker","traefik","complete"],u=n?l.indexOf(s):Math.max(l.indexOf(s),l.indexOf(o())),d=l[Math.min(u,l.length-1)],f=async()=>{await i.mutateAsync(),await r()},h=()=>{e?.()};return n?c.jsx(_i,{className:"mx-auto max-w-2xl",children:c.jsx(js,{className:"flex items-center justify-center py-12",children:c.jsx(Q,{icon:At,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})})}):c.jsxs(_i,{className:"mx-auto max-w-2xl",children:[c.jsxs(r_,{children:[c.jsx(i_,{children:"Deployment Setup"}),c.jsx($_t,{children:"Configure your server for deploying containerized applications"})]}),c.jsxs(js,{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(x0e,{step:"docker",currentStep:d,label:"Docker",status:t?.docker.running?"complete":d==="docker"?"current":"pending"}),c.jsx("div",{className:"h-px flex-1 mx-2 bg-border"}),c.jsx(x0e,{step:"traefik",currentStep:d,label:"Traefik",status:t?.traefik.detected?"complete":d==="traefik"?"current":"pending"})]}),d==="docker"&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:t?.docker.installed?t?.docker.running?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Docker is running"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Version ",t.docker.version]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-amber-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"Docker is not running"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Docker is installed (v",t.docker.version,") but the daemon is not running."]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Start Docker and click refresh."})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-destructive"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"Docker is not installed"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Docker is required to deploy containerized applications."}),c.jsx("a",{href:"https://docs.docker.com/get-docker/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline",children:"Install Docker →"})]})]})}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsxs(we,{variant:"outline",onClick:()=>r(),children:[c.jsx(Q,{icon:lp,size:16,strokeWidth:2,"data-slot":"icon"}),"Refresh"]}),t?.docker.running&&c.jsxs(we,{onClick:()=>a("traefik"),children:["Continue",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})]})]}),d==="traefik"&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:t?.traefik.detected?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:t.traefik.type==="dokploy"?"Dokploy Traefik detected":t.traefik.type==="fulcrum"?"Fulcrum Traefik running":"Traefik detected"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Reverse proxy is ready to route traffic to your apps."}),t.traefik.containerName&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Container: ",t.traefik.containerName]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-amber-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"No Traefik detected"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Traefik handles HTTPS certificates and routes traffic to your apps."}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Fulcrum can start its own Traefik container for you."})]})]})}),c.jsxs("div",{className:"flex justify-end gap-2",children:[!t?.traefik.detected&&c.jsxs(we,{onClick:f,disabled:i.isPending,children:[i.isPending?c.jsx(Q,{icon:At,size:16,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):null,"Start Traefik"]}),t?.traefik.detected&&c.jsxs(we,{onClick:()=>a("complete"),children:["Continue",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})]}),i.isError&&c.jsxs("p",{className:"text-sm text-destructive",children:["Failed to start Traefik: ",i.error?.message||"Unknown error"]})]}),d==="complete"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-green-500/30 bg-green-500/10 p-4",children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-green-600 dark:text-green-400",children:"Setup Complete"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Your server is ready to deploy containerized applications."})]})]}),c.jsx("div",{className:"flex justify-end",children:c.jsxs(we,{onClick:h,children:["Create Your First App",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})})]})]})]})}function s3({value:e,onChange:t}){const{t:n}=Ot("repositories"),[r,i]=x.useState(()=>{const d=Object.entries(e);return d.length===0?[]:d.map(([f,h])=>({id:crypto.randomUUID(),key:f,value:h}))}),s=x.useRef(null);x.useEffect(()=>{const d=Object.entries(e);if(d.length===0&&r.length===0)return;const f=a(r);JSON.stringify(f)!==JSON.stringify(e)&&i(d.map(([h,m])=>({id:crypto.randomUUID(),key:h,value:m})))},[e]);const a=d=>{const f={};for(const h of d){const m=h.key.trim();m&&(f[m]=h.value)}return f},o=(d,f,h)=>{const m=r.map(b=>b.id===d?{...b,[f]:h}:b);i(m),t(a(m))},l=()=>{const d={id:crypto.randomUUID(),key:"",value:""};i([...r,d]),setTimeout(()=>{s.current?.focus()},0)},u=d=>{const f=r.filter(h=>h.id!==d);i(f),t(a(f))};return c.jsxs("div",{className:"space-y-2",children:[r.length>0&&c.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-muted/50",children:[c.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-[40%]",children:n("detailView.settings.agentOptionsFlag")}),c.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:n("detailView.settings.agentOptionsValue")}),c.jsx("th",{className:"w-10"})]})}),c.jsx("tbody",{children:r.map((d,f)=>c.jsxs("tr",{className:"border-t border-border",children:[c.jsx("td",{className:"px-2 py-1",children:c.jsx(Tt,{ref:f===r.length-1?s:void 0,value:d.key,onChange:h=>o(d.id,"key",h.target.value),placeholder:"model",className:"h-8 font-mono text-xs"})}),c.jsx("td",{className:"px-2 py-1",children:c.jsx(Tt,{value:d.value,onChange:h=>o(d.id,"value",h.target.value),placeholder:"haiku",className:"h-8 font-mono text-xs"})}),c.jsx("td",{className:"px-2 py-1",children:c.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>u(d.id),children:c.jsx(Q,{icon:Ps,size:14,strokeWidth:2})})})]},d.id))})]})}),c.jsxs(we,{variant:"outline",size:"sm",onClick:l,className:"w-full",children:[c.jsx(Q,{icon:Dc,size:14,strokeWidth:2,"data-slot":"icon"}),n("detailView.settings.addAgentOption")]})]})}function nQt(e){const t=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return t?`https://${t[1]}/${t[2]}`:e.replace(/\.git$/,"")}function rQt(e){return Qt({queryKey:["git-remote",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/git/remote?path=${encodeURIComponent(e)}`);return t.ok?(await t.json()).remoteUrl:null},enabled:!!e,staleTime:60*1e3})}function iQt({repository:e}){const{t}=Ot("repositories"),n=Ot("projects").t,r=lqe(),{data:i}=rQt(e.path),[s,a]=x.useState(""),[o,l]=x.useState(""),[u,d]=x.useState(""),[f,h]=x.useState({}),[m,b]=x.useState({}),[y,v]=x.useState(null),[_,w]=x.useState(null),[E,T]=x.useState(!1),[k,S]=x.useState(!1);x.useEffect(()=>{e&&(a(e.displayName),l(e.startupScript||""),d(e.copyFiles||""),h(e.claudeOptions||{}),b(e.opencodeOptions||{}),v(e.opencodeModel??null),w(e.defaultAgent??null),T(e.isCopierTemplate??!1),S(!1))},[e]),x.useEffect(()=>{if(e){const R=s!==e.displayName||o!==(e.startupScript||"")||u!==(e.copyFiles||"")||JSON.stringify(f)!==JSON.stringify(e.claudeOptions||{})||JSON.stringify(m)!==JSON.stringify(e.opencodeOptions||{})||y!==(e.opencodeModel??null)||_!==(e.defaultAgent??null)||E!==(e.isCopierTemplate??!1);S(R)}},[s,o,u,f,m,y,_,E,e]);const A=()=>{e&&r.mutate({id:e.id,updates:{displayName:s.trim()||e.path.split("/").pop()||"repo",startupScript:o.trim()||null,copyFiles:u.trim()||null,claudeOptions:Object.keys(f).length>0?f:null,opencodeOptions:Object.keys(m).length>0?m:null,opencodeModel:y,defaultAgent:_,isCopierTemplate:E}},{onSuccess:()=>{it.success(t("detailView.saved")),S(!1)},onError:R=>{it.error(t("detailView.failedToSave"),{description:R instanceof Error?R.message:"Unknown error"})}})};return c.jsx(Lf,{className:"h-full",children:c.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2}),c.jsx("span",{className:"font-mono break-all",children:e.path}),i&&c.jsx("a",{href:nQt(i),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors",title:i,children:c.jsx(Q,{icon:i.includes("github.com")?R$e:Dy,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[c.jsxs("div",{className:"film-grain relative flex-1 rounded-lg p-6 border border-border",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-sm font-medium mb-4",children:n("detailView.general.repositoryTitle")}),c.jsxs(qh,{children:[c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"displayName",children:n("detailView.general.displayName")}),c.jsx(Tt,{id:"displayName",value:s,onChange:R=>a(R.target.value),placeholder:e.path.split("/").pop()||"My Project"})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"startupScript",children:n("detailView.general.startupScript")}),c.jsx(Rc,{id:"startupScript",value:o,onChange:R=>l(R.target.value),placeholder:t("detailView.settings.startupScriptPlaceholder"),rows:3}),c.jsx(Fi,{children:t("detailView.settings.startupScriptDescription")})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"copyFiles",children:n("detailView.general.copyFiles")}),c.jsx(Tt,{id:"copyFiles",value:u,onChange:R=>d(R.target.value),placeholder:t("detailView.settings.copyFilesPlaceholder")}),c.jsx(Fi,{children:t("detailView.settings.copyFilesDescription")})]}),c.jsxs(Pn,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ai,{checked:E,onCheckedChange:R=>T(R===!0)}),c.jsx(Ln,{className:"cursor-pointer",children:t("detailView.settings.isCopierTemplate")})]}),c.jsx(Fi,{children:t("detailView.settings.isCopierTemplateDescription")})]})]})]}),c.jsxs("div",{className:"film-grain relative flex-1 rounded-lg p-6 border border-border",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-sm font-medium mb-4",children:n("detailView.general.agentTitle")}),c.jsxs(qh,{children:[c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.defaultAgent")}),c.jsxs(_r,{value:_??"inherit",onValueChange:R=>w(R==="inherit"?null:R),children:[c.jsx(wr,{className:"w-full",children:c.jsx(Sr,{})}),c.jsxs(Er,{alignItemWithTrigger:!1,children:[c.jsx(Nt,{value:"inherit",children:t("detailView.settings.defaultAgentInherit")}),Object.keys(Ga).map(R=>c.jsx(Nt,{value:R,children:Ga[R]},R))]})]}),c.jsx(Fi,{children:t("detailView.settings.defaultAgentDescription")})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.claudeOptions")}),c.jsx(Fi,{className:"mb-2",children:t("detailView.settings.claudeOptionsDescription")}),c.jsx(s3,{value:f,onChange:h})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.opencodeOptions")}),c.jsx(Fi,{className:"mb-2",children:t("detailView.settings.opencodeOptionsDescription")}),c.jsx(s3,{value:m,onChange:b})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.opencodeModel")}),c.jsx(Wb,{value:y,onChange:v,placeholder:t("detailView.settings.opencodeModelPlaceholder")}),c.jsx(Fi,{children:t("detailView.settings.opencodeModelDescription")})]})]})]})]}),c.jsx("div",{className:"flex items-center justify-end mt-4",children:c.jsxs(we,{size:"sm",onClick:A,disabled:!k||r.isPending,children:[c.jsx(Q,{icon:ur,size:14,strokeWidth:2,"data-slot":"icon"}),r.isPending?t("detailView.saving"):t("detailView.save")]})})]})})}function sQt({app:e,onDeploy:t,onStop:n,onCancelDeploy:r,isBuilding:i,isRunning:s,isStopPending:a,isCancelPending:o,deployStore:l}){const{t:u}=Ot("projects"),d=Ot("common").t,f=oq(),h=async v=>{await f.mutateAsync({id:e.id,updates:{autoDeployEnabled:v}})},m=async v=>{await f.mutateAsync({id:e.id,updates:{autoPortAllocation:v}})},b=async v=>{await f.mutateAsync({id:e.id,updates:{noCacheBuild:v}})},y=async v=>{await f.mutateAsync({id:e.id,updates:{notificationsEnabled:v}})};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:u("detailView.tabs.deploy")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(we,{size:"sm",onClick:t,disabled:i,children:[i?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:cx,size:14,strokeWidth:2}),l.isDeploying?d("apps.deploying"):e.status==="building"?d("apps.building"):u("deploy")]}),i?c.jsxs(we,{variant:"destructive",size:"sm",onClick:r,disabled:o,children:[o?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:OE,size:14,strokeWidth:2}),d(o?"apps.cancelling":"apps.cancelDeploy")]}):c.jsxs(we,{variant:"destructive",size:"sm",onClick:n,disabled:a||!s,children:[a?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:OE,size:14,strokeWidth:2}),u("stop")]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.autoDeployEnabled??!1,onCheckedChange:v=>h(v===!0)}),c.jsx("span",{children:u("detailView.app.autoDeployEnabled")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.autoPortAllocation??!0,onCheckedChange:v=>m(v===!0)}),c.jsx("span",{children:u("detailView.app.autoPortAllocation")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.noCacheBuild??!1,onCheckedChange:v=>b(v===!0)}),c.jsx("span",{children:u("detailView.app.noCacheBuild")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.notificationsEnabled??!0,onCheckedChange:v=>y(v===!0)}),c.jsx("span",{children:u("detailView.app.notificationsEnabled")})]})]})]})}function aQt({app:e,onDeploy:t}){const{t:n}=Ot("projects"),r=Ot("common").t,{data:i}=F2e(e.id),{data:s}=U2e(),a=oq(),o=B2e(),l=s?.tunnelsAvailable??!1,[u,d]=x.useState(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[]),[f,h]=x.useState(null);x.useEffect(()=>{f===null&&d(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[])},[e.services,f]);const m=w=>{if(i?.containers){const E=i.containers.find(T=>T.service===w);if(E)return E.status}return"stopped"},b=async()=>{await a.mutateAsync({id:e.id,updates:{services:u.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort??void 0,exposed:!!w.domain,domain:w.domain||void 0,exposureMethod:w.exposureMethod}))}}),h(null),it.warning(r("apps.deployToApply"),{description:r("apps.deployToApplyDesc"),action:{label:r("apps.deploy"),onClick:t}})},y=(w,E)=>{d(T=>T.map((k,S)=>S===w?{...k,...E}:k))},v=w=>{f===w?b():h(w)},_=()=>{d(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[]),h(null)};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("detailView.app.services")}),u.length>0?c.jsx("div",{className:"space-y-2",children:u.map((w,E)=>{const T=m(w.serviceName),k=T==="running",S=f===E,A=!!w.containerPort,R=!!w.domain;return c.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[c.jsx("div",{className:`h-2 w-2 shrink-0 rounded-full ${k?"bg-green-500":"bg-gray-400"}`,title:T}),c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[c.jsx("span",{className:"font-medium",children:w.serviceName}),w.containerPort&&c.jsxs(Jn,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[":",w.containerPort]})]}),c.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:S?c.jsxs(c.Fragment,{children:[c.jsx(Tt,{value:w.domain,onChange:I=>y(E,{domain:I.target.value}),placeholder:"app.example.com",className:"h-7 text-xs flex-1 min-w-0",autoFocus:!0,disabled:!A}),c.jsxs("select",{value:w.exposureMethod,onChange:I=>y(E,{exposureMethod:I.target.value}),className:"h-7 w-20 rounded-md border bg-background px-2 text-xs shrink-0",disabled:!A,children:[c.jsx("option",{value:"dns",children:"DNS"}),c.jsx("option",{value:"tunnel",disabled:!l,children:"Tunnel"})]})]}):R?c.jsxs(c.Fragment,{children:[c.jsx("a",{href:`https://${w.domain}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate",children:w.domain}),c.jsx(Jn,{variant:w.exposureMethod==="tunnel"?"default":"outline",className:"text-xs px-1.5 py-0 shrink-0",children:w.exposureMethod==="tunnel"?"Tunnel":"DNS"})]}):c.jsx("span",{className:"text-muted-foreground/50 text-xs",children:r(A?"apps.domains.noDomain":"apps.domains.portRequired")})}),S?c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(E),disabled:a.isPending,children:a.isPending?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:ol,size:14,strokeWidth:2,className:"text-green-500"})}),c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"})})]}):c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>v(E),disabled:!A,children:c.jsx(Q,{icon:q$e,size:14,strokeWidth:2,className:A?"text-muted-foreground":"text-muted-foreground/30"})})]},w.serviceName)})}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:r("apps.general.noServicesConfigured")}),c.jsxs(we,{variant:"outline",size:"sm",onClick:()=>o.mutate(e.id),disabled:o.isPending,className:"shrink-0",children:[o.isPending?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):c.jsx(Q,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),"Sync"]})]})]})}function oQt({app:e}){const{t}=Ot("common"),n=oq(),r=y=>Object.entries(y??{}).map(([v,_])=>`${v}=${_}`).join(`
321
+ `).filter(Boolean).pop()||lt;it.error(Ie,{action:{label:"Resolve with Claude",onClick:()=>Ze(`Create a PR for this task. Error: "${lt}". After creating, link it using: fulcrum current-task pr <url>. Worktree: ${s.worktreePath}.`)}})}},st=()=>{if(!s?.worktreePath)return;const We=lq(s.worktreePath,_,w,E);jl(We)},mt=We=>{s&&o.mutate({taskId:s.id,updates:{status:We}})};return a?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx("p",{className:"text-muted-foreground",children:"Loading task..."})}):s?je?c.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[c.jsxs("div",{className:"film-grain relative shrink-0 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex flex-col gap-1 sm:hidden",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[J?c.jsx("input",{ref:ce,type:"text",value:ee,onChange:We=>oe(We.target.value),onKeyDown:ht,onBlur:se,className:"min-w-0 flex-1 truncate text-sm font-medium bg-transparent border-b border-primary outline-none",style:{minWidth:ae?`${ae}px`:void 0}}):c.jsx("h1",{ref:pe,className:"min-w-0 flex-1 truncate text-sm font-medium cursor-pointer hover:text-primary transition-colors",onClick:Me,title:"Click to edit title",children:s.title}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${v0e[s.status]}`}),children:c.jsxs("span",{className:"flex items-center gap-1",children:[o.isPending&&o.variables?.updates?.status&&c.jsx(Q,{icon:At,size:12,className:"animate-spin"}),TN[s.status]]})}),c.jsx(fd,{align:"end",children:c.jsx(wR,{value:s.status,onValueChange:mt,children:Object.entries(TN).map(([We,lt])=>c.jsx(ER,{value:We,children:lt},We))})})]}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),children:c.jsx(Q,{icon:UN,size:16,strokeWidth:2})}),c.jsx(fd,{align:"end",children:!_e&&c.jsxs(c.Fragment,{children:[c.jsxs(ti,{onClick:ot,disabled:f.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:EE,size:14,strokeWidth:2}),"Pull from ",s.baseBranch]}),c.jsxs(ti,{onClick:Ge,disabled:h.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:wE,size:14,strokeWidth:2}),"Merge to ",s.baseBranch]}),c.jsxs(ti,{onClick:xt,disabled:m.isPending||!s.worktreePath,children:[c.jsx(Q,{icon:CE,size:14,strokeWidth:2}),"Push to origin"]}),c.jsxs(ti,{onClick:Ue,disabled:b.isPending||!s.repoPath,children:[c.jsx(Q,{icon:TE,size:14,strokeWidth:2}),"Sync parent"]}),c.jsxs(ti,{onClick:Qe,disabled:!Re,children:[c.jsx(Q,{icon:kE,size:14,strokeWidth:2}),"Commit"]}),!s.prUrl&&c.jsxs(ti,{onClick:ft,disabled:y.isPending,children:[c.jsx(Q,{icon:hd,size:14,strokeWidth:2,className:y.isPending?"animate-pulse":""}),"Create PR"]})]})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>P(!0),children:c.jsx(Q,{icon:Ps,size:16,strokeWidth:2})})]}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:kt,title:"New task terminal",children:c.jsx(Q,{icon:sse,size:14,strokeWidth:2})}),!_e&&c.jsxs(c.Fragment,{children:[R?c.jsxs(Ur,{to:"/repositories/$repoId",params:{repoId:R.id},className:"flex items-center gap-1 hover:text-primary",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),c.jsx("span",{className:"hover:underline",children:s.repoName})]}):c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),s.repoName]}),s.baseBranch&&c.jsxs("span",{className:"text-muted-foreground/70 font-mono truncate",children:["from ",s.baseBranch]}),c.jsx("div",{className:"ml-auto",children:c.jsx(Qw,{worktreePath:s.worktreePath})})]})]})]}),c.jsxs("div",{className:"hidden items-center gap-3 sm:flex",children:[c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[J?c.jsx("input",{ref:ce,type:"text",value:ee,onChange:We=>oe(We.target.value),onKeyDown:ht,onBlur:se,className:"text-sm font-medium bg-transparent border-b border-primary outline-none",style:{minWidth:ae?`${ae}px`:200}}):c.jsx("h1",{ref:pe,className:"text-sm font-medium cursor-pointer hover:text-primary transition-colors",onClick:Me,title:"Click to edit title",children:s.title}),c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:kt,title:"New task terminal",children:c.jsx(Q,{icon:sse,size:14,strokeWidth:2})}),s.links&&s.links.length>0&&c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"Task links"}),children:c.jsx(Q,{icon:Dy,size:14,strokeWidth:2})}),c.jsx(fd,{align:"start",className:"w-auto",children:s.links.map(We=>c.jsxs(ti,{onClick:()=>jl(We.url),children:[c.jsx(Q,{icon:QZt(We.type),size:14,strokeWidth:2}),c.jsx("span",{children:We.label})]},We.id))})]})]}),!_e&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[R?c.jsxs(Ur,{to:"/repositories/$repoId",params:{repoId:R.id},className:"flex items-center gap-1 hover:text-primary",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),c.jsx("span",{className:"hover:underline",children:s.repoName})]}):c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Q,{icon:af,size:12,strokeWidth:2}),s.repoName]}),c.jsx(Q,{icon:Z3,size:12,strokeWidth:2}),c.jsx("span",{className:"font-mono",children:s.branch}),s.baseBranch&&c.jsxs("span",{className:"text-muted-foreground/70 font-mono",children:["from ",s.baseBranch]}),s.prUrl&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/50",children:"•"}),c.jsxs("a",{href:s.prUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-foreground hover:text-primary font-medium",onClick:We=>We.stopPropagation(),children:[c.jsx(Q,{icon:hd,size:14,strokeWidth:2}),c.jsxs("span",{children:["#",s.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]})]})]})]})]}),c.jsxs(ud,{children:[c.jsx(dd,{render:c.jsx("button",{type:"button",className:`rounded-full px-2 py-0.5 text-xs font-medium ${v0e[s.status]}`}),children:c.jsxs("span",{className:"flex items-center gap-1",children:[o.isPending&&o.variables?.updates?.status&&c.jsx(Q,{icon:At,size:12,className:"animate-spin"}),TN[s.status]]})}),c.jsx(fd,{align:"end",children:c.jsx(wR,{value:s.status,onValueChange:mt,children:Object.entries(TN).map(([We,lt])=>c.jsx(ER,{value:We,children:lt},We))})})]}),c.jsxs("div",{className:"flex items-center gap-0",children:[!_e&&c.jsxs(c.Fragment,{children:[c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:ot,disabled:f.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Pull from ${s.baseBranch}`,children:c.jsx(Q,{icon:EE,size:16,strokeWidth:2,className:f.isPending?"animate-spin":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Ge,disabled:h.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:`Merge to ${s.baseBranch}`,children:c.jsx(Q,{icon:wE,size:16,strokeWidth:2,className:h.isPending?"animate-pulse":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:xt,disabled:m.isPending||!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Push to origin",children:c.jsx(Q,{icon:CE,size:16,strokeWidth:2,className:m.isPending?"animate-pulse":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Ue,disabled:b.isPending||!s.repoPath,className:"text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:c.jsx(Q,{icon:TE,size:16,strokeWidth:2,className:b.isPending?"animate-spin":""})}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Qe,disabled:!Re,className:"text-muted-foreground hover:text-foreground",title:"Commit",children:c.jsx(Q,{icon:kE,size:16,strokeWidth:2})}),!s.prUrl&&c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:ft,disabled:y.isPending,className:"text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:c.jsx(Q,{icon:hd,size:16,strokeWidth:2,className:y.isPending?"animate-pulse":""})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",onClick:st,disabled:!s.worktreePath,className:"text-muted-foreground hover:text-foreground",title:"Open in editor",children:c.jsx(Q,{icon:$_e,size:16,strokeWidth:2})})]}),c.jsx(we,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>P(!0),children:c.jsx(Q,{icon:Ps,size:16,strokeWidth:2})})]})]}),z?c.jsxs(il,{value:U,onValueChange:We=>W(We),className:"flex min-h-0 flex-1 flex-col",children:[c.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:c.jsxs(sl,{className:"w-full",children:[c.jsx(Dn,{value:"terminal",className:"flex-1",children:"Terminal"}),c.jsx(Dn,{value:"details",className:"flex-1",children:"Details"})]})}),c.jsx(Mn,{value:"terminal",className:"flex-1 min-h-0",children:c.jsx(l0e,{taskName:s.title,cwd:s.worktreePath,taskId:s.id,agent:s.agent,aiMode:j,description:B,startupScript:_e?S??void 0:s.startupScript,agentOptions:s.agentOptions,opencodeModel:I,serverPort:T,autoFocus:L},G)}),c.jsx(Mn,{value:"details",className:"flex-1 min-h-0 bg-background",children:c.jsxs(il,{value:he,onValueChange:Te,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex items-center justify-between shrink-0 border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs(sl,{variant:"line",children:[!_e&&c.jsxs(Dn,{value:"diff",children:[c.jsx(Q,{icon:c$,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),c.jsxs(Dn,{value:"browser",children:[c.jsx(Q,{icon:UO,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),c.jsxs(Dn,{value:"files",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]}),c.jsxs(Dn,{value:"details",children:[c.jsx(Q,{icon:UN,size:14,strokeWidth:2,"data-slot":"icon"}),"Details"]})]}),!_e&&c.jsx(Qw,{worktreePath:s.worktreePath})]}),!_e&&c.jsx(Mn,{value:"diff",className:"flex-1 overflow-hidden",children:c.jsx(c0e,{taskId:s.id,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0})}),c.jsx(Mn,{value:"browser",className:"flex-1 overflow-hidden",children:c.jsx(u0e,{taskId:s.id})}),c.jsx(Mn,{value:"files",className:"flex-1 overflow-hidden",children:c.jsx(i3,{worktreePath:s.worktreePath,initialSelectedFile:ve,onFileChange:ye})}),c.jsx(Mn,{value:"details",className:"flex-1 overflow-hidden",children:c.jsx(y0e,{task:s})})]})})]}):c.jsxs(gb,{direction:"horizontal",className:"min-h-0 flex-1",children:[c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsx(l0e,{taskName:s.title,cwd:s.worktreePath,taskId:s.id,agent:s.agent,aiMode:j,description:B,startupScript:_e?S??void 0:s.startupScript,agentOptions:s.agentOptions,opencodeModel:I,serverPort:T,autoFocus:L},G)}),c.jsx(bb,{withHandle:!0}),c.jsx(lu,{defaultSize:50,minSize:30,className:"bg-background",children:c.jsxs(il,{value:he,onValueChange:Te,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex items-center justify-between shrink-0 border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs(sl,{variant:"line",children:[!_e&&c.jsxs(Dn,{value:"diff",children:[c.jsx(Q,{icon:c$,size:14,strokeWidth:2,"data-slot":"icon"}),"Diff"]}),c.jsxs(Dn,{value:"browser",children:[c.jsx(Q,{icon:UO,size:14,strokeWidth:2,"data-slot":"icon"}),"Browser"]}),c.jsxs(Dn,{value:"files",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2,"data-slot":"icon"}),"Files"]}),c.jsxs(Dn,{value:"details",children:[c.jsx(Q,{icon:UN,size:14,strokeWidth:2,"data-slot":"icon"}),"Details"]})]}),!_e&&c.jsx(Qw,{worktreePath:s.worktreePath})]}),!_e&&c.jsx(Mn,{value:"diff",className:"flex-1 overflow-hidden",children:c.jsx(c0e,{taskId:s.id,worktreePath:s.worktreePath,baseBranch:s.baseBranch??void 0})}),c.jsx(Mn,{value:"browser",className:"flex-1 overflow-hidden",children:c.jsx(u0e,{taskId:s.id})}),c.jsx(Mn,{value:"files",className:"flex-1 overflow-hidden",children:c.jsx(i3,{worktreePath:s.worktreePath,initialSelectedFile:ve,onFileChange:ye})}),c.jsx(Mn,{value:"details",className:"flex-1 overflow-hidden",children:c.jsx(y0e,{task:s})})]})})]}),c.jsx(i2,{task:s,open:M,onOpenChange:P,onDeleted:()=>r({to:"/tasks"})})]}):c.jsx(ZZt,{task:s}):c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx("p",{className:"text-muted-foreground",children:"Task not found"}),c.jsx(Ur,{to:"/tasks",children:c.jsx(we,{variant:"outline",children:"Back to Tasks"})})]})}function eQt({repoPath:e,repoDisplayName:t,activeTab:n,file:r,onFileChange:i,onFileSaved:s}){const{t:a}=Ot("repositories"),o=h5(),[l,u]=x.useState("terminal"),[d,f]=x.useState(null),[h,m]=x.useState(!1),[b,y]=x.useState(!1),[v,_]=x.useState(!1),w=x.useRef(null),E=x.useRef(null),T=x.useRef(!1),k=x.useRef(!1),{terminals:S,terminalsLoaded:A,connected:R,createTerminal:I,recreateTerminal:D,attachXterm:j,resizeTerminal:B,setupImagePaste:F,writeToTerminal:L}=zJ(),P=(d?S.find(te=>te.id===d):null)?.status;x.useEffect(()=>{Xt.repoTerminal.info("WorkspacePanel mounted",{repoPath:e,activeTab:n})},[e,n]),x.useEffect(()=>{Xt.repoTerminal.debug("WorkspacePanel state changed",{terminalId:d,xtermReady:b,containerReady:v,connected:R,terminalsLoaded:A,terminalCount:S.length,repoPath:e})},[d,b,v,R,A,S.length,e]),x.useEffect(()=>{T.current=!1,k.current=!1,f(null),m(!1)},[e]),x.useEffect(()=>{if(!R||!e||!A||n!=="workspace"){Xt.repoTerminal.debug("find/create: waiting",{connected:R,repoPath:e,terminalsLoaded:A,activeTab:n});return}const te=S.find(ee=>ee.cwd===e&&ee.status==="running");if(te){Xt.repoTerminal.info("found existing terminal",{id:te.id,cwd:te.cwd}),f(te.id);return}T.current||(T.current=!0,m(!0),Xt.repoTerminal.info("creating terminal",{name:t,cwd:e,cols:80,rows:24}),I({name:t,cols:80,rows:24,cwd:e}))},[R,e,t,A,S,n,I]),x.useEffect(()=>{if(!e)return;const te=S.find(oe=>oe.cwd===e&&oe.status==="running");if(!te)return;const ee=d&&S.some(oe=>oe.id===d);(!d||!ee)&&(f(te.id),m(!1),d&&!ee&&(k.current=!1))},[S,e,d]);const U=x.useCallback(te=>{Xt.repoTerminal.info("xterm ready"),w.current=te,y(!0)},[]),W=x.useCallback((te,ee)=>{d&&B(d,te,ee)},[d,B]),G=x.useCallback(te=>{Xt.repoTerminal.info("container ready"),E.current=te,_(!0)},[]),q=x.useCallback(te=>{d&&L(d,te)},[d,L]),Y=x.useCallback(()=>{d&&(k.current=!1,T.current=!1,f(null),D(d))},[d,D]);x.useEffect(()=>{if(!d||!b||!v){Xt.repoTerminal.debug("attach effect: waiting",{terminalId:d,xtermReady:b,containerReady:v});return}if(!w.current||!E.current){Xt.repoTerminal.warn("attach effect: refs not set despite ready states",{terminalId:d});return}if(k.current){Xt.repoTerminal.debug("attach effect: already attached",{terminalId:d});return}return Xt.repoTerminal.info("attaching terminal",{terminalId:d}),j(d,w.current),F(E.current,d),k.current=!0,()=>{Xt.repoTerminal.debug("detaching terminal",{terminalId:d}),k.current=!1}},[d,b,v,j,F]);const X=()=>!h||d?null:c.jsx("div",{className:"flex-1 flex items-center justify-center bg-terminal-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(Q,{icon:At,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"}),c.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:a("detailView.workspace.initializingTerminal")})]})}),z=()=>R?null:c.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:a("detailView.workspace.connectingToTerminal")}),J=()=>!d||!P||P==="running"?null:c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/95",children:c.jsxs("div",{className:"flex flex-col items-center gap-4",children:[c.jsx("span",{className:"text-sm text-destructive",children:a("detailView.workspace.terminalConnectionFailed")}),c.jsx(we,{onClick:Y,variant:"outline",children:a("detailView.workspace.recreateTerminal")})]})});return o?c.jsxs(il,{value:l,onValueChange:te=>u(te),className:"flex min-h-0 flex-1 flex-col h-full",children:[c.jsx("div",{className:"shrink-0 border-b border-border px-2 py-1",children:c.jsxs(sl,{className:"w-full",children:[c.jsx(Dn,{value:"terminal",className:"flex-1",children:a("detailView.mobileWorkspace.terminal")}),c.jsx(Dn,{value:"files",className:"flex-1",children:a("detailView.mobileWorkspace.files")})]})}),c.jsx(Mn,{value:"terminal",className:"flex-1 min-h-0",children:c.jsxs("div",{className:"relative h-full flex flex-col",children:[z(),X(),J(),c.jsx(zU,{className:"flex-1",onReady:U,onResize:W,onContainerReady:G,terminalId:d??void 0,setupImagePaste:F,onSend:q})]})}),c.jsx(Mn,{value:"files",className:"flex-1 min-h-0",children:c.jsx(i3,{worktreePath:e,initialSelectedFile:r,onFileChange:i,onFileSaved:s})})]}):c.jsxs(gb,{direction:"horizontal",className:"h-full",children:[c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsxs("div",{className:"relative h-full flex flex-col",children:[z(),X(),J(),c.jsx(zU,{className:"flex-1",onReady:U,onResize:W,onContainerReady:G,terminalId:d??void 0,setupImagePaste:F,onSend:q})]})}),c.jsx(bb,{withHandle:!0}),c.jsx(lu,{defaultSize:50,minSize:30,children:c.jsx(i3,{worktreePath:e,initialSelectedFile:r,onFileChange:i,onFileSaved:s})})]})}function x0e({step:e,currentStep:t,label:n,status:r}){const i=["docker","traefik","complete"],s=i.indexOf(e),a=i.indexOf(t),o=e===t,l=s<a||r==="complete";return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:Oe("flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium",l&&"bg-green-500 text-white",o&&"bg-primary text-primary-foreground",!l&&!o&&"bg-muted text-muted-foreground",r==="error"&&"bg-destructive text-destructive-foreground"),children:l?c.jsx(Q,{icon:ur,size:14,strokeWidth:2}):r==="error"?c.jsx(Q,{icon:Tn,size:14,strokeWidth:2}):s+1}),c.jsx("span",{className:Oe("text-sm",o&&"font-medium",!l&&!o&&"text-muted-foreground"),children:n})]})}function tQt({onComplete:e}){const{data:t,isLoading:n,refetch:r}=$2e(),i=uJe(),[s,a]=x.useState("docker"),o=()=>!t||!t.docker.installed||!t.docker.running?"docker":!t.traefik.detected&&t.traefik.type==="none"?"traefik":"complete",l=["docker","traefik","complete"],u=n?l.indexOf(s):Math.max(l.indexOf(s),l.indexOf(o())),d=l[Math.min(u,l.length-1)],f=async()=>{await i.mutateAsync(),await r()},h=()=>{e?.()};return n?c.jsx(_i,{className:"mx-auto max-w-2xl",children:c.jsx(js,{className:"flex items-center justify-center py-12",children:c.jsx(Q,{icon:At,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})})}):c.jsxs(_i,{className:"mx-auto max-w-2xl",children:[c.jsxs(r_,{children:[c.jsx(i_,{children:"Deployment Setup"}),c.jsx($_t,{children:"Configure your server for deploying containerized applications"})]}),c.jsxs(js,{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(x0e,{step:"docker",currentStep:d,label:"Docker",status:t?.docker.running?"complete":d==="docker"?"current":"pending"}),c.jsx("div",{className:"h-px flex-1 mx-2 bg-border"}),c.jsx(x0e,{step:"traefik",currentStep:d,label:"Traefik",status:t?.traefik.detected?"complete":d==="traefik"?"current":"pending"})]}),d==="docker"&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:t?.docker.installed?t?.docker.running?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Docker is running"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Version ",t.docker.version]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-amber-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"Docker is not running"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Docker is installed (v",t.docker.version,") but the daemon is not running."]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Start Docker and click refresh."})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-destructive"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"Docker is not installed"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Docker is required to deploy containerized applications."}),c.jsx("a",{href:"https://docs.docker.com/get-docker/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline",children:"Install Docker →"})]})]})}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsxs(we,{variant:"outline",onClick:()=>r(),children:[c.jsx(Q,{icon:lp,size:16,strokeWidth:2,"data-slot":"icon"}),"Refresh"]}),t?.docker.running&&c.jsxs(we,{onClick:()=>a("traefik"),children:["Continue",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})]})]}),d==="traefik"&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:t?.traefik.detected?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:t.traefik.type==="dokploy"?"Dokploy Traefik detected":t.traefik.type==="fulcrum"?"Fulcrum Traefik running":"Traefik detected"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Reverse proxy is ready to route traffic to your apps."}),t.traefik.containerName&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Container: ",t.traefik.containerName]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:Cr,size:20,strokeWidth:2,className:"mt-0.5 text-amber-500"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium",children:"No Traefik detected"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Traefik handles HTTPS certificates and routes traffic to your apps."}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Fulcrum can start its own Traefik container for you."})]})]})}),c.jsxs("div",{className:"flex justify-end gap-2",children:[!t?.traefik.detected&&c.jsxs(we,{onClick:f,disabled:i.isPending,children:[i.isPending?c.jsx(Q,{icon:At,size:16,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):null,"Start Traefik"]}),t?.traefik.detected&&c.jsxs(we,{onClick:()=>a("complete"),children:["Continue",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})]}),i.isError&&c.jsxs("p",{className:"text-sm text-destructive",children:["Failed to start Traefik: ",i.error?.message||"Unknown error"]})]}),d==="complete"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-green-500/30 bg-green-500/10 p-4",children:[c.jsx(Q,{icon:ur,size:20,strokeWidth:2,className:"mt-0.5 text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-green-600 dark:text-green-400",children:"Setup Complete"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Your server is ready to deploy containerized applications."})]})]}),c.jsx("div",{className:"flex justify-end",children:c.jsxs(we,{onClick:h,children:["Create Your First App",c.jsx(Q,{icon:Bl,size:16,strokeWidth:2,"data-slot":"icon"})]})})]})]})]})}function s3({value:e,onChange:t}){const{t:n}=Ot("repositories"),[r,i]=x.useState(()=>{const d=Object.entries(e);return d.length===0?[]:d.map(([f,h])=>({id:crypto.randomUUID(),key:f,value:h}))}),s=x.useRef(null);x.useEffect(()=>{const d=Object.entries(e);if(d.length===0&&r.length===0)return;const f=a(r);JSON.stringify(f)!==JSON.stringify(e)&&i(d.map(([h,m])=>({id:crypto.randomUUID(),key:h,value:m})))},[e]);const a=d=>{const f={};for(const h of d){const m=h.key.trim();m&&(f[m]=h.value)}return f},o=(d,f,h)=>{const m=r.map(b=>b.id===d?{...b,[f]:h}:b);i(m),t(a(m))},l=()=>{const d={id:crypto.randomUUID(),key:"",value:""};i([...r,d]),setTimeout(()=>{s.current?.focus()},0)},u=d=>{const f=r.filter(h=>h.id!==d);i(f),t(a(f))};return c.jsxs("div",{className:"space-y-2",children:[r.length>0&&c.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"bg-muted/50",children:[c.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-[40%]",children:n("detailView.settings.agentOptionsFlag")}),c.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:n("detailView.settings.agentOptionsValue")}),c.jsx("th",{className:"w-10"})]})}),c.jsx("tbody",{children:r.map((d,f)=>c.jsxs("tr",{className:"border-t border-border",children:[c.jsx("td",{className:"px-2 py-1",children:c.jsx(Tt,{ref:f===r.length-1?s:void 0,value:d.key,onChange:h=>o(d.id,"key",h.target.value),placeholder:"model",className:"h-8 font-mono text-xs"})}),c.jsx("td",{className:"px-2 py-1",children:c.jsx(Tt,{value:d.value,onChange:h=>o(d.id,"value",h.target.value),placeholder:"haiku",className:"h-8 font-mono text-xs"})}),c.jsx("td",{className:"px-2 py-1",children:c.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>u(d.id),children:c.jsx(Q,{icon:Ps,size:14,strokeWidth:2})})})]},d.id))})]})}),c.jsxs(we,{variant:"outline",size:"sm",onClick:l,className:"w-full",children:[c.jsx(Q,{icon:Dc,size:14,strokeWidth:2,"data-slot":"icon"}),n("detailView.settings.addAgentOption")]})]})}function nQt(e){const t=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return t?`https://${t[1]}/${t[2]}`:e.replace(/\.git$/,"")}function rQt(e){return Qt({queryKey:["git-remote",e],queryFn:async()=>{if(!e)return null;const t=await fetch(`/api/git/remote?path=${encodeURIComponent(e)}`);return t.ok?(await t.json()).remoteUrl:null},enabled:!!e,staleTime:60*1e3})}function iQt({repository:e}){const{t}=Ot("repositories"),n=Ot("projects").t,r=lqe(),{data:i}=rQt(e.path),[s,a]=x.useState(""),[o,l]=x.useState(""),[u,d]=x.useState(""),[f,h]=x.useState({}),[m,b]=x.useState({}),[y,v]=x.useState(null),[_,w]=x.useState(null),[E,T]=x.useState(!1),[k,S]=x.useState(!1);x.useEffect(()=>{e&&(a(e.displayName),l(e.startupScript||""),d(e.copyFiles||""),h(e.claudeOptions||{}),b(e.opencodeOptions||{}),v(e.opencodeModel??null),w(e.defaultAgent??null),T(e.isCopierTemplate??!1),S(!1))},[e]),x.useEffect(()=>{if(e){const R=s!==e.displayName||o!==(e.startupScript||"")||u!==(e.copyFiles||"")||JSON.stringify(f)!==JSON.stringify(e.claudeOptions||{})||JSON.stringify(m)!==JSON.stringify(e.opencodeOptions||{})||y!==(e.opencodeModel??null)||_!==(e.defaultAgent??null)||E!==(e.isCopierTemplate??!1);S(R)}},[s,o,u,f,m,y,_,E,e]);const A=()=>{e&&r.mutate({id:e.id,updates:{displayName:s.trim()||e.path.split("/").pop()||"repo",startupScript:o.trim()||null,copyFiles:u.trim()||null,claudeOptions:Object.keys(f).length>0?f:null,opencodeOptions:Object.keys(m).length>0?m:null,opencodeModel:y,defaultAgent:_,isCopierTemplate:E}},{onSuccess:()=>{it.success(t("detailView.saved")),S(!1)},onError:R=>{it.error(t("detailView.failedToSave"),{description:R instanceof Error?R.message:"Unknown error"})}})};return c.jsx(Lf,{className:"h-full",children:c.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[c.jsx(Q,{icon:Js,size:14,strokeWidth:2}),c.jsx("span",{className:"font-mono break-all",children:e.path}),i&&c.jsx("a",{href:nQt(i),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors",title:i,children:c.jsx(Q,{icon:i.includes("github.com")?R$e:Dy,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[c.jsxs("div",{className:"film-grain relative flex-1 rounded-lg p-6 border border-border",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-sm font-medium mb-4",children:n("detailView.general.repositoryTitle")}),c.jsxs(qh,{children:[c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"displayName",children:n("detailView.general.displayName")}),c.jsx(Tt,{id:"displayName",value:s,onChange:R=>a(R.target.value),placeholder:e.path.split("/").pop()||"My Project"})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"startupScript",children:n("detailView.general.startupScript")}),c.jsx(Rc,{id:"startupScript",value:o,onChange:R=>l(R.target.value),placeholder:t("detailView.settings.startupScriptPlaceholder"),rows:3}),c.jsx(Fi,{children:t("detailView.settings.startupScriptDescription")})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{htmlFor:"copyFiles",children:n("detailView.general.copyFiles")}),c.jsx(Tt,{id:"copyFiles",value:u,onChange:R=>d(R.target.value),placeholder:t("detailView.settings.copyFilesPlaceholder")}),c.jsx(Fi,{children:t("detailView.settings.copyFilesDescription")})]}),c.jsxs(Pn,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ai,{checked:E,onCheckedChange:R=>T(R===!0)}),c.jsx(Ln,{className:"cursor-pointer",children:t("detailView.settings.isCopierTemplate")})]}),c.jsx(Fi,{children:t("detailView.settings.isCopierTemplateDescription")})]})]})]}),c.jsxs("div",{className:"film-grain relative flex-1 rounded-lg p-6 border border-border",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-sm font-medium mb-4",children:n("detailView.general.agentTitle")}),c.jsxs(qh,{children:[c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.defaultAgent")}),c.jsxs(_r,{value:_??"inherit",onValueChange:R=>w(R==="inherit"?null:R),children:[c.jsx(wr,{className:"w-full",children:c.jsx(Sr,{})}),c.jsxs(Er,{alignItemWithTrigger:!1,children:[c.jsx(Nt,{value:"inherit",children:t("detailView.settings.defaultAgentInherit")}),Object.keys(Ga).map(R=>c.jsx(Nt,{value:R,children:Ga[R]},R))]})]}),c.jsx(Fi,{children:t("detailView.settings.defaultAgentDescription")})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.claudeOptions")}),c.jsx(Fi,{className:"mb-2",children:t("detailView.settings.claudeOptionsDescription")}),c.jsx(s3,{value:f,onChange:h})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.opencodeOptions")}),c.jsx(Fi,{className:"mb-2",children:t("detailView.settings.opencodeOptionsDescription")}),c.jsx(s3,{value:m,onChange:b})]}),c.jsxs(Pn,{children:[c.jsx(Ln,{children:n("detailView.general.opencodeModel")}),c.jsx(Wb,{value:y,onChange:v,placeholder:t("detailView.settings.opencodeModelPlaceholder")}),c.jsx(Fi,{children:t("detailView.settings.opencodeModelDescription")})]})]})]})]}),c.jsx("div",{className:"flex items-center justify-end mt-4",children:c.jsxs(we,{size:"sm",onClick:A,disabled:!k||r.isPending,children:[c.jsx(Q,{icon:ur,size:14,strokeWidth:2,"data-slot":"icon"}),r.isPending?t("detailView.saving"):t("detailView.save")]})})]})})}function sQt({app:e,onDeploy:t,onStop:n,onCancelDeploy:r,isBuilding:i,isRunning:s,isStopPending:a,isCancelPending:o,deployStore:l}){const{t:u}=Ot("projects"),d=Ot("common").t,f=oq(),h=async v=>{await f.mutateAsync({id:e.id,updates:{autoDeployEnabled:v}})},m=async v=>{await f.mutateAsync({id:e.id,updates:{autoPortAllocation:v}})},b=async v=>{await f.mutateAsync({id:e.id,updates:{noCacheBuild:v}})},y=async v=>{await f.mutateAsync({id:e.id,updates:{notificationsEnabled:v}})};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:u("detailView.tabs.deploy")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(we,{size:"sm",onClick:t,disabled:i,children:[i?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:cx,size:14,strokeWidth:2}),l.isDeploying?d("apps.deploying"):e.status==="building"?d("apps.building"):u("deploy")]}),i?c.jsxs(we,{variant:"destructive",size:"sm",onClick:r,disabled:o,children:[o?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:OE,size:14,strokeWidth:2}),d(o?"apps.cancelling":"apps.cancelDeploy")]}):c.jsxs(we,{variant:"destructive",size:"sm",onClick:n,disabled:a||!s,children:[a?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:OE,size:14,strokeWidth:2}),u("stop")]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.autoDeployEnabled??!1,onCheckedChange:v=>h(v===!0)}),c.jsx("span",{children:u("detailView.app.autoDeployEnabled")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.autoPortAllocation??!0,onCheckedChange:v=>m(v===!0)}),c.jsx("span",{children:u("detailView.app.autoPortAllocation")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.noCacheBuild??!1,onCheckedChange:v=>b(v===!0)}),c.jsx("span",{children:u("detailView.app.noCacheBuild")})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx(ai,{checked:e.notificationsEnabled??!0,onCheckedChange:v=>y(v===!0)}),c.jsx("span",{children:u("detailView.app.notificationsEnabled")})]})]})]})}function aQt({app:e,onDeploy:t}){const{t:n}=Ot("projects"),r=Ot("common").t,{data:i}=F2e(e.id),{data:s}=U2e(),a=oq(),o=B2e(),l=s?.tunnelsAvailable??!1,[u,d]=x.useState(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[]),[f,h]=x.useState(null);x.useEffect(()=>{f===null&&d(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[])},[e.services,f]);const m=w=>{if(i?.containers){const E=i.containers.find(T=>T.service===w);if(E)return E.status}return"stopped"},b=async()=>{await a.mutateAsync({id:e.id,updates:{services:u.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort??void 0,exposed:!!w.domain,domain:w.domain||void 0,exposureMethod:w.exposureMethod}))}}),h(null),it.warning(r("apps.deployToApply"),{description:r("apps.deployToApplyDesc"),action:{label:r("apps.deploy"),onClick:t}})},y=(w,E)=>{d(T=>T.map((k,S)=>S===w?{...k,...E}:k))},v=w=>{f===w?b():h(w)},_=()=>{d(e.services?.map(w=>({serviceName:w.serviceName,containerPort:w.containerPort,domain:w.domain??"",exposureMethod:w.exposureMethod??"dns"}))??[]),h(null)};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("detailView.app.services")}),u.length>0?c.jsx("div",{className:"space-y-2",children:u.map((w,E)=>{const T=m(w.serviceName),k=T==="running",S=f===E,A=!!w.containerPort,R=!!w.domain;return c.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[c.jsx("div",{className:`h-2 w-2 shrink-0 rounded-full ${k?"bg-green-500":"bg-gray-400"}`,title:T}),c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[c.jsx("span",{className:"font-medium",children:w.serviceName}),w.containerPort&&c.jsxs(Jn,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[":",w.containerPort]})]}),c.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:S?c.jsxs(c.Fragment,{children:[c.jsx(Tt,{value:w.domain,onChange:I=>y(E,{domain:I.target.value}),placeholder:"app.example.com",className:"h-7 text-xs flex-1 min-w-0",autoFocus:!0,disabled:!A}),c.jsxs("select",{value:w.exposureMethod,onChange:I=>y(E,{exposureMethod:I.target.value}),className:"h-7 w-20 rounded-md border bg-background px-2 text-xs shrink-0",disabled:!A,children:[c.jsx("option",{value:"dns",children:"DNS"}),c.jsx("option",{value:"tunnel",disabled:!l,children:"Tunnel"})]})]}):R?c.jsxs(c.Fragment,{children:[c.jsx("a",{href:`https://${w.domain}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate",children:w.domain}),c.jsx(Jn,{variant:w.exposureMethod==="tunnel"?"default":"outline",className:"text-xs px-1.5 py-0 shrink-0",children:w.exposureMethod==="tunnel"?"Tunnel":"DNS"})]}):c.jsx("span",{className:"text-muted-foreground/50 text-xs",children:r(A?"apps.domains.noDomain":"apps.domains.portRequired")})}),S?c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(E),disabled:a.isPending,children:a.isPending?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Q,{icon:ol,size:14,strokeWidth:2,className:"text-green-500"})}),c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:c.jsx(Q,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"})})]}):c.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>v(E),disabled:!A,children:c.jsx(Q,{icon:q$e,size:14,strokeWidth:2,className:A?"text-muted-foreground":"text-muted-foreground/30"})})]},w.serviceName)})}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:r("apps.general.noServicesConfigured")}),c.jsxs(we,{variant:"outline",size:"sm",onClick:()=>o.mutate(e.id),disabled:o.isPending,className:"shrink-0",children:[o.isPending?c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin","data-slot":"icon"}):c.jsx(Q,{icon:lp,size:14,strokeWidth:2,"data-slot":"icon"}),"Sync"]})]})]})}function oQt({app:e}){const{t}=Ot("common"),n=oq(),r=y=>Object.entries(y??{}).map(([v,_])=>`${v}=${_}`).join(`
322
322
  `),[i,s]=x.useState(()=>r(e.environmentVariables)),[a,o]=x.useState(()=>r(e.environmentVariables)),[l,u]=x.useState(!1),[d,f]=x.useState(!0),h=i!==a,m=x.useMemo(()=>i.split(`
323
323
  `).map((y,v)=>{const _=y.trim();if(!_)return{type:"empty",id:v};if(_.startsWith("#"))return{type:"comment",text:y,id:v};const w=_.indexOf("=");if(w>0){const E=_.slice(0,w).length,T=_.slice(w+1).length;return{type:"env",keyLen:E,valueLen:T,id:v}}return{type:"other",text:y,id:v}}),[i]),b=async()=>{const y={};i.split(`
324
324
  `).forEach(v=>{const _=v.trim();if(!_||_.startsWith("#"))return;const w=_.indexOf("=");if(w>0){const E=_.slice(0,w).trim(),T=_.slice(w+1).trim();E&&(y[E]=T)}}),await n.mutateAsync({id:e.id,updates:{environmentVariables:y}}),o(i),u(!0),setTimeout(()=>u(!1),2e3)};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:t("apps.environment.title")}),h&&c.jsxs("span",{className:"text-xs text-amber-500",children:["(",t("apps.environment.unsavedChanges"),")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(ad,{children:[c.jsx(od,{className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",onClick:()=>f(!d),children:c.jsx(Q,{icon:d?B_e:xC,size:14,strokeWidth:2})}),c.jsx(ld,{children:t(d?"apps.environment.showValues":"apps.environment.hideValues")})]}),h&&c.jsx(we,{variant:"outline",size:"sm",onClick:()=>{s(a),u(!1)},children:t("apps.cancel")}),c.jsx(we,{size:"sm",onClick:b,disabled:n.isPending||!h,children:n.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}),t("status.saving")]}):l?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ol,size:14,strokeWidth:2,className:"text-green-500"}),t("status.saved")]}):t("apps.environment.save")})]})]}),d?c.jsx("div",{className:"font-mono text-sm min-h-[120px] rounded-md border bg-background px-3 py-2 cursor-pointer",onClick:()=>f(!1),children:m.length===0||m.length===1&&m[0].type==="empty"?c.jsx("span",{className:"text-muted-foreground",children:t("apps.environment.placeholder")}):m.map(y=>c.jsx("div",{className:"leading-6",children:y.type==="empty"?c.jsx("span",{children:" "}):y.type==="comment"||y.type==="other"?c.jsx("span",{className:"text-muted-foreground",children:y.text}):c.jsxs(c.Fragment,{children:[c.jsx("span",{style:{color:"var(--chart-1)"},children:"•".repeat(y.keyLen)}),c.jsx("span",{style:{color:"var(--chart-3)"},children:"•"}),c.jsx("span",{style:{color:"var(--chart-2)"},children:"•".repeat(y.valueLen)})]})},y.id))}):c.jsx(Rc,{value:i,onChange:y=>s(y.target.value),placeholder:t("apps.environment.placeholder"),className:"font-mono text-sm min-h-[120px]"})]})}function lQt({app:e,repoPath:t}){const{t:n}=Ot("common"),{data:r,isLoading:i,error:s}=oJe(t,e.composeFile),a=lJe(),o=B2e(),l=fJe(e.id),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,b]=x.useState(!1),[y,v]=x.useState(!1);x.useEffect(()=>{r?.content!==void 0&&(d(r.content),h(r.content))},[r?.content]);const _=u!==f,w=x.useCallback(T=>{d(T),b(!1)},[]),E=x.useCallback(()=>{!t||!e.composeFile||a.mutate({repoPath:t,composeFile:e.composeFile,content:u},{onSuccess:()=>{h(u),b(!0),setTimeout(()=>b(!1),2e3),o.mutate(e.id)}})},[t,e.composeFile,e.id,u,a,o]);return i?c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:n("apps.compose.title")}),c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(Q,{icon:At,size:16,strokeWidth:2,className:"animate-spin"}),c.jsx("span",{className:"text-sm",children:n("status.loading")})]})]}):s?c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:n("apps.compose.title")}),c.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[c.jsx(Q,{icon:Cr,size:16,strokeWidth:2}),c.jsx("span",{className:"text-sm",children:s.message})]})]}):c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("apps.compose.title")}),_&&c.jsxs("span",{className:"text-xs text-amber-500",children:["(",n("apps.compose.unsavedChanges"),")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-muted-foreground",children:e.composeFile}),_&&c.jsx(we,{variant:"outline",size:"sm",onClick:()=>{d(f),b(!1)},children:n("apps.cancel")}),c.jsx(we,{size:"sm",onClick:E,disabled:a.isPending||!_,children:a.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:At,size:14,strokeWidth:2,className:"animate-spin"}),n("status.saving")]}):m?c.jsxs(c.Fragment,{children:[c.jsx(Q,{icon:ol,size:14,strokeWidth:2,className:"text-green-500"}),n("status.saved")]}):n("apps.compose.save")})]})]}),c.jsx("div",{className:"h-[400px] rounded-md border overflow-hidden",children:c.jsx(ZH,{filePath:e.composeFile,content:u,onChange:w})}),c.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:n("apps.compose.previewDescription")}),c.jsxs(we,{variant:"outline",size:"sm",onClick:()=>{l.refetch(),v(!0)},children:[c.jsx(Q,{icon:xC,size:14,strokeWidth:2}),n("apps.compose.preview")]})]}),c.jsx(Ya,{open:y,onOpenChange:v,children:c.jsxs(Xa,{className:"max-w-4xl max-h-[80vh]",children:[c.jsxs(Mo,{children:[c.jsx(Fo,{children:n("apps.compose.generatedTitle")}),c.jsx(ug,{children:n("apps.compose.generatedDescription")})]}),c.jsx("div",{className:"h-[500px] rounded-md border overflow-hidden",children:l.error?c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:c.jsxs("div",{className:"text-center space-y-2",children:[c.jsx(Q,{icon:Cr,size:24,strokeWidth:2,className:"mx-auto text-destructive"}),c.jsx("p",{className:"text-sm",children:l.error.message})]})}):l.data?.content?c.jsx(ZH,{filePath:"swarm-compose.yml",content:l.data.content,onChange:()=>{},readOnly:!0}):c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:c.jsx(Q,{icon:At,size:24,strokeWidth:2,className:"animate-spin"})})})]})})]})}const cQt=/error|exception|failed|uncaught|fatal|crash|errno|reject/i,uQt=/warning|deprecated|caution|unstable|⚠️/i,dQt=/successfully|completed|listening|connected|ready|started|✓|✅|done|healthy|pulled|created|recreated/i,fQt=/debug|version|config|import|GET|POST|PUT|DELETE/i;function hQt(e){return cQt.test(e)?"error":uQt.test(e)?"warning":dQt.test(e)?"success":fQt.test(e)?"debug":"info"}function WJ(e){return e.split(`
package/dist/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
11
11
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
12
  <title>Fulcrum</title>
13
- <script type="module" crossorigin src="/assets/index-RQJK4ee3.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-C_9lnrWl.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/assets/index-CirKr2eQ.css">
15
15
  </head>
16
16
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowsuchagency/fulcrum",
3
- "version": "4.4.2",
3
+ "version": "4.4.4",
4
4
  "description": "Harness Attention. Orchestrate Agents. Ship.",
5
5
  "license": "PolyForm-Perimeter-1.0.0",
6
6
  "repository": {
package/server/index.js CHANGED
@@ -1160303,6 +1160303,18 @@ async function generateSwarmComposeFile(cwd, composeFile, projectName, externalN
1160303
1160303
  networks[externalNetwork] = { external: true };
1160304
1160304
  parsed.networks = networks;
1160305
1160305
  }
1160306
+ for (const serviceConfig of Object.values(services)) {
1160307
+ const svcNetworks = serviceConfig.networks;
1160308
+ const usesDefault = Array.isArray(svcNetworks) ? svcNetworks.includes("default") : typeof svcNetworks === "object" && svcNetworks && ("default" in svcNetworks);
1160309
+ if (usesDefault) {
1160310
+ const networks = parsed.networks || {};
1160311
+ if (!networks["default"]) {
1160312
+ networks["default"] = {};
1160313
+ parsed.networks = networks;
1160314
+ }
1160315
+ break;
1160316
+ }
1160317
+ }
1160306
1160318
  const swarmContent = $stringify(parsed);
1160307
1160319
  await writeFile4(swarmPath, swarmContent, "utf-8");
1160308
1160320
  if (modified.length > 0 || externalNetwork) {
@@ -1259714,7 +1259726,7 @@ mcpRoutes.all("/", async (c) => {
1259714
1259726
  });
1259715
1259727
  const server2 = new McpServer({
1259716
1259728
  name: "fulcrum",
1259717
- version: "4.4.2"
1259729
+ version: "4.4.4"
1259718
1259730
  });
1259719
1259731
  const client3 = new FulcrumClient(`http://localhost:${port}`);
1259720
1259732
  registerTools(server2, client3);