copilot-operator 0.1.22 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/src/api/operator.controller.js +2 -2
  2. package/dist/src/api/operator.service.js +330 -35
  3. package/dist/src/exec/confinement.js +85 -7
  4. package/dist/src/exec/programs.js +12 -3
  5. package/dist/src/exec/reportFile.js +5 -3
  6. package/dist/src/exec/shells.js +13 -2
  7. package/dist/src/log/runLog.js +6 -1
  8. package/dist/src/orchestrator/contract.js +29 -7
  9. package/dist/src/orchestrator/review.js +16 -3
  10. package/dist/src/orchestrator/taskRunner.js +391 -54
  11. package/dist/src/plan/schema.js +11 -1
  12. package/dist/src/plan/systemGuide.js +36 -4
  13. package/dist/src/protocol/parser.js +33 -5
  14. package/dist/src/protocol/reporter.js +2 -0
  15. package/dist/src/session/compose.js +18 -9
  16. package/dist/src/session/exportRecord.js +12 -3
  17. package/dist/src/session/exports.js +46 -9
  18. package/dist/src/session/handoff.js +5 -2
  19. package/dist/src/session/interruption.js +3 -1
  20. package/dist/src/session/runLog.js +42 -1
  21. package/dist/src/session/runName.js +3 -1
  22. package/dist/src/session/store.js +7 -2
  23. package/dist/src/transport/copilotTransport.js +89 -62
  24. package/dist/src/transport/modelMatch.js +37 -0
  25. package/dist/src/vcs/artifacts.js +20 -7
  26. package/dist/src/vcs/commitHygiene.js +7 -2
  27. package/dist/src/vcs/contentIntegrity.js +65 -6
  28. package/dist/src/vcs/git.js +44 -7
  29. package/dist/src/vcs/prepareFromRemote.js +46 -9
  30. package/dist/src/vcs/remoteAuth.js +92 -0
  31. package/dist/src/vcs/runPreflight.js +100 -31
  32. package/dist/src/vcs/scope.js +18 -2
  33. package/dist/src/vcs/snapshot.js +61 -16
  34. package/dist/src/vcs/syncCommand.js +3 -11
  35. package/dist/src/vcs/taskVcs.js +173 -24
  36. package/dist/web/404.html +2 -2
  37. package/dist/web/_next/static/chunks/549-7e35e4fdefadb05d.js +1 -0
  38. package/dist/web/_next/static/chunks/867-52e371cb1ec49089.js +1 -0
  39. package/dist/web/_next/static/chunks/app/defaults/{page-cdc730adea753446.js → page-62c8fbe84baa436a.js} +1 -1
  40. package/dist/web/_next/static/chunks/app/page-4defcfd1eb482644.js +1 -0
  41. package/dist/web/_next/static/chunks/app/sessions/view/{page-185755ada66e2930.js → page-2d3bbc68b27fed2c.js} +1 -1
  42. package/dist/web/appearance.html +2 -2
  43. package/dist/web/appearance.txt +10 -10
  44. package/dist/web/defaults.html +2 -2
  45. package/dist/web/defaults.txt +10 -10
  46. package/dist/web/history.html +2 -2
  47. package/dist/web/history.txt +10 -10
  48. package/dist/web/import.html +2 -2
  49. package/dist/web/import.txt +10 -10
  50. package/dist/web/index.html +2 -2
  51. package/dist/web/index.txt +10 -10
  52. package/dist/web/level1.html +2 -2
  53. package/dist/web/level1.txt +10 -10
  54. package/dist/web/presets.html +2 -2
  55. package/dist/web/presets.txt +10 -10
  56. package/dist/web/sessions/view.html +2 -2
  57. package/dist/web/sessions/view.txt +10 -10
  58. package/dist/web/system.html +2 -2
  59. package/dist/web/system.txt +10 -10
  60. package/package.json +3 -2
  61. package/prompts/level1.md +10 -3
  62. package/dist/web/_next/static/chunks/549-5f90780046c1c24f.js +0 -1
  63. package/dist/web/_next/static/chunks/867-79f07bebe3084811.js +0 -1
  64. package/dist/web/_next/static/chunks/app/page-0a861b38da0a1c51.js +0 -1
  65. /package/dist/web/_next/static/{9Ze8aagkvT-WLfD4KCKKS → beP1HgHJZvBVRTsoU1sZv}/_buildManifest.js +0 -0
  66. /package/dist/web/_next/static/{9Ze8aagkvT-WLfD4KCKKS → beP1HgHJZvBVRTsoU1sZv}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var a=t(3365),n=t(1521),s=t(867),r=t(4969);let i=null,o=[];function d(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var a;return a={kind:"confirm",message:e,...l,resolve:t},void(i?i(a):o.push(a))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,s.kj)(),[u,m]=(0,n.useState)([]),h=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(i=e=>m(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);m(l=>[...l,...e])}return()=>{i=null}},[]);let x=u[0],j=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,r.V)(p,!!x,h),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,a.jsxs)(a.Fragment,{children:[d,x&&(0,a.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,a.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{id:"modal-title",children:null!=(l=x.title)?l:c("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,a.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,a.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:c("dialog.cancel")}),(0,a.jsx)("button",{ref:h,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:c("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>m});var a=t(3365),n=t(1521),s=t(8596),r=t(8197),i=t.n(r),o=t(5549),d=t(867),c=t(1035),u=t(4784);function m(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),[s,r]=(0,n.useState)(!1),[i,u]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,c.Z)(e("model.refreshConfirm"))){r(!0),u(e("model.refreshing"));try{var l;let a=await o.FH.models().then(()=>o.FH.refreshModels());t(a),u(0===a.options.length?null!=(l=a.note)?l:e("model.none"):e("model.refreshed",{n:a.options.length}))}catch(e){u(e.message)}finally{r(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:s,refreshMsg:i};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:e("def.title")}),(0,a.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,a.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,a.jsx)(v,{}),(0,a.jsx)(y,{}),(0,a.jsx)(b,{...h}),(0,a.jsx)(w,{...h}),(0,a.jsx)(g,{})]})}function h(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,n.useRef)(null),a=(0,n.useRef)(null),s=(0,n.useRef)(e);return s.current=e,(0,n.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),a.current&&s.current(a.current.value)},[]),e=>{t.current&&clearTimeout(t.current),a.current={value:e},t.current=setTimeout(()=>{a.current=null,s.current(e)},l)}}function p(e){let{id:l,value:t,min:s,max:r,onChange:i,disabled:o}=e,[d,c]=(0,n.useState)(String(t));return(0,n.useEffect)(()=>c(e=>x(e)===t?e:String(t)),[t]),(0,a.jsx)("input",{id:l,type:"number",min:s,max:r,step:1,value:d,onChange:e=>{c(e.target.value);let l=x(e.target.value);null!==l&&l>=s&&l<=r&&i(l)},onBlur:()=>{let e=x(d),l=null===e?t:Math.max(s,Math.min(r,e));c(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function x(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function j(e){let{msg:l,onSave:t}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,a.jsx)("button",{className:"quiet",onClick:t,title:n("def.saveAnywayWhy"),children:n("def.saveAnyway")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:l||n("def.savedAutomatically")})]})}function v(){var e;let{t:l}=(0,d.kj)(),[t,s]=(0,n.useState)(null),[r,i]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[x,v]=(0,n.useState)(""),[g,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),S=(0,n.useCallback)(async()=>{try{let e=await o.FH.project();s(e),i(e.rootDir),u(e.name),v("")}catch(e){v(e.message)}},[]);(0,n.useEffect)(()=>{S()},[S]);let C=async(e,l)=>{y(!0),p("");try{let t=await o.FH.setProject(e);return s(t),i(t.rootDir),p(l(t)),v(""),!0}catch(e){return v(e.message),!1}finally{y(!1)}},F=e=>C({rootDir:e},e=>e.rootDir?l("proj.saved",{dir:e.rootDir}):l("proj.cleared")),E=e=>C({name:e},()=>l("proj.nameSaved")),M=h(F),D=h(E),R=async(e,l)=>{y(!0);try{var t;let a=await o.FH.browseFolder(l.trim()||void 0);a.ok?e(a.path):a.cancelled||v(null!=(t=a.reason)?t:"")}catch(e){v(e.message)}finally{y(!1)}},T=null!=(e=null==t?void 0:t.others)?e:[],A=e=>e.map(e=>({name:e.name,rootDir:e.rootDir})),B=async()=>{await C({others:[...A(T),{name:b.trim(),rootDir:N.trim()}]},e=>l("proj.othersSaved",{n:e.others.length}))&&(w(""),k(""))};return(0,a.jsxs)("div",{className:"panel",id:"project",children:[(0,a.jsx)("h2",{children:l("proj.title")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.intro")}),x&&(0,a.jsx)("div",{className:"err",children:x}),(0,a.jsx)("p",{className:"muted small",children:l("proj.listIntro")}),(0,a.jsx)(f,{name:c,dir:r,repoOk:!!(null==t?void 0:t.repoOk),repoProblem:null==t?void 0:t.repoProblem,isDefault:!0,busy:g,onNameInput:e=>{u(e),D(e)},onName:e=>void E(e),onDirInput:e=>{i(e),M(e)},onDir:e=>void F(e),onBrowse:()=>void R(e=>void F(e),r),onRemove:(null==t?void 0:t.rootDir)?()=>void F(""):void 0,removeLabel:l("proj.clear")}),(0,a.jsx)(j,{msg:m}),t&&!t.rootDir&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:l("proj.none")}),T.map((e,t)=>(0,a.jsx)(f,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,busy:g,onName:t=>void C({others:A(T.map(l=>l.name===e.name?{...l,name:t}:l))},()=>l("proj.nameSaved")),onDir:t=>void C({others:A(T.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:T.length})),onBrowse:()=>void R(t=>void C({others:A(T.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:T.length})),e.rootDir),onRemove:()=>{let t;t=e.name,C({others:A(T.filter(e=>e.name!==t))},e=>l("proj.othersSaved",{n:e.others.length}))},removeLabel:l("proj.otherRemove")},"other-".concat(t))),(0,a.jsx)("h3",{id:"others",children:l("proj.addTitle")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.othersIntro")}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("input",{type:"text","aria-label":l("proj.entryName"),value:b,onChange:e=>w(e.target.value),placeholder:l("proj.entryName"),disabled:g,style:{width:160}}),(0,a.jsx)("input",{type:"text",className:"grow","aria-label":l("proj.entryDir"),value:N,onChange:e=>k(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:g}),(0,a.jsx)("button",{onClick:()=>void R(e=>k(e),N),disabled:g,children:l("mirror.browse")}),(0,a.jsx)("button",{className:"primary",onClick:()=>void B(),disabled:g||!b.trim()||!N.trim(),children:l("proj.otherAdd")})]}),(0,a.jsx)("h3",{children:l("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:l("proj.affectsNew")}),(0,a.jsx)("li",{children:l("proj.affectsExisting")}),(0,a.jsx)("li",{children:l("proj.affectsPlan")}),(0,a.jsx)("li",{children:l("proj.affectsNever")})]})]})}function f(e){var l;let{name:t,dir:r,repoOk:i,repoProblem:o,isDefault:c=!1,busy:u,onNameInput:m,onName:h,onDirInput:p,onDir:x,onBrowse:j,onRemove:v,removeLabel:f}=e,{t:g}=(0,d.kj)(),y=(0,n.useId)(),[b,w]=(0,n.useState)(t),[N,k]=(0,n.useState)(r);return(0,n.useEffect)(()=>w(t),[t]),(0,n.useEffect)(()=>k(r),[r]),(0,a.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,a.jsx)("label",{htmlFor:"".concat(y,"-name"),children:g("proj.entryName")}),(0,a.jsx)("input",{id:"".concat(y,"-name"),type:"text",value:b,onChange:e=>{w(e.target.value),null==m||m(e.target.value)},onBlur:()=>{(b!==t||m)&&h(b)},placeholder:r?null!=(l=r.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":g("proj.namePlaceholder")})]}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("label",{htmlFor:"".concat(y,"-dir"),children:g("proj.entryDir")}),(0,a.jsx)("input",{id:"".concat(y,"-dir"),type:"text",value:N,onChange:e=>{k(e.target.value),null==p||p(e.target.value)},onBlur:()=>{(N!==r||p)&&x(N)},placeholder:"C:\\Projects\\my-app"})]}),(0,a.jsx)("button",{onClick:j,disabled:u,children:g("mirror.browse")}),v&&(0,a.jsx)("button",{className:"quiet",onClick:v,disabled:u,children:f})]}),(0,a.jsxs)("div",{className:"row small",style:{marginTop:6},children:[c&&(0,a.jsx)("span",{className:"chip",title:g("proj.isDefaultWhy"),children:g("proj.isDefault")}),r&&(0,a.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?g("proj.isRepo"):o,children:g(i?"proj.otherRepo":"proj.otherNotRepo")}),r&&!i&&(0,a.jsx)("span",{className:"muted",children:o||g("proj.notRepoWhy")})]}),r&&i&&(0,a.jsx)(s.E,{dir:r})]})}function g(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),s=(0,n.useRef)(null),r=(0,n.useRef)(Promise.resolve()),[i,c]=(0,n.useState)(2),[u,m]=(0,n.useState)(2),[x,v]=(0,n.useState)(60),[f,g]=(0,n.useState)(240),[y,b]=(0,n.useState)(900),[w,N]=(0,n.useState)("none"),[k,S]=(0,n.useState)("confirm"),[C,F]=(0,n.useState)("ask"),[E,M]=(0,n.useState)(""),[D,R]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.settings().then(e=>{var l,a,n,r,i,o;s.current=e.raw,t(e.raw);let d=null!=(l=e.raw.limits)?l:{};c("number"==typeof d.retryBlockedInFreshChat?d.retryBlockedInFreshChat:2),m("number"==typeof d.minApproachesBeforeBlocked?d.minApproachesBeforeBlocked:2),v("number"==typeof d.maxIterations?d.maxIterations:60),g("number"==typeof d.maxRunMinutes?d.maxRunMinutes:240);let u=null!=(a=e.raw.copilot)?a:{};b("number"==typeof u.replyTimeoutSec?u.replyTimeoutSec:900);let h=null!=(n=e.raw.execution)?n:{};N(null!=(r=h.isolation)?r:"none"),S(null!=(i=h.mode)?i:"confirm"),F(null!=(o=h.networkFetch)?o:"ask")}).catch(e=>R(e.message))},[]);let T=(l,a,n)=>{let i=async()=>{var r;if(!s.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>s.current),d={...i,[l]:{...null!=(r=i[l])?r:{},[a]:n}};M("");try{await o.FH.saveSettings(d),s.current=d,t(d),M(e("exec.saved")),R("")}catch(e){R(e.message)}},d=r.current.then(i);return r.current=d.catch(()=>void 0),d},A=h(e=>T("limits","retryBlockedInFreshChat",e)),B=h(e=>T("limits","minApproachesBeforeBlocked",e)),I=h(e=>T("limits","maxIterations",e)),H=h(e=>T("limits","maxRunMinutes",e)),P=h(e=>T("copilot","replyTimeoutSec",e)),W=(e,l)=>T("execution",e,l);return(0,a.jsxs)("div",{className:"panel",id:"execution",children:[(0,a.jsx)("h2",{children:e("exec.title")}),(0,a.jsx)("p",{className:"muted small",children:e("exec.intro")}),D&&(0,a.jsx)("div",{className:"err",children:D}),(0,a.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"min-approaches",value:u,min:2,max:20,onChange:e=>{m(e),B(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,a.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{c(e),A(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,a.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-iterations",value:x,min:5,max:200,onChange:e=>{v(e),I(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,a.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-minutes",value:f,min:10,max:1440,onChange:e=>{g(e),H(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,a.jsx)("label",{htmlFor:"reply-timeout",children:e("exec.replyTimeout")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"reply-timeout",value:y,min:60,max:10800,onChange:e=>{b(e),P(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,a.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,a.jsxs)("select",{id:"isolation",value:w,onChange:e=>{let l=e.target.value;N(l),W("isolation",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,a.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,a.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,a.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,a.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.isolationWhy")}),(0,a.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,a.jsxs)("select",{id:"start-mode",value:k,onChange:e=>{let l=e.target.value;S(l),W("mode",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,a.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,a.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,a.jsxs)("select",{id:"network-fetch",value:C,onChange:e=>{let l=e.target.value;F(l),W("networkFetch",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,a.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,a.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,a.jsx)(j,{msg:E}),(0,a.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")})]})}function y(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(""),[s,r]=(0,n.useState)(!1),[i,c]=(0,n.useState)(""),[u,m]=(0,n.useState)(""),h=async()=>{r(!0),m(""),c(e("login.waiting"));try{let e=await o.FH.login(l);e.ok?c(e.message):(c(""),m(e.message))}catch(e){c(""),m(e.message)}finally{r(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"login",children:[(0,a.jsx)("h2",{children:e("login.title")}),(0,a.jsx)("p",{className:"muted small",children:e("login.intro")}),u&&(0,a.jsx)("div",{className:"err",children:u}),(0,a.jsx)("label",{htmlFor:"login-account",children:e("login.account")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"login-account",type:"email",className:"grow",value:l,onChange:e=>t(e.target.value),placeholder:"name@company.com",disabled:s}),(0,a.jsx)("button",{className:"primary",onClick:()=>void h(),disabled:s,children:s?e("login.busy"):e("login.button")})]}),(0,a.jsx)("p",{className:"why",children:e("login.accountWhy")}),i&&(0,a.jsx)("div",{className:"small",role:"status",children:i})]})}function b(e){var l;let{catalogue:t,setCatalogue:s,refreshModels:r,refreshing:i,refreshMsg:c}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[p,x]=(0,n.useState)(""),[v,f]=(0,n.useState)(""),[g,y]=(0,n.useState)(!1),b=null!=(l=null==t?void 0:t.defaultModel)?l:"",w=async e=>{y(!0),x("");try{let l=await o.FH.setDefaultModel(e);t&&s({...t,defaultModel:l.defaultModel}),x(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{y(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"model",children:[(0,a.jsx)("h2",{children:m("def.modelTitle")}),(0,a.jsx)("p",{className:"muted small",children:m("def.modelIntro")}),v&&(0,a.jsx)("div",{className:"err",children:v}),(0,a.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-model",chosen:b,onChange:e=>void w(e),none:m("def.modelNone"),catalogue:t,disabled:g||i}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void w(""),disabled:g||!b,children:m("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void r(),disabled:g||i,children:m("model.refresh")})]}),(0,a.jsx)(j,{msg:p||c}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?m("model.readAt",{t:h(t.readAt),n:t.options.length}):m("model.neverRead")}),(0,a.jsx)("h3",{children:m("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:m("def.modelAffectsNew")}),(0,a.jsx)("li",{children:m("def.modelAffectsExisting")}),(0,a.jsx)("li",{children:m("def.modelAffectsBatch")})]})]})}function w(e){var l,t;let{catalogue:s,setCatalogue:r,refreshModels:c,refreshing:m,refreshMsg:h}=e,{t:p}=(0,d.kj)(),[x,v]=(0,n.useState)(""),[f,g]=(0,n.useState)(""),[y,b]=(0,n.useState)(!1),w=null!=(l=null==s?void 0:s.defaultReviewModel)?l:"",N=async e=>{b(!0),v("");try{let l=await o.FH.setDefaultReviewModel(e);s&&r({...s,defaultReviewModel:l.defaultReviewModel}),v(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),g("")}catch(e){g(e.message)}finally{b(!1)}},k=""!==w&&w===(null!=(t=null==s?void 0:s.defaultModel)?t:"");return(0,a.jsxs)("div",{className:"panel",id:"review",children:[(0,a.jsx)("h2",{children:p("def.reviewTitle")}),(0,a.jsx)("p",{className:"muted small",children:p("def.reviewIntro")}),f&&(0,a.jsx)("div",{className:"err",children:f}),(0,a.jsx)("label",{htmlFor:"default-review-model",children:p("def.reviewField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-review-model",chosen:w,onChange:e=>void N(e),none:p("def.reviewNone"),catalogue:s,disabled:y||m}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:y||!w,children:p("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void c(),disabled:y||m,children:p("model.refresh")})]}),k&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,a.jsx)(j,{msg:x||h}),(0,a.jsx)("h3",{children:p("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:p("def.reviewAffectsNew")}),(0,a.jsx)("li",{children:p("def.reviewAffectsExisting")}),(0,a.jsx)("li",{children:p("def.reviewAffectsBatch")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,a.jsx)(i(),{href:"/",className:"button-link plain",children:p("proj.toSessions")}),(0,a.jsx)(i(),{href:"/import",className:"button-link quiet",children:p("proj.toImport")})]})]})}},4784:(e,l,t)=>{"use strict";t.d(l,{Y:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t;let{id:i,chosen:o,onChange:d,none:c,catalogue:u,disabled:m=!1,style:h}=e,{t:p}=(0,r.kj)(),x=function(e){let[l,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(void 0!==e)return;let l=!0;return s.FH.models().then(e=>{l&&t(e)}).catch(()=>void 0),()=>{l=!1}},[e]),void 0!==e?e:l}(u),j=null!=(l=null==x?void 0:x.options)?l:[],v=j.some(e=>e.name===o),f=j.filter(e=>!e.group),g=new Map;for(let e of j)e.group&&g.set(e.group,[...null!=(t=g.get(e.group))?t:[],e]);return(0,a.jsxs)("select",{id:i,value:o,onChange:e=>d(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...h},children:[(0,a.jsx)("option",{value:"",children:c}),o&&!v&&(0,a.jsx)("option",{value:o,children:p("model.notInList",{name:o})}),f.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name)),[...g.entries()].map(e=>{let[l,t]=e;return(0,a.jsx)("optgroup",{label:l,children:t.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name))},l)})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>s});var a=t(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,l,t){(0,a.useEffect)(()=>{var a,s;if(!l)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(s=null!=(a=null==t?void 0:t.current)?a:null==i?void 0:i.querySelector(n))?s:null;null==o||o.focus();let d=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let t=l[0],a=l[l.length-1],s=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),r&&document.contains(r)&&r.focus()}},[e,l,t])}},8596:(e,l,t)=>{"use strict";t.d(l,{E:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t,i,o,d;let{dir:c,onDone:u}=e,{t:m}=(0,r.kj)(),[h,p]=(0,n.useState)(null),[x,j]=(0,n.useState)(!1),[v,f]=(0,n.useState)(""),[g,y]=(0,n.useState)(""),b=e=>(null!=e?e:"—").slice(0,8),w=async()=>{f(""),y(""),j(!0);try{p(await s.FH.preparePreview(c))}catch(e){f(e.message)}finally{j(!1)}},N=async()=>{if(null==h?void 0:h.fingerprint){f(""),j(!0);try{var e,l;let t=await s.FH.prepareProject(c,h.fingerprint);t.ok?(y(null!=(l=t.result)?l:""),p(null),null==u||u()):f(null!=(e=t.problem)?e:"")}catch(e){f(e.message)}finally{j(!1)}}},k=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:m("prep.more",{n:e.length-30})})]});return(0,a.jsxs)("div",{className:"prepare-folder small",style:{marginTop:8,overflowWrap:"anywhere"},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void w(),disabled:x,children:m("prep.show")}),(0,a.jsx)("p",{className:"why",children:m("prep.why")}),v&&(0,a.jsx)("p",{className:"err",role:"alert",children:v}),g&&(0,a.jsx)("p",{className:"notice",role:"status",children:g}),h&&!h.ok&&(0,a.jsx)("p",{className:"err",children:h.problem}),(null==h?void 0:h.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("p",{children:m("prep.where",{target:null!=(l=h.target)?l:"",commit:b(h.targetCommit),branch:null!=(t=h.branch)?t:"HEAD",head:b(h.head)})}),h.alreadyThere?(0,a.jsx)("p",{children:m("prep.already")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:m("prep.willDo")}),(0,a.jsxs)("ol",{style:{margin:"4px 0",paddingLeft:20},children:[h.savedBranch&&(0,a.jsxs)("li",{children:[m("prep.keepChanges",{changed:h.changed.length,untracked:h.untracked.length,saved:h.savedBranch}),k([...h.changed,...h.untracked])]}),h.savedMainBranch&&(0,a.jsxs)("li",{children:[m("prep.keepMain",{n:h.mainOnlyCommits.length,branch:null!=(i=h.localBranch)?i:"",saved:h.savedMainBranch}),k(h.mainOnlyCommits)]}),(0,a.jsx)("li",{children:m("prep.moveTo",{branch:null!=(o=h.localBranch)?o:"",commit:b(h.targetCommit),target:null!=(d=h.target)?d:""})})]}),h.branchOnlyCommits.length>0&&h.branch&&(0,a.jsx)("p",{children:m("prep.branchStays",{branch:h.branch,n:h.branchOnlyCommits.length})}),(0,a.jsx)("p",{className:"muted",children:m("prep.ignored")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void N(),disabled:x,children:m("prep.confirm")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>p(null),disabled:x,children:m("prep.cancel")})]})]})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var a=t(3365),n=t(1521),s=t(867),r=t(4969);let i=null,o=[];function d(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var a;return a={kind:"confirm",message:e,...l,resolve:t},void(i?i(a):o.push(a))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,s.kj)(),[u,m]=(0,n.useState)([]),h=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(i=e=>m(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);m(l=>[...l,...e])}return()=>{i=null}},[]);let x=u[0],j=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,r.V)(p,!!x,h),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,a.jsxs)(a.Fragment,{children:[d,x&&(0,a.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,a.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{id:"modal-title",children:null!=(l=x.title)?l:c("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,a.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,a.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:c("dialog.cancel")}),(0,a.jsx)("button",{ref:h,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:c("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>m});var a=t(3365),n=t(1521),s=t(8596),r=t(8197),i=t.n(r),o=t(5549),d=t(867),c=t(1035),u=t(4784);function m(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),[s,r]=(0,n.useState)(!1),[i,u]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,c.Z)(e("model.refreshConfirm"))){r(!0),u(e("model.refreshing"));try{var l;let a=await o.FH.models().then(()=>o.FH.refreshModels());t(a),u(0===a.options.length?null!=(l=a.note)?l:e("model.none"):e("model.refreshed",{n:a.options.length}))}catch(e){u(e.message)}finally{r(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:s,refreshMsg:i};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:e("def.title")}),(0,a.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,a.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,a.jsx)(v,{}),(0,a.jsx)(g,{}),(0,a.jsx)(b,{...h}),(0,a.jsx)(w,{...h}),(0,a.jsx)(y,{})]})}function h(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,n.useRef)(null),a=(0,n.useRef)(null),s=(0,n.useRef)(e);return s.current=e,(0,n.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),a.current&&s.current(a.current.value)},[]),e=>{t.current&&clearTimeout(t.current),a.current={value:e},t.current=setTimeout(()=>{a.current=null,s.current(e)},l)}}function p(e){let{id:l,value:t,min:s,max:r,onChange:i,disabled:o}=e,[d,c]=(0,n.useState)(String(t));return(0,n.useEffect)(()=>c(e=>x(e)===t?e:String(t)),[t]),(0,a.jsx)("input",{id:l,type:"number",min:s,max:r,step:1,value:d,onChange:e=>{c(e.target.value);let l=x(e.target.value);null!==l&&l>=s&&l<=r&&i(l)},onBlur:()=>{let e=x(d),l=null===e?t:Math.max(s,Math.min(r,e));c(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function x(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function j(e){let{msg:l,onSave:t}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,a.jsx)("button",{className:"quiet",onClick:t,title:n("def.saveAnywayWhy"),children:n("def.saveAnyway")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:l||n("def.savedAutomatically")})]})}function v(){var e;let{t:l}=(0,d.kj)(),[t,s]=(0,n.useState)(null),[r,i]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[x,v]=(0,n.useState)(""),[y,g]=(0,n.useState)(!1),[b,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),S=(0,n.useCallback)(async()=>{try{let e=await o.FH.project();s(e),i(e.rootDir),u(e.name),v("")}catch(e){v(e.message)}},[]);(0,n.useEffect)(()=>{S()},[S]);let C=async(e,l)=>{g(!0),p("");try{let t=await o.FH.setProject(e);return s(t),i(t.rootDir),p(l(t)),v(""),!0}catch(e){return v(e.message),!1}finally{g(!1)}},F=e=>C({rootDir:e},e=>e.rootDir?l("proj.saved",{dir:e.rootDir}):l("proj.cleared")),M=e=>C({name:e},()=>l("proj.nameSaved")),T=h(F),E=h(M),D=async(e,l)=>{g(!0);try{var t;let a=await o.FH.browseFolder(l.trim()||void 0);a.ok?e(a.path):a.cancelled||v(null!=(t=a.reason)?t:"")}catch(e){v(e.message)}finally{g(!1)}},B=null!=(e=null==t?void 0:t.others)?e:[],R=e=>e.map(e=>({name:e.name,rootDir:e.rootDir})),A=async()=>{await C({others:[...R(B),{name:b.trim(),rootDir:N.trim()}]},e=>l("proj.othersSaved",{n:e.others.length}))&&(w(""),k(""))};return(0,a.jsxs)("div",{className:"panel",id:"project",children:[(0,a.jsx)("h2",{children:l("proj.title")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.intro")}),x&&(0,a.jsx)("div",{className:"err",children:x}),(0,a.jsx)("p",{className:"muted small",children:l("proj.listIntro")}),(0,a.jsx)(f,{name:c,dir:r,repoOk:!!(null==t?void 0:t.repoOk),repoProblem:null==t?void 0:t.repoProblem,isDefault:!0,busy:y,onNameInput:e=>{u(e),E(e)},onName:e=>void M(e),onDirInput:e=>{i(e),T(e)},onDir:e=>void F(e),onBrowse:()=>void D(e=>void F(e),r),onRemove:(null==t?void 0:t.rootDir)?()=>void F(""):void 0,removeLabel:l("proj.clear")}),(0,a.jsx)(j,{msg:m}),t&&!t.rootDir&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:l("proj.none")}),B.map((e,t)=>(0,a.jsx)(f,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,busy:y,onName:t=>void C({others:R(B.map(l=>l.name===e.name?{...l,name:t}:l))},()=>l("proj.nameSaved")),onDir:t=>void C({others:R(B.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:B.length})),onBrowse:()=>void D(t=>void C({others:R(B.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:B.length})),e.rootDir),onRemove:()=>{let t;t=e.name,C({others:R(B.filter(e=>e.name!==t))},e=>l("proj.othersSaved",{n:e.others.length}))},removeLabel:l("proj.otherRemove")},"other-".concat(t))),(0,a.jsx)("h3",{id:"others",children:l("proj.addTitle")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.othersIntro")}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("input",{type:"text","aria-label":l("proj.entryName"),value:b,onChange:e=>w(e.target.value),placeholder:l("proj.entryName"),disabled:y,style:{width:160}}),(0,a.jsx)("input",{type:"text",className:"grow","aria-label":l("proj.entryDir"),value:N,onChange:e=>k(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:y}),(0,a.jsx)("button",{onClick:()=>void D(e=>k(e),N),disabled:y,children:l("mirror.browse")}),(0,a.jsx)("button",{className:"primary",onClick:()=>void A(),disabled:y||!b.trim()||!N.trim(),children:l("proj.otherAdd")})]}),(0,a.jsx)("h3",{children:l("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:l("proj.affectsNew")}),(0,a.jsx)("li",{children:l("proj.affectsExisting")}),(0,a.jsx)("li",{children:l("proj.affectsPlan")}),(0,a.jsx)("li",{children:l("proj.affectsNever")})]})]})}function f(e){var l;let{name:t,dir:r,repoOk:i,repoProblem:o,isDefault:c=!1,busy:u,onNameInput:m,onName:h,onDirInput:p,onDir:x,onBrowse:j,onRemove:v,removeLabel:f}=e,{t:y}=(0,d.kj)(),g=(0,n.useId)(),[b,w]=(0,n.useState)(t),[N,k]=(0,n.useState)(r);return(0,n.useEffect)(()=>w(t),[t]),(0,n.useEffect)(()=>k(r),[r]),(0,a.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,a.jsx)("label",{htmlFor:"".concat(g,"-name"),children:y("proj.entryName")}),(0,a.jsx)("input",{id:"".concat(g,"-name"),type:"text",value:b,onChange:e=>{w(e.target.value),null==m||m(e.target.value)},onBlur:()=>{(b!==t||m)&&h(b)},placeholder:r?null!=(l=r.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":y("proj.namePlaceholder")})]}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("label",{htmlFor:"".concat(g,"-dir"),children:y("proj.entryDir")}),(0,a.jsx)("input",{id:"".concat(g,"-dir"),type:"text",value:N,onChange:e=>{k(e.target.value),null==p||p(e.target.value)},onBlur:()=>{(N!==r||p)&&x(N)},placeholder:"C:\\Projects\\my-app"})]}),(0,a.jsx)("button",{onClick:j,disabled:u,children:y("mirror.browse")}),v&&(0,a.jsx)("button",{className:"quiet",onClick:v,disabled:u,children:f})]}),(0,a.jsxs)("div",{className:"row small",style:{marginTop:6},children:[c&&(0,a.jsx)("span",{className:"chip",title:y("proj.isDefaultWhy"),children:y("proj.isDefault")}),r&&(0,a.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?y("proj.isRepo"):o,children:y(i?"proj.otherRepo":"proj.otherNotRepo")}),r&&!i&&(0,a.jsx)("span",{className:"muted",children:o||y("proj.notRepoWhy")})]}),r&&i&&(0,a.jsx)(s.E,{dir:r})]})}function y(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),s=(0,n.useRef)(null),r=(0,n.useRef)(Promise.resolve()),[i,c]=(0,n.useState)(2),[u,m]=(0,n.useState)(2),[x,v]=(0,n.useState)(60),[f,y]=(0,n.useState)(240),[g,b]=(0,n.useState)(900),[w,N]=(0,n.useState)("none"),[k,S]=(0,n.useState)("confirm"),[C,F]=(0,n.useState)("ask"),[M,T]=(0,n.useState)(""),[E,D]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.settings().then(e=>{var l,a,n,r,i,o;s.current=e.raw,t(e.raw);let d=null!=(l=e.raw.limits)?l:{};c("number"==typeof d.retryBlockedInFreshChat?d.retryBlockedInFreshChat:2),m("number"==typeof d.minApproachesBeforeBlocked?d.minApproachesBeforeBlocked:2),v("number"==typeof d.maxIterations?d.maxIterations:60),y("number"==typeof d.maxRunMinutes?d.maxRunMinutes:240);let u=null!=(a=e.raw.copilot)?a:{};b("number"==typeof u.replyTimeoutSec?u.replyTimeoutSec:900);let h=null!=(n=e.raw.execution)?n:{};N(null!=(r=h.isolation)?r:"none"),S(null!=(i=h.mode)?i:"confirm"),F(null!=(o=h.networkFetch)?o:"ask")}).catch(e=>D(e.message))},[]);let B=(l,a,n)=>{let i=async()=>{var r;if(!s.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>s.current),d={...i,[l]:{...null!=(r=i[l])?r:{},[a]:n}};T("");try{await o.FH.saveSettings(d),s.current=d,t(d),T(e("exec.saved")),D("")}catch(e){D(e.message)}},d=r.current.then(i);return r.current=d.catch(()=>void 0),d},R=h(e=>B("limits","retryBlockedInFreshChat",e)),A=h(e=>B("limits","minApproachesBeforeBlocked",e)),I=h(e=>B("limits","maxIterations",e)),H=h(e=>B("limits","maxRunMinutes",e)),P=h(e=>B("copilot","replyTimeoutSec",e)),W=(e,l)=>B("execution",e,l);return(0,a.jsxs)("div",{className:"panel",id:"execution",children:[(0,a.jsx)("h2",{children:e("exec.title")}),(0,a.jsx)("p",{className:"muted small",children:e("exec.intro")}),E&&(0,a.jsx)("div",{className:"err",children:E}),(0,a.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"min-approaches",value:u,min:2,max:20,onChange:e=>{m(e),A(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,a.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{c(e),R(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,a.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-iterations",value:x,min:5,max:200,onChange:e=>{v(e),I(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,a.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-minutes",value:f,min:10,max:1440,onChange:e=>{y(e),H(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,a.jsx)("label",{htmlFor:"reply-timeout",children:e("exec.replyTimeout")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"reply-timeout",value:g,min:60,max:10800,onChange:e=>{b(e),P(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,a.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,a.jsxs)("select",{id:"isolation",value:w,onChange:e=>{let l=e.target.value;N(l),W("isolation",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,a.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,a.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,a.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,a.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.isolationWhy")}),(0,a.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,a.jsxs)("select",{id:"start-mode",value:k,onChange:e=>{let l=e.target.value;S(l),W("mode",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,a.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,a.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,a.jsxs)("select",{id:"network-fetch",value:C,onChange:e=>{let l=e.target.value;F(l),W("networkFetch",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,a.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,a.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,a.jsx)(j,{msg:M}),(0,a.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")})]})}function g(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(""),[s,r]=(0,n.useState)(!1),[i,c]=(0,n.useState)(""),[u,m]=(0,n.useState)(""),h=async()=>{r(!0),m(""),c(e("login.waiting"));try{let e=await o.FH.login(l);e.ok?c(e.message):(c(""),m(e.message))}catch(e){c(""),m(e.message)}finally{r(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"login",children:[(0,a.jsx)("h2",{children:e("login.title")}),(0,a.jsx)("p",{className:"muted small",children:e("login.intro")}),u&&(0,a.jsx)("div",{className:"err",children:u}),(0,a.jsx)("label",{htmlFor:"login-account",children:e("login.account")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"login-account",type:"email",className:"grow",value:l,onChange:e=>t(e.target.value),placeholder:"name@company.com",disabled:s}),(0,a.jsx)("button",{className:"primary",onClick:()=>void h(),disabled:s,children:s?e("login.busy"):e("login.button")})]}),(0,a.jsx)("p",{className:"why",children:e("login.accountWhy")}),i&&(0,a.jsx)("div",{className:"small",role:"status",children:i})]})}function b(e){var l;let{catalogue:t,setCatalogue:s,refreshModels:r,refreshing:i,refreshMsg:c}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[p,x]=(0,n.useState)(""),[v,f]=(0,n.useState)(""),[y,g]=(0,n.useState)(!1),b=null!=(l=null==t?void 0:t.defaultModel)?l:"",w=async e=>{g(!0),x("");try{let l=await o.FH.setDefaultModel(e);t&&s({...t,defaultModel:l.defaultModel}),x(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{g(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"model",children:[(0,a.jsx)("h2",{children:m("def.modelTitle")}),(0,a.jsx)("p",{className:"muted small",children:m("def.modelIntro")}),v&&(0,a.jsx)("div",{className:"err",children:v}),(0,a.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-model",chosen:b,onChange:e=>void w(e),none:m("def.modelNone"),catalogue:t,disabled:y||i}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void w(""),disabled:y||!b,children:m("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void r(),disabled:y||i,children:m("model.refresh")})]}),(0,a.jsx)(j,{msg:p||c}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?m("model.readAt",{t:h(t.readAt),n:t.options.length}):m("model.neverRead")}),(0,a.jsx)("h3",{children:m("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:m("def.modelAffectsNew")}),(0,a.jsx)("li",{children:m("def.modelAffectsExisting")}),(0,a.jsx)("li",{children:m("def.modelAffectsBatch")})]})]})}function w(e){var l,t;let{catalogue:s,setCatalogue:r,refreshModels:c,refreshing:m,refreshMsg:h}=e,{t:p}=(0,d.kj)(),[x,v]=(0,n.useState)(""),[f,y]=(0,n.useState)(""),[g,b]=(0,n.useState)(!1),w=null!=(l=null==s?void 0:s.defaultReviewModel)?l:"",N=async e=>{b(!0),v("");try{let l=await o.FH.setDefaultReviewModel(e);s&&r({...s,defaultReviewModel:l.defaultReviewModel}),v(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),y("")}catch(e){y(e.message)}finally{b(!1)}},k=""!==w&&w===(null!=(t=null==s?void 0:s.defaultModel)?t:"");return(0,a.jsxs)("div",{className:"panel",id:"review",children:[(0,a.jsx)("h2",{children:p("def.reviewTitle")}),(0,a.jsx)("p",{className:"muted small",children:p("def.reviewIntro")}),f&&(0,a.jsx)("div",{className:"err",children:f}),(0,a.jsx)("label",{htmlFor:"default-review-model",children:p("def.reviewField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-review-model",chosen:w,onChange:e=>void N(e),none:p("def.reviewNone"),catalogue:s,disabled:g||m}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:g||!w,children:p("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void c(),disabled:g||m,children:p("model.refresh")})]}),k&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,a.jsx)(j,{msg:x||h}),(0,a.jsx)("h3",{children:p("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:p("def.reviewAffectsNew")}),(0,a.jsx)("li",{children:p("def.reviewAffectsExisting")}),(0,a.jsx)("li",{children:p("def.reviewAffectsBatch")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,a.jsx)(i(),{href:"/",className:"button-link plain",children:p("proj.toSessions")}),(0,a.jsx)(i(),{href:"/import",className:"button-link quiet",children:p("proj.toImport")})]})]})}},4784:(e,l,t)=>{"use strict";t.d(l,{Y:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t;let{id:i,chosen:o,onChange:d,none:c,catalogue:u,disabled:m=!1,style:h}=e,{t:p}=(0,r.kj)(),x=function(e){let[l,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(void 0!==e)return;let l=!0;return s.FH.models().then(e=>{l&&t(e)}).catch(()=>void 0),()=>{l=!1}},[e]),void 0!==e?e:l}(u),j=null!=(l=null==x?void 0:x.options)?l:[],v=j.some(e=>e.name===o),f=j.filter(e=>!e.group),y=new Map;for(let e of j)e.group&&y.set(e.group,[...null!=(t=y.get(e.group))?t:[],e]);return(0,a.jsxs)("select",{id:i,value:o,onChange:e=>d(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...h},children:[(0,a.jsx)("option",{value:"",children:c}),o&&!v&&(0,a.jsx)("option",{value:o,children:p("model.notInList",{name:o})}),f.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name)),[...y.entries()].map(e=>{let[l,t]=e;return(0,a.jsx)("optgroup",{label:l,children:t.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name))},l)})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>s});var a=t(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,l,t){(0,a.useEffect)(()=>{var a,s;if(!l)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(s=null!=(a=null==t?void 0:t.current)?a:null==i?void 0:i.querySelector(n))?s:null;null==o||o.focus();let d=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let t=l[0],a=l[l.length-1],s=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),r&&document.contains(r)&&r.focus()}},[e,l,t])}},8596:(e,l,t)=>{"use strict";t.d(l,{E:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t,i,o,d,c,u;let{dir:m,onDone:h}=e,{t:p}=(0,r.kj)(),x=(0,r.W3)(),[j,v]=(0,n.useState)(null),[f,y]=(0,n.useState)(""),[g,b]=(0,n.useState)(""),[w,N]=(0,n.useState)(""),[k,S]=(0,n.useState)(!1),C=e=>(null!=e?e:"—").slice(0,8),F=async e=>{b(""),N(""),y(e?"fetch":"prepare");try{v(await s.FH.preparePreview(m,e))}catch(e){b(e.message)}finally{y("")}},M=async()=>{if(null==j?void 0:j.fingerprint){b(""),y("prepare");try{var e,l;let t=await s.FH.prepareProject(m,j.fingerprint,{savedBranch:j.savedBranch,savedMainBranch:j.savedMainBranch});t.ok?(N(null!=(l=t.result)?l:""),v(null),null==h||h()):b(null!=(e=t.problem)?e:"")}catch(e){b(e.message)}finally{y("")}}},T=async e=>{try{await navigator.clipboard.writeText(e),S(!0),window.setTimeout(()=>S(!1),2500)}catch(e){b(p("plan.copyFailed"))}},E=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:p("prep.more",{n:e.length-30})})]}),D=j&&!j.ok&&j.fetched&&!j.fetched.ok;return(0,a.jsxs)("div",{className:"prepare-folder small",style:{marginTop:8,overflowWrap:"anywhere"},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!f,children:p("prep.show")}),(0,a.jsx)("p",{className:"why",children:p("prep.why")}),(0,a.jsx)("p",{className:"why",children:p("prep.password")}),"fetch"===f&&(0,a.jsx)("p",{role:"status",children:p("prep.fetching")}),g&&(0,a.jsx)("p",{className:"err",role:"alert",children:g}),w&&(0,a.jsx)("p",{className:"notice",role:"status",children:w}),j&&!j.ok&&!D&&(0,a.jsx)("p",{className:"err",children:j.problem}),D&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:p("prep.fetchFailed")})," ",(0,a.jsx)("code",{children:null==(l=j.fetched)?void 0:l.detail})]}),(null==(t=j.fetched)?void 0:t.auth)&&(0,a.jsx)("p",{children:p("prep.fetchAuth")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!f,children:p("prep.retry")})}),j.fetchCommand&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{style:{marginTop:8},children:p("prep.ownTerminal")}),(0,a.jsx)("pre",{className:"sync-cmd",children:j.fetchCommand}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{var e;T(null!=(e=j.fetchCommand)?e:"")},children:p("prep.copyFetch")}),k&&(0,a.jsx)("span",{className:"badge done",children:p("prep.copied")}),(0,a.jsx)("button",{type:"button",onClick:()=>void F(!1),disabled:!!f,children:p("prep.useFetched")})]}),j.lastFetched&&(0,a.jsx)("p",{className:"muted",children:p("prep.lastFetched",{when:x(j.lastFetched)})})]})]}),(null==j?void 0:j.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("p",{children:p("prep.where",{target:null!=(i=j.target)?i:"",commit:C(j.targetCommit),branch:null!=(o=j.branch)?o:"HEAD",head:C(j.head)})}),!j.fetched&&(0,a.jsxs)("p",{className:"muted",children:[p("prep.notFetched")," ",j.lastFetched?p("prep.lastFetched",{when:x(j.lastFetched)}):p("prep.lastFetchedUnknown")]}),j.alreadyThere?(0,a.jsx)("p",{children:p("prep.already")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:p("prep.willDo")}),(0,a.jsxs)("ol",{style:{margin:"4px 0",paddingLeft:20},children:[j.savedBranch&&(0,a.jsxs)("li",{children:[p("prep.keepChanges",{changed:j.changed.length,untracked:j.untracked.length,saved:j.savedBranch}),E([...j.changed,...j.untracked])]}),j.savedMainBranch&&(0,a.jsxs)("li",{children:[p("prep.keepMain",{n:j.mainOnlyCommits.length,branch:null!=(d=j.localBranch)?d:"",saved:j.savedMainBranch}),E(j.mainOnlyCommits)]}),(0,a.jsx)("li",{children:p("prep.moveTo",{branch:null!=(c=j.localBranch)?c:"",commit:C(j.targetCommit),target:null!=(u=j.target)?u:""})})]}),j.branchOnlyCommits.length>0&&j.branch&&(0,a.jsx)("p",{children:p("prep.branchStays",{branch:j.branch,n:j.branchOnlyCommits.length})}),(0,a.jsx)("p",{className:"muted",children:p("prep.ignored")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void M(),disabled:!!f,children:p("prep.confirm")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>v(null),disabled:!!f,children:p("prep.cancel")})]})]})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,n,t)=>{"use strict";t.d(n,{DialogHost:()=>o,Z:()=>d});var l=t(3365),a=t(1521),s=t(867),i=t(4969);let r=null,c=[];function d(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var l;return l={kind:"confirm",message:e,...n,resolve:t},void(r?r(l):c.push(l))})}function o(e){var n,t;let{children:d}=e,{t:o}=(0,s.kj)(),[h,u]=(0,a.useState)([]),m=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(r=e=>u(n=>[...n,e]),c.length>0){let e=c.splice(0,c.length);u(n=>[...n,...e])}return()=>{r=null}},[]);let x=h[0],j=(0,a.useCallback)(e=>{x&&(x.resolve(e),u(e=>e.slice(1)))},[x]);return(0,i.V)(p,!!x,m),(0,a.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,l.jsxs)(l.Fragment,{children:[d,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(n=x.title)?n:o("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:o("dialog.cancel")}),(0,l.jsx)("button",{ref:m,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:o("dialog.ok")})]})]})})]})}},4811:(e,n,t)=>{"use strict";t.d(n,{p:()=>s});var l=t(1521),a=t(5549);function s(){let[e,n]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=!0;return a.FH.settings().then(t=>{var l;let a=null!=(l=t.raw.execution)?l:{};e&&n("unattended"===a.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,n,t)=>{"use strict";t.d(n,{V:()=>s});var l=t(1521);let a='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,n,t){(0,l.useEffect)(()=>{var l,s;if(!n)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,c=null!=(s=null!=(l=null==t?void 0:t.current)?l:null==r?void 0:r.querySelector(a))?s:null;null==c||c.focus();let d=e=>{if("Tab"!==e.key||!r)return;let n=Array.from(r.querySelectorAll(a)).filter(e=>null!==e.offsetParent);if(0===n.length)return;let t=n[0],l=n[n.length-1],s=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),i&&document.contains(i)&&i.focus()}},[e,n,t])}},5704:(e,n,t)=>{Promise.resolve().then(t.bind(t,6474))},6474:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>j});var l=t(3365),a=t(1521),s=t(8197),i=t.n(s),r=t(5549),c=t(7527),d=t(867),o=t(1035),h=t(4811),u=t(8848);let m={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function p(e){let{groups:n,sessionIds:t,onChange:s}=e,{t:i}=(0,d.kj)(),[r,c]=(0,a.useState)(""),o=n.filter(e=>!e.ready);return 0===o.length?r?(0,l.jsxs)("p",{className:"notice small",role:"status",children:[(0,l.jsx)("strong",{children:i("runvcs.ready")})," ",r]}):null:(0,l.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,l.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:i("runvcs.title")}),(0,l.jsx)("p",{className:"small",children:i("runvcs.why")}),o.map(e=>(0,l.jsx)(x,{group:e,sessionIds:t,onChange:s,onDone:c},e.repoDir))]})}function x(e){var n;let{group:t,sessionIds:s,onChange:i,onDone:c}=e,{t:o}=(0,d.kj)(),[h,u]=(0,a.useState)(!1),[p,x]=(0,a.useState)(!1),[j,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[f,y]=(0,a.useState)({}),N=(e,n)=>{var t,l;return null!=(l=null!=(t=f[e])?t:n)?l:void 0},w=t.actions.find(e=>"snapshot-here"===e.id&&e.available),k=e=>(null!=e?e:"—").slice(0,8),S=async e=>{if("review-inputs"===e)return void u(e=>!e);g(!0),b("");try{var n,l,a;let d="snapshot-on-base"===e?Object.fromEntries(t.inputs.map(e=>[e.path,"include"])):Object.fromEntries(t.entries.filter(e=>N(e.path,e.choice)).map(e=>[e.path,N(e.path,e.choice)])),o=await r.FH.runVcsPrepare(s,t.repoDir,e,d);b(o.ok?null!=(n=o.result)?n:"":null!=(l=o.problem)?l:""),o.ok&&c("".concat(t.repoDir,": ").concat(null!=(a=o.result)?a:"")),i()}catch(e){b(e.message)}finally{g(!1)}};return(0,l.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,l.jsx)("table",{className:"small",children:(0,l.jsxs)("tbody",{children:[(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.repo")}),(0,l.jsx)("td",{children:(0,l.jsx)("code",{children:t.repoDir})})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.current")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:null!=(n=t.branch)?n:"HEAD"})," @ ",(0,l.jsx)("code",{children:k(t.head)})]})]}),t.workBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.workBranch")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:t.workBranch.name})," @ ",(0,l.jsx)("code",{children:k(t.workBranch.head)})]})]}),t.baseBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.base")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:t.baseBranch})," @ ",(0,l.jsx)("code",{children:k(t.baseHead)})]})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.sessions")}),(0,l.jsx)("td",{children:t.sessions.map(e=>"".concat(e.name," (").concat(o("runvcs.role.".concat(e.role)),")")).join(", ")})]}),t.inputPatterns.length>0&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.patterns")}),(0,l.jsx)("td",{children:t.inputPatterns.map(e=>(0,l.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),t.problem&&(0,l.jsxs)("p",{className:"small",children:[(0,l.jsx)("strong",{children:o("runvcs.problem")})," ",t.problem]}),t.inputs.length>0&&(0,l.jsx)("p",{className:"small",children:o("runvcs.inputsCount",{n:t.inputs.length})}),h&&t.inputs.length>0&&(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.inputs.map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path})," — ",o("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,r.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,l.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),t.unrelated.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:o("runvcs.unrelated",{n:t.unrelated.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.unrelated.slice(0,30).map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&t.entries.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:o("runvcs.choose",{n:t.entries.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:t.entries.map(e=>{var n;return(0,l.jsxs)("li",{style:{marginBottom:4},children:[(0,l.jsx)("code",{children:e.path})," ",(0,l.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(o("vcs.snapshotInput"),", "):"",o("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,r.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,l.jsx)("span",{className:"err",children:o("vcs.snapshotBlocked")}):(0,l.jsx)("select",{"aria-label":e.path,value:null!=(n=N(e.path,e.choice))?n:"",onChange:n=>y({...f,[e.path]:n.target.value}),disabled:j||e.allowed.length<2,children:e.allowed.map(e=>(0,l.jsx)("option",{value:e,children:o("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,l.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,l.jsxs)("p",{className:"small muted",children:[o("runvcs.cancelled")," ",(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!1),children:o("runvcs.showAgain")})]}):(0,l.jsxs)("div",{children:[t.actions.map(e=>{var n,a,s;return(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void S(e.id),disabled:j||!e.available,children:[o(m[e.id],{branch:null!=(n=t.baseBranch)?n:"",current:null!=(a=t.branch)?a:"HEAD"}),"review-inputs"===e.id&&h?" ✓":""]}),e.recommended&&(0,l.jsx)("span",{className:"badge done",style:{marginLeft:6},children:o("runvcs.recommended")}),(0,l.jsx)("p",{className:"why",children:e.available?e.result:"".concat(o("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!0),disabled:j,children:o("runvcs.cancel")}),(0,l.jsx)("p",{className:"why",children:o("runvcs.cancelWhy")})]})]}),v&&(0,l.jsx)("p",{className:"small",role:"status",children:v})]})}function j(){let{t:e}=(0,d.kj)(),n=(0,d.W3)(),[t,s]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[m,p]=(0,a.useState)([]),[x,j]=(0,a.useState)([]),[v,b]=(0,a.useState)([]),[f,y]=(0,a.useState)("stop"),[N,w]=(0,a.useState)(!1),[k,S]=(0,a.useState)(""),[C,F]=(0,a.useState)(""),[E,D]=(0,a.useState)(""),[H,T]=(0,a.useState)(null),[I,W]=(0,a.useState)(!1),B=(0,a.useCallback)(async()=>{try{let[e,n,t]=await Promise.all([r.FH.sessions(),r.FH.batch().catch(()=>null),r.FH.approvals().catch(()=>[])]);s(e),u(n),p(t),j(n=>n.filter(n=>e.some(e=>e.id===n))),T(!0),W(!1),D("")}catch(e){W(!(0,r.AV)()),T(!1),D(e.message)}},[]);(0,c.z)(B,3e3),(0,a.useEffect)(()=>{var e;let n=new URLSearchParams(window.location.search),t=(null!=(e=n.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==t.length&&(j(t),y("continue"===n.get("fail")?"continue":"stop"),w(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[R,O]=(0,a.useState)(!1),L=(0,a.useRef)(!1),U=async()=>{if(!L.current){L.current=!0,O(!0);try{let e=await r.FH.createSession(k||"session");S(""),window.location.href=(0,r.aT)(e.id)}catch(e){D(e.message),L.current=!1,O(!1)}}},q=async n=>{if(n.running)return void F(e("home.deleteRunning"));if(await (0,o.Z)(e("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await r.FH.deleteSession(n.id),F(e("home.deleted",{name:n.name})),j(e=>e.filter(e=>e!==n.id)),await B()}catch(e){F(e.message)}},A=async()=>{let n=(null!=t?t:[]).filter(e=>v.includes(e.id)&&!e.running);if(0===n.length)return;let l=n.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,o.Z)(e("home.deleteSelectedConfirm",{n:n.length,names:l})))return;let a=0,s=[];for(let e of n)try{await r.FH.deleteSession(e.id),a+=1}catch(n){s.push("".concat(e.name,": ").concat(n.message))}F(0===s.length?e("home.deletedMany",{n:a}):e("home.deleteSomeFailed",{n:a,m:s.length,why:s.join("; ")})),j(e=>e.filter(e=>!n.some(n=>n.id===e))),b([]),await B()},P=async n=>{let l=(null!=t?t:[]).filter(e=>v.includes(e.id)&&!e.running);if(0===l.length)return;let a=[];for(let e of l)try{await r.FH.updateSession(e.id,{active:n})}catch(n){a.push("".concat(e.name,": ").concat(n.message))}F(0===a.length?e(n?"home.madeActive":"home.madeInactive",{n:l.length}):e("home.statusSomeFailed",{n:l.length-a.length,m:a.length,why:a.join("; ")})),n||j(e=>e.filter(e=>!l.some(n=>n.id===e))),b([]),await B()},M=n=>{if(n.running)return{label:e("state.running"),badge:"running"};let t=n.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==n.status||t||0===n.tasks.length)return{label:e("state.".concat(n.status)),badge:""};let l=n.tasks.filter(e=>"done"!==e.status).length;return 0===l?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:l})}},z=async e=>{if(!t)return;let n=new Map(t.map(e=>[e.id,e]));s(e.map(e=>n.get(e)).filter(e=>!!e));try{s(await r.FH.reorderSessions(e)),D("")}catch(e){D(e.message),B()}},K=(e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=a+n;a<0||s<0||s>=l.length||([l[a],l[s]]=[l[s],l[a]],z(l))},[_,V]=(0,a.useState)(null),[Z,Q]=(0,a.useState)(null),G=(null!=t?t:[]).filter(e=>!e.running),J=G.filter(e=>v.includes(e.id));return(0,l.jsxs)(l.Fragment,{children:[I&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.noToken")}),(0,l.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===H&&!I&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.apiDown")}),(0,l.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),E&&(0,l.jsx)("div",{className:"err",children:E})]}),(0,l.jsxs)("div",{className:"panel",id:"new-session",children:[(0,l.jsx)("h2",{children:e("home.new")}),(0,l.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("input",{type:"text",className:"grow","aria-label":e("home.col.name"),placeholder:e("home.namePlaceholder"),value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&U()}}),(0,l.jsx)("button",{className:"primary",onClick:()=>void U(),disabled:R||!1===H,children:e("home.create")})]})]}),t&&t.length>0&&(0,l.jsx)(g,{sessions:t,selected:x,setSelected:j,onFailure:f,setOnFailure:y,fromPlan:N,batch:h,approvals:m,onChange:B,move:(e,n)=>{j(t=>{let l=t.indexOf(e),a=l+n;if(l<0||a<0||a>=t.length)return t;let s=[...t];return[s[l],s[a]]=[s[a],s[l]],s})}}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:e("home.sessions")}),null===t&&(0,l.jsx)("div",{className:"muted",children:e("home.loading")}),t&&0===t.length&&(0,l.jsx)("div",{className:"muted",children:e("home.none")}),t&&t.length>0&&(0,l.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,l.jsx)("strong",{className:"small",children:e("home.managed",{n:J.length})}),(0,l.jsx)("button",{onClick:()=>void P(!0),disabled:0===J.length,children:e("home.makeActive")}),(0,l.jsx)("button",{onClick:()=>void P(!1),disabled:0===J.length,children:e("home.makeInactive")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void A(),disabled:0===J.length,children:e("home.deleteSelected",{n:J.length})}),(0,l.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),t&&t.length>0&&(0,l.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),t&&t.length>1&&(0,l.jsx)("p",{className:"muted small",children:e("home.orderWhy")}),C&&(0,l.jsx)("div",{className:"muted small",role:"status",children:C}),t&&t.length>0&&(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.manageAll"),title:e("home.manageAll"),checked:G.length>0&&G.every(e=>v.includes(e.id)),onChange:e=>b(e.target.checked?G.map(e=>e.id):[]),disabled:0===G.length})}),(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:t.length>0&&x.length===t.filter(e=>!1!==e.active).length,onChange:e=>j(e.target.checked?t.filter(e=>!1!==e.active).map(e=>e.id):[]),disabled:(null==h?void 0:h.running)===!0})}),(0,l.jsx)("th",{children:e("home.col.order")}),(0,l.jsx)("th",{children:e("home.col.name")}),(0,l.jsx)("th",{children:e("home.col.tasks")}),(0,l.jsx)("th",{children:e("home.col.state")}),(0,l.jsx)("th",{children:e("home.col.chat")}),(0,l.jsx)("th",{children:e("home.col.created")}),(0,l.jsx)("th",{children:(0,l.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,l.jsx)("tbody",{children:t.map((a,s)=>{let c=a.tasks.filter(e=>"done"===e.status).length,d=a.tasks.filter(e=>"queued"===e.status).length,o=[!1===a.active?"inactive":"",_===a.id?"dragging":"",Z===a.id&&_!==a.id?"drop-target":""].filter(Boolean).join(" ");return(0,l.jsxs)("tr",{className:o||void 0,draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",a.id),e.dataTransfer.effectAllowed="move",V(a.id)},onDragOver:e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move",Z!==a.id&&Q(a.id))},onDrop:e=>{e.preventDefault();let n=e.dataTransfer.getData("text/plain")||_;V(null),Q(null),n&&((e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=l.indexOf(n);a<0||s<0||a===s||(l.splice(a,1),l.splice(s,0,e),z(l))})(n,a.id)},onDragEnd:()=>{V(null),Q(null)},children:[(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:v.includes(a.id),onChange:()=>b(e=>e.includes(a.id)?e.filter(e=>e!==a.id):[...e,a.id]),disabled:!!a.running,"aria-label":e("home.manageRow",{name:a.name}),title:a.running?e("home.manageRunning"):e("home.manageRow",{name:a.name})})}),(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:x.includes(a.id),onChange:()=>{var e;return e=a.id,void j(n=>{if(n.includes(e))return n.filter(n=>n!==e);let l=(null!=t?t:[]).map(e=>e.id);return[...n,e].sort((e,n)=>l.indexOf(e)-l.indexOf(n))})},disabled:(null==h?void 0:h.running)===!0||!1===a.active,"aria-label":a.name,title:!1===a.active?e("home.inactiveWhy"):void 0})}),(0,l.jsxs)("td",{className:"order-cell",children:[(0,l.jsx)("span",{className:"drag-handle","aria-hidden":"true",title:e("home.dragHint"),children:"⠿"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,-1),disabled:0===s,"aria-label":e("home.moveUp",{name:a.name}),title:e("home.moveUp",{name:a.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,1),disabled:s===t.length-1,"aria-label":e("home.moveDown",{name:a.name}),title:e("home.moveDown",{name:a.name}),children:"↓"})]}),(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(a.id),children:a.name})}),(0,l.jsxs)("td",{children:[a.tasks.length," ",(0,l.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:c,queued:d})})]}),(0,l.jsxs)("td",{children:[(0,l.jsx)("span",{className:"badge ".concat(M(a).badge),title:M(a).title,children:M(a).label})," ",(0,l.jsx)("span",{className:"chip".concat(!1===a.active?" inactive":""),title:e(!1===a.active?"home.inactiveWhy":"home.activeWhy"),children:e(!1===a.active?"home.statusInactive":"home.statusActive")})]}),(0,l.jsx)("td",{children:a.chat?(0,l.jsx)("a",{href:a.chat.url,target:"_blank",rel:"noreferrer",children:a.chat.name}):(0,l.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,l.jsx)("td",{className:"muted small",children:n(a.createdAt)}),(0,l.jsx)("td",{children:(0,l.jsx)("button",{className:"quiet",onClick:()=>void q(a),disabled:!!a.running,title:e("home.delete"),children:e("home.delete")})})]},a.id)})})]})]})]})}function g(e){var n,t,s,c,m,x,j;let{sessions:g,selected:v,setSelected:b,onFailure:f,setOnFailure:y,fromPlan:N,batch:w,approvals:k,onChange:S,move:C}=e,{t:F}=(0,d.kj)(),[E,D]=(0,a.useState)(""),[H,T]=(0,a.useState)(""),[I,W]=(0,a.useState)(""),[B,R]=(0,a.useState)(""),[O,L]=(0,a.useState)(""),[U,q]=(0,a.useState)(null),[A,P]=(0,a.useState)([]),[M,z]=(0,a.useState)(0);(0,a.useEffect)(()=>{r.FH.models().then(e=>{q(e),W(n=>n||e.defaultModel),R(n=>n||e.defaultReviewModel)}).catch(()=>void 0)},[]);let K=v.join(",");(0,a.useEffect)(()=>{let e=!1,n=K.split(",").filter(Boolean);if(0===n.length)return void P([]);let t=async()=>{let t=await r.FH.runVcs(n).catch(()=>[]);e||P(t)};t();let l=setInterval(()=>void t(),1e4);return()=>{e=!0,clearInterval(l)}},[K,M]);let _=new Map(g.map(e=>[e.id,e])),V=e=>e.tasks.filter(e=>"queued"===e.status).length,Z=v.map(e=>_.get(e)).filter(e=>!!e),Q=Z.filter(e=>V(e)>0&&!1!==e.active),G=Q.reduce((e,n)=>e+V(n),0),J=(null==w?void 0:w.running)===!0,X=g.some(e=>e.running),Y=A.some(e=>!e.ready),$=J||0===Q.length||X||Y,ee=X?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===Z.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Q.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,en=(0,h.p)(),[et,el]=(0,a.useState)(!1),ea=(0,a.useRef)(!1),es=async e=>{if(!ea.current){ea.current=!0,el(!0);try{await e()}catch(e){T(e.message)}finally{ea.current=!1,el(!1),S()}}},ei=async e=>{("unattended"!==e||en||await (0,o.Z)(F("batch.unattendedConfirm",{n:Q.length})))&&await es(async()=>{var n;let t=await r.FH.startBatch(Q.map(e=>e.id),e,f,I||void 0,B||void 0,O.trim()||Q.map(e=>e.planName).find(Boolean)||void 0);D(""),T(t.started?"":null!=(n=t.reason)?n:"")})},er=Z.filter(e=>{var n;return(null!=(n=e.model)?n:"")!==I}).length,ec=Z.filter(e=>{var n;return(null==(n=e.review)?void 0:n.enabled)===!1}).length,ed=null!=(s=null==U?void 0:U.options)?s:[],eo=ed.filter(e=>!e.group),eh=new Map;for(let e of ed)e.group&&eh.set(e.group,[...null!=(c=eh.get(e.group))?c:[],e]);let eu=w?{done:w.sessions.filter(e=>"done"===e.state).length,failed:w.sessions.filter(e=>"failed"===e.state).length,skipped:w.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,em=null==w?void 0:w.sessions.find(e=>"running"===e.state);return(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:F("batch.title")}),(0,l.jsx)("p",{className:"muted small",children:F("batch.hint")}),!J&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("strong",{className:"small",children:F("batch.selected",{n:Q.length,tasks:G})}),(0,l.jsx)("button",{className:"quiet",onClick:()=>b(g.filter(e=>V(e)>0).map(e=>e.id)),children:F("batch.selectQueued")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>b([]),disabled:0===Z.length,children:F("batch.selectNone")})]}),N&&(0,l.jsx)("p",{className:"muted small",children:F("batch.fromPlan")}),Z.length>Q.length&&(0,l.jsx)("p",{className:"muted small",children:F("batch.notRunnable",{n:Z.length-Q.length})}),Q.length>0&&(0,l.jsx)("ol",{className:"run-order",children:Q.map((e,n)=>(0,l.jsxs)("li",{children:[(0,l.jsxs)("span",{children:[e.name," ",(0,l.jsxs)("span",{className:"muted small",children:["(",V(e),")"]})]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,-1),disabled:0===n,"aria-label":F("batch.moveUp",{name:e.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,1),disabled:n===Q.length-1,"aria-label":F("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,l.jsx)("label",{htmlFor:"batch-run-name",children:F("batch.runName")}),(0,l.jsx)("input",{id:"batch-run-name",type:"text",value:O,onChange:e=>L(e.target.value),placeholder:null!=(m=Q.map(e=>e.planName).find(Boolean))?m:F("batch.runNamePlaceholder")}),(0,l.jsx)("p",{className:"why",children:F("batch.runNameWhy")}),(0,l.jsx)("label",{htmlFor:"batch-model",children:F("batch.model")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"batch-model",value:I,onChange:e=>W(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.modelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]}),(null!=(x=null==U?void 0:U.options.length)?x:0)===0&&(0,l.jsx)("span",{className:"muted small",children:F("batch.modelNone")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.modelWhy")}),(0,l.jsx)(u.L,{current:I,onUse:e=>W(e)}),I&&er>0&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.modelOverrides",{n:er})}),(0,l.jsx)("label",{htmlFor:"batch-review-model",children:F("batch.reviewModel")}),(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("select",{id:"batch-review-model",value:B,onChange:e=>R(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.reviewModelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]})}),(0,l.jsx)("p",{className:"why",children:F("batch.reviewModelWhy")}),""!==B&&B===I&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.reviewSame")}),ec>0&&(0,l.jsx)("p",{className:"why",children:F("batch.reviewOffIn",{n:ec})}),(0,l.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,l.jsx)("legend",{className:"muted small",style:{padding:0},children:F("batch.onFailure")}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===f,onChange:()=>y("stop")}),(0,l.jsx)("span",{children:F("batch.chain")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.chainWhy")})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===f,onChange:()=>y("continue")}),(0,l.jsx)("span",{children:F("batch.independent")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.independentWhy")})]})]}),ee&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:F(ee.title)}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:F(ee.why)})]}),(0,l.jsx)(p,{groups:A,sessionIds:Q.map(e=>e.id),onChange:()=>z(e=>e+1)}),H&&(0,l.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,l.jsx)("strong",{children:F("batch.notStartedTitle")}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:H}),/execution\.isolation/.test(H)&&(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:(0,l.jsx)(i(),{href:"/defaults",children:F("batch.notStartedIsolation")})})]}),!Y&&(0,l.jsxs)("div",{className:"run-choice",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{className:"primary",onClick:()=>void ei("unattended"),disabled:et||$,children:F("batch.run",{n:Q.length})}),(0,l.jsx)("p",{className:"why",children:F("batch.runWhy")})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{onClick:()=>void ei("confirm"),disabled:et||$,children:F("batch.runStep")}),(0,l.jsx)("p",{className:"why",children:F("batch.runStepWhy")})]})]})]}),J&&(0,l.jsxs)("div",{className:"row",children:[(null==w?void 0:w.pausing)?(0,l.jsx)("button",{className:"primary",onClick:()=>void es(async()=>{await r.FH.resumeBatch(),D("")}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.resumeWhy"),children:F("batch.resume")}):(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.pauseBatch(),D(F("batch.pausing"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.pauseWhy"),children:F("batch.pause")}),(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.stopBatch(),D(F("batch.stopping"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.stopWhy"),children:F("batch.stop")}),(null==w?void 0:w.pausing)&&!(null==w?void 0:w.stopping)&&(0,l.jsx)("span",{className:"muted small",children:F("batch.pausing")}),(0,l.jsx)("span",{className:"badge",children:F("batch.modelRunning",{name:(em?(null==(n=_.get(em.sessionId))?void 0:n.modelInUse)||(null==(t=_.get(em.sessionId))?void 0:t.model):"")||F("model.default")})}),k.length>0&&(0,l.jsx)("span",{className:"badge waiting-approval",children:F("batch.waiting",{n:k.length})}),em&&(0,l.jsx)("span",{className:"small",children:F("batch.progress",{name:em.name,done:w.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:w.sessions.length})})]}),J&&(0,l.jsx)("p",{className:"muted small",children:F("batch.hiddenWhileRunning")}),E&&(0,l.jsx)("div",{className:"muted small",role:"status",children:E}),(Z.length>0||w)&&(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("a",{className:"button-link",href:r.FH.debugExportUrl(Z.length>0?Z.map(e=>e.id):(null!=(j=null==w?void 0:w.sessions)?j:[]).map(e=>e.sessionId)),children:F("batch.debug")}),(0,l.jsx)("span",{className:"muted small",children:Z.length>0?F("batch.debugSelected",{n:Z.length}):F("batch.debugLast")})]}),(Z.length>0||w)&&(0,l.jsx)("p",{className:"why",children:F("batch.debugWhy")}),w&&(0,l.jsxs)(l.Fragment,{children:[!J&&eu&&(0,l.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,l.jsx)("strong",{children:F("batch.finished",eu)})}),(0,l.jsxs)("table",{style:{marginTop:10},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:F("batch.col.session")}),(0,l.jsx)("th",{children:F("batch.col.state")}),(0,l.jsx)("th",{children:F("batch.col.ran")}),(0,l.jsx)("th",{children:F("batch.col.why")})]})}),(0,l.jsx)("tbody",{children:w.sessions.map(e=>{var n,t;return(0,l.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.name})}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"badge ".concat("running"===(t=e.state)?"running":"done"===t?"done":"failed"===t?"failed":"stopped"===t?"aborted":""),children:F("batch.state.".concat(e.state))})}),(0,l.jsx)("td",{className:"small",children:F("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,l.jsx)("td",{className:"muted small",children:null!=(n=e.reason)?n:""})]},e.sessionId)})})]})]})]})}},7527:(e,n,t)=>{"use strict";t.d(n,{z:()=>a});var l=t(1521);function a(e,n){let t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=(0,l.useRef)(e);a.current=e,(0,l.useEffect)(()=>{let e;if(!t)return;let l=!1,s=async()=>{try{await a.current()}catch(e){}finally{l||(e=setTimeout(()=>void s(),n))}};return s(),()=>{l=!0,e&&clearTimeout(e)}},[n,t])}},8848:(e,n,t)=>{"use strict";t.d(n,{H4:()=>d,L:()=>o,z4:()=>h});var l=t(3365),a=t(8197),s=t.n(a),i=t(1521),r=t(5549),c=t(867);function d(e){let{current:n,onUse:t}=e,{t:a}=(0,c.kj)(),[s,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(n=>{e||d(n)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let o=s.rootDir.trim(),h=n.trim().toLowerCase(),u=t?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,l.jsx)(m,{label:o?a("proj.defaultIs",{dir:o}):a("proj.noneShort"),offer:o&&t&&h!==o.toLowerCase()?{text:a("proj.useIt"),onUse:()=>t(o)}:void 0,more:u.map(e=>({text:a("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==t?void 0:t(e.rootDir)})),link:o?a("proj.change"):a("proj.setIt"),anchor:"project"})}function o(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultModel.trim();return(0,l.jsx)(m,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultReviewModel.trim();return(0,l.jsx)(m,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,n]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(t=>{e||n(t)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:n,offer:t,more:a=[],link:i,anchor:r}=e;return(0,l.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[n," ",t&&(0,l.jsxs)(l.Fragment,{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:t.onUse,children:t.text})," "]}),a.map(e=>(0,l.jsxs)("span",{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,l.jsx)(s(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);