commandmate 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +13 -13
  3. package/.next/app-path-routes-manifest.json +1 -1
  4. package/.next/build-manifest.json +4 -4
  5. package/.next/cache/.tsbuildinfo +1 -1
  6. package/.next/cache/config.json +3 -3
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/.next/next-server.js.nft.json +1 -1
  17. package/.next/prerender-manifest.json +1 -1
  18. package/.next/required-server-files.json +1 -1
  19. package/.next/routes-manifest.json +1 -1
  20. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/app/update-check/route.js +1 -1
  22. package/.next/server/app/api/ollama/models/route.js +1 -0
  23. package/.next/server/app/api/ollama/models/route.js.nft.json +1 -0
  24. package/.next/server/app/api/ollama/models.body +1 -0
  25. package/.next/server/app/api/ollama/models.meta +1 -0
  26. package/.next/server/app/api/repositories/route.js +3 -3
  27. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  28. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  29. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  30. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
  31. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  32. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  33. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -1
  34. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js.nft.json +1 -1
  35. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +1 -1
  36. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -1
  37. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
  38. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  39. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
  40. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  41. package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
  42. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  43. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  44. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  45. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  46. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  47. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  48. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -1
  49. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -1
  50. package/.next/server/app/api/worktrees/[id]/schedules/route.js +2 -2
  51. package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -1
  52. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  53. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  54. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
  55. package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
  56. package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -1
  57. package/.next/server/app/api/worktrees/route.js +1 -1
  58. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  59. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/page.js +1 -1
  61. package/.next/server/app/page_client-reference-manifest.js +1 -1
  62. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/worktrees/[id]/page.js +4 -4
  64. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  66. package/.next/server/app-paths-manifest.json +7 -6
  67. package/.next/server/chunks/2314.js +1 -1
  68. package/.next/server/chunks/4559.js +1 -1
  69. package/.next/server/chunks/539.js +10 -10
  70. package/.next/server/chunks/5853.js +1 -1
  71. package/.next/server/chunks/6228.js +1 -1
  72. package/.next/server/chunks/7425.js +59 -39
  73. package/.next/server/chunks/7566.js +1 -1
  74. package/.next/server/chunks/8693.js +1 -1
  75. package/.next/server/chunks/9446.js +1 -0
  76. package/.next/server/functions-config-manifest.json +1 -1
  77. package/.next/server/middleware-build-manifest.js +1 -1
  78. package/.next/server/middleware-manifest.json +5 -5
  79. package/.next/server/pages/500.html +1 -1
  80. package/.next/server/server-reference-manifest.json +1 -1
  81. package/.next/static/chunks/8091-274bc0716106e7fc.js +1 -0
  82. package/.next/static/chunks/app/page-060057e02b841125.js +1 -0
  83. package/.next/static/chunks/app/worktrees/[id]/page-78580947c201d698.js +1 -0
  84. package/.next/static/chunks/{main-db79434ee4a6c931.js → main-2feda12a4d321111.js} +1 -1
  85. package/.next/static/css/{bd6065b03ddb3efd.css → e85de230ef5ddc40.css} +1 -1
  86. package/.next/trace +5 -5
  87. package/.next/types/app/api/ollama/models/route.ts +343 -0
  88. package/README.md +74 -76
  89. package/dist/server/src/config/schedule-config.js +7 -1
  90. package/dist/server/src/lib/auto-yes-manager.js +2 -2
  91. package/dist/server/src/lib/claude-executor.js +15 -4
  92. package/dist/server/src/lib/cli-patterns.js +73 -9
  93. package/dist/server/src/lib/cli-tools/gemini.js +81 -22
  94. package/dist/server/src/lib/cli-tools/manager.js +4 -2
  95. package/dist/server/src/lib/cli-tools/types.js +64 -2
  96. package/dist/server/src/lib/cli-tools/vibe-local.js +163 -0
  97. package/dist/server/src/lib/cmate-parser.js +25 -3
  98. package/dist/server/src/lib/db-migrations.js +50 -1
  99. package/dist/server/src/lib/db.js +51 -1
  100. package/dist/server/src/lib/prompt-detector.js +4 -3
  101. package/dist/server/src/lib/response-poller.js +22 -11
  102. package/dist/server/src/lib/schedule-manager.js +6 -2
  103. package/dist/server/src/lib/selected-agents-validator.js +99 -0
  104. package/dist/server/src/types/sidebar.js +9 -4
  105. package/package.json +1 -1
  106. package/.next/server/chunks/7536.js +0 -1
  107. package/.next/static/chunks/8091-925542bdfc843dce.js +0 -1
  108. package/.next/static/chunks/app/page-238b5a70d8c101e9.js +0 -1
  109. package/.next/static/chunks/app/worktrees/[id]/page-0c889ab3f30d5af7.js +0 -1
  110. /package/.next/static/{j8HFvzDZj7tHjAnhpXUno → O7EDFfAYQNe_HRbORxQAC}/_buildManifest.js +0 -0
  111. /package/.next/static/{j8HFvzDZj7tHjAnhpXUno → O7EDFfAYQNe_HRbORxQAC}/_ssgManifest.js +0 -0
@@ -1,14 +1,14 @@
1
- (()=>{var e={};e.id=130,e.ids=[130],e.modules={98860:e=>{"use strict";e.exports=require("jsdom")},72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},55315:e=>{"use strict";e.exports=require("path")},17360:e=>{"use strict";e.exports=require("url")},49411:e=>{"use strict";e.exports=require("node:path")},97742:e=>{"use strict";e.exports=require("node:process")},41041:e=>{"use strict";e.exports=require("node:url")},80205:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>l.a,__next_app__:()=>m,originalPathname:()=>u,pages:()=>d,routeModule:()=>p,tree:()=>c}),r(22570),r(25086),r(35866);var a=r(23191),s=r(88716),n=r(37922),l=r.n(n),i=r(95231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);r.d(t,o);let c=["",{children:["worktrees",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,22570)),"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"]}]},{}]},{metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(r.bind(r,25086)),"/home/runner/work/CommandMate/CommandMate/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,35866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}],d=["/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"],u="/worktrees/[id]/page",m={require:r,loadChunk:()=>Promise.resolve()},p=new a.AppPageRouteModule({definition:{kind:s.x.APP_PAGE,page:"/worktrees/[id]/page",pathname:"/worktrees/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},87923:(e,t,r)=>{Promise.resolve().then(r.bind(r,75929))},62829:e=>{"use strict";let{entries:t,setPrototypeOf:r,isFrozen:a,getPrototypeOf:s,getOwnPropertyDescriptor:n}=Object,{freeze:l,seal:i,create:o}=Object,{apply:c,construct:d}="undefined"!=typeof Reflect&&Reflect;l||(l=function(e){return e}),i||(i=function(e){return e}),c||(c=function(e,t){for(var r=arguments.length,a=Array(r>2?r-2:0),s=2;s<r;s++)a[s-2]=arguments[s];return e.apply(t,a)}),d||(d=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return new e(...r)});let u=C(Array.prototype.forEach),m=C(Array.prototype.lastIndexOf),p=C(Array.prototype.pop),h=C(Array.prototype.push),f=C(Array.prototype.splice),x=C(String.prototype.toLowerCase),g=C(String.prototype.toString),y=C(String.prototype.match),b=C(String.prototype.replace),v=C(String.prototype.indexOf),w=C(String.prototype.trim),j=C(Object.prototype.hasOwnProperty),N=C(RegExp.prototype.test),k=(Z=TypeError,function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return d(Z,t)});function C(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,a=Array(r>1?r-1:0),s=1;s<r;s++)a[s-1]=arguments[s];return c(e,t,a)}}function S(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;r&&r(e,null);let n=t.length;for(;n--;){let r=t[n];if("string"==typeof r){let e=s(r);e!==r&&(a(t)||(t[n]=e),r=e)}e[r]=!0}return e}function T(e){let r=o(null);for(let[a,s]of t(e))j(e,a)&&(Array.isArray(s)?r[a]=function(e){for(let t=0;t<e.length;t++)j(e,t)||(e[t]=null);return e}(s):s&&"object"==typeof s&&s.constructor===Object?r[a]=T(s):r[a]=s);return r}function E(e,t){for(;null!==e;){let r=n(e,t);if(r){if(r.get)return C(r.get);if("function"==typeof r.value)return C(r.value)}e=s(e)}return function(){return null}}let M=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),A=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),R=l(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_=l(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),O=l(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),P=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),$=l(["#text"]),L=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),I=l(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),D=l(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),F=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z=i(/\{\{[\w\W]*|[\w\W]*\}\}/gm),H=i(/<%[\w\W]*|[\w\W]*%>/gm),W=i(/\$\{[\w\W]*/gm),B=i(/^data-[\-\w.\u00B7-\uFFFF]+$/),U=i(/^aria-[\-\w]+$/),G=i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V=i(/^(?:\w+script|data):/i),q=i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Y=i(/^html$/i);var Z,K=Object.freeze({__proto__:null,ARIA_ATTR:U,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:i(/^[a-z][.\w]*(-[.\w]+)+$/i),DATA_ATTR:B,DOCTYPE_NAME:Y,ERB_EXPR:H,IS_ALLOWED_URI:G,IS_SCRIPT_OR_DATA:V,MUSTACHE_EXPR:z,TMPLIT_EXPR:W});let X={element:1,text:3,progressingInstruction:7,comment:8,document:9},J=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null,a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(r=t.getAttribute(a));let s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Q=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};var ee=function e(){let r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window,s=t=>e(t);if(s.version="3.3.1",s.removed=[],!a||!a.document||a.document.nodeType!==X.document||!a.Element)return s.isSupported=!1,s;let{document:n}=a,i=n,c=i.currentScript,{DocumentFragment:d,HTMLTemplateElement:C,Node:z,Element:H,NodeFilter:W,NamedNodeMap:B=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:U,DOMParser:V,trustedTypes:q}=a,Z=H.prototype,ee=E(Z,"cloneNode"),et=E(Z,"remove"),er=E(Z,"nextSibling"),ea=E(Z,"childNodes"),es=E(Z,"parentNode");if("function"==typeof C){let e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let en="",{implementation:el,createNodeIterator:ei,createDocumentFragment:eo,getElementsByTagName:ec}=n,{importNode:ed}=i,eu=Q();s.isSupported="function"==typeof t&&"function"==typeof es&&el&&void 0!==el.createHTMLDocument;let{MUSTACHE_EXPR:em,ERB_EXPR:ep,TMPLIT_EXPR:eh,DATA_ATTR:ef,ARIA_ATTR:ex,IS_SCRIPT_OR_DATA:eg,ATTR_WHITESPACE:ey,CUSTOM_ELEMENT:eb}=K,{IS_ALLOWED_URI:ev}=K,ew=null,ej=S({},[...M,...A,...R,...O,...$]),eN=null,ek=S({},[...L,...I,...D,...F]),eC=Object.seal(o(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),eS=null,eT=null,eE=Object.seal(o(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),eM=!0,eA=!0,eR=!1,e_=!0,eO=!1,eP=!0,e$=!1,eL=!1,eI=!1,eD=!1,eF=!1,ez=!1,eH=!0,eW=!1,eB=!0,eU=!1,eG={},eV=null,eq=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),eY=null,eZ=S({},["audio","video","img","source","image","track"]),eK=null,eX=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),eJ="http://www.w3.org/1998/Math/MathML",eQ="http://www.w3.org/2000/svg",e0="http://www.w3.org/1999/xhtml",e1=e0,e2=!1,e4=null,e5=S({},[eJ,eQ,e0],g),e3=S({},["mi","mo","mn","ms","mtext"]),e6=S({},["annotation-xml"]),e8=S({},["title","style","font","a","script"]),e7=null,e9=["application/xhtml+xml","text/html"],te=null,tt=null,tr=n.createElement("form"),ta=function(e){return e instanceof RegExp||e instanceof Function},ts=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!tt||tt!==e){if(e&&"object"==typeof e||(e={}),e=T(e),te="application/xhtml+xml"===(e7=-1===e9.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE)?g:x,ew=j(e,"ALLOWED_TAGS")?S({},e.ALLOWED_TAGS,te):ej,eN=j(e,"ALLOWED_ATTR")?S({},e.ALLOWED_ATTR,te):ek,e4=j(e,"ALLOWED_NAMESPACES")?S({},e.ALLOWED_NAMESPACES,g):e5,eK=j(e,"ADD_URI_SAFE_ATTR")?S(T(eX),e.ADD_URI_SAFE_ATTR,te):eX,eY=j(e,"ADD_DATA_URI_TAGS")?S(T(eZ),e.ADD_DATA_URI_TAGS,te):eZ,eV=j(e,"FORBID_CONTENTS")?S({},e.FORBID_CONTENTS,te):eq,eS=j(e,"FORBID_TAGS")?S({},e.FORBID_TAGS,te):T({}),eT=j(e,"FORBID_ATTR")?S({},e.FORBID_ATTR,te):T({}),eG=!!j(e,"USE_PROFILES")&&e.USE_PROFILES,eM=!1!==e.ALLOW_ARIA_ATTR,eA=!1!==e.ALLOW_DATA_ATTR,eR=e.ALLOW_UNKNOWN_PROTOCOLS||!1,e_=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,eO=e.SAFE_FOR_TEMPLATES||!1,eP=!1!==e.SAFE_FOR_XML,e$=e.WHOLE_DOCUMENT||!1,eD=e.RETURN_DOM||!1,eF=e.RETURN_DOM_FRAGMENT||!1,ez=e.RETURN_TRUSTED_TYPE||!1,eI=e.FORCE_BODY||!1,eH=!1!==e.SANITIZE_DOM,eW=e.SANITIZE_NAMED_PROPS||!1,eB=!1!==e.KEEP_CONTENT,eU=e.IN_PLACE||!1,ev=e.ALLOWED_URI_REGEXP||G,e1=e.NAMESPACE||e0,e3=e.MATHML_TEXT_INTEGRATION_POINTS||e3,e6=e.HTML_INTEGRATION_POINTS||e6,eC=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(eC.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(eC.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(eC.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),eO&&(eA=!1),eF&&(eD=!0),eG&&(ew=S({},$),eN=[],!0===eG.html&&(S(ew,M),S(eN,L)),!0===eG.svg&&(S(ew,A),S(eN,I),S(eN,F)),!0===eG.svgFilters&&(S(ew,R),S(eN,I),S(eN,F)),!0===eG.mathMl&&(S(ew,O),S(eN,D),S(eN,F))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?eE.tagCheck=e.ADD_TAGS:(ew===ej&&(ew=T(ew)),S(ew,e.ADD_TAGS,te))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?eE.attributeCheck=e.ADD_ATTR:(eN===ek&&(eN=T(eN)),S(eN,e.ADD_ATTR,te))),e.ADD_URI_SAFE_ATTR&&S(eK,e.ADD_URI_SAFE_ATTR,te),e.FORBID_CONTENTS&&(eV===eq&&(eV=T(eV)),S(eV,e.FORBID_CONTENTS,te)),e.ADD_FORBID_CONTENTS&&(eV===eq&&(eV=T(eV)),S(eV,e.ADD_FORBID_CONTENTS,te)),eB&&(ew["#text"]=!0),e$&&S(ew,["html","head","body"]),ew.table&&(S(ew,["tbody"]),delete eS.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');en=(r=e.TRUSTED_TYPES_POLICY).createHTML("")}else void 0===r&&(r=J(q,c)),null!==r&&"string"==typeof en&&(en=r.createHTML(""));l&&l(e),tt=e}},tn=S({},[...A,...R,..._]),tl=S({},[...O,...P]),ti=function(e){let t=es(e);t&&t.tagName||(t={namespaceURI:e1,tagName:"template"});let r=x(e.tagName),a=x(t.tagName);return!!e4[e.namespaceURI]&&(e.namespaceURI===eQ?t.namespaceURI===e0?"svg"===r:t.namespaceURI===eJ?"svg"===r&&("annotation-xml"===a||e3[a]):!!tn[r]:e.namespaceURI===eJ?t.namespaceURI===e0?"math"===r:t.namespaceURI===eQ?"math"===r&&e6[a]:!!tl[r]:e.namespaceURI===e0?(t.namespaceURI!==eQ||!!e6[a])&&(t.namespaceURI!==eJ||!!e3[a])&&!tl[r]&&(e8[r]||!tn[r]):"application/xhtml+xml"===e7&&!!e4[e.namespaceURI])},to=function(e){h(s.removed,{element:e});try{es(e).removeChild(e)}catch(t){et(e)}},tc=function(e,t){try{h(s.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(s.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e){if(eD||eF)try{to(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}}},td=function(e){let t=null,a=null;if(eI)e="<remove></remove>"+e;else{let t=y(e,/^[\r\n\t ]+/);a=t&&t[0]}"application/xhtml+xml"===e7&&e1===e0&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let s=r?r.createHTML(e):e;if(e1===e0)try{t=new V().parseFromString(s,e7)}catch(e){}if(!t||!t.documentElement){t=el.createDocument(e1,"template",null);try{t.documentElement.innerHTML=e2?en:s}catch(e){}}let l=t.body||t.documentElement;return(e&&a&&l.insertBefore(n.createTextNode(a),l.childNodes[0]||null),e1===e0)?ec.call(t,e$?"html":"body")[0]:e$?t.documentElement:l},tu=function(e){return ei.call(e.ownerDocument||e,e,W.SHOW_ELEMENT|W.SHOW_COMMENT|W.SHOW_TEXT|W.SHOW_PROCESSING_INSTRUCTION|W.SHOW_CDATA_SECTION,null)},tm=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof B)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},tp=function(e){return"function"==typeof z&&e instanceof z};function th(e,t,r){u(e,e=>{e.call(s,t,r,tt)})}let tf=function(e){let t=null;if(th(eu.beforeSanitizeElements,e,null),tm(e))return to(e),!0;let r=te(e.nodeName);if(th(eu.uponSanitizeElement,e,{tagName:r,allowedTags:ew}),eP&&e.hasChildNodes()&&!tp(e.firstElementChild)&&N(/<[/\w!]/g,e.innerHTML)&&N(/<[/\w!]/g,e.textContent)||e.nodeType===X.progressingInstruction||eP&&e.nodeType===X.comment&&N(/<[/\w]/g,e.data))return to(e),!0;if(!(eE.tagCheck instanceof Function&&eE.tagCheck(r))&&(!ew[r]||eS[r])){if(!eS[r]&&tg(r)&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r)))return!1;if(eB&&!eV[r]){let t=es(e)||e.parentNode,r=ea(e)||e.childNodes;if(r&&t){let a=r.length;for(let s=a-1;s>=0;--s){let a=ee(r[s],!0);a.__removalCount=(e.__removalCount||0)+1,t.insertBefore(a,er(e))}}}return to(e),!0}return e instanceof H&&!ti(e)||("noscript"===r||"noembed"===r||"noframes"===r)&&N(/<\/no(script|embed|frames)/i,e.innerHTML)?(to(e),!0):(eO&&e.nodeType===X.text&&(t=e.textContent,u([em,ep,eh],e=>{t=b(t,e," ")}),e.textContent!==t&&(h(s.removed,{element:e.cloneNode()}),e.textContent=t)),th(eu.afterSanitizeElements,e,null),!1)},tx=function(e,t,r){if(eH&&("id"===t||"name"===t)&&(r in n||r in tr))return!1;if(eA&&!eT[t]&&N(ef,t));else if(eM&&N(ex,t));else if(eE.attributeCheck instanceof Function&&eE.attributeCheck(t,e));else if(!eN[t]||eT[t]){if(!(tg(e)&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,e)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(e))&&(eC.attributeNameCheck instanceof RegExp&&N(eC.attributeNameCheck,t)||eC.attributeNameCheck instanceof Function&&eC.attributeNameCheck(t,e))||"is"===t&&eC.allowCustomizedBuiltInElements&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r))))return!1}else if(eK[t]);else if(N(ev,b(r,ey,"")));else if(("src"===t||"xlink:href"===t||"href"===t)&&"script"!==e&&0===v(r,"data:")&&eY[e]);else if(eR&&!N(eg,b(r,ey,"")));else if(r)return!1;return!0},tg=function(e){return"annotation-xml"!==e&&y(e,eb)},ty=function(e){th(eu.beforeSanitizeAttributes,e,null);let{attributes:t}=e;if(!t||tm(e))return;let a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:eN,forceKeepAttr:void 0},n=t.length;for(;n--;){let{name:l,namespaceURI:i,value:o}=t[n],c=te(l),d="value"===l?o:w(o);if(a.attrName=c,a.attrValue=d,a.keepAttr=!0,a.forceKeepAttr=void 0,th(eu.uponSanitizeAttribute,e,a),d=a.attrValue,eW&&("id"===c||"name"===c)&&(tc(l,e),d="user-content-"+d),eP&&N(/((--!?|])>)|<\/(style|title|textarea)/i,d)||"attributename"===c&&y(d,"href")){tc(l,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr||!e_&&N(/\/>/i,d)){tc(l,e);continue}eO&&u([em,ep,eh],e=>{d=b(d,e," ")});let m=te(e.nodeName);if(!tx(m,c,d)){tc(l,e);continue}if(r&&"object"==typeof q&&"function"==typeof q.getAttributeType){if(i);else switch(q.getAttributeType(m,c)){case"TrustedHTML":d=r.createHTML(d);break;case"TrustedScriptURL":d=r.createScriptURL(d)}}if(d!==o)try{i?e.setAttributeNS(i,l,d):e.setAttribute(l,d),tm(e)?to(e):p(s.removed)}catch(t){tc(l,e)}}th(eu.afterSanitizeAttributes,e,null)},tb=function e(t){let r=null,a=tu(t);for(th(eu.beforeSanitizeShadowDOM,t,null);r=a.nextNode();)th(eu.uponSanitizeShadowNode,r,null),tf(r),ty(r),r.content instanceof d&&e(r.content);th(eu.afterSanitizeShadowDOM,t,null)};return s.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,n=null,l=null,o=null;if((e2=!e)&&(e="<!-->"),"string"!=typeof e&&!tp(e)){if("function"==typeof e.toString){if("string"!=typeof(e=e.toString()))throw k("dirty is not a string, aborting")}else throw k("toString is not a function")}if(!s.isSupported)return e;if(eL||ts(t),s.removed=[],"string"==typeof e&&(eU=!1),eU){if(e.nodeName){let t=te(e.nodeName);if(!ew[t]||eS[t])throw k("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof z)(n=(a=td("<!---->")).ownerDocument.importNode(e,!0)).nodeType===X.element&&"BODY"===n.nodeName?a=n:"HTML"===n.nodeName?a=n:a.appendChild(n);else{if(!eD&&!eO&&!e$&&-1===e.indexOf("<"))return r&&ez?r.createHTML(e):e;if(!(a=td(e)))return eD?null:ez?en:""}a&&eI&&to(a.firstChild);let c=tu(eU?e:a);for(;l=c.nextNode();)tf(l),ty(l),l.content instanceof d&&tb(l.content);if(eU)return e;if(eD){if(eF)for(o=eo.call(a.ownerDocument);a.firstChild;)o.appendChild(a.firstChild);else o=a;return(eN.shadowroot||eN.shadowrootmode)&&(o=ed.call(i,o,!0)),o}let m=e$?a.outerHTML:a.innerHTML;return e$&&ew["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&N(Y,a.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+m),eO&&u([em,ep,eh],e=>{m=b(m,e," ")}),r&&ez?r.createHTML(m):m},s.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ts(e),eL=!0},s.clearConfig=function(){tt=null,eL=!1},s.isValidAttribute=function(e,t,r){return tt||ts({}),tx(te(e),te(t),r)},s.addHook=function(e,t){"function"==typeof t&&h(eu[e],t)},s.removeHook=function(e,t){if(void 0!==t){let r=m(eu[e],t);return -1===r?void 0:f(eu[e],r,1)[0]}return p(eu[e])},s.removeHooks=function(e){eu[e]=[]},s.removeAllHooks=function(){eu=Q()},s}();e.exports=ee},24420:(e,t,r)=>{function a(e){return e&&e.default||e}e.exports=global.DOMPurify=global.DOMPurify||("undefined"!=typeof window?a(r(62829)):function(){let e=a(r(62829)),{JSDOM:t}=a(r(98860)),{window:s}=new t("<!DOCTYPE html>");return e(s)}())},43353:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n}});let a=r(91174);r(10326),r(17577);let s=a._(r(77028));function n(e,t){var r;let a={loading:e=>{let{error:t,isLoading:r,pastDelay:a}=e;return null}};"function"==typeof e&&(a.loader=e);let n={...a,...t};return(0,s.default)({...n,modules:null==(r=n.loadableGenerated)?void 0:r.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},933:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let a=r(94129);function s(e){let{reason:t,children:r}=e;throw new a.BailoutToCSRError(t)}},77028:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return c}});let a=r(10326),s=r(17577),n=r(933),l=r(46618);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},r=(0,s.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,a.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.PreloadCss,{moduleIds:t.modules}),(0,a.jsx)(r,{...e})]}):(0,a.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(r,{...e})});return(0,a.jsx)(s.Suspense,{fallback:i,children:o})}return d.displayName="LoadableComponent",d}},46618:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return n}});let a=r(10326),s=r(54580);function n(e){let{moduleIds:t}=e,r=(0,s.getExpectedRequestStore)("next/dynamic css"),n=[];if(r.reactLoadableManifest&&t){let e=r.reactLoadableManifest;for(let r of t){if(!e[r])continue;let t=e[r].files.filter(e=>e.endsWith(".css"));n.push(...t)}}return 0===n.length?null:(0,a.jsx)(a.Fragment,{children:n.map(e=>(0,a.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:r.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},51387:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;let n=r(5739);Object.defineProperty(t,"types",{enumerable:!0,get:function(){return n.types}}),s(r(49441),t),s(r(61601),t);let l=r(49441),i=r(61601);s(r(5739),t),t.default=l.tokenizer,e.exports=l.tokenizer,e.exports.types=n.types,e.exports.reconstruct=i.reconstruct},61601:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstruct=void 0;let a=r(5739),s=r(10602),n=e=>e.map(t.reconstruct).join(""),l=e=>{if("options"in e)return e.options.map(n).join("|");if("stack"in e)return n(e.stack);throw Error("options or stack must be Root or Group token")};t.reconstruct=e=>{switch(e.type){case a.types.ROOT:return l(e);case a.types.CHAR:{let t=String.fromCharCode(e.value);return(/[[\\{}$^.|?*+()]/.test(t)?"\\":"")+t}case a.types.POSITION:if("^"===e.value||"$"===e.value)return e.value;return`\\${e.value}`;case a.types.REFERENCE:return`\\${e.value}`;case a.types.SET:return s.writeSetTokens(e);case a.types.GROUP:{let t=e.name?`?<${e.name}>`:e.remember?"":e.followedBy?"?=":e.notFollowedBy?"?!":"?:";return`(${t}${l(e)})`}case a.types.REPETITION:{let r;let{min:a,max:s}=e;return r=0===a&&1===s?"?":1===a&&s===1/0?"+":0===a&&s===1/0?"*":s===1/0?`{${a},}`:a===s?`{${a}}`:`{${a},${s}}`,`${t.reconstruct(e.value)}${r}`}case a.types.RANGE:return`${s.setChar(e.from)}-${s.setChar(e.to)}`;default:throw Error(`Invalid token type ${e}`)}}},25296:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.NOTANYCHAR=t.WHITESPACE=t.WORDS=t.INTS=void 0;let l=n(r(40879)),i=r(5739);function o(e){let t={},r=0;for(let a of e)a.type===i.types.CHAR&&(t[a.value]=!0),a.type===i.types.RANGE&&(t[`${a.from}-${a.to}`]=!0),r+=1;return{lookup:()=>Object.assign({},t),len:r}}t.INTS=o(l.ints().set),t.WORDS=o(l.words().set),t.WHITESPACE=o(l.whitespace().set),t.NOTANYCHAR=o(l.anyChar().set)},40879:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.anyChar=t.notWhitespace=t.whitespace=t.notInts=t.ints=t.notWords=t.words=void 0;let a=r(5739),s=()=>[{type:a.types.RANGE,from:48,to:57}],n=()=>[{type:a.types.CHAR,value:95},{type:a.types.RANGE,from:97,to:122},{type:a.types.RANGE,from:65,to:90},{type:a.types.RANGE,from:48,to:57}],l=()=>[{type:a.types.CHAR,value:9},{type:a.types.CHAR,value:10},{type:a.types.CHAR,value:11},{type:a.types.CHAR,value:12},{type:a.types.CHAR,value:13},{type:a.types.CHAR,value:32},{type:a.types.CHAR,value:160},{type:a.types.CHAR,value:5760},{type:a.types.RANGE,from:8192,to:8202},{type:a.types.CHAR,value:8232},{type:a.types.CHAR,value:8233},{type:a.types.CHAR,value:8239},{type:a.types.CHAR,value:8287},{type:a.types.CHAR,value:12288},{type:a.types.CHAR,value:65279}],i=()=>[{type:a.types.CHAR,value:10},{type:a.types.CHAR,value:13},{type:a.types.CHAR,value:8232},{type:a.types.CHAR,value:8233}];t.words=()=>({type:a.types.SET,set:n(),not:!1}),t.notWords=()=>({type:a.types.SET,set:n(),not:!0}),t.ints=()=>({type:a.types.SET,set:s(),not:!1}),t.notInts=()=>({type:a.types.SET,set:s(),not:!0}),t.whitespace=()=>({type:a.types.SET,set:l(),not:!1}),t.notWhitespace=()=>({type:a.types.SET,set:l(),not:!0}),t.anyChar=()=>({type:a.types.SET,set:i(),not:!0})},49441:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizer=void 0;let l=n(r(51356)),i=r(5739),o=n(r(40879)),c=/^[a-zA-Z_$]$/i,d=/^[a-zA-Z0-9_$]$/i,u=/\d/;t.tokenizer=e=>{let t=0,r,a={type:i.types.ROOT,stack:[]},s=a,n=a.stack,m=[],p=[],h=0,f=t=>{throw SyntaxError(`Invalid regular expression: /${e}/: Nothing to repeat at column ${t-1}`)},x=l.strToChars(e);for(;t<x.length;)switch(r=x[t++]){case"\\":if(t===x.length)throw SyntaxError(`Invalid regular expression: /${e}/: \\ at end of pattern`);switch(r=x[t++]){case"b":n.push({type:i.types.POSITION,value:"b"});break;case"B":n.push({type:i.types.POSITION,value:"B"});break;case"w":n.push(o.words());break;case"W":n.push(o.notWords());break;case"d":n.push(o.ints());break;case"D":n.push(o.notInts());break;case"s":n.push(o.whitespace());break;case"S":n.push(o.notWhitespace());break;default:if(u.test(r)){let e=r;for(;t<x.length&&u.test(x[t]);)e+=x[t++];let a=parseInt(e,10),s={type:i.types.REFERENCE,value:a};n.push(s),p.push({reference:s,stack:n,index:n.length-1})}else n.push({type:i.types.CHAR,value:r.charCodeAt(0)})}break;case"^":n.push({type:i.types.POSITION,value:"^"});break;case"$":n.push({type:i.types.POSITION,value:"$"});break;case"[":{let r;"^"===x[t]?(r=!0,t++):r=!1;let a=l.tokenizeClass(x.slice(t),e);t+=a[1],n.push({type:i.types.SET,set:a[0],not:r});break}case".":n.push(o.anyChar());break;case"(":{let a={type:i.types.GROUP,stack:[],remember:!0};if("?"===x[t]){if(r=x[t+1],t+=2,"="===r)a.followedBy=!0,a.remember=!1;else if("!"===r)a.notFollowedBy=!0,a.remember=!1;else if("<"===r){let r="";if(c.test(x[t]))r+=x[t],t++;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${x[t]}' after '<' at column ${t+1}`);for(;t<x.length&&d.test(x[t]);)r+=x[t],t++;if(!r)throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${x[t]}' after '<' at column ${t+1}`);if(">"!==x[t])throw SyntaxError(`Invalid regular expression: /${e}/: Unclosed capture group name, expected '>', found '${x[t]}' at column ${t+1}`);a.name=r,t++}else if(":"===r)a.remember=!1;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid group, character '${r}' after '?' at column ${t-1}`)}else h+=1;n.push(a),m.push(s),s=a,n=a.stack;break}case")":if(0===m.length)throw SyntaxError(`Invalid regular expression: /${e}/: Unmatched ) at column ${t-1}`);n=(s=m.pop()).options?s.options[s.options.length-1]:s.stack;break;case"|":{s.options||(s.options=[s.stack],delete s.stack);let e=[];s.options.push(e),n=e;break}case"{":{let e=/^(\d+)(,(\d+)?)?\}/.exec(x.slice(t)),r,a;null!==e?(0===n.length&&f(t),r=parseInt(e[1],10),a=e[2]?e[3]?parseInt(e[3],10):1/0:r,t+=e[0].length,n.push({type:i.types.REPETITION,min:r,max:a,value:n.pop()})):n.push({type:i.types.CHAR,value:123});break}case"?":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:0,max:1,value:n.pop()});break;case"+":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:1,max:1/0,value:n.pop()});break;case"*":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:0,max:1/0,value:n.pop()});break;default:n.push({type:i.types.CHAR,value:r.charCodeAt(0)})}if(0!==m.length)throw SyntaxError(`Invalid regular expression: /${e}/: Unterminated group`);return function(e,t){for(let r of e.reverse())if(t<r.reference.value){r.reference.type=i.types.CHAR;let e=r.reference.value.toString();if(r.reference.value=parseInt(e,8),!/^[0-7]+$/.test(e)){let t=0;for(;"8"!==e[t]&&"9"!==e[t];)t+=1;if(0===t?(r.reference.value=e.charCodeAt(0),t+=1):r.reference.value=parseInt(e.slice(0,t),8),e.length>t){let a=r.stack.splice(r.index+1);for(let a of e.slice(t))r.stack.push({type:i.types.CHAR,value:a.charCodeAt(0)});r.stack.push(...a)}}}}(p,h),a}},5739:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),s(r(91311),t),s(r(15270),t),s(r(16785),t)},16785:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},91311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},15270:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0,function(e){e[e.ROOT=0]="ROOT",e[e.GROUP=1]="GROUP",e[e.POSITION=2]="POSITION",e[e.SET=3]="SET",e[e.RANGE=4]="RANGE",e[e.REPETITION=5]="REPETITION",e[e.REFERENCE=6]="REFERENCE",e[e.CHAR=7]="CHAR"}(t.types||(t.types={}))},51356:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizeClass=t.strToChars=void 0;let l=r(5739),i=n(r(40879));t.strToChars=e=>e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(e,t,r,a,s,n,l)=>{if(r)return e;let i=String.fromCharCode(t?8:a?parseInt(a,16):s?parseInt(s,16):n?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(n):({0:0,t:9,n:10,v:11,f:12,r:13})[l]);return/[[\]{}^$.|?*+()]/.test(i)?`\\${i}`:i}),t.tokenizeClass=(e,t)=>{var r,a,s,n,o,c,d;let u=[],m,p,h=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;null!==(m=h.exec(e));){let e=null!==(d=null!==(c=null!==(o=null!==(n=null!==(s=null!==(a=null!==(r=m[1]&&i.words())&&void 0!==r?r:m[2]&&i.ints())&&void 0!==a?a:m[3]&&i.whitespace())&&void 0!==s?s:m[4]&&i.notWords())&&void 0!==n?n:m[5]&&i.notInts())&&void 0!==o?o:m[6]&&i.notWhitespace())&&void 0!==c?c:m[7]&&{type:l.types.RANGE,from:(m[8]||m[9]).charCodeAt(0),to:(p=m[10]).charCodeAt(p.length-1)})&&void 0!==d?d:(p=m[16])&&{type:l.types.CHAR,value:p.charCodeAt(0)};if(!e)return[u,h.lastIndex];u.push(e)}throw SyntaxError(`Invalid regular expression: /${t}/: Unterminated character class`)}},10602:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.writeSetTokens=t.setChar=void 0;let l=r(5739),i=n(r(25296));function o(e){return 94===e?"\\^":92===e?"\\\\":93===e?"\\]":45===e?"\\-":String.fromCharCode(e)}function c(e,{lookup:t,len:r}){if(r!==e.length)return!1;let a=t();for(let t of e){if(t.type===l.types.SET)return!1;let e=t.type===l.types.CHAR?t.value:`${t.from}-${t.to}`;if(!a[e])return!1;a[e]=!1}return!0}t.setChar=o,t.writeSetTokens=function e(t,r=!1){if(c(t.set,i.INTS))return t.not?"\\D":"\\d";if(c(t.set,i.WORDS))return t.not?"\\W":"\\w";if(t.not&&c(t.set,i.NOTANYCHAR))return".";if(c(t.set,i.WHITESPACE))return t.not?"\\S":"\\s";let a="";for(let r=0;r<t.set.length;r++){var s;a+=(s=t.set[r]).type===l.types.CHAR?o(s.value):s.type===l.types.RANGE?`${o(s.from)}-${o(s.to)}`:e(s,!0)}let n=`${t.not?"^":""}${a}`;return r?n:`[${n}]`}},75929:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>rb});var a=r(10326),s=r(35047),n=r(79906),l=r(17577),i=r.n(l);let o={output:"",realtimeSnippet:"",isActive:!1,isThinking:!1,autoScroll:!0,lastUpdated:null},c={data:null,messageId:null,visible:!1,answering:!1},d={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5},u={type:null,message:null,retryable:!1,retryCount:0};function m(){return{phase:"idle",terminal:{...o},prompt:{...c},layout:{...d},error:{...u},messages:[],wsConnected:!1}}function p(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SET_TERMINAL_OUTPUT":return{...e,terminal:{...e.terminal,output:t.output,realtimeSnippet:t.realtimeSnippet,lastUpdated:new Date}};case"SET_TERMINAL_ACTIVE":return{...e,terminal:{...e.terminal,isActive:t.isActive}};case"SET_TERMINAL_THINKING":return{...e,terminal:{...e.terminal,isThinking:t.isThinking}};case"SET_AUTO_SCROLL":return{...e,terminal:{...e.terminal,autoScroll:t.enabled}};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...c}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...u}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};case"START_WAITING_FOR_RESPONSE":return{...e,phase:"waiting",terminal:{...e.terminal,isActive:!0,output:"",realtimeSnippet:""},prompt:{...c}};case"RESPONSE_RECEIVED":return{...e,phase:"complete",messages:[...e.messages,t.message],terminal:{...e.terminal,isActive:!1,isThinking:!1}};case"SESSION_ENDED":return{...e,phase:"idle",terminal:{...o},prompt:{...c}};default:return e}}var h=r(2982),f=r(87403),x=r(6162);class g extends l.Component{constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary:${this.props.componentName||"unknown"}]`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:a.jsx(y,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}}function y({componentName:e,error:t,onRetry:r}){let s=(0,x.T)("error"),n=(0,x.T)("common");return(0,a.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-800 mb-2",children:[a.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:a.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),a.jsx("span",{className:"font-medium",children:e?s("boundary.errorOccurredIn",{componentName:e}):s("boundary.errorOccurred")})]}),t&&a.jsx("p",{className:"text-sm text-red-600 mb-3",children:t.message}),r&&a.jsx("button",{onClick:r,className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors text-sm",children:n("retry")})]})}let b=["flex-shrink-0","bg-gray-700","transition-colors","duration-150","hover:bg-blue-500","focus:outline-none","focus:ring-2","focus:ring-blue-500","focus:ring-offset-2","focus:ring-offset-gray-900"],v=["w-1","h-full","cursor-col-resize","hover:w-2"],w=["h-1","w-full","cursor-row-resize","hover:h-2"];function j(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let N=(0,l.memo)(function({onResize:e,orientation:t="horizontal",ariaValueNow:r=50,onDoubleClick:s,minRatio:n=.1}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(0),d=(0,l.useRef)(null),u="horizontal"===t,m=(0,l.useCallback)(e=>{e.preventDefault(),o(!0),c.current=j(e,u)},[u]),p=(0,l.useCallback)(e=>{1===e.touches.length&&(o(!0),c.current=j(e,u))},[u]),h=(0,l.useCallback)(t=>{if(!i)return;let r=j(t,u);e(r-c.current),c.current=r},[i,u,e]),f=(0,l.useCallback)(t=>{if(!i||1!==t.touches.length)return;let r=j(t,u);e(r-c.current),c.current=r},[i,u,e]),x=(0,l.useCallback)(()=>{o(!1)},[]),g=(0,l.useCallback)(()=>{s&&s()},[s]),y=(0,l.useCallback)(t=>{let r=0;u?"ArrowRight"===t.key?r=10:"ArrowLeft"===t.key&&(r=-10):"ArrowDown"===t.key?r=10:"ArrowUp"===t.key&&(r=-10),0!==r&&(t.preventDefault(),e(r))},[u,e]);(0,l.useEffect)(()=>(i&&(document.addEventListener("mousemove",h),document.addEventListener("mouseup",x),document.addEventListener("touchmove",f),document.addEventListener("touchend",x),document.body.style.userSelect="none",document.body.style.cursor=u?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",x),document.body.style.userSelect="",document.body.style.cursor=""}),[i,h,x,f,u]);let N=(0,l.useMemo)(()=>[...b,...u?v:w,...i?["bg-blue-500","dragging",u?"w-2":"h-2"]:[]].join(" "),[u,i]);return a.jsx("div",{ref:d,role:"separator","aria-orientation":t,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Resize panes. Use ${u?"left and right":"up and down"} arrow keys to adjust.`,tabIndex:0,className:N,onMouseDown:m,onTouchStart:p,onKeyDown:y,onDoubleClick:g})}),k={left:"History",right:"Terminal"},C={left:"HistoryPane",right:"TerminalPane"},S=(0,l.memo)(function({pane:e,isActive:t,onClick:r}){return a.jsx("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`${e}-panel`,onClick:r,className:`flex-1 py-2 px-4 text-sm font-medium transition-colors ${t?"text-blue-400 border-b-2 border-blue-400 bg-gray-900":"text-gray-400 hover:text-gray-300"}`,children:k[e]})}),T=(0,l.memo)(function({leftPane:e,rightPane:t}){let[r,s]=(0,l.useState)("right"),n=(0,l.useCallback)(()=>s("left"),[]),i=(0,l.useCallback)(()=>s("right"),[]);return(0,a.jsxs)("div",{"data-testid":"mobile-layout",className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex border-b border-gray-700 bg-gray-800",role:"tablist",children:[a.jsx(S,{pane:"left",isActive:"left"===r,onClick:n}),a.jsx(S,{pane:"right",isActive:"right"===r,onClick:i})]}),a.jsx("div",{id:`${r}-panel`,role:"tabpanel",className:"flex-1 overflow-hidden",children:a.jsx(g,{componentName:C[r],children:"left"===r?e:t})})]})}),E=(0,l.memo)(function({leftPane:e,rightPane:t,leftWidth:r,onResize:s,className:n}){let i=(0,l.useMemo)(()=>({width:`${r}%`}),[r]),o=(0,l.useMemo)(()=>({width:`${100-r}%`}),[r]),c=(0,l.useMemo)(()=>`flex h-full min-h-0 ${n}`.trim(),[n]);return(0,a.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:c,children:[a.jsx("div",{"data-testid":"left-pane","aria-label":"History pane",style:i,className:"flex-shrink-0 overflow-hidden",children:a.jsx(g,{componentName:C.left,children:e})}),a.jsx(N,{onResize:s,orientation:"horizontal",ariaValueNow:r}),a.jsx("div",{"data-testid":"right-pane","aria-label":"Terminal pane",style:o,className:"flex-grow overflow-hidden",children:a.jsx(g,{componentName:C.right,children:t})})]})}),M=(0,l.memo)(function({leftPane:e,rightPane:t,initialLeftWidth:r=50,minLeftWidth:s=20,maxLeftWidth:n=80,className:i=""}){let o=(0,h.d)(),c=(0,l.useRef)(null),[d,u]=(0,l.useState)(r),m=(0,l.useCallback)(e=>{let t=c.current;if(!t)return;let r=t.offsetWidth;if(0===r)return;let a=e/r*100;u(e=>Math.min(n,Math.max(s,e+a)))},[s,n]);return o?a.jsx(T,{leftPane:e,rightPane:t}):a.jsx("div",{ref:c,className:"h-full",children:a.jsx(E,{leftPane:e,rightPane:t,leftWidth:d,onResize:m,className:i})})});var A=r(24420),R=r.n(A),_=r(43053);let O=new(r.n(_)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function P(){return(0,a.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,a.jsxs)("span",{className:"flex gap-1",children:[a.jsx("span",{className:"animate-pulse delay-0",children:"."}),a.jsx("span",{className:"animate-pulse delay-150",children:"."}),a.jsx("span",{className:"animate-pulse delay-300",children:"."})]}),a.jsx("span",{className:"text-sm",children:"Thinking"})]})}let $=(0,l.memo)(function({output:e,isActive:t,isThinking:r=!1,autoScroll:s=!0,onScrollChange:n,className:i=""}){let{scrollRef:o,autoScroll:c,handleScroll:d,scrollToBottom:u}=function(e={}){let{initialAutoScroll:t=!0,onAutoScrollChange:r}=e,a=(0,l.useRef)(null),[s,n]=(0,l.useState)(t),i=(0,l.useCallback)(e=>{n(e),r?.(e)},[r]),o=(0,l.useCallback)(()=>{let e=a.current;if(!e)return!0;let{scrollTop:t,scrollHeight:r,clientHeight:s}=e;return r-s-t<=50},[]),c=(0,l.useCallback)(()=>{let e=o();e&&!s?i(!0):!e&&s&&i(!1)},[s,o,i]),d=(0,l.useCallback)(()=>{let e=a.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),s||i(!0))},[s,i]);return{scrollRef:a,autoScroll:s,setAutoScroll:i,scrollToBottom:d,handleScroll:c}}({initialAutoScroll:s,onAutoScrollChange:n}),m=function(e){let t=O.toHtml(e);return R().sanitize(t,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}(e||"");(0,l.useEffect)(()=>{c&&o.current&&o.current.scrollTo({top:o.current.scrollHeight,behavior:"instant"})},[m,c,o]);let p=(0,l.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",t?"active":"",t?"border-blue-500":"",i].filter(Boolean).join(" "),[t,i]);return(0,a.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,a.jsxs)("div",{ref:o,role:"log","aria-live":"polite","aria-label":"Terminal output",className:p,onScroll:d,children:[a.jsx("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:m}}),t&&r&&a.jsx(P,{})]}),!c&&a.jsx("button",{onClick:u,className:"absolute bottom-4 right-4 bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md text-sm shadow-lg transition-colors","aria-label":"Scroll to bottom",children:"Scroll to bottom"})]})});var L=r(62881);let I=(0,L.Z)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),D=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function F(e){let t=e.split("\n");if(t.length<=5&&e.length<=300)return{text:e,isTruncated:!1};let r=t.slice(0,5).join("\n");return r.length>300&&(r=r.slice(0,300)),{text:r,isTruncated:!0}}let z=(0,l.memo)(function({content:e,onFilePathClick:t}){let r=(0,l.useMemo)(()=>(function(e){let t=e.match(D);if(!t||0===t.length)return[{type:"text",content:e}];let r=[],a=0;return t.forEach(t=>{let s=e.indexOf(t,a);s>a&&r.push({type:"text",content:e.slice(a,s)}),r.push({type:"path",content:t}),a=s+t.length}),a<e.length&&r.push({type:"text",content:e.slice(a)}),r})(e),[e]),s=(0,l.useCallback)(e=>()=>t(e),[t]);return a.jsx("span",{children:r.map((e,t)=>"path"===e.type?a.jsx("button",{type:"button",onClick:s(e.content),className:"text-blue-400 hover:text-blue-300 hover:underline cursor-pointer font-mono text-sm","aria-label":`Open file: ${e.content}`,children:e.content},t):a.jsx("span",{children:e.content},t))})});function H(){return(0,a.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-gray-400 py-2",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),a.jsx("span",{className:"text-sm",children:"Waiting for response..."})]})}let W=(0,l.memo)(function({message:e,onFilePathClick:t,onCopy:r}){let s=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]);return(0,a.jsxs)("div",{className:"relative bg-blue-900/30 border-l-4 border-blue-500 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-blue-400",children:"You"}),a.jsx("span",{className:"text-xs text-gray-500",children:s})]}),a.jsx("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words",children:a.jsx(z,{content:e.content,onFilePathClick:t})}),r&&a.jsx("button",{type:"button","data-testid":"copy-user-message",onClick:()=>r(e.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:a.jsx(I,{size:14,"aria-hidden":"true"})})]})}),B=(0,l.memo)(function({message:e,index:t,total:r,isExpanded:s,onFilePathClick:n,onCopy:i}){let o=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]),{text:c,isTruncated:d}=(0,l.useMemo)(()=>F(e.content),[e.content]),u=s||!d?e.content:c;return(0,a.jsxs)("div",{className:"assistant-message-item relative",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Assistant"}),a.jsx("span",{className:"text-xs text-gray-500",children:o}),r>1&&(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:["(",t+1,"/",r,")"]})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[a.jsx(z,{content:u,onFilePathClick:n}),!s&&d&&a.jsx("span",{className:"text-gray-500",children:"..."})]}),i&&a.jsx("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>i(e.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:a.jsx(I,{size:14,"aria-hidden":"true"})})]})}),U=(0,l.memo)(function({messages:e,isExpanded:t,onFilePathClick:r,onCopy:s}){return a.jsx("div",{className:"bg-gray-800/50 border-l-4 border-gray-600 p-3 border-t border-gray-700 space-y-3",children:e.map((n,l)=>(0,a.jsxs)(i().Fragment,{children:[l>0&&a.jsx("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),a.jsx(B,{message:n,index:l,total:e.length,isExpanded:t,onFilePathClick:r,onCopy:s})]},n.id))})});function G(){return(0,a.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-yellow-900/20 text-yellow-400 text-xs px-3 py-1 flex items-center gap-2",children:[a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{children:"System Message"})]})}let V=(0,l.memo)(function({pair:e,onFilePathClick:t,isExpanded:r=!1,onToggleExpand:s,onCopy:n}){let i=(0,l.useMemo)(()=>e.assistantMessages.some(e=>{let{isTruncated:t}=F(e.content);return t}),[e.assistantMessages]),o=(0,l.useCallback)(()=>{s&&s()},[s]),c=(0,l.useMemo)(()=>{let t="pending"===e.status?"pending":"orphan"===e.status?"orphan border-l-4 border-yellow-600":"";return`border border-gray-700 rounded-lg overflow-hidden mb-4 transition-colors ${t}`.trim()},[e.status]),d=(0,l.useMemo)(()=>{if(e.userMessage){let t=e.userMessage.content.substring(0,50);return`Conversation: ${t}${e.userMessage.content.length>50?"...":""}`}return"System message"},[e.userMessage]);return(0,a.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":d,className:c,children:["orphan"===e.status&&a.jsx(G,{}),e.userMessage&&a.jsx(W,{message:e.userMessage,onFilePathClick:t,onCopy:n}),"pending"===e.status?a.jsx("div",{className:"bg-gray-800/30 border-l-4 border-gray-600 p-3 border-t border-gray-700",children:a.jsx(H,{})}):e.assistantMessages.length>0?(0,a.jsxs)("div",{className:"relative",children:[a.jsx(U,{messages:e.assistantMessages,isExpanded:r,onFilePathClick:t,onCopy:n}),i&&a.jsx("div",{className:"absolute top-2 right-2",children:(0,a.jsxs)("button",{type:"button",onClick:o,className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1 transition-colors bg-gray-800/80 px-2 py-1 rounded","aria-expanded":r,"aria-label":r?"Collapse message":"Expand message",children:[a.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),r?"Collapse":"Expand"]})})]}):null]})});var q=r(91515);function Y(){return(0,a.jsxs)("div",{"data-testid":"loading-indicator",className:"flex items-center justify-center py-4",role:"status","aria-label":"Loading messages",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-100"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-200"})]}),a.jsx("span",{className:"ml-2 text-sm text-gray-400",children:"Loading..."})]})}function Z(){return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[a.jsx("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("p",{className:"text-sm",children:"No messages yet"})]})}let K=["h-full","flex","flex-col","overflow-y-auto","overflow-x-hidden","bg-gray-900","rounded-lg","border","border-gray-700"],X=(0,l.memo)(function({messages:e,worktreeId:t,onFilePathClick:r,isLoading:s=!1,className:n="",showToast:i}){let o=(0,l.useRef)(null),c=(0,l.useRef)(0),d=(0,l.useRef)(e.length);(0,l.useLayoutEffect)(()=>{let e=o.current;e&&(c.current=e.scrollTop)}),(0,l.useLayoutEffect)(()=>{let t=o.current,r=d.current;t&&e.length===r&&requestAnimationFrame(()=>{t.scrollTop=c.current}),d.current=e.length},[e.length]);let{pairs:u,isExpanded:m,toggleExpand:p}=function(e){let t=(0,l.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),r=[],a=null;for(let e of t)if("user"===e.role)a={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},r.push(a);else if("assistant"===e.role){if(a&&null!==a.userMessage)a.assistantMessages.push(e),a.status="completed";else if(a&&null===a.userMessage)a.assistantMessages.push(e);else{let t={id:`orphan-${e.id}`,userMessage:null,assistantMessages:[e],status:"orphan"};r.push(t),a=t}}return r})(e),[e]),[r,a]=(0,l.useState)(new Set),s=(0,l.useCallback)(e=>{a(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),n=(0,l.useCallback)(e=>r.has(e),[r]),i=(0,l.useCallback)(()=>{a(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:r,toggleExpand:s,isExpanded:n,expandAll:i,collapseAll:(0,l.useCallback)(()=>{a(new Set)},[])}}(e),h=(0,l.useMemo)(()=>[...K,n].filter(Boolean).join(" "),[n]),f=(0,l.useCallback)(e=>r(e),[r]),x=(0,l.useCallback)(e=>()=>p(e),[p]),g=(0,l.useCallback)(async e=>{try{await (0,q.v)(e),i?.("Copied to clipboard","success")}catch{console.error("[HistoryPane] Failed to copy to clipboard"),i?.("Failed to copy","error")}},[i]);return(0,a.jsxs)("div",{ref:o,role:"region","aria-label":"Message history",className:h,children:[a.jsx("div",{className:"sticky top-0 bg-gray-900 border-b border-gray-700 px-4 py-2 z-10",children:a.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Message History"})}),a.jsx("div",{className:"flex-1 p-4 min-h-0",children:s?a.jsx(Y,{}):0===e.length?a.jsx(Z,{}):u.map(e=>a.jsx(V,{pair:e,onFilePathClick:f,isExpanded:m(e.id),onToggleExpand:x(e.id),onCopy:g},e.id))})]})}),J={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function Q({visible:e,duration:t=200}){let[r,a]=(0,l.useState)(e?"visible":"hidden");(0,l.useRef)(null),(0,l.useRef)(e);let s="hidden"!==r,n="fade-in"===r||"fade-out"===r;return{shouldRender:s,animationClass:(0,l.useMemo)(()=>{switch(r){case"fade-in":return J.fadeIn;case"fade-out":return J.fadeOut;default:return J.none}},[r]),isAnimating:n}}let ee=`
1
+ (()=>{var e={};e.id=130,e.ids=[130],e.modules={98860:e=>{"use strict";e.exports=require("jsdom")},72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},55315:e=>{"use strict";e.exports=require("path")},17360:e=>{"use strict";e.exports=require("url")},49411:e=>{"use strict";e.exports=require("node:path")},97742:e=>{"use strict";e.exports=require("node:process")},41041:e=>{"use strict";e.exports=require("node:url")},80205:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>l.a,__next_app__:()=>m,originalPathname:()=>u,pages:()=>d,routeModule:()=>p,tree:()=>c}),r(22570),r(25086),r(35866);var a=r(23191),s=r(88716),n=r(37922),l=r.n(n),i=r(95231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);r.d(t,o);let c=["",{children:["worktrees",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,22570)),"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"]}]},{}]},{metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(r.bind(r,25086)),"/home/runner/work/CommandMate/CommandMate/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,35866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(r.bind(r,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}],d=["/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"],u="/worktrees/[id]/page",m={require:r,loadChunk:()=>Promise.resolve()},p=new a.AppPageRouteModule({definition:{kind:s.x.APP_PAGE,page:"/worktrees/[id]/page",pathname:"/worktrees/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},87923:(e,t,r)=>{Promise.resolve().then(r.bind(r,27247))},62829:e=>{"use strict";let{entries:t,setPrototypeOf:r,isFrozen:a,getPrototypeOf:s,getOwnPropertyDescriptor:n}=Object,{freeze:l,seal:i,create:o}=Object,{apply:c,construct:d}="undefined"!=typeof Reflect&&Reflect;l||(l=function(e){return e}),i||(i=function(e){return e}),c||(c=function(e,t){for(var r=arguments.length,a=Array(r>2?r-2:0),s=2;s<r;s++)a[s-2]=arguments[s];return e.apply(t,a)}),d||(d=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return new e(...r)});let u=C(Array.prototype.forEach),m=C(Array.prototype.lastIndexOf),p=C(Array.prototype.pop),h=C(Array.prototype.push),f=C(Array.prototype.splice),x=C(String.prototype.toLowerCase),g=C(String.prototype.toString),b=C(String.prototype.match),y=C(String.prototype.replace),v=C(String.prototype.indexOf),w=C(String.prototype.trim),j=C(Object.prototype.hasOwnProperty),N=C(RegExp.prototype.test),k=(Z=TypeError,function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return d(Z,t)});function C(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,a=Array(r>1?r-1:0),s=1;s<r;s++)a[s-1]=arguments[s];return c(e,t,a)}}function S(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;r&&r(e,null);let n=t.length;for(;n--;){let r=t[n];if("string"==typeof r){let e=s(r);e!==r&&(a(t)||(t[n]=e),r=e)}e[r]=!0}return e}function T(e){let r=o(null);for(let[a,s]of t(e))j(e,a)&&(Array.isArray(s)?r[a]=function(e){for(let t=0;t<e.length;t++)j(e,t)||(e[t]=null);return e}(s):s&&"object"==typeof s&&s.constructor===Object?r[a]=T(s):r[a]=s);return r}function E(e,t){for(;null!==e;){let r=n(e,t);if(r){if(r.get)return C(r.get);if("function"==typeof r.value)return C(r.value)}e=s(e)}return function(){return null}}let M=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),A=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),R=l(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_=l(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),O=l(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),P=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),$=l(["#text"]),L=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),I=l(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),D=l(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),F=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z=i(/\{\{[\w\W]*|[\w\W]*\}\}/gm),H=i(/<%[\w\W]*|[\w\W]*%>/gm),W=i(/\$\{[\w\W]*/gm),B=i(/^data-[\-\w.\u00B7-\uFFFF]+$/),U=i(/^aria-[\-\w]+$/),G=i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V=i(/^(?:\w+script|data):/i),q=i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Y=i(/^html$/i);var Z,K=Object.freeze({__proto__:null,ARIA_ATTR:U,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:i(/^[a-z][.\w]*(-[.\w]+)+$/i),DATA_ATTR:B,DOCTYPE_NAME:Y,ERB_EXPR:H,IS_ALLOWED_URI:G,IS_SCRIPT_OR_DATA:V,MUSTACHE_EXPR:z,TMPLIT_EXPR:W});let X={element:1,text:3,progressingInstruction:7,comment:8,document:9},J=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null,a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(r=t.getAttribute(a));let s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Q=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};var ee=function e(){let r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window,s=t=>e(t);if(s.version="3.3.1",s.removed=[],!a||!a.document||a.document.nodeType!==X.document||!a.Element)return s.isSupported=!1,s;let{document:n}=a,i=n,c=i.currentScript,{DocumentFragment:d,HTMLTemplateElement:C,Node:z,Element:H,NodeFilter:W,NamedNodeMap:B=a.NamedNodeMap||a.MozNamedAttrMap,HTMLFormElement:U,DOMParser:V,trustedTypes:q}=a,Z=H.prototype,ee=E(Z,"cloneNode"),et=E(Z,"remove"),er=E(Z,"nextSibling"),ea=E(Z,"childNodes"),es=E(Z,"parentNode");if("function"==typeof C){let e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let en="",{implementation:el,createNodeIterator:ei,createDocumentFragment:eo,getElementsByTagName:ec}=n,{importNode:ed}=i,eu=Q();s.isSupported="function"==typeof t&&"function"==typeof es&&el&&void 0!==el.createHTMLDocument;let{MUSTACHE_EXPR:em,ERB_EXPR:ep,TMPLIT_EXPR:eh,DATA_ATTR:ef,ARIA_ATTR:ex,IS_SCRIPT_OR_DATA:eg,ATTR_WHITESPACE:eb,CUSTOM_ELEMENT:ey}=K,{IS_ALLOWED_URI:ev}=K,ew=null,ej=S({},[...M,...A,...R,...O,...$]),eN=null,ek=S({},[...L,...I,...D,...F]),eC=Object.seal(o(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),eS=null,eT=null,eE=Object.seal(o(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),eM=!0,eA=!0,eR=!1,e_=!0,eO=!1,eP=!0,e$=!1,eL=!1,eI=!1,eD=!1,eF=!1,ez=!1,eH=!0,eW=!1,eB=!0,eU=!1,eG={},eV=null,eq=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),eY=null,eZ=S({},["audio","video","img","source","image","track"]),eK=null,eX=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),eJ="http://www.w3.org/1998/Math/MathML",eQ="http://www.w3.org/2000/svg",e0="http://www.w3.org/1999/xhtml",e1=e0,e2=!1,e4=null,e5=S({},[eJ,eQ,e0],g),e3=S({},["mi","mo","mn","ms","mtext"]),e6=S({},["annotation-xml"]),e8=S({},["title","style","font","a","script"]),e7=null,e9=["application/xhtml+xml","text/html"],te=null,tt=null,tr=n.createElement("form"),ta=function(e){return e instanceof RegExp||e instanceof Function},ts=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!tt||tt!==e){if(e&&"object"==typeof e||(e={}),e=T(e),te="application/xhtml+xml"===(e7=-1===e9.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE)?g:x,ew=j(e,"ALLOWED_TAGS")?S({},e.ALLOWED_TAGS,te):ej,eN=j(e,"ALLOWED_ATTR")?S({},e.ALLOWED_ATTR,te):ek,e4=j(e,"ALLOWED_NAMESPACES")?S({},e.ALLOWED_NAMESPACES,g):e5,eK=j(e,"ADD_URI_SAFE_ATTR")?S(T(eX),e.ADD_URI_SAFE_ATTR,te):eX,eY=j(e,"ADD_DATA_URI_TAGS")?S(T(eZ),e.ADD_DATA_URI_TAGS,te):eZ,eV=j(e,"FORBID_CONTENTS")?S({},e.FORBID_CONTENTS,te):eq,eS=j(e,"FORBID_TAGS")?S({},e.FORBID_TAGS,te):T({}),eT=j(e,"FORBID_ATTR")?S({},e.FORBID_ATTR,te):T({}),eG=!!j(e,"USE_PROFILES")&&e.USE_PROFILES,eM=!1!==e.ALLOW_ARIA_ATTR,eA=!1!==e.ALLOW_DATA_ATTR,eR=e.ALLOW_UNKNOWN_PROTOCOLS||!1,e_=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,eO=e.SAFE_FOR_TEMPLATES||!1,eP=!1!==e.SAFE_FOR_XML,e$=e.WHOLE_DOCUMENT||!1,eD=e.RETURN_DOM||!1,eF=e.RETURN_DOM_FRAGMENT||!1,ez=e.RETURN_TRUSTED_TYPE||!1,eI=e.FORCE_BODY||!1,eH=!1!==e.SANITIZE_DOM,eW=e.SANITIZE_NAMED_PROPS||!1,eB=!1!==e.KEEP_CONTENT,eU=e.IN_PLACE||!1,ev=e.ALLOWED_URI_REGEXP||G,e1=e.NAMESPACE||e0,e3=e.MATHML_TEXT_INTEGRATION_POINTS||e3,e6=e.HTML_INTEGRATION_POINTS||e6,eC=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(eC.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ta(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(eC.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(eC.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),eO&&(eA=!1),eF&&(eD=!0),eG&&(ew=S({},$),eN=[],!0===eG.html&&(S(ew,M),S(eN,L)),!0===eG.svg&&(S(ew,A),S(eN,I),S(eN,F)),!0===eG.svgFilters&&(S(ew,R),S(eN,I),S(eN,F)),!0===eG.mathMl&&(S(ew,O),S(eN,D),S(eN,F))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?eE.tagCheck=e.ADD_TAGS:(ew===ej&&(ew=T(ew)),S(ew,e.ADD_TAGS,te))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?eE.attributeCheck=e.ADD_ATTR:(eN===ek&&(eN=T(eN)),S(eN,e.ADD_ATTR,te))),e.ADD_URI_SAFE_ATTR&&S(eK,e.ADD_URI_SAFE_ATTR,te),e.FORBID_CONTENTS&&(eV===eq&&(eV=T(eV)),S(eV,e.FORBID_CONTENTS,te)),e.ADD_FORBID_CONTENTS&&(eV===eq&&(eV=T(eV)),S(eV,e.ADD_FORBID_CONTENTS,te)),eB&&(ew["#text"]=!0),e$&&S(ew,["html","head","body"]),ew.table&&(S(ew,["tbody"]),delete eS.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');en=(r=e.TRUSTED_TYPES_POLICY).createHTML("")}else void 0===r&&(r=J(q,c)),null!==r&&"string"==typeof en&&(en=r.createHTML(""));l&&l(e),tt=e}},tn=S({},[...A,...R,..._]),tl=S({},[...O,...P]),ti=function(e){let t=es(e);t&&t.tagName||(t={namespaceURI:e1,tagName:"template"});let r=x(e.tagName),a=x(t.tagName);return!!e4[e.namespaceURI]&&(e.namespaceURI===eQ?t.namespaceURI===e0?"svg"===r:t.namespaceURI===eJ?"svg"===r&&("annotation-xml"===a||e3[a]):!!tn[r]:e.namespaceURI===eJ?t.namespaceURI===e0?"math"===r:t.namespaceURI===eQ?"math"===r&&e6[a]:!!tl[r]:e.namespaceURI===e0?(t.namespaceURI!==eQ||!!e6[a])&&(t.namespaceURI!==eJ||!!e3[a])&&!tl[r]&&(e8[r]||!tn[r]):"application/xhtml+xml"===e7&&!!e4[e.namespaceURI])},to=function(e){h(s.removed,{element:e});try{es(e).removeChild(e)}catch(t){et(e)}},tc=function(e,t){try{h(s.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(s.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e){if(eD||eF)try{to(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}}},td=function(e){let t=null,a=null;if(eI)e="<remove></remove>"+e;else{let t=b(e,/^[\r\n\t ]+/);a=t&&t[0]}"application/xhtml+xml"===e7&&e1===e0&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let s=r?r.createHTML(e):e;if(e1===e0)try{t=new V().parseFromString(s,e7)}catch(e){}if(!t||!t.documentElement){t=el.createDocument(e1,"template",null);try{t.documentElement.innerHTML=e2?en:s}catch(e){}}let l=t.body||t.documentElement;return(e&&a&&l.insertBefore(n.createTextNode(a),l.childNodes[0]||null),e1===e0)?ec.call(t,e$?"html":"body")[0]:e$?t.documentElement:l},tu=function(e){return ei.call(e.ownerDocument||e,e,W.SHOW_ELEMENT|W.SHOW_COMMENT|W.SHOW_TEXT|W.SHOW_PROCESSING_INSTRUCTION|W.SHOW_CDATA_SECTION,null)},tm=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof B)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},tp=function(e){return"function"==typeof z&&e instanceof z};function th(e,t,r){u(e,e=>{e.call(s,t,r,tt)})}let tf=function(e){let t=null;if(th(eu.beforeSanitizeElements,e,null),tm(e))return to(e),!0;let r=te(e.nodeName);if(th(eu.uponSanitizeElement,e,{tagName:r,allowedTags:ew}),eP&&e.hasChildNodes()&&!tp(e.firstElementChild)&&N(/<[/\w!]/g,e.innerHTML)&&N(/<[/\w!]/g,e.textContent)||e.nodeType===X.progressingInstruction||eP&&e.nodeType===X.comment&&N(/<[/\w]/g,e.data))return to(e),!0;if(!(eE.tagCheck instanceof Function&&eE.tagCheck(r))&&(!ew[r]||eS[r])){if(!eS[r]&&tg(r)&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r)))return!1;if(eB&&!eV[r]){let t=es(e)||e.parentNode,r=ea(e)||e.childNodes;if(r&&t){let a=r.length;for(let s=a-1;s>=0;--s){let a=ee(r[s],!0);a.__removalCount=(e.__removalCount||0)+1,t.insertBefore(a,er(e))}}}return to(e),!0}return e instanceof H&&!ti(e)||("noscript"===r||"noembed"===r||"noframes"===r)&&N(/<\/no(script|embed|frames)/i,e.innerHTML)?(to(e),!0):(eO&&e.nodeType===X.text&&(t=e.textContent,u([em,ep,eh],e=>{t=y(t,e," ")}),e.textContent!==t&&(h(s.removed,{element:e.cloneNode()}),e.textContent=t)),th(eu.afterSanitizeElements,e,null),!1)},tx=function(e,t,r){if(eH&&("id"===t||"name"===t)&&(r in n||r in tr))return!1;if(eA&&!eT[t]&&N(ef,t));else if(eM&&N(ex,t));else if(eE.attributeCheck instanceof Function&&eE.attributeCheck(t,e));else if(!eN[t]||eT[t]){if(!(tg(e)&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,e)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(e))&&(eC.attributeNameCheck instanceof RegExp&&N(eC.attributeNameCheck,t)||eC.attributeNameCheck instanceof Function&&eC.attributeNameCheck(t,e))||"is"===t&&eC.allowCustomizedBuiltInElements&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,r)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(r))))return!1}else if(eK[t]);else if(N(ev,y(r,eb,"")));else if(("src"===t||"xlink:href"===t||"href"===t)&&"script"!==e&&0===v(r,"data:")&&eY[e]);else if(eR&&!N(eg,y(r,eb,"")));else if(r)return!1;return!0},tg=function(e){return"annotation-xml"!==e&&b(e,ey)},tb=function(e){th(eu.beforeSanitizeAttributes,e,null);let{attributes:t}=e;if(!t||tm(e))return;let a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:eN,forceKeepAttr:void 0},n=t.length;for(;n--;){let{name:l,namespaceURI:i,value:o}=t[n],c=te(l),d="value"===l?o:w(o);if(a.attrName=c,a.attrValue=d,a.keepAttr=!0,a.forceKeepAttr=void 0,th(eu.uponSanitizeAttribute,e,a),d=a.attrValue,eW&&("id"===c||"name"===c)&&(tc(l,e),d="user-content-"+d),eP&&N(/((--!?|])>)|<\/(style|title|textarea)/i,d)||"attributename"===c&&b(d,"href")){tc(l,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr||!e_&&N(/\/>/i,d)){tc(l,e);continue}eO&&u([em,ep,eh],e=>{d=y(d,e," ")});let m=te(e.nodeName);if(!tx(m,c,d)){tc(l,e);continue}if(r&&"object"==typeof q&&"function"==typeof q.getAttributeType){if(i);else switch(q.getAttributeType(m,c)){case"TrustedHTML":d=r.createHTML(d);break;case"TrustedScriptURL":d=r.createScriptURL(d)}}if(d!==o)try{i?e.setAttributeNS(i,l,d):e.setAttribute(l,d),tm(e)?to(e):p(s.removed)}catch(t){tc(l,e)}}th(eu.afterSanitizeAttributes,e,null)},ty=function e(t){let r=null,a=tu(t);for(th(eu.beforeSanitizeShadowDOM,t,null);r=a.nextNode();)th(eu.uponSanitizeShadowNode,r,null),tf(r),tb(r),r.content instanceof d&&e(r.content);th(eu.afterSanitizeShadowDOM,t,null)};return s.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,n=null,l=null,o=null;if((e2=!e)&&(e="<!-->"),"string"!=typeof e&&!tp(e)){if("function"==typeof e.toString){if("string"!=typeof(e=e.toString()))throw k("dirty is not a string, aborting")}else throw k("toString is not a function")}if(!s.isSupported)return e;if(eL||ts(t),s.removed=[],"string"==typeof e&&(eU=!1),eU){if(e.nodeName){let t=te(e.nodeName);if(!ew[t]||eS[t])throw k("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof z)(n=(a=td("<!---->")).ownerDocument.importNode(e,!0)).nodeType===X.element&&"BODY"===n.nodeName?a=n:"HTML"===n.nodeName?a=n:a.appendChild(n);else{if(!eD&&!eO&&!e$&&-1===e.indexOf("<"))return r&&ez?r.createHTML(e):e;if(!(a=td(e)))return eD?null:ez?en:""}a&&eI&&to(a.firstChild);let c=tu(eU?e:a);for(;l=c.nextNode();)tf(l),tb(l),l.content instanceof d&&ty(l.content);if(eU)return e;if(eD){if(eF)for(o=eo.call(a.ownerDocument);a.firstChild;)o.appendChild(a.firstChild);else o=a;return(eN.shadowroot||eN.shadowrootmode)&&(o=ed.call(i,o,!0)),o}let m=e$?a.outerHTML:a.innerHTML;return e$&&ew["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&N(Y,a.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+m),eO&&u([em,ep,eh],e=>{m=y(m,e," ")}),r&&ez?r.createHTML(m):m},s.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ts(e),eL=!0},s.clearConfig=function(){tt=null,eL=!1},s.isValidAttribute=function(e,t,r){return tt||ts({}),tx(te(e),te(t),r)},s.addHook=function(e,t){"function"==typeof t&&h(eu[e],t)},s.removeHook=function(e,t){if(void 0!==t){let r=m(eu[e],t);return -1===r?void 0:f(eu[e],r,1)[0]}return p(eu[e])},s.removeHooks=function(e){eu[e]=[]},s.removeAllHooks=function(){eu=Q()},s}();e.exports=ee},24420:(e,t,r)=>{function a(e){return e&&e.default||e}e.exports=global.DOMPurify=global.DOMPurify||("undefined"!=typeof window?a(r(62829)):function(){let e=a(r(62829)),{JSDOM:t}=a(r(98860)),{window:s}=new t("<!DOCTYPE html>");return e(s)}())},43353:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n}});let a=r(91174);r(10326),r(17577);let s=a._(r(77028));function n(e,t){var r;let a={loading:e=>{let{error:t,isLoading:r,pastDelay:a}=e;return null}};"function"==typeof e&&(a.loader=e);let n={...a,...t};return(0,s.default)({...n,modules:null==(r=n.loadableGenerated)?void 0:r.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},933:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let a=r(94129);function s(e){let{reason:t,children:r}=e;throw new a.BailoutToCSRError(t)}},77028:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return c}});let a=r(10326),s=r(17577),n=r(933),l=r(46618);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},r=(0,s.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,a.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.PreloadCss,{moduleIds:t.modules}),(0,a.jsx)(r,{...e})]}):(0,a.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(r,{...e})});return(0,a.jsx)(s.Suspense,{fallback:i,children:o})}return d.displayName="LoadableComponent",d}},46618:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return n}});let a=r(10326),s=r(54580);function n(e){let{moduleIds:t}=e,r=(0,s.getExpectedRequestStore)("next/dynamic css"),n=[];if(r.reactLoadableManifest&&t){let e=r.reactLoadableManifest;for(let r of t){if(!e[r])continue;let t=e[r].files.filter(e=>e.endsWith(".css"));n.push(...t)}}return 0===n.length?null:(0,a.jsx)(a.Fragment,{children:n.map(e=>(0,a.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:r.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},51387:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;let n=r(5739);Object.defineProperty(t,"types",{enumerable:!0,get:function(){return n.types}}),s(r(49441),t),s(r(61601),t);let l=r(49441),i=r(61601);s(r(5739),t),t.default=l.tokenizer,e.exports=l.tokenizer,e.exports.types=n.types,e.exports.reconstruct=i.reconstruct},61601:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstruct=void 0;let a=r(5739),s=r(10602),n=e=>e.map(t.reconstruct).join(""),l=e=>{if("options"in e)return e.options.map(n).join("|");if("stack"in e)return n(e.stack);throw Error("options or stack must be Root or Group token")};t.reconstruct=e=>{switch(e.type){case a.types.ROOT:return l(e);case a.types.CHAR:{let t=String.fromCharCode(e.value);return(/[[\\{}$^.|?*+()]/.test(t)?"\\":"")+t}case a.types.POSITION:if("^"===e.value||"$"===e.value)return e.value;return`\\${e.value}`;case a.types.REFERENCE:return`\\${e.value}`;case a.types.SET:return s.writeSetTokens(e);case a.types.GROUP:{let t=e.name?`?<${e.name}>`:e.remember?"":e.followedBy?"?=":e.notFollowedBy?"?!":"?:";return`(${t}${l(e)})`}case a.types.REPETITION:{let r;let{min:a,max:s}=e;return r=0===a&&1===s?"?":1===a&&s===1/0?"+":0===a&&s===1/0?"*":s===1/0?`{${a},}`:a===s?`{${a}}`:`{${a},${s}}`,`${t.reconstruct(e.value)}${r}`}case a.types.RANGE:return`${s.setChar(e.from)}-${s.setChar(e.to)}`;default:throw Error(`Invalid token type ${e}`)}}},25296:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.NOTANYCHAR=t.WHITESPACE=t.WORDS=t.INTS=void 0;let l=n(r(40879)),i=r(5739);function o(e){let t={},r=0;for(let a of e)a.type===i.types.CHAR&&(t[a.value]=!0),a.type===i.types.RANGE&&(t[`${a.from}-${a.to}`]=!0),r+=1;return{lookup:()=>Object.assign({},t),len:r}}t.INTS=o(l.ints().set),t.WORDS=o(l.words().set),t.WHITESPACE=o(l.whitespace().set),t.NOTANYCHAR=o(l.anyChar().set)},40879:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.anyChar=t.notWhitespace=t.whitespace=t.notInts=t.ints=t.notWords=t.words=void 0;let a=r(5739),s=()=>[{type:a.types.RANGE,from:48,to:57}],n=()=>[{type:a.types.CHAR,value:95},{type:a.types.RANGE,from:97,to:122},{type:a.types.RANGE,from:65,to:90},{type:a.types.RANGE,from:48,to:57}],l=()=>[{type:a.types.CHAR,value:9},{type:a.types.CHAR,value:10},{type:a.types.CHAR,value:11},{type:a.types.CHAR,value:12},{type:a.types.CHAR,value:13},{type:a.types.CHAR,value:32},{type:a.types.CHAR,value:160},{type:a.types.CHAR,value:5760},{type:a.types.RANGE,from:8192,to:8202},{type:a.types.CHAR,value:8232},{type:a.types.CHAR,value:8233},{type:a.types.CHAR,value:8239},{type:a.types.CHAR,value:8287},{type:a.types.CHAR,value:12288},{type:a.types.CHAR,value:65279}],i=()=>[{type:a.types.CHAR,value:10},{type:a.types.CHAR,value:13},{type:a.types.CHAR,value:8232},{type:a.types.CHAR,value:8233}];t.words=()=>({type:a.types.SET,set:n(),not:!1}),t.notWords=()=>({type:a.types.SET,set:n(),not:!0}),t.ints=()=>({type:a.types.SET,set:s(),not:!1}),t.notInts=()=>({type:a.types.SET,set:s(),not:!0}),t.whitespace=()=>({type:a.types.SET,set:l(),not:!1}),t.notWhitespace=()=>({type:a.types.SET,set:l(),not:!0}),t.anyChar=()=>({type:a.types.SET,set:i(),not:!0})},49441:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizer=void 0;let l=n(r(51356)),i=r(5739),o=n(r(40879)),c=/^[a-zA-Z_$]$/i,d=/^[a-zA-Z0-9_$]$/i,u=/\d/;t.tokenizer=e=>{let t=0,r,a={type:i.types.ROOT,stack:[]},s=a,n=a.stack,m=[],p=[],h=0,f=t=>{throw SyntaxError(`Invalid regular expression: /${e}/: Nothing to repeat at column ${t-1}`)},x=l.strToChars(e);for(;t<x.length;)switch(r=x[t++]){case"\\":if(t===x.length)throw SyntaxError(`Invalid regular expression: /${e}/: \\ at end of pattern`);switch(r=x[t++]){case"b":n.push({type:i.types.POSITION,value:"b"});break;case"B":n.push({type:i.types.POSITION,value:"B"});break;case"w":n.push(o.words());break;case"W":n.push(o.notWords());break;case"d":n.push(o.ints());break;case"D":n.push(o.notInts());break;case"s":n.push(o.whitespace());break;case"S":n.push(o.notWhitespace());break;default:if(u.test(r)){let e=r;for(;t<x.length&&u.test(x[t]);)e+=x[t++];let a=parseInt(e,10),s={type:i.types.REFERENCE,value:a};n.push(s),p.push({reference:s,stack:n,index:n.length-1})}else n.push({type:i.types.CHAR,value:r.charCodeAt(0)})}break;case"^":n.push({type:i.types.POSITION,value:"^"});break;case"$":n.push({type:i.types.POSITION,value:"$"});break;case"[":{let r;"^"===x[t]?(r=!0,t++):r=!1;let a=l.tokenizeClass(x.slice(t),e);t+=a[1],n.push({type:i.types.SET,set:a[0],not:r});break}case".":n.push(o.anyChar());break;case"(":{let a={type:i.types.GROUP,stack:[],remember:!0};if("?"===x[t]){if(r=x[t+1],t+=2,"="===r)a.followedBy=!0,a.remember=!1;else if("!"===r)a.notFollowedBy=!0,a.remember=!1;else if("<"===r){let r="";if(c.test(x[t]))r+=x[t],t++;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${x[t]}' after '<' at column ${t+1}`);for(;t<x.length&&d.test(x[t]);)r+=x[t],t++;if(!r)throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${x[t]}' after '<' at column ${t+1}`);if(">"!==x[t])throw SyntaxError(`Invalid regular expression: /${e}/: Unclosed capture group name, expected '>', found '${x[t]}' at column ${t+1}`);a.name=r,t++}else if(":"===r)a.remember=!1;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid group, character '${r}' after '?' at column ${t-1}`)}else h+=1;n.push(a),m.push(s),s=a,n=a.stack;break}case")":if(0===m.length)throw SyntaxError(`Invalid regular expression: /${e}/: Unmatched ) at column ${t-1}`);n=(s=m.pop()).options?s.options[s.options.length-1]:s.stack;break;case"|":{s.options||(s.options=[s.stack],delete s.stack);let e=[];s.options.push(e),n=e;break}case"{":{let e=/^(\d+)(,(\d+)?)?\}/.exec(x.slice(t)),r,a;null!==e?(0===n.length&&f(t),r=parseInt(e[1],10),a=e[2]?e[3]?parseInt(e[3],10):1/0:r,t+=e[0].length,n.push({type:i.types.REPETITION,min:r,max:a,value:n.pop()})):n.push({type:i.types.CHAR,value:123});break}case"?":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:0,max:1,value:n.pop()});break;case"+":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:1,max:1/0,value:n.pop()});break;case"*":0===n.length&&f(t),n.push({type:i.types.REPETITION,min:0,max:1/0,value:n.pop()});break;default:n.push({type:i.types.CHAR,value:r.charCodeAt(0)})}if(0!==m.length)throw SyntaxError(`Invalid regular expression: /${e}/: Unterminated group`);return function(e,t){for(let r of e.reverse())if(t<r.reference.value){r.reference.type=i.types.CHAR;let e=r.reference.value.toString();if(r.reference.value=parseInt(e,8),!/^[0-7]+$/.test(e)){let t=0;for(;"8"!==e[t]&&"9"!==e[t];)t+=1;if(0===t?(r.reference.value=e.charCodeAt(0),t+=1):r.reference.value=parseInt(e.slice(0,t),8),e.length>t){let a=r.stack.splice(r.index+1);for(let a of e.slice(t))r.stack.push({type:i.types.CHAR,value:a.charCodeAt(0)});r.stack.push(...a)}}}}(p,h),a}},5739:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),s(r(91311),t),s(r(15270),t),s(r(16785),t)},16785:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},91311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},15270:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0,function(e){e[e.ROOT=0]="ROOT",e[e.GROUP=1]="GROUP",e[e.POSITION=2]="POSITION",e[e.SET=3]="SET",e[e.RANGE=4]="RANGE",e[e.REPETITION=5]="REPETITION",e[e.REFERENCE=6]="REFERENCE",e[e.CHAR=7]="CHAR"}(t.types||(t.types={}))},51356:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizeClass=t.strToChars=void 0;let l=r(5739),i=n(r(40879));t.strToChars=e=>e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(e,t,r,a,s,n,l)=>{if(r)return e;let i=String.fromCharCode(t?8:a?parseInt(a,16):s?parseInt(s,16):n?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(n):({0:0,t:9,n:10,v:11,f:12,r:13})[l]);return/[[\]{}^$.|?*+()]/.test(i)?`\\${i}`:i}),t.tokenizeClass=(e,t)=>{var r,a,s,n,o,c,d;let u=[],m,p,h=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;null!==(m=h.exec(e));){let e=null!==(d=null!==(c=null!==(o=null!==(n=null!==(s=null!==(a=null!==(r=m[1]&&i.words())&&void 0!==r?r:m[2]&&i.ints())&&void 0!==a?a:m[3]&&i.whitespace())&&void 0!==s?s:m[4]&&i.notWords())&&void 0!==n?n:m[5]&&i.notInts())&&void 0!==o?o:m[6]&&i.notWhitespace())&&void 0!==c?c:m[7]&&{type:l.types.RANGE,from:(m[8]||m[9]).charCodeAt(0),to:(p=m[10]).charCodeAt(p.length-1)})&&void 0!==d?d:(p=m[16])&&{type:l.types.CHAR,value:p.charCodeAt(0)};if(!e)return[u,h.lastIndex];u.push(e)}throw SyntaxError(`Invalid regular expression: /${t}/: Unterminated character class`)}},10602:function(e,t,r){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.writeSetTokens=t.setChar=void 0;let l=r(5739),i=n(r(25296));function o(e){return 94===e?"\\^":92===e?"\\\\":93===e?"\\]":45===e?"\\-":String.fromCharCode(e)}function c(e,{lookup:t,len:r}){if(r!==e.length)return!1;let a=t();for(let t of e){if(t.type===l.types.SET)return!1;let e=t.type===l.types.CHAR?t.value:`${t.from}-${t.to}`;if(!a[e])return!1;a[e]=!1}return!0}t.setChar=o,t.writeSetTokens=function e(t,r=!1){if(c(t.set,i.INTS))return t.not?"\\D":"\\d";if(c(t.set,i.WORDS))return t.not?"\\W":"\\w";if(t.not&&c(t.set,i.NOTANYCHAR))return".";if(c(t.set,i.WHITESPACE))return t.not?"\\S":"\\s";let a="";for(let r=0;r<t.set.length;r++){var s;a+=(s=t.set[r]).type===l.types.CHAR?o(s.value):s.type===l.types.RANGE?`${o(s.from)}-${o(s.to)}`:e(s,!0)}let n=`${t.not?"^":""}${a}`;return r?n:`[${n}]`}},27247:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>rw});var a=r(10326),s=r(35047),n=r(79906),l=r(17577),i=r.n(l);let o={output:"",realtimeSnippet:"",isActive:!1,isThinking:!1,autoScroll:!0,lastUpdated:null},c={data:null,messageId:null,visible:!1,answering:!1},d={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5},u={type:null,message:null,retryable:!1,retryCount:0};function m(){return{phase:"idle",terminal:{...o},prompt:{...c},layout:{...d},error:{...u},messages:[],wsConnected:!1}}function p(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SET_TERMINAL_OUTPUT":return{...e,terminal:{...e.terminal,output:t.output,realtimeSnippet:t.realtimeSnippet,lastUpdated:new Date}};case"SET_TERMINAL_ACTIVE":return{...e,terminal:{...e.terminal,isActive:t.isActive}};case"SET_TERMINAL_THINKING":return{...e,terminal:{...e.terminal,isThinking:t.isThinking}};case"SET_AUTO_SCROLL":return{...e,terminal:{...e.terminal,autoScroll:t.enabled}};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...c}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...u}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};case"START_WAITING_FOR_RESPONSE":return{...e,phase:"waiting",terminal:{...e.terminal,isActive:!0,output:"",realtimeSnippet:""},prompt:{...c}};case"RESPONSE_RECEIVED":return{...e,phase:"complete",messages:[...e.messages,t.message],terminal:{...e.terminal,isActive:!1,isThinking:!1}};case"SESSION_ENDED":return{...e,phase:"idle",terminal:{...o},prompt:{...c}};default:return e}}var h=r(2982),f=r(87403),x=r(6162);class g extends l.Component{constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary:${this.props.componentName||"unknown"}]`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:a.jsx(b,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}}function b({componentName:e,error:t,onRetry:r}){let s=(0,x.T)("error"),n=(0,x.T)("common");return(0,a.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-800 mb-2",children:[a.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:a.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),a.jsx("span",{className:"font-medium",children:e?s("boundary.errorOccurredIn",{componentName:e}):s("boundary.errorOccurred")})]}),t&&a.jsx("p",{className:"text-sm text-red-600 mb-3",children:t.message}),r&&a.jsx("button",{onClick:r,className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors text-sm",children:n("retry")})]})}let y=["flex-shrink-0","bg-gray-700","transition-colors","duration-150","hover:bg-blue-500","focus:outline-none","focus:ring-2","focus:ring-blue-500","focus:ring-offset-2","focus:ring-offset-gray-900"],v=["w-1","h-full","cursor-col-resize","hover:w-2"],w=["h-1","w-full","cursor-row-resize","hover:h-2"];function j(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let N=(0,l.memo)(function({onResize:e,orientation:t="horizontal",ariaValueNow:r=50,onDoubleClick:s,minRatio:n=.1}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(0),d=(0,l.useRef)(null),u="horizontal"===t,m=(0,l.useCallback)(e=>{e.preventDefault(),o(!0),c.current=j(e,u)},[u]),p=(0,l.useCallback)(e=>{1===e.touches.length&&(o(!0),c.current=j(e,u))},[u]),h=(0,l.useCallback)(t=>{if(!i)return;let r=j(t,u);e(r-c.current),c.current=r},[i,u,e]),f=(0,l.useCallback)(t=>{if(!i||1!==t.touches.length)return;let r=j(t,u);e(r-c.current),c.current=r},[i,u,e]),x=(0,l.useCallback)(()=>{o(!1)},[]),g=(0,l.useCallback)(()=>{s&&s()},[s]),b=(0,l.useCallback)(t=>{let r=0;u?"ArrowRight"===t.key?r=10:"ArrowLeft"===t.key&&(r=-10):"ArrowDown"===t.key?r=10:"ArrowUp"===t.key&&(r=-10),0!==r&&(t.preventDefault(),e(r))},[u,e]);(0,l.useEffect)(()=>(i&&(document.addEventListener("mousemove",h),document.addEventListener("mouseup",x),document.addEventListener("touchmove",f),document.addEventListener("touchend",x),document.body.style.userSelect="none",document.body.style.cursor=u?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",x),document.body.style.userSelect="",document.body.style.cursor=""}),[i,h,x,f,u]);let N=(0,l.useMemo)(()=>[...y,...u?v:w,...i?["bg-blue-500","dragging",u?"w-2":"h-2"]:[]].join(" "),[u,i]);return a.jsx("div",{ref:d,role:"separator","aria-orientation":t,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Resize panes. Use ${u?"left and right":"up and down"} arrow keys to adjust.`,tabIndex:0,className:N,onMouseDown:m,onTouchStart:p,onKeyDown:b,onDoubleClick:g})}),k={left:"History",right:"Terminal"},C={left:"HistoryPane",right:"TerminalPane"},S=(0,l.memo)(function({pane:e,isActive:t,onClick:r}){return a.jsx("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`${e}-panel`,onClick:r,className:`flex-1 py-2 px-4 text-sm font-medium transition-colors ${t?"text-blue-400 border-b-2 border-blue-400 bg-gray-900":"text-gray-400 hover:text-gray-300"}`,children:k[e]})}),T=(0,l.memo)(function({leftPane:e,rightPane:t}){let[r,s]=(0,l.useState)("right"),n=(0,l.useCallback)(()=>s("left"),[]),i=(0,l.useCallback)(()=>s("right"),[]);return(0,a.jsxs)("div",{"data-testid":"mobile-layout",className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex border-b border-gray-700 bg-gray-800",role:"tablist",children:[a.jsx(S,{pane:"left",isActive:"left"===r,onClick:n}),a.jsx(S,{pane:"right",isActive:"right"===r,onClick:i})]}),a.jsx("div",{id:`${r}-panel`,role:"tabpanel",className:"flex-1 overflow-hidden",children:a.jsx(g,{componentName:C[r],children:"left"===r?e:t})})]})}),E=(0,l.memo)(function({leftPane:e,rightPane:t,leftWidth:r,onResize:s,className:n}){let i=(0,l.useMemo)(()=>({width:`${r}%`}),[r]),o=(0,l.useMemo)(()=>({width:`${100-r}%`}),[r]),c=(0,l.useMemo)(()=>`flex h-full min-h-0 ${n}`.trim(),[n]);return(0,a.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:c,children:[a.jsx("div",{"data-testid":"left-pane","aria-label":"History pane",style:i,className:"flex-shrink-0 overflow-hidden",children:a.jsx(g,{componentName:C.left,children:e})}),a.jsx(N,{onResize:s,orientation:"horizontal",ariaValueNow:r}),a.jsx("div",{"data-testid":"right-pane","aria-label":"Terminal pane",style:o,className:"flex-grow overflow-hidden",children:a.jsx(g,{componentName:C.right,children:t})})]})}),M=(0,l.memo)(function({leftPane:e,rightPane:t,initialLeftWidth:r=50,minLeftWidth:s=20,maxLeftWidth:n=80,className:i=""}){let o=(0,h.d)(),c=(0,l.useRef)(null),[d,u]=(0,l.useState)(r),m=(0,l.useCallback)(e=>{let t=c.current;if(!t)return;let r=t.offsetWidth;if(0===r)return;let a=e/r*100;u(e=>Math.min(n,Math.max(s,e+a)))},[s,n]);return o?a.jsx(T,{leftPane:e,rightPane:t}):a.jsx("div",{ref:c,className:"h-full",children:a.jsx(E,{leftPane:e,rightPane:t,leftWidth:d,onResize:m,className:i})})});var A=r(24420),R=r.n(A),_=r(43053);let O=new(r.n(_)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function P(){return(0,a.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,a.jsxs)("span",{className:"flex gap-1",children:[a.jsx("span",{className:"animate-pulse delay-0",children:"."}),a.jsx("span",{className:"animate-pulse delay-150",children:"."}),a.jsx("span",{className:"animate-pulse delay-300",children:"."})]}),a.jsx("span",{className:"text-sm",children:"Thinking"})]})}let $=(0,l.memo)(function({output:e,isActive:t,isThinking:r=!1,autoScroll:s=!0,onScrollChange:n,className:i=""}){let{scrollRef:o,autoScroll:c,handleScroll:d,scrollToBottom:u}=function(e={}){let{initialAutoScroll:t=!0,onAutoScrollChange:r}=e,a=(0,l.useRef)(null),[s,n]=(0,l.useState)(t),i=(0,l.useCallback)(e=>{n(e),r?.(e)},[r]),o=(0,l.useCallback)(()=>{let e=a.current;if(!e)return!0;let{scrollTop:t,scrollHeight:r,clientHeight:s}=e;return r-s-t<=50},[]),c=(0,l.useCallback)(()=>{let e=o();e&&!s?i(!0):!e&&s&&i(!1)},[s,o,i]),d=(0,l.useCallback)(()=>{let e=a.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),s||i(!0))},[s,i]);return{scrollRef:a,autoScroll:s,setAutoScroll:i,scrollToBottom:d,handleScroll:c}}({initialAutoScroll:s,onAutoScrollChange:n}),m=function(e){let t=O.toHtml(e);return R().sanitize(t,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}(e||"");(0,l.useEffect)(()=>{c&&o.current&&o.current.scrollTo({top:o.current.scrollHeight,behavior:"instant"})},[m,c,o]);let p=(0,l.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",t?"active":"",t?"border-blue-500":"",i].filter(Boolean).join(" "),[t,i]);return(0,a.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,a.jsxs)("div",{ref:o,role:"log","aria-live":"polite","aria-label":"Terminal output",className:p,onScroll:d,children:[a.jsx("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:m}}),t&&r&&a.jsx(P,{})]}),!c&&a.jsx("button",{onClick:u,className:"absolute bottom-4 right-4 bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md text-sm shadow-lg transition-colors","aria-label":"Scroll to bottom",children:"Scroll to bottom"})]})});var L=r(62881);let I=(0,L.Z)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),D=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function F(e){let t=e.split("\n");if(t.length<=5&&e.length<=300)return{text:e,isTruncated:!1};let r=t.slice(0,5).join("\n");return r.length>300&&(r=r.slice(0,300)),{text:r,isTruncated:!0}}let z=(0,l.memo)(function({content:e,onFilePathClick:t}){let r=(0,l.useMemo)(()=>(function(e){let t=e.match(D);if(!t||0===t.length)return[{type:"text",content:e}];let r=[],a=0;return t.forEach(t=>{let s=e.indexOf(t,a);s>a&&r.push({type:"text",content:e.slice(a,s)}),r.push({type:"path",content:t}),a=s+t.length}),a<e.length&&r.push({type:"text",content:e.slice(a)}),r})(e),[e]),s=(0,l.useCallback)(e=>()=>t(e),[t]);return a.jsx("span",{children:r.map((e,t)=>"path"===e.type?a.jsx("button",{type:"button",onClick:s(e.content),className:"text-blue-400 hover:text-blue-300 hover:underline cursor-pointer font-mono text-sm","aria-label":`Open file: ${e.content}`,children:e.content},t):a.jsx("span",{children:e.content},t))})});function H(){return(0,a.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-gray-400 py-2",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),a.jsx("span",{className:"text-sm",children:"Waiting for response..."})]})}let W=(0,l.memo)(function({message:e,onFilePathClick:t,onCopy:r}){let s=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]);return(0,a.jsxs)("div",{className:"relative bg-blue-900/30 border-l-4 border-blue-500 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-blue-400",children:"You"}),a.jsx("span",{className:"text-xs text-gray-500",children:s})]}),a.jsx("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words",children:a.jsx(z,{content:e.content,onFilePathClick:t})}),r&&a.jsx("button",{type:"button","data-testid":"copy-user-message",onClick:()=>r(e.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:a.jsx(I,{size:14,"aria-hidden":"true"})})]})}),B=(0,l.memo)(function({message:e,index:t,total:r,isExpanded:s,onFilePathClick:n,onCopy:i}){let o=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]),{text:c,isTruncated:d}=(0,l.useMemo)(()=>F(e.content),[e.content]),u=s||!d?e.content:c;return(0,a.jsxs)("div",{className:"assistant-message-item relative",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Assistant"}),a.jsx("span",{className:"text-xs text-gray-500",children:o}),r>1&&(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:["(",t+1,"/",r,")"]})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[a.jsx(z,{content:u,onFilePathClick:n}),!s&&d&&a.jsx("span",{className:"text-gray-500",children:"..."})]}),i&&a.jsx("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>i(e.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:a.jsx(I,{size:14,"aria-hidden":"true"})})]})}),U=(0,l.memo)(function({messages:e,isExpanded:t,onFilePathClick:r,onCopy:s}){return a.jsx("div",{className:"bg-gray-800/50 border-l-4 border-gray-600 p-3 border-t border-gray-700 space-y-3",children:e.map((n,l)=>(0,a.jsxs)(i().Fragment,{children:[l>0&&a.jsx("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),a.jsx(B,{message:n,index:l,total:e.length,isExpanded:t,onFilePathClick:r,onCopy:s})]},n.id))})});function G(){return(0,a.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-yellow-900/20 text-yellow-400 text-xs px-3 py-1 flex items-center gap-2",children:[a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{children:"System Message"})]})}let V=(0,l.memo)(function({pair:e,onFilePathClick:t,isExpanded:r=!1,onToggleExpand:s,onCopy:n}){let i=(0,l.useMemo)(()=>e.assistantMessages.some(e=>{let{isTruncated:t}=F(e.content);return t}),[e.assistantMessages]),o=(0,l.useCallback)(()=>{s&&s()},[s]),c=(0,l.useMemo)(()=>{let t="pending"===e.status?"pending":"orphan"===e.status?"orphan border-l-4 border-yellow-600":"";return`border border-gray-700 rounded-lg overflow-hidden mb-4 transition-colors ${t}`.trim()},[e.status]),d=(0,l.useMemo)(()=>{if(e.userMessage){let t=e.userMessage.content.substring(0,50);return`Conversation: ${t}${e.userMessage.content.length>50?"...":""}`}return"System message"},[e.userMessage]);return(0,a.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":d,className:c,children:["orphan"===e.status&&a.jsx(G,{}),e.userMessage&&a.jsx(W,{message:e.userMessage,onFilePathClick:t,onCopy:n}),"pending"===e.status?a.jsx("div",{className:"bg-gray-800/30 border-l-4 border-gray-600 p-3 border-t border-gray-700",children:a.jsx(H,{})}):e.assistantMessages.length>0?(0,a.jsxs)("div",{className:"relative",children:[a.jsx(U,{messages:e.assistantMessages,isExpanded:r,onFilePathClick:t,onCopy:n}),i&&a.jsx("div",{className:"absolute top-2 right-2",children:(0,a.jsxs)("button",{type:"button",onClick:o,className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1 transition-colors bg-gray-800/80 px-2 py-1 rounded","aria-expanded":r,"aria-label":r?"Collapse message":"Expand message",children:[a.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),r?"Collapse":"Expand"]})})]}):null]})});var q=r(91515);function Y(){return(0,a.jsxs)("div",{"data-testid":"loading-indicator",className:"flex items-center justify-center py-4",role:"status","aria-label":"Loading messages",children:[(0,a.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-100"}),a.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-200"})]}),a.jsx("span",{className:"ml-2 text-sm text-gray-400",children:"Loading..."})]})}function Z(){return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[a.jsx("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("p",{className:"text-sm",children:"No messages yet"})]})}let K=["h-full","flex","flex-col","overflow-y-auto","overflow-x-hidden","bg-gray-900","rounded-lg","border","border-gray-700"],X=(0,l.memo)(function({messages:e,worktreeId:t,onFilePathClick:r,isLoading:s=!1,className:n="",showToast:i}){let o=(0,l.useRef)(null),c=(0,l.useRef)(0),d=(0,l.useRef)(e.length);(0,l.useLayoutEffect)(()=>{let e=o.current;e&&(c.current=e.scrollTop)}),(0,l.useLayoutEffect)(()=>{let t=o.current,r=d.current;t&&e.length===r&&requestAnimationFrame(()=>{t.scrollTop=c.current}),d.current=e.length},[e.length]);let{pairs:u,isExpanded:m,toggleExpand:p}=function(e){let t=(0,l.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),r=[],a=null;for(let e of t)if("user"===e.role)a={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},r.push(a);else if("assistant"===e.role){if(a&&null!==a.userMessage)a.assistantMessages.push(e),a.status="completed";else if(a&&null===a.userMessage)a.assistantMessages.push(e);else{let t={id:`orphan-${e.id}`,userMessage:null,assistantMessages:[e],status:"orphan"};r.push(t),a=t}}return r})(e),[e]),[r,a]=(0,l.useState)(new Set),s=(0,l.useCallback)(e=>{a(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),n=(0,l.useCallback)(e=>r.has(e),[r]),i=(0,l.useCallback)(()=>{a(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:r,toggleExpand:s,isExpanded:n,expandAll:i,collapseAll:(0,l.useCallback)(()=>{a(new Set)},[])}}(e),h=(0,l.useMemo)(()=>[...K,n].filter(Boolean).join(" "),[n]),f=(0,l.useCallback)(e=>r(e),[r]),x=(0,l.useCallback)(e=>()=>p(e),[p]),g=(0,l.useCallback)(async e=>{try{await (0,q.v)(e),i?.("Copied to clipboard","success")}catch{console.error("[HistoryPane] Failed to copy to clipboard"),i?.("Failed to copy","error")}},[i]);return(0,a.jsxs)("div",{ref:o,role:"region","aria-label":"Message history",className:h,children:[a.jsx("div",{className:"sticky top-0 bg-gray-900 border-b border-gray-700 px-4 py-2 z-10",children:a.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Message History"})}),a.jsx("div",{className:"flex-1 p-4 min-h-0",children:s?a.jsx(Y,{}):0===e.length?a.jsx(Z,{}):u.map(e=>a.jsx(V,{pair:e,onFilePathClick:f,isExpanded:m(e.id),onToggleExpand:x(e.id),onCopy:g},e.id))})]})}),J={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function Q({visible:e,duration:t=200}){let[r,a]=(0,l.useState)(e?"visible":"hidden");(0,l.useRef)(null),(0,l.useRef)(e);let s="hidden"!==r,n="fade-in"===r||"fade-out"===r;return{shouldRender:s,animationClass:(0,l.useMemo)(()=>{switch(r){case"fade-in":return J.fadeIn;case"fade-out":return J.fadeOut;default:return J.none}},[r]),isAnimating:n}}let ee=`
2
2
  px-6 py-2 rounded-lg font-medium transition-all
3
3
  disabled:opacity-50 disabled:cursor-not-allowed
4
4
  focus:outline-none focus:ring-2 focus:ring-offset-2
5
- `.trim(),et="bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500";function er({promptData:e,answering:t,onRespond:r,onDismiss:s,labelId:n}){let i=(0,x.T)("prompt"),[o,c]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(!1),h=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===o)??null,[e,o]),f=h?.requiresTextInput===!0,g=t||m,y=(0,l.useCallback)(async e=>{if(!g){p(!0);try{await r(e)}catch(e){}finally{p(!1)}}},[g,r]),b=(0,l.useCallback)(async()=>{if(!g&&null!==o){p(!0);try{let e=f&&d.trim()?d.trim():o.toString();await r(e)}catch(e){}finally{p(!1)}}},[g,r,o,f,d]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("h3",{id:n,className:"text-lg font-semibold text-yellow-800 flex items-center gap-2",children:[a.jsx("span",{className:"text-xl","aria-hidden":"true",children:"?"}),i("confirmationFromClaude")]}),s&&a.jsx("button",{type:"button",onClick:s,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 transition-colors",children:a.jsx("svg",{className:"w-5 h-5 text-yellow-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.instructionText&&a.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 bg-gray-50 rounded p-2 border border-gray-200",children:e.instructionText}),a.jsx("p",{className:"text-gray-800 leading-relaxed",children:e.question}),g&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:i("sending")})]}),"yes_no"===e.type&&a.jsx(ea,{promptData:e,disabled:g,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===e.type&&a.jsx(es,{promptData:e,disabled:g,selectedOption:o,onSelectOption:c,textInputValue:d,onTextInputChange:u,showTextInput:f,onSubmit:b})]})}function ea({promptData:e,disabled:t,onYes:r,onNo:s}){let n=(0,x.T)("prompt"),l="yes"===e.defaultOption,i="no"===e.defaultOption,o=`${ee} ${et} ${l?"primary default highlighted":""}`,c=`${ee} ${i?"bg-gray-600 text-white hover:bg-gray-700 primary default highlighted":"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500"}`;return(0,a.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:o,children:n("yes")}),a.jsx("button",{type:"button",onClick:s,disabled:t,className:c,children:n("no")})]})}function es({promptData:e,disabled:t,selectedOption:r,onSelectOption:s,textInputValue:n,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,x.T)("prompt"),m=(0,l.useCallback)(e=>{let a=r===e,s=t?"opacity-50 cursor-not-allowed":"";return`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${a?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${s}`},[r,t]);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>(0,a.jsxs)("label",{className:m(e.number),children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:r===e.number,onChange:()=>s(e.number),disabled:t,className:"mt-1","aria-describedby":e.isDefault?`default-${e.number}`:void 0}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{id:`default-${e.number}`,className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:u("default")})]})]},e.number))})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:n,onChange:e=>i(e.target.value),disabled:t,placeholder:u("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${ee} ${et}`,children:u("submit")})]})}function en({promptData:e,messageId:t,visible:r,answering:s,onRespond:n,onDismiss:i}){let o;let{shouldRender:c,animationClass:d}=Q({visible:r&&null!==e,duration:200}),u=(0,l.useId)();if(!c||!e)return null;let m=(o="opacity-100","animate-fade-in"===d?o="opacity-100 transform translate-y-0":"animate-fade-out"===d&&(o="opacity-0 transform translate-y-2"),`bg-yellow-50 border-2 border-yellow-300 rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out ${d} ${o}`);return a.jsx(g,{componentName:"PromptPanel",children:a.jsx("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":u,"aria-modal":"true",className:m,children:a.jsx(er,{promptData:e,answering:s,onRespond:n,onDismiss:i,labelId:u})})})}var el=r(61421),ei=r(51223);let eo=(0,l.memo)(function({path:e,className:t="w-6 h-6"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),ec={back:"M15 19l-7-7 7-7",menu:"M4 6h16M4 12h16M4 18h16"};function ed({worktreeName:e,repositoryName:t,status:r,gitStatus:s,onBackClick:n,onMenuClick:i}){let o=(0,l.useMemo)(()=>el.xh[r],[r]);return a.jsx("header",{"data-testid":"mobile-header",role:"banner",className:"fixed top-0 inset-x-0 bg-white border-b border-gray-200 shadow-sm pt-safe z-40",children:(0,a.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[a.jsx("div",{className:"w-10 flex-shrink-0",children:n&&a.jsx("button",{type:"button",onClick:n,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(eo,{path:ec.back})})}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:["spinner"===o.type?a.jsx("span",{"data-testid":"status-indicator","aria-label":o.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 border-2 border-t-transparent animate-spin ${o.className}`}):a.jsx("span",{"data-testid":"status-indicator","aria-label":o.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 ${o.className}`}),(0,a.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[a.jsx("h1",{role:"heading","data-testid":"worktree-name",title:e,className:"text-sm font-medium text-gray-900 truncate text-center leading-tight",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:[t&&a.jsx("span",{className:"truncate max-w-[100px] text-center",children:t}),s&&"(unknown)"!==s.currentBranch&&(0,a.jsxs)(a.Fragment,{children:[t&&a.jsx("span",{className:"text-gray-300",children:"/"}),a.jsx("span",{className:"truncate max-w-[80px] font-mono",title:s.currentBranch,"data-testid":"mobile-branch-name",children:(0,ei.aS)(s.currentBranch,20)}),s.isDirty&&a.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),a.jsx("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&a.jsx("button",{type:"button",onClick:i,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(eo,{path:ec.menu})})})]})})}function eu({"data-testid":e,"aria-label":t,className:r=""}){return a.jsx("span",{"data-testid":e,className:`w-2 h-2 rounded-full bg-blue-500 ${r}`.trim(),"aria-label":t})}let em=(0,l.memo)(function({path:e,className:t="w-5 h-5"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),ep={terminal:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",files:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",memo:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},eh=[{id:"terminal",label:"Terminal",icon:a.jsx(em,{path:ep.terminal})},{id:"history",label:"History",icon:a.jsx(em,{path:ep.history})},{id:"files",label:"Files",icon:a.jsx(em,{path:ep.files})},{id:"memo",label:"CMATE",icon:a.jsx(em,{path:ep.memo})},{id:"info",label:"Info",icon:a.jsx(em,{path:ep.info})}];function ef({activeTab:e,onTabChange:t,hasNewOutput:r=!1,hasPrompt:s=!1,hasUpdate:n=!1}){let i=(0,l.useCallback)(t=>{let r=t===e;return`flex flex-col items-center justify-center flex-1 py-2 px-1 transition-colors relative ${r?"text-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]),o=(0,l.useMemo)(()=>(0,a.jsxs)(a.Fragment,{children:[r&&a.jsx("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-green-500 rounded-full","aria-label":"New output available"}),s&&a.jsx("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-yellow-500 rounded-full","aria-label":"Prompt waiting"})]}),[r,s]);return a.jsx("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":"Mobile navigation",className:"fixed bottom-0 inset-x-0 bg-white border-t border-gray-200 flex pb-safe z-40",children:eh.map(r=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===r.id,"aria-label":r.label,onClick:()=>t(r.id),className:i(r.id),children:[r.icon,a.jsx("span",{className:"text-xs mt-1",children:r.label}),"terminal"===r.id&&o,"info"===r.id&&n&&a.jsx(eu,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":"Update available"})]},r.id))})}let ex={base:"px-6 py-3 rounded-lg font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500",defaultSelected:"bg-gray-600 text-white hover:bg-gray-700"};function eg({promptData:e,visible:t,answering:r,onRespond:s,onDismiss:n}){let{shouldRender:i,animationClass:o}=Q({visible:t&&null!==e,duration:300}),c=(0,l.useId)(),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(0),h=(0,l.useRef)(null),f=(0,l.useCallback)(e=>{u(e.touches[0].clientY)},[]),x=(0,l.useCallback)(e=>{if(null===d)return;let t=e.touches[0].clientY-d;t>0&&p(t)},[d]),y=(0,l.useCallback)(()=>{m>100&&n&&n(),p(0),u(null)},[m,n]),b=(0,l.useCallback)(()=>{n&&n()},[n]),v=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!i||!e)return null;let w="animate-fade-out"===o,j=m>0?`translateY(${m}px)`:void 0;return(0,a.jsxs)(g,{componentName:"MobilePromptSheet",children:[a.jsx("div",{"data-testid":"prompt-overlay",onClick:b,className:`fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ${w?"opacity-0":"opacity-100"} ${w?"pointer-events-none":""}`,"aria-hidden":"true"}),(0,a.jsxs)("div",{ref:h,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":c,onClick:v,onTouchStart:f,onTouchMove:x,onTouchEnd:y,style:{transform:j},className:`fixed bottom-0 inset-x-0 bg-white rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ${w?"translate-y-full":"translate-y-0"}`,children:[a.jsx("div",{className:"flex justify-center pt-3 pb-2",children:a.jsx("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-gray-300 rounded-full","aria-hidden":"true"})}),a.jsx("div",{className:"px-4 pb-6",children:a.jsx(ey,{promptData:e,answering:r,onRespond:s,labelId:c})})]})]})}function ey({promptData:e,answering:t,onRespond:r,labelId:s}){let n=(0,x.T)("prompt"),[i,o]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(!1),p=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===i)??null,[e,i]),h=p?.requiresTextInput===!0,f=t||u,g=(0,l.useCallback)(async e=>{if(!f){m(!0);try{await r(e)}catch{}finally{m(!1)}}},[f,r]),y=(0,l.useCallback)(async()=>{if(!f&&null!==i){m(!0);try{let e=h&&c.trim()?c.trim():i.toString();await r(e)}catch{}finally{m(!1)}}},[f,r,i,h,c]);return(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("h3",{id:s,className:"text-lg font-semibold text-gray-900",children:n("confirmationFromClaude")}),e.instructionText&&a.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 bg-gray-50 rounded p-2 border border-gray-200",children:e.instructionText}),a.jsx("p",{className:"text-gray-700 leading-relaxed",children:e.question}),f&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:n("sending")})]}),"yes_no"===e.type&&a.jsx(eb,{promptData:e,disabled:f,onYes:()=>g("yes"),onNo:()=>g("no")}),"multiple_choice"===e.type&&a.jsx(ev,{promptData:e,disabled:f,selectedOption:i,onSelectOption:o,textInputValue:c,onTextInputChange:d,showTextInput:h,onSubmit:y})]})}let eb=(0,l.memo)(function({promptData:e,disabled:t,onYes:r,onNo:s}){let n=(0,x.T)("prompt"),l="yes"===e.defaultOption,i="no"===e.defaultOption;return(0,a.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:`flex-1 ${ex.base} ${ex.primary} ${l?"ring-2 ring-blue-300":""}`,children:n("yes")}),a.jsx("button",{type:"button",onClick:s,disabled:t,className:`flex-1 ${ex.base} ${i?ex.defaultSelected:ex.secondary}`,children:n("no")})]})}),ev=(0,l.memo)(function({promptData:e,disabled:t,selectedOption:r,onSelectOption:s,textInputValue:n,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,x.T)("prompt");return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>{let n=r===e.number;return(0,a.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${n?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${t?"opacity-50 cursor-not-allowed":""}`,children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:n,onChange:()=>s(e.number),disabled:t,className:"mt-1"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:u("default")})]})]},e.number)})})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:n,onChange:e=>i(e.target.value),disabled:t,placeholder:u("enterValuePlaceholder"),className:"w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${ex.base} ${ex.primary}`,children:u("submit")})]})});var ew=r(15470);let ej={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null},eN=(0,L.Z)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),ek=(0,L.Z)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),eC=(0,L.Z)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),eS=(0,L.Z)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),eT=(0,L.Z)("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]),eE=(0,L.Z)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var eM=r(22202);let eA=(0,l.memo)(function({isOpen:e,position:t,targetPath:r,targetType:s,onClose:n,onNewFile:o,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m,onMove:p}){let h=(0,l.useRef)(null),f=(0,l.useCallback)(e=>{e&&r&&e(r),n()},[r,n]),x=[{id:"new-file",label:"New File",icon:a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(o),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:a.jsx(eC,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:a.jsx(eS,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(d)},{id:"move",label:"Move",icon:a.jsx(eT,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{p&&r&&s&&p(r,s),n()},showDividerAfter:!0},{id:"delete",label:"Delete",icon:a.jsx(eE,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(u),variant:"danger"}].filter(e=>!e.showFor||s&&e.showFor.includes(s));return((0,l.useEffect)(()=>{if(!e)return;let t=e=>{if("Escape"===e.key){n();return}if("ArrowDown"===e.key||"ArrowUp"===e.key){let t;e.preventDefault();let r=h.current?.querySelectorAll('[role="menuitem"]');if(!r?.length)return;let a=Array.from(r).findIndex(e=>e===document.activeElement);t="ArrowDown"===e.key?a<r.length-1?a+1:0:a>0?a-1:r.length-1,r[t].focus()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n]),(0,l.useEffect)(()=>{if(e&&h.current){let e=h.current.querySelector('[role="menuitem"]');e&&e.focus()}},[e]),e)?a.jsx("div",{ref:h,"data-testid":"context-menu",role:"menu","aria-label":"File actions",className:"fixed min-w-[160px] py-1 bg-white rounded-lg shadow-lg border border-gray-200 animate-in fade-in-0 zoom-in-95 duration-100",style:{zIndex:eM.k.CONTEXT_MENU,left:`${t.x}px`,top:`${t.y}px`},children:x.map((e,t)=>(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("button",{role:"menuitem",onClick:e.onClick,disabled:!r,className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-gray-100 ${"danger"===e.variant?"text-red-600 hover:bg-red-50 focus:bg-red-50":"text-gray-700 hover:bg-gray-100"} ${r?"":"opacity-50 cursor-not-allowed"}`,children:[e.icon,a.jsx("span",{children:e.label})]}),e.showDividerAfter&&t<x.length-1&&a.jsx("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});var eR=r(352),e_=r(41593),eO=r(34643);let eP=(0,L.Z)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),e$=(0,l.memo)(function({expanded:e}){return a.jsx("svg",{"data-testid":"chevron-icon",className:`w-4 h-4 text-gray-500 transition-transform ${e?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),eL=(0,l.memo)(function({open:e}){return a.jsx("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e?a.jsx("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):a.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),eI=(0,l.memo)(function({text:e,query:t}){if(!t||!t.trim())return a.jsx(a.Fragment,{children:e});let r=(0,ei.hr)(t),s=e.split(RegExp(`(${r})`,"gi"));return a.jsx(a.Fragment,{children:s.map((e,r)=>e.toLowerCase()===t.toLowerCase()?a.jsx("mark",{className:"bg-yellow-200 text-gray-900 px-0.5 rounded",children:e},r):a.jsx("span",{children:e},r))})}),eD=(0,l.memo)(function({extension:e}){let t=(0,l.useMemo)(()=>e&&({ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-400",jsx:"text-yellow-400",json:"text-yellow-600",md:"text-gray-500",css:"text-pink-500",scss:"text-pink-500",html:"text-orange-500",py:"text-green-500"})[e]||"text-gray-400",[e]);return a.jsx("svg",{"data-testid":"file-icon",className:`w-5 h-5 ${t}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eF=(0,l.memo)(function e({item:t,path:r,depth:s,worktreeId:n,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f,dateFnsLocaleStr:x}){var g;let[y,b]=(0,l.useState)(!1),v=r?`${r}/${t.name}`:t.name,w=i.has(v),j="directory"===t.type,N=o.get(v),k=(0,l.useCallback)(async()=>{j?(w||N||(b(!0),await u(v),b(!1)),c(v)):d?.(v)},[j,w,N,v,u,c,d]),C=(0,l.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),k())},[k]),S=(0,l.useCallback)(e=>{e.preventDefault(),m?.(e,v,j?"directory":"file")},[v,j,m]),T=function({delay:e=500,moveThreshold:t=10,onLongPress:r}){let a=(0,l.useRef)(null),s=(0,l.useRef)(null),n=(0,l.useRef)(null),i=(0,l.useCallback)(()=>{a.current&&(clearTimeout(a.current),a.current=null),s.current=null,n.current=null},[]),o=(0,l.useCallback)(t=>{if(1!==t.touches.length)return;let l=t.touches[0];s.current={x:l.clientX,y:l.clientY},n.current=t,a.current=setTimeout(()=>{n.current&&r(n.current),i()},e)},[e,r,i]);return{onTouchStart:o,onTouchMove:(0,l.useCallback)(e=>{if(!s.current||1!==e.touches.length)return;let r=e.touches[0],a=r.clientX-s.current.x,n=r.clientY-s.current.y;Math.sqrt(a*a+n*n)>t&&i()},[t,i]),onTouchEnd:(0,l.useCallback)(()=>{i()},[i]),onTouchCancel:(0,l.useCallback)(()=>{i()},[i])}}({onLongPress:(0,l.useCallback)(e=>{m?.(e,v,j?"directory":"file")},[v,j,m])}),E={paddingLeft:`${.5+1*Math.min(s,20)}rem`,touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{"data-testid":`tree-item-${t.name}`,role:"treeitem","aria-selected":!1,"aria-expanded":j?w:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-gray-100 rounded transition-colors",style:E,onClick:k,onKeyDown:C,onContextMenu:S,onTouchStart:T.onTouchStart,onTouchMove:T.onTouchMove,onTouchEnd:T.onTouchEnd,onTouchCancel:T.onTouchCancel,children:[j?a.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:y?a.jsx("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx(e$,{expanded:w})}):a.jsx("span",{className:"w-4 h-4"}),j?a.jsx(eL,{open:w}):a.jsx(eD,{extension:t.extension}),a.jsx("span",{className:"flex-1 truncate text-sm text-gray-700",children:"name"===h&&p?a.jsx(eI,{text:t.name,query:p}):t.name}),a.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:j?void 0!==t.itemCount&&`${t.itemCount} items`:void 0===(g=t.size)?"":g<1024?`${g} B`:g<1048576?`${(g/1024).toFixed(1)} KB`:`${(g/1048576).toFixed(1)} MB`}),!j&&t.birthtime&&a.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",title:t.birthtime,children:function(e,t){let r=new Date(e);return isNaN(r.getTime())?"":(0,eR.Q)(r,{addSuffix:!0,...t?{locale:t}:{}})}(t.birthtime,x?(0,e_.G)(x):void 0)})]}),j&&w&&N&&a.jsx("div",{role:"group",children:N.filter(e=>{let t=v?`${v}/${e.name}`:e.name;if(!p?.trim())return!0;if("name"===h){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===h&&f&&f.size>0){if(f.has(t))return!0;if("directory"===e.type){for(let e of f)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>a.jsx(e,{item:t,path:v,depth:s+1,worktreeId:n,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f,dateFnsLocaleStr:x},t.name))})]})}),ez=(0,l.memo)(function({worktreeId:e,onFileSelect:t,onNewFile:r,onNewDirectory:s,onRename:n,onDelete:i,onUpload:o,onMove:c,className:d="",refreshTrigger:u=0,searchQuery:m,searchMode:p,searchResults:h,onSearchResultSelect:f,onCmateSetup:x}){let g=(0,eO.bU)(),[y,b]=(0,l.useState)(!0),[v,w]=(0,l.useState)(null),[j,N]=(0,l.useState)([]),[k,C]=(0,l.useState)(new Set),[S,T]=(0,l.useState)(()=>new Map),E=(0,l.useRef)(k);E.current=k;let M=(0,l.useRef)(new Set),{menuState:A,openMenu:R,closeMenu:_}=function(){let[e,t]=(0,l.useState)(ej);return{menuState:e,openMenu:(0,l.useCallback)((e,r,a)=>{let s,n;if(e.preventDefault(),"touches"in e&&e.touches.length>0)s=e.touches[0].clientX,n=e.touches[0].clientY;else{if(!("clientX"in e))return;s=e.clientX,n=e.clientY}t({isOpen:!0,position:{x:s,y:n},targetPath:r,targetType:a})},[]),closeMenu:(0,l.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),resetMenu:(0,l.useCallback)(()=>{t(ej)},[])}}(),O=(0,l.useCallback)(async(t="")=>{try{let r=t?`/api/worktrees/${e}/tree/${t}`:`/api/worktrees/${e}/tree`,a=await fetch(r);if(!a.ok)throw Error(`Failed to load directory: ${a.status}`);return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[e]);(0,l.useEffect)(()=>{let e=!0;return(async()=>{b(!0),w(null);try{let t=await O();if(!e||!t)return;let r=Array.from(E.current),a=new Map,s=[];for(let t=0;t<r.length;t+=5){if(!e)return;let n=r.slice(t,t+5);for(let[e,t]of(await Promise.allSettled(n.map(async e=>{let t=await O(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?a.set(t.value.dirPath,t.value.data.items):s.push(n[e])}if(!e)return;N(t.items),T(a),s.length>0&&C(e=>{let t=new Set(e);for(let e of s)e&&t.delete(e);return t})}catch(t){e&&w(t instanceof Error?t.message:"Failed to load files")}finally{e&&b(!1)}})(),()=>{e=!1}},[O,u]);let P=(0,l.useCallback)(async e=>{if(!(S.has(e)||M.current.has(e))){M.current.add(e);try{let t=await O(e);t&&T(r=>{let a=new Map(r);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{M.current.delete(e)}}},[S,O]),$=(0,l.useCallback)(e=>{C(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),L=(0,l.useMemo)(()=>"content"===p&&h&&0!==h.length?(0,ei.Ps)(h.map(e=>e.filePath)):new Set,[p,h]);(0,l.useEffect)(()=>{L.size>0&&C(e=>{let t=new Set(e);for(let e of L)(S.has(e)||h?.some(t=>t.filePath.startsWith(e+"/")))&&t.add(e);return t})},[L,S,h]);let I=(0,l.useMemo)(()=>{if(!m?.trim())return j;if("name"===p){let e=m.toLowerCase(),t=(r,a)=>r.filter(r=>{let s=a?`${a}/${r.name}`:r.name,n=r.name.toLowerCase().includes(e);if("directory"===r.type){let e=S.get(s);if(e&&t(e,s).length>0)return!0}return n});return t(j,"")}return"content"===p&&L.size>0?j.filter(e=>{if(L.has(e.name))return!0;if("directory"===e.type){for(let t of L)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):j},[j,m,p,L,S]);return y?(0,a.jsxs)("div",{"data-testid":"file-tree-loading",className:`flex items-center justify-center p-4 ${d}`,children:[a.jsx("span",{className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Loading files..."})]}):v?a.jsx("div",{"data-testid":"file-tree-error",className:`p-4 bg-red-50 border border-red-200 rounded-lg ${d}`,children:a.jsx("p",{className:"text-sm text-red-600",children:v})}):0===j.length?(0,a.jsxs)("div",{"data-testid":"file-tree-empty",className:`p-4 text-center text-gray-500 ${d}`,children:[a.jsx("p",{className:"text-sm",children:"No files found"}),(r||s)&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[r&&(0,a.jsxs)("button",{"data-testid":"empty-new-file-button",onClick:()=>r(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New File"})]}),s&&(0,a.jsxs)("button",{"data-testid":"empty-new-directory-button",onClick:()=>s(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New Directory"})]})]})]}):m?.trim()&&0===I.length?a.jsx("div",{"data-testid":"file-tree-no-results",className:`p-4 text-center text-gray-500 ${d}`,children:(0,a.jsxs)("p",{className:"text-sm",children:["No ","content"===p?"files containing":"files matching",' "',m,'"']})}):(0,a.jsxs)("div",{"data-testid":"file-tree-view",role:"tree","aria-label":"File tree",className:`overflow-auto bg-white ${d}`,children:[(r||s||x)&&(0,a.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-gray-200 dark:border-gray-700",children:[r&&(0,a.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>r(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New File"})]}),s&&(0,a.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>s(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New Directory"})]}),x&&(0,a.jsxs)("button",{"data-testid":"toolbar-cmate-button",onClick:x,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(eP,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"CMATE"})]})]}),I.map(r=>a.jsx(eF,{item:r,path:"",depth:0,worktreeId:e,expanded:k,cache:S,onToggle:$,onFileSelect:f||t,onLoadChildren:P,onContextMenu:R,searchQuery:m,searchMode:p,matchedPaths:L,dateFnsLocaleStr:g},r.name)),a.jsx(eA,{isOpen:A.isOpen,position:A.position,targetPath:A.targetPath,targetType:A.targetType,onClose:_,onNewFile:r,onNewDirectory:s,onRename:n,onDelete:i,onUpload:o,onMove:c})]})}),eH=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),eW=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),eB=(0,l.memo)(function(){return a.jsx("div",{"data-testid":"search-loading",className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin","aria-label":"Searching..."})}),eU=(0,l.memo)(function({query:e,mode:t,isSearching:r,error:s,onQueryChange:n,onModeChange:i,onClear:o,placeholder:c="Search files...",className:d=""}){let u=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{n(e.target.value)},[n]),p=(0,l.useCallback)(()=>{o(),u.current?.focus()},[o]),f=(0,l.useCallback)(t=>{"Escape"===t.key&&(e?p():u.current?.blur())},[e,p]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<h.G)){let e=setTimeout(()=>{u.current?.focus()},100);return()=>clearTimeout(e)}},[]),(0,a.jsxs)("div",{"data-testid":"search-bar",className:`flex flex-col gap-2 p-2 bg-white border-b border-gray-200 ${d}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsx(eH,{})}),a.jsx("input",{ref:u,type:"text","data-testid":"search-input",value:e,onChange:m,onKeyDown:f,placeholder:c,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-gray-50 border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search files","aria-busy":r}),a.jsx("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:r?a.jsx(eB,{}):e?a.jsx("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-gray-400 hover:text-gray-600 rounded transition-colors","aria-label":"Clear search",children:a.jsx(eW,{})}):null})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Mode:"}),a.jsx("button",{type:"button","data-testid":"mode-name",onClick:()=>i("name"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"name"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"name"===t,children:"Name"}),a.jsx("button",{type:"button","data-testid":"mode-content",onClick:()=>i("content"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"content"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"content"===t,children:"Content"})]}),s&&a.jsx("div",{"data-testid":"search-error",className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded",role:"alert",children:s})]})}),eG=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eV=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),eq=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eY=[{id:"history",label:"History",icon:a.jsx(eG,{})},{id:"files",label:"Files",icon:a.jsx(eV,{})},{id:"memo",label:"CMATE",icon:a.jsx(eq,{})}],eZ=(0,l.memo)(function({activeTab:e,onTabChange:t,className:r=""}){let s=(0,l.useCallback)(e=>{t(e)},[t]),n=(0,l.useCallback)((e,r)=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),t(e))},[t]),i=(0,l.useCallback)(t=>{let r=t===e;return`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset ${r?"bg-blue-50 text-blue-600 border-b-2 border-blue-600":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]);return a.jsx("div",{role:"tablist","aria-label":"Left pane view switcher",className:`flex border-b border-gray-200 bg-white ${r}`,children:eY.map(t=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===t.id,"aria-label":t.label,tabIndex:0,onClick:()=>s(t.id),onKeyDown:e=>n(t.id,e),className:i(t.id),children:[t.icon,a.jsx("span",{children:t.label})]},t.id))})});var eK=r(77758),eX=r(81194),eJ=r(89918);let eQ=(0,L.Z)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function e0({isOpen:e,onClose:t,worktreeId:r,filePath:s}){let[n,i]=(0,l.useState)(null),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),h=(0,l.useMemo)(()=>!!(n?.content&&!n.isImage&&!n.isVideo),[n]),f=(0,l.useCallback)(async()=>{if(h&&n?.content)try{await (0,q.v)(n.content),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[h,n]);return a.jsx(eK.u_,{isOpen:e,onClose:t,title:s,size:"xl",children:(0,a.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] overflow-y-auto",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"ml-3 text-gray-600",children:"Loading file..."})]}),d&&a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-sm text-red-800",children:d})]})}),n&&!o&&!d&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg overflow-hidden",children:[(0,a.jsxs)("div",{className:"bg-gray-100 px-4 py-2 border-b border-gray-200 flex items-center justify-between",children:[(0,a.jsxs)("p",{className:"text-xs text-gray-600 font-mono truncate",children:[n.worktreePath,"/",n.path]}),h&&a.jsx("button",{"data-testid":"copy-content-button",onClick:f,className:"flex-shrink-0 ml-2 p-1 rounded hover:bg-gray-200 transition-colors text-gray-500 hover:text-gray-700","aria-label":"Copy file content",children:m?a.jsx(eQ,{className:"w-4 h-4 text-green-600"}):a.jsx(I,{className:"w-4 h-4"})})]}),n.isImage?a.jsx(eX.O,{src:n.content,alt:n.path,mimeType:n.mimeType}):n.isVideo?a.jsx(eJ.R,{src:n.content,mimeType:n.mimeType}):a.jsx("div",{className:"p-4",children:a.jsx("pre",{className:"text-sm overflow-x-auto",children:a.jsx("code",{className:`language-${n.extension}`,children:n.content})})})]})]})})}var e1=r(60962),e2=r(83173),e4=r(26394),e5=r(43286),e3=r(72339);let e6=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],e8={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...e6,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...e6],h2:[["className","sr-only"]],img:[...e6,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...e6,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...e6],table:[...e6],ul:[...e6,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},e7={}.hasOwnProperty;function e9(e,t){if(t&&"object"==typeof t)switch("string"==typeof t.type?t.type:""){case"comment":return function(e,t){if(e.schema.allowComments){let e="string"==typeof t.value?t.value:"",r=e.indexOf("-->"),a={type:"comment",value:r<0?e:e.slice(0,r)};return ta(a,t),a}}(e,t);case"doctype":return function(e,t){if(e.schema.allowDoctypes){let e={type:"doctype"};return ta(e,t),e}}(e,t);case"element":return function(e,t){let r="string"==typeof t.tagName?t.tagName:"";e.stack.push(r);let a=te(e,t.children),s=function(e,t){let r;let a=e.stack[e.stack.length-1],s=e.schema.attributes,n=e.schema.required,l=s&&e7.call(s,a)?s[a]:void 0,i=s&&e7.call(s,"*")?s["*"]:void 0,o=t&&"object"==typeof t?t:{},c={};for(r in o)if(e7.call(o,r)){let t=o[r],a=tt(e,ts(l,r),r,t);null==a&&(a=tt(e,ts(i,r),r,t)),null!=a&&(c[r]=a)}if(n&&e7.call(n,a)){let e=n[a];for(r in e)e7.call(e,r)&&!e7.call(c,r)&&(c[r]=e[r])}return c}(e,t.properties);e.stack.pop();let n=!1;if(r&&"*"!==r&&(!e.schema.tagNames||e.schema.tagNames.includes(r))&&(n=!0,e.schema.ancestors&&e7.call(e.schema.ancestors,r))){let t=e.schema.ancestors[r],a=-1;for(n=!1;++a<t.length;)e.stack.includes(t[a])&&(n=!0)}if(!n)return e.schema.strip&&!e.schema.strip.includes(r)?a:void 0;let l={type:"element",tagName:r,properties:s,children:a};return ta(l,t),l}(e,t);case"root":return function(e,t){let r={type:"root",children:te(e,t.children)};return ta(r,t),r}(e,t);case"text":return function(e,t){let r={type:"text",value:"string"==typeof t.value?t.value:""};return ta(r,t),r}(0,t)}}function te(e,t){let r=[];if(Array.isArray(t)){let a=-1;for(;++a<t.length;){let s=e9(e,t[a]);s&&(Array.isArray(s)?r.push(...s):r.push(s))}}return r}function tt(e,t,r,a){return t?Array.isArray(a)?function(e,t,r,a){let s=-1,n=[];for(;++s<a.length;){let l=tr(e,t,r,a[s]);("number"==typeof l||"string"==typeof l)&&n.push(l)}return n}(e,t,r,a):tr(e,t,r,a):void 0}function tr(e,t,r,a){if(("boolean"==typeof a||"number"==typeof a||"string"==typeof a)&&function(e,t,r){let a=e.schema.protocols&&e7.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!a||0===a.length)return!0;let s=String(r),n=s.indexOf(":"),l=s.indexOf("?"),i=s.indexOf("#"),o=s.indexOf("/");if(n<0||o>-1&&n>o||l>-1&&n>l||i>-1&&n>i)return!0;let c=-1;for(;++c<a.length;){let e=a[c];if(n===e.length&&s.slice(0,e.length)===e)return!0}return!1}(e,r,a)){if("object"==typeof t&&t.length>1){let e=!1,r=0;for(;++r<t.length;){let s=t[r];if(s&&"object"==typeof s&&"flags"in s){if(s.test(String(a))){e=!0;break}}else if(s===a){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(r)?e.schema.clobberPrefix+a:a}}function ta(e,t){let r=(0,e3.FK)(t);t.data&&(e.data=(0,e5.ZP)(t.data)),r&&(e.position=r)}function ts(e,t){let r;let a=-1;if(e)for(;++a<e.length;){let s=e[a],n="string"==typeof s?s:s[0];if(n===t)return s;"data*"===n&&(r=s)}if(t.length>4&&"data"===t.slice(0,4).toLowerCase())return r}function tn(e){return function(t){return function(e,t){let r={type:"root",children:[]},a=e9({schema:t?{...e8,...t}:e8,stack:[]},e);return a&&(Array.isArray(a)?1===a.length?r=a[0]:r.children=a:r=a),r}(t,e)}}var tl=r(42283);r(4803);let ti=(0,L.Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),to=(0,L.Z)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),tc=(0,L.Z)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),td=(0,L.Z)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),tu=(0,L.Z)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),tm=(0,L.Z)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var tp=r(94019),th=r(11865),tf=r(43353),tx=r.n(tf);let tg=(0,L.Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),ty=tx()(async()=>{},{loadableGenerated:{modules:["components/worktree/MermaidCodeBlock.tsx -> ./MermaidDiagram"]},ssr:!1,loading:()=>(0,a.jsxs)("div",{className:"mermaid-loading flex items-center gap-2 text-gray-500 p-4",children:[a.jsx(tg,{className:"animate-spin h-4 w-4"}),a.jsx("span",{children:"Loading diagram..."})]})});function tb({className:e,children:t,inline:r}){if(r)return a.jsx("code",{className:e,children:t});if(e&&e.split(" ").includes("language-mermaid")){let e=null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e=>"string"==typeof e?e:"").join(""):String(t);return a.jsx(ty,{code:e})}return a.jsx("code",{className:e,children:t})}function tv(){return"undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}async function tw(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen)return e.webkitRequestFullscreen();if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();throw Error("Fullscreen API not supported")}async function tj(){if("undefined"!=typeof document){if(document.exitFullscreen)return document.exitFullscreen();if(document.webkitExitFullscreen)return document.webkitExitFullscreen();if(document.mozCancelFullScreen)return document.mozCancelFullScreen();if(document.msExitFullscreen)return document.msExitFullscreen()}}function tN(e){let{key:t,defaultValue:r,validate:a,serialize:s=JSON.stringify,deserialize:n=JSON.parse}=e,i=(0,l.useRef)(r),o=(0,l.useRef)(a),c=(0,l.useRef)(s),d=(0,l.useRef)(n);i.current=r,o.current=a,c.current=s,d.current=n;let[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(r);(0,l.useCallback)(()=>i.current,[t]);let f=(0,l.useCallback)(e=>{},[t]);return{value:p,setValue:(0,l.useCallback)(e=>{h(t=>{let r="function"==typeof e?e(t):e;return f(r),r})},[f]),removeValue:(0,l.useCallback)(()=>{h(i.current)},[t]),isAvailable:u}}let tk=()=>!1,tC={split:{showEditor:!0,showPreview:!0,editorWidth:"w-1/2",previewWidth:"w-1/2"},editor:{showEditor:!0,showPreview:!1,editorWidth:"w-full",previewWidth:"w-0"},preview:{showEditor:!1,showPreview:!0,editorWidth:"w-0",previewWidth:"w-full"}},tS={WARNING_THRESHOLD:512e3};function tT(e){return"number"==typeof e&&e>=.1&&e<=.9}function tE(e){return"boolean"==typeof e}function tM({worktreeId:e,filePath:t,onClose:r,onSave:s,initialViewMode:n,onMaximizedChange:i}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(""),[f,x]=(0,l.useState)(()=>n&&("split"===n||"editor"===n||"preview"===n)?n:"split"),[g,y]=(0,l.useState)(!0),[b,v]=(0,l.useState)(!1),[w,j]=(0,l.useState)(null),[k,C]=(0,l.useState)(!1),[S,T]=(0,l.useState)(!1),[E,M]=(0,l.useState)("editor"),[A,R]=(0,l.useState)(null),{toasts:_,showToast:O,removeToast:P}=(0,th.pm)(),$=(0,l.useRef)(null);(0,l.useRef)(null);let L=(0,l.useRef)(null),D=(0,l.useRef)(null),F=(0,h.d)(),{isKeyboardVisible:z,keyboardHeight:H}=function(){let[e,t]=(0,l.useState)(!1),[r,a]=(0,l.useState)(0);return(0,l.useCallback)(()=>{if(!tk())return;let e=window.visualViewport,r=window.innerHeight-e.height,s=r>100;t(s),a(s?r:0)},[]),{isKeyboardVisible:e,keyboardHeight:r}}(),{value:W,setValue:B}=tN({key:"commandmate:md-editor-maximized",defaultValue:!1,validate:tE}),{isFullscreen:U,isFallbackMode:G,enterFullscreen:V,exitFullscreen:Y,toggleFullscreen:Z}=function(e={}){let{elementRef:t,onEnter:r,onExit:a,onError:s}=e,[n,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null);(0,l.useCallback)(()=>{let e=null!=tv();i(e),!e&&o&&c(!1)},[o]);let m=(0,l.useCallback)(async()=>{if(u(null),"undefined"!=typeof navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)){i(!0),c(!0),r?.();return}if("undefined"!=typeof document&&(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&t?.current)try{await tw(t.current),i(!0),c(!1),r?.()}catch(t){let e=t instanceof Error?t.message:"Failed to enter fullscreen";u(e),s?.(t instanceof Error?t:Error(e)),i(!0),c(!0),r?.()}else i(!0),c(!0),r?.()},[t,r,s]),p=(0,l.useCallback)(async()=>{if(u(null),o){i(!1),c(!1),a?.();return}if(tv())try{await tj(),i(!1),a?.()}catch(t){let e=t instanceof Error?t.message:"Failed to exit fullscreen";u(e),s?.(t instanceof Error?t:Error(e)),i(!1),c(!1),a?.()}else i(!1),c(!1),a?.()},[o,a,s]),h=(0,l.useCallback)(async()=>{n?await p():await m()},[n,m,p]);return{isFullscreen:n,isFallbackMode:o,enterFullscreen:m,exitFullscreen:p,toggleFullscreen:h,error:d}}({elementRef:L,onEnter:()=>B(!0),onExit:()=>B(!1)}),{value:K,setValue:X}=tN({key:"commandmate:md-editor-split-ratio",defaultValue:.5,validate:tT}),{ref:J}=function(e={}){let{onSwipeLeft:t,onSwipeRight:r,onSwipeUp:a,onSwipeDown:s,threshold:n=50,enabled:i=!0}=e,o=(0,l.useRef)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),p=(0,l.useRef)(null),h=(0,l.useCallback)(()=>{m(null)},[]);return(0,l.useCallback)(e=>{if(!i)return;if(e.target instanceof HTMLElement&&function(e){let t=e;for(;t;){let{overflowY:e}=getComputedStyle(t);if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return!0;t=t.parentElement}return!1}(e.target)){p.current=null;return}let t=e.touches[0];p.current={x:t.clientX,y:t.clientY},d(!0)},[i]),(0,l.useCallback)(e=>{if(!i||!p.current)return;let t=e.touches[0],r=t.clientX-p.current.x,a=t.clientY-p.current.y,s=Math.abs(r),l=Math.abs(a);s>l&&s>=n?m(r<0?"left":"right"):l>=n&&m(a<0?"up":"down")},[i,n]),(0,l.useCallback)(e=>{if(!i||!p.current){d(!1);return}let l=e.changedTouches[0],o=l.clientX-p.current.x,c=l.clientY-p.current.y,u=Math.abs(o),h=Math.abs(c);u>h?u>=n&&(o<0?(m("left"),t?.()):(m("right"),r?.())):h>=n&&(c<0?(m("up"),a?.()):(m("down"),s?.())),p.current=null,d(!1)},[i,n,t,r,a,s]),{ref:o,isSwiping:c,swipeDirection:u,resetSwipeDirection:h}}({onSwipeDown:()=>{U&&Y()},threshold:150,enabled:U&&F}),Q=o!==d,ee=tC[f],et=F&&!1,er=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{p(e)},300),[]);(0,l.useCallback)(async()=>{y(!0),j(null);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to load file");let s=a.content||"";c(s),u(s),p(s),new Blob([s]).size>tS.WARNING_THRESHOLD&&C(!0)}catch(e){j(e instanceof Error?e.message:"Failed to load file")}finally{y(!1)}},[e,t]);let ea=(0,l.useCallback)(async()=>{if(Q&&!b){v(!0);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o})}),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to save file");u(o),O("File saved successfully","success"),s&&s(t)}catch(e){O(e instanceof Error?e.message:"Failed to save file","error")}finally{v(!1)}}},[e,t,o,Q,b,s,O]),es=(0,l.useCallback)(e=>{let t=e.target.value;c(t),er(t)},[er]),en=(0,l.useCallback)(e=>{x(e)},[]),el=(0,l.useCallback)(()=>{(!Q||window.confirm("You have unsaved changes. Are you sure you want to close?"))&&r&&r()},[Q,r]),eo=(0,l.useCallback)(async()=>{try{await (0,q.v)(o),T(!0),setTimeout(()=>T(!1),2e3)}catch{}},[o]),ec=(0,l.useCallback)(e=>{if(!D.current)return;let t=D.current.offsetWidth;if(0===t)return;let r=e/t;X(e=>Math.max(.1,Math.min(.9,e+r)))},[X]),ed=(0,l.useCallback)(()=>{X(.5)},[X]),eu=(0,l.useCallback)(e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),ea();return}if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F"===e.key){e.preventDefault(),Z();return}if("Escape"===e.key&&U){e.preventDefault(),Y();return}},[ea,Z,Y,U]),em=(0,l.useMemo)(()=>{let e="flex flex-col bg-white";return U&&G?`${e} fixed inset-0`:`${e} h-full`},[U,G]),ep=(0,l.useMemo)(()=>{if(U)return{zIndex:eM.k.MAXIMIZED_EDITOR}},[U]),eh=(0,l.useMemo)(()=>{if("split"===f&&!et)return{width:`${100*K}%`,flexShrink:0}},[f,K,et]),ef=(0,l.useMemo)(()=>{if("split"===f&&!et)return{width:`${(1-K)*100}%`,flexShrink:0}},[f,K,et]),ex=(0,l.useMemo)(()=>{if(z&&H>0)return{paddingBottom:H}},[z,H]),eg=(0,l.useMemo)(()=>({code:tb}),[]),ey=(0,l.useMemo)(()=>a.jsx(e2.UG,{remarkPlugins:[e4.Z],rehypePlugins:[tn,tl.Z],components:eg,children:m}),[m,eg]);if(g)return a.jsx("div",{"data-testid":"markdown-editor",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"mt-4 text-gray-600",children:"Loading..."})]})});if(w)return a.jsx("div",{"data-testid":"markdown-editor-error",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx(ti,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),a.jsx("p",{className:"text-red-600",children:w}),r&&a.jsx("button",{onClick:r,className:"mt-4 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg",children:"Close"})]})});let eb=(0,a.jsxs)("div",{ref:e=>{L.current=e,J.current=e},"data-testid":"markdown-editor",className:em,style:ep,onKeyDown:eu,role:U&&G?"dialog":void 0,"aria-modal":U&&G?"true":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 bg-gray-50",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-shrink",children:[a.jsx(eP,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:t}),Q&&a.jsx("span",{"data-testid":"dirty-indicator",className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 flex-shrink-0",children:"Unsaved"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!et&&(0,a.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[a.jsx("button",{"data-testid":"view-mode-split","aria-pressed":"split"===f,onClick:()=>en("split"),className:`p-1.5 rounded ${"split"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Split view",children:a.jsx(to,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-editor","aria-pressed":"editor"===f,onClick:()=>en("editor"),className:`p-1.5 rounded ${"editor"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Editor only",children:a.jsx(eP,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-preview","aria-pressed":"preview"===f,onClick:()=>en("preview"),className:`p-1.5 rounded ${"preview"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Preview only",children:a.jsx(tc,{className:"h-4 w-4"})})]}),a.jsx("button",{"data-testid":"copy-content-button",onClick:eo,className:`p-1.5 hover:bg-gray-100 rounded ${S?"text-green-500":"text-gray-500 hover:text-gray-700"}`,title:"Copy content",children:S?a.jsx(eQ,{className:"h-4 w-4"}):a.jsx(I,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"maximize-button",onClick:Z,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:U?"Exit fullscreen (ESC)":"Enter fullscreen (Ctrl+Shift+F)","aria-pressed":U,children:U?a.jsx(td,{className:"h-4 w-4"}):a.jsx(tu,{className:"h-4 w-4"})}),(0,a.jsxs)("button",{"data-testid":"save-button",onClick:ea,disabled:!Q||b,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${Q&&!b?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[a.jsx(tm,{className:"h-4 w-4"}),b?"Saving...":"Save"]}),r&&a.jsx("button",{"data-testid":"close-button",onClick:el,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:"Close",children:a.jsx(tp.Z,{className:"h-4 w-4"})})]})]}),U&&(0,a.jsxs)("div",{"data-testid":"maximize-hint",className:"flex items-center justify-center px-4 py-1 bg-gray-800 text-gray-300 text-xs",children:["Press ESC to exit fullscreen ",F&&"(or swipe down)"]}),k&&(0,a.jsxs)("div",{"data-testid":"large-file-warning",className:"flex items-center gap-2 px-4 py-2 bg-yellow-50 border-b border-yellow-200 text-yellow-800 text-sm",children:[a.jsx(ti,{className:"h-4 w-4"}),"Large file: Performance may be affected.",a.jsx("button",{onClick:()=>C(!1),className:"ml-auto text-yellow-600 hover:text-yellow-800",children:a.jsx(tp.Z,{className:"h-4 w-4"})})]}),et&&(0,a.jsxs)("div",{className:"flex border-b border-gray-200",children:[(0,a.jsxs)("button",{"data-testid":"mobile-tab-editor",onClick:()=>M("editor"),className:`flex-1 py-2 text-sm font-medium ${"editor"===E?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(eP,{className:"h-4 w-4 inline-block mr-1"}),"Editor"]}),(0,a.jsxs)("button",{"data-testid":"mobile-tab-preview",onClick:()=>M("preview"),className:`flex-1 py-2 text-sm font-medium ${"preview"===E?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(tc,{className:"h-4 w-4 inline-block mr-1"}),"Preview"]})]}),(0,a.jsxs)("div",{ref:D,className:"flex flex-1 overflow-hidden",style:ex,children:[et?"editor"===E&&a.jsx("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("textarea",{ref:$,"data-testid":"markdown-editor-textarea",value:o,onChange:es,onKeyDown:eu,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}):a.jsx("div",{"data-testid":"markdown-editor-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showEditor?"":"hidden"}`,style:"split"===f?eh:{width:ee.showEditor?"100%":"0%"},children:a.jsx("textarea",{ref:$,"data-testid":"markdown-editor-textarea",value:o,onChange:es,onKeyDown:eu,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}),"split"===f&&ee.showEditor&&ee.showPreview&&!et&&a.jsx(N,{onResize:ec,onDoubleClick:ed,orientation:"horizontal",ariaValueNow:Math.round(100*K),minRatio:.1}),et?"preview"===E&&a.jsx("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:ey})}):a.jsx("div",{"data-testid":"markdown-preview-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showPreview?"":"hidden"}`,style:"split"===f?ef:{width:ee.showPreview?"100%":"0%"},children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:ey})})]}),a.jsx(th.Ix,{toasts:_,onClose:P})]});return U&&G&&A?(0,e1.createPortal)(eb,A):eb}let tA=[".md"],tR=[{extension:".png",maxFileSize:5242880,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:5242880,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:5242880,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:15728640,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:5242880,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:5242880,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:5242880,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]}],t_=tR.map(e=>e.extension);var tO=r(73002);function tP({value:e,saveFn:t,debounceMs:r=300,disabled:a=!1,maxRetries:s=3,onSaveComplete:n}){let[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(null),u=(0,l.useRef)(e),m=(0,l.useRef)(t),p=(0,l.useRef)(n),h=(0,l.useRef)(null),f=(0,l.useRef)(!0);(0,l.useRef)(e);let x=(0,l.useCallback)(async e=>{if(!f.current)return;o(!0),d(null);let t=null,r=0;for(;r<=s;)try{await m.current(e),f.current&&(o(!1),d(null),p.current?.());return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++r<=s){let e=1e3*Math.pow(2,r-1);await new Promise(t=>setTimeout(t,e))}}f.current&&(o(!1),d(t))},[s]),g=(0,l.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);return{isSaving:i,error:c,saveNow:(0,l.useCallback)(async()=>{a||(g(),await x(u.current))},[a,g,x])}}let t$=(0,l.memo)(function({memo:e,onUpdate:t,onDelete:r,isSaving:s,error:n,className:i=""}){let[o,c]=(0,l.useState)(e.title),[d,u]=(0,l.useState)(e.content),[m,p]=(0,l.useState)(!1),h=(0,l.useRef)();(0,l.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let{isSaving:f,error:x,saveNow:g}=tP({value:o,saveFn:async r=>{await t(e.id,{title:r})}}),{isSaving:y,error:b,saveNow:v}=tP({value:d,saveFn:async r=>{await t(e.id,{content:r})}}),w=n??x?.message??b?.message??null,j=(0,l.useCallback)(e=>{c(e.target.value)},[]),N=(0,l.useCallback)(e=>{u(e.target.value)},[]),k=(0,l.useCallback)(()=>{g()},[g]),C=(0,l.useCallback)(()=>{v()},[v]),S=(0,l.useCallback)(()=>{r(e.id)},[e.id,r]),T=(0,l.useCallback)(async()=>{if(d.trim())try{await (0,q.v)(d),p(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>p(!1),2e3)}catch{}},[d]);return(0,a.jsxs)("div",{"data-testid":"memo-card",className:`bg-white border border-gray-200 rounded-lg p-4 space-y-3 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"text",value:o,onChange:j,onBlur:k,placeholder:"Memo title",className:"flex-1 text-sm font-medium text-gray-900 bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(s??(f||y))&&a.jsx("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),a.jsx("button",{type:"button",onClick:T,"aria-label":"Copy memo content",className:"p-1 text-gray-400 hover:text-gray-600 transition-colors rounded",children:m?a.jsx(eQ,{className:"w-4 h-4 text-green-600"}):a.jsx(I,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:S,"aria-label":"Delete memo",className:"p-1 text-gray-400 hover:text-red-500 transition-colors rounded",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),a.jsx("textarea",{value:d,onChange:N,onBlur:C,placeholder:"Enter memo content...",rows:4,className:"w-full text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),w&&a.jsx("div",{className:"text-xs text-red-500",children:w})]})}),tL=(0,l.memo)(function({currentCount:e,maxCount:t,onAdd:r,isLoading:s=!1,className:n=""}){let l=e>=t||s;return(0,a.jsxs)("div",{"data-testid":"memo-add-button",className:`flex flex-col items-center gap-2 ${n}`,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{l||r()},disabled:l,"aria-label":"Add Memo","aria-disabled":l,className:`
5
+ `.trim(),et="bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500";function er({promptData:e,answering:t,onRespond:r,onDismiss:s,labelId:n,cliToolName:i}){let o=(0,x.T)("prompt"),[c,d]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(!1),f=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===c)??null,[e,c]),g=f?.requiresTextInput===!0,b=t||p,y=(0,l.useCallback)(async e=>{if(!b){h(!0);try{await r(e)}catch(e){}finally{h(!1)}}},[b,r]),v=(0,l.useCallback)(async()=>{if(!b&&null!==c){h(!0);try{let e=g&&u.trim()?u.trim():c.toString();await r(e)}catch(e){}finally{h(!1)}}},[b,r,c,g,u]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("h3",{id:n,className:"text-lg font-semibold text-yellow-800 flex items-center gap-2",children:[a.jsx("span",{className:"text-xl","aria-hidden":"true",children:"?"}),i?o("confirmationFrom",{toolName:i}):o("confirmationFromClaude")]}),s&&a.jsx("button",{type:"button",onClick:s,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 transition-colors",children:a.jsx("svg",{className:"w-5 h-5 text-yellow-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.instructionText&&a.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 bg-gray-50 rounded p-2 border border-gray-200",children:e.instructionText}),a.jsx("p",{className:"text-gray-800 leading-relaxed",children:e.question}),b&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:o("sending")})]}),"yes_no"===e.type&&a.jsx(ea,{promptData:e,disabled:b,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===e.type&&a.jsx(es,{promptData:e,disabled:b,selectedOption:c,onSelectOption:d,textInputValue:u,onTextInputChange:m,showTextInput:g,onSubmit:v})]})}function ea({promptData:e,disabled:t,onYes:r,onNo:s}){let n=(0,x.T)("prompt"),l="yes"===e.defaultOption,i="no"===e.defaultOption,o=`${ee} ${et} ${l?"primary default highlighted":""}`,c=`${ee} ${i?"bg-gray-600 text-white hover:bg-gray-700 primary default highlighted":"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500"}`;return(0,a.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:o,children:n("yes")}),a.jsx("button",{type:"button",onClick:s,disabled:t,className:c,children:n("no")})]})}function es({promptData:e,disabled:t,selectedOption:r,onSelectOption:s,textInputValue:n,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,x.T)("prompt"),m=(0,l.useCallback)(e=>{let a=r===e,s=t?"opacity-50 cursor-not-allowed":"";return`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${a?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${s}`},[r,t]);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>(0,a.jsxs)("label",{className:m(e.number),children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:r===e.number,onChange:()=>s(e.number),disabled:t,className:"mt-1","aria-describedby":e.isDefault?`default-${e.number}`:void 0}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{id:`default-${e.number}`,className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:u("default")})]})]},e.number))})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:n,onChange:e=>i(e.target.value),disabled:t,placeholder:u("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${ee} ${et}`,children:u("submit")})]})}function en({promptData:e,messageId:t,visible:r,answering:s,onRespond:n,onDismiss:i,cliToolName:o}){let c;let{shouldRender:d,animationClass:u}=Q({visible:r&&null!==e,duration:200}),m=(0,l.useId)();if(!d||!e)return null;let p=(c="opacity-100","animate-fade-in"===u?c="opacity-100 transform translate-y-0":"animate-fade-out"===u&&(c="opacity-0 transform translate-y-2"),`bg-yellow-50 border-2 border-yellow-300 rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out ${u} ${c}`);return a.jsx(g,{componentName:"PromptPanel",children:a.jsx("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":m,"aria-modal":"true",className:p,children:a.jsx(er,{promptData:e,answering:s,onRespond:n,onDismiss:i,labelId:m,cliToolName:o})})})}var el=r(61421),ei=r(51223);let eo=(0,l.memo)(function({path:e,className:t="w-6 h-6"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),ec={back:"M15 19l-7-7 7-7",menu:"M4 6h16M4 12h16M4 18h16"};function ed({worktreeName:e,repositoryName:t,status:r,gitStatus:s,onBackClick:n,onMenuClick:i}){let o=(0,l.useMemo)(()=>el.xh[r],[r]);return a.jsx("header",{"data-testid":"mobile-header",role:"banner",className:"fixed top-0 inset-x-0 bg-white border-b border-gray-200 shadow-sm pt-safe z-40",children:(0,a.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[a.jsx("div",{className:"w-10 flex-shrink-0",children:n&&a.jsx("button",{type:"button",onClick:n,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(eo,{path:ec.back})})}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:["spinner"===o.type?a.jsx("span",{"data-testid":"status-indicator","aria-label":o.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 border-2 border-t-transparent animate-spin ${o.className}`}):a.jsx("span",{"data-testid":"status-indicator","aria-label":o.label,className:`w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 ${o.className}`}),(0,a.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[a.jsx("h1",{role:"heading","data-testid":"worktree-name",title:e,className:"text-sm font-medium text-gray-900 truncate text-center leading-tight",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:[t&&a.jsx("span",{className:"truncate max-w-[100px] text-center",children:t}),s&&"(unknown)"!==s.currentBranch&&(0,a.jsxs)(a.Fragment,{children:[t&&a.jsx("span",{className:"text-gray-300",children:"/"}),a.jsx("span",{className:"truncate max-w-[80px] font-mono",title:s.currentBranch,"data-testid":"mobile-branch-name",children:(0,ei.aS)(s.currentBranch,20)}),s.isDirty&&a.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),a.jsx("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&a.jsx("button",{type:"button",onClick:i,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 transition-colors",children:a.jsx(eo,{path:ec.menu})})})]})})}function eu({"data-testid":e,"aria-label":t,className:r=""}){return a.jsx("span",{"data-testid":e,className:`w-2 h-2 rounded-full bg-blue-500 ${r}`.trim(),"aria-label":t})}let em=(0,l.memo)(function({path:e,className:t="w-5 h-5"}){return a.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}),ep={terminal:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",files:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",memo:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},eh=[{id:"terminal",label:"Terminal",icon:a.jsx(em,{path:ep.terminal})},{id:"history",label:"History",icon:a.jsx(em,{path:ep.history})},{id:"files",label:"Files",icon:a.jsx(em,{path:ep.files})},{id:"memo",label:"CMATE",icon:a.jsx(em,{path:ep.memo})},{id:"info",label:"Info",icon:a.jsx(em,{path:ep.info})}];function ef({activeTab:e,onTabChange:t,hasNewOutput:r=!1,hasPrompt:s=!1,hasUpdate:n=!1}){let i=(0,l.useCallback)(t=>{let r=t===e;return`flex flex-col items-center justify-center flex-1 py-2 px-1 transition-colors relative ${r?"text-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]),o=(0,l.useMemo)(()=>(0,a.jsxs)(a.Fragment,{children:[r&&a.jsx("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-green-500 rounded-full","aria-label":"New output available"}),s&&a.jsx("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-yellow-500 rounded-full","aria-label":"Prompt waiting"})]}),[r,s]);return a.jsx("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":"Mobile navigation",className:"fixed bottom-0 inset-x-0 bg-white border-t border-gray-200 flex pb-safe z-40",children:eh.map(r=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===r.id,"aria-label":r.label,onClick:()=>t(r.id),className:i(r.id),children:[r.icon,a.jsx("span",{className:"text-xs mt-1",children:r.label}),"terminal"===r.id&&o,"info"===r.id&&n&&a.jsx(eu,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":"Update available"})]},r.id))})}let ex={base:"px-6 py-3 rounded-lg font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500",defaultSelected:"bg-gray-600 text-white hover:bg-gray-700"};function eg({promptData:e,visible:t,answering:r,onRespond:s,onDismiss:n,cliToolName:i}){let{shouldRender:o,animationClass:c}=Q({visible:t&&null!==e,duration:300}),d=(0,l.useId)(),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(0),f=(0,l.useRef)(null),x=(0,l.useCallback)(e=>{m(e.touches[0].clientY)},[]),b=(0,l.useCallback)(e=>{if(null===u)return;let t=e.touches[0].clientY-u;t>0&&h(t)},[u]),y=(0,l.useCallback)(()=>{p>100&&n&&n(),h(0),m(null)},[p,n]),v=(0,l.useCallback)(()=>{n&&n()},[n]),w=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!o||!e)return null;let j="animate-fade-out"===c,N=p>0?`translateY(${p}px)`:void 0;return(0,a.jsxs)(g,{componentName:"MobilePromptSheet",children:[a.jsx("div",{"data-testid":"prompt-overlay",onClick:v,className:`fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ${j?"opacity-0":"opacity-100"} ${j?"pointer-events-none":""}`,"aria-hidden":"true"}),(0,a.jsxs)("div",{ref:f,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":d,onClick:w,onTouchStart:x,onTouchMove:b,onTouchEnd:y,style:{transform:N},className:`fixed bottom-0 inset-x-0 bg-white rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ${j?"translate-y-full":"translate-y-0"}`,children:[a.jsx("div",{className:"flex justify-center pt-3 pb-2",children:a.jsx("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-gray-300 rounded-full","aria-hidden":"true"})}),a.jsx("div",{className:"px-4 pb-6",children:a.jsx(eb,{promptData:e,answering:r,onRespond:s,labelId:d,cliToolName:i})})]})]})}function eb({promptData:e,answering:t,onRespond:r,labelId:s,cliToolName:n}){let i=(0,x.T)("prompt"),[o,c]=(0,l.useState)(()=>{if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault);return t?.number??null}return null}),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(!1),h=(0,l.useMemo)(()=>"multiple_choice"!==e.type?null:e.options.find(e=>e.number===o)??null,[e,o]),f=h?.requiresTextInput===!0,g=t||m,b=(0,l.useCallback)(async e=>{if(!g){p(!0);try{await r(e)}catch{}finally{p(!1)}}},[g,r]),y=(0,l.useCallback)(async()=>{if(!g&&null!==o){p(!0);try{let e=f&&d.trim()?d.trim():o.toString();await r(e)}catch{}finally{p(!1)}}},[g,r,o,f,d]);return(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("h3",{id:s,className:"text-lg font-semibold text-gray-900",children:n?i("confirmationFrom",{toolName:n}):i("confirmationFromClaude")}),e.instructionText&&a.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 bg-gray-50 rounded p-2 border border-gray-200",children:e.instructionText}),a.jsx("p",{className:"text-gray-700 leading-relaxed",children:e.question}),g&&(0,a.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("span",{children:i("sending")})]}),"yes_no"===e.type&&a.jsx(ey,{promptData:e,disabled:g,onYes:()=>b("yes"),onNo:()=>b("no")}),"multiple_choice"===e.type&&a.jsx(ev,{promptData:e,disabled:g,selectedOption:o,onSelectOption:c,textInputValue:d,onTextInputChange:u,showTextInput:f,onSubmit:y})]})}let ey=(0,l.memo)(function({promptData:e,disabled:t,onYes:r,onNo:s}){let n=(0,x.T)("prompt"),l="yes"===e.defaultOption,i="no"===e.defaultOption;return(0,a.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":"Yes or No options",children:[a.jsx("button",{type:"button",onClick:r,disabled:t,className:`flex-1 ${ex.base} ${ex.primary} ${l?"ring-2 ring-blue-300":""}`,children:n("yes")}),a.jsx("button",{type:"button",onClick:s,disabled:t,className:`flex-1 ${ex.base} ${i?ex.defaultSelected:ex.secondary}`,children:n("no")})]})}),ev=(0,l.memo)(function({promptData:e,disabled:t,selectedOption:r,onSelectOption:s,textInputValue:n,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,x.T)("prompt");return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("fieldset",{children:[a.jsx("legend",{className:"sr-only",children:"Select an option"}),a.jsx("div",{className:"space-y-2",children:e.options.map(e=>{let n=r===e.number;return(0,a.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${n?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${t?"opacity-50 cursor-not-allowed":""}`,children:[a.jsx("input",{type:"radio",name:d,value:e.number,checked:n,onChange:()=>s(e.number),disabled:t,className:"mt-1"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&a.jsx("span",{className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:u("default")})]})]},e.number)})})]}),o&&(0,a.jsxs)("div",{className:"mt-3",children:[a.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),a.jsx("input",{id:`text-input-${d}`,type:"text",value:n,onChange:e=>i(e.target.value),disabled:t,placeholder:u("enterValuePlaceholder"),className:"w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),a.jsx("button",{type:"button",onClick:c,disabled:t||null===r,className:`w-full ${ex.base} ${ex.primary}`,children:u("submit")})]})});var ew=r(15470);let ej={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null},eN=(0,L.Z)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),ek=(0,L.Z)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),eC=(0,L.Z)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),eS=(0,L.Z)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),eT=(0,L.Z)("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]),eE=(0,L.Z)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var eM=r(22202);let eA=(0,l.memo)(function({isOpen:e,position:t,targetPath:r,targetType:s,onClose:n,onNewFile:o,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m,onMove:p}){let h=(0,l.useRef)(null),f=(0,l.useCallback)(e=>{e&&r&&e(r),n()},[r,n]),x=[{id:"new-file",label:"New File",icon:a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(o),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:a.jsx(eC,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:a.jsx(eS,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(d)},{id:"move",label:"Move",icon:a.jsx(eT,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{p&&r&&s&&p(r,s),n()},showDividerAfter:!0},{id:"delete",label:"Delete",icon:a.jsx(eE,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>f(u),variant:"danger"}].filter(e=>!e.showFor||s&&e.showFor.includes(s));return((0,l.useEffect)(()=>{if(!e)return;let t=e=>{if("Escape"===e.key){n();return}if("ArrowDown"===e.key||"ArrowUp"===e.key){let t;e.preventDefault();let r=h.current?.querySelectorAll('[role="menuitem"]');if(!r?.length)return;let a=Array.from(r).findIndex(e=>e===document.activeElement);t="ArrowDown"===e.key?a<r.length-1?a+1:0:a>0?a-1:r.length-1,r[t].focus()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n]),(0,l.useEffect)(()=>{if(e&&h.current){let e=h.current.querySelector('[role="menuitem"]');e&&e.focus()}},[e]),e)?a.jsx("div",{ref:h,"data-testid":"context-menu",role:"menu","aria-label":"File actions",className:"fixed min-w-[160px] py-1 bg-white rounded-lg shadow-lg border border-gray-200 animate-in fade-in-0 zoom-in-95 duration-100",style:{zIndex:eM.k.CONTEXT_MENU,left:`${t.x}px`,top:`${t.y}px`},children:x.map((e,t)=>(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("button",{role:"menuitem",onClick:e.onClick,disabled:!r,className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-gray-100 ${"danger"===e.variant?"text-red-600 hover:bg-red-50 focus:bg-red-50":"text-gray-700 hover:bg-gray-100"} ${r?"":"opacity-50 cursor-not-allowed"}`,children:[e.icon,a.jsx("span",{children:e.label})]}),e.showDividerAfter&&t<x.length-1&&a.jsx("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});var eR=r(352),e_=r(41593),eO=r(34643);let eP=(0,L.Z)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),e$=(0,l.memo)(function({expanded:e}){return a.jsx("svg",{"data-testid":"chevron-icon",className:`w-4 h-4 text-gray-500 transition-transform ${e?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),eL=(0,l.memo)(function({open:e}){return a.jsx("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e?a.jsx("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):a.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),eI=(0,l.memo)(function({text:e,query:t}){if(!t||!t.trim())return a.jsx(a.Fragment,{children:e});let r=(0,ei.hr)(t),s=e.split(RegExp(`(${r})`,"gi"));return a.jsx(a.Fragment,{children:s.map((e,r)=>e.toLowerCase()===t.toLowerCase()?a.jsx("mark",{className:"bg-yellow-200 text-gray-900 px-0.5 rounded",children:e},r):a.jsx("span",{children:e},r))})}),eD=(0,l.memo)(function({extension:e}){let t=(0,l.useMemo)(()=>e&&({ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-400",jsx:"text-yellow-400",json:"text-yellow-600",md:"text-gray-500",css:"text-pink-500",scss:"text-pink-500",html:"text-orange-500",py:"text-green-500"})[e]||"text-gray-400",[e]);return a.jsx("svg",{"data-testid":"file-icon",className:`w-5 h-5 ${t}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eF=(0,l.memo)(function e({item:t,path:r,depth:s,worktreeId:n,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f,dateFnsLocaleStr:x}){var g;let[b,y]=(0,l.useState)(!1),v=r?`${r}/${t.name}`:t.name,w=i.has(v),j="directory"===t.type,N=o.get(v),k=(0,l.useCallback)(async()=>{j?(w||N||(y(!0),await u(v),y(!1)),c(v)):d?.(v)},[j,w,N,v,u,c,d]),C=(0,l.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),k())},[k]),S=(0,l.useCallback)(e=>{e.preventDefault(),m?.(e,v,j?"directory":"file")},[v,j,m]),T=function({delay:e=500,moveThreshold:t=10,onLongPress:r}){let a=(0,l.useRef)(null),s=(0,l.useRef)(null),n=(0,l.useRef)(null),i=(0,l.useCallback)(()=>{a.current&&(clearTimeout(a.current),a.current=null),s.current=null,n.current=null},[]),o=(0,l.useCallback)(t=>{if(1!==t.touches.length)return;let l=t.touches[0];s.current={x:l.clientX,y:l.clientY},n.current=t,a.current=setTimeout(()=>{n.current&&r(n.current),i()},e)},[e,r,i]);return{onTouchStart:o,onTouchMove:(0,l.useCallback)(e=>{if(!s.current||1!==e.touches.length)return;let r=e.touches[0],a=r.clientX-s.current.x,n=r.clientY-s.current.y;Math.sqrt(a*a+n*n)>t&&i()},[t,i]),onTouchEnd:(0,l.useCallback)(()=>{i()},[i]),onTouchCancel:(0,l.useCallback)(()=>{i()},[i])}}({onLongPress:(0,l.useCallback)(e=>{m?.(e,v,j?"directory":"file")},[v,j,m])}),E={paddingLeft:`${.5+1*Math.min(s,20)}rem`,touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{"data-testid":`tree-item-${t.name}`,role:"treeitem","aria-selected":!1,"aria-expanded":j?w:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-gray-100 rounded transition-colors",style:E,onClick:k,onKeyDown:C,onContextMenu:S,onTouchStart:T.onTouchStart,onTouchMove:T.onTouchMove,onTouchEnd:T.onTouchEnd,onTouchCancel:T.onTouchCancel,children:[j?a.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:b?a.jsx("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx(e$,{expanded:w})}):a.jsx("span",{className:"w-4 h-4"}),j?a.jsx(eL,{open:w}):a.jsx(eD,{extension:t.extension}),a.jsx("span",{className:"flex-1 truncate text-sm text-gray-700",children:"name"===h&&p?a.jsx(eI,{text:t.name,query:p}):t.name}),a.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:j?void 0!==t.itemCount&&`${t.itemCount} items`:void 0===(g=t.size)?"":g<1024?`${g} B`:g<1048576?`${(g/1024).toFixed(1)} KB`:`${(g/1048576).toFixed(1)} MB`}),!j&&t.birthtime&&a.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",title:t.birthtime,children:function(e,t){let r=new Date(e);return isNaN(r.getTime())?"":(0,eR.Q)(r,{addSuffix:!0,...t?{locale:t}:{}})}(t.birthtime,x?(0,e_.G)(x):void 0)})]}),j&&w&&N&&a.jsx("div",{role:"group",children:N.filter(e=>{let t=v?`${v}/${e.name}`:e.name;if(!p?.trim())return!0;if("name"===h){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===h&&f&&f.size>0){if(f.has(t))return!0;if("directory"===e.type){for(let e of f)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>a.jsx(e,{item:t,path:v,depth:s+1,worktreeId:n,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:f,dateFnsLocaleStr:x},t.name))})]})}),ez=(0,l.memo)(function({worktreeId:e,onFileSelect:t,onNewFile:r,onNewDirectory:s,onRename:n,onDelete:i,onUpload:o,onMove:c,className:d="",refreshTrigger:u=0,searchQuery:m,searchMode:p,searchResults:h,onSearchResultSelect:f,onCmateSetup:x}){let g=(0,eO.bU)(),[b,y]=(0,l.useState)(!0),[v,w]=(0,l.useState)(null),[j,N]=(0,l.useState)([]),[k,C]=(0,l.useState)(new Set),[S,T]=(0,l.useState)(()=>new Map),E=(0,l.useRef)(k);E.current=k;let M=(0,l.useRef)(new Set),{menuState:A,openMenu:R,closeMenu:_}=function(){let[e,t]=(0,l.useState)(ej);return{menuState:e,openMenu:(0,l.useCallback)((e,r,a)=>{let s,n;if(e.preventDefault(),"touches"in e&&e.touches.length>0)s=e.touches[0].clientX,n=e.touches[0].clientY;else{if(!("clientX"in e))return;s=e.clientX,n=e.clientY}t({isOpen:!0,position:{x:s,y:n},targetPath:r,targetType:a})},[]),closeMenu:(0,l.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),resetMenu:(0,l.useCallback)(()=>{t(ej)},[])}}(),O=(0,l.useCallback)(async(t="")=>{try{let r=t?`/api/worktrees/${e}/tree/${t}`:`/api/worktrees/${e}/tree`,a=await fetch(r);if(!a.ok)throw Error(`Failed to load directory: ${a.status}`);return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[e]);(0,l.useEffect)(()=>{let e=!0;return(async()=>{y(!0),w(null);try{let t=await O();if(!e||!t)return;let r=Array.from(E.current),a=new Map,s=[];for(let t=0;t<r.length;t+=5){if(!e)return;let n=r.slice(t,t+5);for(let[e,t]of(await Promise.allSettled(n.map(async e=>{let t=await O(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?a.set(t.value.dirPath,t.value.data.items):s.push(n[e])}if(!e)return;N(t.items),T(a),s.length>0&&C(e=>{let t=new Set(e);for(let e of s)e&&t.delete(e);return t})}catch(t){e&&w(t instanceof Error?t.message:"Failed to load files")}finally{e&&y(!1)}})(),()=>{e=!1}},[O,u]);let P=(0,l.useCallback)(async e=>{if(!(S.has(e)||M.current.has(e))){M.current.add(e);try{let t=await O(e);t&&T(r=>{let a=new Map(r);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{M.current.delete(e)}}},[S,O]),$=(0,l.useCallback)(e=>{C(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),L=(0,l.useMemo)(()=>"content"===p&&h&&0!==h.length?(0,ei.Ps)(h.map(e=>e.filePath)):new Set,[p,h]);(0,l.useEffect)(()=>{L.size>0&&C(e=>{let t=new Set(e);for(let e of L)(S.has(e)||h?.some(t=>t.filePath.startsWith(e+"/")))&&t.add(e);return t})},[L,S,h]);let I=(0,l.useMemo)(()=>{if(!m?.trim())return j;if("name"===p){let e=m.toLowerCase(),t=(r,a)=>r.filter(r=>{let s=a?`${a}/${r.name}`:r.name,n=r.name.toLowerCase().includes(e);if("directory"===r.type){let e=S.get(s);if(e&&t(e,s).length>0)return!0}return n});return t(j,"")}return"content"===p&&L.size>0?j.filter(e=>{if(L.has(e.name))return!0;if("directory"===e.type){for(let t of L)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):j},[j,m,p,L,S]);return b?(0,a.jsxs)("div",{"data-testid":"file-tree-loading",className:`flex items-center justify-center p-4 ${d}`,children:[a.jsx("span",{className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Loading files..."})]}):v?a.jsx("div",{"data-testid":"file-tree-error",className:`p-4 bg-red-50 border border-red-200 rounded-lg ${d}`,children:a.jsx("p",{className:"text-sm text-red-600",children:v})}):0===j.length?(0,a.jsxs)("div",{"data-testid":"file-tree-empty",className:`p-4 text-center text-gray-500 ${d}`,children:[a.jsx("p",{className:"text-sm",children:"No files found"}),(r||s)&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[r&&(0,a.jsxs)("button",{"data-testid":"empty-new-file-button",onClick:()=>r(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New File"})]}),s&&(0,a.jsxs)("button",{"data-testid":"empty-new-directory-button",onClick:()=>s(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New Directory"})]})]})]}):m?.trim()&&0===I.length?a.jsx("div",{"data-testid":"file-tree-no-results",className:`p-4 text-center text-gray-500 ${d}`,children:(0,a.jsxs)("p",{className:"text-sm",children:["No ","content"===p?"files containing":"files matching",' "',m,'"']})}):(0,a.jsxs)("div",{"data-testid":"file-tree-view",role:"tree","aria-label":"File tree",className:`overflow-auto bg-white ${d}`,children:[(r||s||x)&&(0,a.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-gray-200 dark:border-gray-700",children:[r&&(0,a.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>r(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(eN,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New File"})]}),s&&(0,a.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>s(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(ek,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"New Directory"})]}),x&&(0,a.jsxs)("button",{"data-testid":"toolbar-cmate-button",onClick:x,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[a.jsx(eP,{className:"w-4 h-4","aria-hidden":"true"}),a.jsx("span",{children:"CMATE"})]})]}),I.map(r=>a.jsx(eF,{item:r,path:"",depth:0,worktreeId:e,expanded:k,cache:S,onToggle:$,onFileSelect:f||t,onLoadChildren:P,onContextMenu:R,searchQuery:m,searchMode:p,matchedPaths:L,dateFnsLocaleStr:g},r.name)),a.jsx(eA,{isOpen:A.isOpen,position:A.position,targetPath:A.targetPath,targetType:A.targetType,onClose:_,onNewFile:r,onNewDirectory:s,onRename:n,onDelete:i,onUpload:o,onMove:c})]})}),eH=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),eW=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),eB=(0,l.memo)(function(){return a.jsx("div",{"data-testid":"search-loading",className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin","aria-label":"Searching..."})}),eU=(0,l.memo)(function({query:e,mode:t,isSearching:r,error:s,onQueryChange:n,onModeChange:i,onClear:o,placeholder:c="Search files...",className:d=""}){let u=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{n(e.target.value)},[n]),p=(0,l.useCallback)(()=>{o(),u.current?.focus()},[o]),f=(0,l.useCallback)(t=>{"Escape"===t.key&&(e?p():u.current?.blur())},[e,p]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<h.G)){let e=setTimeout(()=>{u.current?.focus()},100);return()=>clearTimeout(e)}},[]),(0,a.jsxs)("div",{"data-testid":"search-bar",className:`flex flex-col gap-2 p-2 bg-white border-b border-gray-200 ${d}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsx(eH,{})}),a.jsx("input",{ref:u,type:"text","data-testid":"search-input",value:e,onChange:m,onKeyDown:f,placeholder:c,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-gray-50 border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search files","aria-busy":r}),a.jsx("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:r?a.jsx(eB,{}):e?a.jsx("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-gray-400 hover:text-gray-600 rounded transition-colors","aria-label":"Clear search",children:a.jsx(eW,{})}):null})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Mode:"}),a.jsx("button",{type:"button","data-testid":"mode-name",onClick:()=>i("name"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"name"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"name"===t,children:"Name"}),a.jsx("button",{type:"button","data-testid":"mode-content",onClick:()=>i("content"),className:`px-2 py-0.5 text-xs rounded transition-colors ${"content"===t?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"aria-pressed":"content"===t,children:"Content"})]}),s&&a.jsx("div",{"data-testid":"search-error",className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded",role:"alert",children:s})]})}),eG=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eV=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),eq=(0,l.memo)(function(){return a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eY=[{id:"history",label:"History",icon:a.jsx(eG,{})},{id:"files",label:"Files",icon:a.jsx(eV,{})},{id:"memo",label:"CMATE",icon:a.jsx(eq,{})}],eZ=(0,l.memo)(function({activeTab:e,onTabChange:t,className:r=""}){let s=(0,l.useCallback)(e=>{t(e)},[t]),n=(0,l.useCallback)((e,r)=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),t(e))},[t]),i=(0,l.useCallback)(t=>{let r=t===e;return`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset ${r?"bg-blue-50 text-blue-600 border-b-2 border-blue-600":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]);return a.jsx("div",{role:"tablist","aria-label":"Left pane view switcher",className:`flex border-b border-gray-200 bg-white ${r}`,children:eY.map(t=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":e===t.id,"aria-label":t.label,tabIndex:0,onClick:()=>s(t.id),onKeyDown:e=>n(t.id,e),className:i(t.id),children:[t.icon,a.jsx("span",{children:t.label})]},t.id))})});var eK=r(77758),eX=r(81194),eJ=r(89918);let eQ=(0,L.Z)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function e0({isOpen:e,onClose:t,worktreeId:r,filePath:s}){let[n,i]=(0,l.useState)(null),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),h=(0,l.useMemo)(()=>!!(n?.content&&!n.isImage&&!n.isVideo),[n]),f=(0,l.useCallback)(async()=>{if(h&&n?.content)try{await (0,q.v)(n.content),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[h,n]);return a.jsx(eK.u_,{isOpen:e,onClose:t,title:s,size:"xl",children:(0,a.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] overflow-y-auto",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"ml-3 text-gray-600",children:"Loading file..."})]}),d&&a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-sm text-red-800",children:d})]})}),n&&!o&&!d&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg overflow-hidden",children:[(0,a.jsxs)("div",{className:"bg-gray-100 px-4 py-2 border-b border-gray-200 flex items-center justify-between",children:[(0,a.jsxs)("p",{className:"text-xs text-gray-600 font-mono truncate",children:[n.worktreePath,"/",n.path]}),h&&a.jsx("button",{"data-testid":"copy-content-button",onClick:f,className:"flex-shrink-0 ml-2 p-1 rounded hover:bg-gray-200 transition-colors text-gray-500 hover:text-gray-700","aria-label":"Copy file content",children:m?a.jsx(eQ,{className:"w-4 h-4 text-green-600"}):a.jsx(I,{className:"w-4 h-4"})})]}),n.isImage?a.jsx(eX.O,{src:n.content,alt:n.path,mimeType:n.mimeType}):n.isVideo?a.jsx(eJ.R,{src:n.content,mimeType:n.mimeType}):a.jsx("div",{className:"p-4",children:a.jsx("pre",{className:"text-sm overflow-x-auto",children:a.jsx("code",{className:`language-${n.extension}`,children:n.content})})})]})]})})}var e1=r(60962),e2=r(83173),e4=r(26394),e5=r(43286),e3=r(72339);let e6=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],e8={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...e6,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...e6],h2:[["className","sr-only"]],img:[...e6,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...e6,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...e6],table:[...e6],ul:[...e6,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},e7={}.hasOwnProperty;function e9(e,t){if(t&&"object"==typeof t)switch("string"==typeof t.type?t.type:""){case"comment":return function(e,t){if(e.schema.allowComments){let e="string"==typeof t.value?t.value:"",r=e.indexOf("-->"),a={type:"comment",value:r<0?e:e.slice(0,r)};return ta(a,t),a}}(e,t);case"doctype":return function(e,t){if(e.schema.allowDoctypes){let e={type:"doctype"};return ta(e,t),e}}(e,t);case"element":return function(e,t){let r="string"==typeof t.tagName?t.tagName:"";e.stack.push(r);let a=te(e,t.children),s=function(e,t){let r;let a=e.stack[e.stack.length-1],s=e.schema.attributes,n=e.schema.required,l=s&&e7.call(s,a)?s[a]:void 0,i=s&&e7.call(s,"*")?s["*"]:void 0,o=t&&"object"==typeof t?t:{},c={};for(r in o)if(e7.call(o,r)){let t=o[r],a=tt(e,ts(l,r),r,t);null==a&&(a=tt(e,ts(i,r),r,t)),null!=a&&(c[r]=a)}if(n&&e7.call(n,a)){let e=n[a];for(r in e)e7.call(e,r)&&!e7.call(c,r)&&(c[r]=e[r])}return c}(e,t.properties);e.stack.pop();let n=!1;if(r&&"*"!==r&&(!e.schema.tagNames||e.schema.tagNames.includes(r))&&(n=!0,e.schema.ancestors&&e7.call(e.schema.ancestors,r))){let t=e.schema.ancestors[r],a=-1;for(n=!1;++a<t.length;)e.stack.includes(t[a])&&(n=!0)}if(!n)return e.schema.strip&&!e.schema.strip.includes(r)?a:void 0;let l={type:"element",tagName:r,properties:s,children:a};return ta(l,t),l}(e,t);case"root":return function(e,t){let r={type:"root",children:te(e,t.children)};return ta(r,t),r}(e,t);case"text":return function(e,t){let r={type:"text",value:"string"==typeof t.value?t.value:""};return ta(r,t),r}(0,t)}}function te(e,t){let r=[];if(Array.isArray(t)){let a=-1;for(;++a<t.length;){let s=e9(e,t[a]);s&&(Array.isArray(s)?r.push(...s):r.push(s))}}return r}function tt(e,t,r,a){return t?Array.isArray(a)?function(e,t,r,a){let s=-1,n=[];for(;++s<a.length;){let l=tr(e,t,r,a[s]);("number"==typeof l||"string"==typeof l)&&n.push(l)}return n}(e,t,r,a):tr(e,t,r,a):void 0}function tr(e,t,r,a){if(("boolean"==typeof a||"number"==typeof a||"string"==typeof a)&&function(e,t,r){let a=e.schema.protocols&&e7.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!a||0===a.length)return!0;let s=String(r),n=s.indexOf(":"),l=s.indexOf("?"),i=s.indexOf("#"),o=s.indexOf("/");if(n<0||o>-1&&n>o||l>-1&&n>l||i>-1&&n>i)return!0;let c=-1;for(;++c<a.length;){let e=a[c];if(n===e.length&&s.slice(0,e.length)===e)return!0}return!1}(e,r,a)){if("object"==typeof t&&t.length>1){let e=!1,r=0;for(;++r<t.length;){let s=t[r];if(s&&"object"==typeof s&&"flags"in s){if(s.test(String(a))){e=!0;break}}else if(s===a){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(r)?e.schema.clobberPrefix+a:a}}function ta(e,t){let r=(0,e3.FK)(t);t.data&&(e.data=(0,e5.ZP)(t.data)),r&&(e.position=r)}function ts(e,t){let r;let a=-1;if(e)for(;++a<e.length;){let s=e[a],n="string"==typeof s?s:s[0];if(n===t)return s;"data*"===n&&(r=s)}if(t.length>4&&"data"===t.slice(0,4).toLowerCase())return r}function tn(e){return function(t){return function(e,t){let r={type:"root",children:[]},a=e9({schema:t?{...e8,...t}:e8,stack:[]},e);return a&&(Array.isArray(a)?1===a.length?r=a[0]:r.children=a:r=a),r}(t,e)}}var tl=r(42283);r(4803);let ti=(0,L.Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),to=(0,L.Z)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),tc=(0,L.Z)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),td=(0,L.Z)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),tu=(0,L.Z)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),tm=(0,L.Z)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var tp=r(94019),th=r(11865),tf=r(43353),tx=r.n(tf);let tg=(0,L.Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),tb=tx()(async()=>{},{loadableGenerated:{modules:["components/worktree/MermaidCodeBlock.tsx -> ./MermaidDiagram"]},ssr:!1,loading:()=>(0,a.jsxs)("div",{className:"mermaid-loading flex items-center gap-2 text-gray-500 p-4",children:[a.jsx(tg,{className:"animate-spin h-4 w-4"}),a.jsx("span",{children:"Loading diagram..."})]})});function ty({className:e,children:t,inline:r}){if(r)return a.jsx("code",{className:e,children:t});if(e&&e.split(" ").includes("language-mermaid")){let e=null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e=>"string"==typeof e?e:"").join(""):String(t);return a.jsx(tb,{code:e})}return a.jsx("code",{className:e,children:t})}function tv(){return"undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}async function tw(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen)return e.webkitRequestFullscreen();if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();throw Error("Fullscreen API not supported")}async function tj(){if("undefined"!=typeof document){if(document.exitFullscreen)return document.exitFullscreen();if(document.webkitExitFullscreen)return document.webkitExitFullscreen();if(document.mozCancelFullScreen)return document.mozCancelFullScreen();if(document.msExitFullscreen)return document.msExitFullscreen()}}function tN(e){let{key:t,defaultValue:r,validate:a,serialize:s=JSON.stringify,deserialize:n=JSON.parse}=e,i=(0,l.useRef)(r),o=(0,l.useRef)(a),c=(0,l.useRef)(s),d=(0,l.useRef)(n);i.current=r,o.current=a,c.current=s,d.current=n;let[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(r);(0,l.useCallback)(()=>i.current,[t]);let f=(0,l.useCallback)(e=>{},[t]);return{value:p,setValue:(0,l.useCallback)(e=>{h(t=>{let r="function"==typeof e?e(t):e;return f(r),r})},[f]),removeValue:(0,l.useCallback)(()=>{h(i.current)},[t]),isAvailable:u}}let tk=()=>!1,tC={split:{showEditor:!0,showPreview:!0,editorWidth:"w-1/2",previewWidth:"w-1/2"},editor:{showEditor:!0,showPreview:!1,editorWidth:"w-full",previewWidth:"w-0"},preview:{showEditor:!1,showPreview:!0,editorWidth:"w-0",previewWidth:"w-full"}},tS={WARNING_THRESHOLD:512e3};function tT(e){return"number"==typeof e&&e>=.1&&e<=.9}function tE(e){return"boolean"==typeof e}function tM({worktreeId:e,filePath:t,onClose:r,onSave:s,initialViewMode:n,onMaximizedChange:i}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(""),[f,x]=(0,l.useState)(()=>n&&("split"===n||"editor"===n||"preview"===n)?n:"split"),[g,b]=(0,l.useState)(!0),[y,v]=(0,l.useState)(!1),[w,j]=(0,l.useState)(null),[k,C]=(0,l.useState)(!1),[S,T]=(0,l.useState)(!1),[E,M]=(0,l.useState)("editor"),[A,R]=(0,l.useState)(null),{toasts:_,showToast:O,removeToast:P}=(0,th.pm)(),$=(0,l.useRef)(null);(0,l.useRef)(null);let L=(0,l.useRef)(null),D=(0,l.useRef)(null),F=(0,h.d)(),{isKeyboardVisible:z,keyboardHeight:H}=function(){let[e,t]=(0,l.useState)(!1),[r,a]=(0,l.useState)(0);return(0,l.useCallback)(()=>{if(!tk())return;let e=window.visualViewport,r=window.innerHeight-e.height,s=r>100;t(s),a(s?r:0)},[]),{isKeyboardVisible:e,keyboardHeight:r}}(),{value:W,setValue:B}=tN({key:"commandmate:md-editor-maximized",defaultValue:!1,validate:tE}),{isFullscreen:U,isFallbackMode:G,enterFullscreen:V,exitFullscreen:Y,toggleFullscreen:Z}=function(e={}){let{elementRef:t,onEnter:r,onExit:a,onError:s}=e,[n,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null);(0,l.useCallback)(()=>{let e=null!=tv();i(e),!e&&o&&c(!1)},[o]);let m=(0,l.useCallback)(async()=>{if(u(null),"undefined"!=typeof navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)){i(!0),c(!0),r?.();return}if("undefined"!=typeof document&&(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&t?.current)try{await tw(t.current),i(!0),c(!1),r?.()}catch(t){let e=t instanceof Error?t.message:"Failed to enter fullscreen";u(e),s?.(t instanceof Error?t:Error(e)),i(!0),c(!0),r?.()}else i(!0),c(!0),r?.()},[t,r,s]),p=(0,l.useCallback)(async()=>{if(u(null),o){i(!1),c(!1),a?.();return}if(tv())try{await tj(),i(!1),a?.()}catch(t){let e=t instanceof Error?t.message:"Failed to exit fullscreen";u(e),s?.(t instanceof Error?t:Error(e)),i(!1),c(!1),a?.()}else i(!1),c(!1),a?.()},[o,a,s]),h=(0,l.useCallback)(async()=>{n?await p():await m()},[n,m,p]);return{isFullscreen:n,isFallbackMode:o,enterFullscreen:m,exitFullscreen:p,toggleFullscreen:h,error:d}}({elementRef:L,onEnter:()=>B(!0),onExit:()=>B(!1)}),{value:K,setValue:X}=tN({key:"commandmate:md-editor-split-ratio",defaultValue:.5,validate:tT}),{ref:J}=function(e={}){let{onSwipeLeft:t,onSwipeRight:r,onSwipeUp:a,onSwipeDown:s,threshold:n=50,enabled:i=!0}=e,o=(0,l.useRef)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),p=(0,l.useRef)(null),h=(0,l.useCallback)(()=>{m(null)},[]);return(0,l.useCallback)(e=>{if(!i)return;if(e.target instanceof HTMLElement&&function(e){let t=e;for(;t;){let{overflowY:e}=getComputedStyle(t);if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return!0;t=t.parentElement}return!1}(e.target)){p.current=null;return}let t=e.touches[0];p.current={x:t.clientX,y:t.clientY},d(!0)},[i]),(0,l.useCallback)(e=>{if(!i||!p.current)return;let t=e.touches[0],r=t.clientX-p.current.x,a=t.clientY-p.current.y,s=Math.abs(r),l=Math.abs(a);s>l&&s>=n?m(r<0?"left":"right"):l>=n&&m(a<0?"up":"down")},[i,n]),(0,l.useCallback)(e=>{if(!i||!p.current){d(!1);return}let l=e.changedTouches[0],o=l.clientX-p.current.x,c=l.clientY-p.current.y,u=Math.abs(o),h=Math.abs(c);u>h?u>=n&&(o<0?(m("left"),t?.()):(m("right"),r?.())):h>=n&&(c<0?(m("up"),a?.()):(m("down"),s?.())),p.current=null,d(!1)},[i,n,t,r,a,s]),{ref:o,isSwiping:c,swipeDirection:u,resetSwipeDirection:h}}({onSwipeDown:()=>{U&&Y()},threshold:150,enabled:U&&F}),Q=o!==d,ee=tC[f],et=F&&!1,er=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{p(e)},300),[]);(0,l.useCallback)(async()=>{b(!0),j(null);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to load file");let s=a.content||"";c(s),u(s),p(s),new Blob([s]).size>tS.WARNING_THRESHOLD&&C(!0)}catch(e){j(e instanceof Error?e.message:"Failed to load file")}finally{b(!1)}},[e,t]);let ea=(0,l.useCallback)(async()=>{if(Q&&!y){v(!0);try{let r=await fetch(`/api/worktrees/${e}/files/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o})}),a=await r.json();if(!r.ok||!a.success)throw Error(a.error?.message||"Failed to save file");u(o),O("File saved successfully","success"),s&&s(t)}catch(e){O(e instanceof Error?e.message:"Failed to save file","error")}finally{v(!1)}}},[e,t,o,Q,y,s,O]),es=(0,l.useCallback)(e=>{let t=e.target.value;c(t),er(t)},[er]),en=(0,l.useCallback)(e=>{x(e)},[]),el=(0,l.useCallback)(()=>{(!Q||window.confirm("You have unsaved changes. Are you sure you want to close?"))&&r&&r()},[Q,r]),eo=(0,l.useCallback)(async()=>{try{await (0,q.v)(o),T(!0),setTimeout(()=>T(!1),2e3)}catch{}},[o]),ec=(0,l.useCallback)(e=>{if(!D.current)return;let t=D.current.offsetWidth;if(0===t)return;let r=e/t;X(e=>Math.max(.1,Math.min(.9,e+r)))},[X]),ed=(0,l.useCallback)(()=>{X(.5)},[X]),eu=(0,l.useCallback)(e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),ea();return}if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F"===e.key){e.preventDefault(),Z();return}if("Escape"===e.key&&U){e.preventDefault(),Y();return}},[ea,Z,Y,U]),em=(0,l.useMemo)(()=>{let e="flex flex-col bg-white";return U&&G?`${e} fixed inset-0`:`${e} h-full`},[U,G]),ep=(0,l.useMemo)(()=>{if(U)return{zIndex:eM.k.MAXIMIZED_EDITOR}},[U]),eh=(0,l.useMemo)(()=>{if("split"===f&&!et)return{width:`${100*K}%`,flexShrink:0}},[f,K,et]),ef=(0,l.useMemo)(()=>{if("split"===f&&!et)return{width:`${(1-K)*100}%`,flexShrink:0}},[f,K,et]),ex=(0,l.useMemo)(()=>{if(z&&H>0)return{paddingBottom:H}},[z,H]),eg=(0,l.useMemo)(()=>({code:ty}),[]),eb=(0,l.useMemo)(()=>a.jsx(e2.UG,{remarkPlugins:[e4.Z],rehypePlugins:[tn,tl.Z],components:eg,children:m}),[m,eg]);if(g)return a.jsx("div",{"data-testid":"markdown-editor",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"mt-4 text-gray-600",children:"Loading..."})]})});if(w)return a.jsx("div",{"data-testid":"markdown-editor-error",className:"flex items-center justify-center h-full bg-white",children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx(ti,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),a.jsx("p",{className:"text-red-600",children:w}),r&&a.jsx("button",{onClick:r,className:"mt-4 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg",children:"Close"})]})});let ey=(0,a.jsxs)("div",{ref:e=>{L.current=e,J.current=e},"data-testid":"markdown-editor",className:em,style:ep,onKeyDown:eu,role:U&&G?"dialog":void 0,"aria-modal":U&&G?"true":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 bg-gray-50",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-shrink",children:[a.jsx(eP,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:t}),Q&&a.jsx("span",{"data-testid":"dirty-indicator",className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 flex-shrink-0",children:"Unsaved"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!et&&(0,a.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[a.jsx("button",{"data-testid":"view-mode-split","aria-pressed":"split"===f,onClick:()=>en("split"),className:`p-1.5 rounded ${"split"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Split view",children:a.jsx(to,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-editor","aria-pressed":"editor"===f,onClick:()=>en("editor"),className:`p-1.5 rounded ${"editor"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Editor only",children:a.jsx(eP,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"view-mode-preview","aria-pressed":"preview"===f,onClick:()=>en("preview"),className:`p-1.5 rounded ${"preview"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Preview only",children:a.jsx(tc,{className:"h-4 w-4"})})]}),a.jsx("button",{"data-testid":"copy-content-button",onClick:eo,className:`p-1.5 hover:bg-gray-100 rounded ${S?"text-green-500":"text-gray-500 hover:text-gray-700"}`,title:"Copy content",children:S?a.jsx(eQ,{className:"h-4 w-4"}):a.jsx(I,{className:"h-4 w-4"})}),a.jsx("button",{"data-testid":"maximize-button",onClick:Z,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:U?"Exit fullscreen (ESC)":"Enter fullscreen (Ctrl+Shift+F)","aria-pressed":U,children:U?a.jsx(td,{className:"h-4 w-4"}):a.jsx(tu,{className:"h-4 w-4"})}),(0,a.jsxs)("button",{"data-testid":"save-button",onClick:ea,disabled:!Q||y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${Q&&!y?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[a.jsx(tm,{className:"h-4 w-4"}),y?"Saving...":"Save"]}),r&&a.jsx("button",{"data-testid":"close-button",onClick:el,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:"Close",children:a.jsx(tp.Z,{className:"h-4 w-4"})})]})]}),U&&(0,a.jsxs)("div",{"data-testid":"maximize-hint",className:"flex items-center justify-center px-4 py-1 bg-gray-800 text-gray-300 text-xs",children:["Press ESC to exit fullscreen ",F&&"(or swipe down)"]}),k&&(0,a.jsxs)("div",{"data-testid":"large-file-warning",className:"flex items-center gap-2 px-4 py-2 bg-yellow-50 border-b border-yellow-200 text-yellow-800 text-sm",children:[a.jsx(ti,{className:"h-4 w-4"}),"Large file: Performance may be affected.",a.jsx("button",{onClick:()=>C(!1),className:"ml-auto text-yellow-600 hover:text-yellow-800",children:a.jsx(tp.Z,{className:"h-4 w-4"})})]}),et&&(0,a.jsxs)("div",{className:"flex border-b border-gray-200",children:[(0,a.jsxs)("button",{"data-testid":"mobile-tab-editor",onClick:()=>M("editor"),className:`flex-1 py-2 text-sm font-medium ${"editor"===E?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(eP,{className:"h-4 w-4 inline-block mr-1"}),"Editor"]}),(0,a.jsxs)("button",{"data-testid":"mobile-tab-preview",onClick:()=>M("preview"),className:`flex-1 py-2 text-sm font-medium ${"preview"===E?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"}`,children:[a.jsx(tc,{className:"h-4 w-4 inline-block mr-1"}),"Preview"]})]}),(0,a.jsxs)("div",{ref:D,className:"flex flex-1 overflow-hidden",style:ex,children:[et?"editor"===E&&a.jsx("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("textarea",{ref:$,"data-testid":"markdown-editor-textarea",value:o,onChange:es,onKeyDown:eu,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}):a.jsx("div",{"data-testid":"markdown-editor-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showEditor?"":"hidden"}`,style:"split"===f?eh:{width:ee.showEditor?"100%":"0%"},children:a.jsx("textarea",{ref:$,"data-testid":"markdown-editor-textarea",value:o,onChange:es,onKeyDown:eu,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}),"split"===f&&ee.showEditor&&ee.showPreview&&!et&&a.jsx(N,{onResize:ec,onDoubleClick:ed,orientation:"horizontal",ariaValueNow:Math.round(100*K),minRatio:.1}),et?"preview"===E&&a.jsx("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden w-full",children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:eb})}):a.jsx("div",{"data-testid":"markdown-preview-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showPreview?"":"hidden"}`,style:"split"===f?ef:{width:ee.showPreview?"100%":"0%"},children:a.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:eb})})]}),a.jsx(th.Ix,{toasts:_,onClose:P})]});return U&&G&&A?(0,e1.createPortal)(ey,A):ey}let tA=[".md"],tR=[{extension:".png",maxFileSize:5242880,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:5242880,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:5242880,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:15728640,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:5242880,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:5242880,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:5242880,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]}],t_=tR.map(e=>e.extension);var tO=r(73002);function tP({value:e,saveFn:t,debounceMs:r=300,disabled:a=!1,maxRetries:s=3,onSaveComplete:n}){let[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(null),u=(0,l.useRef)(e),m=(0,l.useRef)(t),p=(0,l.useRef)(n),h=(0,l.useRef)(null),f=(0,l.useRef)(!0);(0,l.useRef)(e);let x=(0,l.useCallback)(async e=>{if(!f.current)return;o(!0),d(null);let t=null,r=0;for(;r<=s;)try{await m.current(e),f.current&&(o(!1),d(null),p.current?.());return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++r<=s){let e=1e3*Math.pow(2,r-1);await new Promise(t=>setTimeout(t,e))}}f.current&&(o(!1),d(t))},[s]),g=(0,l.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);return{isSaving:i,error:c,saveNow:(0,l.useCallback)(async()=>{a||(g(),await x(u.current))},[a,g,x])}}let t$=(0,l.memo)(function({memo:e,onUpdate:t,onDelete:r,isSaving:s,error:n,className:i=""}){let[o,c]=(0,l.useState)(e.title),[d,u]=(0,l.useState)(e.content),[m,p]=(0,l.useState)(!1),h=(0,l.useRef)();(0,l.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let{isSaving:f,error:x,saveNow:g}=tP({value:o,saveFn:async r=>{await t(e.id,{title:r})}}),{isSaving:b,error:y,saveNow:v}=tP({value:d,saveFn:async r=>{await t(e.id,{content:r})}}),w=n??x?.message??y?.message??null,j=(0,l.useCallback)(e=>{c(e.target.value)},[]),N=(0,l.useCallback)(e=>{u(e.target.value)},[]),k=(0,l.useCallback)(()=>{g()},[g]),C=(0,l.useCallback)(()=>{v()},[v]),S=(0,l.useCallback)(()=>{r(e.id)},[e.id,r]),T=(0,l.useCallback)(async()=>{if(d.trim())try{await (0,q.v)(d),p(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>p(!1),2e3)}catch{}},[d]);return(0,a.jsxs)("div",{"data-testid":"memo-card",className:`bg-white border border-gray-200 rounded-lg p-4 space-y-3 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"text",value:o,onChange:j,onBlur:k,placeholder:"Memo title",className:"flex-1 text-sm font-medium text-gray-900 bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(s??(f||b))&&a.jsx("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),a.jsx("button",{type:"button",onClick:T,"aria-label":"Copy memo content",className:"p-1 text-gray-400 hover:text-gray-600 transition-colors rounded",children:m?a.jsx(eQ,{className:"w-4 h-4 text-green-600"}):a.jsx(I,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:S,"aria-label":"Delete memo",className:"p-1 text-gray-400 hover:text-red-500 transition-colors rounded",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),a.jsx("textarea",{value:d,onChange:N,onBlur:C,placeholder:"Enter memo content...",rows:4,className:"w-full text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),w&&a.jsx("div",{className:"text-xs text-red-500",children:w})]})}),tL=(0,l.memo)(function({currentCount:e,maxCount:t,onAdd:r,isLoading:s=!1,className:n=""}){let l=e>=t||s;return(0,a.jsxs)("div",{"data-testid":"memo-add-button",className:`flex flex-col items-center gap-2 ${n}`,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{l||r()},disabled:l,"aria-label":"Add Memo","aria-disabled":l,className:`
6
6
  flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed
7
7
  transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500
8
8
  ${l?"border-gray-200 text-gray-400 cursor-not-allowed opacity-50":"border-gray-300 text-gray-600 hover:border-blue-400 hover:text-blue-600 hover:bg-blue-50"}
9
- `,children:[s?a.jsx("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),a.jsx("span",{className:"text-sm font-medium",children:"Add Memo"})]}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[Math.max(0,t-e)," remaining"]})]})}),tI=(0,l.memo)(function({worktreeId:e,className:t=""}){let[r,s]=(0,l.useState)([]),[n,i]=(0,l.useState)(!0),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(null),h=(0,l.useCallback)(async()=>{i(!0),u(null);try{let t=await tO.nE.getAll(e);s(t.sort((e,t)=>e.position-t.position))}catch(e){u((0,tO.zG)(e))}finally{i(!1)}},[e]);(0,l.useEffect)(()=>{h()},[h]);let f=(0,l.useCallback)(async()=>{c(!0),p(null);try{let t=await tO.nE.create(e,{title:"Memo",content:""});s(e=>[...e,t])}catch(e){p((0,tO.zG)(e))}finally{c(!1)}},[e]),x=(0,l.useCallback)(async(t,r)=>{await tO.nE.update(e,t,r),s(e=>e.map(e=>e.id===t?{...e,...r}:e))},[e]),g=(0,l.useCallback)(async t=>{try{await tO.nE.delete(e,t),s(e=>e.filter(e=>e.id!==t))}catch(e){console.error("Failed to delete memo:",e)}},[e]),y=(0,l.useCallback)(()=>{h()},[h]);return n?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"text-sm text-gray-500",children:"Loading memos..."})]})}):d?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[a.jsx("svg",{className:"w-12 h-12 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm text-red-600",children:d}),a.jsx("button",{type:"button",onClick:y,"aria-label":"Retry",className:"px-4 py-2 text-sm font-medium text-white bg-blue-500 rounded-lg hover:bg-blue-600 transition-colors",children:"Retry"})]})}):(0,a.jsxs)("div",{"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[0===r.length&&!m&&(0,a.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[a.jsx("p",{children:"No memos yet."}),a.jsx("p",{className:"text-sm",children:"Click the button below to add one."})]}),r.map(e=>a.jsx(t$,{memo:e,onUpdate:x,onDelete:g},e.id)),m&&a.jsx("div",{className:"text-center py-2 text-sm text-red-500",children:m}),a.jsx(tL,{currentCount:r.length,maxCount:5,onAdd:f,isLoading:o,className:"mt-2"})]})});function tD(e){return new Date(e).toLocaleString()}let tF=(0,l.memo)(function({worktreeId:e,className:t=""}){let r=(0,x.T)("schedule"),[s,n]=(0,l.useState)([]),[i,o]=(0,l.useState)([]),[c,d]=(0,l.useState)(!0),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(null),[f,g]=(0,l.useState)(null),y=(0,l.useCallback)(async()=>{d(!0),m(null);try{let[t,r]=await Promise.all([fetch(`/api/worktrees/${e}/execution-logs`),fetch(`/api/worktrees/${e}/schedules`)]);if(t.ok){let e=await t.json();n(e.logs||[])}if(r.ok){let e=await r.json();o(e.schedules||[])}}catch(e){m(e instanceof Error?e.message:"Failed to fetch data")}finally{d(!1)}},[e]);(0,l.useEffect)(()=>{y()},[y]);let b=(0,l.useCallback)(async t=>{if(p===t){h(null),g(null);return}try{let r=await fetch(`/api/worktrees/${e}/execution-logs/${t}`);if(r.ok){let e=await r.json();g(e.log),h(t)}}catch(e){console.error("Failed to fetch log detail:",e)}},[e,p]);return c?a.jsx("div",{className:`flex items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"text-sm text-gray-500",children:r("loading")})]})}):u?a.jsx("div",{className:`flex items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-red-600",children:u}),a.jsx("button",{type:"button",onClick:()=>void y(),className:"ml-2 px-3 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-600",children:r("retry")})]})}):(0,a.jsxs)("div",{className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:[r("title")," (",i.length,")"]}),0===i.length?(0,a.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[a.jsx("p",{className:"font-medium text-gray-600 mb-3",children:r("noSchedulesTitle")}),(0,a.jsxs)("ol",{className:"text-sm text-left inline-block space-y-1.5 list-decimal list-inside",children:[a.jsx("li",{children:r("noSchedulesStep1")}),a.jsx("li",{children:r("noSchedulesStep2")}),a.jsx("li",{children:r("noSchedulesStep3")}),a.jsx("li",{children:r("noSchedulesStep4")})]})]}):a.jsx("div",{className:"space-y-2",children:i.map(e=>(0,a.jsxs)("div",{className:"border border-gray-200 rounded p-3 bg-white",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-medium text-sm",children:e.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${e.enabled?"bg-green-50 text-green-600":"bg-gray-50 text-gray-500"}`,children:e.enabled?r("enabled"):r("disabled")})]}),(0,a.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[(0,a.jsxs)("span",{children:[r("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,a.jsxs)("span",{className:"ml-3",children:[r("lastRun"),": ",tD(e.last_executed_at)]})]})]},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:[r("executionLogs")," (",s.length,")"]}),0===s.length?a.jsx("p",{className:"text-sm text-gray-500",children:r("noLogs")}):a.jsx("div",{className:"space-y-2",children:s.map(e=>(0,a.jsxs)("div",{className:"border border-gray-200 rounded bg-white",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>void b(e.id),className:"w-full text-left p-3 hover:bg-gray-50 transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||r("unknownSchedule")}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${function(e){switch(e){case"completed":return"text-green-600 bg-green-50";case"failed":return"text-red-600 bg-red-50";case"timeout":return"text-yellow-600 bg-yellow-50";case"running":return"text-blue-600 bg-blue-50";case"cancelled":return"text-gray-600 bg-gray-50"}}(e.status)}`,children:r(`status.${e.status}`)})]}),(0,a.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[tD(e.started_at),null!==e.exit_code&&(0,a.jsxs)("span",{className:"ml-2",children:[r("exitCode"),": ",e.exit_code]})]})]}),p===e.id&&f&&(0,a.jsxs)("div",{className:"border-t border-gray-200 p-3 bg-gray-50 space-y-3",children:[(0,a.jsxs)("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:r("message")}),a.jsx("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700",children:f.message})]}),(0,a.jsxs)("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:r("response")}),a.jsx("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700 max-h-60 overflow-y-auto",children:f.result||r("noOutput")})]})]})]},e.id))})]})]})}),tz=(0,l.memo)(function({worktreeId:e,className:t=""}){let r=(0,x.T)("schedule"),[s,n]=(0,l.useState)("notes"),i=(0,l.useCallback)(e=>{n(e)},[]);return(0,a.jsxs)("div",{className:`flex flex-col h-full ${t}`,children:[(0,a.jsxs)("div",{className:"flex border-b border-gray-200 bg-white flex-shrink-0",children:[a.jsx("button",{type:"button",onClick:()=>i("notes"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${"notes"===s?"text-blue-600 border-b-2 border-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`,children:r("notes")}),a.jsx("button",{type:"button",onClick:()=>i("logs"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${"logs"===s?"text-blue-600 border-b-2 border-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`,children:r("logs")})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:"notes"===s?a.jsx(tI,{worktreeId:e,className:"h-full"}):a.jsx(tF,{worktreeId:e,className:"h-full"})})]})});var tH=r(11867);function tW(){let[e,t]=(0,l.useState)(null),[r,a]=(0,l.useState)(!0),[s,n]=(0,l.useState)(null);return{data:e,loading:r,error:s}}function tB({hasUpdate:e,latestVersion:t,releaseUrl:r,updateCommand:s,installType:n}){let l=(0,x.T)("worktree");return e?(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 mt-2",role:"status","aria-label":l("update.available"),"data-testid":"update-notification-banner",children:[a.jsx("p",{className:"text-sm font-medium text-blue-800 mb-1",children:l("update.available")}),t&&a.jsx("p",{className:"text-sm text-blue-700 mb-2",children:l("update.latestVersion",{version:t})}),s&&"global"===n&&(0,a.jsxs)("div",{className:"mb-2",children:[a.jsx("p",{className:"text-xs text-blue-600 mb-1",children:l("update.updateCommand")}),a.jsx("code",{className:"block bg-blue-100 rounded px-2 py-1 text-xs text-blue-900 font-mono",children:s})]}),r&&(0,a.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[l("update.viewRelease"),a.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),a.jsx("p",{className:"text-xs text-blue-500 mt-2",children:l("update.dataPreserved")})]}):null}function tU({version:e,className:t}){let r=(0,x.T)("worktree"),{data:s,loading:n}=tW(),i=(0,l.useMemo)(()=>s&&s.hasUpdate?{hasUpdate:s.hasUpdate,latestVersion:s.latestVersion,releaseUrl:s.releaseUrl,updateCommand:s.updateCommand,installType:s.installType}:null,[s]);return(0,a.jsxs)("div",{className:t,"data-testid":"version-section",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:r("update.version")}),a.jsx("p",{className:"text-sm text-gray-700",children:e}),n&&a.jsx("p",{className:"text-xs text-gray-400 mt-1","data-testid":"version-loading",children:"..."}),i&&a.jsx(tB,{...i})]})}let tG="https://github.com/Kewton/CommandMate",tV=`${tG}/issues`,tq=`${tG}/issues/new`,tY=`${tq}?template=bug_report.md`,tZ=`${tq}?template=feature_request.md`,tK=`${tq}?template=question.md`;function tX({className:e}){let t=(0,x.T)("worktree"),r=[{href:tY,label:t("feedback.bugReport")},{href:tZ,label:t("feedback.featureRequest")},{href:tK,label:t("feedback.question")},{href:tV,label:t("feedback.viewIssues")}];return(0,a.jsxs)("div",{className:e,"data-testid":"feedback-section",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-2",children:t("feedback.title")}),a.jsx("div",{className:"flex flex-col gap-1",children:r.map(({href:e,label:t})=>(0,a.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[t,a.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},e))})]})}var tJ=r(28676);r(63817);let tQ=[36e5,108e5,288e5],t0={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function t1({isOpen:e,onConfirm:t,onCancel:r,cliToolName:s}){let n=(0,x.T)("autoYes"),i=(0,x.T)("common"),[o,c]=(0,l.useState)(36e5),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(null),[h,f]=(0,l.useState)(!1),g=(0,l.useRef)(null),y=e=>n(t0[e].replace("autoYes.",""));return a.jsx(tJ.u,{isOpen:e,onClose:r,title:s?n("enableTitleWithTool",{toolName:s}):n("enableTitle"),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("featureDescription")}),(0,a.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[a.jsx("li",{children:n("yesNoAutoResponse")}),a.jsx("li",{children:n("multipleChoiceAutoSelect")})]}),a.jsx("p",{className:"mt-1",children:n("autoDisableAfter",{duration:y(o)})}),s&&a.jsx("p",{className:"mt-2 text-gray-500",children:n("appliesOnlyToCurrent",{toolName:s})})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("duration")}),a.jsx("div",{className:"flex gap-2",children:tQ.map(e=>a.jsx("button",{type:"button",onClick:()=>c(e),className:`flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ${o===e?"border-blue-600 bg-blue-50 text-blue-700":"border-gray-300 bg-white text-gray-700 hover:border-gray-400"}`,style:{minHeight:"44px"},children:y(e)},e))})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.jsx("label",{htmlFor:"stop-pattern-input",className:"font-medium",children:n("stopPatternLabel")}),(0,a.jsxs)("div",{className:"relative",ref:g,children:[a.jsx("button",{type:"button",onClick:()=>f(!h),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 text-gray-600 text-[10px] font-bold hover:bg-gray-400 focus:outline-none","aria-label":n("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),h&&(0,a.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-gray-200 bg-white p-3 shadow-lg text-xs text-gray-700","data-testid":"regex-tips-tooltip",children:[a.jsx("p",{className:"font-medium mb-1.5",children:n("regexTipsTitle")}),(0,a.jsxs)("ul",{className:"space-y-1",children:[(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"\\bcat\\b"})," ",n("regexTipWordBoundary")]}),(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"error|fatal"})," ",n("regexTipOr")]}),(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"(?i)error"})," ",n("regexTipCaseNote")]})]})]})]})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:n("stopPatternDescription")}),a.jsx("input",{id:"stop-pattern-input",type:"text",value:d,onChange:e=>u(e.target.value),placeholder:n("stopPatternPlaceholder"),className:`w-full px-3 py-2 border rounded-md text-sm font-mono ${m?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"} focus:outline-none focus:ring-1`,"data-testid":"stop-pattern-input"}),m&&a.jsx("p",{className:"mt-1 text-xs text-red-600","data-testid":"stop-pattern-error",children:m})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("aboutRisks")}),a.jsx("p",{children:n("riskWarning")})]}),a.jsx("div",{className:"bg-yellow-50 border-l-4 border-yellow-400 p-3",children:(0,a.jsxs)("p",{className:"text-sm text-yellow-800",children:[a.jsx("span",{className:"font-medium",children:n("disclaimer")}),n("disclaimerText")]})}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:i("cancel")}),a.jsx("button",{type:"button",onClick:()=>{t(o,d.trim()||void 0)},disabled:!!m,className:`px-4 py-2 text-sm font-medium rounded-md text-white ${m?"bg-gray-400 cursor-not-allowed":"bg-yellow-600 hover:bg-yellow-700"}`,"data-testid":"confirm-button",children:n("agreeAndEnable")})]})]})})}function t2(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}let t4=(0,l.memo)(function({enabled:e,expiresAt:t,onToggle:r,lastAutoResponse:s,cliToolName:n,inline:i=!1}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),[h,f]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!e||!t){c("");return}let r=()=>{c(function(e){let t=Math.max(0,e-Date.now()),r=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return r>0?`${r}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}(t))};r();let a=setInterval(r,1e3);return()=>clearInterval(a)},[e,t]),(0,l.useEffect)(()=>{if(!s)return;u(`Auto responded: "${s}"`);let e=setTimeout(()=>u(null),2e3);return()=>clearTimeout(e)},[s]);let x=(0,l.useCallback)(()=>{e?(p(!0),r({enabled:!1}).finally(()=>p(!1))):f(!0)},[e,r]),g=(0,l.useCallback)((e,t)=>{f(!1),p(!0),r({enabled:!0,duration:e,stopPattern:t}).finally(()=>p(!1))},[r]),y=(0,l.useCallback)(()=>{f(!1)},[]);return(0,a.jsxs)("div",{className:i?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-gray-50 border-b border-gray-200",children:[a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Yes mode",disabled:m,onClick:x,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${e?"bg-blue-600":"bg-gray-300"} ${m?"opacity-50":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Auto Yes"}),e&&n&&(0,a.jsxs)("span",{className:"text-xs text-blue-600 font-medium","aria-label":"Auto Yes target",children:["(",t2(n),")"]}),e&&o&&a.jsx("span",{className:"text-sm text-gray-500","aria-label":"Time remaining",children:o}),d&&a.jsx("span",{className:"text-sm text-green-600 animate-pulse",children:d}),a.jsx(t1,{isOpen:h,onConfirm:g,onCancel:y,cliToolName:t2(n)})]})}),t5=(0,l.memo)(function({isBranchMismatch:e,currentBranch:t,initialBranch:r}){let[s,n]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{n(!1)},[t]),!e||s||null===r)?null:(0,a.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-amber-50 border border-amber-200 text-amber-800 rounded-lg",children:[a.jsx(ti,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsx("div",{className:"flex-1 min-w-0",children:(0,a.jsxs)("span",{className:"text-sm",children:["Branch changed from"," ",a.jsx("span",{className:"font-medium",children:r})," ","to"," ",a.jsx("span",{className:"font-medium",children:t})]})}),a.jsx("button",{type:"button",onClick:()=>n(!0),className:"p-1 rounded hover:bg-amber-100 transition-colors","aria-label":"Dismiss alert",children:a.jsx(tp.Z,{className:"w-4 h-4"})})]})});var t3=r(18421);let t6=(0,L.Z)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),t8=(0,L.Z)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),t7=(0,L.Z)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),t9=(0,l.memo)(function({isOpen:e,onClose:t,onConfirm:r,worktreeId:s,sourcePath:n,sourceType:i}){let o=(0,x.T)("worktree"),c=(0,x.T)("common"),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(new Set([""])),[h,f]=(0,l.useState)([]),[g,y]=(0,l.useState)(!1),[b,v]=(0,l.useState)(new Set),w=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"";(0,l.useEffect)(()=>{e&&(u(w),p(new Set([""])),f([]),j())},[e,s]);let j=(0,l.useCallback)(async()=>{y(!0);try{let e=await fetch(`/api/worktrees/${s}/tree`);if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));f(t)}catch{}finally{y(!1)}},[s]),N=(0,l.useCallback)(async e=>{v(t=>new Set(t).add(e));try{let t=await fetch(`/api/worktrees/${s}/tree/${e}`);if(!t.ok)return;let r=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:`${e}/${t.name}`,loaded:!1}));f(t=>(function e(t,r,a){return t.map(t=>t.path===r?{...t,children:a,loaded:!0}:t.children?{...t,children:e(t.children,r,a)}:t)})(t,e,r))}catch{}finally{v(t=>{let r=new Set(t);return r.delete(e),r})}},[s]),k=(0,l.useCallback)(async e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});let t=function e(t,r){for(let a of t){if(a.path===r)return a;if(a.children){let t=e(a.children,r);if(t)return t}}return null}(h,e);t&&!t.loaded&&await N(e)},[h,N]),C=(0,l.useCallback)(e=>!(e===w||"directory"===i&&(e===n||e.startsWith(n+"/"))),[w,n,i]),S=(e,t=0)=>{let r=m.has(e.path),s=d===e.path,n=b.has(e.path),l=C(e.path);return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:`flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ${s?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"} ${l?"":"opacity-40 cursor-not-allowed"}`,style:{paddingLeft:`${.5+1.25*t}rem`},onClick:()=>{l&&u(e.path)},children:[a.jsx("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),k(e.path)},children:n?a.jsx(tg,{className:"w-3 h-3 animate-spin text-gray-400"}):a.jsx(t6,{className:`w-3 h-3 text-gray-400 transition-transform ${r?"rotate-90":""}`})}),r?a.jsx(t8,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):a.jsx(t7,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:e.name})]}),r&&e.children&&a.jsx("div",{children:e.children.map(e=>S(e,t+1))})]},e.path)},T=C(d);return a.jsx(tJ.u,{isOpen:e,onClose:t,title:o("fileTree.moveDialogTitle"),size:"md",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:[o("fileTree.moveTo"),": ",a.jsx("span",{className:"font-mono text-gray-800",children:n})]}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,a.jsxs)("div",{className:`flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ${""===d?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"} ${C("")?"":"opacity-40 cursor-not-allowed"}`,onClick:()=>{C("")&&u("")},children:[a.jsx("span",{className:"w-4 h-4"}),a.jsx(t7,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),a.jsx("span",{children:o("fileTree.rootDirectory")})]}),g?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(tg,{className:"w-5 h-5 animate-spin text-gray-400"})}):h.map(e=>S(e,1))]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:t,className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:c("cancel")}),a.jsx("button",{onClick:()=>r(d),disabled:!T,className:"px-4 py-2 text-sm text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:o("fileTree.moveConfirm")})]})]})})});function re(e){return e?e.split("/").map(encodeURIComponent).join("/"):""}let rt=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function rr(e){return e.replace(RegExp(rt.source,"g"),"")}let ra=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,rs=["default","acceptEdits","plan","dontAsk","bypassPermissions"],rn=["read-only","workspace-write","danger-full-access"],rl=["Name","Cron","Message","CLI Tool","Enabled"],ri=["Permission"],ro=`## Schedules
9
+ `,children:[s?a.jsx("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),a.jsx("span",{className:"text-sm font-medium",children:"Add Memo"})]}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[Math.max(0,t-e)," remaining"]})]})}),tI=(0,l.memo)(function({worktreeId:e,className:t=""}){let[r,s]=(0,l.useState)([]),[n,i]=(0,l.useState)(!0),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(null),h=(0,l.useCallback)(async()=>{i(!0),u(null);try{let t=await tO.nE.getAll(e);s(t.sort((e,t)=>e.position-t.position))}catch(e){u((0,tO.zG)(e))}finally{i(!1)}},[e]);(0,l.useEffect)(()=>{h()},[h]);let f=(0,l.useCallback)(async()=>{c(!0),p(null);try{let t=await tO.nE.create(e,{title:"Memo",content:""});s(e=>[...e,t])}catch(e){p((0,tO.zG)(e))}finally{c(!1)}},[e]),x=(0,l.useCallback)(async(t,r)=>{await tO.nE.update(e,t,r),s(e=>e.map(e=>e.id===t?{...e,...r}:e))},[e]),g=(0,l.useCallback)(async t=>{try{await tO.nE.delete(e,t),s(e=>e.filter(e=>e.id!==t))}catch(e){console.error("Failed to delete memo:",e)}},[e]),b=(0,l.useCallback)(()=>{h()},[h]);return n?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"text-sm text-gray-500",children:"Loading memos..."})]})}):d?a.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[a.jsx("svg",{className:"w-12 h-12 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm text-red-600",children:d}),a.jsx("button",{type:"button",onClick:b,"aria-label":"Retry",className:"px-4 py-2 text-sm font-medium text-white bg-blue-500 rounded-lg hover:bg-blue-600 transition-colors",children:"Retry"})]})}):(0,a.jsxs)("div",{"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[0===r.length&&!m&&(0,a.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[a.jsx("p",{children:"No memos yet."}),a.jsx("p",{className:"text-sm",children:"Click the button below to add one."})]}),r.map(e=>a.jsx(t$,{memo:e,onUpdate:x,onDelete:g},e.id)),m&&a.jsx("div",{className:"text-center py-2 text-sm text-red-500",children:m}),a.jsx(tL,{currentCount:r.length,maxCount:5,onAdd:f,isLoading:o,className:"mt-2"})]})});function tD(e){return new Date(e).toLocaleString()}let tF=(0,l.memo)(function({worktreeId:e,className:t=""}){let r=(0,x.T)("schedule"),[s,n]=(0,l.useState)([]),[i,o]=(0,l.useState)([]),[c,d]=(0,l.useState)(!0),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(null),[f,g]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{d(!0),m(null);try{let[t,r]=await Promise.all([fetch(`/api/worktrees/${e}/execution-logs`),fetch(`/api/worktrees/${e}/schedules`)]);if(t.ok){let e=await t.json();n(e.logs||[])}if(r.ok){let e=await r.json();o(e.schedules||[])}}catch(e){m(e instanceof Error?e.message:"Failed to fetch data")}finally{d(!1)}},[e]);(0,l.useEffect)(()=>{b()},[b]);let y=(0,l.useCallback)(async t=>{if(p===t){h(null),g(null);return}try{let r=await fetch(`/api/worktrees/${e}/execution-logs/${t}`);if(r.ok){let e=await r.json();g(e.log),h(t)}}catch(e){console.error("Failed to fetch log detail:",e)}},[e,p]);return c?a.jsx("div",{className:`flex items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),a.jsx("span",{className:"text-sm text-gray-500",children:r("loading")})]})}):u?a.jsx("div",{className:`flex items-center justify-center h-full p-4 ${t}`,children:(0,a.jsxs)("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-red-600",children:u}),a.jsx("button",{type:"button",onClick:()=>void b(),className:"ml-2 px-3 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-600",children:r("retry")})]})}):(0,a.jsxs)("div",{className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:[r("title")," (",i.length,")"]}),0===i.length?(0,a.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[a.jsx("p",{className:"font-medium text-gray-600 mb-3",children:r("noSchedulesTitle")}),(0,a.jsxs)("ol",{className:"text-sm text-left inline-block space-y-1.5 list-decimal list-inside",children:[a.jsx("li",{children:r("noSchedulesStep1")}),a.jsx("li",{children:r("noSchedulesStep2")}),a.jsx("li",{children:r("noSchedulesStep3")}),a.jsx("li",{children:r("noSchedulesStep4")})]})]}):a.jsx("div",{className:"space-y-2",children:i.map(e=>(0,a.jsxs)("div",{className:"border border-gray-200 rounded p-3 bg-white",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-medium text-sm",children:e.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${e.enabled?"bg-green-50 text-green-600":"bg-gray-50 text-gray-500"}`,children:e.enabled?r("enabled"):r("disabled")})]}),(0,a.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[(0,a.jsxs)("span",{children:[r("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,a.jsxs)("span",{className:"ml-3",children:[r("lastRun"),": ",tD(e.last_executed_at)]})]})]},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:[r("executionLogs")," (",s.length,")"]}),0===s.length?a.jsx("p",{className:"text-sm text-gray-500",children:r("noLogs")}):a.jsx("div",{className:"space-y-2",children:s.map(e=>(0,a.jsxs)("div",{className:"border border-gray-200 rounded bg-white",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>void y(e.id),className:"w-full text-left p-3 hover:bg-gray-50 transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||r("unknownSchedule")}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${function(e){switch(e){case"completed":return"text-green-600 bg-green-50";case"failed":return"text-red-600 bg-red-50";case"timeout":return"text-yellow-600 bg-yellow-50";case"running":return"text-blue-600 bg-blue-50";case"cancelled":return"text-gray-600 bg-gray-50"}}(e.status)}`,children:r(`status.${e.status}`)})]}),(0,a.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[tD(e.started_at),null!==e.exit_code&&(0,a.jsxs)("span",{className:"ml-2",children:[r("exitCode"),": ",e.exit_code]})]})]}),p===e.id&&f&&(0,a.jsxs)("div",{className:"border-t border-gray-200 p-3 bg-gray-50 space-y-3",children:[(0,a.jsxs)("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:r("message")}),a.jsx("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700",children:f.message})]}),(0,a.jsxs)("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:r("response")}),a.jsx("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700 max-h-60 overflow-y-auto",children:f.result||r("noOutput")})]})]})]},e.id))})]})]})});var tz=r(2491);let tH=(0,l.memo)(function({worktreeId:e,selectedAgents:t,onSelectedAgentsChange:r,vibeLocalModel:s,onVibeLocalModelChange:n}){let i=(0,x.T)("schedule"),[o,c]=(0,l.useState)(()=>new Set(t)),[d,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)([]),[h,f]=(0,l.useState)(null),[g,b]=(0,l.useState)(!1),[y,v]=(0,l.useState)(!1),w=(0,l.useRef)(o);w.current=o,(0,l.useEffect)(()=>{c(new Set(t))},[t]);let j=o.has("vibe-local");(0,l.useEffect)(()=>{if(!j){p([]),f(null);return}let e=!1;return b(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(p(t.models),f(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(p([]),f("Failed to fetch models"))}).finally(()=>{e||b(!1)}),()=>{e=!0}},[j]);let N=(0,l.useCallback)(async(a,s)=>{let n=new Set(w.current);if(s?n.add(a):n.delete(a),c(n),2===n.size){let a=Array.from(n);u(!0);try{(await fetch(`/api/worktrees/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:a})})).ok?r(a):c(new Set(t))}catch{c(new Set(t))}finally{u(!1)}}},[e,t,r]),k=(0,l.useCallback)(async t=>{let r=t.target.value,a=""===r?null:r;v(!0);try{(await fetch(`/api/worktrees/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:a})})).ok&&n(a)}catch{}finally{v(!1)}},[e,n]),C=o.size>=2;return(0,a.jsxs)("div",{className:"p-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-1",children:i("agentSettings")}),a.jsx("p",{className:"text-xs text-gray-500 mb-4",children:i("selectAgents")}),a.jsx("div",{className:"space-y-3",children:tz.tK.map(e=>{let t=o.has(e),r=!t&&C;return(0,a.jsxs)("label",{className:`flex items-center gap-3 p-2 rounded-lg border transition-colors ${t?"border-blue-200 bg-blue-50":r?"border-gray-100 bg-gray-50 opacity-50":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"}`,children:[a.jsx("input",{type:"checkbox","data-testid":`agent-checkbox-${e}`,"aria-label":(0,tz.Ds)(e),checked:t,disabled:r||d,onChange:t=>N(e,t.target.checked),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:(0,tz.Ds)(e)})]},e)})}),d&&(0,a.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-gray-500",children:[a.jsx("span",{className:"w-3 h-3 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),i("loading")]}),j&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-gray-200",children:[a.jsx("h4",{className:"text-sm font-semibold text-gray-700 mb-2",children:i("vibeLocalModel")}),g?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[a.jsx("span",{className:"w-3 h-3 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),i("loading")]}):h&&0===m.length?a.jsx("p",{className:"text-xs text-amber-600",children:i("ollamaNotAvailable")}):(0,a.jsxs)("select",{"data-testid":"vibe-local-model-select",value:s??"",onChange:k,disabled:y,className:"w-full text-sm border border-gray-300 rounded-md px-3 py-2 bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50",children:[a.jsx("option",{value:"",children:i("vibeLocalModelDefault")}),m.map(e=>(0,a.jsxs)("option",{value:e.name,children:[e.name,e.parameterSize?` (${e.parameterSize})`:""]},e.name))]})]})]})}),tW=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"}],tB=(0,l.memo)(function({worktreeId:e,className:t="",selectedAgents:r,onSelectedAgentsChange:s,vibeLocalModel:n,onVibeLocalModelChange:i}){let o=(0,x.T)("schedule"),[c,d]=(0,l.useState)("notes"),u=(0,l.useCallback)(e=>{d(e)},[]);return(0,a.jsxs)("div",{className:`flex flex-col h-full ${t}`,children:[a.jsx("div",{className:"flex border-b border-gray-200 bg-white flex-shrink-0",children:tW.map(e=>a.jsx("button",{type:"button",onClick:()=>u(e.id),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${c===e.id?"text-blue-600 border-b-2 border-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`,children:o(e.labelKey)},e.id))}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===c&&a.jsx(tI,{worktreeId:e,className:"h-full"}),"logs"===c&&a.jsx(tF,{worktreeId:e,className:"h-full"}),"agent"===c&&a.jsx(tH,{worktreeId:e,selectedAgents:r,onSelectedAgentsChange:s,vibeLocalModel:n,onVibeLocalModelChange:i})]})]})});var tU=r(11867);function tG(){let[e,t]=(0,l.useState)(null),[r,a]=(0,l.useState)(!0),[s,n]=(0,l.useState)(null);return{data:e,loading:r,error:s}}function tV({hasUpdate:e,latestVersion:t,releaseUrl:r,updateCommand:s,installType:n}){let l=(0,x.T)("worktree");return e?(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 mt-2",role:"status","aria-label":l("update.available"),"data-testid":"update-notification-banner",children:[a.jsx("p",{className:"text-sm font-medium text-blue-800 mb-1",children:l("update.available")}),t&&a.jsx("p",{className:"text-sm text-blue-700 mb-2",children:l("update.latestVersion",{version:t})}),s&&"global"===n&&(0,a.jsxs)("div",{className:"mb-2",children:[a.jsx("p",{className:"text-xs text-blue-600 mb-1",children:l("update.updateCommand")}),a.jsx("code",{className:"block bg-blue-100 rounded px-2 py-1 text-xs text-blue-900 font-mono",children:s})]}),r&&(0,a.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[l("update.viewRelease"),a.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),a.jsx("p",{className:"text-xs text-blue-500 mt-2",children:l("update.dataPreserved")})]}):null}function tq({version:e,className:t}){let r=(0,x.T)("worktree"),{data:s,loading:n}=tG(),i=(0,l.useMemo)(()=>s&&s.hasUpdate?{hasUpdate:s.hasUpdate,latestVersion:s.latestVersion,releaseUrl:s.releaseUrl,updateCommand:s.updateCommand,installType:s.installType}:null,[s]);return(0,a.jsxs)("div",{className:t,"data-testid":"version-section",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:r("update.version")}),a.jsx("p",{className:"text-sm text-gray-700",children:e}),n&&a.jsx("p",{className:"text-xs text-gray-400 mt-1","data-testid":"version-loading",children:"..."}),i&&a.jsx(tV,{...i})]})}let tY="https://github.com/Kewton/CommandMate",tZ=`${tY}/issues`,tK=`${tY}/issues/new`,tX=`${tK}?template=bug_report.md`,tJ=`${tK}?template=feature_request.md`,tQ=`${tK}?template=question.md`;function t0({className:e}){let t=(0,x.T)("worktree"),r=[{href:tX,label:t("feedback.bugReport")},{href:tJ,label:t("feedback.featureRequest")},{href:tQ,label:t("feedback.question")},{href:tZ,label:t("feedback.viewIssues")}];return(0,a.jsxs)("div",{className:e,"data-testid":"feedback-section",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-2",children:t("feedback.title")}),a.jsx("div",{className:"flex flex-col gap-1",children:r.map(({href:e,label:t})=>(0,a.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[t,a.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},e))})]})}var t1=r(28676);r(63817);let t2=[36e5,108e5,288e5],t4={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function t5({isOpen:e,onConfirm:t,onCancel:r,cliToolName:s}){let n=(0,x.T)("autoYes"),i=(0,x.T)("common"),[o,c]=(0,l.useState)(36e5),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(null),[h,f]=(0,l.useState)(!1),g=(0,l.useRef)(null),b=e=>n(t4[e].replace("autoYes.",""));return a.jsx(t1.u,{isOpen:e,onClose:r,title:s?n("enableTitleWithTool",{toolName:s}):n("enableTitle"),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("featureDescription")}),(0,a.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[a.jsx("li",{children:n("yesNoAutoResponse")}),a.jsx("li",{children:n("multipleChoiceAutoSelect")})]}),a.jsx("p",{className:"mt-1",children:n("autoDisableAfter",{duration:b(o)})}),s&&a.jsx("p",{className:"mt-2 text-gray-500",children:n("appliesOnlyToCurrent",{toolName:s})})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("duration")}),a.jsx("div",{className:"flex gap-2",children:t2.map(e=>a.jsx("button",{type:"button",onClick:()=>c(e),className:`flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ${o===e?"border-blue-600 bg-blue-50 text-blue-700":"border-gray-300 bg-white text-gray-700 hover:border-gray-400"}`,style:{minHeight:"44px"},children:b(e)},e))})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.jsx("label",{htmlFor:"stop-pattern-input",className:"font-medium",children:n("stopPatternLabel")}),(0,a.jsxs)("div",{className:"relative",ref:g,children:[a.jsx("button",{type:"button",onClick:()=>f(!h),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 text-gray-600 text-[10px] font-bold hover:bg-gray-400 focus:outline-none","aria-label":n("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),h&&(0,a.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-gray-200 bg-white p-3 shadow-lg text-xs text-gray-700","data-testid":"regex-tips-tooltip",children:[a.jsx("p",{className:"font-medium mb-1.5",children:n("regexTipsTitle")}),(0,a.jsxs)("ul",{className:"space-y-1",children:[(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"\\bcat\\b"})," ",n("regexTipWordBoundary")]}),(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"error|fatal"})," ",n("regexTipOr")]}),(0,a.jsxs)("li",{children:[a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"(?i)error"})," ",n("regexTipCaseNote")]})]})]})]})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:n("stopPatternDescription")}),a.jsx("input",{id:"stop-pattern-input",type:"text",value:d,onChange:e=>u(e.target.value),placeholder:n("stopPatternPlaceholder"),className:`w-full px-3 py-2 border rounded-md text-sm font-mono ${m?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"} focus:outline-none focus:ring-1`,"data-testid":"stop-pattern-input"}),m&&a.jsx("p",{className:"mt-1 text-xs text-red-600","data-testid":"stop-pattern-error",children:m})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-700",children:[a.jsx("p",{className:"font-medium mb-2",children:n("aboutRisks")}),a.jsx("p",{children:n("riskWarning")})]}),a.jsx("div",{className:"bg-yellow-50 border-l-4 border-yellow-400 p-3",children:(0,a.jsxs)("p",{className:"text-sm text-yellow-800",children:[a.jsx("span",{className:"font-medium",children:n("disclaimer")}),n("disclaimerText")]})}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:i("cancel")}),a.jsx("button",{type:"button",onClick:()=>{t(o,d.trim()||void 0)},disabled:!!m,className:`px-4 py-2 text-sm font-medium rounded-md text-white ${m?"bg-gray-400 cursor-not-allowed":"bg-yellow-600 hover:bg-yellow-700"}`,"data-testid":"confirm-button",children:n("agreeAndEnable")})]})]})})}let t3=(0,l.memo)(function({enabled:e,expiresAt:t,onToggle:r,lastAutoResponse:s,cliToolName:n,inline:i=!1}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),[h,f]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!e||!t){c("");return}let r=()=>{c(function(e){let t=Math.max(0,e-Date.now()),r=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return r>0?`${r}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}(t))};r();let a=setInterval(r,1e3);return()=>clearInterval(a)},[e,t]),(0,l.useEffect)(()=>{if(!s)return;u(`Auto responded: "${s}"`);let e=setTimeout(()=>u(null),2e3);return()=>clearTimeout(e)},[s]);let x=(0,l.useCallback)(()=>{e?(p(!0),r({enabled:!1}).finally(()=>p(!1))):f(!0)},[e,r]),g=(0,l.useCallback)((e,t)=>{f(!1),p(!0),r({enabled:!0,duration:e,stopPattern:t}).finally(()=>p(!1))},[r]),b=(0,l.useCallback)(()=>{f(!1)},[]);return(0,a.jsxs)("div",{className:i?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-gray-50 border-b border-gray-200",children:[a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Yes mode",disabled:m,onClick:x,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${e?"bg-blue-600":"bg-gray-300"} ${m?"opacity-50":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Auto Yes"}),e&&n&&(0,a.jsxs)("span",{className:"text-xs text-blue-600 font-medium","aria-label":"Auto Yes target",children:["(",(0,tz.ts)(n,""),")"]}),e&&o&&a.jsx("span",{className:"text-sm text-gray-500","aria-label":"Time remaining",children:o}),d&&a.jsx("span",{className:"text-sm text-green-600 animate-pulse",children:d}),a.jsx(t5,{isOpen:h,onConfirm:g,onCancel:b,cliToolName:(0,tz.ts)(n,"")})]})}),t6=(0,l.memo)(function({isBranchMismatch:e,currentBranch:t,initialBranch:r}){let[s,n]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{n(!1)},[t]),!e||s||null===r)?null:(0,a.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-amber-50 border border-amber-200 text-amber-800 rounded-lg",children:[a.jsx(ti,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsx("div",{className:"flex-1 min-w-0",children:(0,a.jsxs)("span",{className:"text-sm",children:["Branch changed from"," ",a.jsx("span",{className:"font-medium",children:r})," ","to"," ",a.jsx("span",{className:"font-medium",children:t})]})}),a.jsx("button",{type:"button",onClick:()=>n(!0),className:"p-1 rounded hover:bg-amber-100 transition-colors","aria-label":"Dismiss alert",children:a.jsx(tp.Z,{className:"w-4 h-4"})})]})});var t8=r(77465),t7=r(18421);let t9=(0,L.Z)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),re=(0,L.Z)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),rt=(0,L.Z)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),rr=(0,l.memo)(function({isOpen:e,onClose:t,onConfirm:r,worktreeId:s,sourcePath:n,sourceType:i}){let o=(0,x.T)("worktree"),c=(0,x.T)("common"),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(new Set([""])),[h,f]=(0,l.useState)([]),[g,b]=(0,l.useState)(!1),[y,v]=(0,l.useState)(new Set),w=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"";(0,l.useEffect)(()=>{e&&(u(w),p(new Set([""])),f([]),j())},[e,s]);let j=(0,l.useCallback)(async()=>{b(!0);try{let e=await fetch(`/api/worktrees/${s}/tree`);if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));f(t)}catch{}finally{b(!1)}},[s]),N=(0,l.useCallback)(async e=>{v(t=>new Set(t).add(e));try{let t=await fetch(`/api/worktrees/${s}/tree/${e}`);if(!t.ok)return;let r=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:`${e}/${t.name}`,loaded:!1}));f(t=>(function e(t,r,a){return t.map(t=>t.path===r?{...t,children:a,loaded:!0}:t.children?{...t,children:e(t.children,r,a)}:t)})(t,e,r))}catch{}finally{v(t=>{let r=new Set(t);return r.delete(e),r})}},[s]),k=(0,l.useCallback)(async e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});let t=function e(t,r){for(let a of t){if(a.path===r)return a;if(a.children){let t=e(a.children,r);if(t)return t}}return null}(h,e);t&&!t.loaded&&await N(e)},[h,N]),C=(0,l.useCallback)(e=>!(e===w||"directory"===i&&(e===n||e.startsWith(n+"/"))),[w,n,i]),S=(e,t=0)=>{let r=m.has(e.path),s=d===e.path,n=y.has(e.path),l=C(e.path);return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:`flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ${s?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"} ${l?"":"opacity-40 cursor-not-allowed"}`,style:{paddingLeft:`${.5+1.25*t}rem`},onClick:()=>{l&&u(e.path)},children:[a.jsx("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),k(e.path)},children:n?a.jsx(tg,{className:"w-3 h-3 animate-spin text-gray-400"}):a.jsx(t9,{className:`w-3 h-3 text-gray-400 transition-transform ${r?"rotate-90":""}`})}),r?a.jsx(re,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):a.jsx(rt,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:e.name})]}),r&&e.children&&a.jsx("div",{children:e.children.map(e=>S(e,t+1))})]},e.path)},T=C(d);return a.jsx(t1.u,{isOpen:e,onClose:t,title:o("fileTree.moveDialogTitle"),size:"md",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:[o("fileTree.moveTo"),": ",a.jsx("span",{className:"font-mono text-gray-800",children:n})]}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,a.jsxs)("div",{className:`flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ${""===d?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"} ${C("")?"":"opacity-40 cursor-not-allowed"}`,onClick:()=>{C("")&&u("")},children:[a.jsx("span",{className:"w-4 h-4"}),a.jsx(rt,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),a.jsx("span",{children:o("fileTree.rootDirectory")})]}),g?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(tg,{className:"w-5 h-5 animate-spin text-gray-400"})}):h.map(e=>S(e,1))]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:t,className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:c("cancel")}),a.jsx("button",{onClick:()=>r(d),disabled:!T,className:"px-4 py-2 text-sm text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:o("fileTree.moveConfirm")})]})]})})});function ra(e){return e?e.split("/").map(encodeURIComponent).join("/"):""}let rs=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function rn(e){return e.replace(RegExp(rs.source,"g"),"")}let rl=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,ri=["default","acceptEdits","plan","dontAsk","bypassPermissions"],ro=["read-only","workspace-write","danger-full-access"],rc=["Name","Cron","Message","CLI Tool","Enabled"],rd=["Permission"],ru=`## Schedules
10
10
 
11
11
  | Name | Cron | Message | CLI Tool | Enabled | Permission |
12
12
  |------|------|---------|----------|---------|------------|
13
13
  | example-task | 0 * * * * | README.mdを要約してください | claude | true | acceptEdits |
14
- `;function rc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function rd(e,t,r,a){let[s,n]=(0,l.useState)(!1),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1),u=(0,l.useCallback)(async()=>{if(e){d(!0);try{let r=await tO.Iv.updateDescription(e.id,i);t(r),n(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,l.useCallback)(()=>{o(e?.description||""),n(!1)},[e]);return{isEditing:s,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,l.useCallback)(()=>{n(!0)},[])}}let ru=(0,l.memo)(function({worktreeId:e,worktree:t,cardClassName:r,descriptionEditor:s,showLogs:n,onToggleLogs:l}){let{isEditing:i,text:o,setText:c,isSaving:d,handleSave:u,handleCancel:m,startEditing:p}=s;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Worktree"}),a.jsx("p",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),a.jsx("p",{className:"text-base text-gray-900",children:t.repositoryName}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 break-all",children:t.repositoryPath})]}),(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Path"}),a.jsx("p",{className:"text-sm text-gray-700 break-all font-mono",children:t.path})]}),t.status&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Status"}),a.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${"done"===t.status?"bg-green-100 text-green-800":"doing"===t.status?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:t.status.toUpperCase()})]}),(0,a.jsxs)("div",{className:r,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Description"}),!i&&a.jsx("button",{type:"button",onClick:p,className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),i?(0,a.jsxs)("div",{className:"space-y-3",children:[a.jsx("textarea",{value:o,onChange:e=>c(e.target.value),placeholder:"Add notes about this branch...",className:"w-full min-h-[150px] p-3 border border-gray-300 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:u,disabled:d,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:d?"Saving...":"Save"}),a.jsx("button",{type:"button",onClick:m,disabled:d,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 disabled:opacity-50 text-sm font-medium",children:"Cancel"})]})]}):a.jsx("div",{className:"min-h-[50px]",children:t.description?a.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:t.description}):a.jsx("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),t.link&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Link"}),a.jsx("a",{href:t.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline break-all",children:t.link})]}),t.updatedAt&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Last Updated"}),a.jsx("p",{className:"text-sm text-gray-700",children:new Date(t.updatedAt).toLocaleString()})]}),a.jsx(tU,{version:"v0.3.2",className:r}),a.jsx(tX,{className:r}),(0,a.jsxs)("div",{className:r,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Logs"}),a.jsx("button",{type:"button",onClick:l,className:"text-sm text-blue-600 hover:text-blue-800",children:n?"Hide":"Show"})]}),n&&a.jsx(tH.n,{worktreeId:e})]})]})}),rm=(0,l.memo)(function({worktreeName:e,repositoryName:t,description:r,status:s,gitStatus:n,onBackClick:l,onInfoClick:i,onMenuClick:o,hasUpdate:c}){let d=el.Ie[s],u=r?(0,ei.aS)(r,50):null;return(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:o,className:"p-2 -ml-2 rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-100 transition-colors","aria-label":"Toggle sidebar",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),(0,a.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-gray-600 hover:text-gray-900 transition-colors","aria-label":"Go back to worktree list",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),a.jsx("span",{className:"text-sm font-medium",children:"Back"})]}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),"spinner"===d.type?a.jsx("span",{"data-testid":"desktop-status-indicator",title:d.label,"aria-label":d.label,className:`w-3 h-3 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${d.className}`}):a.jsx("span",{"data-testid":"desktop-status-indicator",title:d.label,"aria-label":d.label,className:`w-3 h-3 rounded-full flex-shrink-0 ${d.className}`}),(0,a.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("h1",{className:"text-lg font-semibold text-gray-900 truncate max-w-[200px] leading-tight",children:e}),u&&a.jsx("span",{className:"text-sm text-gray-500 truncate max-w-md",title:r,children:u})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[a.jsx("span",{className:"truncate max-w-[200px]",children:t}),n&&"(unknown)"!==n.currentBranch&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-300",children:"/"}),a.jsx("span",{className:"truncate max-w-[150px] font-mono",title:n.currentBranch,"data-testid":"desktop-branch-name",children:(0,ei.aS)(n.currentBranch,30)}),n.isDirty&&a.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors","aria-label":"View worktree information",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm font-medium",children:"Info"}),c&&a.jsx(eu,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":"Update available"})]})]})}),rp=(0,l.memo)(function({worktreeId:e,worktree:t,isOpen:r,onClose:s,onWorktreeUpdate:n}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(r),d=rd(t,n,r,()=>{let e=r&&!c.current;return c.current=r,e});return t?a.jsx(tJ.u,{isOpen:r,onClose:s,title:"Worktree Information",size:"md",children:a.jsx("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:a.jsx(ru,{worktreeId:e,worktree:t,cardClassName:"bg-gray-50 rounded-lg p-4",descriptionEditor:d,showLogs:i,onToggleLogs:()=>o(!i)})})}):null}),rh=(0,l.memo)(function(){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("p",{className:"text-gray-600",children:"Loading worktree..."})]})})}),rf=(0,l.memo)(function({message:e,onRetry:t}){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,a.jsxs)("div",{className:"text-center p-6 bg-red-50 rounded-lg border border-red-200 max-w-md",children:[a.jsx("svg",{className:"mx-auto h-12 w-12 text-red-400 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-red-600 font-medium",children:"Error loading worktree"}),a.jsx("p",{className:"text-red-500 text-sm mt-2",children:e}),t&&a.jsx("button",{type:"button",onClick:t,className:"mt-4 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2",children:"Retry"})]})})}),rx=(0,l.memo)(function({worktreeId:e,worktree:t,onWorktreeUpdate:r}){let[s,n]=(0,l.useState)(!1),i=(0,l.useRef)(t?.id),o=(0,l.useRef)(!1),c=rd(t,r,t?.id,()=>{let e=t?.id!==i.current;return i.current=t?.id,e&&!o.current});return(o.current=c.isEditing,t)?a.jsx("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:a.jsx(ru,{worktreeId:e,worktree:t,cardClassName:"bg-white rounded-lg border border-gray-200 p-4",descriptionEditor:c,showLogs:s,onToggleLogs:()=>n(!s)})}):a.jsx("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),rg=(0,l.memo)(function({activeTab:e,worktreeId:t,worktree:r,messages:s,terminalOutput:n,isTerminalActive:l,isThinking:i,onFilePathClick:o,onFileSelect:c,onWorktreeUpdate:d,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,onMove:x,refreshTrigger:y,fileSearch:b,showToast:v,onCmateSetup:w}){switch(e){case"terminal":return a.jsx(g,{componentName:"TerminalDisplay",children:a.jsx($,{output:n,isActive:l,isThinking:i,className:"h-full"})});case"history":return a.jsx(g,{componentName:"HistoryPane",children:a.jsx(X,{messages:s,worktreeId:t,onFilePathClick:o,className:"h-full",showToast:v})});case"files":return a.jsx(g,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eU,{query:b.query,mode:b.mode,isSearching:b.isSearching,error:b.error,onQueryChange:b.setQuery,onModeChange:b.setMode,onClear:b.clearSearch}),a.jsx(ez,{worktreeId:t,onFileSelect:c,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,onMove:x,onCmateSetup:w,refreshTrigger:y,searchQuery:b.query,searchMode:b.mode,searchResults:b.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return a.jsx(g,{componentName:"NotesAndLogsPane",children:a.jsx(tz,{worktreeId:t,className:"h-full"})});case"info":return a.jsx(rx,{worktreeId:t,worktree:r,onWorktreeUpdate:d});default:return null}}),ry=(0,l.memo)(function({worktreeId:e}){let t=(0,s.useRouter)(),r=(0,h.d)(),{toggle:n,openMobileDrawer:i}=(0,f.Sz)(),{state:o,actions:c}=function(){let[e,t]=(0,l.useReducer)(p,void 0,m),r=(0,l.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),setTerminalOutput:(e,r)=>t({type:"SET_TERMINAL_OUTPUT",output:e,realtimeSnippet:r}),setTerminalActive:e=>t({type:"SET_TERMINAL_ACTIVE",isActive:e}),setTerminalThinking:e=>t({type:"SET_TERMINAL_THINKING",isThinking:e}),showPrompt:(e,r)=>t({type:"SHOW_PROMPT",data:e,messageId:r}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,r)=>t({type:"UPDATE_MESSAGE",id:e,updates:r}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),startWaitingForResponse:e=>t({type:"START_WAITING_FOR_RESPONSE",cliToolId:e}),responseReceived:e=>t({type:"RESPONSE_RECEIVED",message:e}),sessionEnded:()=>t({type:"SESSION_ENDED"}),setAutoScroll:e=>t({type:"SET_AUTO_SCROLL",enabled:e}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e})}),[]);return{state:e,dispatch:t,actions:r}}(),d=(0,x.T)("worktree"),u=(0,x.T)("error"),y=(0,x.T)("common"),b=(0,x.T)("autoYes"),v=(0,x.T)("schedule"),[w,j]=(0,l.useState)(null),[N,k]=(0,l.useState)(!0),[C,S]=(0,l.useState)(null),[T,E]=(0,l.useState)(!1),[A,R]=(0,l.useState)(null),[_,O]=(0,l.useState)(null),[P,L]=(0,l.useState)(!1),[I,D]=(0,l.useState)(!1),[F,z]=(0,l.useState)(null),H=(0,l.useRef)(!1),[W,B]=(0,l.useState)(!1),[U,G]=(0,l.useState)("claude"),V=(0,l.useRef)(U);V.current=U;let[q,Y]=(0,l.useState)(0),Z=function(e){let{worktreeId:t,initialMode:r="name",debounceMs:a=300}=e,[s,n]=(0,l.useState)(""),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(r),[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(null),[f,x]=(0,l.useState)(null),g=(0,l.useRef)(null),y=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{o(e)},a),[a]),b=(0,l.useCallback)(e=>{n(e),y(e),x(null)},[y]),v=(0,l.useCallback)(()=>{n(""),o(""),h(null),x(null),m(!1),g.current&&(g.current.abort(),g.current=null)},[]),w=(0,l.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),j=(0,l.useCallback)(()=>p&&0!==p.results.length?(0,ei.Ps)(p.results.map(e=>e.filePath)):new Set,[p]);return{query:s,mode:c,isSearching:u,results:p,error:f,setQuery:b,setMode:d,clearSearch:v,filterByName:w,getMatchedPaths:j}}({worktreeId:e}),K=(0,l.useRef)(!1),J=(0,l.useRef)(e);(0,l.useEffect)(()=>{J.current!==e&&(c.clearMessages(),K.current=!1,c.setTerminalOutput("",""),J.current=e)},[e,c]);let Q=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}`);if(!t.ok)throw Error(`Failed to fetch worktree: ${t.status}`);let r=await t.json();return j(r),r}catch(e){return S(e instanceof Error?e.message:"Unknown error"),null}},[e]),ee=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/messages?cliTool=${V.current}`);if(!t.ok)throw Error(`Failed to fetch messages: ${t.status}`);let r=await t.json();c.setMessages(r.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[e,c]),et=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/current-output?cliTool=${V.current}`);if(!t.ok)return;let r=await t.json(),a=r.fullOutput??r.realtimeSnippet??"";if((a||r.isRunning)&&c.setTerminalOutput(a,r.realtimeSnippet??""),c.setTerminalActive(r.isRunning??!1),c.setTerminalThinking(r.thinking??!1),r.isPromptWaiting&&r.promptData?c.showPrompt(r.promptData,`prompt-${Date.now()}`):!r.isPromptWaiting&&o.prompt.visible&&c.clearPrompt(),r.autoYes){let e=H.current;D(r.autoYes.enabled),z(r.autoYes.expiresAt),H.current=r.autoYes.enabled,e&&!r.autoYes.enabled&&"stop_pattern_matched"===r.autoYes.stopReason&&B(!0)}}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[e,c,o.prompt.visible]),er=(0,l.useRef)(U);(0,l.useEffect)(()=>{er.current!==U&&(er.current=U,c.clearMessages(),c.setTerminalOutput("",""),ee(),et())},[U,c,ee,et]);let ea=(0,l.useCallback)(e=>{R(e)},[]),es=(0,l.useCallback)(e=>{let t=e.split(".").pop()?.toLowerCase(),r=t?`.${t}`:"";tA.includes(r)?O(e):R(e)},[]),eo=(0,l.useCallback)(()=>{R(null)},[]),ec=(0,l.useCallback)(()=>{O(null)},[]),eu=(0,l.useCallback)(e=>{Y(e=>e+1)},[]),em=(0,l.useCallback)(e=>{c.setLeftPaneTab(e)},[c]),ep=(0,l.useCallback)(()=>{t.push("/")},[t]),eh=(0,l.useCallback)(()=>{E(!0)},[]),ex=(0,l.useCallback)(()=>{E(!1)},[]),ey=(0,l.useCallback)(async t=>{c.setPromptAnswering(!0);try{let r=function(e,t,r){let a={answer:e,cliTool:t};if(r&&(a.promptType=r.type,"multiple_choice"===r.type)){let e=r.options.find(e=>e.isDefault);e&&(a.defaultOptionNumber=e.number)}return a}(t,U,o.prompt.data),a=await fetch(`/api/worktrees/${e}/prompt-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw Error(`Failed to send prompt response: ${a.status}`);c.clearPrompt(),await et()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{c.setPromptAnswering(!1)}},[e,c,et,U,o.prompt.data]),eb=(0,l.useCallback)(()=>{c.clearPrompt()},[c]),ev=(0,l.useCallback)(e=>{c.setMobileActivePane(e)},[c]),ej=(0,l.useCallback)(e=>{c.setAutoScroll(e)},[c]),eN=(0,l.useCallback)(()=>{ee(),et()},[ee,et]),ek=(0,l.useCallback)(async t=>{try{let r=await fetch(`/api/worktrees/${e}/auto-yes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t.enabled,cliToolId:U,duration:t.duration,stopPattern:t.stopPattern})});if(r.ok){let e=await r.json();D(e.enabled),z(e.expiresAt),H.current=e.enabled}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[e,U]),[eC,eS]=(0,l.useState)(!1),eT=(0,l.useCallback)(()=>{eS(!0)},[]),eE=(0,l.useCallback)(async()=>{eS(!1);try{if(!(await fetch(`/api/worktrees/${e}/kill-session?cliTool=${U}`,{method:"POST"})).ok)return;c.clearMessages(),c.setTerminalOutput("",""),c.setTerminalActive(!1),c.setTerminalThinking(!1),c.clearPrompt(),await Q()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[e,U,c,Q]),eM=(0,l.useCallback)(()=>{eS(!1)},[]),eA=(0,l.useCallback)(async t=>{let r=window.prompt("Enter file name (e.g., document.md):");if(!r)return;let a=r.endsWith(".md")?r:`${r}.md`,s=t?`${t}/${a}`:a;try{if(!(await fetch(`/api/worktrees/${e}/files/${re(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");Y(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert(u("fileOps.failedToCreateFile"))}},[e,u]),eR=(0,l.useCallback)(async t=>{let r=window.prompt("Enter directory name:");if(!r)return;let a=t?`${t}/${r}`:r;try{if(!(await fetch(`/api/worktrees/${e}/files/${re(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");Y(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(u("fileOps.failedToCreateDirectory"))}},[e,u]),e_=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||"",a=window.prompt("Enter new name:",r);if(a&&a!==r)try{if(!(await fetch(`/api/worktrees/${e}/files/${re(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:a})})).ok)throw Error("Failed to rename");Y(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(u("fileOps.failedToRename"))}},[e,u]),eO=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||t;if(window.confirm(y("confirmDelete",{name:r})))try{if(!(await fetch(`/api/worktrees/${e}/files/${re(t)}?recursive=true`,{method:"DELETE"})).ok)throw Error("Failed to delete");(_===t||_?.startsWith(`${t}/`))&&O(null),Y(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(u("fileOps.failedToDelete"))}},[e,_,y,u]),{toasts:eP,showToast:e$,removeToast:eL}=(0,th.pm)();(0,l.useEffect)(()=>{W&&(e$(b("stopPatternMatched"),"info"),B(!1))},[W,e$,b]);let{moveTarget:eI,isMoveDialogOpen:eD,handleMove:eF,handleMoveConfirm:eH,handleMoveCancel:eW}=function(e,t,r,a){let[s,n]=(0,l.useState)(null),[i,o]=(0,l.useState)(!1),c=(0,l.useCallback)((e,t)=>{n({path:e,type:t}),o(!0)},[]),d=(0,l.useCallback)(async l=>{if(s)try{let n=await fetch(`/api/worktrees/${e}/files/${s.path}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),i=await n.json();if(!n.ok||!i.success){let e=i.error?.message||"Failed to move";a?.(e);return}r?.("Moved successfully"),t()}catch{a?.("Failed to move")}finally{n(null),o(!1)}},[s,e,t,r,a]);return{moveTarget:s,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,l.useCallback)(()=>{n(null),o(!1)},[])}}(e,()=>Y(e=>e+1),e=>e$(e,"success"),e=>e$(e,"error")),eB=(0,l.useRef)(null),eG=(0,l.useRef)(""),eV=(0,l.useCallback)(e=>{eG.current=e,eB.current?.click()},[]),eq=(0,l.useCallback)(async()=>{try{let t;let r=await fetch(`/api/worktrees/${e}/tree`);if(!r.ok)throw Error(`Failed to list worktree files: ${r.status}`);if(((await r.json()).items??[]).some(e=>"CMATE.md"===e.name)){let r=await fetch(`/api/worktrees/${e}/files/CMATE.md`);if(!r.ok)throw Error(`Failed to read CMATE.md: ${r.status}`);let a=await r.json();if("string"!=typeof a.content){e$(v("cmateValidation.failed"),"error");return}t=a.content}else{if(!(await fetch(`/api/worktrees/${e}/files/CMATE.md`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:ro})})).ok)throw Error("Failed to create CMATE.md");e$(v("cmateCreated"),"success"),Y(e=>e+1),t=ro}let a=function(e){let t=[],r=e.split("\n"),a=!1;for(let e of r){let r=e.trim(),s=r.match(/^##\s+(.+)$/);if(s){a="Schedules"===s[1].trim();continue}if(!a||!r.startsWith("|"))continue;let n=r.split("|").slice(1,-1).map(e=>e.trim());for(let e=0;e<rl.length;e++){let r=rl[e],a=n[e];a&&a===r||t.push({row:-1,message:`Header column ${e+1}: expected "${r}", got "${a||"(missing)"}"`,field:"header"})}for(let e=0;e<ri.length;e++){let r=rl.length+e,a=ri[e],s=n[r];void 0!==s&&s!==a&&t.push({row:-1,message:`Header column ${r+1}: expected "${a}", got "${s}"`,field:"header"})}break}return t}(t),s=(function(e){let t=new Map,r=e.split("\n"),a=null,s=!1,n=!1;for(let e of r){let r=e.trim(),l=r.match(/^##\s+(.+)$/);if(l){a=l[1].trim(),s=!1,n=!1,t.has(a)||t.set(a,[]);continue}if(!r||!r.startsWith("|")||!a)continue;if(!s){s=!0;continue}if(!n){if(r.match(/^\|[\s-:|]+\|$/)){n=!0;continue}n=!0}let i=r.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(a).push(i)}return t})(t).get("Schedules");if(!s||0===s.length){e$(v("cmateValidation.noSchedulesSection"),"error");return}let n=function(e){let t=[];for(let r=0;r<e.length;r++){let a=e[r];if(a.length<3){t.push({row:r,message:`Row ${r+1}: insufficient columns (need at least 3, got ${a.length})`,field:"columns"});continue}let[s,n,l]=a,i=rr(s);ra.test(i)||t.push({row:r,message:`Row ${r+1}: invalid name "${i}"`,field:"name"}),!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(n)&&t.push({row:r,message:`Row ${r+1}: invalid cron "${n}"`,field:"cron"}),rr(l).trim()||t.push({row:r,message:`Row ${r+1}: empty message`,field:"message"});let o=a[5];if(void 0!==o&&""!==o.trim()){let e=o.trim(),s=a[3]?.trim()||"claude";("codex"===s?rn:rs).includes(e)||t.push({row:r,message:`Row ${r+1}: invalid permission "${e}" for ${s}`,field:"permission"})}}return t}(s),l=[...a,...n];if(0===l.length)e$(v("cmateValidation.valid",{count:String(s.length)}),"success");else{let e=l.slice(0,3).map(e=>e.message).join("; "),t=l.length>3?` (+${l.length-3})`:"";e$(v("cmateValidation.errors",{errorCount:String(l.length),details:e+t}),"error")}}catch(e){console.error("[WorktreeDetailRefactored] CMATE setup error:",e),e$(v("cmateValidation.failed"),"error")}},[e,e$,v]),eY=(0,l.useCallback)(async t=>{let r=t.target.files?.[0];if(!r)return;t.target.value="";let a=eG.current,s=`.${r.name.split(".").pop()?.toLowerCase()}`;if(!function(e){if(!e)return!1;let t=e.toLowerCase();return t_.includes(t)}(s)){e$(`Unsupported file type: ${s}. Allowed: ${t_.join(", ")}`,"error");return}let n=function(e){let t=function(e){let t=e.toLowerCase();return tR.find(e=>e.extension===t)}(e);return t?.maxFileSize??5242880}(s);if(r.size>n){e$(`File too large. Maximum size: ${(n/1024/1024).toFixed(1)}MB`,"error");return}let l=new FormData;l.append("file",r);try{let t=await fetch(`/api/worktrees/${e}/upload/${re(a||".")}`,{method:"POST",body:l});if(!t.ok){let e=await t.json().catch(()=>({})),r=e?.error?.message||"Failed to upload file";e$(r,"error");return}let r=await t.json();e$(`Uploaded: ${r.filename}`,"success"),Y(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),e$("Upload failed. Please try again.","error")}},[e,e$]),{data:eK}=tW(),eX=eK?.hasUpdate??!1,{lastAutoResponse:eJ}=function({worktreeId:e,cliTool:t,isPromptWaiting:r,promptData:a,autoYesEnabled:s,lastServerResponseTimestamp:n}){(0,l.useRef)(null);let[i,o]=(0,l.useState)(null);return{lastAutoResponse:i}}({worktreeId:e,cliTool:U,isPromptWaiting:o.prompt.visible,promptData:o.prompt.data,autoYesEnabled:I}),eQ=(0,l.useCallback)(async()=>{S(null),k(!0),await Q()&&await Promise.all([ee(),et()]),k(!1)},[Q,ee,et]),e1=(0,l.useRef)(0),e2=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-e1.current<5e3)){if(e1.current=e,C){eQ();return}try{await Promise.all([Q(),ee(),et()])}finally{S(null)}}},[C,eQ,Q,ee,et]);(0,l.useEffect)(()=>{if(K.current)return;let e=!0;return(async()=>{k(!0);let t=await Q();e&&(t&&await Promise.all([ee(),et()]),e&&(k(!1),K.current=!0))})(),()=>{e=!1}},[Q,ee,et]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",e2),()=>{document.removeEventListener("visibilitychange",e2)}),[e2]),(0,l.useEffect)(()=>{if(N||C)return;let e=setInterval(async()=>{await Promise.all([et(),Q(),ee()])},o.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[N,C,et,Q,ee,o.terminal.isActive]),(0,l.useEffect)(()=>{c.setLayoutMode(r?"tabs":"split")},[r,c]);let e4=(0,l.useMemo)(()=>(function(e,t,r="claude"){if(t)return"error";if(!e)return"idle";let a=e.sessionStatusByCli?.[r];if(a){if(a.isWaitingForResponse)return"waiting";if(a.isProcessing)return"running";if(a.isRunning)return"ready"}if("claude"===r){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(w,null!==o.error.type,U),[w,o.error.type,U]),e5=(0,l.useMemo)(()=>o.layout.mobileActivePane,[o.layout.mobileActivePane]),e3=(0,l.useMemo)(()=>o.layout.leftPaneTab,[o.layout.leftPaneTab]),e6=w?.name??"Unknown";return N?a.jsx(rh,{}):C?a.jsx(rf,{message:C,onRetry:eQ}):r?a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(ed,{worktreeName:e6,repositoryName:w?.repositoryName,status:e4,gitStatus:w?.gitStatus,onBackClick:ep,onMenuClick:i}),w?.gitStatus&&w.gitStatus.isBranchMismatch&&a.jsx("div",{className:"fixed top-14 inset-x-0 z-35",children:a.jsx(t5,{isBranchMismatch:w.gitStatus.isBranchMismatch,currentBranch:w.gitStatus.currentBranch,initialBranch:w.gitStatus.initialBranch})}),(0,a.jsxs)("div",{className:"fixed top-14 inset-x-0 z-30 flex items-center justify-between px-3 py-1.5 bg-gray-50 border-b border-gray-200",children:[a.jsx(t4,{enabled:I,expiresAt:F,onToggle:ek,lastAutoResponse:eJ,cliToolName:U,inline:!0}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("nav",{className:"flex gap-2","aria-label":"CLI Tool Selection",children:["claude","codex"].map(e=>{let t=(0,t3.He)(w?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>G(e),className:`px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ${U===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"}`,"aria-current":U===e?"page":void 0,children:["spinner"===r.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${r.className}`,title:r.label}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${r.className}`,title:r.label}),rc(e)]},e)})}),(0,a.jsxs)("button",{onClick:eT,disabled:!w?.sessionStatusByCli?.[U]?.isRunning,className:`flex items-center gap-0.5 px-1.5 py-0.5 text-xs font-medium rounded transition-colors ${w?.sessionStatusByCli?.[U]?.isRunning?"text-red-600 hover:bg-red-50":"invisible"}`,"aria-label":`End ${U} session`,children:[a.jsx("span",{"aria-hidden":"true",children:"✕"}),"End"]})]})]}),a.jsx("main",{className:"flex-1 pt-[6.25rem] pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(rg,{activeTab:e5,worktreeId:e,worktree:w,messages:o.messages,terminalOutput:o.terminal.output,isTerminalActive:o.terminal.isActive,isThinking:o.terminal.isThinking,onFilePathClick:ea,onFileSelect:es,onWorktreeUpdate:j,onNewFile:eA,onNewDirectory:eR,onRename:e_,onDelete:eO,onUpload:eV,onMove:eF,refreshTrigger:q,fileSearch:Z,showToast:e$,onCmateSetup:eq})}),a.jsx("div",{className:"fixed left-0 right-0 border-t border-gray-200 bg-white p-2 z-30",style:{bottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(ew.R,{worktreeId:e,onMessageSent:eN,cliToolId:U,isSessionRunning:o.terminal.isActive})}),a.jsx(ef,{activeTab:e5,onTabChange:ev,hasNewOutput:!1,hasPrompt:o.prompt.visible,hasUpdate:eX}),!I&&a.jsx(eg,{promptData:o.prompt.data,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:ey,onDismiss:eb}),a.jsx(e0,{isOpen:null!==A,onClose:eo,worktreeId:e,filePath:A??""}),_&&a.jsx(tJ.u,{isOpen:!0,onClose:ec,title:_.split("/").pop()||"Editor",size:"full",disableClose:P,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:_,onClose:ec,onSave:eu,onMaximizedChange:L})})}),a.jsx("input",{ref:eB,type:"file",accept:t_.join(","),onChange:eY,className:"hidden","aria-label":"Upload file"}),a.jsx(tJ.u,{isOpen:eC,onClose:eM,title:d("session.confirmEnd",{tool:rc(U)}),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:eM,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:y("cancel")}),a.jsx("button",{type:"button",onClick:eE,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:y("end")})]})]})}),eI&&a.jsx(t9,{isOpen:eD,onClose:eW,onConfirm:eH,worktreeId:e,sourcePath:eI.path,sourceType:eI.type}),a.jsx(th.Ix,{toasts:eP,onClose:eL})]})}):a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col relative",children:[a.jsx(rm,{worktreeName:e6,repositoryName:w?.repositoryName??"Unknown",description:w?.description,status:e4,gitStatus:w?.gitStatus,onBackClick:ep,onInfoClick:eh,onMenuClick:n,hasUpdate:eX}),(0,a.jsxs)("div",{className:"px-4 py-2 bg-white border-b border-gray-200 flex items-center justify-between",children:[a.jsx("nav",{className:"flex gap-4","aria-label":"CLI Tool Selection",children:["claude","codex"].map(e=>{let t=(0,t3.He)(w?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>G(e),className:`pb-2 px-2 border-b-2 font-medium text-sm transition-colors flex items-center gap-1.5 ${U===e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,"aria-current":U===e?"page":void 0,children:["spinner"===r.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${r.className}`,title:r.label,"aria-label":`${e} status: ${r.label}`}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${r.className}`,title:r.label,"aria-label":`${e} status: ${r.label}`}),rc(e)]},e)})}),w?.sessionStatusByCli?.[U]?.isRunning&&(0,a.jsxs)("button",{onClick:eT,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-red-600 hover:text-red-800 hover:bg-red-50 rounded transition-colors","aria-label":`End ${U} session`,children:[a.jsx("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),w?.gitStatus&&a.jsx(t5,{isBranchMismatch:w.gitStatus.isBranchMismatch,currentBranch:w.gitStatus.currentBranch,initialBranch:w.gitStatus.initialBranch}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(M,{leftPane:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eZ,{activeTab:e3,onTabChange:em}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===e3&&a.jsx(X,{messages:o.messages,worktreeId:e,onFilePathClick:ea,className:"h-full",showToast:e$}),"files"===e3&&a.jsx(g,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eU,{query:Z.query,mode:Z.mode,isSearching:Z.isSearching,error:Z.error,onQueryChange:Z.setQuery,onModeChange:Z.setMode,onClear:Z.clearSearch}),a.jsx(ez,{worktreeId:e,onFileSelect:es,onNewFile:eA,onNewDirectory:eR,onRename:e_,onDelete:eO,onUpload:eV,onMove:eF,onCmateSetup:eq,refreshTrigger:q,searchQuery:Z.query,searchMode:Z.mode,searchResults:Z.results?.results,className:"flex-1 min-h-0"})]})}),"memo"===e3&&a.jsx(g,{componentName:"NotesAndLogsPane",children:a.jsx(tz,{worktreeId:e,className:"h-full"})})]})]}),rightPane:a.jsx($,{output:o.terminal.output,isActive:o.terminal.isActive,isThinking:o.terminal.isThinking,autoScroll:o.terminal.autoScroll,onScrollChange:ej}),initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),a.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 p-4 bg-gray-50",children:a.jsx(ew.R,{worktreeId:e,onMessageSent:eN,cliToolId:U,isSessionRunning:o.terminal.isActive})}),a.jsx(t4,{enabled:I,expiresAt:F,onToggle:ek,lastAutoResponse:eJ,cliToolName:U}),o.prompt.visible&&!I&&a.jsx("div",{className:"fixed bottom-20 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-2xl px-4",children:a.jsx(en,{promptData:o.prompt.data,messageId:o.prompt.messageId,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:ey,onDismiss:eb})}),a.jsx(rp,{worktreeId:e,worktree:w,isOpen:T,onClose:ex,onWorktreeUpdate:j}),a.jsx(e0,{isOpen:null!==A,onClose:eo,worktreeId:e,filePath:A??""}),_&&a.jsx(tJ.u,{isOpen:!0,onClose:ec,title:_.split("/").pop()||"Editor",size:"full",disableClose:P,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:_,onClose:ec,onSave:eu,onMaximizedChange:L})})}),a.jsx("input",{ref:eB,type:"file",accept:t_.join(","),onChange:eY,className:"hidden","aria-label":"Upload file"}),a.jsx(tJ.u,{isOpen:eC,onClose:eM,title:d("session.confirmEnd",{tool:rc(U)}),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:eM,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:y("cancel")}),a.jsx("button",{type:"button",onClick:eE,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:y("end")})]})]})}),eI&&a.jsx(t9,{isOpen:eD,onClose:eW,onConfirm:eH,worktreeId:e,sourcePath:eI.path,sourceType:eI.type}),a.jsx(th.Ix,{toasts:eP,onClose:eL})]})})});function rb(){let e=(0,s.useParams)().id;return a.jsx(n.Vw,{children:a.jsx(ry,{worktreeId:e})})}},81194:(e,t,r)=>{"use strict";r.d(t,{O:()=>n});var a=r(10326),s=r(17577);function n({src:e,alt:t,onError:r}){let[n,l]=(0,s.useState)(!1);return n?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[a.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),a.jsx("p",{className:"text-sm",children:"Failed to load image"}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t})]}):a.jsx("div",{className:"flex items-center justify-center p-4",children:a.jsx("img",{src:e,alt:t,onError:()=>{l(!0),r?.()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},89918:(e,t,r)=>{"use strict";r.d(t,{R:()=>n});var a=r(10326),s=r(17577);function n({src:e,onError:t}){let[r,n]=(0,s.useState)(!0),[l,i]=(0,s.useState)(!1);return l?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[a.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),a.jsx("p",{className:"text-sm",children:"Failed to load video"})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[r&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"ml-3 text-gray-600",children:"Loading video..."})]}),a.jsx("video",{controls:!0,src:e,onLoadedData:()=>{n(!1)},onError:()=>{n(!1),i(!0),t?.()},style:{maxWidth:"100%",maxHeight:"500px",display:r?"none":"block"},className:"rounded-lg shadow-sm",children:"Your browser does not support the video tag."})]})}},22570:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>a});let a=(0,r(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx#default`)},4803:()=>{},63817:(e,t,r)=>{"use strict";let a=r(51387),s=a.types;function n(e,t){var r;t||(t={});let n=void 0===t.limit?25:t.limit;(r=e,"[object RegExp]"===({}).toString.call(r))?e=e.source:"string"!=typeof e&&(e=String(e));try{e=a(e)}catch{return!1}let l=0;return function e(t,r){let a,i;if(t.type===s.REPETITION&&(r++,l++,r>1||l>n))return!1;if(t.options){for(a=0,i=t.options.length;a<i;a++)if(!e({stack:t.options[a]},r))return!1}let o=t.stack||t.value?.stack;if(!o)return!0;for(a=0;a<o.length;a++)if(!e(o[a],r))return!1;return!0}(e,0)}e.exports=n,e.exports.default=n,e.exports.safeRegex=n}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,3294,6621,8705,7458,7808,3860,539],()=>r(80205));module.exports=a})();
14
+ `;function rm(e,t,r,a){let[s,n]=(0,l.useState)(!1),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1),u=(0,l.useCallback)(async()=>{if(e){d(!0);try{let r=await tO.Iv.updateDescription(e.id,i);t(r),n(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,l.useCallback)(()=>{o(e?.description||""),n(!1)},[e]);return{isEditing:s,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,l.useCallback)(()=>{n(!0)},[])}}let rp=(0,l.memo)(function({worktreeId:e,worktree:t,cardClassName:r,descriptionEditor:s,showLogs:n,onToggleLogs:l}){let{isEditing:i,text:o,setText:c,isSaving:d,handleSave:u,handleCancel:m,startEditing:p}=s;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Worktree"}),a.jsx("p",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),a.jsx("p",{className:"text-base text-gray-900",children:t.repositoryName}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 break-all",children:t.repositoryPath})]}),(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Path"}),a.jsx("p",{className:"text-sm text-gray-700 break-all font-mono",children:t.path})]}),t.status&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Status"}),a.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${"done"===t.status?"bg-green-100 text-green-800":"doing"===t.status?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:t.status.toUpperCase()})]}),(0,a.jsxs)("div",{className:r,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Description"}),!i&&a.jsx("button",{type:"button",onClick:p,className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),i?(0,a.jsxs)("div",{className:"space-y-3",children:[a.jsx("textarea",{value:o,onChange:e=>c(e.target.value),placeholder:"Add notes about this branch...",className:"w-full min-h-[150px] p-3 border border-gray-300 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:u,disabled:d,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:d?"Saving...":"Save"}),a.jsx("button",{type:"button",onClick:m,disabled:d,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 disabled:opacity-50 text-sm font-medium",children:"Cancel"})]})]}):a.jsx("div",{className:"min-h-[50px]",children:t.description?a.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:t.description}):a.jsx("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),t.link&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Link"}),a.jsx("a",{href:t.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline break-all",children:t.link})]}),t.updatedAt&&(0,a.jsxs)("div",{className:r,children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Last Updated"}),a.jsx("p",{className:"text-sm text-gray-700",children:new Date(t.updatedAt).toLocaleString()})]}),a.jsx(tq,{version:"v0.3.3",className:r}),a.jsx(t0,{className:r}),(0,a.jsxs)("div",{className:r,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Logs"}),a.jsx("button",{type:"button",onClick:l,className:"text-sm text-blue-600 hover:text-blue-800",children:n?"Hide":"Show"})]}),n&&a.jsx(tU.n,{worktreeId:e})]})]})}),rh=(0,l.memo)(function({worktreeName:e,repositoryName:t,description:r,status:s,gitStatus:n,onBackClick:l,onInfoClick:i,onMenuClick:o,hasUpdate:c}){let d=el.Ie[s],u=r?(0,ei.aS)(r,50):null;return(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:o,className:"p-2 -ml-2 rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-100 transition-colors","aria-label":"Toggle sidebar",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),(0,a.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-gray-600 hover:text-gray-900 transition-colors","aria-label":"Go back to worktree list",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),a.jsx("span",{className:"text-sm font-medium",children:"Back"})]}),a.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),"spinner"===d.type?a.jsx("span",{"data-testid":"desktop-status-indicator",title:d.label,"aria-label":d.label,className:`w-3 h-3 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${d.className}`}):a.jsx("span",{"data-testid":"desktop-status-indicator",title:d.label,"aria-label":d.label,className:`w-3 h-3 rounded-full flex-shrink-0 ${d.className}`}),(0,a.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("h1",{className:"text-lg font-semibold text-gray-900 truncate max-w-[200px] leading-tight",children:e}),u&&a.jsx("span",{className:"text-sm text-gray-500 truncate max-w-md",title:r,children:u})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[a.jsx("span",{className:"truncate max-w-[200px]",children:t}),n&&"(unknown)"!==n.currentBranch&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-300",children:"/"}),a.jsx("span",{className:"truncate max-w-[150px] font-mono",title:n.currentBranch,"data-testid":"desktop-branch-name",children:(0,ei.aS)(n.currentBranch,30)}),n.isDirty&&a.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors","aria-label":"View worktree information",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{className:"text-sm font-medium",children:"Info"}),c&&a.jsx(eu,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":"Update available"})]})]})}),rf=(0,l.memo)(function({worktreeId:e,worktree:t,isOpen:r,onClose:s,onWorktreeUpdate:n}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(r),d=rm(t,n,r,()=>{let e=r&&!c.current;return c.current=r,e});return t?a.jsx(t1.u,{isOpen:r,onClose:s,title:"Worktree Information",size:"md",children:a.jsx("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:a.jsx(rp,{worktreeId:e,worktree:t,cardClassName:"bg-gray-50 rounded-lg p-4",descriptionEditor:d,showLogs:i,onToggleLogs:()=>o(!i)})})}):null}),rx=(0,l.memo)(function(){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600","aria-hidden":"true"}),a.jsx("p",{className:"text-gray-600",children:"Loading worktree..."})]})})}),rg=(0,l.memo)(function({message:e,onRetry:t}){return a.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,a.jsxs)("div",{className:"text-center p-6 bg-red-50 rounded-lg border border-red-200 max-w-md",children:[a.jsx("svg",{className:"mx-auto h-12 w-12 text-red-400 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-red-600 font-medium",children:"Error loading worktree"}),a.jsx("p",{className:"text-red-500 text-sm mt-2",children:e}),t&&a.jsx("button",{type:"button",onClick:t,className:"mt-4 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2",children:"Retry"})]})})}),rb=(0,l.memo)(function({worktreeId:e,worktree:t,onWorktreeUpdate:r}){let[s,n]=(0,l.useState)(!1),i=(0,l.useRef)(t?.id),o=(0,l.useRef)(!1),c=rm(t,r,t?.id,()=>{let e=t?.id!==i.current;return i.current=t?.id,e&&!o.current});return(o.current=c.isEditing,t)?a.jsx("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:a.jsx(rp,{worktreeId:e,worktree:t,cardClassName:"bg-white rounded-lg border border-gray-200 p-4",descriptionEditor:c,showLogs:s,onToggleLogs:()=>n(!s)})}):a.jsx("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),ry=(0,l.memo)(function({activeTab:e,worktreeId:t,worktree:r,messages:s,terminalOutput:n,isTerminalActive:l,isThinking:i,onFilePathClick:o,onFileSelect:c,onWorktreeUpdate:d,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,onMove:x,refreshTrigger:b,fileSearch:y,showToast:v,onCmateSetup:w,selectedAgents:j,onSelectedAgentsChange:N,vibeLocalModel:k,onVibeLocalModelChange:C}){switch(e){case"terminal":return a.jsx(g,{componentName:"TerminalDisplay",children:a.jsx($,{output:n,isActive:l,isThinking:i,className:"h-full"})});case"history":return a.jsx(g,{componentName:"HistoryPane",children:a.jsx(X,{messages:s,worktreeId:t,onFilePathClick:o,className:"h-full",showToast:v})});case"files":return a.jsx(g,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eU,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),a.jsx(ez,{worktreeId:t,onFileSelect:c,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,onMove:x,onCmateSetup:w,refreshTrigger:b,searchQuery:y.query,searchMode:y.mode,searchResults:y.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return a.jsx(g,{componentName:"NotesAndLogsPane",children:a.jsx(tB,{worktreeId:t,className:"h-full",selectedAgents:j,onSelectedAgentsChange:N,vibeLocalModel:k,onVibeLocalModelChange:C})});case"info":return a.jsx(rb,{worktreeId:t,worktree:r,onWorktreeUpdate:d});default:return null}}),rv=(0,l.memo)(function({worktreeId:e}){let t=(0,s.useRouter)(),r=(0,h.d)(),{toggle:n,openMobileDrawer:i}=(0,f.Sz)(),{state:o,actions:c}=function(){let[e,t]=(0,l.useReducer)(p,void 0,m),r=(0,l.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),setTerminalOutput:(e,r)=>t({type:"SET_TERMINAL_OUTPUT",output:e,realtimeSnippet:r}),setTerminalActive:e=>t({type:"SET_TERMINAL_ACTIVE",isActive:e}),setTerminalThinking:e=>t({type:"SET_TERMINAL_THINKING",isThinking:e}),showPrompt:(e,r)=>t({type:"SHOW_PROMPT",data:e,messageId:r}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,r)=>t({type:"UPDATE_MESSAGE",id:e,updates:r}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),startWaitingForResponse:e=>t({type:"START_WAITING_FOR_RESPONSE",cliToolId:e}),responseReceived:e=>t({type:"RESPONSE_RECEIVED",message:e}),sessionEnded:()=>t({type:"SESSION_ENDED"}),setAutoScroll:e=>t({type:"SET_AUTO_SCROLL",enabled:e}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e})}),[]);return{state:e,dispatch:t,actions:r}}(),d=(0,x.T)("worktree"),u=(0,x.T)("error"),b=(0,x.T)("common"),y=(0,x.T)("autoYes"),v=(0,x.T)("schedule"),[w,j]=(0,l.useState)(null),[N,k]=(0,l.useState)(!0),[C,S]=(0,l.useState)(null),[T,E]=(0,l.useState)(!1),[A,R]=(0,l.useState)(null),[_,O]=(0,l.useState)(null),[P,L]=(0,l.useState)(!1),[I,D]=(0,l.useState)(!1),[F,z]=(0,l.useState)(null),H=(0,l.useRef)(!1),[W,B]=(0,l.useState)(!1),[U,G]=(0,l.useState)(t8.Fq),[V,q]=(0,l.useState)(null),[Y,Z]=(0,l.useState)(t8.Fq[0]),K=(0,l.useRef)(Y);K.current=Y;let[J,Q]=(0,l.useState)(0),ee=function(e){let{worktreeId:t,initialMode:r="name",debounceMs:a=300}=e,[s,n]=(0,l.useState)(""),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(r),[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(null),[f,x]=(0,l.useState)(null),g=(0,l.useRef)(null),b=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{o(e)},a),[a]),y=(0,l.useCallback)(e=>{n(e),b(e),x(null)},[b]),v=(0,l.useCallback)(()=>{n(""),o(""),h(null),x(null),m(!1),g.current&&(g.current.abort(),g.current=null)},[]),w=(0,l.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),j=(0,l.useCallback)(()=>p&&0!==p.results.length?(0,ei.Ps)(p.results.map(e=>e.filePath)):new Set,[p]);return{query:s,mode:c,isSearching:u,results:p,error:f,setQuery:y,setMode:d,clearSearch:v,filterByName:w,getMatchedPaths:j}}({worktreeId:e}),et=(0,l.useRef)(!1),er=(0,l.useRef)(e);(0,l.useEffect)(()=>{er.current!==e&&(c.clearMessages(),et.current=!1,c.setTerminalOutput("",""),er.current=e)},[e,c]);let ea=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}`);if(!t.ok)throw Error(`Failed to fetch worktree: ${t.status}`);let r=await t.json();return j(r),r.selectedAgents&&G(r.selectedAgents),"vibeLocalModel"in r&&q(r.vibeLocalModel??null),r}catch(e){return S(e instanceof Error?e.message:"Unknown error"),null}},[e]),es=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/messages?cliTool=${K.current}`);if(!t.ok)throw Error(`Failed to fetch messages: ${t.status}`);let r=await t.json();c.setMessages(r.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[e,c]),eo=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/current-output?cliTool=${K.current}`);if(!t.ok)return;let r=await t.json(),a=r.fullOutput??r.realtimeSnippet??"";if((a||r.isRunning)&&c.setTerminalOutput(a,r.realtimeSnippet??""),c.setTerminalActive(r.isRunning??!1),c.setTerminalThinking(r.thinking??!1),r.isPromptWaiting&&r.promptData?c.showPrompt(r.promptData,`prompt-${Date.now()}`):!r.isPromptWaiting&&o.prompt.visible&&c.clearPrompt(),r.autoYes){let e=H.current;D(r.autoYes.enabled),z(r.autoYes.expiresAt),H.current=r.autoYes.enabled,e&&!r.autoYes.enabled&&"stop_pattern_matched"===r.autoYes.stopReason&&B(!0)}}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[e,c,o.prompt.visible]);(0,l.useEffect)(()=>{U.includes(Y)||Z(U[0])},[U,Y]);let ec=(0,l.useCallback)(e=>{G(e)},[]),eu=(0,l.useCallback)(e=>{q(e)},[]),em=(0,l.useRef)(Y);(0,l.useEffect)(()=>{em.current!==Y&&(em.current=Y,c.clearMessages(),c.setTerminalOutput("",""),es(),eo())},[Y,c,es,eo]);let ep=(0,l.useCallback)(e=>{R(e)},[]),eh=(0,l.useCallback)(e=>{let t=e.split(".").pop()?.toLowerCase(),r=t?`.${t}`:"";tA.includes(r)?O(e):R(e)},[]),ex=(0,l.useCallback)(()=>{R(null)},[]),eb=(0,l.useCallback)(()=>{O(null)},[]),ey=(0,l.useCallback)(e=>{Q(e=>e+1)},[]),ev=(0,l.useCallback)(e=>{c.setLeftPaneTab(e)},[c]),ej=(0,l.useCallback)(()=>{t.push("/")},[t]),eN=(0,l.useCallback)(()=>{E(!0)},[]),ek=(0,l.useCallback)(()=>{E(!1)},[]),eC=(0,l.useCallback)(async t=>{c.setPromptAnswering(!0);try{let r=function(e,t,r){let a={answer:e,cliTool:t};if(r&&(a.promptType=r.type,"multiple_choice"===r.type)){let e=r.options.find(e=>e.isDefault);e&&(a.defaultOptionNumber=e.number)}return a}(t,Y,o.prompt.data),a=await fetch(`/api/worktrees/${e}/prompt-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw Error(`Failed to send prompt response: ${a.status}`);c.clearPrompt(),await eo()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{c.setPromptAnswering(!1)}},[e,c,eo,Y,o.prompt.data]),eS=(0,l.useCallback)(()=>{c.clearPrompt()},[c]),eT=(0,l.useCallback)(e=>{c.setMobileActivePane(e)},[c]),eE=(0,l.useCallback)(e=>{c.setAutoScroll(e)},[c]),eM=(0,l.useCallback)(()=>{es(),eo()},[es,eo]),eA=(0,l.useCallback)(async t=>{try{let r=await fetch(`/api/worktrees/${e}/auto-yes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t.enabled,cliToolId:Y,duration:t.duration,stopPattern:t.stopPattern})});if(r.ok){let e=await r.json();D(e.enabled),z(e.expiresAt),H.current=e.enabled}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[e,Y]),[eR,e_]=(0,l.useState)(!1),eO=(0,l.useCallback)(()=>{e_(!0)},[]),eP=(0,l.useCallback)(async()=>{e_(!1);try{if(!(await fetch(`/api/worktrees/${e}/kill-session?cliTool=${Y}`,{method:"POST"})).ok)return;c.clearMessages(),c.setTerminalOutput("",""),c.setTerminalActive(!1),c.setTerminalThinking(!1),c.clearPrompt(),await ea()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[e,Y,c,ea]),e$=(0,l.useCallback)(()=>{e_(!1)},[]),eL=(0,l.useCallback)(async t=>{let r=window.prompt("Enter file name (e.g., document.md):");if(!r)return;let a=r.endsWith(".md")?r:`${r}.md`,s=t?`${t}/${a}`:a;try{if(!(await fetch(`/api/worktrees/${e}/files/${ra(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");Q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert(u("fileOps.failedToCreateFile"))}},[e,u]),eI=(0,l.useCallback)(async t=>{let r=window.prompt("Enter directory name:");if(!r)return;let a=t?`${t}/${r}`:r;try{if(!(await fetch(`/api/worktrees/${e}/files/${ra(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");Q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(u("fileOps.failedToCreateDirectory"))}},[e,u]),eD=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||"",a=window.prompt("Enter new name:",r);if(a&&a!==r)try{if(!(await fetch(`/api/worktrees/${e}/files/${ra(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:a})})).ok)throw Error("Failed to rename");Q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(u("fileOps.failedToRename"))}},[e,u]),eF=(0,l.useCallback)(async t=>{let r=t.split("/").pop()||t;if(window.confirm(b("confirmDelete",{name:r})))try{if(!(await fetch(`/api/worktrees/${e}/files/${ra(t)}?recursive=true`,{method:"DELETE"})).ok)throw Error("Failed to delete");(_===t||_?.startsWith(`${t}/`))&&O(null),Q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(u("fileOps.failedToDelete"))}},[e,_,b,u]),{toasts:eH,showToast:eW,removeToast:eB}=(0,th.pm)();(0,l.useEffect)(()=>{W&&(eW(y("stopPatternMatched"),"info"),B(!1))},[W,eW,y]);let{moveTarget:eG,isMoveDialogOpen:eV,handleMove:eq,handleMoveConfirm:eY,handleMoveCancel:eK}=function(e,t,r,a){let[s,n]=(0,l.useState)(null),[i,o]=(0,l.useState)(!1),c=(0,l.useCallback)((e,t)=>{n({path:e,type:t}),o(!0)},[]),d=(0,l.useCallback)(async l=>{if(s)try{let n=await fetch(`/api/worktrees/${e}/files/${s.path}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),i=await n.json();if(!n.ok||!i.success){let e=i.error?.message||"Failed to move";a?.(e);return}r?.("Moved successfully"),t()}catch{a?.("Failed to move")}finally{n(null),o(!1)}},[s,e,t,r,a]);return{moveTarget:s,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,l.useCallback)(()=>{n(null),o(!1)},[])}}(e,()=>Q(e=>e+1),e=>eW(e,"success"),e=>eW(e,"error")),eX=(0,l.useRef)(null),eJ=(0,l.useRef)(""),eQ=(0,l.useCallback)(e=>{eJ.current=e,eX.current?.click()},[]),e1=(0,l.useCallback)(async()=>{try{let t;let r=await fetch(`/api/worktrees/${e}/tree`);if(!r.ok)throw Error(`Failed to list worktree files: ${r.status}`);if(((await r.json()).items??[]).some(e=>"CMATE.md"===e.name)){let r=await fetch(`/api/worktrees/${e}/files/CMATE.md`);if(!r.ok)throw Error(`Failed to read CMATE.md: ${r.status}`);let a=await r.json();if("string"!=typeof a.content){eW(v("cmateValidation.failed"),"error");return}t=a.content}else{if(!(await fetch(`/api/worktrees/${e}/files/CMATE.md`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:ru})})).ok)throw Error("Failed to create CMATE.md");eW(v("cmateCreated"),"success"),Q(e=>e+1),t=ru}let a=function(e){let t=[],r=e.split("\n"),a=!1;for(let e of r){let r=e.trim(),s=r.match(/^##\s+(.+)$/);if(s){a="Schedules"===s[1].trim();continue}if(!a||!r.startsWith("|"))continue;let n=r.split("|").slice(1,-1).map(e=>e.trim());for(let e=0;e<rc.length;e++){let r=rc[e],a=n[e];a&&a===r||t.push({row:-1,message:`Header column ${e+1}: expected "${r}", got "${a||"(missing)"}"`,field:"header"})}for(let e=0;e<rd.length;e++){let r=rc.length+e,a=rd[e],s=n[r];void 0!==s&&s!==a&&t.push({row:-1,message:`Header column ${r+1}: expected "${a}", got "${s}"`,field:"header"})}break}return t}(t),s=(function(e){let t=new Map,r=e.split("\n"),a=null,s=!1,n=!1;for(let e of r){let r=e.trim(),l=r.match(/^##\s+(.+)$/);if(l){a=l[1].trim(),s=!1,n=!1,t.has(a)||t.set(a,[]);continue}if(!r||!r.startsWith("|")||!a)continue;if(!s){s=!0;continue}if(!n){if(r.match(/^\|[\s-:|]+\|$/)){n=!0;continue}n=!0}let i=r.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(a).push(i)}return t})(t).get("Schedules");if(!s||0===s.length){eW(v("cmateValidation.noSchedulesSection"),"error");return}let n=function(e){let t=[];for(let r=0;r<e.length;r++){let a=e[r];if(a.length<3){t.push({row:r,message:`Row ${r+1}: insufficient columns (need at least 3, got ${a.length})`,field:"columns"});continue}let[s,n,l]=a,i=rn(s);rl.test(i)||t.push({row:r,message:`Row ${r+1}: invalid name "${i}"`,field:"name"}),!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(n)&&t.push({row:r,message:`Row ${r+1}: invalid cron "${n}"`,field:"cron"}),rn(l).trim()||t.push({row:r,message:`Row ${r+1}: empty message`,field:"message"});let o=a[5];if(void 0!==o&&""!==o.trim()){let e=o.trim(),s=a[3]?.trim()||"claude";("codex"===s?ro:ri).includes(e)||t.push({row:r,message:`Row ${r+1}: invalid permission "${e}" for ${s}`,field:"permission"})}}return t}(s),l=[...a,...n];if(0===l.length)eW(v("cmateValidation.valid",{count:String(s.length)}),"success");else{let e=l.slice(0,3).map(e=>e.message).join("; "),t=l.length>3?` (+${l.length-3})`:"";eW(v("cmateValidation.errors",{errorCount:String(l.length),details:e+t}),"error")}}catch(e){console.error("[WorktreeDetailRefactored] CMATE setup error:",e),eW(v("cmateValidation.failed"),"error")}},[e,eW,v]),e2=(0,l.useCallback)(async t=>{let r=t.target.files?.[0];if(!r)return;t.target.value="";let a=eJ.current,s=`.${r.name.split(".").pop()?.toLowerCase()}`;if(!function(e){if(!e)return!1;let t=e.toLowerCase();return t_.includes(t)}(s)){eW(`Unsupported file type: ${s}. Allowed: ${t_.join(", ")}`,"error");return}let n=function(e){let t=function(e){let t=e.toLowerCase();return tR.find(e=>e.extension===t)}(e);return t?.maxFileSize??5242880}(s);if(r.size>n){eW(`File too large. Maximum size: ${(n/1024/1024).toFixed(1)}MB`,"error");return}let l=new FormData;l.append("file",r);try{let t=await fetch(`/api/worktrees/${e}/upload/${ra(a||".")}`,{method:"POST",body:l});if(!t.ok){let e=await t.json().catch(()=>({})),r=e?.error?.message||"Failed to upload file";eW(r,"error");return}let r=await t.json();eW(`Uploaded: ${r.filename}`,"success"),Q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),eW("Upload failed. Please try again.","error")}},[e,eW]),{data:e4}=tG(),e5=e4?.hasUpdate??!1,{lastAutoResponse:e3}=function({worktreeId:e,cliTool:t,isPromptWaiting:r,promptData:a,autoYesEnabled:s,lastServerResponseTimestamp:n}){(0,l.useRef)(null);let[i,o]=(0,l.useState)(null);return{lastAutoResponse:i}}({worktreeId:e,cliTool:Y,isPromptWaiting:o.prompt.visible,promptData:o.prompt.data,autoYesEnabled:I}),e6=(0,l.useCallback)(async()=>{S(null),k(!0),await ea()&&await Promise.all([es(),eo()]),k(!1)},[ea,es,eo]),e8=(0,l.useRef)(0),e7=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-e8.current<5e3)){if(e8.current=e,C){e6();return}try{await Promise.all([ea(),es(),eo()])}finally{S(null)}}},[C,e6,ea,es,eo]);(0,l.useEffect)(()=>{if(et.current)return;let e=!0;return(async()=>{k(!0);let t=await ea();e&&(t&&await Promise.all([es(),eo()]),e&&(k(!1),et.current=!0))})(),()=>{e=!1}},[ea,es,eo]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",e7),()=>{document.removeEventListener("visibilitychange",e7)}),[e7]),(0,l.useEffect)(()=>{if(N||C)return;let e=setInterval(async()=>{await Promise.all([eo(),ea(),es()])},o.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[N,C,eo,ea,es,o.terminal.isActive]),(0,l.useEffect)(()=>{c.setLayoutMode(r?"tabs":"split")},[r,c]);let e9=(0,l.useMemo)(()=>(function(e,t,r="claude"){if(t)return"error";if(!e)return"idle";let a=e.sessionStatusByCli?.[r];if(a){if(a.isWaitingForResponse)return"waiting";if(a.isProcessing)return"running";if(a.isRunning)return"ready"}if("claude"===r){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(w,null!==o.error.type,Y),[w,o.error.type,Y]),te=(0,l.useMemo)(()=>o.layout.mobileActivePane,[o.layout.mobileActivePane]),tt=(0,l.useMemo)(()=>o.layout.leftPaneTab,[o.layout.leftPaneTab]),tr=w?.name??"Unknown";return N?a.jsx(rx,{}):C?a.jsx(rg,{message:C,onRetry:e6}):r?a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(ed,{worktreeName:tr,repositoryName:w?.repositoryName,status:e9,gitStatus:w?.gitStatus,onBackClick:ej,onMenuClick:i}),w?.gitStatus&&w.gitStatus.isBranchMismatch&&a.jsx("div",{className:"fixed top-14 inset-x-0 z-35",children:a.jsx(t6,{isBranchMismatch:w.gitStatus.isBranchMismatch,currentBranch:w.gitStatus.currentBranch,initialBranch:w.gitStatus.initialBranch})}),(0,a.jsxs)("div",{className:"fixed top-14 inset-x-0 z-30 flex items-center justify-between px-3 py-1.5 bg-gray-50 border-b border-gray-200",children:[a.jsx(t3,{enabled:I,expiresAt:F,onToggle:eA,lastAutoResponse:e3,cliToolName:Y,inline:!0}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("nav",{className:"flex gap-2","aria-label":"CLI Tool Selection",children:U.map(e=>{let t=(0,t7.He)(w?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>Z(e),className:`px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ${Y===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"}`,"aria-current":Y===e?"page":void 0,children:["spinner"===r.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${r.className}`,title:r.label}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${r.className}`,title:r.label}),(0,tz.Ds)(e)]},e)})}),(0,a.jsxs)("button",{onClick:eO,disabled:!w?.sessionStatusByCli?.[Y]?.isRunning,className:`flex items-center gap-0.5 px-1.5 py-0.5 text-xs font-medium rounded transition-colors ${w?.sessionStatusByCli?.[Y]?.isRunning?"text-red-600 hover:bg-red-50":"invisible"}`,"aria-label":`End ${Y} session`,children:[a.jsx("span",{"aria-hidden":"true",children:"✕"}),"End"]})]})]}),a.jsx("main",{className:"flex-1 pt-[6.25rem] pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(ry,{activeTab:te,worktreeId:e,worktree:w,messages:o.messages,terminalOutput:o.terminal.output,isTerminalActive:o.terminal.isActive,isThinking:o.terminal.isThinking,onFilePathClick:ep,onFileSelect:eh,onWorktreeUpdate:j,onNewFile:eL,onNewDirectory:eI,onRename:eD,onDelete:eF,onUpload:eQ,onMove:eq,refreshTrigger:J,fileSearch:ee,showToast:eW,onCmateSetup:e1,selectedAgents:U,onSelectedAgentsChange:ec,vibeLocalModel:V,onVibeLocalModelChange:eu})}),a.jsx("div",{className:"fixed left-0 right-0 border-t border-gray-200 bg-white p-2 z-30",style:{bottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:a.jsx(ew.R,{worktreeId:e,onMessageSent:eM,cliToolId:Y,isSessionRunning:o.terminal.isActive})}),a.jsx(ef,{activeTab:te,onTabChange:eT,hasNewOutput:!1,hasPrompt:o.prompt.visible,hasUpdate:e5}),!I&&a.jsx(eg,{promptData:o.prompt.data,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:eC,onDismiss:eS,cliToolName:(0,tz.Ds)(Y)}),a.jsx(e0,{isOpen:null!==A,onClose:ex,worktreeId:e,filePath:A??""}),_&&a.jsx(t1.u,{isOpen:!0,onClose:eb,title:_.split("/").pop()||"Editor",size:"full",disableClose:P,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:_,onClose:eb,onSave:ey,onMaximizedChange:L})})}),a.jsx("input",{ref:eX,type:"file",accept:t_.join(","),onChange:e2,className:"hidden","aria-label":"Upload file"}),a.jsx(t1.u,{isOpen:eR,onClose:e$,title:d("session.confirmEnd",{tool:(0,tz.Ds)(Y)}),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:e$,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:b("cancel")}),a.jsx("button",{type:"button",onClick:eP,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:b("end")})]})]})}),eG&&a.jsx(rr,{isOpen:eV,onClose:eK,onConfirm:eY,worktreeId:e,sourcePath:eG.path,sourceType:eG.type}),a.jsx(th.Ix,{toasts:eH,onClose:eB})]})}):a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col relative",children:[a.jsx(rh,{worktreeName:tr,repositoryName:w?.repositoryName??"Unknown",description:w?.description,status:e9,gitStatus:w?.gitStatus,onBackClick:ej,onInfoClick:eN,onMenuClick:n,hasUpdate:e5}),(0,a.jsxs)("div",{className:"px-4 py-2 bg-white border-b border-gray-200 flex items-center justify-between",children:[a.jsx("nav",{className:"flex gap-4","aria-label":"CLI Tool Selection",children:U.map(e=>{let t=(0,t7.He)(w?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>Z(e),className:`pb-2 px-2 border-b-2 font-medium text-sm transition-colors flex items-center gap-1.5 ${Y===e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,"aria-current":Y===e?"page":void 0,children:["spinner"===r.type?a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${r.className}`,title:r.label,"aria-label":`${e} status: ${r.label}`}):a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${r.className}`,title:r.label,"aria-label":`${e} status: ${r.label}`}),(0,tz.Ds)(e)]},e)})}),w?.sessionStatusByCli?.[Y]?.isRunning&&(0,a.jsxs)("button",{onClick:eO,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-red-600 hover:text-red-800 hover:bg-red-50 rounded transition-colors","aria-label":`End ${Y} session`,children:[a.jsx("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),w?.gitStatus&&a.jsx(t6,{isBranchMismatch:w.gitStatus.isBranchMismatch,currentBranch:w.gitStatus.currentBranch,initialBranch:w.gitStatus.initialBranch}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(M,{leftPane:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eZ,{activeTab:tt,onTabChange:ev}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===tt&&a.jsx(X,{messages:o.messages,worktreeId:e,onFilePathClick:ep,className:"h-full",showToast:eW}),"files"===tt&&a.jsx(g,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eU,{query:ee.query,mode:ee.mode,isSearching:ee.isSearching,error:ee.error,onQueryChange:ee.setQuery,onModeChange:ee.setMode,onClear:ee.clearSearch}),a.jsx(ez,{worktreeId:e,onFileSelect:eh,onNewFile:eL,onNewDirectory:eI,onRename:eD,onDelete:eF,onUpload:eQ,onMove:eq,onCmateSetup:e1,refreshTrigger:J,searchQuery:ee.query,searchMode:ee.mode,searchResults:ee.results?.results,className:"flex-1 min-h-0"})]})}),"memo"===tt&&a.jsx(g,{componentName:"NotesAndLogsPane",children:a.jsx(tB,{worktreeId:e,className:"h-full",selectedAgents:U,onSelectedAgentsChange:ec,vibeLocalModel:V,onVibeLocalModelChange:eu})})]})]}),rightPane:a.jsx($,{output:o.terminal.output,isActive:o.terminal.isActive,isThinking:o.terminal.isThinking,autoScroll:o.terminal.autoScroll,onScrollChange:eE}),initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),a.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 p-4 bg-gray-50",children:a.jsx(ew.R,{worktreeId:e,onMessageSent:eM,cliToolId:Y,isSessionRunning:o.terminal.isActive})}),a.jsx(t3,{enabled:I,expiresAt:F,onToggle:eA,lastAutoResponse:e3,cliToolName:Y}),o.prompt.visible&&!I&&a.jsx("div",{className:"fixed bottom-20 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-2xl px-4",children:a.jsx(en,{promptData:o.prompt.data,messageId:o.prompt.messageId,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:eC,onDismiss:eS,cliToolName:(0,tz.Ds)(Y)})}),a.jsx(rf,{worktreeId:e,worktree:w,isOpen:T,onClose:ek,onWorktreeUpdate:j}),a.jsx(e0,{isOpen:null!==A,onClose:ex,worktreeId:e,filePath:A??""}),_&&a.jsx(t1.u,{isOpen:!0,onClose:eb,title:_.split("/").pop()||"Editor",size:"full",disableClose:P,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:_,onClose:eb,onSave:ey,onMaximizedChange:L})})}),a.jsx("input",{ref:eX,type:"file",accept:t_.join(","),onChange:e2,className:"hidden","aria-label":"Upload file"}),a.jsx(t1.u,{isOpen:eR,onClose:e$,title:d("session.confirmEnd",{tool:(0,tz.Ds)(Y)}),size:"sm",showCloseButton:!0,children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:e$,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:b("cancel")}),a.jsx("button",{type:"button",onClick:eP,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:b("end")})]})]})}),eG&&a.jsx(rr,{isOpen:eV,onClose:eK,onConfirm:eY,worktreeId:e,sourcePath:eG.path,sourceType:eG.type}),a.jsx(th.Ix,{toasts:eH,onClose:eB})]})})});function rw(){let e=(0,s.useParams)().id;return a.jsx(n.Vw,{children:a.jsx(rv,{worktreeId:e})})}},81194:(e,t,r)=>{"use strict";r.d(t,{O:()=>n});var a=r(10326),s=r(17577);function n({src:e,alt:t,onError:r}){let[n,l]=(0,s.useState)(!1);return n?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[a.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),a.jsx("p",{className:"text-sm",children:"Failed to load image"}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t})]}):a.jsx("div",{className:"flex items-center justify-center p-4",children:a.jsx("img",{src:e,alt:t,onError:()=>{l(!0),r?.()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},89918:(e,t,r)=>{"use strict";r.d(t,{R:()=>n});var a=r(10326),s=r(17577);function n({src:e,onError:t}){let[r,n]=(0,s.useState)(!0),[l,i]=(0,s.useState)(!1);return l?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[a.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),a.jsx("p",{className:"text-sm",children:"Failed to load video"})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[r&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"ml-3 text-gray-600",children:"Loading video..."})]}),a.jsx("video",{controls:!0,src:e,onLoadedData:()=>{n(!1)},onError:()=>{n(!1),i(!0),t?.()},style:{maxWidth:"100%",maxHeight:"500px",display:r?"none":"block"},className:"rounded-lg shadow-sm",children:"Your browser does not support the video tag."})]})}},22570:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>a});let a=(0,r(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx#default`)},4803:()=>{},63817:(e,t,r)=>{"use strict";let a=r(51387),s=a.types;function n(e,t){var r;t||(t={});let n=void 0===t.limit?25:t.limit;(r=e,"[object RegExp]"===({}).toString.call(r))?e=e.source:"string"!=typeof e&&(e=String(e));try{e=a(e)}catch{return!1}let l=0;return function e(t,r){let a,i;if(t.type===s.REPETITION&&(r++,l++,r>1||l>n))return!1;if(t.options){for(a=0,i=t.options.length;a<i;a++)if(!e({stack:t.options[a]},r))return!1}let o=t.stack||t.value?.stack;if(!o)return!0;for(a=0;a<o.length;a++)if(!e(o[a],r))return!1;return!0}(e,0)}e.exports=n,e.exports.default=n,e.exports.safeRegex=n}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,3294,6621,8705,7458,7808,3860,539],()=>r(80205));module.exports=a})();