copilot-operator 0.1.97 → 0.1.99
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/dist/src/api/folderPicker.js +22 -22
- package/dist/src/api/operator.controller.js +21 -9
- package/dist/src/api/operator.service.js +233 -39
- package/dist/src/config/exportHome.js +51 -9
- package/dist/src/config/home.js +27 -11
- package/dist/src/exec/authorizer.js +11 -4
- package/dist/src/exec/commandHeads.js +25 -0
- package/dist/src/exec/confinement.js +50 -4
- package/dist/src/exec/network.js +11 -1
- package/dist/src/exec/npmScripts.js +33 -0
- package/dist/src/exec/policy.js +70 -6
- package/dist/src/exec/processes.js +24 -5
- package/dist/src/exec/programs.js +21 -0
- package/dist/src/exec/reportFile.js +2 -1
- package/dist/src/exec/runner.js +31 -9
- package/dist/src/exec/scriptFiles.js +133 -6
- package/dist/src/orchestrator/handoff.js +3 -3
- package/dist/src/orchestrator/kerriganRunner.js +14 -6
- package/dist/src/orchestrator/leadRunner.js +43 -23
- package/dist/src/orchestrator/review.js +66 -10
- package/dist/src/orchestrator/taskRunner.js +73 -14
- package/dist/src/plan/kerrigan.js +253 -253
- package/dist/src/plan/schema.js +3 -13
- package/dist/src/plan/systemGuide.js +2 -2
- package/dist/src/protocol/kerriganSchema.js +5 -1
- package/dist/src/protocol/replySchema.js +2 -2
- package/dist/src/queue/queue.js +86 -0
- package/dist/src/session/compose.js +14 -10
- package/dist/src/session/locatorFailures.js +27 -6
- package/dist/src/session/model.js +19 -0
- package/dist/src/session/workspace.js +20 -5
- package/dist/src/transport/copilotTransport.js +82 -62
- package/dist/src/util/zip.js +147 -44
- package/dist/src/vcs/newBranch.js +20 -3
- package/dist/src/vcs/referenceGuard.js +9 -4
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.a4fe6ae48f3d3ff9.js +1 -0
- package/dist/web/_next/static/chunks/1548.765d6eed5325bd01.js +1 -0
- package/dist/web/_next/static/chunks/2163.e8d6c85412d5d411.js +1 -0
- package/dist/web/_next/static/chunks/{8124-967df691ec1bfeeb.js → 6240-8ba644c53ffab87d.js} +1 -1
- package/dist/web/_next/static/chunks/714.f2dcd6b41b58d1a7.js +1 -0
- package/dist/web/_next/static/chunks/7220.652a8a339c1e7401.js +1 -0
- package/dist/web/_next/static/chunks/7921-9cf1ece94fc89bb3.js +1 -0
- package/dist/web/_next/static/chunks/{8584.3301b056c97be517.js → 8584.7c438425140f1d8d.js} +1 -1
- package/dist/web/_next/static/chunks/9067.8c4e6a64620a45d9.js +1 -0
- package/dist/web/_next/static/chunks/9747.43d25bdff8737d09.js +1 -0
- package/dist/web/_next/static/chunks/app/{layout-7943a4391ad2f88f.js → layout-97259931ed97e20d.js} +1 -1
- package/dist/web/_next/static/chunks/app/page-26e4ea30eb076e6b.js +1 -0
- package/dist/web/_next/static/chunks/app/queue/page-7228e045f8ea10c4.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-c915d61553e1025b.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-4d24f44eb9077fb7.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-710628d673fa4afb.js → webpack-31db88c3d5781520.js} +1 -1
- package/dist/web/_next/static/css/{523d11041085f836.css → 87999096d96266fd.css} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +26 -25
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +26 -25
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +26 -25
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +26 -25
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +26 -25
- package/package.json +3 -2
- package/prompts/kerrigan1.md +2 -1
- package/prompts/lead1.md +2 -1
- package/prompts/level1.md +6 -1
- package/prompts/review1.md +7 -4
- package/dist/web/_next/static/chunks/1077.4da389906036b1bb.js +0 -1
- package/dist/web/_next/static/chunks/1548.4aa3e42afe4542ab.js +0 -1
- package/dist/web/_next/static/chunks/2163.4c6ce20cf967756c.js +0 -1
- package/dist/web/_next/static/chunks/714.ffb1325246519f64.js +0 -1
- package/dist/web/_next/static/chunks/7220.f483b83c11525063.js +0 -1
- package/dist/web/_next/static/chunks/7921-946e538fe3f9630f.js +0 -1
- package/dist/web/_next/static/chunks/9067.03cdfb01ebf6a35d.js +0 -1
- package/dist/web/_next/static/chunks/9747.fe06238bc42bd23d.js +0 -1
- package/dist/web/_next/static/chunks/app/page-6ec948e0cf4b24f0.js +0 -1
- package/dist/web/_next/static/chunks/app/queue/page-9cfc8f78d536cfb6.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-9c2b961beb8b3dce.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-3466496814a70b62.js +0 -1
- /package/dist/web/_next/static/{D3ew46wEw5JXPsTVwZwFC → n8n-2FmbL8PhXulu4hTV5}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{D3ew46wEw5JXPsTVwZwFC → n8n-2FmbL8PhXulu4hTV5}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{11272:(e,t,a)=>{"use strict";a.d(t,{O:()=>l});var s=a(73365);function l(){return(0,s.jsxs)("svg",{className:"branch-ico",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,s.jsx)("path",{d:"M4.5 3.5v9M4.5 10c0-3 7-2.5 7-5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"4.5",cy:"3",r:"1.7",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"4.5",cy:"13",r:"1.7",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"11.5",cy:"4.2",r:"1.7",fill:"currentColor"})]})}},60405:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>ao});var s=a(73365),l=a(1521),n=a(18197),i=a.n(n),r=a(1702),c=a(15549);let o=new Map,d=new Set,u=e=>"cop.git.base:".concat(e);function h(e){return d.add(e),()=>{d.delete(e)}}function m(e){return[(0,l.useSyncExternalStore)(h,()=>(function(e){let t=o.get(e);if(void 0!==t)return t;let a="";try{var s;a=null!=(s=window.localStorage.getItem(u(e)))?s:""}catch(e){}return o.set(e,a),a})(e),()=>""),t=>(function(e,t){o.set(e,t);try{window.localStorage.setItem(u(e),t)}catch(e){}for(let e of d)e()})(e,t)]}var p=a(87527);let f="cop.drafts.v1",x="cop.tabs.v1",b=new Set,g=new Set,v=(e,t)=>"".concat(j(e),"\n").concat(t);function j(e){return e.trim().replace(/\//g,"\\").replace(/\\+$/,"").toLowerCase()}function w(e){let t={};for(let[a,s]of Object.entries(function(e){try{let t=window.localStorage.getItem(e),a=t?JSON.parse(t):null;return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}catch(e){return{}}}(e))){let e=j(a);t[e]=e in t&&s&&"object"==typeof s?{...t[e],...s}:s}return t}function k(e,t){try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return!1}}function y(e,t){var a;g.delete(v(e,t));let s=null==(a=w(f)[j(e)])?void 0:a[t];return s&&"string"==typeof s.text?s:null}function N(e,t){var a;b.delete(v(e,t));let s=w(f),l=j(e);(null==(a=s[l])?void 0:a[t])&&(delete s[l][t],0===Object.keys(s[l]).length&&delete s[l],k(f,s))}function S(){return b.size>0}var C=a(8205),F=a(16752);let M=[{id:"plain",name:"Plain text"},{id:"typescript",name:"TypeScript"},{id:"javascript",name:"JavaScript"},{id:"json",name:"JSON"},{id:"html",name:"HTML"},{id:"xml",name:"XML"},{id:"css",name:"CSS"},{id:"scss",name:"SCSS"},{id:"markdown",name:"Markdown"},{id:"powershell",name:"PowerShell"},{id:"batch",name:"Batch (cmd)"},{id:"shell",name:"Shell"},{id:"python",name:"Python"},{id:"csharp",name:"C#"},{id:"java",name:"Java"},{id:"kotlin",name:"Kotlin"},{id:"go",name:"Go"},{id:"rust",name:"Rust"},{id:"c",name:"C"},{id:"cpp",name:"C++"},{id:"swift",name:"Swift"},{id:"dart",name:"Dart"},{id:"php",name:"PHP"},{id:"ruby",name:"Ruby"},{id:"lua",name:"Lua"},{id:"sql",name:"SQL"},{id:"yaml",name:"YAML"},{id:"toml",name:"TOML"},{id:"ini",name:"INI / config"},{id:"dockerfile",name:"Dockerfile"},{id:"makefile",name:"Makefile"},{id:"vue",name:"Vue"}],O={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",json5:"json",webmanifest:"json",har:"json",css:"css",scss:"scss",sass:"scss",less:"scss",html:"html",htm:"html",xhtml:"html",svelte:"html",vue:"vue",xml:"xml",svg:"xml",xsd:"xml",xsl:"xml",csproj:"xml",props:"xml",targets:"xml",config:"xml",resx:"xml",plist:"xml",vbproj:"xml",fsproj:"xml",nuspec:"xml",md:"markdown",markdown:"markdown",mdx:"markdown",ps1:"powershell",psm1:"powershell",psd1:"powershell",bat:"batch",cmd:"batch",sh:"shell",bash:"shell",zsh:"shell",py:"python",pyw:"python",pyi:"python",cs:"csharp",csx:"csharp",java:"java",kt:"kotlin",kts:"kotlin",gradle:"kotlin",go:"go",rs:"rust",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",hh:"cpp",hxx:"cpp",swift:"swift",dart:"dart",php:"php",rb:"ruby",lua:"lua",sql:"sql",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",properties:"ini",env:"ini",editorconfig:"ini",gitconfig:"ini",npmrc:"ini",dockerfile:"dockerfile",mk:"makefile"},E={dockerfile:"dockerfile",containerfile:"dockerfile",makefile:"makefile",gnumakefile:"makefile",".gitignore":"shell",".gitattributes":"shell",".dockerignore":"shell",".npmignore":"shell",".prettierignore":"shell",".eslintignore":"shell",".env":"ini",".editorconfig":"ini",".npmrc":"ini",".gitconfig":"ini",".babelrc":"json",".prettierrc":"json",".eslintrc":"json","tsconfig.json":"json","package.json":"json",gemfile:"ruby",rakefile:"ruby",jenkinsfile:"java"};function L(e){var t;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("/").pop().toLowerCase();if(E[s])return E[s];if(s.startsWith(".env."))return"ini";if(s.startsWith("dockerfile."))return"dockerfile";let l=s.lastIndexOf(".");if(l>0&&O[s.slice(l+1)])return O[s.slice(l+1)];let n=null!=(t=a.slice(0,200).split(/\r?\n/)[0])?t:"",i=/^#!.*\b(python\d?|node|deno|bun|bash|sh|zsh|pwsh|powershell|ruby|php|lua)\b/.exec(n);if(i){let e=i[1];return e.startsWith("python")?"python":"node"===e||"deno"===e||"bun"===e?"javascript":"pwsh"===e||"powershell"===e?"powershell":"ruby"===e?"ruby":"php"===e?"php":"lua"===e?"lua":"shell"}let r=a.trimStart().slice(0,100);if(/^<\?xml\b/.test(r))return"xml";if(/^<!doctype html|^<html\b/i.test(r))return"html";if(/^[{[]/.test(r))try{return JSON.parse(a),"json"}catch(e){}return"plain"}let q=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),z=(e,t)=>'<span class="hl-'.concat(e,'">').concat(q(t),"</span>"),I=e=>new Set(e.split(/\s+/).filter(Boolean)),D=I("break case catch class const continue debugger default delete do else export extends finally for from function if import in instanceof let new of return super switch this throw try typeof var void while with yield async await static get set as satisfies"),W=new Set([...D,...I("interface type enum implements namespace module declare abstract private protected public readonly keyof infer is asserts override accessor unique")]),A=I("string number boolean bigint symbol object unknown any never void undefined Record Partial Required Readonly Pick Omit Promise Array Map Set Date Error RegExp"),R=I("true false null undefined NaN Infinity"),H={typescript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:W,types:A,literals:R,calls:!0,sigil:/^@[A-Za-z_]\w*/},javascript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:D,literals:R,calls:!0},csharp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false null"),keywords:I("abstract as base break case catch checked class const continue default delegate do else enum event explicit extern finally fixed for foreach goto if implicit in interface internal is lock namespace new operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw try typeof unchecked unsafe using virtual volatile while async await var record init required get set value where yield partial"),types:I("bool byte char decimal double float int long object sbyte short string uint ulong ushort void dynamic Task List Dictionary")},java:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false null"),keywords:I("abstract assert break case catch class const continue default do else enum extends final finally for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try volatile while var record sealed permits yield"),types:I("boolean byte char double float int long short void String Object List Map Integer"),sigil:/^@[A-Za-z_]\w*/},kotlin:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false null"),keywords:I("as break class continue do else for fun if in interface is object package return super this throw try typealias typeof val var when while by catch constructor delegate dynamic field file finally get import init param property receiver set setparam where actual abstract annotation companion const crossinline data enum expect external final infix inline inner internal lateinit noinline open operator out override private protected public reified sealed suspend tailrec vararg"),types:I("Int Long Short Byte Double Float Boolean Char String Unit Any Nothing List Map Set"),sigil:/^@[A-Za-z_]\w*/},go:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],calls:!0,literals:I("true false nil iota"),keywords:I("break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var"),types:I("bool byte complex64 complex128 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr any")},rust:{line:["//"],block:[["/*","*/"]],quotes:['"'],calls:!0,literals:I("true false None Some Ok Err"),keywords:I("as async await break const continue crate dyn else enum extern fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait type unsafe use where while"),types:I("bool char f32 f64 i8 i16 i32 i64 i128 isize str u8 u16 u32 u64 u128 usize String Vec Option Result Box"),sigil:/^#!?\[[^\]]*\]/},c:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false NULL"),keywords:I("auto break case const continue default do else enum extern for goto if inline register restrict return sizeof static struct switch typedef union volatile while"),types:I("char double float int long short signed unsigned void size_t bool"),sigil:/^#\s*\w+/},cpp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false nullptr NULL"),keywords:I("alignas alignof and asm auto break case catch class const constexpr const_cast continue decltype default delete do dynamic_cast else enum explicit export extern for friend goto if inline mutable namespace new noexcept not operator or private protected public register reinterpret_cast return sizeof static static_assert static_cast struct switch template this thread_local throw try typedef typeid typename union using virtual volatile while override final concept requires co_await co_return co_yield"),types:I("bool char double float int long short signed unsigned void wchar_t size_t string vector map std"),sigil:/^#\s*\w+/},swift:{line:["//"],block:[["/*","*/"]],quotes:['"'],calls:!0,literals:I("true false nil"),keywords:I("associatedtype class deinit enum extension fileprivate func import init inout internal let open operator private protocol public rethrows static struct subscript typealias var break case continue default defer do else fallthrough for guard if in repeat return switch where while as catch is self Self super throw throws try async await some any"),types:I("Int Double Float Bool String Character Array Dictionary Set Optional Void"),sigil:/^@[A-Za-z_]\w*/},dart:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:I("true false null"),keywords:I("abstract as assert async await break case catch class const continue covariant default deferred do dynamic else enum export extends extension external factory final finally for get hide if implements import in interface is late library mixin new on operator part required rethrow return set show static super switch sync this throw try typedef var void while with yield"),types:I("int double num bool String List Map Set Future Stream Object"),sigil:/^@[A-Za-z_]\w*/},php:{line:["//","#"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,caseless:!0,literals:I("true false null"),keywords:I("abstract and array as break callable case catch class clone const continue declare default do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile enum extends final finally fn for foreach function global goto if implements include include_once instanceof insteadof interface isset list match namespace new or print private protected public readonly require require_once return static switch throw trait try unset use var while xor yield"),sigil:/^\$[A-Za-z_]\w*/},lua:{line:["--"],block:[["--[[","]]"]],quotes:['"',"'"],calls:!0,literals:I("true false nil"),keywords:I("and break do else elseif end for function goto if in local not or repeat return then until while")},powershell:{line:["#"],block:[["<#","#>"]],quotes:['"',"'"],multiline:['"',"'"],caseless:!0,calls:!1,literals:I("$true $false $null"),keywords:I("begin break catch class continue data define do dynamicparam else elseif end enum exit filter finally for foreach from function hidden if in inlinescript param process return sequence static switch throw trap try until using var while workflow -and -or -not -xor -eq -ne -gt -ge -lt -le -like -notlike -match -notmatch -contains -notcontains -in -notin -replace -split -join -is -isnot -as -band -bor -f"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_][\w:]*|[?^$_])/},python:{line:["#"],quotes:['"""',"'''",'"',"'"],multiline:['"""',"'''"],calls:!0,literals:I("True False None"),keywords:I("and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield match case"),types:I("int float str bool list dict set tuple bytes object type self cls"),sigil:/^@[A-Za-z_][\w.]*/},ruby:{line:["#"],block:[["=begin","=end"]],quotes:['"',"'"],calls:!0,literals:I("true false nil"),keywords:I("alias and begin break case class def defined? do else elsif end ensure for if in module next not or redo rescue retry return self super then undef unless until when while yield require require_relative attr_accessor attr_reader attr_writer"),sigil:/^(?:@@?|\$)[A-Za-z_]\w*|^:[A-Za-z_]\w*/},shell:{line:["#"],quotes:['"',"'"],multiline:['"',"'"],literals:I("true false"),keywords:I("if then else elif fi case esac for select while until do done in function time coproc return exit export local readonly declare unset shift source alias echo cd"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_]\w*|[0-9@#?$!*-])/},batch:{line:["REM ","rem ","::"],quotes:['"'],caseless:!0,keywords:I("call cd chdir cls copy del dir echo else endlocal errorlevel exist exit for goto if in md mkdir move not off on pause popd pushd rd rem ren rmdir set setlocal shift start title type"),sigil:/^%[^%\s]+%|^%%?[A-Za-z0-9~]/},dockerfile:{line:["#"],quotes:['"',"'"],caseless:!0,keywords:I("from as run cmd label maintainer expose env add copy entrypoint volume user workdir arg onbuild stopsignal healthcheck shell"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_]\w*)/},makefile:{line:["#"],quotes:['"',"'"],keywords:I("ifeq ifneq ifdef ifndef else endif include define endef export override .PHONY"),sigil:/^\$(?:\([^)]*\)|\{[^}]*\}|[@<^*?%])/},sql:{line:["--"],block:[["/*","*/"]],quotes:["'",'"'],caseless:!0,calls:!0,literals:I("true false null"),keywords:I("select from where and or not insert into values update set delete create table view index drop alter add column primary key foreign references join left right inner outer full on as group by order having limit offset union all distinct case when then else end exists in is like between with returning begin commit rollback transaction grant revoke default constraint unique check if replace truncate procedure function trigger declare"),types:I("int integer bigint smallint decimal numeric float real double varchar char text date time timestamp boolean bool uuid json jsonb blob")}};function T(e,t){let a="",s=0,l=e.length,n=a=>t.caseless?e.substr(s,a.length).toLowerCase()===a.toLowerCase():e.startsWith(a,s),i=[...t.quotes].sort((e,t)=>t.length-e.length);for(;s<l;){var r,c,o,d,u,h,m;let p=e[s],f=null==(r=t.block)?void 0:r.find(e=>{let[t]=e;return n(t)});if(f){let t=e.indexOf(f[1],s+f[0].length),n=t<0?l:t+f[1].length;a+=z("com",e.slice(s,n)),s=n;continue}if(null==(c=t.line)?void 0:c.find(e=>n(e))){let t=e.indexOf("\n",s),n=t<0?l:t;a+=z("com",e.slice(s,n)),s=n;continue}let x=i.find(t=>e.startsWith(t,s));if(x){let n=s+x.length,i=null==(o=t.multiline)?void 0:o.includes(x),r=t!==H.powershell&&t!==H.batch&&(t!==H.shell&&t!==H.sql||"'"!==x);for(;n<l;){if("\\"===e[n]&&r){n+=2;continue}if(e.startsWith(x,n)){n+=x.length;break}if("\n"===e[n]&&!i)break;n+=1}a+=z("str",e.slice(s,Math.min(n,l))),s=Math.min(n,l);continue}if(t.sigil&&/[$@#%:[]/.test(p)){let l=t.sigil.exec(e.slice(s,s+200));if(l){let e=l[0];a+=z("@"===p||"#"===p||"["===p?"meta":"var",e),s+=e.length;continue}}if(/[0-9]/.test(p)||"."===p&&/[0-9]/.test(null!=(d=e[s+1])?d:"")){let t=null!=(u=e[s-1])?u:"";if(!/[\w$]/.test(t)){let t=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)[a-zA-Z]*/.exec(e.slice(s,s+64));if(t){a+=z("num",t[0]),s+=t[0].length;continue}}}if(/[A-Za-z_$-]/.test(p)){let l=/^-?[A-Za-z_$][\w$-]*\??/.exec(e.slice(s,s+120));if(l&&!(l[0].startsWith("-")&&!t.caseless)){let n=l[0];t!==H.powershell&&n.includes("-")&&(n=n.split("-")[0]||n.slice(0,1)),n||(n=p);let i=t.caseless?n.toLowerCase():n,r=(null==(h=t.literals)?void 0:h.has(i))?"lit":t.keywords.has(i)?"kw":(null==(m=t.types)?void 0:m.has(i))?"type":null;r?a+=z(r,n):t.calls&&"("===e[s+n.length]?a+=z("fn",n):/^[A-Z][a-z]\w*$/.test(n)&&t.types?a+=z("type",n):t===H.powershell&&/^[A-Z][a-z]+-[A-Z]\w*$/.test(n)?a+=z("fn",n):a+=q(n),s+=n.length;continue}}a+=q(p),s+=1}return a}function P(e,t){let a="",s=0,l=e.length;for(;s<l;){if(e.startsWith("\x3c!--",s)){let t=e.indexOf("--\x3e",s+4),n=t<0?l:t+3;a+=z("com",e.slice(s,n)),s=n;continue}if(e.startsWith("<![CDATA[",s)){let t=e.indexOf("]]>",s),n=t<0?l:t+3;a+=z("str",e.slice(s,n)),s=n;continue}let n=/^<\/?[A-Za-z!?][\w:.-]*/.exec(e.slice(s,s+100));if(n){let i=n[0];for(a+=z(i.startsWith("<!")||i.startsWith("<?")?"meta":"tag",i),s+=i.length;s<l&&">"!==e[s];){let t=/^[\s/?]+/.exec(e.slice(s,s+50));if(t){a+=q(t[0]),s+=t[0].length;continue}if('"'===e[s]||"'"===e[s]){let t=e.indexOf(e[s],s+1),n=t<0?l:t+1;a+=z("str",e.slice(s,n)),s=n;continue}let n=/^[^\s=>/"']+/.exec(e.slice(s,s+100));if(n){a+=z("attr",n[0]),s+=n[0].length;continue}a+=q(e[s]),s+=1}s<l&&(a+=z("tag",">"),s+=1);let r=i.toLowerCase();if(t&&("<script"===r||"<style"===r)){let t="<script"===r?"</script":"</style",n=e.toLowerCase().indexOf(t,s),i=n<0?l:n,c=e.slice(s,i);a+="<script"===r?T(c,H.javascript):B(c,!1),s=i}continue}if("&"===e[s]){let t=/^&[#\w]+;/.exec(e.slice(s,s+12));if(t){a+=z("lit",t[0]),s+=t[0].length;continue}}let i=e.indexOf("<",s+1),r=e.indexOf("&",s+1),c=Math.min(i<0?l:i,r<0?l:r);a+=q(e.slice(s,c)),s=c}return a}function B(e,t){let a="",s=0,l=e.length,n=0,i=!1;for(;s<l;){var r;let c=e[s];if(e.startsWith("/*",s)){let t=e.indexOf("*/",s+2),n=t<0?l:t+2;a+=z("com",e.slice(s,n)),s=n;continue}if(t&&e.startsWith("//",s)){let t=e.indexOf("\n",s),n=t<0?l:t;a+=z("com",e.slice(s,n)),s=n;continue}if('"'===c||"'"===c){let t=s+1;for(;t<l&&e[t]!==c&&"\n"!==e[t];)t+="\\"===e[t]?2:1;a+=z("str",e.slice(s,t+1)),s=t+1;continue}if("@"===c){let t=/^@[\w-]+/.exec(e.slice(s,s+40));if(t){a+=z("kw",t[0]),s+=t[0].length;continue}}if("$"===c&&t){let t=/^\$[\w-]+/.exec(e.slice(s,s+60));if(t){a+=z("var",t[0]),s+=t[0].length;continue}}if("{"===c&&(n+=1),"}"===c&&(n=Math.max(0,n-1),i=!1),";"===c&&(i=!1),":"===c&&n>0){a+=q(c),s+=1,i=!0;continue}if("#"===c&&i){let t=/^#[\da-fA-F]{3,8}\b/.exec(e.slice(s,s+12));if(t){a+=z("num",t[0]),s+=t[0].length;continue}}if(/[\d.]/.test(c)&&i&&!/[\w-]/.test(null!=(r=e[s-1])?r:"")){let t=/^-?(?:\d+\.?\d*|\.\d+)(?:%|[a-zA-Z]+)?/.exec(e.slice(s,s+20));if(t){a+=z("num",t[0]),s+=t[0].length;continue}}if(/[A-Za-z_-]/.test(c)){let t=/^-?-?[A-Za-z_][\w-]*/.exec(e.slice(s,s+80));if(t){let l=t[0];a+=n>0&&!i&&/^\s*:/.test(e.slice(s+l.length,s+l.length+10))?z("prop",l):i?/^(important|inherit|initial|unset|none|auto)$/.test(l)?z("lit",l):"("===e[s+l.length]?z("fn",l):q(l):z("tag",l),s+=l.length;continue}}a+=q(c),s+=1}return a}let _={typescript:{text:"TS",color:"#3178c6"},javascript:{text:"JS",color:"#b89a00"},json:{text:"{}",color:"#c48c12"},html:{text:"<>",color:"#e34c26"},xml:{text:"<>",color:"#e37933"},css:{text:"#",color:"#2f6fe0"},scss:{text:"S",color:"#cd6799"},markdown:{text:"M↓",color:"#3f7fbf"},powershell:{text:"PS",color:"#2a7bd0"},batch:{text:"BAT",color:"#7c8a96"},shell:{text:"$_",color:"#4a9e22"},python:{text:"PY",color:"#3d7fbf"},csharp:{text:"C#",color:"#9b4dca"},java:{text:"J",color:"#b07219"},kotlin:{text:"K",color:"#7f52ff"},go:{text:"GO",color:"#00a3cc"},rust:{text:"RS",color:"#c4561f"},c:{text:"C",color:"#6f8aa6"},cpp:{text:"C++",color:"#d6336c"},swift:{text:"SW",color:"#f05138"},dart:{text:"DT",color:"#0a85d6"},php:{text:"PHP",color:"#777bb4"},ruby:{text:"RB",color:"#cc342d"},lua:{text:"LUA",color:"#5466d6"},sql:{text:"SQL",color:"#d48a00"},yaml:{text:"Y",color:"#cb3a3a"},toml:{text:"T",color:"#b5562a"},ini:{glyph:"gear",color:"#7c8a96"},dockerfile:{text:"D",color:"#2496ed"},makefile:{text:"MK",color:"#7c8a96"},vue:{text:"V",color:"#3fae7c"}},$={glyph:"image",color:"#a074c4"},K={glyph:"archive",color:"#a07d3e"},U={png:$,jpg:$,jpeg:$,gif:$,webp:$,ico:$,bmp:$,svg:{text:"SVG",color:"#d6922d"},pdf:{text:"PDF",color:"#d03b35"},csv:{text:"CSV",color:"#2e8a55"},xlsx:{text:"XLS",color:"#2e8a55"},docx:{text:"DOC",color:"#3a6cc0"},pptx:{text:"PPT",color:"#d04a26"},zip:K,gz:K,"7z":K,tgz:K,txt:{text:"TXT",color:"#7c8a96"},log:{text:"LOG",color:"#7c8a96"},lock:{glyph:"lock",color:"#7c8a96"},exe:{text:"EXE",color:"#7c8a96"},dll:{text:"DLL",color:"#7c8a96"},sln:{text:"SLN",color:"#9b4dca"},csproj:{text:"C#",color:"#9b4dca"},tsx:{text:"TSX",color:"#3178c6"},jsx:{text:"JSX",color:"#b89a00"}},Z={glyph:"git",color:"#f14e32"},V={".gitignore":Z,".gitattributes":Z,".gitmodules":Z,"package.json":{text:"npm",color:"#cb3837"},"package-lock.json":{text:"npm",color:"#cb3837"},license:{text:"\xa9",color:"#7c8a96"},"license.md":{text:"\xa9",color:"#7c8a96"},"license.txt":{text:"\xa9",color:"#7c8a96"},".env":{glyph:"gear",color:"#c49a10"}};[...Object.values(_),...Object.values(U),...Object.values(V)].filter(e=>!!e);let J=e=>{let t=e.replace("#",""),a=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(a.slice(e,e+2),16))},G=e=>{let[t,a,s]=e;return"#".concat([t,a,s].map(e=>Math.round(e).toString(16).padStart(2,"0")).join(""))};function Y(e){let[t,a,s]=J(e).map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*a+.0722*s}let Q=new Map;function X(e){let{glyph:t}=e;switch(t){case"image":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"11",cy:"4.5",r:"1.8",fill:"currentColor"}),(0,s.jsx)("path",{d:"M1 14 6 7l3.5 4.5L11.5 9 15 14z",fill:"currentColor"})]});case"git":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M4.5 3v10M4.5 9.5c0-2.5 7-2 7-5",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"4.5",cy:"3",r:"1.9",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"4.5",cy:"13",r:"1.9",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"11.5",cy:"4.5",r:"1.9",fill:"currentColor"})]});case"lock":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M5 7V5a3 3 0 0 1 6 0v2",fill:"none",stroke:"currentColor",strokeWidth:"1.8"}),(0,s.jsx)("rect",{x:"3",y:"7",width:"10",height:"8",rx:"1.5",fill:"currentColor"})]});case"gear":return(0,s.jsx)("path",{d:"M8 5.2a2.8 2.8 0 1 0 0 5.6 2.8 2.8 0 0 0 0-5.6zM7 1h2l.4 1.9 1.3.6 1.7-1 1.4 1.4-1 1.7.6 1.3L15 7v2l-1.9.4-.6 1.3 1 1.7-1.4 1.4-1.7-1-1.3.6L9 15H7l-.4-1.9-1.3-.6-1.7 1-1.4-1.4 1-1.7-.6-1.3L1 9V7l1.9-.4.6-1.3-1-1.7 1.4-1.4 1.7 1 1.3-.6z",fill:"currentColor",fillRule:"evenodd"});case"archive":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M2 4h12v10H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M8 4v1.5M8 7v1.5M8 10v1.5",stroke:"currentColor",strokeWidth:"1.6"}),(0,s.jsx)("path",{d:"M1.5 1.5h13V4h-13z",fill:"currentColor"})]})}}let ee=e=>({"--ico":e.color,"--ico-dark":function(e){let t=Q.get(e);if(t)return t;let a=J(e),s=G(a);for(let e=.12;e<=1&&!(function(e,t){let[a,s]=[Y(e),Y(t)].sort((e,t)=>t-e);return(a+.05)/(s+.05)}(s=G(a.map(t=>t+(255-t)*e)),"#152436")>=4.8);e+=.04);return Q.set(e,s),s}(e.color)});function et(e){var t;let{path:a}=e,l=function(e){var t;let a=e.split("/").pop().toLowerCase();if(V[a])return V[a];let s=a.lastIndexOf("."),l=s>0?a.slice(s+1):"";return U[l]?U[l]:null!=(t=_[L(e)])?t:null}(a);if(!l)return(0,s.jsxs)("svg",{className:"file-ico",viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,s.jsx)("path",{d:"M3.5 1.5h6l3 3v10h-9z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M9.5 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})]});if(l.glyph)return(0,s.jsx)("svg",{className:"file-ico marked",viewBox:"0 0 16 16","aria-hidden":"true",style:ee(l),children:(0,s.jsx)(X,{glyph:l.glyph})});let n=null!=(t=l.text)?t:"",i=n.length>=3?9.2:2===n.length?11.5:15;return(0,s.jsx)("svg",{className:"file-ico marked",viewBox:"0 0 16 16","aria-hidden":"true",style:ee(l),children:(0,s.jsx)("text",{x:"8",y:"8.6",textAnchor:"middle",dominantBaseline:"middle",fontFamily:"'Segoe UI', system-ui, sans-serif",fontWeight:"800",fontSize:i,fill:"currentColor",...n.length>=2?{textLength:n.length>=3?16:15,lengthAdjust:"spacingAndGlyphs"}:{},children:n})})}let ea={staged:"git.uncommitted.staged",changes:"git.uncommitted.changes",untracked:"git.uncommitted.untracked",mixed:"git.uncommitted.mixed"};function es(e){var t,a,n;let{data:i,onBase:r,onOpenFile:c,statusName:o}=e,{t:d}=(0,C.kj)(),[u,h]=(0,l.useState)("all");if(i.problem){let e="no-common"===i.problem?d("git.problem.noCommon",{base:null!=(t=i.base)?t:""}):d("no-base"===i.problem?"git.problem.noBase":"git.problem.noCommit");return(0,s.jsx)("p",{className:"muted small wb-pad",children:e})}let m=i.files,p=m.filter(e=>e.uncommitted),f=m.filter(e=>e.committed),x="committed"===u?f:"uncommitted"===u?p:m,b=m.reduce((e,t)=>e+Math.max(0,t.added),0),g=m.reduce((e,t)=>e+Math.max(0,t.removed),0),v=(e,t)=>(0,s.jsx)("button",{type:"button",role:"tab","aria-selected":u===e,className:u===e?"on":"",onClick:()=>h(e),children:t});return(0,s.jsxs)("div",{className:"wb-branch",children:[(0,s.jsxs)("div",{className:"wb-branch-base",children:[(0,s.jsx)("label",{htmlFor:"wb-branch-base",className:"muted small",children:d("git.against")}),(0,s.jsx)("select",{id:"wb-branch-base",value:null!=(a=i.base)?a:"",onChange:e=>r(e.target.value),title:d("git.againstWhy"),children:i.bases.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("p",{className:"muted small wb-pad wb-branch-counts",children:[(0,s.jsx)("span",{className:"wb-branch-ahead",children:d("git.branchCounts",{ahead:i.ahead,behind:i.behind})}),(0,s.jsxs)("span",{className:"wb-branch-files",children:[d("git.branchFiles",{files:m.length}),m.length>0&&(0,s.jsxs)("span",{className:"wb-git-counts",children:[" \xb7 ",(0,s.jsxs)("span",{className:"plus",children:["+",b]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",g]})]})]})]}),0===m.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noBranchChanges",{base:null!=(n=i.base)?n:""})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wb-branch-filter",role:"tablist","aria-label":d("git.filter"),children:[v("all",d("git.filterAll",{n:m.length})),v("committed",d("git.filterCommitted",{n:f.length})),v("uncommitted",d("git.filterUncommitted",{n:p.length}))]}),p.length>0&&(0,s.jsxs)("p",{className:"muted small wb-pad wb-branch-legend",children:[(0,s.jsx)("span",{className:"wb-uncommitted","aria-hidden":"true",children:"●"})," ",d("git.legend")]}),0===x.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("uncommitted"===u?"git.allCommitted":"git.noneCommitted")}):(0,s.jsx)("ul",{className:"wb-git-files","aria-label":d("git.branch"),children:x.map(e=>(0,s.jsx)(el,{f:e,onOpen:t=>c(e.path,t),statusName:o},e.path))}),i.moreFiles&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.moreFiles",{n:m.length})})]})]})}function el(e){let{f:t,onOpen:a,statusName:l}=e,{t:n}=(0,C.kj)(),i=t.path.lastIndexOf("/"),r=t.uncommitted?n(ea[t.uncommitted]):"";return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"wb-row wb-git-file".concat(t.uncommitted?" has-uncommitted":""),onClick:()=>a(),onDoubleClick:()=>a(!0),title:["".concat(t.oldPath?"".concat(t.oldPath," → "):"").concat(t.path," \xb7 ").concat(l(t.status)),t.committed?n("git.inCommits"):"",r].filter(Boolean).join(" \xb7 "),children:[(0,s.jsx)(et,{path:t.path}),(0,s.jsx)("span",{className:"wb-row-name",children:t.path.slice(i+1)}),i>=0&&(0,s.jsx)("span",{className:"muted wb-git-dir",children:t.path.slice(0,i)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"wb-git-counts",children:t.added<0?n("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",t.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",t.removed]})]})}),t.uncommitted?(0,s.jsx)("span",{className:"wb-uncommitted u-".concat(t.uncommitted),role:"img","aria-label":r,children:"●"}):(0,s.jsx)("span",{className:"wb-uncommitted none","aria-hidden":"true"}),(0,s.jsx)("span",{className:"wb-git-status s-".concat(t.status),"aria-hidden":"true",children:t.status})]})})}var en=a(24872);let ei=e=>"cop.git.message:".concat(e.toLowerCase()),er="cop.git.opSeen",ec=e=>{try{var t;return null!=(t=localStorage.getItem(e))?t:""}catch(e){return""}},eo=(e,t)=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch(e){}};function ed(e){var t;let{state:a,onChanged:n,onOpen:i}=e,{t:r}=(0,C.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(null),[m,f]=(0,l.useState)(""),[x,b]=(0,l.useState)(!1),g=(0,l.useRef)(""),v=(0,l.useRef)(n);v.current=n;let j=a.dir;(0,l.useEffect)(()=>{d(ec(ei(j)))},[j]);let w=(0,l.useCallback)(e=>{d(e),eo(ei(j),e)},[j]),k=(0,l.useCallback)(()=>c.FH.gitOp().then(e=>{let{op:t}=e;if(!t||t.id===ec(er))return h(null);h(t),"running"!==t.state&&g.current!==t.id&&(g.current=t.id,v.current(),"commit"===t.kind&&"done"===t.state&&void 0!==t.message&&ec(ei(j)).trim()===t.message.trim()&&w(""))}).catch(()=>void 0),[j,w]);(0,l.useEffect)(()=>{k()},[k]),(0,p.z)(k,1e3,(null==u?void 0:u.state)==="running");let y=(null==u?void 0:u.state)==="running"||x,N=a.staged.length,S=a.changes.length,F=0===N,M=F?S:N,O=a.upstream,E=!!a.branch&&"HEAD"!==a.branch,L=e=>{f(""),b(!0),e().then(e=>{eo(er,""),h(e)}).catch(e=>f(e.message)).finally(()=>b(!1))},q=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:F;return L(()=>c.FH.gitCommit(t,a,e))},z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L(()=>c.FH.gitPush(e))},I=(e,t)=>{var a,s;return"commit"===e.kind?q(t,null!=(a=e.message)?a:o,null!=(s=e.all)?s:F):z(t)},D=o.trim()?0===M?r("git.nothingToCommit"):F?r("git.commitAllWhy",{n:S}):r("git.commitWhy",{n:N}):r("git.commitNeedsMessage"),W=null!=(t=null==O?void 0:O.name)?t:"",A=O?O.behind>0&&O.ahead>0?r("git.pushBehind",{target:W,n:O.behind}):0===O.ahead?r("git.pushNothing",{target:W}):r("git.pushWhy",{target:W,n:O.ahead}):r("git.publishWhy");return(0,s.jsxs)("div",{className:"wb-git-actions",children:[(0,s.jsx)("label",{htmlFor:"wb-git-message",className:"sr-only",children:r("git.message")}),(0,s.jsx)("textarea",{id:"wb-git-message",className:"wb-git-message",rows:2,value:o,placeholder:r("git.messagePlaceholder"),onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&o.trim()&&M>0&&!y&&(e.preventDefault(),q())},disabled:y}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsxs)("button",{type:"button",className:"primary",onClick:()=>q(),disabled:y||!o.trim()||0===M,title:D,children:["✓ ",r(F?"git.commitAll":"git.commit"),M>0&&(0,s.jsx)("span",{className:"wb-badge",children:M})]}),E&&!(O&&0===O.ahead)&&(0,s.jsx)("button",{type:"button",onClick:()=>z(),disabled:y,title:A,children:O?r("git.push",{n:O.ahead}):r("git.publish")})]}),m&&(0,s.jsx)("p",{className:"err small",role:"alert",children:m}),u&&(0,s.jsx)(eu,{op:u,onAgain:I,onDismiss:()=>{u&&eo(er,u.id),h(null)},onOpen:i,onIdentity:e=>I(e,{})})]})}function eu(e){var t,a,l;let{op:n,onAgain:i,onDismiss:r,onOpen:c,onIdentity:o}=e,{t:d}=(0,C.kj)(),u=null!=(t=n.target)?t:"",h=(null!=(a=n.commit)?a:"").slice(0,8),m="running"===n.state?"commit"===n.kind?d("git.op.committing"):d("git.op.pushing",{target:u}):"hooks"===n.state?d("git.op.hooksAsk"):"done"===n.state?"commit"===n.kind?d("git.op.committed",{sha:h,branch:null!=(l=n.branch)?l:"HEAD"}):n.upToDate?d("git.op.upToDate",{target:u}):n.published?d("git.op.published",{target:u}):d("git.op.pushed",{target:u}):"commit"===n.kind?d("git.op.commitFailed"):d("git.op.pushFailed");return(0,s.jsxs)("div",{className:"wb-git-op s-".concat(n.state),role:"failed"===n.state?"alert":"status","aria-live":"polite","data-awaits":"hooks"===n.state?"git-hooks":void 0,children:[(0,s.jsxs)("div",{className:"wb-git-op-head",children:["running"===n.state&&(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"}),(0,s.jsx)("strong",{className:"grow",children:m}),"running"!==n.state&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:r,title:d("git.op.dismiss"),"aria-label":d("git.op.dismiss"),children:"✕"})]}),"failed"===n.state&&n.cause&&(0,s.jsx)("p",{className:"wb-git-why",children:d("git.why.".concat(n.cause))}),n.passwordWindow&&"running"===n.state&&(0,s.jsx)("p",{className:"wb-git-why",children:d("git.op.passwordWindow")}),"running"!==n.state&&"hooks"!==n.state&&"none"!==n.hooks&&(0,s.jsx)("p",{className:"muted small",children:"run"===n.hooks?d("git.op.hooksRan"):d("git.op.hooksSkipped")}),"hooks"===n.state&&n.flagged&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{className:"wb-git-hooks",children:n.flagged.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsx)("code",{children:e.path})," — ",d("git.hookWhy.".concat(e.why))," ",!/^[A-Za-z]:|^\//.test(e.path)&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>c({kind:"file",path:e.path}),children:d("git.hooks.open")})]},e.path))}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{hooks:"skip"}),title:d("git.hooks.skipWhy"),children:d("git.hooks.skip")}),(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{trust:n.flagged.map(e=>({path:e.path,sha:e.sha}))}),title:d("git.hooks.trustWhy"),children:d("git.hooks.trust")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:r,children:d("git.hooks.cancel")})]})]}),"failed"===n.state&&"identity"===n.cause&&"commit"===n.kind&&(0,s.jsx)(eh,{onSaved:()=>o(n)}),"failed"===n.state&&"hook"===n.cause&&(0,s.jsx)("div",{className:"wb-git-buttons",children:(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{hooks:"skip"}),title:d("git.hooks.skipWhy"),children:d("git.hooks.skip")})}),(n.output||"failed"===n.state)&&(0,s.jsxs)("details",{className:"wb-git-output",open:"failed"===n.state||"running"===n.state,children:[(0,s.jsxs)("summary",{children:[d("git.op.output")," ",(0,s.jsx)("code",{children:n.command})]}),(0,s.jsxs)("pre",{children:[n.cut?"…\n":"",n.output||"—"]}),n.output&&(0,s.jsx)(en.i8,{text:n.output,what:"git.op.copy"})]})]})}function eh(e){let{onSaved:t}=e,{t:a}=(0,C.kj)(),[n,i]=(0,l.useState)(""),[r,o]=(0,l.useState)(""),[d,u]=(0,l.useState)(!0),[h,m]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{c.FH.gitIdentity().then(e=>{i(t=>t||e.name),o(t=>t||e.email)}).catch(()=>void 0)},[]),(0,s.jsxs)("form",{className:"wb-git-identity",onSubmit:e=>{e.preventDefault(),m(""),f(!0),c.FH.setGitIdentity(n,r,d).then(t).catch(e=>m(e.message)).finally(()=>f(!1))},children:[(0,s.jsx)("p",{className:"small",children:(0,s.jsx)("strong",{children:a("git.identity.title")})}),(0,s.jsxs)("label",{children:[a("git.identity.name"),(0,s.jsx)("input",{type:"text",value:n,onChange:e=>i(e.target.value),autoComplete:"name"})]}),(0,s.jsxs)("label",{children:[a("git.identity.email"),(0,s.jsx)("input",{type:"email",value:r,onChange:e=>o(e.target.value),autoComplete:"email"})]}),(0,s.jsxs)("label",{className:"check",children:[(0,s.jsx)("input",{type:"checkbox",checked:d,onChange:e=>u(e.target.checked)})," ",a("git.identity.global")]}),h&&(0,s.jsx)("p",{className:"err small",children:h}),(0,s.jsx)("button",{type:"submit",disabled:p||!n.trim()||!r.trim(),children:a("git.identity.save")})]})}var em=a(11272);function ep(e){let{view:t,onOpen:a,reveal:l,workspace:n,onOpenFolder:i,grip:r}=e;return"commits"===t?(0,s.jsx)(eg,{workspace:n,onOpen:a,onOpenFolder:i,grip:r}):(0,s.jsx)(eb,{workspace:n,onOpen:a,reveal:l,onOpenFolder:i,grip:r})}function ef(e){let{title:t,children:a,grip:l}=e;return(0,s.jsxs)("div",{className:"wb-side-head",children:[l,(0,s.jsx)("h2",{children:t}),(0,s.jsx)("span",{className:"grow"}),a]})}let ex=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"});function eb(e){let{workspace:t,onOpen:a,reveal:n,onOpenFolder:i,grip:r}=e,{t:o}=(0,C.kj)(),[d,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(""),[f,x]=(0,l.useState)(new Set),[b,g]=(0,l.useState)(""),[v,j]=(0,l.useState)(""),w=()=>(null==t?void 0:t.ok)?c.FH.workspaceFiles().then(e=>{u(e.files),m("")}).catch(e=>m(e.message)):Promise.resolve();(0,l.useEffect)(()=>{u(null),w()},[null==t?void 0:t.dir,null==t?void 0:t.ok]),(0,p.z)(w,6e3,!!(null==t?void 0:t.ok));let k=(0,l.useRef)(0),y=(0,l.useRef)("");(0,l.useEffect)(()=>{if(!n||!d||k.current===n.n)return;if(k.current=n.n,!d.includes(n.path)){g(""),j(n.path);return}j(""),g(n.path);let e=n.path.split("/");x(t=>new Set([...t,...e.slice(0,-1).map((t,a)=>e.slice(0,a+1).join("/"))])),y.current=n.path},[n,d]),(0,l.useEffect)(()=>{if(!y.current)return;let e=[...document.querySelectorAll(".wb-tree-list [data-path]")].find(e=>e.dataset.path===y.current);e&&(y.current="",e.scrollIntoView({block:"nearest"}))});let N=(e,t)=>(0,s.jsxs)(s.Fragment,{children:[[...e.dirs.keys()].sort(ex).map(a=>{let l=t?"".concat(t,"/").concat(a):a;return(0,s.jsxs)("li",{role:"treeitem","aria-expanded":f.has(l),children:[(0,s.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>x(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),children:[(0,s.jsx)("span",{className:"wb-chev","aria-hidden":"true",children:f.has(l)?"▾":"▸"}),(0,s.jsx)("span",{className:"wb-row-name",children:a})]}),f.has(l)&&(0,s.jsx)("ul",{role:"group",children:N(e.dirs.get(a),l)})]},"d:".concat(l))}),[...e.files].sort((e,t)=>ex(e.split("/").pop(),t.split("/").pop())).map(e=>(0,s.jsx)("li",{role:"treeitem","aria-selected":b===e,children:(0,s.jsxs)("button",{type:"button",className:"wb-row file".concat(b===e?" sel":""),"data-path":e,onClick:()=>{g(e),j(""),a({kind:"file",path:e,preview:!0})},onDoubleClick:()=>a({kind:"file",path:e}),title:e,children:[(0,s.jsx)(et,{path:e}),(0,s.jsx)("span",{className:"wb-row-name",children:e.split("/").pop()})]})},"f:".concat(e)))]});return(0,s.jsxs)("div",{className:"wb-tree",children:[(0,s.jsxs)(ef,{title:(null==t?void 0:t.ok)?t.name:o("wb.files"),grip:r,children:[(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:i,title:o("chat.openFolder"),"aria-label":o("chat.openFolder"),children:"⋯"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void w(),title:o("wb.refresh"),"aria-label":o("wb.refresh"),children:"↻"})]}),t?t.ok?h?(0,s.jsx)("p",{className:"err small wb-pad",children:h}):d?(0,s.jsxs)(s.Fragment,{children:[v&&(0,s.jsx)("p",{className:"muted small wb-pad",role:"status",children:o("wb.revealGone",{name:v})}),(0,s.jsx)("p",{className:"muted small wb-pad",title:t.dir,children:t.branch?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(em.O,{})," ",t.branch]}):t.dir}),(0,s.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":o("wb.files"),children:N(function(e){let t={dirs:new Map,files:[]};for(let a of e){let e=a.split("/"),s=t;for(let t of e.slice(0,-1)){let e=s.dirs.get(t);e||(e={dirs:new Map,files:[]},s.dirs.set(t,e)),s=e}s.files.push(a)}return t}(d),"")})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:o("wb.loading")}):(0,s.jsxs)("div",{className:"wb-pad",children:[(0,s.jsx)("p",{className:"small",children:t.problem}),(0,s.jsx)("button",{type:"button",className:"primary",onClick:i,children:o("chat.openFolder")})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:o("wb.loading")})]})}function eg(e){var t,a;let{workspace:n,onOpen:i,onOpenFolder:r,grip:o}=e,{t:d}=(0,C.kj)(),u=(0,C.W3)(),[h,f]=(0,l.useState)(null),[x,b]=(0,l.useState)(""),[g,v]=(0,l.useState)(new Set),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(new Map),[N,S]=(0,l.useState)(null),[F,M]=m(null!=(t=null==n?void 0:n.dir)?t:""),O=(0,l.useCallback)(()=>Promise.all([c.FH.workspaceGit(),c.FH.workspaceBranch(F||void 0)]).then(e=>{let[t,a]=e;f(t),S(a),b("")}).catch(e=>b(e.message)),[F]);(0,l.useEffect)(()=>{f(null),S(null),(null==n?void 0:n.ok)&&O()},[O,null==n?void 0:n.ok,null==n?void 0:n.dir]),(0,p.z)(O,5e3,!!(null==n?void 0:n.ok));let E=e=>d("git.status.".concat("!"===e?"conflict":e)),[L,q]=(0,l.useState)(!1),[z,I]=(0,l.useState)(""),D=(e,t)=>{q(!0),I(""),c.FH.gitStage(e,t).then(f).catch(e=>I(e.message)).finally(()=>q(!1))},W=(e,t,a)=>{let l=e.path.lastIndexOf("/");return(0,s.jsxs)("li",{className:"changes"===t||"staged"===t?"wb-git-stageable":void 0,children:[(0,s.jsxs)("button",{type:"button",className:"wb-row wb-git-file",onClick:()=>i({kind:"diff",area:t,path:e.path,...a?{commit:a}:{},preview:!0}),onDoubleClick:()=>i({kind:"diff",area:t,path:e.path,...a?{commit:a}:{}}),title:"".concat(e.oldPath?"".concat(e.oldPath," → "):"").concat(e.path," \xb7 ").concat(E(e.status)),children:[(0,s.jsx)(et,{path:e.path}),(0,s.jsx)("span",{className:"wb-row-name",children:e.path.slice(l+1)}),l>=0&&(0,s.jsx)("span",{className:"muted wb-git-dir",children:e.path.slice(0,l)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"wb-git-counts",children:e.added<0?d("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})}),(0,s.jsx)("span",{className:"wb-git-status s-".concat("!"===e.status?"conflict":e.status),"aria-hidden":"true",children:e.status})]}),"changes"===t||"staged"===t?(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D("changes"===t?"stage":"unstage",[e.path]),disabled:L,title:d("changes"===t?"git.stageFile":"git.unstageFile",{path:e.path}),"aria-label":d("changes"===t?"git.stageFile":"git.unstageFile",{path:e.path}),children:"changes"===t?"+":"−"}):null]},"".concat(t,":").concat(null!=a?a:"",":").concat(e.path))},A=(e,t,a,l,n)=>(0,s.jsxs)("div",{className:"wb-git-section",children:[(0,s.jsxs)("div",{className:"wb-git-head-row",children:[(0,s.jsxs)("button",{type:"button",className:"wb-git-head","aria-expanded":!g.has(e),onClick:()=>v(t=>new Set(t.has(e)?[...t].filter(t=>t!==e):[...t,e])),children:[(0,s.jsx)("span",{"aria-hidden":"true",children:g.has(e)?"▸":"▾"})," ",t,null!==a&&(0,s.jsx)("span",{className:"wb-badge",children:a})]}),n]}),!g.has(e)&&l]}),R=e=>(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D(e,"all"),disabled:L,title:d("stage"===e?"git.stageAll":"git.unstageAll"),"aria-label":d("stage"===e?"git.stageAll":"git.unstageAll"),children:"stage"===e?"+":"−"});return(0,s.jsxs)("div",{className:"wb-tree",children:[(0,s.jsx)(ef,{title:d("git.title"),grip:o,children:(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void O(),title:d("git.refresh"),"aria-label":d("git.refresh"),disabled:!(null==n?void 0:n.ok),children:"↻"})}),(null==n?void 0:n.ok)?x?(0,s.jsx)("p",{className:"err small wb-pad",children:x}):h?h.isRepo?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"small wb-pad wb-git-branch",children:[(0,s.jsx)(em.O,{})," ",(0,s.jsx)("strong",{children:null!=(a=h.branch)?a:"HEAD"}),h.upstream&&(0,s.jsxs)("span",{className:"muted",children:[" \xb7 ",d("git.upstream",{name:h.upstream.name,ahead:h.upstream.ahead,behind:h.upstream.behind})]})]}),(0,s.jsx)(ed,{state:h,onChanged:()=>void O(),onOpen:i}),z&&(0,s.jsx)("p",{className:"err small wb-pad",role:"alert",children:z}),N&&A("branch",d("git.branch"),N.problem?null:N.files.length,(0,s.jsx)(es,{data:N,onBase:M,statusName:E,onOpenFile:(e,t)=>i({kind:"diff",area:"branch",path:e,...N.base?{commit:N.base}:{},...t?{}:{preview:!0}})})),h.staged.length>0&&A("staged",d("git.staged"),h.staged.length,(0,s.jsx)("ul",{className:"wb-git-files",children:h.staged.map(e=>W(e,"staged"))}),R("unstage")),A("changes",d("git.changes"),h.changes.length,0===h.changes.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noChanges")}):(0,s.jsx)("ul",{className:"wb-git-files",children:h.changes.map(e=>W(e,"changes"))}),h.changes.length>0?R("stage"):void 0),A("commits",d("git.commits"),null,0===h.commits.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noCommits")}):(0,s.jsx)("ul",{className:"wb-commits",children:h.commits.map((e,t)=>{var a;let l=k.get(e.sha),n=!!(null==N?void 0:N.mergeBase)&&N.commits.includes(e.sha),i=!!(null==N?void 0:N.mergeBase)&&e.sha===N.mergeBase&&t>0&&N.commits.length>0;return(0,s.jsxs)("li",{className:n?"on-branch":void 0,children:[i&&(0,s.jsx)("p",{className:"wb-branch-start small",role:"separator",children:d("git.branchStart",{base:null!=(a=N.base)?a:"",sha:e.short})}),(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":j===e.sha,onClick:()=>(e=>{if(j===e)return void w("");w(e),k.has(e)||c.FH.workspaceCommit(e).then(t=>y(a=>new Map(a).set(e,t.files))).catch(t=>y(a=>new Map(a).set(e,t.message)))})(e.sha),title:n?"".concat(e.subject," \xb7 ").concat(d("git.onBranch")):e.subject,children:[(0,s.jsx)("span",{"aria-hidden":"true",children:j===e.sha?"▾":"▸"}),(0,s.jsx)("code",{children:e.short}),(0,s.jsx)("span",{className:"wb-row-name",children:e.subject})]}),(0,s.jsxs)("div",{className:"muted wb-commit-meta",children:[e.author," \xb7 ",u(e.at)]}),j===e.sha&&(void 0===l?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("wb.loading")}):"string"==typeof l?(0,s.jsx)("p",{className:"err small wb-pad",children:l}):(0,s.jsx)("ul",{className:"wb-git-files nested","aria-label":d("git.commitFiles",{sha:e.short}),children:l.map(t=>W(t,"commit",e.sha))}))]},e.sha)})})),h.moreCommits&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.more",{n:h.commits.length})})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.notRepo")}):(0,s.jsx)("p",{className:"muted small wb-pad",children:d("wb.loading")}):(0,s.jsxs)("div",{className:"wb-pad",children:[(0,s.jsx)("p",{className:"muted small",children:d("git.noFolder")}),(0,s.jsx)("button",{type:"button",onClick:r,children:d("chat.openFolder")})]})]})}let ev=/^(\s{0,3})(`{3,}|~{3,})\s*([^\s`]*)?.*$/,ej=/^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;function ew(e,t){if(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith("//"))return null;let a=function(e){try{return decodeURI(e)}catch(t){return e}}(t.split("#")[0].split("?")[0]),s=(a.startsWith("/")?a.slice(1):"".concat(e).concat(e?"/":"").concat(a)).split("/"),l=[];for(let e of s)if(""!==e&&"."!==e)if(".."===e){if(0===l.length)return null;l.pop()}else l.push(e);return l.join("/")}function ek(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"i",l=[],n=e,i=0,r=()=>"".concat(a,"-").concat(i++),o=[[/^\\([\\`*_{}[\]()#+\-.!|~<>])/,e=>e[1]],[/^(`+)([\s\S]*?[^`])\1(?!`)/,e=>(0,s.jsx)("code",{children:e[2].replace(/^ (.*) $/,"$1")},r())],[/^!\[([^\]]*)\]\(\s*<?([^\s)>]+)>?(?:\s+"([^"]*)")?\s*\)/,e=>{let a=ew(t.dir,e[2]);return null===a?(0,s.jsxs)("a",{href:e[2],target:"_blank",rel:"noopener noreferrer",title:t.t("md.externalImage",{url:e[2]}),children:["\uD83D\uDDBC ",e[1]||e[2]]},r()):(0,s.jsx)("img",{src:"".concat(c.nC,"/workspace/raw?path=").concat(encodeURIComponent(a)),alt:e[1],title:e[3],loading:"lazy"},r())}],[/^\[((?:[^\][]|\[[^\]]*\])*)\]\(\s*<?([^\s)>]*)>?(?:\s+"([^"]*)")?\s*\)/,e=>d(e[2],ek(e[1],t,r()),e[3])],[/^<(https?:\/\/[^>\s]+)>/,e=>d(e[1],[e[1]])],[/^(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/,e=>d(e[1],[e[1]])],[/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/,e=>(0,s.jsx)("strong",{children:ek(e[2],t,r())},r())],[RegExp("^(\\*|_)(?=\\S)([\\s\\S]*?\\S)\\1(?![\\p{L}\\p{N}])","u"),e=>(0,s.jsx)("em",{children:ek(e[2],t,r())},r())],[/^~~(?=\S)([\s\S]*?\S)~~/,e=>(0,s.jsx)("del",{children:ek(e[1],t,r())},r())],[/^( {2,}|\\)\n/,()=>(0,s.jsx)("br",{},r())]];function d(e,a,l){if(e.startsWith("#"))return(0,s.jsx)("a",{href:e,title:l,children:a},r());let n=ew(t.dir,e);return null!==n?(0,s.jsx)("a",{href:"#".concat(n),title:null!=l?l:n,onClick:e=>{e.preventDefault(),t.onOpenFile(n)},children:a},r()):(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,children:a},r())}let u="",h=()=>{u&&l.push(u),u=""};for(;n.length>0;){let e=!1;for(let[t,a]of o){let s=t.exec(n);if(s){h(),l.push(a(s)),n=n.slice(s[0].length),e=!0;break}}e||(u+=n[0],n=n.slice(1))}return h(),l}function ey(e){let{code:t}=e,{t:n}=(0,C.kj)(),i=(0,l.useId)().replace(/[^a-zA-Z0-9]/g,""),[r,c]=(0,l.useState)(""),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)("");return((0,l.useEffect)(()=>{let e=()=>{var e;return h(null!=(e=document.documentElement.dataset.theme)?e:"light")};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>t.disconnect()},[]),(0,l.useEffect)(()=>{if(!u)return;let e=!1;return(async()=>{try{let s=(await Promise.all([a.e(7100),a.e(8653),a.e(9891)]).then(a.bind(a,50879))).default;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"===u?"dark":"default",fontFamily:"inherit"});let l=await s.render("mmd-".concat(i,"-").concat(u),t);e||(c(l.svg),d(""))}catch(t){var s;e||d(null!=(s=t.message.split("\n")[0])?s:String(t))}})(),()=>{e=!0}},[t,u,i]),o)?(0,s.jsxs)("div",{className:"md-mermaid bad",children:[(0,s.jsx)("p",{className:"small",children:n("md.mermaidError",{why:o})}),(0,s.jsx)("pre",{children:(0,s.jsx)("code",{children:t})})]}):r?(0,s.jsx)("div",{className:"md-mermaid",role:"img","aria-label":t.split("\n")[0],dangerouslySetInnerHTML:{__html:r}}):(0,s.jsx)("p",{className:"md-mermaid muted small",children:n("md.mermaidLoading")})}function eN(e){let{text:t,path:a,onOpenFile:l}=e,{t:n}=(0,C.kj)(),i=a.includes("/")?a.slice(0,a.lastIndexOf("/")):"";return(0,s.jsx)("article",{className:"md",children:function e(t,a){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"b";return t.map((t,n)=>{let i="".concat(l,"-").concat(n);switch(t.kind){case"heading":{let e="h".concat(t.level);return(0,s.jsx)(e,{id:t.text.toLowerCase().replace(/[`*_~[\]()]/g,"").replace(RegExp("[^\\p{L}\\p{N}\\s-]","gu"),"").trim().replace(/\s+/g,"-"),children:ek(t.text,a,i)},i)}case"para":return(0,s.jsx)("p",{children:ek(t.text,a,i)},i);case"rule":return(0,s.jsx)("hr",{},i);case"html":return(0,s.jsx)("pre",{className:"md-html",children:(0,s.jsx)("code",{children:t.text})},i);case"quote":return(0,s.jsx)("blockquote",{children:e(t.blocks,a,i)},i);case"code":{var r,c;if("mermaid"===t.lang)return(0,s.jsx)(ey,{code:t.text},i);let e=null!=(c=null==(r=M.find(e=>e.id===t.lang||e.name.toLowerCase()===t.lang))?void 0:r.id)?c:({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",sh:"shell",bash:"shell",zsh:"shell",ps1:"powershell",pwsh:"powershell",py:"python",cs:"csharp","c#":"csharp",yml:"yaml",md:"markdown",html:"html",xml:"xml",json:"json",css:"css",sql:"sql",rs:"rust",go:"go",java:"java",kt:"kotlin",rb:"ruby",php:"php",cpp:"cpp","c++":"cpp",c:"c",bat:"batch",cmd:"batch",toml:"toml",ini:"ini",dockerfile:"dockerfile"})[t.lang];return(0,s.jsx)("pre",{className:"md-code",children:e?(0,s.jsx)("code",{dangerouslySetInnerHTML:{__html:function e(t,a){switch(a){case"plain":return q(t);case"json":return t.replace(/("(?:[^"\\\n]|\\.)*")(\s*:)?|\/\/[^\n]*|\/\*[\s\S]*?\*\/|\b(true|false|null)\b|-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[&<>]/g,(e,t,a,s)=>void 0!==t?a?z("prop",t)+q(a):z("str",t):e.startsWith("//")||e.startsWith("/*")?z("com",e):s?z("lit",e):/^[&<>]$/.test(e)?q(e):z("num",e));case"html":case"vue":return P(t,!0);case"xml":return P(t,!1);case"css":return B(t,!1);case"scss":return B(t,!0);case"yaml":return t.split("\n").map(e=>{let t=/^(\s*(?:- )?)([^#:'"\n][^:#\n]*?)(:)(\s|$)(.*)$/.exec(e),a=e=>e.replace(/(#.*$)|("(?:[^"\\]|\\.)*"|'[^']*')|(\b(?:true|false|null|yes|no|on|off|~)\b)|(-?\b\d+(?:\.\d+)?\b)|([&*][\w-]+)|([&<>])/gi,(e,t,a,s,l,n,i)=>t?z("com",t):a?z("str",a):s?z("lit",s):l?z("num",l):n?z("var",n):i?q(i):q(e));return/^\s*#/.test(e)?z("com",e):/^\s*---|^\s*\.\.\./.test(e)?z("meta",e):t?q(t[1])+z("prop",t[2])+q(t[3])+q(t[4])+a(t[5]):a(e)}).join("\n");case"ini":case"toml":return t.split("\n").map(e=>{if(/^\s*[#;]/.test(e))return z("com",e);let t=/^(\s*)(\[\[?[^\]]*\]\]?)(.*)$/.exec(e);if(t)return q(t[1])+z("head",t[2])+q(t[3]);let a=/^(\s*)([^=:\s][^=:]*?)(\s*[=:]\s*)(.*)$/.exec(e);if(a){let e=a[4],t=/^(".*"|'.*')$/.test(e.trim())?z("str",e):/^-?\d+(\.\d+)?$/.test(e.trim())?z("num",e):/^(true|false|yes|no|on|off)$/i.test(e.trim())?z("lit",e):q(e);return q(a[1])+z("prop",a[2])+q(a[3])+t}return q(e)}).join("\n");case"markdown":return function(t){let a=t.split("\n"),s=[],l=null;for(let t of a){if(l){t.trimStart().startsWith(l.mark)?(s.push(l.body.length?e(l.body.join("\n"),l.lang):""),s.push(z("code",t)),l=null):l.body.push(t);continue}let a=/^(\s*)(```+|~~~+)\s*([\w+#-]*)/.exec(t);if(a){var n,i,r;let e=a[3]?null!=(r=O[a[3].toLowerCase()])?r:null!=(i=null==(n=M.find(e=>e.name.toLowerCase()===a[3].toLowerCase()))?void 0:n.id)?i:"plain":"plain";l={mark:a[2],lang:e,body:[]},s.push(z("code",t));continue}if(/^\s{0,3}#{1,6}\s/.test(t)){s.push(z("head",t));continue}if(/^\s*>/.test(t)){s.push(z("com",t));continue}let c=q(t);c=c.replace(/^(\s*)([-*+]|\d+[.)])(\s)/,(e,t,a,s)=>"".concat(t,'<span class="hl-kw">').concat(a,"</span>").concat(s)).replace(/(`+)([^`]+?)\1/g,e=>'<span class="hl-code">'.concat(e,"</span>")).replace(RegExp("(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1","g"),e=>'<span class="hl-head">'.concat(e,"</span>")).replace(RegExp("(^|[^*\\w])(\\*|_)(?=\\S)(.+?)(?<=\\S)\\2(?!\\w)","g"),(e,t,a,s)=>"".concat(t,'<span class="hl-em">').concat(a).concat(s).concat(a,"</span>")).replace(/(!?\[[^\]]*\])(\([^)]*\))/g,(e,t,a)=>'<span class="hl-str">'.concat(t,'</span><span class="hl-link">').concat(a,"</span>")),s.push(c)}return l&&s.push(e(l.body.join("\n"),l.lang)),s.join("\n")}(t);default:{let e=H[a];return e?T(t,e):q(t)}}}(t.text,e)}}):(0,s.jsx)("code",{children:t.text})},i)}case"list":{let l=t.items.map((t,l)=>(0,s.jsxs)("li",{className:t.task?"md-task":void 0,children:[t.task&&(0,s.jsx)("input",{type:"checkbox",checked:!!t.done,disabled:!0,"aria-label":t.done?"✓":"○"}),1===t.blocks.length&&"para"===t.blocks[0].kind?ek(t.blocks[0].text,a,"".concat(i,"-").concat(l)):e(t.blocks,a,"".concat(i,"-").concat(l))]},"".concat(i,"-").concat(l)));return t.ordered?(0,s.jsx)("ol",{start:t.start,children:l},i):(0,s.jsx)("ul",{children:l},i)}case"table":return(0,s.jsx)("div",{className:"md-table",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:t.head.map((e,l)=>(0,s.jsx)("th",{style:t.align[l]?{textAlign:t.align[l]}:void 0,children:ek(e,a,"".concat(i,"-h").concat(l))},l))})}),(0,s.jsx)("tbody",{children:t.rows.map((e,l)=>(0,s.jsx)("tr",{children:t.head.map((n,r)=>{var c;return(0,s.jsx)("td",{style:t.align[r]?{textAlign:t.align[r]}:void 0,children:ek(null!=(c=e[r])?c:"",a,"".concat(i,"-").concat(l,"-").concat(r))},r)})},l))})]})},i)}})}(function e(t){let a=t.replace(/\r\n?/g,"\n").split("\n"),s=[],l=0,n=e=>void 0===e||""===e.trim();for(;l<a.length;){var i,r,c,o,d,u,h,m;let t=a[l];if(n(t)){l+=1;continue}let p=ev.exec(t);if(p){let e=p[2],t=[];for(l+=1;l<a.length&&!a[l].trim().startsWith(e[0].repeat(e.length));)t.push(a[l++]);l+=1,s.push({kind:"code",lang:(null!=(i=p[3])?i:"").toLowerCase(),text:t.join("\n")});continue}let f=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(t);if(f){s.push({kind:"heading",level:f[1].length,text:f[2]}),l+=1;continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(t)){s.push({kind:"rule"}),l+=1;continue}if(/^\s{0,3}>/.test(t)){let t=[];for(;l<a.length&&!n(a[l])&&(/^\s{0,3}>/.test(a[l])||t.length>0)&&!(!/^\s{0,3}>/.test(a[l])&&(ev.test(a[l])||ej.test(a[l])));)t.push(a[l].replace(/^\s{0,3}>\s?/,"")),l+=1;s.push({kind:"quote",blocks:e(t.join("\n"))});continue}if(t.includes("|")&&l+1<a.length&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(a[l+1])){let e=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split(RegExp("(?<!\\\\)\\|")).map(e=>e.trim().replace(/\\\|/g,"|")),i=e(t),r=e(a[l+1]).map(e=>e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":e.startsWith(":")?"left":"");l+=2;let c=[];for(;l<a.length&&!n(a[l])&&a[l].includes("|");)c.push(e(a[l++]));s.push({kind:"table",head:i,align:r,rows:c});continue}let x=ej.exec(t);if(x){let t=x[1].length,i=/\d/.test(x[2]),p=[];for(;l<a.length;){let s=ej.exec(a[l]);if(!s||s[1].length!==t||/\d/.test(s[2])!==i)break;let f=[s[3]];for(l+=1;l<a.length;){let e=a[l],s=ej.exec(e);if(n(e)){if(l+1<a.length&&(null!=(u=null==(d=a[l+1].match(/^\s*/))?void 0:d[0].length)?u:0)>t&&!n(a[l+1])){f.push(""),l+=1;continue}break}if(s&&s[1].length<=t)break;let r=null!=(h=null==(o=e.match(/^\s*/))?void 0:o[0].length)?h:0;if(r<=t&&!s&&/^\s{0,3}(#|>|```|~~~)/.test(e))break;f.push(r>t?e.slice(Math.min(r,t+2+ +!!i)):e.trim()),l+=1}let x=/^\[([ xX])\]\s+/.exec(f[0]);for(x&&(f[0]=f[0].slice(x[0].length)),p.push({blocks:e(f.join("\n")),...x?{task:!0,done:" "!==x[1]}:{}});l<a.length&&n(a[l])&&(null==(c=ej.exec(null!=(m=a[l+1])?m:""))||null==(r=c[1])?void 0:r.length)===t;)l+=1}s.push({kind:"list",ordered:i,start:i?parseInt(x[2],10):1,items:p});continue}if(/^\s{0,3}<[a-zA-Z!/]/.test(t)){let e=[];for(;l<a.length&&!n(a[l]);)e.push(a[l++]);s.push({kind:"html",text:e.join("\n")});continue}let b=[];for(;l<a.length&&!n(a[l])&&!ev.test(a[l])&&!/^\s{0,3}(#{1,6}\s|>)/.test(a[l])&&!(b.length>0&&ej.test(a[l]));){if(b.length>0&&/^\s{0,3}(=+|-+)\s*$/.test(a[l])){s.push({kind:"heading",level:a[l].trim().startsWith("=")?1:2,text:b.join(" ")}),b.length=0,l+=1;break}b.push(a[l++])}b.length>0&&s.push({kind:"para",text:b.join("\n")})}return s}(t),{dir:i,onOpenFile:l,t:n})})}var eS=a(75821);let eC=null,eF={plain:"plaintext",batch:"bat",vue:"html",toml:"ini",makefile:"plaintext"},eM=e=>{var t;return null!=(t=eF[e])?t:e};function eO(e,t){let a=function(){let e=document.documentElement,t=getComputedStyle(e),a=parseFloat(t.getPropertyValue("--scale"))||1;return{dark:"dark"===e.dataset.theme,size:Math.round(13*a*10)/10,background:t.getPropertyValue("--bg").trim()||"#ffffff",ink:t.getPropertyValue("--ink").trim()||"#000000"}}();e.editor.defineTheme("cop-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":a.dark?"#ffffff":a.background}}),e.editor.defineTheme("cop-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":a.dark?a.background:"#1e1e1e"}}),e.editor.setTheme(a.dark?"cop-dark":"cop-light"),null==t||t.updateOptions({fontSize:a.size})}function eE(e){let{path:t,value:n,language:i,onChange:r,onSave:c,onToggleMarkdown:o,goTo:d,label:u,reset:h}=e,{t:m}=(0,C.kj)(),p=(0,l.useRef)(null),f=(0,l.useRef)(null),x=(0,l.useRef)(null),[b,g]=(0,l.useState)(!1),[v,j]=(0,l.useState)(""),w=(0,l.useRef)({onChange:r,onSave:c,onToggleMarkdown:o});return w.current={onChange:r,onSave:c,onToggleMarkdown:o},(0,l.useEffect)(()=>{let e=!1,s=null;return(null!=eC||(eC=(async()=>{self.MonacoEnvironment={getWorker:(e,t)=>"json"===t?new Worker(a.tu(new URL(a.p+a.u(2355),a.b)),{type:void 0}):"css"===t||"scss"===t||"less"===t?new Worker(a.tu(new URL(a.p+a.u(7443),a.b)),{type:void 0}):"html"===t||"handlebars"===t||"razor"===t?new Worker(a.tu(new URL(a.p+a.u(7484),a.b)),{type:void 0}):"typescript"===t||"javascript"===t?new Worker(a.tu(new URL(a.p+a.u(7695),a.b)),{type:void 0}):new Worker(a.tu(new URL(a.p+a.u(2395),a.b)),{type:void 0})};let e=await Promise.all([a.e(3499),a.e(5591),a.e(2737),a.e(1384),a.e(5706),a.e(4008),a.e(9658)]).then(a.bind(a,39658)),t={noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0};for(let a of(e.typescript.typescriptDefaults.setDiagnosticsOptions(t),e.typescript.javascriptDefaults.setDiagnosticsOptions(t),e.json.jsonDefaults.setDiagnosticsOptions({...e.json.jsonDefaults.diagnosticsOptions,validate:!1}),[e.css.cssDefaults,e.css.scssDefaults,e.css.lessDefaults]))a.setOptions({...a.options,validate:!1});return e})()),eC).then(a=>{if(e||!p.current)return;x.current=a;let l=a.editor.createModel(n,eM(i),a.Uri.file("/workspace/".concat(t))),r=a.editor.create(p.current,{model:l,automaticLayout:!0,ariaLabel:u,minimap:{enabled:!0},scrollBeyondLastLine:!1,renderWhitespace:"selection",tabSize:2,detectIndentation:!0,fixedOverflowWidgets:!0,renderValidationDecorations:"off"});f.current=r,eO(a,r),p.current.copEditor=r,l.onDidChangeContent(()=>w.current.onChange(l.getValue())),r.addAction({id:"cop.save",label:m("ed.save"),keybindings:[a.KeyMod.CtrlCmd|a.KeyCode.KeyS],run:()=>w.current.onSave()}),r.addAction({id:"cop.markdownView",label:m("ed.viewPreview"),keybindings:[a.KeyMod.CtrlCmd|a.KeyMod.Shift|a.KeyCode.KeyV],precondition:void 0,run:()=>{var e,t;return null==(e=(t=w.current).onToggleMarkdown)?void 0:e.call(t)}}),(s=new MutationObserver(()=>eO(a,r))).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-textsize"]}),g(!0)}).catch(e=>j(e.message)),()=>{var t;e=!0,null==s||s.disconnect();let a=f.current;null==a||null==(t=a.getModel())||t.dispose(),null==a||a.dispose(),f.current=null}},[t]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&t.getValue()!==n&&t.pushEditOperations([],[{range:t.getFullModelRange(),text:n}],()=>null)},[h,b]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&x.current&&x.current.editor.setModelLanguage(t,eM(i))},[i,b]),(0,l.useEffect)(()=>{var e;null==(e=f.current)||e.updateOptions({ariaLabel:u})},[u]),(0,l.useEffect)(()=>{var e,t,a;let s=f.current,l=x.current,n=null==s?void 0:s.getModel();if(!d||!s||!l||!n)return;let i=Math.max(1,Math.min(d.line,n.getLineCount())),r=n.getLineLength(i),c=Math.min(null!=(e=d.from)?e:0,r)+1,o=Math.min(null!=(a=null!=(t=d.to)?t:d.from)?a:0,r)+1,u=new l.Range(i,c,i,o);s.setSelection(u),s.revealRangeNearTopIfOutsideViewport(u),s.focus()},[null==d?void 0:d.n,b]),(0,s.jsxs)("div",{className:"ed-code",children:[!b&&!v&&(0,s.jsx)("p",{className:"muted small ed-code-loading",children:m("ed.loading")}),v&&(0,s.jsx)("p",{className:"err small",children:m("ed.failed",{reason:v})}),(0,s.jsx)("div",{ref:p,className:"ed-monaco","data-ready":b?"yes":void 0})]})}let eL="cop.md.view";function eq(e){var t,a,n,i,r;let{dir:o,path:d,onDirty:u,goTo:h,onOpenFile:m}=e,{t:x}=(0,C.kj)(),[S,F]=(0,l.useState)(null),[O,E]=(0,l.useState)(""),[q,z]=(0,l.useState)(""),[I,D]=(0,l.useState)(""),[W,A]=(0,l.useState)(!1),[R,H]=(0,l.useState)(!1),[T,P]=(0,l.useState)(!1),[B,_]=(0,l.useState)("auto"),[$,K]=(0,l.useState)(0),U=!!S&&null!==S.text&&O!==S.text;(0,l.useEffect)(()=>null==u?void 0:u(d,U),[d,U,u]);let Z=(0,l.useCallback)(async e=>{try{var t,a;let s=await c.FH.workspaceFile(d,o).catch(t=>{let a=e&&404===t.status?y(o,d):null;if(!a)throw t;return P(!0),{path:d,text:"",binary:!1,tooLarge:!1,size:0,...a.version?{version:a.version}:{}}}),l=e?y(o,d):null;e||N(o,d),l&&null!==s.text&&l.text!==s.text?(F({...s,version:null!=(t=l.version)?t:s.version}),E(l.text)):(l&&N(o,d),F(s),E(null!=(a=s.text)?a:"")),K(e=>e+1),H(!1),z("")}catch(e){z(e.message)}},[d,o]),V=(0,l.useCallback)(()=>Z(!1),[Z]);(0,l.useEffect)(()=>{F(null),D(""),H(!1),Z(!0)},[Z]);let J=(0,l.useRef)(null),G=(0,l.useRef)(null),Y=(0,l.useCallback)(()=>{J.current&&(!function(e,t,a,s){var l;if(g.has(v(e,t)))return;let n=w(f),i=j(e);n[i]={...null!=(l=n[i])?l:{},[t]:{text:a,...s?{version:s}:{},at:new Date().toISOString()}},k(f,n)?b.delete(v(e,t)):b.add(v(e,t))}(o,d,J.current.text,J.current.version),G.current=J.current.text,J.current=null)},[o,d]);(0,l.useEffect)(()=>{if(!S||null===S.text)return;if(!U){J.current=null,function(e,t,a){if(null===a)return;let s=y(e,t);s&&s.text===a&&N(e,t)}(o,d,G.current),G.current=null;return}J.current={text:O,...S.version?{version:S.version}:{}};let e=setTimeout(Y,300);return()=>clearTimeout(e)},[U,O,S,o,d,Y]),(0,l.useEffect)(()=>(window.addEventListener("pagehide",Y),()=>{window.removeEventListener("pagehide",Y),Y()}),[Y]),(0,p.z)(async()=>{if(!(null==S?void 0:S.version)||W)return;let e=await c.FH.workspaceFile(d,o).catch(e=>(404===e.status&&P(!0),null));if(e&&P(!1),(null==e?void 0:e.version)&&e.version!==S.version)if(U)H(!0);else{var t;F(e),E(null!=(t=e.text)?t:""),K(e=>e+1)}},4e3,!!S);let Q="auto"===B?L(d,null!=(t=null==S?void 0:S.text)?t:""):B,X="markdown"===L(d,""),[ee,ea]=(0,l.useState)("preview");(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(eL);("code"===e||"split"===e||"preview"===e)&&ea(e)}catch(e){}},[]);let es=e=>{ea(e);try{window.localStorage.setItem(eL,e)}catch(e){}},el=X?ee:"code",en=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!X||"code"===el)return;let e=e=>{var t;if(!(e.ctrlKey||e.metaKey)||!e.shiftKey||e.altKey||"v"!==e.key.toLowerCase()||!en.current||en.current.closest("[hidden]"))return;let a=e.target;null!=a&&null!=(t=a.closest)&&t.call(a,'input, textarea, select, [contenteditable=""], [contenteditable="true"], .monaco-editor')||(e.preventDefault(),es("code"))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)});let ei=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(S&&!W){A(!0),D("");try{let a=await c.FH.saveWorkspaceFile(d,O,e||t?void 0:S.version,o,t);F({...S,text:O,version:a.version,size:a.size}),H(!1),P(!1),D(x("ed.saved"))}catch(e){409===e.status?H(!0):404===e.status?P(!0):D(e.message)}finally{A(!1)}}};return((0,l.useEffect)(()=>{h&&X&&"preview"===ee&&ea("split")},[null==h?void 0:h.n]),q&&!S)?(0,s.jsx)("p",{className:"err small",children:q}):S?S.binary||S.tooLarge?(0,s.jsxs)("div",{className:"wb-file",children:[(0,s.jsx)("p",{className:"muted small",children:x("wb.fileOnDisk",{path:S.path})}),(0,s.jsx)("p",{className:"muted",children:S.binary?x("wb.binary"):x("wb.tooLarge")})]}):(0,s.jsxs)("div",{className:"ed",ref:en,children:[(0,s.jsxs)("div",{className:"ed-bar",children:[(0,s.jsx)(et,{path:d}),(0,s.jsx)("span",{className:"ed-path",title:S.path,children:S.path}),(0,s.jsx)("span",{className:"small ".concat(U?"ed-dirty":"muted"),role:"status",children:U?x("ed.unsaved"):I||x("ed.clean")}),(0,s.jsx)("span",{className:"grow"}),X&&(0,s.jsx)("span",{className:"segmented ed-md-view",role:"group","aria-label":x("ed.view"),title:x("ed.viewWhy"),children:["code","split","preview"].map(e=>(0,s.jsx)("button",{type:"button","aria-pressed":ee===e,onClick:()=>es(e),children:x("code"===e?"ed.viewCode":"split"===e?"ed.viewSplit":"ed.viewPreview")},e))}),(0,s.jsx)("label",{htmlFor:"ed-lang-".concat(d),className:"sr-only",children:x("ed.language")}),(0,s.jsxs)("select",{id:"ed-lang-".concat(d),className:"ed-lang",value:B,onChange:e=>_(e.target.value),title:x("ed.language"),children:[(0,s.jsx)("option",{value:"auto",children:x("ed.langAuto",{name:(n=L(d,null!=(a=S.text)?a:""),null!=(r=null==(i=M.find(e=>e.id===n))?void 0:i.name)?r:n)})}),M.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,s.jsx)("button",{type:"button",className:"quiet small",disabled:!U||W,onClick:()=>{var e;E(null!=(e=S.text)?e:""),K(e=>e+1),D("")},children:x("ed.revert")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:!U||W,onClick:()=>void ei(),title:"Ctrl+S",children:x("ed.save")})]}),T&&(0,s.jsxs)("div",{className:"notice caution small ed-gone",role:"alert",children:[(0,s.jsx)("span",{children:x("ed.goneFromDisk")}),(0,s.jsx)("button",{type:"button",className:"small",disabled:W,onClick:()=>void ei(!1,!0),children:x("ed.saveAgain")})]}),R&&!T&&(0,s.jsxs)("div",{className:"notice caution small ed-conflict",role:"alert",children:[(0,s.jsx)("span",{children:x("ed.changedOnDisk")}),(0,s.jsx)("button",{type:"button",className:"small",onClick:()=>void V(),children:x("ed.reload")}),(0,s.jsx)("button",{type:"button",className:"small danger",onClick:()=>void ei(!0),children:x("ed.saveOver")})]}),(0,s.jsxs)("div",{className:"ed-body ed-show-".concat(el),children:["code"!==el&&(0,s.jsx)("div",{className:"ed-preview",children:(0,s.jsx)(eS.ErrorBoundary,{resetKey:O,children:(0,s.jsx)(eN,{text:O,path:d,onOpenFile:e=>null==m?void 0:m(e)})})}),"preview"!==el&&(0,s.jsx)(eE,{path:d,value:O,language:Q,onChange:E,onSave:()=>void ei(),onToggleMarkdown:X?()=>es("code"===ee?"preview":"code"):void 0,goTo:h,label:x("ed.label",{path:S.path}),reset:$})]})]}):(0,s.jsx)("p",{className:"muted small",children:x("wb.loading")})}function ez(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function eI(e,t){let a=function(e,t){let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];)a+=1;let s=e.length,l=t.length;for(;s>a&&l>a&&e[s-1]===t[l-1];)s-=1,l-=1;let n=[];for(let e=0;e<a;e+=1)n.push({kind:"same",a:e,b:e});for(let i of function(e,t){let a=e.length,s=t.length;if(0===a)return t.map((e,t)=>({kind:"add",b:t}));if(0===s)return e.map((e,t)=>({kind:"del",a:t}));let l=a+s,n=l+1,i=new Int32Array(2*l+3),r=[];for(let c=0;c<=Math.min(l,2e3);c+=1){r.push(i.slice(n-c-1,n+c+2));for(let l=-c;l<=c;l+=2){let o=l===-c||l!==c&&i[n+l-1]<i[n+l+1]?i[n+l+1]:i[n+l-1]+1,d=o-l;for(;o<a&&d<s&&e[o]===t[d];)o+=1,d+=1;if(i[n+l]=o,o>=a&&d>=s)return function(e,t,a,s){let l=[],n=t.length,i=a.length;for(let t=s;t>0;t-=1){let a=e[t],s=e=>a[e+t+1],r=n-i,c=r===-t||r!==t&&s(r-1)<s(r+1)?r+1:r-1,o=s(c),d=o-c;for(;n>o&&i>d;)n-=1,i-=1,l.push({kind:"same",a:n,b:i});n===o?l.push({kind:"add",b:d}):l.push({kind:"del",a:o}),n=o,i=d}for(;n>0&&i>0;)n-=1,i-=1,l.push({kind:"same",a:n,b:i});return l.reverse()}(r,e,t,c)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(a,s),t.slice(a,l)))n.push({kind:i.kind,...void 0!==i.a?{a:i.a+a}:{},...void 0!==i.b?{b:i.b+a}:{}});for(let t=0;s+t<e.length;t+=1)n.push({kind:"same",a:s+t,b:l+t});return n}(e,t),s=[];for(let l=0;l<a.length;){let n=a[l];if("same"===n.kind){s.push({kind:"same",left:{no:n.a+1,text:e[n.a]},right:{no:n.b+1,text:t[n.b]}}),l+=1;continue}let i=[],r=[];for(;l<a.length&&"same"!==a[l].kind;){let e=a[l];"del"===e.kind?i.push(e.a):r.push(e.b),l+=1}let c=Math.max(i.length,r.length);for(let a=0;a<c;a+=1){let l=i[a],n=r[a];s.push({kind:void 0!==l&&void 0!==n?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==n?{right:{no:n+1,text:t[n]}}:{}})}}return s}function eD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let s=0;s<e.length;){if("same"!==e[s].kind){l.push({type:"row",row:e[s],index:s}),s+=1;continue}let n=s;for(;n<e.length&&"same"===e[n].kind;)n+=1;let i=0===s?0:t,r=n===e.length?0:t,c=n-s-i-r;if(c>1&&!a.has(s+i)){for(let t=s;t<s+i;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:s+i,count:c});for(let t=n-r;t<n;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=s;t<n;t+=1)l.push({type:"row",row:e[t],index:t});s=n}return l}var eW=a(94969);function eA(e){let{sessionId:t,taskId:a,runId:n,title:i,files:r}=e,{t:c}=(0,C.kj)(),[o,d]=(0,l.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>d(!0),title:c("diff.openWhy"),children:c("diff.open",{n:r})}),o&&(0,s.jsx)(eR,{sessionId:t,taskId:a,runId:n,title:i,onClose:()=>d(!1)})]})}function eR(e){var t,a,n,i,r,o,d;let{sessionId:u,taskId:h,runId:m,title:p,onClose:f}=e,{t:x}=(0,C.kj)(),[b,g]=(0,l.useState)(null),[v,j]=(0,l.useState)(""),[w,k]=(0,l.useState)(0),[y,N]=(0,l.useState)(new Map),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!0),[E,L]=(0,l.useState)(new Map),[q,z]=(0,l.useState)(-1),I=(0,l.useRef)(null),D=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,eW.V)(D,!0,W),(0,l.useEffect)(()=>{c.FH.taskChanges(u,h,m).then(g).catch(e=>j(e.message))},[u,h,m]);let A=null!=(n=null==b?void 0:b.files)?n:[],R=A[w];(0,l.useEffect)(()=>{!R||y.has(R.path)||c.FH.taskChangeFile(u,h,R.path,m).then(e=>N(t=>new Map(t).set(R.path,e))).catch(e=>N(t=>new Map(t).set(R.path,e.message)))},[R,y,u,h,m]);let H=R?y.get(R.path):void 0,T=(0,l.useMemo)(()=>!H||"string"==typeof H||H.binary||H.tooLarge?[]:eI(ez(H.before),ez(H.after)),[H]),P=R&&E.get(R.path)||new Set,B=(0,l.useMemo)(()=>eD(T,3,P,S),[T,P,S]),_=(0,l.useMemo)(()=>T.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===T[t-1].kind)?[t]:[]),[T]);(0,l.useEffect)(()=>{z(-1),I.current&&(I.current.scrollTop=0)},[w]);let $=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let a=q<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,q+e));z(a);let s=null==(t=I.current)?void 0:t.querySelector('[data-row="'.concat(_[a],'"]'));null==s||s.scrollIntoView({block:"center"})},[q,_]),K=(0,l.useCallback)(e=>k(t=>Math.min(Math.max(0,t+e),Math.max(0,A.length-1))),[A.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)f();else if("n"===e.key)$(1);else if("p"===e.key)$(-1);else if("]"===e.key)K(1);else{if("["!==e.key)return;K(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[$,K,f]);let U=A.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,s.jsxs)("div",{ref:D,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,s.jsxs)("div",{className:"diff-head",children:[(0,s.jsx)("h2",{id:"diff-title",children:x("diff.title",{title:p})}),(null==b?void 0:b.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[b.branch?"".concat(b.branch," \xb7 "):"",null==(t=b.base)?void 0:t.slice(0,8)," → ",null==(a=b.commit)?void 0:a.slice(0,8)," \xb7 ",x("diff.summary",{n:A.length,a:U.added,r:U.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:x("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:f,children:x("diff.close")})]}),v&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:v}),!b&&!v&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:x("diff.loading")}),b&&!b.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:b.problem}),(null==b?void 0:b.ok)&&0===A.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.nothing")}),(null==b?void 0:b.ok)&&A.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":x("diff.files"),children:A.map((e,t)=>{let a=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===w?" on":""),onClick:()=>k(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,s.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,s.jsxs)("span",{className:"diff-path",children:[a>=0&&(0,s.jsx)("span",{className:"muted",children:e.path.slice(0,a+1)}),(0,s.jsx)("strong",{children:e.path.slice(a+1)})]}),(0,s.jsx)("span",{className:"diff-counts",children:e.added<0?x("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,s.jsxs)("div",{className:"diff-main",children:[R&&(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsxs)("div",{className:"diff-title-row",children:[(0,s.jsx)("strong",{className:"diff-name",children:R.oldPath?"".concat(R.oldPath," → ").concat(R.path):R.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===R.status?x("diff.added"):"D"===R.status?x("diff.deleted"):"R"===R.status?x("diff.renamed"):""})]}),(0,s.jsx)(eH,{changes:_.length,onChange:$,files:{at:w,count:A.length,onFile:K},whole:S,onWhole:F,wrap:M,onWrap:O})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:I,children:[void 0===H&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:x("diff.loading")}),"string"==typeof H&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:H}),H&&"string"!=typeof H&&H.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.binary")}),H&&"string"!=typeof H&&H.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.tooLarge")}),H&&"string"!=typeof H&&!H.binary&&!H.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(i=H.before)?i:"").includes("\r\n")!==(null!=(r=H.after)?r:"").includes("\r\n")&&null!==H.before&&null!==H.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:x("diff.eol",{from:(null!=(o=H.before)?o:"").includes("\r\n")?"CRLF":"LF",to:(null!=(d=H.after)?d:"").includes("\r\n")?"CRLF":"LF"})}),T.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:x("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(M?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)(eT,{changes:_.length,at:q}),(0,s.jsx)("tbody",{children:B.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(R&&L(e=>{var a;return new Map(e).set(R.path,new Set([...null!=(a=e.get(R.path))?a:[],t]))}))},children:x("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eP,{row:e.row,index:e.index,current:q>=0&&_[q]===e.index},e.index))})]})]})]})]})]})]})}function eH(e){let{changes:t,onChange:a,files:l,whole:n,onWhole:i,wrap:r,onWrap:c}=e,{t:o}=(0,C.kj)();return(0,s.jsxs)("div",{className:"diff-tools",children:[(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>a(-1),disabled:0===t,children:o("diff.prevChange")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>a(1),disabled:0===t,children:o("diff.nextChange")})]}),l&&l.count>1&&(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>l.onFile(-1),disabled:0===l.at,children:o("diff.prevFile")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>l.onFile(1),disabled:l.at>=l.count-1,children:o("diff.nextFile")})]}),(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:e=>i(e.target.checked)})," ",o("diff.whole")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:r,onChange:e=>c(e.target.checked)})," ",o("diff.wrap")]})]})]})}function eT(e){let{changes:t,at:a}=e,{t:l}=(0,C.kj)();return(0,s.jsxs)("thead",{children:[t>0&&(0,s.jsx)("tr",{className:"diff-where",children:(0,s.jsx)("th",{colSpan:4,children:l("diff.changeN",{i:a<0?"–":a+1,n:t})})}),(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{colSpan:2,children:l("diff.before")}),(0,s.jsx)("th",{colSpan:2,children:l("diff.after")})]})]})}function eP(e){var t,a,n,i;let{row:r,index:c,current:o}=e,d="change"===r.kind?function(e,t){let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];)a+=1;let s=e.length,l=t.length;for(;s>a&&l>a&&e[s-1]===t[l-1];)s-=1,l-=1;return{start:a,leftEnd:s,rightEnd:l}}(r.left.text,r.right.text):null,u=e=>{let t=r[e];if(!t)return null;if(!d)return t.text;let a="left"===e?d.leftEnd:d.rightEnd;return(0,s.jsxs)(l.Fragment,{children:[t.text.slice(0,d.start),(0,s.jsx)("mark",{children:t.text.slice(d.start,a)}),t.text.slice(a)]})};return(0,s.jsxs)("tr",{className:"diff-row ".concat(r.kind).concat(o?" current":""),"data-row":c,children:[(0,s.jsx)("td",{className:"num",children:null!=(n=null==(t=r.left)?void 0:t.no)?n:""}),(0,s.jsx)("td",{className:"code l".concat(r.left?"":" empty"),children:u("left")}),(0,s.jsx)("td",{className:"num",children:null!=(i=null==(a=r.right)?void 0:a.no)?i:""}),(0,s.jsx)("td",{className:"code r".concat(r.right?"":" empty"),children:u("right")})]})}function eB(e){var t;let{area:a,path:n,commit:i}=e,{t:r}=(0,C.kj)(),[o,d]=(0,l.useState)(null),[u,h]=(0,l.useState)(""),[m,f]=(0,l.useState)(!1),[x,b]=(0,l.useState)(!0),[g,v]=(0,l.useState)(new Set),[j,w]=(0,l.useState)(-1),k=(0,l.useRef)(null),y=(0,l.useCallback)(()=>c.FH.workspaceGitFile(a,n,i).then(e=>{d(e),h("")}).catch(e=>h(e.message)),[a,n,i]);(0,l.useEffect)(()=>{d(null),h(""),v(new Set),w(-1),y()},[y]),(0,p.z)(y,5e3,"commit"!==a);let N=(0,l.useMemo)(()=>!o||o.binary||o.tooLarge?[]:eI(ez(o.before),ez(o.after)),[o]),S=(0,l.useMemo)(()=>eD(N,3,g,m),[N,g,m]),F=(0,l.useMemo)(()=>N.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===N[t-1].kind)?[t]:[]),[N]),M="commit"===a?(null!=i?i:"").slice(0,7):"branch"===a?r("git.againstBase",{base:null!=i?i:""}):r("staged"===a?"git.index":"git.workingTree"),O=null!=(t=null==o?void 0:o.status)?t:"";return(0,s.jsxs)("div",{className:"wb-gitdiff",children:[(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsxs)("div",{className:"diff-title-row",children:[(0,s.jsx)("strong",{className:"diff-name",children:(null==o?void 0:o.oldPath)?"".concat(o.oldPath," → ").concat(n):n}),(0,s.jsxs)("span",{className:"muted small",children:[M,O?" \xb7 ".concat(r("git.status.".concat("!"===O?"conflict":O))):""]})]}),(0,s.jsx)(eH,{changes:F.length,onChange:e=>{var t,a;if(0===F.length)return;let s=j<0?1===e?0:F.length-1:Math.min(F.length-1,Math.max(0,j+e));w(s),null==(a=k.current)||null==(t=a.querySelector('[data-row="'.concat(F[s],'"]')))||t.scrollIntoView({block:"center"})},whole:m,onWhole:f,wrap:x,onWrap:b})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:k,children:[u&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:u}),!o&&!u&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:r("diff.loading")}),(null==o?void 0:o.binary)&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:r("diff.binary")}),(null==o?void 0:o.tooLarge)&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:r("diff.tooLarge")}),o&&!o.binary&&!o.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[N.length>0&&0===F.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:r("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(x?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)(eT,{changes:F.length,at:j}),(0,s.jsx)("tbody",{children:S.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>v(t=>new Set([...t,e.from])),children:r("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eP,{row:e.row,index:e.index,current:j>=0&&F[j]===e.index},e.index))})]})]})]})]})}var e_=a(61238),e$=a(52157);let eK="",eU=new Set;function eZ(e){if(e!==eK)for(let t of(eK=e,eU))t()}function eV(e){return eU.add(e),()=>{eU.delete(e)}}function eJ(){return[(0,l.useSyncExternalStore)(eV,()=>eK,()=>""),eZ]}var eG=a(41370),eY=a(33389),eQ=a(68176);function eX(e,t){let[a,s]=(0,l.useState)(null),n=(0,l.useRef)(!0),[i,r]=(0,l.useState)(!0),c=(0,l.useRef)(e);c.current=e;let o=(0,l.useRef)(null),d=(0,l.useRef)(0),u=(0,l.useRef)(new Set),h=(0,l.useCallback)(e=>s(e),[]),m=(0,l.useCallback)(e=>{n.current!==e&&(n.current=e,r(e))},[]),p=e=>[...e.querySelectorAll("[data-awaits]")].filter(e=>!e.closest("[data-kerrigan-thinking]")),f=e=>{var t;return null!=(t=e.closest("[data-awaits-frame]"))?t:e},x=(e,t,a)=>{let s=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,l=e.clientHeight-t.offsetHeight;return a&&l>24?s-l/2:s-12},b=(e,t)=>{let a=e.scrollHeight-e.clientHeight;e.scrollTop=Math.max(0,Math.min(a,t)),o.current=e.scrollTop,d.current=e.scrollTop},g=e=>{let t=p(e)[0],a=e.scrollHeight-e.clientHeight;b(e,t?Math.min(a,x(e,f(t),!1)):a)},v=e=>{var t;if(0===e.clientHeight)return!1;let a=p(e),s=a.filter(e=>{var t;return!u.current.has(null!=(t=e.dataset.awaits)?t:"")});for(let e of a)u.current.add(null!=(t=e.dataset.awaits)?t:"");let l=s[0];return!!l&&(n.current?g(e):b(e,x(e,f(l),!0)),!0)};return(0,l.useLayoutEffect)(()=>{if(!a)return;a.dataset.follow="",d.current=a.scrollTop;let e=()=>{let e=a.scrollTop,t=a.scrollHeight-e-a.clientHeight<=24,s=null!==o.current&&1>=Math.abs(e-o.current);o.current=null,t?m(!0):!s&&e<d.current-1&&m(!1),d.current=e},t=()=>{c.current&&!v(a)&&n.current&&g(a)},s=new ResizeObserver(t);for(let e of(s.observe(a),a.children))s.observe(e);let l=new MutationObserver(e=>{for(let t of e){for(let e of t.addedNodes)e instanceof Element&&e.parentElement===a&&s.observe(e);for(let e of t.removedNodes)e instanceof Element&&s.unobserve(e)}t()});return l.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-awaits","data-kerrigan-thinking"]}),a.addEventListener("scroll",e,{passive:!0}),()=>{a.removeEventListener("scroll",e),s.disconnect(),l.disconnect(),delete a.dataset.follow}},[a,m]),(0,l.useLayoutEffect)(()=>{a&&e&&!v(a)&&n.current&&g(a)},[a,e,t]),{ref:h,following:i,follow:(0,l.useCallback)(()=>{n.current=!0,r(!0),a&&g(a)},[a])}}var e0=a(51035),e1=a(24784),e2=a(65132),e3=a(36657),e4=a(92842),e5=a(79717);let e6={done:"✓",running:"●",planned:"○",blocked:"⊘",failed:"✗",stopped:"■"},e8={done:"lead.todo.done",running:"lead.todo.running",planned:"lead.todo.planned",blocked:"lead.todo.blocked",failed:"lead.todo.failed",stopped:"lead.todo.stopped"};function e7(e){var t,a;let s=[];for(let t of e.items)t.phase&&!s.includes(t.phase)&&s.push(t.phase);let l=null!=(a=null!=(t=e.items.find(e=>"running"===e.status))?t:e.items.find(e=>"planned"===e.status))?a:e.items.at(-1);return{phases:s,current:(null==l?void 0:l.phase)?s.indexOf(l.phase):-1}}function e9(e){let{lead:t,live:a}=e,{t:l}=(0,C.kj)(),n=t.ledger;if(!n||0===n.items.length)return(0,s.jsx)("p",{className:"muted small cs-lead-progress",children:l("lead.subtasks",{n:t.subtasks,max:t.maxSubtasks})});let i=n.items,r=e=>i.filter(t=>t.status===e).length,c=i.findIndex(e=>"running"===e.status),o=r("blocked")+r("failed"),{phases:d,current:u}=e7(n);return(0,s.jsxs)("div",{className:"cs-lead-progress",role:"status",children:[d.length>0&&u>=0&&(0,s.jsx)("p",{className:"cs-lead-phase",children:l("lead.phase",{n:u+1,total:d.length,title:d[u]})}),(0,s.jsxs)("p",{className:"small",children:[(0,s.jsx)("strong",{children:a&&c>=0?l("lead.subtaskOf",{n:c+1,total:i.length}):l("lead.doneOf",{done:r("done"),total:i.length})}),o>0&&(0,s.jsxs)("span",{className:"cs-lead-stuck",children:[" \xb7 ",l("lead.stuck",{n:o})]})]}),(0,s.jsx)("p",{className:"muted small",children:l("lead.left",{left:r("planned"),max:t.maxSubtasks})}),(0,s.jsx)(te,{ledger:n,live:a})]})}function te(e){let{ledger:t,live:a}=e,{t:l}=(0,C.kj)(),{phases:n}=e7(t),i=0===n.length?[{phase:"",items:t.items}]:[];if(n.length>0){for(let e of n)i.push({phase:e,items:t.items.filter(t=>t.phase===e)});let e=t.items.filter(e=>!e.phase);e.length>0&&i.push({phase:l("lead.otherPhase"),items:e})}let r=i.map(e=>[...e.phase?["## ".concat(e.phase)]:[],...e.items.map(e=>"".concat(e6["running"===e.status&&!a?"stopped":e.status]," ").concat(e.title).concat(e.n?" (#".concat(e.n,")"):""))].join("\n")).join("\n\n");return(0,s.jsxs)("details",{className:"cs-ledger",children:[(0,s.jsx)("summary",{children:l("lead.ledgerList",{v:t.revision})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:r,what:"lead.copyList"})}),i.map(e=>(0,s.jsxs)("div",{className:"cs-ledger-group",children:[e.phase&&(0,s.jsx)("p",{className:"cs-ledger-phase",children:e.phase}),(0,s.jsx)("ul",{children:e.items.map(e=>{let t="running"!==e.status||a?e.status:"stopped";return(0,s.jsxs)("li",{className:"cs-todo cs-todo-".concat(t),children:[(0,s.jsx)("span",{className:"cs-todo-mark",title:l(e8[t]),"aria-label":l(e8[t]),children:e6[t]}),(0,s.jsx)("span",{className:"cs-todo-title",children:e.title}),e.n?(0,s.jsxs)("span",{className:"muted small",title:l("lead.givenAs",{n:e.n}),children:[" ","#",e.n]}):null]},e.title)})})]},e.phase||"-"))]})}function tt(e){let{change:t}=e,{t:a}=(0,C.kj)();if(1===t.revision)return(0,s.jsx)("p",{className:"cs-system cs-ledger-change",children:a("lead.ledgerFirst",{n:t.total})});let l=[t.added>0?a("lead.ledgerAdded",{n:t.added}):"",t.removed>0?a("lead.ledgerRemoved",{n:t.removed}):""].filter(Boolean).join(", ")||a("lead.ledgerReordered");return(0,s.jsx)("p",{className:"cs-system cs-ledger-change",children:a("lead.ledgerChanged",{v:t.revision,what:l})})}function ta(e){var t,a;let{workspace:n,running:i,queue:r=!1,onMade:c}=e,{t:o}=(0,C.kj)(),[d,u]=(0,l.useState)(!1),h=(t={running:i,queue:r,workspace:n}).running?o("nb.offRunning"):t.queue?o("nb.offQueue"):(null==(a=t.workspace)?void 0:a.ok)?t.workspace.isRepo?"":o("nb.offNoRepo"):o("nb.offNoFolder");return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"button-link plain small cs-new-branch","aria-disabled":!!h||void 0,onClick:()=>!h&&u(!0),title:h||o("nb.buttonWhy"),children:o("nb.button")}),d&&(0,s.jsx)(ts,{onClose:()=>u(!1),onMade:e=>{u(!1),c(e)}})]})}function ts(e){var t,a,n,i,r,o,d,u,h,m,p;let{onClose:f,onMade:x}=e,{t:b}=(0,C.kj)(),g=(0,C.W3)(),v=(0,l.useRef)(null),j=(0,l.useRef)(null),[w,k]=(0,l.useState)(null),[y,N]=(0,l.useState)(!0),[S,F]=(0,l.useState)(""),[M,O]=(0,l.useState)("take"),[E,L]=(0,l.useState)(""),[q,z]=(0,l.useState)(!1),[I,D]=(0,l.useState)(""),[W,A]=(0,l.useState)(!1),R=(0,eG.q)(y||q);(0,eW.V)(v,!0,j);let H=async e=>{N(!0),D(""),A(!1);try{let t=await c.FH.newBranchPreview(e);k(t),t.suggested&&F(e=>e||t.suggested)}catch(e){k(null),D(e.message)}finally{N(!1)}};(0,l.useEffect)(()=>{H(!0)},[]),(0,l.useEffect)(()=>{let e=e=>{"Escape"!==e.key||q||(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[q,f]);let T=async()=>{if(null==w?void 0:w.fingerprint){z(!0),D(""),A(!1);try{let e=await c.FH.newBranchCreate(S.trim(),M,w.fingerprint,"commit"===M?E:void 0);if(e.ok)return void x(e.result);D(e.problem),e.conflict&&(A(!0),O("aside"))}catch(e){D(e.message)}finally{z(!1)}}},P=(null!=(t=null==w?void 0:w.changed.length)?t:0)+(null!=(a=null==w?void 0:w.untracked.length)?a:0),B=(null==w?void 0:w.fetched)&&!w.fetched.ok,_=[...null!=(n=null==w?void 0:w.changed)?n:[],...null!=(i=null==w?void 0:w.untracked)?i:[]];return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!q&&f(),children:(0,s.jsxs)("div",{ref:v,className:"modal wide nb",role:"dialog","aria-modal":"true","aria-labelledby":"nb-title",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{id:"nb-title",children:b("nb.title")}),y?(0,s.jsxs)("div",{className:"nb-reading",role:"status",children:[(0,s.jsxs)("p",{children:[b("nb.fetching"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}),(0,s.jsx)("p",{className:"muted small",children:b("nb.passwordNote")})]}):(0,s.jsxs)(s.Fragment,{children:[(null==w?void 0:w.ok)&&(0,s.jsxs)(s.Fragment,{children:[B&&(0,s.jsxs)("div",{className:"nb-warn",role:"alert",children:[(0,s.jsx)("p",{children:b(w.fetched.auth?"nb.fetchAuth":"nb.fetchFailed",{remote:null!=(r=w.remote)?r:"origin",detail:null!=(o=w.fetched.detail)?o:""})}),(0,s.jsx)("p",{className:"small",children:w.lastFetched?b("nb.lastFetched",{target:null!=(d=w.target)?d:"",at:g(w.lastFetched)}):b("nb.lastKnown",{target:null!=(u=w.target)?u:""})}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",onClick:()=>void H(!0),disabled:q,children:b("nb.tryAgain")})})]}),(0,s.jsxs)("p",{className:"nb-from",children:[b("nb.from",{target:null!=(h=w.target)?h:"",commit:(null!=(m=w.targetCommit)?m:"").slice(0,8)})," ",w.targetSubject&&(0,s.jsxs)("span",{className:"muted",children:["— ",w.targetSubject]})]}),(0,s.jsx)("p",{className:"small muted",children:w.branch?b("nb.now",{branch:w.branch}):b("nb.nowDetached")}),(0,s.jsxs)("div",{className:"settings-field",children:[(0,s.jsx)("label",{htmlFor:"nb-name",className:"field-label",children:b("nb.name")}),(0,s.jsx)("input",{id:"nb-name",type:"text",dir:"ltr",value:S,onChange:e=>F(e.target.value),spellCheck:!1,disabled:q})]}),P>0&&(0,s.jsxs)("fieldset",{className:"nb-dirty",children:[(0,s.jsx)("legend",{children:b("nb.dirty",{n:P})}),(0,s.jsxs)("ul",{className:"small nb-files",children:[_.slice(0,8).map(e=>(0,s.jsx)("li",{children:(0,s.jsx)("code",{children:e})},e)),_.length>8&&(0,s.jsx)("li",{className:"muted",children:b("nb.more",{n:_.length-8})})]}),(0,s.jsxs)("label",{className:"nb-choice",children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"take"===M,onChange:()=>O("take"),disabled:W||q}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.take")})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.takeWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"aside"===M,onChange:()=>O("aside"),disabled:q}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.aside")})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.asideWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",title:w.branch?void 0:b("nb.commitDetached"),children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"commit"===M,onChange:()=>O("commit"),disabled:q||!w.branch}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.commit",{branch:null!=(p=w.branch)?p:"—"})})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.commitWhy")})]})]}),"commit"===M&&w.branch&&(0,s.jsxs)("div",{className:"settings-field nb-message",children:[(0,s.jsx)("label",{htmlFor:"nb-message",className:"field-label",children:b("nb.commitMessage")}),(0,s.jsx)("input",{id:"nb-message",type:"text",value:E,onChange:e=>L(e.target.value),placeholder:"Work in progress, before a new branch from main",disabled:q,maxLength:2e3})]})]}),(0,s.jsx)("p",{className:"muted small",children:b("nb.after")})]}),I&&(0,s.jsx)("p",{className:"err",role:"alert",children:I})]}),(0,s.jsxs)("div",{className:"row modal-actions",children:[(0,s.jsx)("button",{ref:j,type:"button",className:"quiet",onClick:f,disabled:q,children:b("nb.cancel")}),!y&&!(null==w?void 0:w.ok)&&(0,s.jsx)("button",{type:"button",onClick:()=>void H(!0),children:b("nb.tryAgain")}),!y&&(null==w?void 0:w.ok)&&I&&!q&&(0,s.jsx)("button",{type:"button",onClick:()=>void H(!0),children:b("nb.tryAgain")}),!y&&(null==w?void 0:w.ok)&&(0,s.jsx)("button",{type:"button",className:"primary",onClick:()=>void T(),disabled:q||!S.trim(),"aria-busy":q||void 0,children:q?(0,s.jsxs)(s.Fragment,{children:[b("nb.making"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}):b(B?"nb.makeFromLast":"nb.make")})]})]})})}var tl=a(34982),tn=a(44504),ti=a(14236);let tr="cop.chat.thread",tc="cop.chat.plan",to="cop.chat.review",td="cop.chat.lead",tu="cop.chat.kerrigan",th=(e,t)=>{try{t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e)}catch(e){}},tm=e=>{try{var t;return null!=(t=window.localStorage.getItem(e))?t:""}catch(e){return""}};function tp(e){var t,a,n,r,o,d,u,h,m,f,x,b,g,v,j,w,k,y,N,S,F,M;let{workspace:O,composeAsk:E,showThread:L,onOpenFile:q,onChange:z,onOpenFolder:I,onTurn:D}=e,{t:W,locale:A}=(0,C.kj)(),[R,H]=(0,l.useState)([]),[T,P]=(0,l.useState)(""),[B,_]=(0,l.useState)(null),[$,K]=(0,l.useState)(!1),[U,Z]=(0,l.useState)(!0),[V,J]=(0,l.useState)(""),[G,Y]=(0,l.useState)(!1),[Q,X]=(0,l.useState)(""),[ee,et]=(0,l.useState)(!1),[ea,es]=(0,l.useState)(null),[el,ei]=(0,l.useState)(""),[er,ec]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(""),[eu,eh]=(0,l.useState)([]),[em,ep]=(0,l.useState)(null),[ef,ex]=(0,l.useState)(""),[eb,eg]=(0,l.useState)(!1),[ev,ej]=(0,l.useState)([]),[ew,ek]=eJ(),ey=(0,l.useRef)(null),eN=!!B&&("idle"!==B.status||!!B.directedBy&&B.tasks.some(e=>"running"===e.status||"waiting-approval"===e.status)),eS=B?!!B.lead||!!B.kerrigan:G||ee,eC=null!=(m=(B?!!B.kerrigan:ee)?(null==em?void 0:em.defaultKerriganModel)||(null==em?void 0:em.defaultLeadModel)||(null==em?void 0:em.defaultModel):eS&&(null==em?void 0:em.defaultLeadModel)||(null==em?void 0:em.defaultModel))?m:"",eF=null!=(f=null==em?void 0:em.defaultModel)?f:"",eM=B?!B.manualModel&&(B.model||eC)?null!=(x=B.model)?x:"":e1.u:"",eO=ef!==e1.u&&(ef||eC)?ef:e1.u;(0,l.useEffect)(()=>{P(tm(tr)),K("on"===tm(tc)),Z("off"!==tm(to)),Y("on"===tm(td)&&"on"!==tm(tu)),et("on"===tm(tu))},[]),(0,l.useEffect)(()=>{var e;E>0&&(null==(e=ey.current)||e.focus())},[E]),(0,l.useEffect)(()=>{(null==L?void 0:L.id)&&eT(L.id)},[null==L?void 0:L.n]),(0,l.useEffect)(()=>{c.FH.models().then(ep).catch(()=>void 0),c.FH.skills().then(e=>ej(e.skills)).catch(()=>void 0)},[]);let eE=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),eL=ev.filter(e=>!e.projectDir||(null==O?void 0:O.dir)&&eE(e.projectDir)===eE(O.dir)),eq=(0,l.useCallback)(()=>c.FH.chatThreads().then(H).catch(()=>void 0),[]);(0,p.z)(eq,5e3);let ez=(0,l.useRef)(T);ez.current=T;let eI=(0,l.useCallback)(()=>{let e=ez.current;return e?c.FH.session(e).then(t=>{ez.current===e&&_("chat"===t.kind?t:null)}).catch(t=>{404===t.status&&ez.current===e&&(_(null),P(""),th(tr,""))}):Promise.resolve(_(null))},[]);(0,l.useEffect)(()=>{eI()},[T,eI]),(0,p.z)(eI,eN?1500:5e3,!!T);let eD=(0,l.useRef)(new Set),eW=()=>T&&eN?c.FH.approvals(T).then(e=>eh(e.filter(e=>!eD.current.has(e.id)))).catch(()=>void 0):Promise.resolve(eh([]));(0,p.z)(eW,1500,!!T);let eA=(e,t)=>{t&&(eD.current.add(e),eh(t=>t.filter(t=>t.id!==e))),eW()},eR=null!=(b=null==B||null==(t=B.lead)?void 0:t.workerSessionId)?b:"",eH=(0,l.useCallback)(()=>eR?c.FH.session(eR).then(es).catch(()=>void 0):Promise.resolve(es(null)),[eR]);(0,l.useEffect)(()=>{eH()},[eH]),(0,p.z)(eH,eN?1500:1e4,!!eR);let eT=e=>{ez.current=e,P(e),th(tr,e),ed(""),eZ(null)},eP=e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-model",className:"sr-only",children:W("chat.model")}),(0,s.jsx)(e1.Yb,{id:"cs-model",chosen:B?eM:eO,onChange:e=>void e6(e),byHand:W("chat.modelByHand"),none:eC?W("chat.modelDefault",{model:eC}):void 0,catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:e}}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void tt(),disabled:eb||eN,title:W("chat.readModels"),"aria-label":W("chat.readModels"),children:"↻"})]}),eB=eN||R.some(e=>e.running),e$=eB?W("chat.newChatRunning"):B?"":W("chat.newChatFresh"),eK=()=>{var e;eT(""),_(null),null==(e=ey.current)||e.focus()},[eU,eZ]=(0,l.useState)(null),eV=e=>e.replace(/^chat: /,""),eY=async()=>{var e;let t=null!=(e=null==eU?void 0:eU.trim())?e:"";if(B&&t)try{let e=await c.FH.updateSession(B.id,{name:t});_(t=>t&&t.id===e.id?{...t,name:e.name}:t),H(t=>t.map(t=>t.id===e.id?{...t,name:e.name}:t)),eZ(null),ed("")}catch(e){ed(e.message)}},eQ=async()=>{let e=el.trim();if(!e||er)return;let t=ew,a=eL.length>0?/^\/([a-z0-9][a-z0-9-]*[a-z0-9])(?=\s|$)\s*([\s\S]*)$/.exec(e):null;if(a){let s=eL.find(e=>e.name===a[1]);if(!s)return void ed(W("chat.skillUnknown",{name:a[1],names:eL.map(e=>"/".concat(e.name)).join(", ")}));if(!a[2].trim())return void ed(W("chat.skillNoText",{name:s.name}));t=s.name,e=a[2].trim()}ec(!0),ed("");try{var s;let a=!T,l=a&&ef===e1.u,n=a&&G&&!ee?{workerModel:Q===e1.u?void 0:Q||void 0,workerManualModel:Q===e1.u}:void 0,i=a&&ee?{chatModel:Q===e1.u?void 0:Q||void 0,chatManualModel:Q===e1.u}:void 0,r=await c.FH.chatSend(e,T||void 0,a&&!l&&ef||void 0,l,A,a&&$&&!i,a?!n&&!i&&U:void 0,n,t||void 0,a&&!n&&!i&&V||void 0,i);if(ei(""),ek(""),eT(r.threadId),r.noted)return void ed(W("chat.noted"));let o=await c.FH.settings().then(e=>{var t;return(null==(t=e.raw.execution)?void 0:t.mode)==="unattended"?"unattended":"confirm"}).catch(()=>"confirm"),d=await c.FH.start(r.threadId,o);d.started||ed(W("chat.notStarted",{reason:null!=(s=d.reason)?s:""}))}catch(e){ed(e.message)}finally{ec(!1),eI(),eq(),z()}},e2=async(e,t,a)=>{if(!B||er)return!1;ec(!0),ed("");let s=!1;try{var l;let n=await c.FH.chatRetrySubtask(B.id,e.id,t,a);s=n.started,n.started||ed(null!=(l=n.reason)?l:W("retry.notStarted"))}catch(e){ed(e.message)}finally{ec(!1),eI()}return s},e3=async e=>{if(B&&!er){ec(!0),ed("");try{var t;let a=await c.FH.chatContinue(B.id,e.id);a.started||ed(null!=(t=a.reason)?t:W("chat.carryOnNotStarted"))}catch(e){ed(e.message)}finally{ec(!1),eI(),eq(),z()}}},e4=async e=>{if(B&&!er&&await (0,e0.Z)(W("chat.rewindConfirm",{n:B.tasks.length-B.tasks.indexOf(e)}))){ec(!0),ed("");try{var t;let a=await c.FH.chatRewind(B.id,e.id);ei(a.text),ed(W("chat.rewound")),null==(t=ey.current)||t.focus()}catch(e){ed(e.message)}finally{ec(!1),eI(),z()}}},e5=async e=>{if(B){_(t=>{var a;if(!t)return t;let{review:s,workerModel:l,workerManualModel:n,...i}=e;return{...t,...i,...s?{review:{...null!=(a=t.review)?a:{enabled:!0,model:""},...s}}:{},...(null==s?void 0:s.model)!==void 0?{reviewModelSource:s.model?"operator":void 0}:{},...t.lead&&(void 0!==l||void 0!==n)?{lead:{...t.lead,workerManualModel:n||void 0,workerModel:n?void 0:l||void 0}}:{},...t.kerrigan&&(void 0!==l||void 0!==n)?{kerrigan:{chatManualModel:n||void 0,chatModel:n?void 0:l||void 0}}:{}}});try{await c.FH.updateSession(B.id,e)}catch(e){ed(e.message)}finally{eI()}}},e6=async e=>{if(!B)return void ex(e);await e5(e===e1.u?{model:"",manualModel:!0}:{model:e,manualModel:!1})},e8=B?!!B.lead:G&&!ee,e7=B?!!B.kerrigan:ee,e9=B?B.kerrigan?B.kerrigan.chatManualModel?e1.u:null!=(g=B.kerrigan.chatModel)?g:"":(null==(a=B.lead)?void 0:a.workerManualModel)?e1.u:null!=(v=null==(n=B.lead)?void 0:n.workerModel)?v:"":Q,te=async e=>{if(!B)return void X(e);await e5(e===e1.u?{workerModel:"",workerManualModel:!0}:{workerModel:e,workerManualModel:!1})},tt=async()=>{eg(!0),ed(W("chat.modelsReading"));try{ep(await c.FH.refreshModels()),ed(W("chat.modelsRead"))}catch(e){ed(e.message)}finally{eg(!1)}},ts=B?"approve"===B.planMode:$,tl=async e=>{if(!B){K(e),th(tc,e?"on":"");return}await e5({planMode:e?"approve":"off"})},tn=B?(null==(r=B.review)?void 0:r.enabled)!==!1:U,ti=async e=>{if(!B){Z(e),th(to,e?"":"off");return}await e5({review:{enabled:e}})},tp=B?"operator"===B.reviewModelSource&&null!=(j=null==(o=B.review)?void 0:o.model)?j:"":V,tx=null!=(w=null==em?void 0:em.defaultReviewModel)?w:"",tb=async e=>{if(!B)return void J(e);await e5({review:{model:e}})},tg=eN&&!!(null==B?void 0:B.paused),tj=(0,e_.v)(),tw=async()=>{if(!B)return;let e=!B.paused;_(t=>t?{...t,paused:e}:t);try{await (e?c.FH.pause(B.id):c.FH.resume(B.id))}catch(e){ed(e.message)}finally{eI()}},[tk,ty]=(0,l.useState)(!1);(0,l.useEffect)(()=>{eN||ty(!1)},[eN]),(0,l.useEffect)(()=>{ty(!1)},[null==B?void 0:B.id]);let tN=(0,eG.q)(tk),tS=null==B?void 0:B.tasks.at(-1),tC=null==tS||null==(u=tS.lead)||null==(d=u.rounds.filter(e=>e.subtask).at(-1))?void 0:d.subtask;(0,l.useEffect)(()=>{D(T?B&&tS?tC&&eR?{sessionId:eR,taskId:tC.taskId}:{sessionId:B.id,taskId:tS.id}:null:"new")},[T,null==B?void 0:B.id,null==tS?void 0:tS.id,null==tC?void 0:tC.taskId,eR]);let{ref:tO}=eX(!0,"".concat(null!=(k=null==B?void 0:B.tasks.length)?k:0,":").concat(null!=(y=null==tS?void 0:tS.status)?y:"",":").concat(null!=(N=null==tS?void 0:tS.iterations)?N:0));return(0,s.jsxs)("div",{className:"cs",children:[(0,s.jsxs)("div",{className:"cs-head",children:[null!==eU&&B?(0,s.jsxs)("form",{className:"cs-rename",onSubmit:e=>{e.preventDefault(),eY()},children:[(0,s.jsx)("label",{htmlFor:"cs-rename",className:"sr-only",children:W("chat.renameLabel")}),(0,s.jsx)("input",{id:"cs-rename",type:"text",dir:"auto",maxLength:120,value:eU,autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>eZ(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),eZ(null))}}),(0,s.jsx)("button",{type:"submit",className:"wb-icon-btn",disabled:!eU.trim(),title:W("chat.renameSave"),"aria-label":W("chat.renameSave"),children:"✓"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>eZ(null),title:W("chat.renameCancel"),"aria-label":W("chat.renameCancel"),children:"✕"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:W("chat.thread")}),(0,s.jsxs)("select",{id:"cs-thread",dir:"auto",value:T,onChange:e=>eT(e.target.value),children:[(0,s.jsx)("option",{value:"",children:W("chat.newThread")}),(function(e){var t,a;let s=new Map,l=new Set(e.map(e=>e.id));for(let a of e)a.directedBy&&l.has(a.directedBy)&&s.set(a.directedBy,[...null!=(t=s.get(a.directedBy))?t:[],a]);let n=[];for(let t of e)t.directedBy&&l.has(t.directedBy)||(n.push(t),n.push(...(null!=(a=s.get(t.id))?a:[]).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))));return n})(R).map(e=>(0,s.jsx)("option",{value:e.id,children:e.kerrigan?"✦ ".concat(eV(e.name)):e.directedBy?" ↳ ".concat(eV(e.name)):eV(e.name)},e.id))]}),B&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rename-btn",onClick:()=>eZ(eV(B.name)),title:W("chat.rename"),"aria-label":W("chat.rename"),children:"✎"})]}),(0,s.jsxs)("span",{className:"cs-new-wrap",children:[(0,s.jsx)("button",{type:"button",className:"cs-new","aria-disabled":!!e$||void 0,"aria-describedby":e$?"cs-new-tip":void 0,onClick:()=>{e$||eK()},title:e$?void 0:W("chat.newChatWhy"),children:W("chat.newChat")}),e$&&(0,s.jsx)("span",{id:"cs-new-tip",role:"tooltip",className:"cs-new-tip",children:e$})]})]}),(0,s.jsxs)("div",{className:"cs-body",ref:tO,"aria-live":"polite",children:[(null==B?void 0:B.directedBy)&&(0,s.jsxs)("p",{className:"cs-system cs-directed",children:[W("kz.directedBy")," ",(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>eT(B.directedBy),children:W("kz.openHers")})]}),B?B.tasks.map((e,t)=>B.kerrigan?(0,s.jsx)(tM,{n:t+1,session:B,task:e,threads:R,approvals:eu,onDecided:eA,onOpenFile:q,onOpenChat:eT,onRewind:eN||er?void 0:()=>void e4(e)},e.id):B.lead?(0,s.jsx)(tF,{n:t+1,session:B,task:e,worker:ea,approvals:eu,onDecided:eA,onOpenFile:q,onRewind:eN||er?void 0:()=>void e4(e),onRetrySubtask:eN||"aborted"!==e.status||!(0,c.ex)(e.parked)?void 0:(t,a)=>e2(e,t,a)},e.id):(0,s.jsx)(tv,{n:t+1,session:B,task:e,approvals:eu.filter(t=>t.taskId===e.id),onDecided:eA,onOpenFile:q,onRewind:eN||er?void 0:()=>void e4(e)},e.id)):(0,s.jsx)(tf,{workspace:O,onPick:e=>{var t;ei(e),null==(t=ey.current)||t.focus()},onOpenFolder:I}),B&&!eN&&!(B.directedBy&&(null==(h=B.tasks.at(-1))?void 0:h.fromKerrigan))&&!!(M=B.tasks.at(-1))&&!!(0,c.ex)(M.parked)&&("queued"===M.status||"aborted"===M.status||"limit-reached"===M.status||!!M.limit&&("failed"===M.status||"blocked"===M.status))&&(0,s.jsxs)("div",{className:"cs-system cs-carry",role:"group","aria-label":W("chat.carryOnLabel"),children:[(0,s.jsx)("span",{className:"grow",children:W("chat.carryOnNote")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:er,onClick:()=>void e3(B.tasks.at(-1)),children:W("chat.carryOn")})]}),tg&&(0,s.jsx)("p",{className:"cs-system cs-paused",role:"status",children:W("chat.pausedNote")}),eN&&(null==tj?void 0:tj.password)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"password:".concat(null!=(S=null==B?void 0:B.id)?S:""),tabIndex:-1,children:[W("chat.passwordWaiting"),(0,s.jsx)(en.T4,{text:W("chat.passwordWaiting")})]}),eN&&(null==tj?void 0:tj.signIn)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"sign-in:".concat(null!=(F=null==B?void 0:B.id)?F:""),tabIndex:-1,children:[W("chat.signInWaiting"),(0,s.jsx)(en.T4,{text:W("chat.signInWaiting")})]}),eo&&(0,s.jsx)("p",{className:"cs-system",role:"status",children:eo})]}),(0,s.jsxs)("div",{className:"cs-compose",children:[(0,s.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:W("chat.input")}),(0,s.jsx)("textarea",{id:"cs-input",ref:ey,value:el,onChange:e=>ei(e.target.value),placeholder:eN?W("chat.placeholderRunning"):(null==O?void 0:O.ok)?W("chat.placeholder",{folder:O.name}):W("chat.placeholderNoFolder"),disabled:er||!(null==O?void 0:O.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),eQ())}}),e7?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.kerriganModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eP("90%")}),(0,s.jsx)("label",{htmlFor:"cs-chats-model",className:"cs-pick-label",children:W("chat.kerriganChatsModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(e1.Yb,{id:"cs-chats-model",chosen:e9,onChange:e=>void te(e),byHand:W("chat.modelByHand"),none:eF?W("chat.modelDefault",{model:eF}):W("chat.modelByHand"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):e8?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.leadModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eP("90%")}),(0,s.jsx)("label",{htmlFor:"cs-worker-model",className:"cs-pick-label",children:W("chat.workerModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(e1.Yb,{id:"cs-worker-model",chosen:e9,onChange:e=>void te(e),byHand:W("chat.modelByHand"),none:eF?W("chat.modelDefault",{model:eF}):W("chat.workerSameModel"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):tn&&!e7?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.workModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eP("90%")}),(0,s.jsx)("label",{htmlFor:"cs-review-model",className:"cs-pick-label",children:W("chat.reviewModel")}),(0,s.jsx)("div",{className:"cs-bar",title:W("chat.reviewModelWhy"),children:(0,s.jsx)(e1.Yb,{id:"cs-review-model",chosen:tp,onChange:e=>void tb(e),none:tx?W("chat.reviewModelDefault",{model:tx}):W("chat.reviewModelByHand"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):(0,s.jsx)("div",{className:"cs-bar",children:eP("48%")}),(0,s.jsxs)("div",{className:"cs-bar cs-skills",children:[eL.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-skill",className:"cs-pick-label",children:W("chat.skill")}),(0,s.jsxs)("select",{id:"cs-skill",value:ew,onChange:e=>ek(e.target.value),disabled:eN,title:W("chat.skillWhy"),style:{minWidth:0,maxWidth:"60%"},children:[(0,s.jsx)("option",{value:"",children:W("chat.skillNone")}),eL.map(e=>(0,s.jsxs)("option",{value:e.name,title:e.description||void 0,children:["/",e.name]},e.name))]})]}),(0,s.jsx)(i(),{href:"/settings#skills",className:"button-link plain small cs-skills-link",title:W("chat.skillsLinkWhy"),children:W("chat.skillsLink")}),(0,s.jsx)(ta,{workspace:O,running:eB,queue:!!(null==tj?void 0:tj.queue),onMade:e=>{eK(),ed("".concat(e," ").concat(W("nb.madeChat"))),z()}})]}),(0,s.jsxs)("div",{className:"cs-bar",children:[(0,s.jsxs)("label",{className:"cs-plan-toggle cs-kerrigan-toggle",title:W("chat.kerriganWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:e7,disabled:eN||!!B,onChange:e=>{var t;return t=e.target.checked,void(!B&&(et(t),th(tu,t?"on":""),t&&(Y(!1),th(td,""))))}}),(0,s.jsx)("span",{children:W("chat.kerrigan")})]}),!e7&&(0,s.jsxs)("label",{className:"cs-plan-toggle",title:W("chat.planModeWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:ts,disabled:eN,onChange:e=>void tl(e.target.checked)}),(0,s.jsx)("span",{children:W("chat.planMode")})]}),!e7&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-lead-toggle",title:W("chat.leadWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:e8,disabled:eN||!!B,onChange:e=>{var t;return t=e.target.checked,void(!B&&(Y(t),th(td,t?"on":""),t&&(et(!1),th(tu,""))))}}),(0,s.jsx)("span",{children:W("chat.lead")})]}),!e8&&!e7&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-review-toggle",title:W("chat.reviewWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tn,disabled:eN,onChange:e=>void ti(e.target.checked)}),(0,s.jsx)("span",{children:W("chat.review")})]}),(0,s.jsxs)("span",{className:"cs-actions",children:[eN&&(0,s.jsx)("button",{type:"button",className:"cs-pause",onClick:()=>void tw(),title:tg?W("chat.resumeWhy"):W("chat.pauseWhy"),children:tg?W("chat.resume"):W("chat.pause")}),eN&&(0,s.jsx)("button",{type:"button",className:"danger cs-stop",onClick:()=>{B&&!tk&&(ty(!0),c.FH.stop(B.id).then(()=>ed(W("chat.stopping"))).catch(e=>{ty(!1),ed(e.message)}))},disabled:tk,"aria-busy":tk||void 0,children:tk?(0,s.jsxs)(s.Fragment,{children:[W("chat.stoppingNow"),(0,s.jsx)("span",{className:"saving-dots",children:tN})]}):W("chat.stop")}),(0,s.jsx)("button",{type:"button",className:"primary",disabled:er||!el.trim()||!(null==O?void 0:O.ok),onClick:()=>void eQ(),title:W("chat.sendWhy"),children:eN?W("chat.sendNote"):W("chat.send")})]})]})]})]})}function tf(e){var t;let{workspace:a,onPick:l,onOpenFolder:n}=e,{t:i}=(0,C.kj)();if(!a)return(0,s.jsx)("p",{className:"muted small",children:i("wb.loading")});if(!a.ok)return(0,s.jsxs)("div",{className:"cs-welcome",children:[(0,s.jsx)("p",{children:a.problem}),(0,s.jsx)("button",{type:"button",className:"primary",onClick:n,children:i("chat.openFolder")})]});let r=[i("chat.example1"),i("chat.example2"),i("chat.example3")];return(0,s.jsxs)("div",{className:"cs-welcome",children:[(0,s.jsx)("h3",{children:i("chat.welcome",{folder:a.name})}),(0,s.jsx)("p",{className:"muted small",children:i("chat.welcomeWhy",{dir:a.dir,branch:null!=(t=a.branch)?t:"—"})}),(0,s.jsx)("ul",{className:"cs-examples",children:r.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>l(e),children:e})},e))})]})}function tx(e,t){var a;let[s,n]=(0,l.useState)(null),i=(null==t?void 0:t.status)==="running"||(null==t?void 0:t.status)==="waiting-approval",r=()=>t&&(t.startedAt||i)?c.FH.taskStory(e,t.id,t.runId).then(n).catch(()=>void 0):Promise.resolve();(0,l.useEffect)(()=>{r()},[e,null==t?void 0:t.id,null==t?void 0:t.runId,null==t?void 0:t.status]),(0,p.z)(r,i?1500:6e4,!!i);let o=[],d=e=>e.forEach(e=>"review"===e.kind?d(e.entries):o.push(e));return d(null!=(a=null==s?void 0:s.entries)?a:[]),o}function tb(e){let{entries:t}=e;return(0,s.jsx)(s.Fragment,{children:t.map((e,t)=>{var a;return"reply"===e.kind?(null==(a=e.notes)?void 0:a.trim())?(0,s.jsxs)("div",{className:"cs-bot",children:[(0,s.jsx)(e2.s,{text:e.notes}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:e.notes,what:"chat.copyReply"})})]},t):null:"step"===e.kind?(0,s.jsx)(ty,{step:e},t):"handoff"===e.kind?(0,s.jsx)(eQ.Q$,{card:e.card,outcome:e.outcome,answer:e.answer},t):null})})}function tg(e){let{task:t,n:a,onRewind:l}=e,{t:n}=(0,C.kj)(),i=(0,C.Vl)();return(0,s.jsxs)("div",{className:"cs-user-row",children:[l&&(t.checkpoint||"queued"===t.status)&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rewind",onClick:l,title:n("chat.rewind"),"aria-label":n("chat.rewind"),children:"↶"}),(0,s.jsxs)("div",{className:"cs-user",children:[(0,s.jsxs)("p",{className:"cs-user-head",children:[(0,s.jsx)("span",{className:"cs-user-who",children:n("chat.you")}),(0,s.jsx)("span",{className:"cs-user-n",children:n("chat.youN",{n:a})}),(0,s.jsx)("time",{dateTime:t.createdAt,children:i(t.createdAt)})]}),t.skill&&(0,s.jsx)(tE,{skill:t.skill}),(0,s.jsx)(tk,{children:(0,s.jsx)(e2.s,{text:t.prompt})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:t.prompt,what:"chat.copyMessage"})})]})]})}function tv(e){var t,a,l,n;let{n:i,session:r,task:o,approvals:d,onDecided:u,onOpenFile:h,onRewind:m}=e,{t:p}=(0,C.kj)(),f="running"===o.status||"waiting-approval"===o.status,x=tx(r.id,o);return(0,s.jsxs)("section",{className:"cs-turn",id:"cs-turn-".concat(o.id),"aria-label":p("chat.turn",{text:o.title}),children:[(0,s.jsx)(tg,{task:o,n:i,onRewind:m}),"queued"===o.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:p("idle"===r.status?"chat.queued":"chat.waitingTurn")}),(0,s.jsx)(tb,{entries:x}),(null==(t=o.plan)?void 0:t.approved)&&!d.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:p("chat.planShown",{v:o.plan.version})}),(0,s.jsx)(e5.D,{plan:o.plan})]}),d.map(e=>(0,s.jsx)(tS,{approval:e,onDecided:u},e.id)),f&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[o.acting?(0,s.jsx)(e4.y,{actor:o.acting.actor,acting:o.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",p("chat.working",{n:o.iterations})]}),!f&&"queued"!==o.status&&(0,s.jsx)(tj,{task:o}),!f&&(0,s.jsx)(tO,{session:r,task:o}),o.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:c.FH.taskExchangeUrl(r.id,o.id),download:!0,title:p("chat.exchangeWhy"),children:p("chat.exchange")})}),(null!=(n=null==(l=o.vcs)||null==(a=l.files)?void 0:a.length)?n:0)>0&&!f&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:p("chat.changed",{n:o.vcs.files.length})}),o.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>h(e.path),title:e.path,children:[(0,s.jsx)(et,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eA,{sessionId:r.id,taskId:o.id,runId:o.runId,title:o.title,files:o.vcs.files.length})]})]})}function tj(e){let{task:t}=e,a=(0,l.useRef)(null),[n,i]=(0,l.useState)(!1),r=[t.summary,"done"!==t.status?t.reason:""].filter(Boolean).join("\n\n");return(0,l.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),a=parseFloat(t.lineHeight)||1.45*parseFloat(t.fontSize);i(e.scrollHeight>a*tw)};t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[]),(0,s.jsxs)("div",{className:"cs-end s-".concat(t.status),children:[(0,s.jsx)(ar,{status:t.status}),(0,s.jsxs)("div",{className:"grow",ref:a,children:[t.summary?(0,s.jsx)(e2.s,{text:t.summary}):null,"done"!==t.status&&t.reason?(0,s.jsx)("p",{className:"small",children:t.reason}):null,r&&n&&(0,s.jsx)("div",{className:"cs-copy-row cs-copy-bottom",children:(0,s.jsx)(en.i8,{text:r,what:"chat.copySummary"})})]}),r&&(0,s.jsx)(en.i8,{text:r,what:"chat.copySummary"})]})}let tw=6;function tk(e){let{children:t}=e,{t:a}=(0,C.kj)(),n=(0,l.useRef)(null),[i,r]=(0,l.useState)(0),[c,o]=(0,l.useState)(!1),[d,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),a=parseFloat(t.lineHeight)||1.45*parseFloat(t.fontSize),s=Math.round(3*a);r(s),o(e.scrollHeight>s+.6*a)};t();let a=new ResizeObserver(t);return a.observe(e),()=>a.disconnect()},[]);let h=c&&!d;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{ref:n,className:"cs-fold".concat(h?" folded":""),style:h?{maxHeight:i}:void 0,children:[t,h&&(0,s.jsxs)("div",{className:"cs-fold-blur","aria-hidden":"true",children:[(0,s.jsx)("span",{}),(0,s.jsx)("span",{}),(0,s.jsx)("span",{})]})]}),c&&(0,s.jsx)("button",{type:"button",className:"cs-fold-toggle","aria-expanded":d,"aria-label":a(d?"chat.foldClose":"chat.foldOpen"),title:a(d?"chat.foldClose":"chat.foldOpen"),onClick:()=>u(!d),children:d?"▴":"▾"})]})}function ty(e){let{step:t}=e,{t:a}=(0,C.kj)(),n=!t.outcome,[i,r]=(0,l.useState)(null),c=null!=i?i:n||t.failed;return(0,s.jsxs)("div",{className:"cs-cmd".concat(t.failed?" bad":""),children:[(0,s.jsxs)("div",{className:"cs-cmd-row",children:[(0,s.jsxs)("button",{type:"button",className:"cs-cmd-head","aria-expanded":c,onClick:()=>r(!c),children:[(0,s.jsx)("span",{className:"cs-cmd-ico","aria-hidden":"true",children:n?"⟳":t.failed?"✗":"✓"}),(0,s.jsx)("code",{className:"wb-row-name",children:t.command}),(0,s.jsx)("span",{className:"muted small",children:n?a("chat.running"):void 0!==t.exitCode?a("chat.exit",{code:t.exitCode}):t.outcome})]}),(0,s.jsx)(en.i8,{text:t.output?"$ ".concat(t.command,"\n").concat(t.output):t.command,what:"chat.copyCommand"})]}),c&&t.output&&(0,s.jsx)("pre",{className:"cs-out",children:t.output})]})}let tN=e=>({"data-awaits":e.id,tabIndex:-1});function tS(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,C.kj)(),i=a.kerrigan;return i?(0,s.jsxs)("div",{className:"cs-kz-card s-".concat(i.state),"data-awaits-frame":"",..."thinking"===i.state?{"data-kerrigan-thinking":""}:{},children:[(0,s.jsxs)("p",{className:"small cs-kz-on-card",role:"status",children:[(0,s.jsx)(e4.y,{actor:"kerrigan"})," ","thinking"===i.state?n("kz.thinking"):n("kz.yoursOnCard",{why:null!=(t=i.why)?t:""}),"yours"===i.state&&i.suggestion&&(0,s.jsxs)("span",{className:"cs-kz-suggests",children:[" ",n("kz.suggests",{answer:i.suggestion})]})]}),(0,s.jsx)(tC,{approval:a,onDecided:l})]}):(0,s.jsx)(tC,{approval:a,onDecided:l})}function tC(e){var t,a,l;let{approval:n,onDecided:i}=e,{t:r}=(0,C.kj)(),{err:o,choose:d,mark:u}=(0,eY.p)(),h=async e=>{i(n.id,await d(e,async()=>{await c.FH.decide(n.id,e)}))};return n.plan?(0,s.jsx)("div",{className:"cs-plan-ask",...tN(n),children:(0,s.jsx)(e3.Mt,{approval:n,onDecided:e=>i(n.id,e)})}):(null==(t=n.question)?void 0:t.handoff)?(0,s.jsx)(tA,{approval:n,onDecided:i}):n.question?(0,s.jsx)(tR,{approval:n,onDecided:i}):n.retry?(0,s.jsx)(tW,{approval:n,onDecided:i}):n.model?(0,s.jsx)("p",{className:"cs-system small",children:r("chat.lookAbove")}):(0,s.jsxs)("div",{className:"cs-ask",role:"group","aria-label":r("chat.askTitle"),...tN(n),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:r("chat.askTitle")})," ",n.actor&&(0,s.jsx)(e4.y,{actor:n.actor,how:"asks"})]}),(0,s.jsx)("pre",{className:"cs-out",children:n.description}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:n.description,what:"chat.copyAsked"})}),n.platform&&(0,s.jsx)("p",{className:"reason small",children:r("approval.platform",{platform:n.platform})}),n.readOnly&&(0,s.jsx)("p",{className:"reason small cs-read-only",children:r("approval.readOnly")}),(null!=(l=null==(a=n.scripts)?void 0:a.length)?l:0)>0&&(0,s.jsx)(eQ.G,{scripts:n.scripts}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...u("run"),onClick:()=>void h("run"),children:r("chat.askRun")}),!n.network&&!n.platform&&!n.runAllOff&&(0,s.jsx)("button",{type:"button",...u("run-all"),onClick:()=>void h("run-all"),children:r("chat.askRunAll")}),(0,s.jsx)("button",{type:"button",...u("skip"),onClick:()=>void h("skip"),children:r("chat.askSkip")})]}),(0,s.jsx)(e3.Sz,{approval:n}),o&&(0,s.jsx)("p",{className:"err",role:"alert",children:o}),(0,s.jsx)(en.T4,{text:(0,tn.Mo)(r,n)})]})}function tF(e){var t,a,n,i,r,o,d,u,h,m,p,f,x,b,g,v,j,w;let{n:k,session:y,task:N,worker:S,approvals:F,onDecided:M,onOpenFile:O,onRewind:E,onRetrySubtask:L}=e,{t:q}=(0,C.kj)(),z="running"===N.status||"waiting-approval"===N.status,I=null!=(b=null==(t=N.lead)?void 0:t.rounds)?b:[],D=new Map(I.filter(e=>e.subtask).map(e=>[e.subtask.n,e.n])),W=null==(a=I.filter(e=>"plan"===e.status).at(-1))?void 0:a.n,A=F.filter(e=>e.taskId===N.id),R=(null==(n=I.at(-1))?void 0:n.subtask)&&(null==S?void 0:S.tasks.find(e=>{var t,a;return e.id===(null==(a=I.at(-1))||null==(t=a.subtask)?void 0:t.taskId)&&("running"===e.status||"waiting-approval"===e.status)}));return(0,s.jsxs)("section",{className:"cs-turn cs-lead-turn",id:"cs-turn-".concat(N.id),"aria-label":q("chat.turn",{text:N.title}),children:[(0,s.jsx)(tg,{task:N,n:k,onRewind:E}),"queued"===N.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===y.status?q("chat.queued"):q("chat.waitingTurn")}),I.map(e=>{var t,a;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tL,{who:q("lead.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tL,{who:q("lead.who"),text:e.notes}),e.ledger&&(0,s.jsx)(tt,{change:e.ledger}),"plan"===e.status&&e.n===W&&N.plan&&!A.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:q("lead.plan",{v:N.plan.version})}),(0,s.jsx)(e5.D,{plan:N.plan})]}),e.subtask&&D.get(e.subtask.n)===e.n&&(0,s.jsx)(tq,{round:e,worker:S,approvals:F.filter(t=>{var a;return t.taskId===(null==(a=e.subtask)?void 0:a.taskId)}),onDecided:M,onOpenFile:O,onRetry:L?t=>L(e.subtask.n,t):void 0}),(null==(t=e.question)?void 0:t.answer)!==void 0&&(0,s.jsxs)("div",{className:"cs-bot cs-lead-qa",children:[(0,s.jsx)("p",{className:"cs-who",children:q("lead.question")}),(0,s.jsx)(e2.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:(0,tn.yw)(q,{...e.question,options:null!=(a=e.question.options)?a:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:q("lead.answered")}),(0,s.jsx)(e2.s,{text:e.question.answer}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:e.question.answer,what:"chat.copyAnswer"})})]})]},e.n)}),A.map(e=>(0,s.jsx)(tS,{approval:e,onDecided:M},e.id)),z&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[N.acting?(0,s.jsx)(e4.y,{actor:N.acting.actor,acting:N.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",R?(null==(i=N.lead)?void 0:i.ledger)?q("lead.workingOn",{title:null!=(g=null==(o=I.at(-1))||null==(r=o.subtask)?void 0:r.title)?g:""}):q("lead.working",{n:null!=(v=null==(u=I.at(-1))||null==(d=u.subtask)?void 0:d.n)?v:0}):q("lead.thinking")]}),N.lead&&(z||N.lead.ledger)&&(0,s.jsx)(e9,{lead:N.lead,live:z}),(null==(h=N.lead)?void 0:h.messages)&&(0,s.jsx)("p",{className:"muted small cs-lead-count",children:q("lead.messages",{lead:N.lead.messages.lead,worker:N.lead.messages.worker,total:N.lead.messages.lead+N.lead.messages.worker})}),!z&&"queued"!==N.status&&(0,s.jsx)(tj,{task:N}),!z&&(0,s.jsx)(tO,{session:y,task:N}),!z&&(null!=(j=null==(p=N.lead)||null==(m=p.evidence)?void 0:m.length)?j:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:q("lead.evidence")}),(0,s.jsx)("ul",{children:N.lead.evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e2.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:N.lead.evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),N.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:c.FH.taskExchangeUrl(y.id,N.id),download:!0,title:q("chat.exchangeWhy"),children:q("chat.exchange")})}),(null!=(w=null==(x=N.vcs)||null==(f=x.files)?void 0:f.length)?w:0)>0&&!z&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:q("chat.changed",{n:N.vcs.files.length})}),N.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>O(e.path),title:e.path,children:[(0,s.jsx)(et,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eA,{sessionId:y.id,taskId:N.id,runId:N.runId,title:N.title,files:N.vcs.files.length})]})]})}function tM(e){var t,a,n,i,r,o,d,u;let{n:h,session:m,task:p,threads:f,approvals:x,onDecided:b,onOpenFile:g,onOpenChat:v,onRewind:j}=e,{t:w}=(0,C.kj)(),k="running"===p.status||"waiting-approval"===p.status,y=p.kerrigan,N=null!=(o=null==y?void 0:y.rounds)?o:[],S=e=>{var t,a;return(null!=(a=null==(t=f.find(t=>t.id===e))?void 0:t.name)?a:"").replace(/^chat: /,"")||w("kz.aChat")},F=k?x.filter(e=>e.taskId===p.id||e.sessionId!==m.id):[],M=null==(t=[...N].reverse().find(e=>e.send))?void 0:t.send,O=k&&M&&("running"===M.status||"waiting-approval"===M.status);return(0,s.jsxs)("section",{className:"cs-turn cs-kz-turn",id:"cs-turn-".concat(p.id),"aria-label":w("chat.turn",{text:p.title}),children:[(0,s.jsx)(tg,{task:p,n:h,onRewind:j}),"queued"===p.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===m.status?w("chat.queued"):w("chat.waitingTurn")}),N.map((e,t)=>{var a,n,i;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tL,{who:w("kz.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tL,{who:w("actor.kerrigan"),text:e.notes}),(null!=(n=null==(a=e.sources)?void 0:a.length)?n:0)>0&&(0,s.jsxs)("div",{className:"cs-kz-sources small",children:[(0,s.jsx)("span",{className:"cs-who",children:w("kz.sources")}),(0,s.jsx)("ul",{children:e.sources.map(e=>(0,s.jsx)("li",{children:e},e))})]}),e.send&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-send",children:[(0,s.jsx)("p",{className:"cs-who",children:w("kz.send",{n:e.send.n,name:S(e.send.sessionId)})}),(0,s.jsxs)("p",{className:"cs-kz-chips",children:[(0,s.jsx)("span",{className:"badge",children:"same"===e.send.chat?w("kz.sameChat"):w("kz.newChat")}),e.send.planMode&&(0,s.jsx)("span",{className:"badge",children:w("kz.planMode")}),e.send.twoChats&&(0,s.jsx)("span",{className:"badge",children:w("kz.twoChats")}),e.send.review&&(0,s.jsx)("span",{className:"badge",children:w("kz.review")}),e.send.skill&&(0,s.jsx)("span",{className:"badge skill",children:w("chat.skillUsed",{name:e.send.skill})})]}),(0,s.jsx)(tk,{children:(0,s.jsx)(e2.s,{text:e.send.prompt})}),(0,s.jsxs)("div",{className:"cs-copy-row",children:[(0,s.jsx)(en.i8,{text:e.send.prompt,what:"kz.copyPrompt"}),e.send.sessionId&&(0,s.jsx)("button",{type:"button",className:"quiet small cs-kz-open",onClick:()=>v(e.send.sessionId),title:w("kz.openChatWhy"),children:w("kz.openChat")})]}),e.send.status&&"running"!==e.send.status&&"waiting-approval"!==e.send.status&&(0,s.jsxs)("p",{className:"small cs-kz-ended",children:[(0,s.jsx)(ar,{status:e.send.status})," ",w("kz.chatEnded")]})]}),e.card&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-answer",children:[(0,s.jsxs)("p",{className:"cs-who",children:[w("kz.cardHead")," ",e.card.actor&&(0,s.jsx)(e4.y,{actor:e.card.actor,how:"asks"})]}),(0,s.jsx)(e2.s,{text:e.card.text}),void 0!==e.card.answer&&(0,s.jsx)("p",{className:"small",children:(0,s.jsx)("strong",{children:"operator"===e.card.by?w("kz.youAnswered",{answer:e.card.answer}):w("kz.answered",{answer:e.card.answer})})}),e.card.yours&&(0,s.jsxs)("p",{className:"small cs-kz-yours",children:[w("kz.leftToYou",{why:e.card.yours.why}),e.card.yours.suggestion?" ".concat(w("kz.suggests",{answer:e.card.yours.suggestion})):""]})]}),e.question&&void 0!==e.question.answer&&(0,s.jsxs)("div",{className:"cs-bot cs-lead-qa",children:[(0,s.jsx)("p",{className:"cs-who",children:w("kz.asked")}),(0,s.jsx)(e2.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:(0,tn.yw)(w,{...e.question,options:null!=(i=e.question.options)?i:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:w("lead.answered")}),(0,s.jsx)(e2.s,{text:e.question.answer})]}),"blocked"===e.status&&e.needed&&(0,s.jsx)("p",{className:"small cs-kz-needed",children:w("kz.needed",{needed:e.needed})})]},"".concat(e.at,"-").concat(t))}),F.map(e=>(0,s.jsx)(tS,{approval:e,onDecided:b},e.id)),k&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[p.acting?(0,s.jsx)(e4.y,{actor:p.acting.actor,acting:p.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",O?w("kz.chatWorking",{n:M.n,name:S(M.sessionId)}):w("kz.working")]}),y&&(y.sent>0||y.messages>0)&&(0,s.jsx)("p",{className:"muted small cs-kz-count",children:w("kz.counts",{sent:y.sent,max:y.maxSends,messages:y.messages})}),!k&&"queued"!==p.status&&(0,s.jsx)(tj,{task:p}),!k&&(null!=(d=null==(n=N.at(-1))||null==(a=n.evidence)?void 0:a.length)?d:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:w("lead.evidence")}),(0,s.jsx)("ul",{children:N.at(-1).evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e2.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:N.at(-1).evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),p.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:c.FH.taskExchangeUrl(m.id,p.id),download:!0,title:w("chat.exchangeWhy"),children:w("chat.exchange")})}),(null!=(u=null==(r=p.vcs)||null==(i=r.files)?void 0:i.length)?u:0)>0&&!k&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:w("chat.changed",{n:p.vcs.files.length})}),p.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>g(e.path),title:e.path,children:[(0,s.jsx)(et,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eA,{sessionId:m.id,taskId:p.id,runId:p.runId,title:p.title,files:p.vcs.files.length})]})]})}function tO(e){let{session:t,task:a}=e;if(!a.parked||!t.queueItem)return null;let l=t.queueItem;return(0,s.jsx)("div",{className:"cs-parked",children:(0,s.jsx)(tl.a,{parked:a.parked,onAnswer:async e=>void await c.FH.answerParked(l,{...e,sessionId:t.id})})})}function tE(e){let{skill:t}=e,{t:a}=(0,C.kj)();return(0,s.jsx)("p",{className:"cs-skill-chip",children:(0,s.jsx)("span",{className:"badge skill",title:t.description||void 0,children:a("chat.skillUsed",{name:t.name})})})}function tL(e){let{who:t,text:a}=e;return(0,s.jsxs)("div",{className:"cs-bot cs-lead-say",children:[(0,s.jsx)("p",{className:"cs-who",children:t}),(0,s.jsx)(e2.s,{text:a}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:a,what:"chat.copyReply"})})]})}function tq(e){var t,a,l,n,i,r,c,o;let{round:d,worker:u,approvals:h,onDecided:m,onOpenFile:p,onRetry:f}=e,{t:x}=(0,C.kj)(),b=(0,eY.p)(),g=d.subtask,v=null==u?void 0:u.tasks.find(e=>e.id===g.taskId),j=(null==v?void 0:v.status)==="running"||(null==v?void 0:v.status)==="waiting-approval",w=tx(null!=(l=null==u?void 0:u.id)?l:"",v),k=null!=(n=g.attempts)?n:[],y=k.at(-1),N=null!=(i=g.maxAttempts)?i:k.length,S=k.slice(0,-1),F=k.length>1,M=!j&&!!y&&"done"!==y.status&&!!y.category,O=!!f&&!!v&&"done"!==v.status&&!j;return(0,s.jsxs)("details",{className:"cs-subtask s-".concat(null!=(r=null==v?void 0:v.status)?r:"queued"),open:j||h.length>0||O||void 0,children:[(0,s.jsxs)("summary",{children:[(0,s.jsx)(ar,{status:null!=(c=null==v?void 0:v.status)?c:"queued"})," ",(0,s.jsx)("span",{children:x("lead.subtask",{n:g.n,title:g.title})}),g.readOnly&&(0,s.jsx)("span",{className:"badge",children:x("lead.readOnly")}),g.fresh&&(0,s.jsx)("span",{className:"badge",children:x("lead.fresh")}),j&&F&&y&&(0,s.jsx)("span",{className:"badge running cs-attempt",children:x("retry.retrying",{k:y.attempt,m:N})}),!j&&F&&(null==v?void 0:v.status)==="done"&&y&&(0,s.jsx)("span",{className:"badge done cs-attempt",children:x("retry.doneAt",{k:y.attempt})}),M&&(0,s.jsx)("span",{className:"badge failed cs-attempt",children:x("retry.attempt",{k:y.attempt,m:N})})]}),(0,s.jsxs)("div",{className:"cs-subtask-body",children:[M&&(0,s.jsxs)("p",{className:"small cs-attempt-why",children:[(0,s.jsx)("span",{className:"badge",children:x(tn.P3[y.category])})," ",y.reason&&(0,s.jsx)("span",{children:y.reason})]}),S.length>0&&(0,s.jsx)(tz,{attempts:S,max:N,worker:u}),F&&(0,s.jsx)("p",{className:"cs-who cs-attempt-now",children:x("retry.attempt",{k:y.attempt,m:N})}),(0,s.jsx)(tb,{entries:w}),h.map(e=>(0,s.jsx)(tS,{approval:e,onDecided:m},e.id)),v&&!j&&"queued"!==v.status&&(0,s.jsx)(tj,{task:v}),v&&(null!=(o=null==(a=v.vcs)||null==(t=a.files)?void 0:t.length)?o:0)>0&&!j&&(0,s.jsx)("div",{className:"cs-files",children:v.vcs.files.slice(0,8).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>p(e.path),title:e.path,children:[(0,s.jsx)(et,{path:e.path})," ",e.path.split("/").pop()]},e.path))}),O&&f&&(0,s.jsxs)("div",{className:"cs-retry-after",role:"group","aria-label":x("retry.afterStop"),children:[(0,s.jsx)("p",{className:"muted small",children:x("retry.afterStopWhy")}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...b.mark("same"),onClick:()=>void b.choose("same",()=>f(!1)),children:x("retry.same")}),(0,s.jsx)("button",{type:"button",...b.mark("fresh"),onClick:()=>void b.choose("fresh",()=>f(!0)),children:x("retry.fresh")})]}),(0,s.jsx)(en.T4,{text:(0,tn.qq)(x,g.n,g.title)})]})]})]})}function tz(e){let{attempts:t,max:a,worker:l}=e,{t:n}=(0,C.kj)();return(0,s.jsxs)("details",{className:"cs-attempts",children:[(0,s.jsx)("summary",{className:"small",children:n("retry.earlier",{n:t.length})}),t.map(e=>(0,s.jsx)(tI,{attempt:e,max:a,worker:l},e.attempt))]})}function tI(e){var t;let{attempt:a,max:n,worker:i}=e,{t:r}=(0,C.kj)(),c=(0,C.Vl)(),[o,d]=(0,l.useState)(!1),u=null==i?void 0:i.tasks.find(e=>e.id===a.taskId);return(0,s.jsxs)("details",{className:"cs-attempt-line s-".concat(a.status),onToggle:e=>d(e.target.open),children:[(0,s.jsxs)("summary",{className:"small",children:[(0,s.jsx)(ar,{status:a.status})," ",(0,s.jsx)("strong",{children:r("retry.attempt",{k:a.attempt,m:n})}),a.category&&(0,s.jsx)("span",{className:"badge",children:r(tn.P3[a.category])}),a.fresh&&(0,s.jsx)("span",{className:"badge",children:r("lead.fresh")}),a.continued&&(0,s.jsx)("span",{className:"badge",children:r("retry.continued")}),a.restored&&(0,s.jsx)("span",{className:"badge",children:r("retry.restored")}),"after-stop"===a.by&&(0,s.jsx)("span",{className:"badge",children:r("retry.byAfterStop")})]}),(0,s.jsxs)("div",{className:"cs-attempt-facts small",children:[a.reason&&(0,s.jsx)("p",{children:r("retry.reason",{reason:a.reason})}),(0,s.jsxs)("p",{className:"muted",children:[r("retry.commands",{started:a.commands.started,completed:a.commands.completed})," \xb7"," ",r(!0===a.repoChanged?"retry.repoChanged":!1===a.repoChanged?"retry.repoSame":"retry.repoUnknown"),a.startedAt&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 ",c(a.startedAt),a.endedAt?"–".concat(c(a.endedAt)):""]})]}),o&&(0,s.jsx)(tD,{sessionId:null!=(t=null==i?void 0:i.id)?t:"",task:u})]})]})}function tD(e){let{sessionId:t,task:a}=e,l=tx(t,a);return(0,s.jsx)(tb,{entries:l})}function tW(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,C.kj)(),{err:i,choose:r,mark:o}=(0,eY.p)(),d=a.retry,u=async e=>{("restore"!==e||await (0,e0.Z)(n("retry.restoreConfirm")))&&l(a.id,await r(e,async()=>{await c.FH.answerRetry(a.id,e)}))};return(0,s.jsxs)("div",{className:"cs-ask cs-retry",role:"group","aria-label":n("retry.title",{n:d.n}),...tN(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:n("retry.title",{n:d.n})})," ",(0,s.jsx)(e4.y,{actor:null!=(t=a.actor)?t:"lead",how:"asks"})]}),(0,s.jsxs)("p",{className:"small",children:[(0,s.jsx)("span",{className:"badge failed",children:n("retry.attempt",{k:d.attempt,m:d.maxAttempts})})," ",(0,s.jsx)("span",{className:"badge",children:n(tn.P3[d.category])})]}),d.reason&&(0,s.jsx)("p",{className:"small",children:n("retry.reason",{reason:d.reason})}),"unknown"===d.sideEffects&&(0,s.jsx)("p",{className:"reason small",children:n("retry.unknown")}),d.changed.length>0&&(0,s.jsx)("p",{className:"muted small",children:n("retry.changed",{files:d.changed.slice(0,8).join(", ")+(d.changed.length>8?", …":"")})}),(0,s.jsx)("div",{className:"row",children:d.choices.map((e,t)=>(0,s.jsx)("button",{type:"button",className:0===t?"primary":void 0,...o(e),onClick:()=>void u(e),children:n(tn.Sx[e])},e))}),i&&(0,s.jsx)("p",{className:"err",role:"alert",children:i}),(0,s.jsx)(en.T4,{text:(0,tn.Mo)(n,a)})]})}function tA(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,C.kj)(),r=(0,l.useId)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),{locked:f,err:x,choose:b,mark:g}=(0,eY.p)(),v=a.question,j=async e=>{let t="revise"===e?m:o;("ran"!==e&&"revise"!==e||t.trim())&&n(a.id,await b(e,async()=>{await c.FH.answerQuestion(a.id,t,e)}))},w=async()=>{await (0,e0.Z)(i("lead.stopConfirm"))&&n(a.id,await b("stop",async()=>{await c.FH.decide(a.id,"abort")}))};return(0,s.jsxs)("div",{className:"cs-ask cs-handoff",role:"group","aria-label":i("ho.title"),...tN(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("ho.title")})," ",(0,s.jsx)(e4.y,{actor:null!=(t=a.actor)?t:"worker",how:"asks"})]}),(0,s.jsx)(eQ.Lp,{card:v.handoff,why:v.text}),(0,s.jsx)("label",{htmlFor:"".concat(r,"-out"),className:"small",children:i("ho.output")}),(0,s.jsx)("textarea",{id:"".concat(r,"-out"),className:"prose",rows:5,dir:"ltr",value:o,onChange:e=>d(e.target.value),placeholder:i("ho.outputPlaceholder"),disabled:f}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...g("ran"),disabled:f||!o.trim(),onClick:()=>void j("ran"),children:i("ho.send")}),(0,s.jsx)("button",{type:"button",...g("revise"),"aria-expanded":u,onClick:()=>h(e=>!e),title:i("ho.reviseWhy"),disabled:f,children:i("ho.revise")}),(0,s.jsx)("button",{type:"button",...g("declined"),onClick:()=>void j("declined"),title:i("ho.notRunWhy"),children:i("ho.notRun")}),(0,s.jsx)("button",{type:"button",className:"danger",...g("stop"),onClick:()=>void w(),children:i("lead.stop")})]}),u&&(0,s.jsxs)("div",{className:"ho-revise",children:[(0,s.jsx)("label",{htmlFor:"".concat(r,"-note"),className:"small",children:i("ho.reviseNote")}),(0,s.jsx)("textarea",{id:"".concat(r,"-note"),className:"prose",rows:3,value:m,onChange:e=>p(e.target.value),required:!0,"aria-required":"true",disabled:f}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",className:"primary",disabled:f||!m.trim(),onClick:()=>void j("revise"),children:i("ho.reviseSend")})})]}),x&&(0,s.jsx)("p",{className:"err",role:"alert",children:x}),(0,s.jsx)(en.T4,{text:(0,tn.Mo)(i,a)})]})}function tR(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,C.kj)(),r=(0,l.useId)(),{locked:o,err:d,choose:u,mark:h}=(0,eY.p)(),m=a.question,p=null!=(t=a.actor)?t:"lead",f=async(e,t)=>{(t.chosen||t.text.trim())&&n(a.id,await u(e,async()=>{await (t.chosen?c.FH.answerChosen(a.id,t.chosen,t.text):c.FH.answerQuestion(a.id,t.text))}))},x=async()=>{await (0,e0.Z)(i("lead.stopConfirm"))&&n(a.id,await u("stop",async()=>{await c.FH.decide(a.id,"abort")}))};return(0,s.jsxs)("div",{className:"cs-ask cs-question",role:"group","aria-label":i("lead"===p?"lead.question":"chat.question"),...tN(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("lead"===p?"lead.question":"chat.question")})," ",(0,s.jsx)(e4.y,{actor:p,how:"asks"})]}),(0,s.jsx)(e2.s,{text:m.text}),m.why&&(0,s.jsx)("p",{className:"muted small",children:m.why}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(en.i8,{text:(0,tn.yw)(i,m,!0),what:"chat.copyQuestion"})}),(0,s.jsx)(ti.Y,{id:r,q:m,locked:o,mark:h,onAnswer:(e,t)=>void f(e,t),children:(0,s.jsx)("button",{type:"button",className:"danger",...h("stop"),onClick:()=>void x(),children:i("lead.stop")})}),d&&(0,s.jsx)("p",{className:"err",role:"alert",children:d}),(0,s.jsx)(en.T4,{text:(0,tn.Mo)(i,a)})]})}function tH(e){let{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onOpenFolder:i,onTurn:r,onChange:c,onClose:o,grip:d}=e,{t:u}=(0,C.kj)(),h=(0,e_.v)(),m=(0,e$.ms)(h),p=(0,e$.IH)(u,h);return(0,s.jsxs)("div",{className:"wb-chat-inner",children:[(0,s.jsxs)("div",{className:"wb-chat-tabs",role:"tablist","aria-label":u("wb.chatPanel"),children:[d,(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":!0,className:"on",children:[u("wb.chatTab"),m&&(0,s.jsxs)("span",{className:"wb-live-badge".concat((null==h?void 0:h.paused)?" paused":""),role:"status",title:p,"aria-label":p,children:[(0,s.jsx)("span",{className:"wb-live-badge-dot","aria-hidden":"true"}),u("wb.live")]})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":u("wb.toggleChat"),title:u("wb.toggleChat"),onClick:o,children:"\xd7"})]}),(0,s.jsx)(tp,{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onChange:c,onOpenFolder:i,onTurn:r})]})}var tT=a(5462);let tP=[{tab:"terminal",label:"wb.terminal",infoLabel:"wb.terminalInfoLabel",info:"wb.terminalInfo"},{tab:"problems",label:"wb.problems",infoLabel:"wb.problemsInfoLabel",info:"wb.problemsInfo"},{tab:"output",label:"wb.output",infoLabel:"wb.outputInfoLabel",info:"wb.outputInfo"}];function tB(e){let{open:t,onToggle:a,tab:n,onTab:i,session:r,task:c,newChat:o=!1,onShowMessage:d}=e,{t:u}=(0,C.kj)(),h=r?function(e){let t=[];return e.tasks.forEach((a,s)=>{var l,n,i,r;let c="".concat(s+1,". ").concat(a.title),o=function(l,n,i){var r,o;let d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c,u=null!=(r=i.at)?r:a.finishedAt;t.push({key:"".concat(e.id,"|").concat(a.id,"|a").concat(null!=(o=a.attempt)?o:1,"|").concat(l,"|").concat(n),taskId:a.id,kind:l,text:n,where:d,...i,...u?{at:u}:{},...!i.at&&u&&"stop"!==i.from?{atEnd:!0}:{},n:s+1,title:a.title,status:a.status})};for(let e of null!=(i=a.checkResults)?i:[])e.passed||o("error","".concat(e.name,": ").concat(e.detail.slice(0,160)),{from:"check",full:"".concat(e.name,"\n\n").concat(e.detail),at:e.at});if((null==(l=a.review)?void 0:l.verdict)==="fail")for(let e of null!=(r=a.review.findings)?r:[])o("error",e.what.slice(0,200),{from:"review",full:e.what,evidence:e.evidence||void 0,place:e.where,at:a.review.at},e.where?"".concat(c," \xb7 ").concat(e.where):c);["failed","blocked","limit-reached","aborted"].includes(a.status)&&a.reason&&o("warn",a.reason.slice(0,200),{from:"stop",full:a.reason}),(null==(n=a.vcs)?void 0:n.problem)&&o("warn",a.vcs.problem.slice(0,200),{from:"vcs",full:a.vcs.problem,at:a.vcs.problemAt})}),t}(r):[],[m,p]=(0,l.useState)(()=>new Set),[f,x]=(0,l.useState)(!1),[b,g]=(0,l.useState)(()=>new Set);(0,l.useEffect)(()=>p(tU()),[]);let v=e=>p(function(e){let t=[...new Set([...tU(),...e.filter(e=>e)])].slice(-500);try{window.localStorage.setItem(tK,JSON.stringify(t))}catch(e){}return new Set(t)}(e)),j=h.filter(e=>!m.has(e.key)),w=f?h:j,k=h.length-j.length;return(0,s.jsxs)("section",{className:"wb-bottom","aria-label":u("wb.panel"),children:[(0,s.jsxs)("div",{className:"wb-bottom-tabs",role:"tablist","aria-label":u("wb.panel"),children:[tP.map(e=>{let{tab:a,label:r,infoLabel:c,info:o}=e;return(0,s.jsxs)(l.Fragment,{children:[(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":t&&n===a,className:t&&n===a?"on":"",onClick:()=>i(a),children:[u(r),"problems"===a&&j.length>0&&(0,s.jsx)("span",{className:"wb-badge",children:j.length})]}),(0,s.jsx)(tT.q,{label:u(c),text:u(o)})]},a)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":u("wb.cmdPanel"),title:"".concat(u("wb.cmdPanel")," (Ctrl+J)"),onClick:a,children:t?"▾":"▴"})]}),t&&(0,s.jsx)("div",{className:"wb-bottom-body",role:"tabpanel",children:"terminal"===n?o?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.newChatTerminal")}):(0,s.jsx)(tZ,{session:r,task:c}):"problems"===n?0===h.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:o?u("wb.newChatProblems"):r?u("wb.noProblems"):u("wb.pickChat")}):(0,s.jsxs)(s.Fragment,{children:[0===w.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.problemsNoneNew")}):(0,s.jsx)("ul",{className:"wb-problems",children:w.map((e,t)=>{let a=b.has(e.key);return(0,s.jsxs)("li",{className:m.has(e.key)?"seen":void 0,children:[(0,s.jsxs)("div",{className:"wb-problem-line",children:[(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":a,"aria-controls":a?"wb-problem-".concat(t):void 0,onClick:()=>{let t;return t=e.key,g(e=>{let a=new Set(e);return a.delete(t)||a.add(t),a})},title:u(a?"wb.problemLessWhy":"wb.problemMoreWhy"),children:[(0,s.jsx)("span",{className:"wb-fold","aria-hidden":"true",children:a?"▾":"▸"}),(0,s.jsx)("span",{className:"wb-sev ".concat(e.kind),"aria-hidden":"true",children:"error"===e.kind?"✗":"⚠"}),(0,s.jsx)("span",{className:"wb-row-name",children:e.text}),(0,s.jsx)("span",{className:"muted wb-problem-where",children:e.where})]}),!m.has(e.key)&&(0,s.jsx)("button",{type:"button",className:"quiet small wb-seen",onClick:()=>v([e.key]),title:u("wb.problemSeenWhy"),children:u("wb.problemSeen")})]}),a&&r&&(0,s.jsx)(t$,{id:"wb-problem-".concat(t),problem:e,session:r,onShowMessage:d})]},e.key)})}),(j.length>1||k>0)&&(0,s.jsxs)("div",{className:"row wb-pad",children:[j.length>1&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>v(j.map(e=>e.key)),title:u("wb.problemSeenWhy"),children:u("wb.problemsAllSeen")}),k>0&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>x(!f),children:f?u("wb.problemsHideSeen"):u("wb.problemsShowSeen",{n:k})})]})]}):o?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.newChatOutput")}):(0,s.jsx)(tV,{session:r})})]})}let t_={check:"wb.problemFromCheck",review:"wb.problemFromReview",stop:"wb.problemFromStop",vcs:"wb.problemFromVcs"};function t$(e){var t;let{id:a,problem:n,session:i,onShowMessage:r}=e,{t:c}=(0,C.kj)(),o=(0,C.W3)(),d=c("status.".concat(n.status)),u=c(t_[n.from],{status:d}),h=n.at?n.atEnd?c("wb.problemWhenEnd",{time:o(n.at)}):o(n.at):c("wb.problemWhenNone"),m=i.name.replace(/^chat: /,""),p=(null==(t=i.chat)?void 0:t.name)&&i.chat.name!==m?i.chat.name:void 0,f=[["wb.problemWhat",u],["wb.problemWhen",h],["wb.problemChat",p?"".concat(m," (").concat(c("wb.problemInCopilot",{name:p}),")"):m],["wb.problemMessage","".concat(n.n,". ").concat(n.title)],...n.place?[["wb.problemPlace",n.place]]:[]],x=[n.full,...n.evidence?["".concat(c("wb.problemEvidence"),":\n").concat(n.evidence)]:[],f.map(e=>{let[t,a]=e;return"".concat(c(t),": ").concat(a)}).join("\n")].join("\n\n");return(0,s.jsxs)("div",{id:a,className:"wb-problem-more",children:[(0,s.jsx)("dl",{className:"wb-problem-facts",children:f.map(e=>{let[t,a]=e;return(0,s.jsxs)(l.Fragment,{children:[(0,s.jsx)("dt",{children:c(t)}),(0,s.jsx)("dd",{dir:"auto",children:a})]},t)})}),(0,s.jsxs)("div",{className:"row wb-problem-actions",children:[(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>r(n.taskId),children:c("wb.problemShow")}),(0,s.jsx)(en.i8,{text:x,what:"wb.problemCopy"})]}),(0,s.jsx)("p",{className:"wb-problem-full",dir:"auto",children:n.full}),n.evidence&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"muted small wb-problem-label",children:c("wb.problemEvidence")}),(0,s.jsx)("p",{className:"wb-problem-full",dir:"auto",children:n.evidence})]})]})}let tK="cop.problems.seen";function tU(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(tK))?e:"[]");return new Set(Array.isArray(t)?t.filter(e=>"string"==typeof e):[])}catch(e){return new Set}}function tZ(e){var t,a;let{session:n,task:i}=e,{t:r}=(0,C.kj)(),[o,d]=(0,l.useState)(null),u=(null==i?void 0:i.status)==="running"||(null==i?void 0:i.status)==="waiting-approval",{ref:h}=eX(!!u,null!=(t=null==o?void 0:o.entries.length)?t:0),m=()=>n&&i&&(i.startedAt||u)?c.FH.taskStory(n.id,i.id,i.runId).then(d).catch(()=>void 0):Promise.resolve();if((0,l.useEffect)(()=>{d(null),m()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,p.z)(m,u?2e3:15e3,!!n&&!!i),!i)return(0,s.jsx)("p",{className:"muted small wb-pad",children:r("wb.pickChat")});let f=[],x=e=>e.forEach(e=>"step"===e.kind?f.push(e):"review"===e.kind?x(e.entries):void 0);return(x(null!=(a=null==o?void 0:o.entries)?a:[]),0===f.length)?(0,s.jsx)("p",{className:"muted small wb-pad",children:o?r("wb.noSteps"):r("wb.loading")}):(0,s.jsx)("div",{ref:h,className:"wb-terminal","aria-live":"off",children:f.map((e,t)=>(0,s.jsxs)("div",{className:e.failed?"bad":"",children:[(0,s.jsxs)("div",{className:"wb-cmd",children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"$ "}),e.command,(0,s.jsxs)("span",{className:"muted",children:[" ",e.outcome?"".concat(e.outcome).concat(void 0!==e.exitCode?" (".concat(e.exitCode,")"):""):r("wb.runningNow")]})]}),e.output&&(0,s.jsx)("pre",{children:e.output})]},t))})}function tV(e){let{session:t}=e,{t:a}=(0,C.kj)(),n=(0,C.W3)(),[i,r]=(0,l.useState)([]),{ref:o}=eX(!0,i.length),d=()=>t?c.FH.sessionEvents(t.id).then(r).catch(()=>void 0):Promise.resolve();return((0,l.useEffect)(()=>{r([]),d()},[null==t?void 0:t.id]),(0,p.z)(d,3e3,!!t),t)?(0,s.jsx)("div",{ref:o,className:"wb-terminal",children:0===i.length?(0,s.jsx)("p",{className:"muted small",children:a("wb.noEvents")}):i.map((e,t)=>{var a;return(0,s.jsxs)("div",{className:"error"===e.level?"bad":"warn"===e.level?"warnline":"",children:[(0,s.jsxs)("span",{className:"muted",children:[n(e.at)," "]}),null!=(a=e.message)?a:e.type]},t)})}):(0,s.jsx)("p",{className:"muted small wb-pad",children:a("wb.pickChat")})}function tJ(e){var t,a,n,i,r,o,d,u,h,m,f;let{sessions:x,session:b,workspace:g,onShowThread:v,onApprovals:j,onShowWaiting:w}=e,{t:k}=(0,C.kj)(),y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[a,s]=(0,l.useState)(()=>Date.now());return(0,l.useEffect)(()=>{if(!e)return;s(Date.now());let a=window.setInterval(()=>s(Date.now()),t);return()=>window.clearInterval(a)},[e,t]),a}(!0,5e3),[N,S]=(0,l.useState)([]),[F,M]=(0,l.useState)({iterations:60,minutes:240});(0,l.useEffect)(()=>{c.FH.settings().then(e=>{var t,a,s;let l=null!=(t=e.raw.limits)?t:{};M({iterations:null!=(a=l.maxIterations)?a:60,minutes:null!=(s=l.maxRunMinutes)?s:240})}).catch(()=>void 0)},[]);let O=(0,l.useRef)(j);O.current=j,(0,p.z)(()=>c.FH.approvals().then(e=>{var t;S(e),null==(t=O.current)||t.call(O,e)}).catch(()=>void 0),3e3);let E=null!=(r=x.find(e=>"idle"!==e.status&&!e.workerOf))?r:x.find(e=>"idle"!==e.status),L=null==E?void 0:E.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),q=Math.floor(function(e,t,a){let s=e?Date.parse(e):NaN;if(!Number.isFinite(s))return 0;let l=0;for(let e of null!=t?t:[]){let t=Date.parse(e.from),n=e.to?Date.parse(e.to):a;Number.isFinite(t)&&Number.isFinite(n)&&(l+=Math.max(0,Math.min(n,a)-Math.max(t,s)))}return Math.max(0,a-s-l)}(null==L?void 0:L.startedAt,null==E?void 0:E.pauses,y)/6e4);return(0,s.jsxs)("footer",{className:"wb-statusbar","aria-label":k("wb.status"),children:[(null==g?void 0:g.ok)&&(0,s.jsxs)("span",{title:g.dir,children:[(0,s.jsx)(em.O,{})," ",g.branch?"".concat(g.name," \xb7 ").concat(g.branch):g.name]}),E&&L?(0,s.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>v(E.id),title:k("wb.openRunning"),children:[(0,s.jsx)("span",{className:E.paused?"wb-live paused":"wb-live","aria-hidden":"true"})," ",L.acting&&(0,s.jsx)(e4.y,{actor:L.acting.actor,acting:L.acting})," ",L.lead?k("wb.runningLineTwo",{session:E.name.replace(/^chat: /,""),task:L.title,lead:null!=(o=null==(t=L.lead.messages)?void 0:t.lead)?o:0,worker:null!=(d=null==(a=L.lead.messages)?void 0:a.worker)?d:0,total:(null!=(u=null==(n=L.lead.messages)?void 0:n.lead)?u:0)+(null!=(h=null==(i=L.lead.messages)?void 0:i.worker)?h:0),m:q,maxm:F.minutes}):k("wb.runningLine",{session:E.name.replace(/^chat: /,""),task:L.title,n:L.iterations,max:F.iterations,m:q,maxm:F.minutes}),E.paused&&(0,s.jsxs)("strong",{className:"wb-paused",children:[" \xb7 ",k("wb.pausedTag")]})]}):(0,s.jsx)("span",{children:k("wb.idle")}),(0,s.jsx)("span",{className:"grow"}),N.length>0&&(0,s.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;let t=N[0];!t.model&&(null==w?void 0:w(t))||null==(e=document.querySelector(".approval-banner"))||e.scrollIntoView({block:"start"})},children:k("wb.waiting",{n:N.length})}),b&&(0,s.jsx)("span",{title:k("wb.modelNow"),children:null!=(f=null!=(m=b.modelInUse)?m:b.model)?f:k("wb.modelDefault")})]})}function tG(e){let{commands:t,onClose:a}=e,{t:n}=(0,C.kj)(),i=(0,r.useRouter)(),[c,o]=(0,l.useState)(""),[d,u]=(0,l.useState)(0),h=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=h.current)?void 0:e.focus()},[]);let m=(0,l.useMemo)(()=>{let e=c.toLowerCase().split(/\s+/).filter(Boolean);return t.filter(t=>e.every(e=>{var a;return"".concat(t.label," ").concat(null!=(a=t.hint)?a:"").toLowerCase().includes(e)})).slice(0,60)},[c,t]),p=0===m.length?-1:Math.min(d,m.length-1),f=e=>{var t;if(e)if(a(),e.href){let t=e.href;S()?(0,e0.Z)(n("ed.leaveUnkept")).then(e=>e&&i.push(t)):i.push(t)}else null==(t=e.run)||t.call(e)};return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:a,children:(0,s.jsxs)("div",{className:"wb-palette",role:"dialog","aria-modal":"true","aria-label":n("wb.palette"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("input",{ref:h,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"wb-palette-list","aria-activedescendant":p>=0?"wb-cmd-".concat(p):void 0,"aria-label":n("wb.palette"),placeholder:n("wb.palettePlaceholder"),value:c,onChange:e=>{o(e.target.value),u(0)},onKeyDown:e=>{"Escape"===e.key?a():"ArrowDown"===e.key?(e.preventDefault(),u(Math.min(m.length-1,p+1))):"ArrowUp"===e.key?(e.preventDefault(),u(Math.max(0,p-1))):"Enter"===e.key&&(e.preventDefault(),f(m[p]))}}),(0,s.jsxs)("ul",{id:"wb-palette-list",role:"listbox","aria-label":n("wb.palette"),children:[0===m.length&&(0,s.jsx)("li",{className:"muted small",children:n("wb.paletteNone")}),m.map((e,t)=>(0,s.jsxs)("li",{id:"wb-cmd-".concat(t),role:"option","aria-selected":t===p,className:t===p?"on":"",onMouseEnter:()=>u(t),onClick:()=>f(e),children:[(0,s.jsx)("span",{className:"wb-row-name",children:e.label}),e.hint&&(0,s.jsx)("span",{className:"muted small",children:e.hint})]},e.id))]})]})})}function tY(){let{t:e}=(0,C.kj)();return(0,s.jsxs)("section",{className:"kerrigan-about","aria-labelledby":"kerrigan-about-title",children:[(0,s.jsx)("h3",{id:"kerrigan-about-title",children:e("kerrigan.aboutTitle")}),(0,s.jsx)("p",{children:e("kerrigan.aboutWhat")}),(0,s.jsx)("p",{className:"kerrigan-about-uses",children:e("kerrigan.aboutUses")}),(0,s.jsxs)("ul",{children:[(0,s.jsx)("li",{children:e("kerrigan.aboutUse1")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse2")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse3")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse4",{file:e("chatloc.file")})})]}),(0,s.jsx)("p",{className:"kerrigan-about-uses",children:e("kerrigan.aboutStepsTitle")}),(0,s.jsxs)("ol",{children:[(0,s.jsx)("li",{children:e("kerrigan.aboutStep1",{button:e("kerrigan.button"),copy:e("kerrigan.copy"),save:e("kerrigan.save")})}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep2")}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep3")}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep4")})]}),(0,s.jsx)("p",{className:"muted small",children:e("kerrigan.aboutFresh")}),(0,s.jsx)("p",{className:"muted small",children:e("kerrigan.aboutNote")})]})}function tQ(e){let{workspace:t}=e,{t:a,locale:n}=(0,C.kj)(),i=(0,tT.f)("below"),[r,o]=(0,l.useState)(""),[d,u]=eJ(),[h,m]=(0,l.useState)([]);(0,l.useEffect)(()=>{c.FH.skills().then(e=>m(e.skills)).catch(()=>void 0)},[]);let p=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),f=h.filter(e=>!e.projectDir||(null==t?void 0:t.ok)&&p(e.projectDir)===p(t.dir)),x=async()=>{try{let e=await c.FH.kerrigan(n,d||void 0);return e.filled?e:{...e,text:e.text.replace(/⟦([\w.-]+)⟧/g,(e,t)=>a(t))}}catch(e){return o(a("kerrigan.failed",{reason:e.message})),null}},b=async()=>{i.close();let e=await x();if(!e)return;let t=URL.createObjectURL(new Blob([e.text],{type:"text/markdown;charset=utf-8"})),s=document.createElement("a");s.href=t,s.download=e.fileName,s.click(),URL.revokeObjectURL(t),o(a("kerrigan.saved",{name:e.fileName}))},g=async()=>{i.close();let e=await x();e&&o(await (0,en.Dk)(e.text)?a("kerrigan.copied",{n:e.text.length}):a("kerrigan.copyFailed"))};return(0,s.jsxs)("div",{className:"kerrigan",children:[(0,s.jsxs)("div",{className:"row",children:[(0,s.jsxs)("button",{ref:i.anchor,type:"button",className:"primary","aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,onClick:()=>{i.open||x(),i.toggle()},children:[a("kerrigan.button")," ",(0,s.jsx)("span",{"aria-hidden":"true",children:"▾"})]}),(0,s.jsx)(tT.q,{label:a("kerrigan.infoLabel"),text:a("kerrigan.info")}),f.length>0&&(0,s.jsxs)("span",{className:"kerrigan-skill",children:[(0,s.jsx)("label",{htmlFor:"kerrigan-skill",className:"cs-pick-label",children:a("chat.skill")}),(0,s.jsxs)("select",{id:"kerrigan-skill",value:d,onChange:e=>u(e.target.value),children:[(0,s.jsx)("option",{value:"",children:a("chat.skillNone")}),f.map(e=>(0,s.jsxs)("option",{value:e.name,title:e.description||void 0,children:["/",e.name]},e.name))]}),(0,s.jsx)(tT.q,{label:a("info.about",{name:a("chat.skill")}),text:a("kerrigan.skillWhy")})]})]}),i.open&&(0,s.jsxs)("div",{ref:i.panel,id:i.id,role:"menu","aria-label":a("kerrigan.menu"),className:"pop menu",style:i.style,children:[(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void b(),children:a("kerrigan.save")}),(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void g(),children:a("kerrigan.copy")})]}),r&&(0,s.jsx)("p",{className:"small",role:"status",children:r})]})}var tX=a(83285);let t0=(e,t)=>0===t||/[/\\._\-\s]/.test(e[t-1])||/[a-z]/.test(e[t-1])&&/[A-Z]/.test(e[t]);function t1(e,t){let a=e.toLowerCase(),s=[],l=0,n=0,i=-2;for(let r of t.toLowerCase()){let t=a.indexOf(r,n);if(t<0)return null;for(let s=t;s>=0&&s<a.length&&s<t+12;s=a.indexOf(r,s+1))if(t0(e,s)){t=s;break}l+=1,t===i+1&&(l+=5),t0(e,t)&&(l+=3),e[t]===r&&(l+=1),s.push(t),i=t,n=t+1}return{score:l-.05*Math.max(0,s[0]),hits:s}}function t2(e,t){let a=new Set(t),l=[],n="",i=!1,r=e=>{n&&(l.push(i?(0,s.jsx)("mark",{className:"qo-hit",children:n},e):n),n="")};return[...e].forEach((e,t)=>{let s=a.has(t);s!==i&&(r(t),i=s),n+=e}),r(e.length),l}function t3(e){let{recent:t,onOpen:a,onClose:n}=e,{t:i}=(0,C.kj)(),[r,o]=(0,l.useState)(null),[d,u]=(0,l.useState)(""),[h,m]=(0,l.useState)(0),[p,f]=(0,l.useState)(!1),x=(0,l.useRef)(null),b=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=x.current)?void 0:e.focus()},[]),(0,l.useEffect)(()=>{c.FH.workspaceFiles().then(e=>o(e.files)).catch(()=>o([]))},[]);let{query:g,line:v}=function(e){let t=/^(.*?):(\d+)(?::\d+)?\s*$/.exec(e);return t?{query:t[1],line:Number(t[2])}:{query:e}}(d),j=(0,l.useMemo)(()=>{if(!r)return[];if(!g.trim()){let e=new Set(r),a=t.filter(t=>e.has(t)),s=r.filter(e=>!a.includes(e)).slice(0,50);return[...a.map(e=>({path:e,score:0,nameHits:[],dirHits:[],recent:!0})),...s.map(e=>({path:e,score:0,nameHits:[],dirHits:[]}))]}return function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,s=[];for(let a of e){let e=function(e,t){let a=t.trim();if(!a)return{path:e,score:0,nameHits:[],dirHits:[]};let s=e.lastIndexOf("/"),l=e.slice(s+1),n=s>=0?e.slice(0,s):"",i=0,r=[],c=[];for(let t of a.split(/\s+/).filter(Boolean)){if(t.includes("/")){let a=t1(e,t);if(!a)return null;for(let e of(i+=a.score,a.hits))e>s?r.push(e-s-1):c.push(e);continue}let a=t1(l,t);if(a){i+=a.score+10+8*!!l.toLowerCase().startsWith(t.toLowerCase()),r.push(...a.hits);continue}let n=t1(e,t);if(!n)return null;for(let e of(i+=n.score,n.hits))e>s?r.push(e-s-1):c.push(e)}return{path:e,score:i-.01*e.length-(n?.2*n.split("/").length:0),nameHits:r,dirHits:c}}(a,t);e&&s.push(e)}return s.sort((e,t)=>t.score-e.score||e.path.localeCompare(t.path)).slice(0,a)}(r,g,60)},[r,g,t]),w=0===j.length?-1:Math.min(h,j.length-1);(0,l.useEffect)(()=>{var e,t;null==(t=b.current)||null==(e=t.querySelector('[aria-selected="true"]'))||e.scrollIntoView({block:"nearest"})},[w]);let k=e=>{e&&(n(),a(e.path,v))};return(0,l.useEffect)(()=>{p&&r&&(f(!1),k(j[0]))},[p,r]),(0,s.jsx)("div",{className:"modal-backdrop qo-backdrop",role:"presentation",onClick:n,children:(0,s.jsxs)("div",{className:"wb-palette qo",role:"dialog","aria-modal":"true","aria-label":i("quick.label"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("input",{ref:x,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"qo-list","aria-activedescendant":w>=0?"qo-".concat(w):void 0,"aria-label":i("quick.label"),placeholder:i("quick.placeholder"),value:d,spellCheck:!1,onChange:e=>{u(e.target.value),m(0)},onKeyDown:e=>{"Escape"===e.key?n():"ArrowDown"===e.key?(e.preventDefault(),m(Math.min(j.length-1,w+1))):"ArrowUp"===e.key?(e.preventDefault(),m(Math.max(0,w-1))):"Enter"===e.key&&(e.preventDefault(),r?k(j[w]):f(!0))}}),(0,s.jsxs)("ul",{id:"qo-list",ref:b,role:"listbox","aria-label":i("quick.label"),children:[r&&0===j.length&&(0,s.jsx)("li",{className:"muted small qo-none",children:i("quick.none")}),j.map((e,t)=>{let a=e.path.lastIndexOf("/"),l=e.path.slice(a+1),n=a>=0?e.path.slice(0,a):"";return(0,s.jsxs)("li",{id:"qo-".concat(t),role:"option","aria-selected":t===w,className:"qo-row".concat(t===w?" on":""),onMouseEnter:()=>m(t),onClick:()=>k(e),title:e.path,children:[(0,s.jsx)(et,{path:e.path}),(0,s.jsx)("span",{className:"qo-name",children:t2(l,e.nameHits)}),n&&(0,s.jsx)("span",{className:"qo-dir",children:t2(n,e.dirHits)}),"recent"in e&&e.recent&&(0,s.jsx)("span",{className:"qo-tag",children:i("quick.recent")})]},e.path)})]})]})})}function t4(e){var t;let{onOpen:a,grip:n,focusAsk:i}=e,{t:r}=(0,C.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,p]=(0,l.useState)(!1),[f,x]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!1),[v,j]=(0,l.useState)(""),[w,k]=(0,l.useState)(""),[y,N]=(0,l.useState)(null),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[E,L]=(0,l.useState)(new Set),q=(0,l.useRef)(null),z=(0,l.useRef)(0);(0,l.useEffect)(()=>{if(i>0){var e,t;null==(e=q.current)||e.focus(),null==(t=q.current)||t.select()}},[i]);let I=async()=>{let e=++z.current;if(!o){N(null),F(!1),O("");return}F(!0);try{let t=await c.FH.workspaceSearch(o,{matchCase:u,wholeWord:m,regex:f,include:v,exclude:w});if(e!==z.current)return;N(t),O(""),L(new Set)}catch(t){e===z.current&&O(t.message)}finally{e===z.current&&F(!1)}};(0,l.useEffect)(()=>{let e=setTimeout(()=>void I(),300);return()=>clearTimeout(e)},[o,u,m,f,v,w]);let D=null!=(t=null==y?void 0:y.files)?t:[],W=D.length>0&&D.every(e=>E.has(e.path)),A=(e,t,a,l,n)=>(0,s.jsx)("button",{type:"button",className:"sv-toggle ".concat(n).concat(t?" on":""),"aria-pressed":t,"aria-label":e,title:e,onClick:()=>a(!t),children:l}),R=S?r("search.searching"):M||(null==y?void 0:y.problem)?r("search.problem",{why:M||(null==y?void 0:y.problem)||""}):y&&o?0===y.total?r("search.none"):r("search.results",{n:y.total,files:D.length}):"";return(0,s.jsxs)("div",{className:"sv",children:[(0,s.jsxs)("div",{className:"wb-side-head",children:[n,(0,s.jsx)("h2",{children:r("search.title")}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void I(),disabled:!o,"aria-label":r("search.refresh"),title:r("search.refresh"),children:"↻"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>{var e;d(""),N(null),null==(e=q.current)||e.focus()},disabled:!o&&!y,"aria-label":r("search.clear"),title:r("search.clear"),children:(0,s.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:(0,s.jsx)("path",{d:"M3 4h10M6 4V2.5h4V4M4.5 4l.7 9.5h5.6L11.5 4"})})}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>L(W?new Set:new Set(D.map(e=>e.path))),disabled:0===D.length,"aria-label":r(W?"search.expand":"search.collapse"),title:r(W?"search.expand":"search.collapse"),children:(0,s.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:W?(0,s.jsx)("path",{d:"M4 6l4 4 4-4"}):(0,s.jsx)("path",{d:"M3 3h10v10H3zM5.5 8h5"})})})]}),(0,s.jsxs)("div",{className:"sv-form",children:[(0,s.jsxs)("div",{className:"sv-row",children:[(0,s.jsx)("button",{type:"button",className:"sv-details".concat(b?" on":""),"aria-expanded":b,"aria-label":r("search.details"),title:r("search.details"),onClick:()=>g(!b),children:"…"}),(0,s.jsxs)("div",{className:"sv-box",children:[(0,s.jsx)("input",{ref:q,type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&I()},placeholder:r("search.input"),"aria-label":r("search.input"),spellCheck:!1}),A(r("search.matchCase"),u,h,"Aa","case"),A(r("search.wholeWord"),m,p,(0,s.jsx)("span",{className:"sv-word",children:"ab"}),"word"),A(r("search.regex"),f,x,".*","regex")]})]}),b&&(0,s.jsxs)("div",{className:"sv-globs",children:[(0,s.jsx)("label",{htmlFor:"sv-include",children:r("search.include")}),(0,s.jsx)("input",{id:"sv-include",type:"text",value:v,onChange:e=>j(e.target.value),placeholder:r("search.includePlaceholder"),spellCheck:!1}),(0,s.jsx)("label",{htmlFor:"sv-exclude",children:r("search.exclude")}),(0,s.jsx)("input",{id:"sv-exclude",type:"text",value:w,onChange:e=>k(e.target.value),placeholder:r("search.excludePlaceholder"),spellCheck:!1})]}),R&&(0,s.jsx)("p",{className:"sv-message".concat(M||(null==y?void 0:y.problem)?" bad":""),role:"status",children:R}),(null==y?void 0:y.truncated)&&!S&&(0,s.jsx)("p",{className:"sv-message",children:r("search.truncated")})]}),(0,s.jsx)("div",{className:"sv-results",role:"tree","aria-label":r("search.title"),children:D.map(e=>{let t=!E.has(e.path),l=e.path.lastIndexOf("/");return(0,s.jsxs)("div",{role:"treeitem","aria-expanded":t,"aria-selected":!1,className:"sv-file",children:[(0,s.jsxs)("button",{type:"button",className:"sv-file-head",onClick:()=>L(t=>{let a=new Set(t);return a.has(e.path)?a.delete(e.path):a.add(e.path),a}),title:e.path,children:[(0,s.jsx)("span",{className:"sv-chevron".concat(t?" open":""),"aria-hidden":"true",children:"›"}),(0,s.jsx)(et,{path:e.path}),(0,s.jsx)("span",{className:"sv-name",children:e.path.slice(l+1)}),l>0&&(0,s.jsx)("span",{className:"sv-dir",children:e.path.slice(0,l)}),(0,s.jsx)("span",{className:"sv-count",children:e.matches.reduce((e,t)=>e+Math.max(1,t.ranges.length),0)})]}),t&&(0,s.jsx)("div",{role:"group",children:e.matches.map((t,l)=>(0,s.jsx)("button",{type:"button",role:"treeitem","aria-selected":!1,className:"sv-match",title:"".concat(e.path,":").concat(t.line),onClick:()=>{var s;return a({path:e.path,line:t.line,...void 0!==t.column?{from:t.column,to:t.column+(null!=(s=t.length)?s:0)}:{}})},onDoubleClick:()=>{var s;return a({path:e.path,line:t.line,...void 0!==t.column?{from:t.column,to:t.column+(null!=(s=t.length)?s:0)}:{}},!0)},children:function(e,t){let a=[],l=0;return t.forEach((t,n)=>{let[i,r]=t;i>l&&a.push(e.slice(l,i)),a.push((0,s.jsx)("mark",{className:"sv-hit",children:e.slice(i,r)},n)),l=r}),l<e.length&&a.push(e.slice(l)),a}(t.text,t.ranges)},"".concat(t.line,"-").concat(l)))})]},e.path)})})]})}let t5=["side","center","chat"],t6="application/x-cop-area",t8=["wb.moveLeft","wb.moveCenter","wb.moveRight"];function t7(e){let{name:t,place:a,onMove:l,onDragging:n}=e,{t:i}=(0,C.kj)(),r=(0,tT.f)("below");return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{ref:r.anchor,type:"button",className:"wb-grip",draggable:!0,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?r.id:void 0,"aria-label":i("wb.move",{name:t}),title:i("wb.moveWhy"),onClick:r.toggle,onDragStart:e=>{var t,a;e.dataTransfer.setData(t6,null!=(a=null==(t=e.currentTarget.closest("[data-area]"))?void 0:t.dataset.area)?a:""),e.dataTransfer.effectAllowed="move",r.close(),n(!0)},onDragEnd:()=>n(!1),children:(0,s.jsx)("svg",{viewBox:"0 0 10 16",width:"8",height:"13","aria-hidden":"true",children:[3,8,13].map(e=>(0,s.jsxs)("g",{children:[(0,s.jsx)("circle",{cx:"2.5",cy:e,r:"1.4",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"7.5",cy:e,r:"1.4",fill:"currentColor"})]},e))})}),r.open&&(0,s.jsx)("div",{ref:r.panel,id:r.id,role:"menu","aria-label":i("wb.move",{name:t}),className:"pop wb-move-menu",style:r.style,children:t8.map((e,t)=>(0,s.jsx)("button",{type:"button",role:"menuitem",disabled:t===a,onClick:()=>{r.close(),l(t)},children:i(e)},e))})]})}let t9=e=>{var t;return"diff"===e.kind?"d:".concat(e.area,":").concat(null!=(t=e.commit)?t:"",":").concat(e.path):"f:".concat(e.path)},ae={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0,order:t5},at="cop.workbench.layout";function aa(){return(0,s.jsx)(l.Suspense,{fallback:null,children:(0,s.jsx)(as,{})})}function as(){let{t:e}=(0,C.kj)(),t=(0,r.useRouter)(),[a,n]=(0,l.useState)(null),[o,d]=(0,l.useState)([]),[u,h]=(0,l.useState)(""),[m,f]=(0,l.useState)("files"),[b,y]=(0,l.useState)(""),[M,O]=(0,l.useState)(null),[E,L]=(0,l.useState)(null),[q,z]=(0,l.useState)("terminal"),[I,D]=(0,l.useState)(ae),[W,A]=(0,l.useState)(!1),[R,H]=(0,l.useState)(0),[T,P]=(0,l.useState)(null),[B,_]=(0,l.useState)(new Set),$=(0,l.useCallback)((e,t)=>{t&&d(t=>t.some(t=>"file"===t.kind&&t.path===e&&t.preview)?t.map(t=>"file"===t.kind&&t.path===e?{...t,preview:!1}:t):t),_(a=>{if(a.has(e)===t)return a;let s=new Set(a);return t?s.add(e):s.delete(e),s})},[]),K=(0,l.useCallback)(()=>c.FH.sessions().then(e=>n(e.filter(e=>"chat"===e.kind))).catch(()=>void 0),[]);(0,p.z)(K,3e3);let U=(0,l.useCallback)(()=>c.FH.workspace().then(O).catch(()=>void 0),[]);(0,p.z)(U,1e4);let[Z,V]=(0,l.useState)(null),J=(null==M?void 0:M.ok)?M.dir:null;(0,l.useEffect)(()=>{if(!J||J===Z)return;let e=function(e){let t=w(x)[j(e)];return{tabs:Array.isArray(null==t?void 0:t.tabs)?t.tabs.filter(e=>e&&"file"===e.kind&&"string"==typeof e.path):[],active:"string"==typeof(null==t?void 0:t.active)?t.active:""}}(J);d(e.tabs),h(e.tabs.some(t=>t9(t)===e.active)?e.active:e.tabs[0]?t9(e.tabs[0]):""),_(new Set),V(J)},[J,Z]),(0,l.useEffect)(()=>{if(Z){var e=o.filter(e=>"file"===e.kind).map(e=>({kind:"file",path:e.path,...e.preview?{preview:!0}:{}}));let t=w(x);0===e.length?delete t[j(Z)]:t[j(Z)]={tabs:e,active:u},k(x,t)}},[Z,o,u]),(0,l.useEffect)(()=>{let e=e=>{S()&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),(0,l.useEffect)(()=>{let a=a=>{var s,l;if(!S()||a.defaultPrevented||0!==a.button||a.ctrlKey||a.metaKey||a.shiftKey||a.altKey)return;let n=null==(l=a.target)||null==(s=l.closest)?void 0:s.call(l,"a[href]");if(!n||"_blank"===n.target||n.hasAttribute("download"))return;let i=new URL(n.href,window.location.href);i.origin===window.location.origin&&i.pathname!==window.location.pathname&&(a.preventDefault(),a.stopPropagation(),(0,e0.Z)(e("ed.leaveUnkept")).then(e=>{e&&t.push("".concat(i.pathname).concat(i.search).concat(i.hash))}))};return document.addEventListener("click",a,!0),()=>document.removeEventListener("click",a,!0)},[t,e]);let G=(0,l.useCallback)(async()=>{try{if(S()&&!await (0,e0.Z)(e("ed.leaveUnkept")))return;let t=await c.FH.browseFolder((null==M?void 0:M.dir)||void 0);if(!t.ok){t.reason&&y(t.reason);return}await c.FH.openProjectFolder(t.path),y(""),await U()}catch(e){y(e.message)}},[null==M?void 0:M.dir,U,e]);(0,l.useEffect)(()=>D(function(){try{var e;let t=window.localStorage.getItem(at);if(!t)return ae;let a={...ae,...JSON.parse(t)};return{...a,order:(e=a.order,Array.isArray(e)&&3===e.length&&t5.every(t=>e.includes(t))?e:t5)}}catch(e){return ae}}()),[]),(0,l.useEffect)(()=>{try{window.localStorage.setItem(at,JSON.stringify(I))}catch(e){}},[I]);let Y=(0,l.useCallback)(e=>{let t=t9(e);d(a=>{let s=a.findIndex(e=>t9(e)===t);if(s>=0)return e.preview||!a[s].preview?a:a.map((e,t)=>t===s?{...e,preview:!1}:e);if(!e.preview)return[...a,e];let l=a.findIndex(e=>e.preview);return l<0?[...a,e]:a.map((t,a)=>a===l?e:t)}),h(t)},[]),[Q,X]=(0,l.useState)(null),[ee,ea]=(0,l.useState)(!1),[es,el]=(0,l.useState)(null),[en,ei]=(0,l.useState)(0),er=(0,l.useCallback)((e,t)=>{Y({kind:"file",path:e.path,...t?{}:{preview:!0}}),el(t=>{var a;return{path:e.path,line:e.line,from:e.from,to:e.to,n:(null!=(a=null==t?void 0:t.n)?a:0)+1}})},[Y]),ec=()=>{f("search"),em({sideOpen:!0}),ei(e=>e+1)},eo=async t=>{let a=o.find(e=>t9(e)===t);if((null==a?void 0:a.kind)==="file"&&B.has(a.path)){var s,l;if(!await (0,e0.Z)(e("ed.closeUnsaved",{name:null!=(s=a.path.split("/").pop())?s:a.path})))return;$(a.path,!1),Z&&(l=a.path,g.add(v(Z,l)),N(Z,l))}d(e=>{let a=e.findIndex(e=>t9(e)===t),s=e.filter(e=>t9(e)!==t);return t===u&&h(s[Math.max(0,a-1)]?t9(s[Math.max(0,a-1)]):""),s})},ed=o.find(e=>t9(e)===u),eu=E&&"new"!==E?null==a?void 0:a.find(e=>e.id===E.sessionId):void 0,eh=E&&"new"!==E?null==eu?void 0:eu.tasks.find(e=>e.id===E.taskId):void 0,em=e=>D(t=>({...t,...e})),ef=e=>{let t=o.find(t=>t9(t)===e);t&&(d(t=>t.map(t=>t9(t)===e&&t.preview?{...t,preview:!1}:t)),f("files"),em({sideOpen:!0}),X(e=>{var a;return{path:t.path,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}}))},ex=()=>{em({chatOpen:!0}),H(e=>e+1)},eb=(0,l.useRef)(new Set),eg=e=>{var t;let s=null==a?void 0:a.find(t=>t.id===e.sessionId);if(!s)return!1;em({chatOpen:!0});let l=[];for(let e=s;e&&l.length<4;e=null==a?void 0:a.find(t=>{var a;return t.id===(null!=(a=e.workerOf)?a:e.directedBy)}))e.workerOf||l.push(e.id);if(l.includes(tm(tr)))return!0;let n=null!=(t=l.at(-1))?t:s.id;return P(e=>{var t;return{id:n,n:(null!=(t=null==e?void 0:e.n)?t:0)+1}}),!0};(0,l.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();"k"===t||"p"===t&&e.shiftKey?(e.preventDefault(),A(!0)):"p"===t?(e.preventDefault(),ea(!0)):"f"===t&&e.shiftKey?(e.preventDefault(),ec()):"e"===t&&e.shiftKey?(e.preventDefault(),f("files"),em({sideOpen:!0})):"b"!==t||e.shiftKey?"j"===t?(e.preventDefault(),em({bottomOpen:!I.bottomOpen})):"l"===t&&(e.preventDefault(),ex()):(e.preventDefault(),em({sideOpen:!I.sideOpen}))},t=t=>{var a,s;let l=t.key.toLowerCase();(t.ctrlKey||t.metaKey)&&("k"===l||"l"===l)&&!t.shiftKey&&!t.altKey&&(null==(s=t.target)||null==(a=s.closest)?void 0:a.call(s,".monaco-editor"))&&(t.stopPropagation(),e(t))};return window.addEventListener("keydown",t,!0),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("keydown",e)}},[I]);let ev=(0,l.useMemo)(()=>[{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:ex},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>em({sideOpen:!I.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>em({bottomOpen:!I.bottomOpen})},{id:"quick-open",label:e("wb.cmdQuickOpen"),hint:"Ctrl+P",run:()=>ea(!0)},{id:"search",label:e("wb.cmdSearch"),hint:"Ctrl+Shift+F",run:ec},{id:"layout",label:e("wb.cmdResetLayout"),run:()=>em({order:t5,side:ae.side,chat:ae.chat})},{id:"files",label:e("wb.cmdFiles"),run:()=>{em({sideOpen:!0}),f("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{em({sideOpen:!0}),f("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{em({bottomOpen:!0}),z("problems")}},...ed?[{id:"keep-tab",label:e("wb.cmdKeepTab"),run:()=>ef(u)}]:[],...[["/queue","nav.queue"],["/settings","nav.defaults"],["/system","nav.system"]].map(t=>{let[a,s]=t;return{id:"go:".concat(a),label:e("wb.cmdGo",{page:e(s)}),href:a}}),...(null!=a?a:[]).map(t=>({id:"c:".concat(t.id),label:e("wb.cmdThread",{name:t.name.replace(/^chat: /,"")}),run:()=>{em({chatOpen:!0}),P(e=>{var a;return{id:t.id,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}})}}))],[a,e,I,u,o]),[ej,ew]=(0,l.useState)(!1),[ek,ey]=(0,l.useState)(null),eN=e=>I.order.indexOf(e),eS=I.order.filter(e=>"side"===e?I.sideOpen:"chat"!==e||I.chatOpen),eC=eS.map(e=>1===eN(e)?"minmax(0, 1fr)":"".concat(0===eN(e)?I.side:I.chat,"px"));eC.length>0&&!eC.includes("minmax(0, 1fr)")&&(eC[eC.length-1]="minmax(0, 1fr)");let eF=["46px",...eC.flatMap((e,t)=>0===t?[e]:["5px",e])].join(" "),eM=(e,t)=>em({order:function(e,t,a){let s=e.indexOf(t);if(s<0||a<0||a>2||s===a)return e;let l=[...e];return l[s]=e[a],l[a]=t,l}(I.order,e,t)}),eO=(e,t)=>(0,s.jsx)(t7,{area:e,name:t,place:eN(e),onMove:t=>eM(e,t),onDragging:ew}),eE=t=>({"data-area":t,"data-drop":e("wb.dropHere"),onDragOver:e=>{e.dataTransfer.types.includes(t6)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",ek!==t&&ey(t))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ey(e=>e===t?null:e)},onDrop:e=>{let a=e.dataTransfer.getData(t6);e.preventDefault(),ey(null),ew(!1),a&&a!==t&&I.order.includes(a)&&eM(a,eN(t))}}),eL=e=>"".concat(ej?" wb-drop":"").concat(ek===e?" wb-drop-over":""),ez={"--wb-columns":eF,"--wb-side":I.sideOpen?"".concat(I.side,"px"):"0px","--wb-chat":I.chatOpen?"".concat(I.chat,"px"):"0px","--wb-bottom":I.bottomOpen?"".concat(I.bottom,"px"):"34px"},eI={side:(0,s.jsxs)("aside",{className:"wb-side".concat(eL("side")),"aria-label":e("wb.explorer"),hidden:!I.sideOpen,...eE("side"),children:[(0,s.jsx)("div",{className:"wb-side-view",hidden:"search"!==m,children:(0,s.jsx)(t4,{onOpen:er,grip:"search"===m?eO("side",e("wb.explorer")):void 0,focusAsk:en})}),"search"!==m&&(0,s.jsx)(ep,{view:m,onOpen:Y,reveal:Q,workspace:M,onOpenFolder:()=>void G(),grip:eO("side",e("wb.explorer"))})]},"side"),center:(0,s.jsxs)("section",{className:"wb-center".concat(eL("center")),"aria-label":e("wb.editor"),...eE("center"),children:[(0,s.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[eO("center",e("wb.editor")),0===o.length&&(0,s.jsx)("span",{className:"muted small wb-tabs-empty",children:e("wb.noTabs")}),o.map(t=>{var a,l,n;let i=t9(t),r="diff"===t.kind?"".concat(t.path.split("/").pop()," (").concat("commit"===t.area?(null!=(a=t.commit)?a:"").slice(0,7):"branch"===t.area?"⎇ ".concat(null!=(l=t.commit)?l:""):e("staged"===t.area?"git.index":"git.workingTree"),")"):null!=(n=t.path.split("/").pop())?n:t.path;return(0,s.jsxs)("div",{className:"wb-tab".concat(i===u?" active":"").concat(t.preview?" preview":""),children:[(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":i===u,onClick:()=>h(i),onDoubleClick:()=>ef(i),title:t.preview?"".concat(t.path," \xb7 ").concat(e("wb.previewHint")):t.path,children:["diff"===t.kind?(0,s.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"\xb1"}):(0,s.jsx)(et,{path:t.path}),(0,s.jsx)("span",{className:"wb-tab-label",children:r}),"file"===t.kind&&B.has(t.path)&&(0,s.jsx)("span",{className:"wb-unsaved",title:e("ed.unsaved"),"aria-label":e("ed.unsaved"),children:"●"})]}),(0,s.jsx)("button",{type:"button",className:"wb-tab-close","aria-label":e("wb.closeTab",{name:r}),onClick:()=>void eo(i),children:"\xd7"})]},i)})]}),(0,s.jsxs)("div",{className:"wb-editor",role:"tabpanel",children:[b&&ed&&(0,s.jsxs)("div",{className:"wb-problem err small",role:"alert",children:[(0,s.jsx)("span",{children:b}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>y(""),children:e("git.op.dismiss")})]}),ed?"diff"===ed.kind?(0,s.jsx)(eB,{area:ed.area,path:ed.path,commit:ed.commit},t9(ed)):null:(0,s.jsx)(ac,{workspace:M,problem:b}),Z&&o.map(e=>"file"===e.kind?(0,s.jsx)("div",{className:"wb-file-pane",hidden:t9(e)!==u,children:(0,s.jsx)(eq,{dir:Z,path:e.path,onDirty:$,goTo:(null==es?void 0:es.path)===e.path?es:void 0,onOpenFile:e=>Y({kind:"file",path:e})})},"".concat(Z,"|").concat(t9(e))):null)]}),I.bottomOpen&&(0,s.jsx)(ai,{axis:"y",label:e("wb.resize"),onDrag:e=>em({bottom:al(I.bottom-e,90,700)})}),(0,s.jsx)(tB,{open:I.bottomOpen,onToggle:()=>em({bottomOpen:!I.bottomOpen}),tab:q,onTab:e=>{z(e),em({bottomOpen:!0})},session:eu,task:eh,newChat:"new"===E,onShowMessage:e=>{em({chatOpen:!0}),window.setTimeout(()=>{var t;return null==(t=document.getElementById("cs-turn-".concat(e)))?void 0:t.scrollIntoView({block:"start",behavior:"smooth"})},50)}})]},"center"),chat:(0,s.jsx)("aside",{className:"wb-chat".concat(eL("chat")),"aria-label":e("wb.chatPanel"),hidden:!I.chatOpen,...eE("chat"),children:(0,s.jsx)(tH,{workspace:M,composeAsk:R,showThread:T,onOpenFile:e=>Y({kind:"file",path:e}),onOpenFolder:()=>void G(),onTurn:L,onChange:()=>void K(),onClose:()=>em({chatOpen:!1}),grip:eO("chat",e("wb.chatPanel"))})},"chat")};return(0,s.jsxs)("div",{className:"wb",style:ez,children:[(0,s.jsxs)("header",{className:"wb-top",children:[(0,s.jsxs)("span",{className:"wb-brand",children:[(0,s.jsx)(tX.g,{}),"copilot-operator"]}),(0,s.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>A(!0),title:e("wb.paletteWhy"),children:[(0,s.jsx)("span",{children:e("wb.palette")}),(0,s.jsx)("kbd",{children:"Ctrl+K"})]}),(0,s.jsxs)("nav",{className:"wb-menu","aria-label":e("nav.label"),children:[(0,s.jsx)(i(),{href:"/queue",children:e("nav.queue")}),(0,s.jsx)(i(),{href:"/settings",children:e("nav.defaults")}),(0,s.jsx)(i(),{href:"/system",children:e("nav.system")}),(0,s.jsx)(F.i,{})]})]}),(0,s.jsxs)("div",{className:"wb-body".concat(I.sideOpen?"":" no-side").concat(I.chatOpen?"":" no-chat"),children:[(0,s.jsx)(an,{side:m,sideOpen:I.sideOpen,onSide:e=>{e===m&&I.sideOpen?em({sideOpen:!1}):(f(e),em({sideOpen:!0}))},chatOpen:I.chatOpen,onChat:()=>em({chatOpen:!I.chatOpen}),workspace:M}),I.order.map(t=>{let a=eS.indexOf(t),n=a>0?eS[a-1]:null;return(0,s.jsxs)(l.Fragment,{children:[n&&(0,s.jsx)(ai,{axis:"x",label:e("wb.resize"),onDrag:e=>{0===eN(n)?em({side:al(I.side+e,180,820)}):2===eN(t)&&em({chat:al(I.chat-e,260,820)})}}),eI[t]]},t)})]}),(0,s.jsx)(tJ,{sessions:null!=a?a:[],session:eu,workspace:M,onShowThread:e=>{em({chatOpen:!0}),P(t=>{var a;return{id:e,n:(null!=(a=null==t?void 0:t.n)?a:0)+1}})},onApprovals:e=>{let t=e.filter(e=>{var t;return!eb.current.has(e.id)&&(null==(t=e.kerrigan)?void 0:t.state)!=="thinking"&&!!(null==a?void 0:a.some(t=>t.id===e.sessionId))});for(let e of t)eb.current.add(e.id);t[0]&&eg(t[0])},onShowWaiting:eg}),W&&(0,s.jsx)(tG,{commands:ev,onClose:()=>A(!1)}),ee&&(0,s.jsx)(t3,{recent:o.filter(e=>"file"===e.kind).map(e=>e.path).reverse(),onOpen:(e,t)=>t?er({path:e,line:t}):Y({kind:"file",path:e,preview:!0}),onClose:()=>ea(!1)})]})}let al=(e,t,a)=>Math.max(t,Math.min(a,e));function an(e){var t,a;let{side:n,sideOpen:i,onSide:r,chatOpen:o,onChat:d,workspace:u}=e,{t:h}=(0,C.kj)(),f=(e,t,a,l)=>(0,s.jsxs)("button",{type:"button",className:"wb-act".concat(i&&n===e?" on":""),"aria-pressed":i&&n===e,"aria-label":t,"aria-describedby":(null==l?void 0:l.said)?"wb-act-".concat(e,"-said"):void 0,title:(null==l?void 0:l.said)?"".concat(t," \xb7 ").concat(l.said):t,onClick:()=>r(e),children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a}),null==l?void 0:l.badges,(null==l?void 0:l.said)&&(0,s.jsx)("span",{id:"wb-act-".concat(e,"-said"),className:"sr-only",children:l.said})]}),x=!!(null==u?void 0:u.ok),[b]=m(x?u.dir:""),[g,v]=(0,l.useState)(null),j=(0,l.useCallback)(()=>c.FH.workspaceGitCounts(b||void 0).then(v).catch(()=>v(null)),[b]);(0,l.useEffect)(()=>{v(null),x&&j()},[j,x,null==u?void 0:u.dir]),(0,p.z)(j,5e3,x);let w=(null==g?void 0:g.isRepo)?g.uncommitted:0,k=(null==g?void 0:g.isRepo)&&null!=(t=g.branch)?t:0,y=h("git.badgeUncommitted",{n:w}),N=h("git.badgeBranch",{n:k,base:null!=(a=null==g?void 0:g.base)?a:""}),S=[...w>0?[y]:[],...k>0?[N]:[]].join(" \xb7 "),F=e=>e>99?"99+":String(e),M=(0,s.jsxs)(s.Fragment,{children:[w>0&&(0,s.jsx)("span",{className:"wb-act-badge uncommitted","aria-hidden":"true",children:F(w)}),k>0&&(0,s.jsx)("span",{className:"wb-act-badge branch","aria-hidden":"true",children:F(k)})]});return(0,s.jsxs)("nav",{className:"wb-activity","aria-label":h("wb.views"),children:[f("files",h("wb.viewFiles"),(0,s.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),f("search",h("wb.search"),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"10.5",cy:"10.5",r:"6"}),(0,s.jsx)("path",{d:"M15 15l5 5"})]})),f("commits",h("wb.viewCommits"),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M12 3v6M12 15v6"})]}),{said:S,badges:M}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-act".concat(o?" on":""),"aria-pressed":o,"aria-label":h("wb.toggleChat"),title:"".concat(h("wb.toggleChat")," (Ctrl+L)"),onClick:d,children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",children:(0,s.jsx)("path",{d:"M4 5h16v11H9l-5 4z"})})})]})}function ai(e){let{axis:t,label:a,onDrag:n}=e,i=(0,l.useRef)(null);return(0,s.jsx)("div",{className:"wb-split ".concat(t),role:"separator","aria-orientation":"x"===t?"vertical":"horizontal","aria-label":a,tabIndex:0,onPointerDown:e=>{i.current="x"===t?e.clientX:e.clientY,e.target.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(null===i.current)return;let a="x"===t?e.clientX:e.clientY;n(a-i.current),i.current=a},onPointerUp:()=>i.current=null,onKeyDown:e=>{let a=e.shiftKey?40:12;("x"===t&&"ArrowLeft"===e.key||"y"===t&&"ArrowUp"===e.key)&&n(-a),("x"===t&&"ArrowRight"===e.key||"y"===t&&"ArrowDown"===e.key)&&n(a)}})}function ar(e){var t;let{status:a}=e,{t:l}=(0,C.kj)();return(0,s.jsx)("span",{className:"wb-status s-".concat(a),title:l("status.".concat(a)),"aria-label":l("status.".concat(a)),role:"img",children:null!=(t=({done:"✓",failed:"✗",blocked:"⊘","limit-reached":"⏸",aborted:"■",queued:"○",running:"●","waiting-approval":"◐"})[a])?t:"\xb7"})}function ac(e){let{workspace:t,problem:a}=e,{t:l}=(0,C.kj)();return(0,s.jsxs)("div",{className:"wb-welcome",children:[(0,s.jsx)("h2",{children:(null==t?void 0:t.ok)?t.name:l("wb.welcome")}),(0,s.jsx)("p",{className:"muted",children:(null==t?void 0:t.ok)?l("wb.welcomeChat",{dir:t.dir}):l("wb.welcomeWhy")}),a&&(0,s.jsx)("p",{className:"err small",children:a}),(0,s.jsx)(tQ,{workspace:t}),(0,s.jsx)(tY,{}),(0,s.jsx)("p",{className:"muted small",children:l("wb.keys")})]})}function ao(){return(0,s.jsx)(aa,{})}},92364:(e,t,a)=>{Promise.resolve().then(a.bind(a,60405))}},e=>{e.O(0,[8197,7921,895,6240,1024,2347,3131,7358],()=>e(e.s=92364)),_N_E=e.O()}]);
|