commandmate 0.2.10 → 0.2.12

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 (70) hide show
  1. package/.env.example +2 -1
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/app-build-manifest.json +12 -12
  4. package/.next/app-path-routes-manifest.json +1 -1
  5. package/.next/build-manifest.json +2 -2
  6. package/.next/cache/.tsbuildinfo +1 -1
  7. package/.next/cache/config.json +3 -3
  8. package/.next/cache/webpack/client-production/0.pack +0 -0
  9. package/.next/cache/webpack/client-production/1.pack +0 -0
  10. package/.next/cache/webpack/client-production/2.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack +0 -0
  12. package/.next/cache/webpack/client-production/index.pack.old +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/repositories/clone/[jobId]/route.js +1 -1
  23. package/.next/server/app/api/repositories/clone/route.js +1 -1
  24. package/.next/server/app/api/repositories/route.js +2 -2
  25. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  26. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  27. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  28. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  29. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  30. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  31. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
  32. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
  33. package/.next/server/app/page_client-reference-manifest.js +1 -1
  34. package/.next/server/app/worktrees/[id]/files/[...path]/page.js +1 -1
  35. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  36. package/.next/server/app/worktrees/[id]/page.js +3 -3
  37. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  38. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app-paths-manifest.json +10 -10
  40. package/.next/server/chunks/2509.js +1 -0
  41. package/.next/server/chunks/369.js +1 -1
  42. package/.next/server/chunks/5488.js +4 -4
  43. package/.next/server/chunks/7808.js +1 -1
  44. package/.next/server/chunks/8693.js +1 -0
  45. package/.next/server/chunks/8744.js +1 -1
  46. package/.next/server/chunks/9238.js +14 -14
  47. package/.next/server/chunks/9367.js +2 -2
  48. package/.next/server/functions-config-manifest.json +1 -1
  49. package/.next/server/pages/500.html +1 -1
  50. package/.next/server/server-reference-manifest.json +1 -1
  51. package/.next/static/chunks/5970-2e18108d0cabd8af.js +1 -0
  52. package/.next/static/chunks/9178-88850a7c48deea07.js +1 -0
  53. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/page-4a3c0861367e0391.js +1 -0
  54. package/.next/static/chunks/app/worktrees/[id]/page-c99258f57461962c.js +1 -0
  55. package/.next/static/css/897ffb669f47c97b.css +3 -0
  56. package/.next/trace +5 -5
  57. package/README.md +154 -181
  58. package/dist/server/src/config/auto-yes-config.js +44 -2
  59. package/dist/server/src/lib/auto-yes-manager.js +249 -41
  60. package/dist/server/src/lib/claude-session.js +60 -21
  61. package/dist/server/src/lib/prompt-key.js +30 -0
  62. package/package.json +19 -7
  63. package/.next/server/chunks/667.js +0 -1
  64. package/.next/static/chunks/5970-dc8fb1c8c0217636.js +0 -1
  65. package/.next/static/chunks/8864-2f60eadc8404fdd0.js +0 -1
  66. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/page-ce9ac3658f2b7d91.js +0 -1
  67. package/.next/static/chunks/app/worktrees/[id]/page-1b8e4c49fbaf3f99.js +0 -1
  68. package/.next/static/css/a69d9c70fce558b4.css +0 -3
  69. /package/.next/static/{NGcx1ej6oVBba0MO0bwCg → ym6mA6Dl9wX62h3AoYO45}/_buildManifest.js +0 -0
  70. /package/.next/static/{NGcx1ej6oVBba0MO0bwCg → ym6mA6Dl9wX62h3AoYO45}/_ssgManifest.js +0 -0
@@ -1,9 +1,9 @@
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,a)=>{"use strict";a.r(t),a.d(t,{GlobalError:()=>l.a,__next_app__:()=>m,originalPathname:()=>u,pages:()=>d,routeModule:()=>p,tree:()=>c}),a(22570),a(25086),a(35866);var r=a(23191),n=a(88716),s=a(37922),l=a.n(s),i=a(95231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);a.d(t,o);let c=["",{children:["worktrees",{children:["[id]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(a.bind(a,22570)),"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx"]}]},{}]},{metadata:{icon:[async e=>(await Promise.resolve().then(a.bind(a,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(a.bind(a,63601))).default(e)],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(a.bind(a,25086)),"/home/runner/work/CommandMate/CommandMate/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(a.t.bind(a,35866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(a.bind(a,71150))).default(e)],apple:[async e=>(await Promise.resolve().then(a.bind(a,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:a,loadChunk:()=>Promise.resolve()},p=new r.AppPageRouteModule({definition:{kind:n.x.APP_PAGE,page:"/worktrees/[id]/page",pathname:"/worktrees/[id]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},87923:(e,t,a)=>{Promise.resolve().then(a.bind(a,56055))},62829:e=>{"use strict";let{entries:t,setPrototypeOf:a,isFrozen:r,getPrototypeOf:n,getOwnPropertyDescriptor:s}=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 a=arguments.length,r=Array(a>2?a-2:0),n=2;n<a;n++)r[n-2]=arguments[n];return e.apply(t,r)}),d||(d=function(e){for(var t=arguments.length,a=Array(t>1?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];return new e(...a)});let u=C(Array.prototype.forEach),m=C(Array.prototype.lastIndexOf),p=C(Array.prototype.pop),h=C(Array.prototype.push),x=C(Array.prototype.splice),f=C(String.prototype.toLowerCase),g=C(String.prototype.toString),b=C(String.prototype.match),y=C(String.prototype.replace),w=C(String.prototype.indexOf),v=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),a=0;a<e;a++)t[a]=arguments[a];return d(Z,t)});function C(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var a=arguments.length,r=Array(a>1?a-1:0),n=1;n<a;n++)r[n-1]=arguments[n];return c(e,t,r)}}function S(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:f;a&&a(e,null);let s=t.length;for(;s--;){let a=t[s];if("string"==typeof a){let e=n(a);e!==a&&(r(t)||(t[s]=e),a=e)}e[a]=!0}return e}function T(e){let a=o(null);for(let[r,n]of t(e))j(e,r)&&(Array.isArray(n)?a[r]=function(e){for(let t=0;t<e.length;t++)j(e,t)||(e[t]=null);return e}(n):n&&"object"==typeof n&&n.constructor===Object?a[r]=T(n):a[r]=n);return a}function E(e,t){for(;null!==e;){let a=s(e,t);if(a){if(a.get)return C(a.get);if("function"==typeof a.value)return C(a.value)}e=n(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"]),L=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"]),D=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=l(["#text"]),O=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"]),$=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),U=i(/<%[\w\W]*|[\w\W]*%>/gm),W=i(/\$\{[\w\W]*/gm),B=i(/^data-[\-\w.\u00B7-\uFFFF]+$/),H=i(/^aria-[\-\w]+$/),q=i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V=i(/^(?:\w+script|data):/i),G=i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Y=i(/^html$/i);var Z,K=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:G,CUSTOM_ELEMENT:i(/^[a-z][.\w]*(-[.\w]+)+$/i),DATA_ATTR:B,DOCTYPE_NAME:Y,ERB_EXPR:U,IS_ALLOWED_URI:q,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 a=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(a=t.getAttribute(r));let n="dompurify"+(a?"#"+a:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}},Q=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};var ee=function e(){let a,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window,n=t=>e(t);if(n.version="3.3.1",n.removed=[],!r||!r.document||r.document.nodeType!==X.document||!r.Element)return n.isSupported=!1,n;let{document:s}=r,i=s,c=i.currentScript,{DocumentFragment:d,HTMLTemplateElement:C,Node:z,Element:U,NodeFilter:W,NamedNodeMap:B=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:H,DOMParser:V,trustedTypes:G}=r,Z=U.prototype,ee=E(Z,"cloneNode"),et=E(Z,"remove"),ea=E(Z,"nextSibling"),er=E(Z,"childNodes"),en=E(Z,"parentNode");if("function"==typeof C){let e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let es="",{implementation:el,createNodeIterator:ei,createDocumentFragment:eo,getElementsByTagName:ec}=s,{importNode:ed}=i,eu=Q();n.isSupported="function"==typeof t&&"function"==typeof en&&el&&void 0!==el.createHTMLDocument;let{MUSTACHE_EXPR:em,ERB_EXPR:ep,TMPLIT_EXPR:eh,DATA_ATTR:ex,ARIA_ATTR:ef,IS_SCRIPT_OR_DATA:eg,ATTR_WHITESPACE:eb,CUSTOM_ELEMENT:ey}=K,{IS_ALLOWED_URI:ew}=K,ev=null,ej=S({},[...M,...A,...R,...L,...P]),eN=null,ek=S({},[...O,...I,...$,...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,eL=!1,eD=!0,eP=!1,eO=!1,eI=!1,e$=!1,eF=!1,ez=!1,eU=!0,eW=!1,eB=!0,eH=!1,eq={},eV=null,eG=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,ta=s.createElement("form"),tr=function(e){return e instanceof RegExp||e instanceof Function},tn=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:f,ev=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):eG,eS=j(e,"FORBID_TAGS")?S({},e.FORBID_TAGS,te):T({}),eT=j(e,"FORBID_ATTR")?S({},e.FORBID_ATTR,te):T({}),eq=!!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,eL=e.SAFE_FOR_TEMPLATES||!1,eD=!1!==e.SAFE_FOR_XML,eP=e.WHOLE_DOCUMENT||!1,e$=e.RETURN_DOM||!1,eF=e.RETURN_DOM_FRAGMENT||!1,ez=e.RETURN_TRUSTED_TYPE||!1,eI=e.FORCE_BODY||!1,eU=!1!==e.SANITIZE_DOM,eW=e.SANITIZE_NAMED_PROPS||!1,eB=!1!==e.KEEP_CONTENT,eH=e.IN_PLACE||!1,ew=e.ALLOWED_URI_REGEXP||q,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&&tr(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(eC.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&tr(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),eL&&(eA=!1),eF&&(e$=!0),eq&&(ev=S({},P),eN=[],!0===eq.html&&(S(ev,M),S(eN,O)),!0===eq.svg&&(S(ev,A),S(eN,I),S(eN,F)),!0===eq.svgFilters&&(S(ev,R),S(eN,I),S(eN,F)),!0===eq.mathMl&&(S(ev,L),S(eN,$),S(eN,F))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?eE.tagCheck=e.ADD_TAGS:(ev===ej&&(ev=T(ev)),S(ev,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===eG&&(eV=T(eV)),S(eV,e.FORBID_CONTENTS,te)),e.ADD_FORBID_CONTENTS&&(eV===eG&&(eV=T(eV)),S(eV,e.ADD_FORBID_CONTENTS,te)),eB&&(ev["#text"]=!0),eP&&S(ev,["html","head","body"]),ev.table&&(S(ev,["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.');es=(a=e.TRUSTED_TYPES_POLICY).createHTML("")}else void 0===a&&(a=J(G,c)),null!==a&&"string"==typeof es&&(es=a.createHTML(""));l&&l(e),tt=e}},ts=S({},[...A,...R,..._]),tl=S({},[...L,...D]),ti=function(e){let t=en(e);t&&t.tagName||(t={namespaceURI:e1,tagName:"template"});let a=f(e.tagName),r=f(t.tagName);return!!e4[e.namespaceURI]&&(e.namespaceURI===eQ?t.namespaceURI===e0?"svg"===a:t.namespaceURI===eJ?"svg"===a&&("annotation-xml"===r||e3[r]):!!ts[a]:e.namespaceURI===eJ?t.namespaceURI===e0?"math"===a:t.namespaceURI===eQ?"math"===a&&e6[r]:!!tl[a]:e.namespaceURI===e0?(t.namespaceURI!==eQ||!!e6[r])&&(t.namespaceURI!==eJ||!!e3[r])&&!tl[a]&&(e8[a]||!ts[a]):"application/xhtml+xml"===e7&&!!e4[e.namespaceURI])},to=function(e){h(n.removed,{element:e});try{en(e).removeChild(e)}catch(t){et(e)}},tc=function(e,t){try{h(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e){if(e$||eF)try{to(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}}},td=function(e){let t=null,r=null;if(eI)e="<remove></remove>"+e;else{let t=b(e,/^[\r\n\t ]+/);r=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 n=a?a.createHTML(e):e;if(e1===e0)try{t=new V().parseFromString(n,e7)}catch(e){}if(!t||!t.documentElement){t=el.createDocument(e1,"template",null);try{t.documentElement.innerHTML=e2?es:n}catch(e){}}let l=t.body||t.documentElement;return(e&&r&&l.insertBefore(s.createTextNode(r),l.childNodes[0]||null),e1===e0)?ec.call(t,eP?"html":"body")[0]:eP?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 H&&("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,a){u(e,e=>{e.call(n,t,a,tt)})}let tx=function(e){let t=null;if(th(eu.beforeSanitizeElements,e,null),tm(e))return to(e),!0;let a=te(e.nodeName);if(th(eu.uponSanitizeElement,e,{tagName:a,allowedTags:ev}),eD&&e.hasChildNodes()&&!tp(e.firstElementChild)&&N(/<[/\w!]/g,e.innerHTML)&&N(/<[/\w!]/g,e.textContent)||e.nodeType===X.progressingInstruction||eD&&e.nodeType===X.comment&&N(/<[/\w]/g,e.data))return to(e),!0;if(!(eE.tagCheck instanceof Function&&eE.tagCheck(a))&&(!ev[a]||eS[a])){if(!eS[a]&&tg(a)&&(eC.tagNameCheck instanceof RegExp&&N(eC.tagNameCheck,a)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(a)))return!1;if(eB&&!eV[a]){let t=en(e)||e.parentNode,a=er(e)||e.childNodes;if(a&&t){let r=a.length;for(let n=r-1;n>=0;--n){let r=ee(a[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,ea(e))}}}return to(e),!0}return e instanceof U&&!ti(e)||("noscript"===a||"noembed"===a||"noframes"===a)&&N(/<\/no(script|embed|frames)/i,e.innerHTML)?(to(e),!0):(eL&&e.nodeType===X.text&&(t=e.textContent,u([em,ep,eh],e=>{t=y(t,e," ")}),e.textContent!==t&&(h(n.removed,{element:e.cloneNode()}),e.textContent=t)),th(eu.afterSanitizeElements,e,null),!1)},tf=function(e,t,a){if(eU&&("id"===t||"name"===t)&&(a in s||a in ta))return!1;if(eA&&!eT[t]&&N(ex,t));else if(eM&&N(ef,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,a)||eC.tagNameCheck instanceof Function&&eC.tagNameCheck(a))))return!1}else if(eK[t]);else if(N(ew,y(a,eb,"")));else if(("src"===t||"xlink:href"===t||"href"===t)&&"script"!==e&&0===w(a,"data:")&&eY[e]);else if(eR&&!N(eg,y(a,eb,"")));else if(a)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 r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:eN,forceKeepAttr:void 0},s=t.length;for(;s--;){let{name:l,namespaceURI:i,value:o}=t[s],c=te(l),d="value"===l?o:v(o);if(r.attrName=c,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,th(eu.uponSanitizeAttribute,e,r),d=r.attrValue,eW&&("id"===c||"name"===c)&&(tc(l,e),d="user-content-"+d),eD&&N(/((--!?|])>)|<\/(style|title|textarea)/i,d)||"attributename"===c&&b(d,"href")){tc(l,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr||!e_&&N(/\/>/i,d)){tc(l,e);continue}eL&&u([em,ep,eh],e=>{d=y(d,e," ")});let m=te(e.nodeName);if(!tf(m,c,d)){tc(l,e);continue}if(a&&"object"==typeof G&&"function"==typeof G.getAttributeType){if(i);else switch(G.getAttributeType(m,c)){case"TrustedHTML":d=a.createHTML(d);break;case"TrustedScriptURL":d=a.createScriptURL(d)}}if(d!==o)try{i?e.setAttributeNS(i,l,d):e.setAttribute(l,d),tm(e)?to(e):p(n.removed)}catch(t){tc(l,e)}}th(eu.afterSanitizeAttributes,e,null)},ty=function e(t){let a=null,r=tu(t);for(th(eu.beforeSanitizeShadowDOM,t,null);a=r.nextNode();)th(eu.uponSanitizeShadowNode,a,null),tx(a),tb(a),a.content instanceof d&&e(a.content);th(eu.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,s=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(!n.isSupported)return e;if(eO||tn(t),n.removed=[],"string"==typeof e&&(eH=!1),eH){if(e.nodeName){let t=te(e.nodeName);if(!ev[t]||eS[t])throw k("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof z)(s=(r=td("<!---->")).ownerDocument.importNode(e,!0)).nodeType===X.element&&"BODY"===s.nodeName?r=s:"HTML"===s.nodeName?r=s:r.appendChild(s);else{if(!e$&&!eL&&!eP&&-1===e.indexOf("<"))return a&&ez?a.createHTML(e):e;if(!(r=td(e)))return e$?null:ez?es:""}r&&eI&&to(r.firstChild);let c=tu(eH?e:r);for(;l=c.nextNode();)tx(l),tb(l),l.content instanceof d&&ty(l.content);if(eH)return e;if(e$){if(eF)for(o=eo.call(r.ownerDocument);r.firstChild;)o.appendChild(r.firstChild);else o=r;return(eN.shadowroot||eN.shadowrootmode)&&(o=ed.call(i,o,!0)),o}let m=eP?r.outerHTML:r.innerHTML;return eP&&ev["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&N(Y,r.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+m),eL&&u([em,ep,eh],e=>{m=y(m,e," ")}),a&&ez?a.createHTML(m):m},n.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tn(e),eO=!0},n.clearConfig=function(){tt=null,eO=!1},n.isValidAttribute=function(e,t,a){return tt||tn({}),tf(te(e),te(t),a)},n.addHook=function(e,t){"function"==typeof t&&h(eu[e],t)},n.removeHook=function(e,t){if(void 0!==t){let a=m(eu[e],t);return -1===a?void 0:x(eu[e],a,1)[0]}return p(eu[e])},n.removeHooks=function(e){eu[e]=[]},n.removeAllHooks=function(){eu=Q()},n}();e.exports=ee},24420:(e,t,a)=>{function r(e){return e&&e.default||e}e.exports=global.DOMPurify=global.DOMPurify||("undefined"!=typeof window?r(a(62829)):function(){let e=r(a(62829)),{JSDOM:t}=r(a(98860)),{window:n}=new t("<!DOCTYPE html>");return e(n)}())},43353:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return s}});let r=a(91174);a(10326),a(17577);let n=r._(a(77028));function s(e,t){var a;let r={loading:e=>{let{error:t,isLoading:a,pastDelay:r}=e;return null}};"function"==typeof e&&(r.loader=e);let s={...r,...t};return(0,n.default)({...s,modules:null==(a=s.loadableGenerated)?void 0:a.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,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return n}});let r=a(94129);function n(e){let{reason:t,children:a}=e;throw new r.BailoutToCSRError(t)}},77028:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return c}});let r=a(10326),n=a(17577),s=a(933),l=a(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},a=(0,n.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,r.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.PreloadCss,{moduleIds:t.modules}),(0,r.jsx)(a,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(a,{...e})});return(0,r.jsx)(n.Suspense,{fallback:i,children:o})}return d.displayName="LoadableComponent",d}},46618:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return s}});let r=a(10326),n=a(54580);function s(e){let{moduleIds:t}=e,a=(0,n.getExpectedRequestStore)("next/dynamic css"),s=[];if(a.reactLoadableManifest&&t){let e=a.reactLoadableManifest;for(let a of t){if(!e[a])continue;let t=e[a].files.filter(e=>e.endsWith(".css"));s.push(...t)}}return 0===s.length?null:(0,r.jsx)(r.Fragment,{children:s.map(e=>(0,r.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:a.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},56055:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>al});var r=a(10326),n=a(35047),s=a(2583),l=a(17577),i=a.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=a(2982),x=a(87403),f=a(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:r.jsx(b,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}}function b({componentName:e,error:t,onRetry:a}){let n=(0,f.T)("error"),s=(0,f.T)("common");return(0,r.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-red-800 mb-2",children:[r.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:r.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"})}),r.jsx("span",{className:"font-medium",children:e?n("boundary.errorOccurredIn",{componentName:e}):n("boundary.errorOccurred")})]}),t&&r.jsx("p",{className:"text-sm text-red-600 mb-3",children:t.message}),a&&r.jsx("button",{onClick:a,className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors text-sm",children:s("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"],w=["w-1","h-full","cursor-col-resize","hover:w-2"],v=["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:a=50,onDoubleClick:n,minRatio:s=.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 a=j(t,u);e(a-c.current),c.current=a},[i,u,e]),x=(0,l.useCallback)(t=>{if(!i||1!==t.touches.length)return;let a=j(t,u);e(a-c.current),c.current=a},[i,u,e]),f=(0,l.useCallback)(()=>{o(!1)},[]),g=(0,l.useCallback)(()=>{n&&n()},[n]),b=(0,l.useCallback)(t=>{let a=0;u?"ArrowRight"===t.key?a=10:"ArrowLeft"===t.key&&(a=-10):"ArrowDown"===t.key?a=10:"ArrowUp"===t.key&&(a=-10),0!==a&&(t.preventDefault(),e(a))},[u,e]);(0,l.useEffect)(()=>(i&&(document.addEventListener("mousemove",h),document.addEventListener("mouseup",f),document.addEventListener("touchmove",x),document.addEventListener("touchend",f),document.body.style.userSelect="none",document.body.style.cursor=u?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",f),document.body.style.userSelect="",document.body.style.cursor=""}),[i,h,f,x,u]);let N=(0,l.useMemo)(()=>[...y,...u?w:v,...i?["bg-blue-500","dragging",u?"w-2":"h-2"]:[]].join(" "),[u,i]);return r.jsx("div",{ref:d,role:"separator","aria-orientation":t,"aria-valuenow":a,"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:a}){return r.jsx("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`${e}-panel`,onClick:a,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[a,n]=(0,l.useState)("right"),s=(0,l.useCallback)(()=>n("left"),[]),i=(0,l.useCallback)(()=>n("right"),[]);return(0,r.jsxs)("div",{"data-testid":"mobile-layout",className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex border-b border-gray-700 bg-gray-800",role:"tablist",children:[r.jsx(S,{pane:"left",isActive:"left"===a,onClick:s}),r.jsx(S,{pane:"right",isActive:"right"===a,onClick:i})]}),r.jsx("div",{id:`${a}-panel`,role:"tabpanel",className:"flex-1 overflow-hidden",children:r.jsx(g,{componentName:C[a],children:"left"===a?e:t})})]})}),E=(0,l.memo)(function({leftPane:e,rightPane:t,leftWidth:a,onResize:n,className:s}){let i=(0,l.useMemo)(()=>({width:`${a}%`}),[a]),o=(0,l.useMemo)(()=>({width:`${100-a}%`}),[a]),c=(0,l.useMemo)(()=>`flex h-full min-h-0 ${s}`.trim(),[s]);return(0,r.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:c,children:[r.jsx("div",{"data-testid":"left-pane","aria-label":"History pane",style:i,className:"flex-shrink-0 overflow-hidden",children:r.jsx(g,{componentName:C.left,children:e})}),r.jsx(N,{onResize:n,orientation:"horizontal",ariaValueNow:a}),r.jsx("div",{"data-testid":"right-pane","aria-label":"Terminal pane",style:o,className:"flex-grow overflow-hidden",children:r.jsx(g,{componentName:C.right,children:t})})]})}),M=(0,l.memo)(function({leftPane:e,rightPane:t,initialLeftWidth:a=50,minLeftWidth:n=20,maxLeftWidth:s=80,className:i=""}){let o=(0,h.d)(),c=(0,l.useRef)(null),[d,u]=(0,l.useState)(a),m=(0,l.useCallback)(e=>{let t=c.current;if(!t)return;let a=t.offsetWidth;if(0===a)return;let r=e/a*100;u(e=>Math.min(s,Math.max(n,e+r)))},[n,s]);return o?r.jsx(T,{leftPane:e,rightPane:t}):r.jsx("div",{ref:c,className:"h-full",children:r.jsx(E,{leftPane:e,rightPane:t,leftWidth:d,onResize:m,className:i})})});var A=a(24420),R=a.n(A),_=a(43053);let L=new(a.n(_)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function D(){return(0,r.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,r.jsxs)("span",{className:"flex gap-1",children:[r.jsx("span",{className:"animate-pulse delay-0",children:"."}),r.jsx("span",{className:"animate-pulse delay-150",children:"."}),r.jsx("span",{className:"animate-pulse delay-300",children:"."})]}),r.jsx("span",{className:"text-sm",children:"Thinking"})]})}let P=(0,l.memo)(function({output:e,isActive:t,isThinking:a=!1,autoScroll:n=!0,onScrollChange:s,className:i=""}){let{scrollRef:o,autoScroll:c,handleScroll:d,scrollToBottom:u}=function(e={}){let{initialAutoScroll:t=!0,onAutoScrollChange:a}=e,r=(0,l.useRef)(null),[n,s]=(0,l.useState)(t),i=(0,l.useCallback)(e=>{s(e),a?.(e)},[a]),o=(0,l.useCallback)(()=>{let e=r.current;if(!e)return!0;let{scrollTop:t,scrollHeight:a,clientHeight:n}=e;return a-n-t<=50},[]),c=(0,l.useCallback)(()=>{let e=o();e&&!n?i(!0):!e&&n&&i(!1)},[n,o,i]),d=(0,l.useCallback)(()=>{let e=r.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),n||i(!0))},[n,i]);return{scrollRef:r,autoScroll:n,setAutoScroll:i,scrollToBottom:d,handleScroll:c}}({initialAutoScroll:n,onAutoScrollChange:s}),m=function(e){let t=L.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,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,r.jsxs)("div",{ref:o,role:"log","aria-live":"polite","aria-label":"Terminal output",className:p,onScroll:d,children:[r.jsx("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:m}}),t&&a&&r.jsx(D,{})]}),!c&&r.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 O=a(62881);let I=(0,O.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"}]]),$=/(\/[^\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 a=t.slice(0,5).join("\n");return a.length>300&&(a=a.slice(0,300)),{text:a,isTruncated:!0}}let z=(0,l.memo)(function({content:e,onFilePathClick:t}){let a=(0,l.useMemo)(()=>(function(e){let t=e.match($);if(!t||0===t.length)return[{type:"text",content:e}];let a=[],r=0;return t.forEach(t=>{let n=e.indexOf(t,r);n>r&&a.push({type:"text",content:e.slice(r,n)}),a.push({type:"path",content:t}),r=n+t.length}),r<e.length&&a.push({type:"text",content:e.slice(r)}),a})(e),[e]),n=(0,l.useCallback)(e=>()=>t(e),[t]);return r.jsx("span",{children:a.map((e,t)=>"path"===e.type?r.jsx("button",{type:"button",onClick:n(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):r.jsx("span",{children:e.content},t))})});function U(){return(0,r.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-gray-400 py-2",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),r.jsx("span",{className:"text-sm",children:"Waiting for response..."})]})}let W=(0,l.memo)(function({message:e,onFilePathClick:t,onCopy:a}){let n=(0,l.useMemo)(()=>e.timestamp.toLocaleTimeString(),[e.timestamp]);return(0,r.jsxs)("div",{className:"relative bg-blue-900/30 border-l-4 border-blue-500 p-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-xs font-medium text-blue-400",children:"You"}),r.jsx("span",{className:"text-xs text-gray-500",children:n})]}),r.jsx("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words",children:r.jsx(z,{content:e.content,onFilePathClick:t})}),a&&r.jsx("button",{type:"button","data-testid":"copy-user-message",onClick:()=>a(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:r.jsx(I,{size:14,"aria-hidden":"true"})})]})}),B=(0,l.memo)(function({message:e,index:t,total:a,isExpanded:n,onFilePathClick:s,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=n||!d?e.content:c;return(0,r.jsxs)("div",{className:"assistant-message-item relative",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Assistant"}),r.jsx("span",{className:"text-xs text-gray-500",children:o}),a>1&&(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["(",t+1,"/",a,")"]})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[r.jsx(z,{content:u,onFilePathClick:s}),!n&&d&&r.jsx("span",{className:"text-gray-500",children:"..."})]}),i&&r.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:r.jsx(I,{size:14,"aria-hidden":"true"})})]})}),H=(0,l.memo)(function({messages:e,isExpanded:t,onFilePathClick:a,onCopy:n}){return r.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((s,l)=>(0,r.jsxs)(i().Fragment,{children:[l>0&&r.jsx("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),r.jsx(B,{message:s,index:l,total:e.length,isExpanded:t,onFilePathClick:a,onCopy:n})]},s.id))})});function q(){return(0,r.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:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})}),r.jsx("span",{children:"System Message"})]})}let V=(0,l.memo)(function({pair:e,onFilePathClick:t,isExpanded:a=!1,onToggleExpand:n,onCopy:s}){let i=(0,l.useMemo)(()=>e.assistantMessages.some(e=>{let{isTruncated:t}=F(e.content);return t}),[e.assistantMessages]),o=(0,l.useCallback)(()=>{n&&n()},[n]),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,r.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":d,className:c,children:["orphan"===e.status&&r.jsx(q,{}),e.userMessage&&r.jsx(W,{message:e.userMessage,onFilePathClick:t,onCopy:s}),"pending"===e.status?r.jsx("div",{className:"bg-gray-800/30 border-l-4 border-gray-600 p-3 border-t border-gray-700",children:r.jsx(U,{})}):e.assistantMessages.length>0?(0,r.jsxs)("div",{className:"relative",children:[r.jsx(H,{messages:e.assistantMessages,isExpanded:a,onFilePathClick:t,onCopy:s}),i&&r.jsx("div",{className:"absolute top-2 right-2",children:(0,r.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":a,"aria-label":a?"Collapse message":"Expand message",children:[r.jsx("svg",{className:`w-3 h-3 transition-transform ${a?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),a?"Collapse":"Expand"]})})]}):null]})});var G=a(91515);function Y(){return(0,r.jsxs)("div",{"data-testid":"loading-indicator",className:"flex items-center justify-center py-4",role:"status","aria-label":"Loading messages",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-100"}),r.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-200"})]}),r.jsx("span",{className:"ml-2 text-sm text-gray-400",children:"Loading..."})]})}function Z(){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[r.jsx("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})}),r.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:a,isLoading:n=!1,className:s="",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,a=d.current;t&&e.length===a&&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()),a=[],r=null;for(let e of t)if("user"===e.role)r={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},a.push(r);else if("assistant"===e.role){if(r&&null!==r.userMessage)r.assistantMessages.push(e),r.status="completed";else if(r&&null===r.userMessage)r.assistantMessages.push(e);else{let t={id:`orphan-${e.id}`,userMessage:null,assistantMessages:[e],status:"orphan"};a.push(t),r=t}}return a})(e),[e]),[a,r]=(0,l.useState)(new Set),n=(0,l.useCallback)(e=>{r(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),s=(0,l.useCallback)(e=>a.has(e),[a]),i=(0,l.useCallback)(()=>{r(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:a,toggleExpand:n,isExpanded:s,expandAll:i,collapseAll:(0,l.useCallback)(()=>{r(new Set)},[])}}(e),h=(0,l.useMemo)(()=>[...K,s].filter(Boolean).join(" "),[s]),x=(0,l.useCallback)(e=>a(e),[a]),f=(0,l.useCallback)(e=>()=>p(e),[p]),g=(0,l.useCallback)(async e=>{try{await (0,G.v)(e),i?.("Copied to clipboard","success")}catch{console.error("[HistoryPane] Failed to copy to clipboard"),i?.("Failed to copy","error")}},[i]);return(0,r.jsxs)("div",{ref:o,role:"region","aria-label":"Message history",className:h,children:[r.jsx("div",{className:"sticky top-0 bg-gray-900 border-b border-gray-700 px-4 py-2 z-10",children:r.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Message History"})}),r.jsx("div",{className:"flex-1 p-4 min-h-0",children:n?r.jsx(Y,{}):0===e.length?r.jsx(Z,{}):u.map(e=>r.jsx(V,{pair:e,onFilePathClick:x,isExpanded:m(e.id),onToggleExpand:f(e.id),onCopy:g},e.id))})]})}),J={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function Q({visible:e,duration:t=200}){let[a,r]=(0,l.useState)(e?"visible":"hidden");(0,l.useRef)(null),(0,l.useRef)(e);let n="hidden"!==a,s="fade-in"===a||"fade-out"===a;return{shouldRender:n,animationClass:(0,l.useMemo)(()=>{switch(a){case"fade-in":return J.fadeIn;case"fade-out":return J.fadeOut;default:return J.none}},[a]),isAnimating:s}}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,74810))},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=l(["#text"]),I=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"]),D=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"]),$=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,...L]),eN=null,ek=S({},[...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,eL=!1,eI=!1,eD=!1,e$=!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,eL=e.WHOLE_DOCUMENT||!1,e$=e.RETURN_DOM||!1,eF=e.RETURN_DOM_FRAGMENT||!1,ez=e.RETURN_TRUSTED_TYPE||!1,eD=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&&(e$=!0),eG&&(ew=S({},L),eN=[],!0===eG.html&&(S(ew,M),S(eN,I)),!0===eG.svg&&(S(ew,A),S(eN,D),S(eN,F)),!0===eG.svgFilters&&(S(ew,R),S(eN,D),S(eN,F)),!0===eG.mathMl&&(S(ew,O),S(eN,$),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),eL&&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(e$||eF)try{to(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}}},td=function(e){let t=null,a=null;if(eD)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,eL?"html":"body")[0]:eL?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(eI||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(!e$&&!eO&&!eL&&-1===e.indexOf("<"))return r&&ez?r.createHTML(e):e;if(!(a=td(e)))return e$?null:ez?en:""}a&&eD&&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(e$){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=eL?a.outerHTML:a.innerHTML;return eL&&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),eI=!0},s.clearConfig=function(){tt=null,eI=!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}]`}},74810:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ro});var a=r(10326),s=r(35047),n=r(2583),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 L=(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 I=r(62881);let D=(0,I.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"}]]),$=/(\/[^\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($);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(D,{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(D,{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 ea({promptData:e,answering:t,onRespond:a,onDismiss:n,labelId:s}){let i=(0,f.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]),x=h?.requiresTextInput===!0,g=t||m,b=(0,l.useCallback)(async e=>{if(!g){p(!0);try{await a(e)}catch(e){}finally{p(!1)}}},[g,a]),y=(0,l.useCallback)(async()=>{if(!g&&null!==o){p(!0);try{let e=x&&d.trim()?d.trim():o.toString();await a(e)}catch(e){}finally{p(!1)}}},[g,a,o,x,d]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h3",{id:s,className:"text-lg font-semibold text-yellow-800 flex items-center gap-2",children:[r.jsx("span",{className:"text-xl","aria-hidden":"true",children:"?"}),i("confirmationFromClaude")]}),n&&r.jsx("button",{type:"button",onClick:n,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 transition-colors",children:r.jsx("svg",{className:"w-5 h-5 text-yellow-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.instructionText&&r.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}),r.jsx("p",{className:"text-gray-800 leading-relaxed",children:e.question}),g&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),r.jsx("span",{children:i("sending")})]}),"yes_no"===e.type&&r.jsx(er,{promptData:e,disabled:g,onYes:()=>b("yes"),onNo:()=>b("no")}),"multiple_choice"===e.type&&r.jsx(en,{promptData:e,disabled:g,selectedOption:o,onSelectOption:c,textInputValue:d,onTextInputChange:u,showTextInput:x,onSubmit:y})]})}function er({promptData:e,disabled:t,onYes:a,onNo:n}){let s=(0,f.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,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":"Yes or No options",children:[r.jsx("button",{type:"button",onClick:a,disabled:t,className:o,children:s("yes")}),r.jsx("button",{type:"button",onClick:n,disabled:t,className:c,children:s("no")})]})}function en({promptData:e,disabled:t,selectedOption:a,onSelectOption:n,textInputValue:s,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,f.T)("prompt"),m=(0,l.useCallback)(e=>{let r=a===e,n=t?"opacity-50 cursor-not-allowed":"";return`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${r?"bg-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"} ${n}`},[a,t]);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[r.jsx("legend",{className:"sr-only",children:"Select an option"}),r.jsx("div",{className:"space-y-2",children:e.options.map(e=>(0,r.jsxs)("label",{className:m(e.number),children:[r.jsx("input",{type:"radio",name:d,value:e.number,checked:a===e.number,onChange:()=>n(e.number),disabled:t,className:"mt-1","aria-describedby":e.isDefault?`default-${e.number}`:void 0}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&r.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,r.jsxs)("div",{className:"mt-3",children:[r.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),r.jsx("input",{id:`text-input-${d}`,type:"text",value:s,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"})]}),r.jsx("button",{type:"button",onClick:c,disabled:t||null===a,className:`w-full ${ee} ${et}`,children:u("submit")})]})}function es({promptData:e,messageId:t,visible:a,answering:n,onRespond:s,onDismiss:i}){let o;let{shouldRender:c,animationClass:d}=Q({visible:a&&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 r.jsx(g,{componentName:"PromptPanel",children:r.jsx("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":u,"aria-modal":"true",className:m,children:r.jsx(ea,{promptData:e,answering:n,onRespond:s,onDismiss:i,labelId:u})})})}var el=a(61421),ei=a(51223);let eo=(0,l.memo)(function({path:e,className:t="w-6 h-6"}){return r.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:r.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:a,gitStatus:n,onBackClick:s,onMenuClick:i}){let o=(0,l.useMemo)(()=>el.xh[a],[a]);return r.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,r.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[r.jsx("div",{className:"w-10 flex-shrink-0",children:s&&r.jsx("button",{type:"button",onClick:s,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 transition-colors",children:r.jsx(eo,{path:ec.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:["spinner"===o.type?r.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}`}):r.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,r.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[r.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,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:[t&&r.jsx("span",{className:"truncate max-w-[100px] text-center",children:t}),n&&"(unknown)"!==n.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[t&&r.jsx("span",{className:"text-gray-300",children:"/"}),r.jsx("span",{className:"truncate max-w-[80px] font-mono",title:n.currentBranch,"data-testid":"mobile-branch-name",children:(0,ei.aS)(n.currentBranch,20)}),n.isDirty&&r.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),r.jsx("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&r.jsx("button",{type:"button",onClick:i,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 transition-colors",children:r.jsx(eo,{path:ec.menu})})})]})})}function eu({"data-testid":e,"aria-label":t,className:a=""}){return r.jsx("span",{"data-testid":e,className:`w-2 h-2 rounded-full bg-blue-500 ${a}`.trim(),"aria-label":t})}let em=(0,l.memo)(function({path:e,className:t="w-5 h-5"}){return r.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:r.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:r.jsx(em,{path:ep.terminal})},{id:"history",label:"History",icon:r.jsx(em,{path:ep.history})},{id:"files",label:"Files",icon:r.jsx(em,{path:ep.files})},{id:"memo",label:"Memo",icon:r.jsx(em,{path:ep.memo})},{id:"info",label:"Info",icon:r.jsx(em,{path:ep.info})}];function ex({activeTab:e,onTabChange:t,hasNewOutput:a=!1,hasPrompt:n=!1,hasUpdate:s=!1}){let i=(0,l.useCallback)(t=>{let a=t===e;return`flex flex-col items-center justify-center flex-1 py-2 px-1 transition-colors relative ${a?"text-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"}`},[e]),o=(0,l.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[a&&r.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"}),n&&r.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"})]}),[a,n]);return r.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(a=>(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":e===a.id,"aria-label":a.label,onClick:()=>t(a.id),className:i(a.id),children:[a.icon,r.jsx("span",{className:"text-xs mt-1",children:a.label}),"terminal"===a.id&&o,"info"===a.id&&s&&r.jsx(eu,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":"Update available"})]},a.id))})}let ef={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:a,onRespond:n,onDismiss:s}){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),x=(0,l.useCallback)(e=>{u(e.touches[0].clientY)},[]),f=(0,l.useCallback)(e=>{if(null===d)return;let t=e.touches[0].clientY-d;t>0&&p(t)},[d]),b=(0,l.useCallback)(()=>{m>100&&s&&s(),p(0),u(null)},[m,s]),y=(0,l.useCallback)(()=>{s&&s()},[s]),w=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!i||!e)return null;let v="animate-fade-out"===o,j=m>0?`translateY(${m}px)`:void 0;return(0,r.jsxs)(g,{componentName:"MobilePromptSheet",children:[r.jsx("div",{"data-testid":"prompt-overlay",onClick:y,className:`fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ${v?"opacity-0":"opacity-100"} ${v?"pointer-events-none":""}`,"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:h,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":c,onClick:w,onTouchStart:x,onTouchMove:f,onTouchEnd:b,style:{transform:j},className:`fixed bottom-0 inset-x-0 bg-white rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ${v?"translate-y-full":"translate-y-0"}`,children:[r.jsx("div",{className:"flex justify-center pt-3 pb-2",children:r.jsx("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-gray-300 rounded-full","aria-hidden":"true"})}),r.jsx("div",{className:"px-4 pb-6",children:r.jsx(eb,{promptData:e,answering:a,onRespond:n,labelId:c})})]})]})}function eb({promptData:e,answering:t,onRespond:a,labelId:n}){let s=(0,f.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,x=t||u,g=(0,l.useCallback)(async e=>{if(!x){m(!0);try{await a(e)}catch{}finally{m(!1)}}},[x,a]),b=(0,l.useCallback)(async()=>{if(!x&&null!==i){m(!0);try{let e=h&&c.trim()?c.trim():i.toString();await a(e)}catch{}finally{m(!1)}}},[x,a,i,h,c]);return(0,r.jsxs)("div",{className:"space-y-4",children:[r.jsx("h3",{id:n,className:"text-lg font-semibold text-gray-900",children:s("confirmationFromClaude")}),e.instructionText&&r.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}),r.jsx("p",{className:"text-gray-700 leading-relaxed",children:e.question}),x&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",role:"status","aria-live":"polite",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),r.jsx("span",{children:s("sending")})]}),"yes_no"===e.type&&r.jsx(ey,{promptData:e,disabled:x,onYes:()=>g("yes"),onNo:()=>g("no")}),"multiple_choice"===e.type&&r.jsx(ew,{promptData:e,disabled:x,selectedOption:i,onSelectOption:o,textInputValue:c,onTextInputChange:d,showTextInput:h,onSubmit:b})]})}let ey=(0,l.memo)(function({promptData:e,disabled:t,onYes:a,onNo:n}){let s=(0,f.T)("prompt"),l="yes"===e.defaultOption,i="no"===e.defaultOption;return(0,r.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":"Yes or No options",children:[r.jsx("button",{type:"button",onClick:a,disabled:t,className:`flex-1 ${ef.base} ${ef.primary} ${l?"ring-2 ring-blue-300":""}`,children:s("yes")}),r.jsx("button",{type:"button",onClick:n,disabled:t,className:`flex-1 ${ef.base} ${i?ef.defaultSelected:ef.secondary}`,children:s("no")})]})}),ew=(0,l.memo)(function({promptData:e,disabled:t,selectedOption:a,onSelectOption:n,textInputValue:s,onTextInputChange:i,showTextInput:o,onSubmit:c}){let d=(0,l.useId)(),u=(0,f.T)("prompt");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[r.jsx("legend",{className:"sr-only",children:"Select an option"}),r.jsx("div",{className:"space-y-2",children:e.options.map(e=>{let s=a===e.number;return(0,r.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${s?"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:[r.jsx("input",{type:"radio",name:d,value:e.number,checked:s,onChange:()=>n(e.number),disabled:t,className:"mt-1"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&r.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,r.jsxs)("div",{className:"mt-3",children:[r.jsx("label",{htmlFor:`text-input-${d}`,className:"sr-only",children:"Custom value input"}),r.jsx("input",{id:`text-input-${d}`,type:"text",value:s,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"})]}),r.jsx("button",{type:"button",onClick:c,disabled:t||null===a,className:`w-full ${ef.base} ${ef.primary}`,children:u("submit")})]})});var ev=a(15470);let ej={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null},eN=(0,O.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,O.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,O.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,O.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,O.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,O.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"}]]),eM=(0,l.memo)(function({isOpen:e,position:t,targetPath:a,targetType:n,onClose:s,onNewFile:o,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m,onMove:p}){let h=(0,l.useRef)(null),x=(0,l.useCallback)(e=>{e&&a&&e(a),s()},[a,s]),f=[{id:"new-file",label:"New File",icon:r.jsx(eN,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>x(o),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:r.jsx(ek,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>x(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:r.jsx(eC,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>x(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:r.jsx(eS,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>x(d)},{id:"move",label:"Move",icon:r.jsx(eT,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{p&&a&&n&&p(a,n),s()},showDividerAfter:!0},{id:"delete",label:"Delete",icon:r.jsx(eE,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>x(u),variant:"danger"}].filter(e=>!e.showFor||n&&e.showFor.includes(n));return((0,l.useEffect)(()=>{if(!e)return;let t=e=>{if("Escape"===e.key){s();return}if("ArrowDown"===e.key||"ArrowUp"===e.key){let t;e.preventDefault();let a=h.current?.querySelectorAll('[role="menuitem"]');if(!a?.length)return;let r=Array.from(a).findIndex(e=>e===document.activeElement);t="ArrowDown"===e.key?r<a.length-1?r+1:0:r>0?r-1:a.length-1,a[t].focus()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,s]),(0,l.useEffect)(()=>{if(e&&h.current){let e=h.current.querySelector('[role="menuitem"]');e&&e.focus()}},[e]),e)?r.jsx("div",{ref:h,"data-testid":"context-menu",role:"menu","aria-label":"File actions",className:"fixed z-50 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:{left:`${t.x}px`,top:`${t.y}px`},children:f.map((e,t)=>(0,r.jsxs)(i().Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem",onClick:e.onClick,disabled:!a,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"} ${a?"":"opacity-50 cursor-not-allowed"}`,children:[e.icon,r.jsx("span",{children:e.label})]}),e.showDividerAfter&&t<f.length-1&&r.jsx("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});var eA=a(352),eR=a(41593),e_=a(34643);let eL=(0,l.memo)(function({expanded:e}){return r.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:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),eD=(0,l.memo)(function({open:e}){return r.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?r.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"}):r.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"})})}),eP=(0,l.memo)(function({text:e,query:t}){if(!t||!t.trim())return r.jsx(r.Fragment,{children:e});let a=(0,ei.hr)(t),n=e.split(RegExp(`(${a})`,"gi"));return r.jsx(r.Fragment,{children:n.map((e,a)=>e.toLowerCase()===t.toLowerCase()?r.jsx("mark",{className:"bg-yellow-200 text-gray-900 px-0.5 rounded",children:e},a):r.jsx("span",{children:e},a))})}),eO=(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 r.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:r.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"})})}),eI=(0,l.memo)(function e({item:t,path:a,depth:n,worktreeId:s,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:x,dateFnsLocaleStr:f}){var g;let[b,y]=(0,l.useState)(!1),w=a?`${a}/${t.name}`:t.name,v=i.has(w),j="directory"===t.type,N=o.get(w),k=(0,l.useCallback)(async()=>{j?(v||N||(y(!0),await u(w),y(!1)),c(w)):d?.(w)},[j,v,N,w,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,w,j?"directory":"file")},[w,j,m]),T=function({delay:e=500,moveThreshold:t=10,onLongPress:a}){let r=(0,l.useRef)(null),n=(0,l.useRef)(null),s=(0,l.useRef)(null),i=(0,l.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),n.current=null,s.current=null},[]),o=(0,l.useCallback)(t=>{if(1!==t.touches.length)return;let l=t.touches[0];n.current={x:l.clientX,y:l.clientY},s.current=t,r.current=setTimeout(()=>{s.current&&a(s.current),i()},e)},[e,a,i]);return{onTouchStart:o,onTouchMove:(0,l.useCallback)(e=>{if(!n.current||1!==e.touches.length)return;let a=e.touches[0],r=a.clientX-n.current.x,s=a.clientY-n.current.y;Math.sqrt(r*r+s*s)>t&&i()},[t,i]),onTouchEnd:(0,l.useCallback)(()=>{i()},[i]),onTouchCancel:(0,l.useCallback)(()=>{i()},[i])}}({onLongPress:(0,l.useCallback)(e=>{m?.(e,w,j?"directory":"file")},[w,j,m])}),E={paddingLeft:`${.5+1*Math.min(n,20)}rem`,touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":`tree-item-${t.name}`,role:"treeitem","aria-selected":!1,"aria-expanded":j?v: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?r.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:b?r.jsx("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):r.jsx(eL,{expanded:v})}):r.jsx("span",{className:"w-4 h-4"}),j?r.jsx(eD,{open:v}):r.jsx(eO,{extension:t.extension}),r.jsx("span",{className:"flex-1 truncate text-sm text-gray-700",children:"name"===h&&p?r.jsx(eP,{text:t.name,query:p}):t.name}),r.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&&r.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",title:t.birthtime,children:function(e,t){let a=new Date(e);return isNaN(a.getTime())?"":(0,eA.Q)(a,{addSuffix:!0,...t?{locale:t}:{}})}(t.birthtime,f?(0,eR.G)(f):void 0)})]}),j&&v&&N&&r.jsx("div",{role:"group",children:N.filter(e=>{let t=w?`${w}/${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&&x&&x.size>0){if(x.has(t))return!0;if("directory"===e.type){for(let e of x)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>r.jsx(e,{item:t,path:w,depth:n+1,worktreeId:s,expanded:i,cache:o,onToggle:c,onFileSelect:d,onLoadChildren:u,onContextMenu:m,searchQuery:p,searchMode:h,matchedPaths:x,dateFnsLocaleStr:f},t.name))})]})}),e$=(0,l.memo)(function({worktreeId:e,onFileSelect:t,onNewFile:a,onNewDirectory:n,onRename:s,onDelete:i,onUpload:o,onMove:c,className:d="",refreshTrigger:u=0,searchQuery:m,searchMode:p,searchResults:h,onSearchResultSelect:x}){let f=(0,e_.bU)(),[g,b]=(0,l.useState)(!0),[y,w]=(0,l.useState)(null),[v,j]=(0,l.useState)([]),[N,k]=(0,l.useState)(new Set),[C,S]=(0,l.useState)(()=>new Map),T=(0,l.useRef)(N);T.current=N;let E=(0,l.useRef)(new Set),{menuState:M,openMenu:A,closeMenu:R}=function(){let[e,t]=(0,l.useState)(ej);return{menuState:e,openMenu:(0,l.useCallback)((e,a,r)=>{let n,s;if(e.preventDefault(),"touches"in e&&e.touches.length>0)n=e.touches[0].clientX,s=e.touches[0].clientY;else{if(!("clientX"in e))return;n=e.clientX,s=e.clientY}t({isOpen:!0,position:{x:n,y:s},targetPath:a,targetType:r})},[]),closeMenu:(0,l.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),resetMenu:(0,l.useCallback)(()=>{t(ej)},[])}}(),_=(0,l.useCallback)(async(t="")=>{try{let a=t?`/api/worktrees/${e}/tree/${t}`:`/api/worktrees/${e}/tree`,r=await fetch(a);if(!r.ok)throw Error(`Failed to load directory: ${r.status}`);return await r.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 _();if(!e||!t)return;let a=Array.from(T.current),r=new Map,n=[];for(let t=0;t<a.length;t+=5){if(!e)return;let s=a.slice(t,t+5);for(let[e,t]of(await Promise.allSettled(s.map(async e=>{let t=await _(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?r.set(t.value.dirPath,t.value.data.items):n.push(s[e])}if(!e)return;j(t.items),S(r),n.length>0&&k(e=>{let t=new Set(e);for(let e of n)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}},[_,u]);let L=(0,l.useCallback)(async e=>{if(!(C.has(e)||E.current.has(e))){E.current.add(e);try{let t=await _(e);t&&S(a=>{let r=new Map(a);return r.set(e,t.items),r})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{E.current.delete(e)}}},[C,_]),D=(0,l.useCallback)(e=>{k(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),P=(0,l.useMemo)(()=>"content"===p&&h&&0!==h.length?(0,ei.Ps)(h.map(e=>e.filePath)):new Set,[p,h]);(0,l.useEffect)(()=>{P.size>0&&k(e=>{let t=new Set(e);for(let e of P)(C.has(e)||h?.some(t=>t.filePath.startsWith(e+"/")))&&t.add(e);return t})},[P,C,h]);let O=(0,l.useMemo)(()=>{if(!m?.trim())return v;if("name"===p){let e=m.toLowerCase(),t=(a,r)=>a.filter(a=>{let n=r?`${r}/${a.name}`:a.name,s=a.name.toLowerCase().includes(e);if("directory"===a.type){let e=C.get(n);if(e&&t(e,n).length>0)return!0}return s});return t(v,"")}return"content"===p&&P.size>0?v.filter(e=>{if(P.has(e.name))return!0;if("directory"===e.type){for(let t of P)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):v},[v,m,p,P,C]);return g?(0,r.jsxs)("div",{"data-testid":"file-tree-loading",className:`flex items-center justify-center p-4 ${d}`,children:[r.jsx("span",{className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),r.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Loading files..."})]}):y?r.jsx("div",{"data-testid":"file-tree-error",className:`p-4 bg-red-50 border border-red-200 rounded-lg ${d}`,children:r.jsx("p",{className:"text-sm text-red-600",children:y})}):0===v.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:`p-4 text-center text-gray-500 ${d}`,children:[r.jsx("p",{className:"text-sm",children:"No files found"}),(a||n)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)("button",{"data-testid":"empty-new-file-button",onClick:()=>a(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:[r.jsx(eN,{className:"w-4 h-4","aria-hidden":"true"}),r.jsx("span",{children:"New File"})]}),n&&(0,r.jsxs)("button",{"data-testid":"empty-new-directory-button",onClick:()=>n(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:[r.jsx(ek,{className:"w-4 h-4","aria-hidden":"true"}),r.jsx("span",{children:"New Directory"})]})]})]}):m?.trim()&&0===O.length?r.jsx("div",{"data-testid":"file-tree-no-results",className:`p-4 text-center text-gray-500 ${d}`,children:(0,r.jsxs)("p",{className:"text-sm",children:["No ","content"===p?"files containing":"files matching",' "',m,'"']})}):(0,r.jsxs)("div",{"data-testid":"file-tree-view",role:"tree","aria-label":"File tree",className:`overflow-auto bg-white ${d}`,children:[O.map(a=>r.jsx(eI,{item:a,path:"",depth:0,worktreeId:e,expanded:N,cache:C,onToggle:D,onFileSelect:x||t,onLoadChildren:L,onContextMenu:A,searchQuery:m,searchMode:p,matchedPaths:P,dateFnsLocaleStr:f},a.name)),r.jsx(eM,{isOpen:M.isOpen,position:M.position,targetPath:M.targetPath,targetType:M.targetType,onClose:R,onNewFile:a,onNewDirectory:n,onRename:s,onDelete:i,onUpload:o,onMove:c})]})}),eF=(0,l.memo)(function(){return r.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),ez=(0,l.memo)(function(){return r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),eU=(0,l.memo)(function(){return r.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..."})}),eW=(0,l.memo)(function({query:e,mode:t,isSearching:a,error:n,onQueryChange:s,onModeChange:i,onClear:o,placeholder:c="Search files...",className:d=""}){let u=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{s(e.target.value)},[s]),p=(0,l.useCallback)(()=>{o(),u.current?.focus()},[o]),h=(0,l.useCallback)(t=>{"Escape"===t.key&&(e?p():u.current?.blur())},[e,p]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<768)){let e=setTimeout(()=>{u.current?.focus()},100);return()=>clearTimeout(e)}},[]),(0,r.jsxs)("div",{"data-testid":"search-bar",className:`flex flex-col gap-2 p-2 bg-white border-b border-gray-200 ${d}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx(eF,{})}),r.jsx("input",{ref:u,type:"text","data-testid":"search-input",value:e,onChange:m,onKeyDown:h,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":a}),r.jsx("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?r.jsx(eU,{}):e?r.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:r.jsx(ez,{})}):null})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"Mode:"}),r.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"}),r.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"})]}),n&&r.jsx("div",{"data-testid":"search-error",className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded",role:"alert",children:n})]})}),eB=(0,l.memo)(function(){return r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eH=(0,l.memo)(function(){return r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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 r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})})}),eV=[{id:"history",label:"History",icon:r.jsx(eB,{})},{id:"files",label:"Files",icon:r.jsx(eH,{})},{id:"memo",label:"Memo",icon:r.jsx(eq,{})}],eG=(0,l.memo)(function({activeTab:e,onTabChange:t,className:a=""}){let n=(0,l.useCallback)(e=>{t(e)},[t]),s=(0,l.useCallback)((e,a)=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),t(e))},[t]),i=(0,l.useCallback)(t=>{let a=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 ${a?"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 r.jsx("div",{role:"tablist","aria-label":"Left pane view switcher",className:`flex border-b border-gray-200 bg-white ${a}`,children:eV.map(t=>(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":e===t.id,"aria-label":t.label,tabIndex:0,onClick:()=>n(t.id),onKeyDown:e=>s(t.id,e),className:i(t.id),children:[t.icon,r.jsx("span",{children:t.label})]},t.id))})});var eY=a(77758);function eZ({src:e,alt:t,onError:a}){let[n,s]=(0,l.useState)(!1);return n?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[r.jsx("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})}),r.jsx("p",{className:"text-sm",children:"Failed to load image"}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t})]}):r.jsx("div",{className:"flex items-center justify-center p-4",children:r.jsx("img",{src:e,alt:t,onError:()=>{s(!0),a?.()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}let eK=(0,O.Z)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function eX({isOpen:e,onClose:t,worktreeId:a,filePath:n}){let[s,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)(()=>!!(s?.content&&!s.isImage),[s]),x=(0,l.useCallback)(async()=>{if(h&&s?.content)try{await (0,G.v)(s.content),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[h,s]);return r.jsx(eY.u_,{isOpen:e,onClose:t,title:n,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] overflow-y-auto",children:[o&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[r.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),r.jsx("p",{className:"ml-3 text-gray-600",children:"Loading file..."})]}),d&&r.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[r.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),r.jsx("p",{className:"text-sm text-red-800",children:d})]})}),s&&!o&&!d&&(0,r.jsxs)("div",{className:"bg-gray-50 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"bg-gray-100 px-4 py-2 border-b border-gray-200 flex items-center justify-between",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-600 font-mono truncate",children:[s.worktreePath,"/",s.path]}),h&&r.jsx("button",{"data-testid":"copy-content-button",onClick:x,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?r.jsx(eK,{className:"w-4 h-4 text-green-600"}):r.jsx(I,{className:"w-4 h-4"})})]}),s.isImage?r.jsx(eZ,{src:s.content,alt:s.path,mimeType:s.mimeType}):r.jsx("div",{className:"p-4",children:r.jsx("pre",{className:"text-sm overflow-x-auto",children:r.jsx("code",{className:`language-${s.extension}`,children:s.content})})})]})]})})}var eJ=a(60962),eQ=a(83173),e0=a(26394),e1=a(43286),e2=a(72339);let e4=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],e5={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...e4,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...e4],h2:[["className","sr-only"]],img:[...e4,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...e4,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...e4],table:[...e4],ul:[...e4,["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"]},e3={}.hasOwnProperty;function e6(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:"",a=e.indexOf("-->"),r={type:"comment",value:a<0?e:e.slice(0,a)};return te(r,t),r}}(e,t);case"doctype":return function(e,t){if(e.schema.allowDoctypes){let e={type:"doctype"};return te(e,t),e}}(e,t);case"element":return function(e,t){let a="string"==typeof t.tagName?t.tagName:"";e.stack.push(a);let r=e8(e,t.children),n=function(e,t){let a;let r=e.stack[e.stack.length-1],n=e.schema.attributes,s=e.schema.required,l=n&&e3.call(n,r)?n[r]:void 0,i=n&&e3.call(n,"*")?n["*"]:void 0,o=t&&"object"==typeof t?t:{},c={};for(a in o)if(e3.call(o,a)){let t=o[a],r=e7(e,tt(l,a),a,t);null==r&&(r=e7(e,tt(i,a),a,t)),null!=r&&(c[a]=r)}if(s&&e3.call(s,r)){let e=s[r];for(a in e)e3.call(e,a)&&!e3.call(c,a)&&(c[a]=e[a])}return c}(e,t.properties);e.stack.pop();let s=!1;if(a&&"*"!==a&&(!e.schema.tagNames||e.schema.tagNames.includes(a))&&(s=!0,e.schema.ancestors&&e3.call(e.schema.ancestors,a))){let t=e.schema.ancestors[a],r=-1;for(s=!1;++r<t.length;)e.stack.includes(t[r])&&(s=!0)}if(!s)return e.schema.strip&&!e.schema.strip.includes(a)?r:void 0;let l={type:"element",tagName:a,properties:n,children:r};return te(l,t),l}(e,t);case"root":return function(e,t){let a={type:"root",children:e8(e,t.children)};return te(a,t),a}(e,t);case"text":return function(e,t){let a={type:"text",value:"string"==typeof t.value?t.value:""};return te(a,t),a}(0,t)}}function e8(e,t){let a=[];if(Array.isArray(t)){let r=-1;for(;++r<t.length;){let n=e6(e,t[r]);n&&(Array.isArray(n)?a.push(...n):a.push(n))}}return a}function e7(e,t,a,r){return t?Array.isArray(r)?function(e,t,a,r){let n=-1,s=[];for(;++n<r.length;){let l=e9(e,t,a,r[n]);("number"==typeof l||"string"==typeof l)&&s.push(l)}return s}(e,t,a,r):e9(e,t,a,r):void 0}function e9(e,t,a,r){if(("boolean"==typeof r||"number"==typeof r||"string"==typeof r)&&function(e,t,a){let r=e.schema.protocols&&e3.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||0===r.length)return!0;let n=String(a),s=n.indexOf(":"),l=n.indexOf("?"),i=n.indexOf("#"),o=n.indexOf("/");if(s<0||o>-1&&s>o||l>-1&&s>l||i>-1&&s>i)return!0;let c=-1;for(;++c<r.length;){let e=r[c];if(s===e.length&&n.slice(0,e.length)===e)return!0}return!1}(e,a,r)){if("object"==typeof t&&t.length>1){let e=!1,a=0;for(;++a<t.length;){let n=t[a];if(n&&"object"==typeof n&&"flags"in n){if(n.test(String(r))){e=!0;break}}else if(n===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(a)?e.schema.clobberPrefix+r:r}}function te(e,t){let a=(0,e2.FK)(t);t.data&&(e.data=(0,e1.ZP)(t.data)),a&&(e.position=a)}function tt(e,t){let a;let r=-1;if(e)for(;++r<e.length;){let n=e[r],s="string"==typeof n?n:n[0];if(s===t)return n;"data*"===s&&(a=n)}if(t.length>4&&"data"===t.slice(0,4).toLowerCase())return a}function ta(e){return function(t){return function(e,t){let a={type:"root",children:[]},r=e6({schema:t?{...e5,...t}:e5,stack:[]},e);return r&&(Array.isArray(r)?1===r.length?a=r[0]:a.children=r:a=r),a}(t,e)}}var tr=a(42283);a(4803);let tn=(0,O.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"}]]),ts=(0,O.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"}]]),tl=(0,O.Z)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),ti=(0,O.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"}]]),to=(0,O.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"}]]),tc=(0,O.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"}]]),td=(0,O.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 tu=a(94019),tm=a(11865),tp=a(43353),th=a.n(tp);let tx=(0,O.Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),tf=th()(async()=>{},{loadableGenerated:{modules:["components/worktree/MermaidCodeBlock.tsx -> ./MermaidDiagram"]},ssr:!1,loading:()=>(0,r.jsxs)("div",{className:"mermaid-loading flex items-center gap-2 text-gray-500 p-4",children:[r.jsx(tx,{className:"animate-spin h-4 w-4"}),r.jsx("span",{children:"Loading diagram..."})]})});function tg({className:e,children:t,inline:a}){if(a)return r.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 r.jsx(tf,{code:e})}return r.jsx("code",{className:e,children:t})}function tb(){return"undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}async function ty(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 tw(){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 tv(e){let{key:t,defaultValue:a,validate:r,serialize:n=JSON.stringify,deserialize:s=JSON.parse}=e,[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(a);(0,l.useCallback)(()=>a,[t,a,r,s]);let u=(0,l.useCallback)(e=>{},[t,n]);return{value:c,setValue:(0,l.useCallback)(e=>{d(t=>{let a="function"==typeof e?e(t):e;return u(a),a})},[u]),removeValue:(0,l.useCallback)(()=>{d(a)},[t,a]),isAvailable:i}}let tj=()=>!1;var tN=a(22202);let tk={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"}},tC={WARNING_THRESHOLD:512e3};function tS(e){return"number"==typeof e&&e>=.1&&e<=.9}function tT(e){return"boolean"==typeof e}function tE({worktreeId:e,filePath:t,onClose:a,onSave:n,initialViewMode:s,onMaximizedChange:i}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(""),[x,f]=(0,l.useState)(()=>s&&("split"===s||"editor"===s||"preview"===s)?s:"split"),[g,b]=(0,l.useState)(!0),[y,w]=(0,l.useState)(!1),[v,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:L,removeToast:D}=(0,tm.pm)(),P=(0,l.useRef)(null);(0,l.useRef)(null);let O=(0,l.useRef)(null),$=(0,l.useRef)(null),F=(0,h.d)(),{isKeyboardVisible:z,keyboardHeight:U}=function(){let[e,t]=(0,l.useState)(!1),[a,r]=(0,l.useState)(0);return(0,l.useCallback)(()=>{if(!tj())return;let e=window.visualViewport,a=window.innerHeight-e.height,n=a>100;t(n),r(n?a:0)},[]),{isKeyboardVisible:e,keyboardHeight:a}}(),{value:W,setValue:B}=tv({key:"commandmate:md-editor-maximized",defaultValue:!1,validate:tT}),{isFullscreen:H,isFallbackMode:q,enterFullscreen:V,exitFullscreen:Y,toggleFullscreen:Z}=function(e={}){let{elementRef:t,onEnter:a,onExit:r,onError:n}=e,[s,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null);(0,l.useCallback)(()=>{let e=null!=tb();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),a?.();return}if("undefined"!=typeof document&&(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&t?.current)try{await ty(t.current),i(!0),c(!1),a?.()}catch(t){let e=t instanceof Error?t.message:"Failed to enter fullscreen";u(e),n?.(t instanceof Error?t:Error(e)),i(!0),c(!0),a?.()}else i(!0),c(!0),a?.()},[t,a,n]),p=(0,l.useCallback)(async()=>{if(u(null),o){i(!1),c(!1),r?.();return}if(tb())try{await tw(),i(!1),r?.()}catch(t){let e=t instanceof Error?t.message:"Failed to exit fullscreen";u(e),n?.(t instanceof Error?t:Error(e)),i(!1),c(!1),r?.()}else i(!1),c(!1),r?.()},[o,r,n]),h=(0,l.useCallback)(async()=>{s?await p():await m()},[s,m,p]);return{isFullscreen:s,isFallbackMode:o,enterFullscreen:m,exitFullscreen:p,toggleFullscreen:h,error:d}}({elementRef:O,onEnter:()=>B(!0),onExit:()=>B(!1)}),{value:K,setValue:X}=tv({key:"commandmate:md-editor-split-ratio",defaultValue:.5,validate:tS}),{ref:J}=function(e={}){let{onSwipeLeft:t,onSwipeRight:a,onSwipeUp:r,onSwipeDown:n,threshold:s=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;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],a=t.clientX-p.current.x,r=t.clientY-p.current.y,n=Math.abs(a),l=Math.abs(r);n>l&&n>=s?m(a<0?"left":"right"):l>=s&&m(r<0?"up":"down")},[i,s]),(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>=s&&(o<0?(m("left"),t?.()):(m("right"),a?.())):h>=s&&(c<0?(m("up"),r?.()):(m("down"),n?.())),p.current=null,d(!1)},[i,s,t,a,r,n]),{ref:o,isSwiping:c,swipeDirection:u,resetSwipeDirection:h}}({onSwipeDown:()=>{H&&Y()},threshold:100,enabled:H&&F}),Q=o!==d,ee=tk[x],et=F&&!1,ea=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{p(e)},300),[]);(0,l.useCallback)(async()=>{b(!0),j(null);try{let a=await fetch(`/api/worktrees/${e}/files/${t}`),r=await a.json();if(!a.ok||!r.success)throw Error(r.error?.message||"Failed to load file");let n=r.content||"";c(n),u(n),p(n),new Blob([n]).size>tC.WARNING_THRESHOLD&&C(!0)}catch(e){j(e instanceof Error?e.message:"Failed to load file")}finally{b(!1)}},[e,t]);let er=(0,l.useCallback)(async()=>{if(Q&&!y){w(!0);try{let a=await fetch(`/api/worktrees/${e}/files/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o})}),r=await a.json();if(!a.ok||!r.success)throw Error(r.error?.message||"Failed to save file");u(o),L("File saved successfully","success"),n&&n(t)}catch(e){L(e instanceof Error?e.message:"Failed to save file","error")}finally{w(!1)}}},[e,t,o,Q,y,n,L]),en=(0,l.useCallback)(e=>{let t=e.target.value;c(t),ea(t)},[ea]),es=(0,l.useCallback)(e=>{f(e)},[]),el=(0,l.useCallback)(()=>{(!Q||window.confirm("You have unsaved changes. Are you sure you want to close?"))&&a&&a()},[Q,a]),eo=(0,l.useCallback)(async()=>{try{await (0,G.v)(o),T(!0),setTimeout(()=>T(!1),2e3)}catch{}},[o]),ec=(0,l.useCallback)(e=>{if(!$.current)return;let t=$.current.offsetWidth;if(0===t)return;let a=e/t;X(e=>Math.max(.1,Math.min(.9,e+a)))},[X]),ed=(0,l.useCallback)(()=>{X(.5)},[X]),eu=(0,l.useCallback)(e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),er();return}if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F"===e.key){e.preventDefault(),Z();return}if("Escape"===e.key&&H){e.preventDefault(),Y();return}},[er,Z,Y,H]),em=(0,l.useMemo)(()=>{let e="flex flex-col bg-white";return H&&q?`${e} fixed inset-0`:`${e} h-full`},[H,q]),ep=(0,l.useMemo)(()=>{if(H)return{zIndex:tN.k.MAXIMIZED_EDITOR}},[H]),eh=(0,l.useMemo)(()=>{if("split"===x&&!et)return{width:`${100*K}%`,flexShrink:0}},[x,K,et]),ex=(0,l.useMemo)(()=>{if("split"===x&&!et)return{width:`${(1-K)*100}%`,flexShrink:0}},[x,K,et]),ef=(0,l.useMemo)(()=>{if(z&&U>0)return{paddingBottom:U}},[z,U]),eg=(0,l.useMemo)(()=>({code:tg}),[]),eb=(0,l.useMemo)(()=>r.jsx(eQ.UG,{remarkPlugins:[e0.Z],rehypePlugins:[ta,tr.Z],components:eg,children:m}),[m,eg]);if(g)return r.jsx("div",{"data-testid":"markdown-editor",className:"flex items-center justify-center h-full bg-white",children:(0,r.jsxs)("div",{className:"text-center",children:[r.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),r.jsx("p",{className:"mt-4 text-gray-600",children:"Loading..."})]})});if(v)return r.jsx("div",{"data-testid":"markdown-editor-error",className:"flex items-center justify-center h-full bg-white",children:(0,r.jsxs)("div",{className:"text-center",children:[r.jsx(tn,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),r.jsx("p",{className:"text-red-600",children:v}),a&&r.jsx("button",{onClick:a,className:"mt-4 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg",children:"Close"})]})});let ey=(0,r.jsxs)("div",{ref:e=>{O.current=e,J.current=e},"data-testid":"markdown-editor",className:em,style:ep,onKeyDown:eu,role:H&&q?"dialog":void 0,"aria-modal":H&&q?"true":void 0,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 bg-gray-50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-shrink",children:[r.jsx(ts,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),r.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:t}),Q&&r.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,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!et&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[r.jsx("button",{"data-testid":"view-mode-split","aria-pressed":"split"===x,onClick:()=>es("split"),className:`p-1.5 rounded ${"split"===x?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Split view",children:r.jsx(tl,{className:"h-4 w-4"})}),r.jsx("button",{"data-testid":"view-mode-editor","aria-pressed":"editor"===x,onClick:()=>es("editor"),className:`p-1.5 rounded ${"editor"===x?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Editor only",children:r.jsx(ts,{className:"h-4 w-4"})}),r.jsx("button",{"data-testid":"view-mode-preview","aria-pressed":"preview"===x,onClick:()=>es("preview"),className:`p-1.5 rounded ${"preview"===x?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,title:"Preview only",children:r.jsx(ti,{className:"h-4 w-4"})})]}),r.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?r.jsx(eK,{className:"h-4 w-4"}):r.jsx(I,{className:"h-4 w-4"})}),r.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:H?"Exit fullscreen (ESC)":"Enter fullscreen (Ctrl+Shift+F)","aria-pressed":H,children:H?r.jsx(to,{className:"h-4 w-4"}):r.jsx(tc,{className:"h-4 w-4"})}),(0,r.jsxs)("button",{"data-testid":"save-button",onClick:er,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:[r.jsx(td,{className:"h-4 w-4"}),y?"Saving...":"Save"]}),a&&r.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:r.jsx(tu.Z,{className:"h-4 w-4"})})]})]}),H&&(0,r.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,r.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:[r.jsx(tn,{className:"h-4 w-4"}),"Large file: Performance may be affected.",r.jsx("button",{onClick:()=>C(!1),className:"ml-auto text-yellow-600 hover:text-yellow-800",children:r.jsx(tu.Z,{className:"h-4 w-4"})})]}),et&&(0,r.jsxs)("div",{className:"flex border-b border-gray-200",children:[(0,r.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:[r.jsx(ts,{className:"h-4 w-4 inline-block mr-1"}),"Editor"]}),(0,r.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:[r.jsx(ti,{className:"h-4 w-4 inline-block mr-1"}),"Preview"]})]}),(0,r.jsxs)("div",{ref:$,className:"flex flex-1 overflow-hidden",style:ef,children:[et?"editor"===E&&r.jsx("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden w-full",children:r.jsx("textarea",{ref:P,"data-testid":"markdown-editor-textarea",value:o,onChange:en,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})}):r.jsx("div",{"data-testid":"markdown-editor-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showEditor?"":"hidden"}`,style:"split"===x?eh:{width:ee.showEditor?"100%":"0%"},children:r.jsx("textarea",{ref:P,"data-testid":"markdown-editor-textarea",value:o,onChange:en,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"===x&&ee.showEditor&&ee.showPreview&&!et&&r.jsx(N,{onResize:ec,onDoubleClick:ed,orientation:"horizontal",ariaValueNow:Math.round(100*K),minRatio:.1}),et?"preview"===E&&r.jsx("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden w-full",children:r.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:eb})}):r.jsx("div",{"data-testid":"markdown-preview-container",className:`flex flex-col overflow-hidden transition-all duration-200 ${ee.showPreview?"":"hidden"}`,style:"split"===x?ex:{width:ee.showPreview?"100%":"0%"},children:r.jsx("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:eb})})]}),r.jsx(tm.Ix,{toasts:_,onClose:D})]});return H&&q&&A?(0,eJ.createPortal)(ey,A):ey}let tM=[".md"],tA=[{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:".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"]}],tR=tA.map(e=>e.extension);var t_=a(73002);function tL({value:e,saveFn:t,debounceMs:a=300,disabled:r=!1,maxRetries:n=3,onSaveComplete:s}){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)(s),h=(0,l.useRef)(null),x=(0,l.useRef)(!0);(0,l.useRef)(e);let f=(0,l.useCallback)(async e=>{if(!x.current)return;o(!0),d(null);let t=null,a=0;for(;a<=n;)try{await m.current(e),x.current&&(o(!1),d(null),p.current?.());return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++a<=n){let e=1e3*Math.pow(2,a-1);await new Promise(t=>setTimeout(t,e))}}x.current&&(o(!1),d(t))},[n]),g=(0,l.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);return{isSaving:i,error:c,saveNow:(0,l.useCallback)(async()=>{r||(g(),await f(u.current))},[r,g,f])}}let tD=(0,l.memo)(function({memo:e,onUpdate:t,onDelete:a,isSaving:n,error:s,className:i=""}){let[o,c]=(0,l.useState)(e.title),[d,u]=(0,l.useState)(e.content),{isSaving:m,error:p,saveNow:h}=tL({value:o,saveFn:async a=>{await t(e.id,{title:a})}}),{isSaving:x,error:f,saveNow:g}=tL({value:d,saveFn:async a=>{await t(e.id,{content:a})}}),b=s??p?.message??f?.message??null,y=(0,l.useCallback)(e=>{c(e.target.value)},[]),w=(0,l.useCallback)(e=>{u(e.target.value)},[]),v=(0,l.useCallback)(()=>{h()},[h]),j=(0,l.useCallback)(()=>{g()},[g]),N=(0,l.useCallback)(()=>{a(e.id)},[e.id,a]);return(0,r.jsxs)("div",{"data-testid":"memo-card",className:`bg-white border border-gray-200 rounded-lg p-4 space-y-3 ${i}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"text",value:o,onChange:y,onBlur:v,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"}),(n??(m||x))&&r.jsx("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),r.jsx("button",{type:"button",onClick:N,"aria-label":"Delete memo",className:"p-1 text-gray-400 hover:text-red-500 transition-colors rounded",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})})})]}),r.jsx("textarea",{value:d,onChange:w,onBlur:j,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"}),b&&r.jsx("div",{className:"text-xs text-red-500",children:b})]})}),tP=(0,l.memo)(function({currentCount:e,maxCount:t,onAdd:a,isLoading:n=!1,className:s=""}){let l=e>=t||n;return(0,r.jsxs)("div",{"data-testid":"memo-add-button",className:`flex flex-col items-center gap-2 ${s}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{l||a()},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}){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:"Memo",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,I.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,I.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,I.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,I.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,I.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,I.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.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"})})}),e$=(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(eP,{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))})]})}),eF=(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}){let x=(0,eO.bU)(),[g,y]=(0,l.useState)(!0),[b,v]=(0,l.useState)(null),[w,j]=(0,l.useState)([]),[N,k]=(0,l.useState)(new Set),[C,S]=(0,l.useState)(()=>new Map),T=(0,l.useRef)(N);T.current=N;let E=(0,l.useRef)(new Set),{menuState:M,openMenu:A,closeMenu:R}=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)},[])}}(),_=(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),v(null);try{let t=await _();if(!e||!t)return;let r=Array.from(T.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 _(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;j(t.items),S(a),s.length>0&&k(e=>{let t=new Set(e);for(let e of s)e&&t.delete(e);return t})}catch(t){e&&v(t instanceof Error?t.message:"Failed to load files")}finally{e&&y(!1)}})(),()=>{e=!1}},[_,u]);let O=(0,l.useCallback)(async e=>{if(!(C.has(e)||E.current.has(e))){E.current.add(e);try{let t=await _(e);t&&S(r=>{let a=new Map(r);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{E.current.delete(e)}}},[C,_]),P=(0,l.useCallback)(e=>{k(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&&k(e=>{let t=new Set(e);for(let e of L)(C.has(e)||h?.some(t=>t.filePath.startsWith(e+"/")))&&t.add(e);return t})},[L,C,h]);let I=(0,l.useMemo)(()=>{if(!m?.trim())return w;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=C.get(s);if(e&&t(e,s).length>0)return!0}return n});return t(w,"")}return"content"===p&&L.size>0?w.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}):w},[w,m,p,L,C]);return g?(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..."})]}):b?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:b})}):0===w.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)&&(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"})]})]}),I.map(r=>a.jsx(e$,{item:r,path:"",depth:0,worktreeId:e,expanded:N,cache:C,onToggle:P,onFileSelect:f||t,onLoadChildren:O,onContextMenu:A,searchQuery:m,searchMode:p,matchedPaths:L,dateFnsLocaleStr:x},r.name)),a.jsx(eA,{isOpen:M.isOpen,position:M.position,targetPath:M.targetPath,targetType:M.targetType,onClose:R,onNewFile:r,onNewDirectory:s,onRename:n,onDelete:i,onUpload:o,onMove:c})]})}),ez=(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"})})}),eH=(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"})})}),eW=(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..."})}),eB=(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(ez,{})}),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(eW,{}):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(eH,{})}):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})]})}),eU=(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"})})}),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:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),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:"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"})})}),eq=[{id:"history",label:"History",icon:a.jsx(eU,{})},{id:"files",label:"Files",icon:a.jsx(eG,{})},{id:"memo",label:"Memo",icon:a.jsx(eV,{})}],eY=(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:eq.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 eZ=r(77758),eK=r(81194),eX=r(89918);let eJ=(0,I.Z)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function eQ({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(eZ.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(eJ,{className:"w-4 h-4 text-green-600"}):a.jsx(D,{className:"w-4 h-4"})})]}),n.isImage?a.jsx(eK.O,{src:n.content,alt:n.path,mimeType:n.mimeType}):n.isVideo?a.jsx(eX.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 e0=r(60962),e1=r(83173),e2=r(26394),e4=r(43286),e5=r(72339);let e3=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],e6={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...e3,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...e3],h2:[["className","sr-only"]],img:[...e3,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...e3,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...e3],table:[...e3],ul:[...e3,["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"]},e8={}.hasOwnProperty;function e7(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 tr(a,t),a}}(e,t);case"doctype":return function(e,t){if(e.schema.allowDoctypes){let e={type:"doctype"};return tr(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=e9(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&&e8.call(s,a)?s[a]:void 0,i=s&&e8.call(s,"*")?s["*"]:void 0,o=t&&"object"==typeof t?t:{},c={};for(r in o)if(e8.call(o,r)){let t=o[r],a=te(e,ta(l,r),r,t);null==a&&(a=te(e,ta(i,r),r,t)),null!=a&&(c[r]=a)}if(n&&e8.call(n,a)){let e=n[a];for(r in e)e8.call(e,r)&&!e8.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&&e8.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 tr(l,t),l}(e,t);case"root":return function(e,t){let r={type:"root",children:e9(e,t.children)};return tr(r,t),r}(e,t);case"text":return function(e,t){let r={type:"text",value:"string"==typeof t.value?t.value:""};return tr(r,t),r}(0,t)}}function e9(e,t){let r=[];if(Array.isArray(t)){let a=-1;for(;++a<t.length;){let s=e7(e,t[a]);s&&(Array.isArray(s)?r.push(...s):r.push(s))}}return r}function te(e,t,r,a){return t?Array.isArray(a)?function(e,t,r,a){let s=-1,n=[];for(;++s<a.length;){let l=tt(e,t,r,a[s]);("number"==typeof l||"string"==typeof l)&&n.push(l)}return n}(e,t,r,a):tt(e,t,r,a):void 0}function tt(e,t,r,a){if(("boolean"==typeof a||"number"==typeof a||"string"==typeof a)&&function(e,t,r){let a=e.schema.protocols&&e8.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 tr(e,t){let r=(0,e5.FK)(t);t.data&&(e.data=(0,e4.ZP)(t.data)),r&&(e.position=r)}function ta(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 ts(e){return function(t){return function(e,t){let r={type:"root",children:[]},a=e7({schema:t?{...e6,...t}:e6,stack:[]},e);return a&&(Array.isArray(a)?1===a.length?r=a[0]:r.children=a:r=a),r}(t,e)}}var tn=r(42283);r(4803);let tl=(0,I.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"}]]),ti=(0,I.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"}]]),to=(0,I.Z)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),tc=(0,I.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,I.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,I.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,I.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,I.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)(),L=(0,l.useRef)(null);(0,l.useRef)(null);let I=(0,l.useRef)(null),$=(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:I,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(!$.current)return;let t=$.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(e1.UG,{remarkPlugins:[e2.Z],rehypePlugins:[ts,tn.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(tl,{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=>{I.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(ti,{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(ti,{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(eJ,{className:"h-4 w-4"}):a.jsx(D,{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(tl,{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(ti,{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:$,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:L,"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:L,"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,e0.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 tL=(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),{isSaving:m,error:p,saveNow:h}=tP({value:o,saveFn:async r=>{await t(e.id,{title:r})}}),{isSaving:f,error:x,saveNow:g}=tP({value:d,saveFn:async r=>{await t(e.id,{content:r})}}),y=n??p?.message??x?.message??null,b=(0,l.useCallback)(e=>{c(e.target.value)},[]),v=(0,l.useCallback)(e=>{u(e.target.value)},[]),w=(0,l.useCallback)(()=>{h()},[h]),j=(0,l.useCallback)(()=>{g()},[g]),N=(0,l.useCallback)(()=>{r(e.id)},[e.id,r]);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:b,onBlur:w,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??(m||f))&&a.jsx("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),a.jsx("button",{type:"button",onClick:N,"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:v,onBlur:j,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"}),y&&a.jsx("div",{className:"text-xs text-red-500",children:y})]})}),tI=(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:[n?r.jsx("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),r.jsx("span",{className:"text-sm font-medium",children:"Add Memo"})]}),(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:[Math.max(0,t-e)," remaining"]})]})}),tO=(0,l.memo)(function({worktreeId:e,className:t=""}){let[a,n]=(0,l.useState)([]),[s,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 t_.nE.getAll(e);n(t.sort((e,t)=>e.position-t.position))}catch(e){u((0,t_.zG)(e))}finally{i(!1)}},[e]);(0,l.useEffect)(()=>{h()},[h]);let x=(0,l.useCallback)(async()=>{c(!0),p(null);try{let t=await t_.nE.create(e,{title:"Memo",content:""});n(e=>[...e,t])}catch(e){p((0,t_.zG)(e))}finally{c(!1)}},[e]),f=(0,l.useCallback)(async(t,a)=>{await t_.nE.update(e,t,a),n(e=>e.map(e=>e.id===t?{...e,...a}:e))},[e]),g=(0,l.useCallback)(async t=>{try{await t_.nE.delete(e,t),n(e=>e.filter(e=>e.id!==t))}catch(e){console.error("Failed to delete memo:",e)}},[e]),b=(0,l.useCallback)(()=>{h()},[h]);return s?r.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,r.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),r.jsx("span",{className:"text-sm text-gray-500",children:"Loading memos..."})]})}):d?r.jsx("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${t}`,children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx("svg",{className:"w-12 h-12 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),r.jsx("span",{className:"text-sm text-red-600",children:d}),r.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,r.jsxs)("div",{"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${t}`,children:[0===a.length&&!m&&(0,r.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[r.jsx("p",{children:"No memos yet."}),r.jsx("p",{className:"text-sm",children:"Click the button below to add one."})]}),a.map(e=>r.jsx(tD,{memo:e,onUpdate:f,onDelete:g},e.id)),m&&r.jsx("div",{className:"text-center py-2 text-sm text-red-500",children:m}),r.jsx(tP,{currentCount:a.length,maxCount:5,onAdd:x,isLoading:o,className:"mt-2"})]})});var tI=a(11867);function t$(){let[e,t]=(0,l.useState)(null),[a,r]=(0,l.useState)(!0),[n,s]=(0,l.useState)(null);return{data:e,loading:a,error:n}}function tF({hasUpdate:e,latestVersion:t,releaseUrl:a,updateCommand:n,installType:s}){let l=(0,f.T)("worktree");return e?(0,r.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:[r.jsx("p",{className:"text-sm font-medium text-blue-800 mb-1",children:l("update.available")}),t&&r.jsx("p",{className:"text-sm text-blue-700 mb-2",children:l("update.latestVersion",{version:t})}),n&&"global"===s&&(0,r.jsxs)("div",{className:"mb-2",children:[r.jsx("p",{className:"text-xs text-blue-600 mb-1",children:l("update.updateCommand")}),r.jsx("code",{className:"block bg-blue-100 rounded px-2 py-1 text-xs text-blue-900 font-mono",children:n})]}),a&&(0,r.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[l("update.viewRelease"),r.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),r.jsx("p",{className:"text-xs text-blue-500 mt-2",children:l("update.dataPreserved")})]}):null}function tz({version:e,className:t}){let a=(0,f.T)("worktree"),{data:n,loading:s}=t$(),i=(0,l.useMemo)(()=>n&&n.hasUpdate?{hasUpdate:n.hasUpdate,latestVersion:n.latestVersion,releaseUrl:n.releaseUrl,updateCommand:n.updateCommand,installType:n.installType}:null,[n]);return(0,r.jsxs)("div",{className:t,"data-testid":"version-section",children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:a("update.version")}),r.jsx("p",{className:"text-sm text-gray-700",children:e}),s&&r.jsx("p",{className:"text-xs text-gray-400 mt-1","data-testid":"version-loading",children:"..."}),i&&r.jsx(tF,{...i})]})}let tU="https://github.com/Kewton/CommandMate",tW=`${tU}/issues`,tB=`${tU}/issues/new`,tH=`${tB}?template=bug_report.md`,tq=`${tB}?template=feature_request.md`,tV=`${tB}?template=question.md`;function tG({className:e}){let t=(0,f.T)("worktree"),a=[{href:tH,label:t("feedback.bugReport")},{href:tq,label:t("feedback.featureRequest")},{href:tV,label:t("feedback.question")},{href:tW,label:t("feedback.viewIssues")}];return(0,r.jsxs)("div",{className:e,"data-testid":"feedback-section",children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-2",children:t("feedback.title")}),r.jsx("div",{className:"flex flex-col gap-1",children:a.map(({href:e,label:t})=>(0,r.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,r.jsx("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},e))})]})}var tY=a(28676);let tZ=[36e5,108e5,288e5],tK={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function tX({isOpen:e,onConfirm:t,onCancel:a,cliToolName:n}){let s=(0,f.T)("autoYes"),i=(0,f.T)("common"),[o,c]=(0,l.useState)(36e5),d=e=>s(tK[e].replace("autoYes.",""));return r.jsx(tY.u,{isOpen:e,onClose:a,title:n?s("enableTitleWithTool",{toolName:n}):s("enableTitle"),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-700",children:[r.jsx("p",{className:"font-medium mb-2",children:s("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[r.jsx("li",{children:s("yesNoAutoResponse")}),r.jsx("li",{children:s("multipleChoiceAutoSelect")})]}),r.jsx("p",{className:"mt-1",children:s("autoDisableAfter",{duration:d(o)})}),n&&r.jsx("p",{className:"mt-2 text-gray-500",children:s("appliesOnlyToCurrent",{toolName:n})})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700",children:[r.jsx("p",{className:"font-medium mb-2",children:s("duration")}),r.jsx("div",{className:"flex gap-2",children:tZ.map(e=>r.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:d(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700",children:[r.jsx("p",{className:"font-medium mb-2",children:s("aboutRisks")}),r.jsx("p",{children:s("riskWarning")})]}),r.jsx("div",{className:"bg-yellow-50 border-l-4 border-yellow-400 p-3",children:(0,r.jsxs)("p",{className:"text-sm text-yellow-800",children:[r.jsx("span",{className:"font-medium",children:s("disclaimer")}),s("disclaimerText")]})}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[r.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:i("cancel")}),r.jsx("button",{type:"button",onClick:()=>t(o),className:"px-4 py-2 text-sm font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 text-white",children:s("agreeAndEnable")})]})]})})}function tJ(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}let tQ=(0,l.memo)(function({enabled:e,expiresAt:t,onToggle:a,lastAutoResponse:n,cliToolName:s,inline:i=!1}){let[o,c]=(0,l.useState)(""),[d,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),[h,x]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!e||!t){c("");return}let a=()=>{c(function(e){let t=Math.max(0,e-Date.now()),a=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);return a>0?`${a}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}(t))};a();let r=setInterval(a,1e3);return()=>clearInterval(r)},[e,t]),(0,l.useEffect)(()=>{if(!n)return;u(`Auto responded: "${n}"`);let e=setTimeout(()=>u(null),2e3);return()=>clearTimeout(e)},[n]);let f=(0,l.useCallback)(()=>{e?(p(!0),a(!1).finally(()=>p(!1))):x(!0)},[e,a]),g=(0,l.useCallback)(e=>{x(!1),p(!0),a(!0,e).finally(()=>p(!1))},[a]),b=(0,l.useCallback)(()=>{x(!1)},[]);return(0,r.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:[r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":"Auto Yes mode",disabled:m,onClick:f,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:r.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})}),r.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Auto Yes"}),e&&s&&(0,r.jsxs)("span",{className:"text-xs text-blue-600 font-medium","aria-label":"Auto Yes target",children:["(",tJ(s),")"]}),e&&o&&r.jsx("span",{className:"text-sm text-gray-500","aria-label":"Time remaining",children:o}),d&&r.jsx("span",{className:"text-sm text-green-600 animate-pulse",children:d}),r.jsx(tX,{isOpen:h,onConfirm:g,onCancel:b,cliToolName:tJ(s)})]})}),t0=(0,l.memo)(function({isBranchMismatch:e,currentBranch:t,initialBranch:a}){let[n,s]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{s(!1)},[t]),!e||n||null===a)?null:(0,r.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:[r.jsx(tn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),r.jsx("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("span",{className:"text-sm",children:["Branch changed from"," ",r.jsx("span",{className:"font-medium",children:a})," ","to"," ",r.jsx("span",{className:"font-medium",children:t})]})}),r.jsx("button",{type:"button",onClick:()=>s(!0),className:"p-1 rounded hover:bg-amber-100 transition-colors","aria-label":"Dismiss alert",children:r.jsx(tu.Z,{className:"w-4 h-4"})})]})});var t1=a(18421);let t2=(0,O.Z)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),t4=(0,O.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"}]]),t5=(0,O.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"}]]),t3=(0,l.memo)(function({isOpen:e,onClose:t,onConfirm:a,worktreeId:n,sourcePath:s,sourceType:i}){let o=(0,f.T)("worktree"),c=(0,f.T)("common"),[d,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(new Set([""])),[h,x]=(0,l.useState)([]),[g,b]=(0,l.useState)(!1),[y,w]=(0,l.useState)(new Set),v=s.includes("/")?s.substring(0,s.lastIndexOf("/")):"";(0,l.useEffect)(()=>{e&&(u(v),p(new Set([""])),x([]),j())},[e,n]);let j=(0,l.useCallback)(async()=>{b(!0);try{let e=await fetch(`/api/worktrees/${n}/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}));x(t)}catch{}finally{b(!1)}},[n]),N=(0,l.useCallback)(async e=>{w(t=>new Set(t).add(e));try{let t=await fetch(`/api/worktrees/${n}/tree/${e}`);if(!t.ok)return;let a=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:`${e}/${t.name}`,loaded:!1}));x(t=>(function e(t,a,r){return t.map(t=>t.path===a?{...t,children:r,loaded:!0}:t.children?{...t,children:e(t.children,a,r)}:t)})(t,e,a))}catch{}finally{w(t=>{let a=new Set(t);return a.delete(e),a})}},[n]),k=(0,l.useCallback)(async e=>{p(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a});let t=function e(t,a){for(let r of t){if(r.path===a)return r;if(r.children){let t=e(r.children,a);if(t)return t}}return null}(h,e);t&&!t.loaded&&await N(e)},[h,N]),C=(0,l.useCallback)(e=>!(e===v||"directory"===i&&(e===s||e.startsWith(s+"/"))),[v,s,i]),S=(e,t=0)=>{let a=m.has(e.path),n=d===e.path,s=y.has(e.path),l=C(e.path);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:`flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ${n?"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:[r.jsx("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),k(e.path)},children:s?r.jsx(tx,{className:"w-3 h-3 animate-spin text-gray-400"}):r.jsx(t2,{className:`w-3 h-3 text-gray-400 transition-transform ${a?"rotate-90":""}`})}),a?r.jsx(t4,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):r.jsx(t5,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:e.name})]}),a&&e.children&&r.jsx("div",{children:e.children.map(e=>S(e,t+1))})]},e.path)},T=C(d);return r.jsx(tY.u,{isOpen:e,onClose:t,title:o("fileTree.moveDialogTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-600",children:[o("fileTree.moveTo"),": ",r.jsx("span",{className:"font-mono text-gray-800",children:s})]}),(0,r.jsxs)("div",{className:"border border-gray-200 rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,r.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:[r.jsx("span",{className:"w-4 h-4"}),r.jsx(t5,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),r.jsx("span",{children:o("fileTree.rootDirectory")})]}),g?r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(tx,{className:"w-5 h-5 animate-spin text-gray-400"})}):h.map(e=>S(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[r.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")}),r.jsx("button",{onClick:()=>a(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 t6(e){return e.charAt(0).toUpperCase()+e.slice(1)}function t8(e,t,a,r){let[n,s]=(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 a=await t_.Iv.updateDescription(e.id,i);t(a),s(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,l.useCallback)(()=>{o(e?.description||""),s(!1)},[e]);return{isEditing:n,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,l.useCallback)(()=>{s(!0)},[])}}let t7=(0,l.memo)(function({worktreeId:e,worktree:t,cardClassName:a,descriptionEditor:n,showLogs:s,onToggleLogs:l}){let{isEditing:i,text:o,setText:c,isSaving:d,handleSave:u,handleCancel:m,startEditing:p}=n;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Worktree"}),r.jsx("p",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),(0,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),r.jsx("p",{className:"text-base text-gray-900",children:t.repositoryName}),r.jsx("p",{className:"text-xs text-gray-500 mt-1 break-all",children:t.repositoryPath})]}),(0,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Path"}),r.jsx("p",{className:"text-sm text-gray-700 break-all font-mono",children:t.path})]}),t.status&&(0,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Status"}),r.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,r.jsxs)("div",{className:a,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Description"}),!i&&r.jsx("button",{type:"button",onClick:p,className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),i?(0,r.jsxs)("div",{className:"space-y-3",children:[r.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,r.jsxs)("div",{className:"flex gap-2",children:[r.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"}),r.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"})]})]}):r.jsx("div",{className:"min-h-[50px]",children:t.description?r.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:t.description}):r.jsx("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),t.link&&(0,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Link"}),r.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,r.jsxs)("div",{className:a,children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Last Updated"}),r.jsx("p",{className:"text-sm text-gray-700",children:new Date(t.updatedAt).toLocaleString()})]}),r.jsx(tz,{version:"v0.2.10",className:a}),r.jsx(tG,{className:a}),(0,r.jsxs)("div",{className:a,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("h2",{className:"text-sm font-medium text-gray-500",children:"Logs"}),r.jsx("button",{type:"button",onClick:l,className:"text-sm text-blue-600 hover:text-blue-800",children:s?"Hide":"Show"})]}),s&&r.jsx(tI.n,{worktreeId:e})]})]})}),t9=(0,l.memo)(function({worktreeName:e,repositoryName:t,description:a,status:n,gitStatus:s,onBackClick:l,onInfoClick:i,onMenuClick:o,hasUpdate:c}){let d=el.Ie[n],u=a?(0,ei.aS)(a,50):null;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[r.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:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),(0,r.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:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),r.jsx("span",{className:"text-sm font-medium",children:"Back"})]}),r.jsx("div",{className:"w-px h-6 bg-gray-300","aria-hidden":"true"}),"spinner"===d.type?r.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}`}):r.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,r.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-lg font-semibold text-gray-900 truncate max-w-[200px] leading-tight",children:e}),u&&r.jsx("span",{className:"text-sm text-gray-500 truncate max-w-md",title:a,children:u})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[r.jsx("span",{className:"truncate max-w-[200px]",children:t}),s&&"(unknown)"!==s.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[r.jsx("span",{className:"text-gray-300",children:"/"}),r.jsx("span",{className:"truncate max-w-[150px] font-mono",title:s.currentBranch,"data-testid":"desktop-branch-name",children:(0,ei.aS)(s.currentBranch,30)}),s.isDirty&&r.jsx("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),(0,r.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:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})}),r.jsx("span",{className:"text-sm font-medium",children:"Info"}),c&&r.jsx(eu,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":"Update available"})]})]})}),ae=(0,l.memo)(function({worktreeId:e,worktree:t,isOpen:a,onClose:n,onWorktreeUpdate:s}){let[i,o]=(0,l.useState)(!1),c=(0,l.useRef)(a),d=t8(t,s,a,()=>{let e=a&&!c.current;return c.current=a,e});return t?r.jsx(tY.u,{isOpen:a,onClose:n,title:"Worktree Information",size:"md",children:r.jsx("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:r.jsx(t7,{worktreeId:e,worktree:t,cardClassName:"bg-gray-50 rounded-lg p-4",descriptionEditor:d,showLogs:i,onToggleLogs:()=>o(!i)})})}):null}),at=(0,l.memo)(function(){return r.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600","aria-hidden":"true"}),r.jsx("p",{className:"text-gray-600",children:"Loading worktree..."})]})})}),aa=(0,l.memo)(function({message:e,onRetry:t}){return r.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,r.jsxs)("div",{className:"text-center p-6 bg-red-50 rounded-lg border border-red-200 max-w-md",children:[r.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:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),r.jsx("p",{className:"text-red-600 font-medium",children:"Error loading worktree"}),r.jsx("p",{className:"text-red-500 text-sm mt-2",children:e}),t&&r.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"})]})})}),ar=(0,l.memo)(function({worktreeId:e,worktree:t,onWorktreeUpdate:a}){let[n,s]=(0,l.useState)(!1),i=(0,l.useRef)(t?.id),o=(0,l.useRef)(!1),c=t8(t,a,t?.id,()=>{let e=t?.id!==i.current;return i.current=t?.id,e&&!o.current});return(o.current=c.isEditing,t)?r.jsx("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:r.jsx(t7,{worktreeId:e,worktree:t,cardClassName:"bg-white rounded-lg border border-gray-200 p-4",descriptionEditor:c,showLogs:n,onToggleLogs:()=>s(!n)})}):r.jsx("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),an=(0,l.memo)(function({activeTab:e,worktreeId:t,worktree:a,messages:n,terminalOutput:s,isTerminalActive:l,isThinking:i,onFilePathClick:o,onFileSelect:c,onWorktreeUpdate:d,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:x,onMove:f,refreshTrigger:b,fileSearch:y,showToast:w}){switch(e){case"terminal":return r.jsx(g,{componentName:"TerminalDisplay",children:r.jsx(P,{output:s,isActive:l,isThinking:i,className:"h-full"})});case"history":return r.jsx(g,{componentName:"HistoryPane",children:r.jsx(X,{messages:n,worktreeId:t,onFilePathClick:o,className:"h-full",showToast:w})});case"files":return r.jsx(g,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[r.jsx(eW,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),r.jsx(e$,{worktreeId:t,onFileSelect:c,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:x,onMove:f,refreshTrigger:b,searchQuery:y.query,searchMode:y.mode,searchResults:y.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return r.jsx(g,{componentName:"MemoPane",children:r.jsx(tO,{worktreeId:t,className:"h-full"})});case"info":return r.jsx(ar,{worktreeId:t,worktree:a,onWorktreeUpdate:d});default:return null}}),as=(0,l.memo)(function({worktreeId:e}){let t=(0,n.useRouter)(),a=(0,h.d)(),{toggle:s,openMobileDrawer:i}=(0,x.Sz)(),{state:o,actions:c}=function(){let[e,t]=(0,l.useReducer)(p,void 0,m),a=(0,l.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),setTerminalOutput:(e,a)=>t({type:"SET_TERMINAL_OUTPUT",output:e,realtimeSnippet:a}),setTerminalActive:e=>t({type:"SET_TERMINAL_ACTIVE",isActive:e}),setTerminalThinking:e=>t({type:"SET_TERMINAL_THINKING",isThinking:e}),showPrompt:(e,a)=>t({type:"SHOW_PROMPT",data:e,messageId:a}),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,a)=>t({type:"UPDATE_MESSAGE",id:e,updates:a}),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:a}}(),d=(0,f.T)("worktree"),u=(0,f.T)("error"),b=(0,f.T)("common"),[y,w]=(0,l.useState)(null),[v,j]=(0,l.useState)(!0),[N,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(!1),[T,E]=(0,l.useState)(null),[A,R]=(0,l.useState)(null),[_,L]=(0,l.useState)(!1),[D,O]=(0,l.useState)(!1),[I,$]=(0,l.useState)(null),[F,z]=(0,l.useState)("claude"),U=(0,l.useRef)(F);U.current=F;let[W,B]=(0,l.useState)(0),H=function(e){let{worktreeId:t,initialMode:a="name",debounceMs:r=300}=e,[n,s]=(0,l.useState)(""),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(a),[u,m]=(0,l.useState)(!1),[p,h]=(0,l.useState)(null),[x,f]=(0,l.useState)(null),g=(0,l.useRef)(null),b=(0,l.useMemo)(()=>(0,ei.Ds)(e=>{o(e)},r),[r]),y=(0,l.useCallback)(e=>{s(e),b(e),f(null)},[b]),w=(0,l.useCallback)(()=>{s(""),o(""),h(null),f(null),m(!1),g.current&&(g.current.abort(),g.current=null)},[]),v=(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:n,mode:c,isSearching:u,results:p,error:x,setQuery:y,setMode:d,clearSearch:w,filterByName:v,getMatchedPaths:j}}({worktreeId:e}),q=(0,l.useRef)(!1),V=(0,l.useRef)(e);(0,l.useEffect)(()=>{V.current!==e&&(c.clearMessages(),q.current=!1,c.setTerminalOutput("",""),V.current=e)},[e,c]);let G=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}`);if(!t.ok)throw Error(`Failed to fetch worktree: ${t.status}`);let a=await t.json();return w(a),a}catch(e){return k(e instanceof Error?e.message:"Unknown error"),null}},[e]),Y=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/messages?cliTool=${U.current}`);if(!t.ok)throw Error(`Failed to fetch messages: ${t.status}`);let a=await t.json();c.setMessages(a.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[e,c]),Z=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/current-output?cliTool=${U.current}`);if(!t.ok)return;let a=await t.json(),r=a.fullOutput??a.realtimeSnippet??"";(r||a.isRunning)&&c.setTerminalOutput(r,a.realtimeSnippet??""),c.setTerminalActive(a.isRunning??!1),c.setTerminalThinking(a.thinking??!1),a.isPromptWaiting&&a.promptData?c.showPrompt(a.promptData,`prompt-${Date.now()}`):!a.isPromptWaiting&&o.prompt.visible&&c.clearPrompt(),a.autoYes&&(O(a.autoYes.enabled),$(a.autoYes.expiresAt))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[e,c,o.prompt.visible]),K=(0,l.useRef)(F);(0,l.useEffect)(()=>{K.current!==F&&(K.current=F,c.clearMessages(),c.setTerminalOutput("",""),Y(),Z())},[F,c,Y,Z]);let J=(0,l.useCallback)(e=>{E(e)},[]),Q=(0,l.useCallback)(e=>{let t=e.split(".").pop()?.toLowerCase(),a=t?`.${t}`:"";tM.includes(a)?R(e):E(e)},[]),ee=(0,l.useCallback)(()=>{E(null)},[]),et=(0,l.useCallback)(()=>{R(null)},[]),ea=(0,l.useCallback)(e=>{B(e=>e+1)},[]),er=(0,l.useCallback)(e=>{c.setLeftPaneTab(e)},[c]),en=(0,l.useCallback)(()=>{t.push("/")},[t]),eo=(0,l.useCallback)(()=>{S(!0)},[]),ec=(0,l.useCallback)(()=>{S(!1)},[]),eu=(0,l.useCallback)(async t=>{c.setPromptAnswering(!0);try{let a=function(e,t,a){let r={answer:e,cliTool:t};if(a&&(r.promptType=a.type,"multiple_choice"===a.type)){let e=a.options.find(e=>e.isDefault);e&&(r.defaultOptionNumber=e.number)}return r}(t,F,o.prompt.data),r=await fetch(`/api/worktrees/${e}/prompt-response`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!r.ok)throw Error(`Failed to send prompt response: ${r.status}`);c.clearPrompt(),await Z()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{c.setPromptAnswering(!1)}},[e,c,Z,F,o.prompt.data]),em=(0,l.useCallback)(()=>{c.clearPrompt()},[c]),ep=(0,l.useCallback)(e=>{c.setMobileActivePane(e)},[c]),eh=(0,l.useCallback)(e=>{c.setAutoScroll(e)},[c]),ef=(0,l.useCallback)(()=>{Y(),Z()},[Y,Z]),eb=(0,l.useCallback)(async(t,a)=>{try{let r=await fetch(`/api/worktrees/${e}/auto-yes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t,cliToolId:F,duration:a})});if(r.ok){let e=await r.json();O(e.enabled),$(e.expiresAt)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[e,F]),[ey,ew]=(0,l.useState)(!1),ej=(0,l.useCallback)(()=>{ew(!0)},[]),eN=(0,l.useCallback)(async()=>{ew(!1);try{if(!(await fetch(`/api/worktrees/${e}/kill-session?cliTool=${F}`,{method:"POST"})).ok)return;c.clearMessages(),c.setTerminalOutput("",""),c.setTerminalActive(!1),c.setTerminalThinking(!1),c.clearPrompt(),await G()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[e,F,c,G]),ek=(0,l.useCallback)(()=>{ew(!1)},[]),eC=(0,l.useCallback)(async t=>{let a=window.prompt("Enter file name (e.g., document.md):");if(!a)return;let r=a.endsWith(".md")?a:`${a}.md`,n=t?`${t}/${r}`:r;try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");B(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert(u("fileOps.failedToCreateFile"))}},[e,u]),eS=(0,l.useCallback)(async t=>{let a=window.prompt("Enter directory name:");if(!a)return;let r=t?`${t}/${a}`:a;try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");B(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(u("fileOps.failedToCreateDirectory"))}},[e,u]),eT=(0,l.useCallback)(async t=>{let a=t.split("/").pop()||"",r=window.prompt("Enter new name:",a);if(r&&r!==a)try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:r})})).ok)throw Error("Failed to rename");B(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(u("fileOps.failedToRename"))}},[e,u]),eE=(0,l.useCallback)(async t=>{let a=t.split("/").pop()||t;if(window.confirm(b("confirmDelete",{name:a})))try{if(!(await fetch(`/api/worktrees/${e}/files/${encodeURIComponent(t)}?recursive=true`,{method:"DELETE"})).ok)throw Error("Failed to delete");(A===t||A?.startsWith(`${t}/`))&&R(null),B(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(u("fileOps.failedToDelete"))}},[e,A,b,u]),{toasts:eM,showToast:eA,removeToast:eR}=(0,tm.pm)(),{moveTarget:e_,isMoveDialogOpen:eL,handleMove:eD,handleMoveConfirm:eP,handleMoveCancel:eO}=function(e,t,a,r){let[n,s]=(0,l.useState)(null),[i,o]=(0,l.useState)(!1),c=(0,l.useCallback)((e,t)=>{s({path:e,type:t}),o(!0)},[]),d=(0,l.useCallback)(async l=>{if(n)try{let s=await fetch(`/api/worktrees/${e}/files/${n.path}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),i=await s.json();if(!s.ok||!i.success){let e=i.error?.message||"Failed to move";r?.(e);return}a?.("Moved successfully"),t()}catch{r?.("Failed to move")}finally{s(null),o(!1)}},[n,e,t,a,r]);return{moveTarget:n,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,l.useCallback)(()=>{s(null),o(!1)},[])}}(e,()=>B(e=>e+1),e=>eA(e,"success"),e=>eA(e,"error")),eI=(0,l.useRef)(null),eF=(0,l.useRef)(""),ez=(0,l.useCallback)(e=>{eF.current=e,eI.current?.click()},[]),eU=(0,l.useCallback)(async t=>{let a=t.target.files?.[0];if(!a)return;t.target.value="";let r=eF.current,n=`.${a.name.split(".").pop()?.toLowerCase()}`;if(!function(e){if(!e)return!1;let t=e.toLowerCase();return tR.includes(t)}(n)){eA(`Unsupported file type: ${n}. Allowed: ${tR.join(", ")}`,"error");return}let s=function(e){let t=function(e){let t=e.toLowerCase();return tA.find(e=>e.extension===t)}(e);return t?.maxFileSize??5242880}(n);if(a.size>s){eA(`File too large. Maximum size: ${(s/1024/1024).toFixed(1)}MB`,"error");return}let l=new FormData;l.append("file",a);try{let t=await fetch(`/api/worktrees/${e}/upload/${encodeURIComponent(r||".")}`,{method:"POST",body:l});if(!t.ok){let e=await t.json().catch(()=>({})),a=e?.error?.message||"Failed to upload file";eA(a,"error");return}let a=await t.json();eA(`Uploaded: ${a.filename}`,"success"),B(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),eA("Upload failed. Please try again.","error")}},[e,eA]),{data:eB}=t$(),eH=eB?.hasUpdate??!1,{lastAutoResponse:eq}=function({worktreeId:e,cliTool:t,isPromptWaiting:a,promptData:r,autoYesEnabled:n,lastServerResponseTimestamp:s}){(0,l.useRef)(null);let[i,o]=(0,l.useState)(null);return{lastAutoResponse:i}}({worktreeId:e,cliTool:F,isPromptWaiting:o.prompt.visible,promptData:o.prompt.data,autoYesEnabled:D}),eV=(0,l.useCallback)(async()=>{k(null),j(!0),await G()&&await Promise.all([Y(),Z()]),j(!1)},[G,Y,Z]),eY=(0,l.useRef)(0),eZ=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-eY.current<5e3)){if(eY.current=e,N){eV();return}try{await Promise.all([G(),Y(),Z()])}finally{k(null)}}},[N,eV,G,Y,Z]);(0,l.useEffect)(()=>{if(q.current)return;let e=!0;return(async()=>{j(!0);let t=await G();e&&(t&&await Promise.all([Y(),Z()]),e&&(j(!1),q.current=!0))})(),()=>{e=!1}},[G,Y,Z]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",eZ),()=>{document.removeEventListener("visibilitychange",eZ)}),[eZ]),(0,l.useEffect)(()=>{if(v||N)return;let e=setInterval(async()=>{await Promise.all([Z(),G(),Y()])},o.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[v,N,Z,G,Y,o.terminal.isActive]),(0,l.useEffect)(()=>{c.setLayoutMode(a?"tabs":"split")},[a,c]);let eK=(0,l.useMemo)(()=>(function(e,t,a="claude"){if(t)return"error";if(!e)return"idle";let r=e.sessionStatusByCli?.[a];if(r){if(r.isWaitingForResponse)return"waiting";if(r.isProcessing)return"running";if(r.isRunning)return"ready"}if("claude"===a){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(y,null!==o.error.type,F),[y,o.error.type,F]),eJ=(0,l.useMemo)(()=>o.layout.mobileActivePane,[o.layout.mobileActivePane]),eQ=(0,l.useMemo)(()=>o.layout.leftPaneTab,[o.layout.leftPaneTab]),e0=y?.name??"Unknown";return v?r.jsx(at,{}):N?r.jsx(aa,{message:N,onRetry:eV}):a?r.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[r.jsx(ed,{worktreeName:e0,repositoryName:y?.repositoryName,status:eK,gitStatus:y?.gitStatus,onBackClick:en,onMenuClick:i}),y?.gitStatus&&y.gitStatus.isBranchMismatch&&r.jsx("div",{className:"fixed top-14 inset-x-0 z-35",children:r.jsx(t0,{isBranchMismatch:y.gitStatus.isBranchMismatch,currentBranch:y.gitStatus.currentBranch,initialBranch:y.gitStatus.initialBranch})}),(0,r.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:[r.jsx(tQ,{enabled:D,expiresAt:I,onToggle:eb,lastAutoResponse:eq,cliToolName:F,inline:!0}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("nav",{className:"flex gap-2","aria-label":"CLI Tool Selection",children:["claude","codex"].map(e=>{let t=(0,t1.He)(y?.sessionStatusByCli?.[e]),a=el.F4[t];return(0,r.jsxs)("button",{onClick:()=>z(e),className:`px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ${F===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"}`,"aria-current":F===e?"page":void 0,children:["spinner"===a.type?r.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${a.className}`,title:a.label}):r.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.className}`,title:a.label}),t6(e)]},e)})}),(0,r.jsxs)("button",{onClick:ej,disabled:!y?.sessionStatusByCli?.[F]?.isRunning,className:`flex items-center gap-0.5 px-1.5 py-0.5 text-xs font-medium rounded transition-colors ${y?.sessionStatusByCli?.[F]?.isRunning?"text-red-600 hover:bg-red-50":"invisible"}`,"aria-label":`End ${F} session`,children:[r.jsx("span",{"aria-hidden":"true",children:"✕"}),"End"]})]})]}),r.jsx("main",{className:"flex-1 pt-[6.25rem] pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:r.jsx(an,{activeTab:eJ,worktreeId:e,worktree:y,messages:o.messages,terminalOutput:o.terminal.output,isTerminalActive:o.terminal.isActive,isThinking:o.terminal.isThinking,onFilePathClick:J,onFileSelect:Q,onWorktreeUpdate:w,onNewFile:eC,onNewDirectory:eS,onRename:eT,onDelete:eE,onUpload:ez,onMove:eD,refreshTrigger:W,fileSearch:H,showToast:eA})}),r.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:r.jsx(ev.R,{worktreeId:e,onMessageSent:ef,cliToolId:F,isSessionRunning:o.terminal.isActive})}),r.jsx(ex,{activeTab:eJ,onTabChange:ep,hasNewOutput:!1,hasPrompt:o.prompt.visible,hasUpdate:eH}),!D&&r.jsx(eg,{promptData:o.prompt.data,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:eu,onDismiss:em}),r.jsx(eX,{isOpen:null!==T,onClose:ee,worktreeId:e,filePath:T??""}),A&&r.jsx(tY.u,{isOpen:!0,onClose:et,title:A.split("/").pop()||"Editor",size:"full",disableClose:_,children:r.jsx("div",{className:"h-[80vh]",children:r.jsx(tE,{worktreeId:e,filePath:A,onClose:et,onSave:ea,onMaximizedChange:L})})}),r.jsx("input",{ref:eI,type:"file",accept:tR.join(","),onChange:eU,className:"hidden","aria-label":"Upload file"}),r.jsx(tY.u,{isOpen:ey,onClose:ek,title:d("session.confirmEnd",{tool:t6(F)}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[r.jsx("button",{type:"button",onClick:ek,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:b("cancel")}),r.jsx("button",{type:"button",onClick:eN,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:b("end")})]})]})}),e_&&r.jsx(t3,{isOpen:eL,onClose:eO,onConfirm:eP,worktreeId:e,sourcePath:e_.path,sourceType:e_.type}),r.jsx(tm.Ix,{toasts:eM,onClose:eR})]})}):r.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col relative",children:[r.jsx(t9,{worktreeName:e0,repositoryName:y?.repositoryName??"Unknown",description:y?.description,status:eK,gitStatus:y?.gitStatus,onBackClick:en,onInfoClick:eo,onMenuClick:s,hasUpdate:eH}),(0,r.jsxs)("div",{className:"px-4 py-2 bg-white border-b border-gray-200 flex items-center justify-between",children:[r.jsx("nav",{className:"flex gap-4","aria-label":"CLI Tool Selection",children:["claude","codex"].map(e=>{let t=(0,t1.He)(y?.sessionStatusByCli?.[e]),a=el.F4[t];return(0,r.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 ${F===e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,"aria-current":F===e?"page":void 0,children:["spinner"===a.type?r.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ${a.className}`,title:a.label,"aria-label":`${e} status: ${a.label}`}):r.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.className}`,title:a.label,"aria-label":`${e} status: ${a.label}`}),t6(e)]},e)})}),y?.sessionStatusByCli?.[F]?.isRunning&&(0,r.jsxs)("button",{onClick:ej,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 ${F} session`,children:[r.jsx("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),y?.gitStatus&&r.jsx(t0,{isBranchMismatch:y.gitStatus.isBranchMismatch,currentBranch:y.gitStatus.currentBranch,initialBranch:y.gitStatus.initialBranch}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(M,{leftPane:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[r.jsx(eG,{activeTab:eQ,onTabChange:er}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===eQ&&r.jsx(X,{messages:o.messages,worktreeId:e,onFilePathClick:J,className:"h-full",showToast:eA}),"files"===eQ&&r.jsx(g,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[r.jsx(eW,{query:H.query,mode:H.mode,isSearching:H.isSearching,error:H.error,onQueryChange:H.setQuery,onModeChange:H.setMode,onClear:H.clearSearch}),r.jsx(e$,{worktreeId:e,onFileSelect:Q,onNewFile:eC,onNewDirectory:eS,onRename:eT,onDelete:eE,onUpload:ez,onMove:eD,refreshTrigger:W,searchQuery:H.query,searchMode:H.mode,searchResults:H.results?.results,className:"flex-1 min-h-0"})]})}),"memo"===eQ&&r.jsx(g,{componentName:"MemoPane",children:r.jsx(tO,{worktreeId:e,className:"h-full"})})]})]}),rightPane:r.jsx(P,{output:o.terminal.output,isActive:o.terminal.isActive,isThinking:o.terminal.isThinking,autoScroll:o.terminal.autoScroll,onScrollChange:eh}),initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),r.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 p-4 bg-gray-50",children:r.jsx(ev.R,{worktreeId:e,onMessageSent:ef,cliToolId:F,isSessionRunning:o.terminal.isActive})}),r.jsx(tQ,{enabled:D,expiresAt:I,onToggle:eb,lastAutoResponse:eq,cliToolName:F}),o.prompt.visible&&!D&&r.jsx("div",{className:"fixed bottom-20 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-2xl px-4",children:r.jsx(es,{promptData:o.prompt.data,messageId:o.prompt.messageId,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:eu,onDismiss:em})}),r.jsx(ae,{worktreeId:e,worktree:y,isOpen:C,onClose:ec,onWorktreeUpdate:w}),r.jsx(eX,{isOpen:null!==T,onClose:ee,worktreeId:e,filePath:T??""}),A&&r.jsx(tY.u,{isOpen:!0,onClose:et,title:A.split("/").pop()||"Editor",size:"full",disableClose:_,children:r.jsx("div",{className:"h-[80vh]",children:r.jsx(tE,{worktreeId:e,filePath:A,onClose:et,onSave:ea,onMaximizedChange:L})})}),r.jsx("input",{ref:eI,type:"file",accept:tR.join(","),onChange:eU,className:"hidden","aria-label":"Upload file"}),r.jsx(tY.u,{isOpen:ey,onClose:ek,title:d("session.confirmEnd",{tool:t6(F)}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-gray-700",children:d("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[r.jsx("button",{type:"button",onClick:ek,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:b("cancel")}),r.jsx("button",{type:"button",onClick:eN,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:b("end")})]})]})}),e_&&r.jsx(t3,{isOpen:eL,onClose:eO,onConfirm:eP,worktreeId:e,sourcePath:e_.path,sourceType:e_.type}),r.jsx(tm.Ix,{toasts:eM,onClose:eR})]})})});function al(){let e=(0,n.useParams)().id;return r.jsx(s.Vw,{children:r.jsx(as,{worktreeId:e})})}},22570:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>r});let r=(0,a(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx#default`)},4803:()=>{}};var t=require("../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[8948,1287,6621,8705,7458,7808,3860,9238],()=>a(80205));module.exports=r})();
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"]})]})}),tD=(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(tL,{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(tI,{currentCount:r.length,maxCount:5,onAdd:f,isLoading:o,className:"mt-2"})]})});var t$=r(11867);function tF(){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 tz({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 tH({version:e,className:t}){let r=(0,x.T)("worktree"),{data:s,loading:n}=tF(),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(tz,{...i})]})}let tW="https://github.com/Kewton/CommandMate",tB=`${tW}/issues`,tU=`${tW}/issues/new`,tG=`${tU}?template=bug_report.md`,tV=`${tU}?template=feature_request.md`,tq=`${tU}?template=question.md`;function tY({className:e}){let t=(0,x.T)("worktree"),r=[{href:tG,label:t("feedback.bugReport")},{href:tV,label:t("feedback.featureRequest")},{href:tq,label:t("feedback.question")},{href:tB,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 tZ=r(28676);r(63817);let tK=[36e5,108e5,288e5],tX={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function tJ({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(tX[e].replace("autoYes.",""));return a.jsx(tZ.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:tK.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 tQ(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}let t0=(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:["(",tQ(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(tJ,{isOpen:h,onConfirm:g,onCancel:y,cliToolName:tQ(n)})]})}),t1=(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(tl,{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 t2=r(18421);let t4=(0,I.Z)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),t5=(0,I.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"}]]),t3=(0,I.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"}]]),t6=(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(t4,{className:`w-3 h-3 text-gray-400 transition-transform ${r?"rotate-90":""}`})}),r?a.jsx(t5,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):a.jsx(t3,{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(tZ.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(t3,{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 t8(e){return e?e.split("/").map(encodeURIComponent).join("/"):""}function t7(e){return e.charAt(0).toUpperCase()+e.slice(1)}function t9(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 re=(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(tH,{version:"v0.2.12",className:r}),a.jsx(tY,{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(t$.n,{worktreeId:e})]})]})}),rt=(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"})]})]})}),rr=(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=t9(t,n,r,()=>{let e=r&&!c.current;return c.current=r,e});return t?a.jsx(tZ.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(re,{worktreeId:e,worktree:t,cardClassName:"bg-gray-50 rounded-lg p-4",descriptionEditor:d,showLogs:i,onToggleLogs:()=>o(!i)})})}):null}),ra=(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..."})]})})}),rs=(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"})]})})}),rn=(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=t9(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(re,{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..."})}),rl=(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}){switch(e){case"terminal":return a.jsx(g,{componentName:"TerminalDisplay",children:a.jsx(L,{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(eB,{query:b.query,mode:b.mode,isSearching:b.isSearching,error:b.error,onQueryChange:b.setQuery,onModeChange:b.setMode,onClear:b.clearSearch}),a.jsx(eF,{worktreeId:t,onFileSelect:c,onNewFile:u,onNewDirectory:m,onRename:p,onDelete:h,onUpload:f,onMove:x,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:"MemoPane",children:a.jsx(tD,{worktreeId:t,className:"h-full"})});case"info":return a.jsx(rn,{worktreeId:t,worktree:r,onWorktreeUpdate:d});default:return null}}),ri=(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,w]=(0,l.useState)(null),[j,N]=(0,l.useState)(!0),[k,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(!1),[E,A]=(0,l.useState)(null),[R,_]=(0,l.useState)(null),[O,P]=(0,l.useState)(!1),[I,D]=(0,l.useState)(!1),[$,F]=(0,l.useState)(null),z=(0,l.useRef)(!1),[H,W]=(0,l.useState)(!1),[B,U]=(0,l.useState)("claude"),G=(0,l.useRef)(B);G.current=B;let[V,q]=(0,l.useState)(0),Y=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}),Z=(0,l.useRef)(!1),K=(0,l.useRef)(e);(0,l.useEffect)(()=>{K.current!==e&&(c.clearMessages(),Z.current=!1,c.setTerminalOutput("",""),K.current=e)},[e,c]);let J=(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 w(r),r}catch(e){return C(e instanceof Error?e.message:"Unknown error"),null}},[e]),Q=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/messages?cliTool=${G.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]),ee=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/worktrees/${e}/current-output?cliTool=${G.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=z.current;D(r.autoYes.enabled),F(r.autoYes.expiresAt),z.current=r.autoYes.enabled,e&&!r.autoYes.enabled&&"stop_pattern_matched"===r.autoYes.stopReason&&W(!0)}}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[e,c,o.prompt.visible]),et=(0,l.useRef)(B);(0,l.useEffect)(()=>{et.current!==B&&(et.current=B,c.clearMessages(),c.setTerminalOutput("",""),Q(),ee())},[B,c,Q,ee]);let er=(0,l.useCallback)(e=>{A(e)},[]),ea=(0,l.useCallback)(e=>{let t=e.split(".").pop()?.toLowerCase(),r=t?`.${t}`:"";tA.includes(r)?_(e):A(e)},[]),es=(0,l.useCallback)(()=>{A(null)},[]),eo=(0,l.useCallback)(()=>{_(null)},[]),ec=(0,l.useCallback)(e=>{q(e=>e+1)},[]),eu=(0,l.useCallback)(e=>{c.setLeftPaneTab(e)},[c]),em=(0,l.useCallback)(()=>{t.push("/")},[t]),ep=(0,l.useCallback)(()=>{T(!0)},[]),eh=(0,l.useCallback)(()=>{T(!1)},[]),ex=(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,B,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 ee()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{c.setPromptAnswering(!1)}},[e,c,ee,B,o.prompt.data]),ey=(0,l.useCallback)(()=>{c.clearPrompt()},[c]),eb=(0,l.useCallback)(e=>{c.setMobileActivePane(e)},[c]),ev=(0,l.useCallback)(e=>{c.setAutoScroll(e)},[c]),ej=(0,l.useCallback)(()=>{Q(),ee()},[Q,ee]),eN=(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:B,duration:t.duration,stopPattern:t.stopPattern})});if(r.ok){let e=await r.json();D(e.enabled),F(e.expiresAt),z.current=e.enabled}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[e,B]),[ek,eC]=(0,l.useState)(!1),eS=(0,l.useCallback)(()=>{eC(!0)},[]),eT=(0,l.useCallback)(async()=>{eC(!1);try{if(!(await fetch(`/api/worktrees/${e}/kill-session?cliTool=${B}`,{method:"POST"})).ok)return;c.clearMessages(),c.setTerminalOutput("",""),c.setTerminalActive(!1),c.setTerminalThinking(!1),c.clearPrompt(),await J()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[e,B,c,J]),eE=(0,l.useCallback)(()=>{eC(!1)},[]),eM=(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/${t8(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]),eA=(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/${t8(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]),eR=(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/${t8(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]),e_=(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/${t8(t)}?recursive=true`,{method:"DELETE"})).ok)throw Error("Failed to delete");(R===t||R?.startsWith(`${t}/`))&&_(null),q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(u("fileOps.failedToDelete"))}},[e,R,y,u]),{toasts:eO,showToast:eP,removeToast:eL}=(0,th.pm)();(0,l.useEffect)(()=>{H&&(eP(b("stopPatternMatched"),"info"),W(!1))},[H,eP,b]);let{moveTarget:eI,isMoveDialogOpen:eD,handleMove:e$,handleMoveConfirm:ez,handleMoveCancel:eH}=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=>eP(e,"success"),e=>eP(e,"error")),eW=(0,l.useRef)(null),eU=(0,l.useRef)(""),eG=(0,l.useCallback)(e=>{eU.current=e,eW.current?.click()},[]),eV=(0,l.useCallback)(async t=>{let r=t.target.files?.[0];if(!r)return;t.target.value="";let a=eU.current,s=`.${r.name.split(".").pop()?.toLowerCase()}`;if(!function(e){if(!e)return!1;let t=e.toLowerCase();return t_.includes(t)}(s)){eP(`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){eP(`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/${t8(a||".")}`,{method:"POST",body:l});if(!t.ok){let e=await t.json().catch(()=>({})),r=e?.error?.message||"Failed to upload file";eP(r,"error");return}let r=await t.json();eP(`Uploaded: ${r.filename}`,"success"),q(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),eP("Upload failed. Please try again.","error")}},[e,eP]),{data:eq}=tF(),eZ=eq?.hasUpdate??!1,{lastAutoResponse:eK}=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:B,isPromptWaiting:o.prompt.visible,promptData:o.prompt.data,autoYesEnabled:I}),eX=(0,l.useCallback)(async()=>{C(null),N(!0),await J()&&await Promise.all([Q(),ee()]),N(!1)},[J,Q,ee]),eJ=(0,l.useRef)(0),e0=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-eJ.current<5e3)){if(eJ.current=e,k){eX();return}try{await Promise.all([J(),Q(),ee()])}finally{C(null)}}},[k,eX,J,Q,ee]);(0,l.useEffect)(()=>{if(Z.current)return;let e=!0;return(async()=>{N(!0);let t=await J();e&&(t&&await Promise.all([Q(),ee()]),e&&(N(!1),Z.current=!0))})(),()=>{e=!1}},[J,Q,ee]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",e0),()=>{document.removeEventListener("visibilitychange",e0)}),[e0]),(0,l.useEffect)(()=>{if(j||k)return;let e=setInterval(async()=>{await Promise.all([ee(),J(),Q()])},o.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[j,k,ee,J,Q,o.terminal.isActive]),(0,l.useEffect)(()=>{c.setLayoutMode(r?"tabs":"split")},[r,c]);let e1=(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"})(v,null!==o.error.type,B),[v,o.error.type,B]),e2=(0,l.useMemo)(()=>o.layout.mobileActivePane,[o.layout.mobileActivePane]),e4=(0,l.useMemo)(()=>o.layout.leftPaneTab,[o.layout.leftPaneTab]),e5=v?.name??"Unknown";return j?a.jsx(ra,{}):k?a.jsx(rs,{message:k,onRetry:eX}):r?a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(ed,{worktreeName:e5,repositoryName:v?.repositoryName,status:e1,gitStatus:v?.gitStatus,onBackClick:em,onMenuClick:i}),v?.gitStatus&&v.gitStatus.isBranchMismatch&&a.jsx("div",{className:"fixed top-14 inset-x-0 z-35",children:a.jsx(t1,{isBranchMismatch:v.gitStatus.isBranchMismatch,currentBranch:v.gitStatus.currentBranch,initialBranch:v.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(t0,{enabled:I,expiresAt:$,onToggle:eN,lastAutoResponse:eK,cliToolName:B,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,t2.He)(v?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>U(e),className:`px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ${B===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"}`,"aria-current":B===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}),t7(e)]},e)})}),(0,a.jsxs)("button",{onClick:eS,disabled:!v?.sessionStatusByCli?.[B]?.isRunning,className:`flex items-center gap-0.5 px-1.5 py-0.5 text-xs font-medium rounded transition-colors ${v?.sessionStatusByCli?.[B]?.isRunning?"text-red-600 hover:bg-red-50":"invisible"}`,"aria-label":`End ${B} 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(rl,{activeTab:e2,worktreeId:e,worktree:v,messages:o.messages,terminalOutput:o.terminal.output,isTerminalActive:o.terminal.isActive,isThinking:o.terminal.isThinking,onFilePathClick:er,onFileSelect:ea,onWorktreeUpdate:w,onNewFile:eM,onNewDirectory:eA,onRename:eR,onDelete:e_,onUpload:eG,onMove:e$,refreshTrigger:V,fileSearch:Y,showToast:eP})}),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:ej,cliToolId:B,isSessionRunning:o.terminal.isActive})}),a.jsx(ef,{activeTab:e2,onTabChange:eb,hasNewOutput:!1,hasPrompt:o.prompt.visible,hasUpdate:eZ}),!I&&a.jsx(eg,{promptData:o.prompt.data,visible:o.prompt.visible,answering:o.prompt.answering,onRespond:ex,onDismiss:ey}),a.jsx(eQ,{isOpen:null!==E,onClose:es,worktreeId:e,filePath:E??""}),R&&a.jsx(tZ.u,{isOpen:!0,onClose:eo,title:R.split("/").pop()||"Editor",size:"full",disableClose:O,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:R,onClose:eo,onSave:ec,onMaximizedChange:P})})}),a.jsx("input",{ref:eW,type:"file",accept:t_.join(","),onChange:eV,className:"hidden","aria-label":"Upload file"}),a.jsx(tZ.u,{isOpen:ek,onClose:eE,title:d("session.confirmEnd",{tool:t7(B)}),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:eE,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:eT,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(t6,{isOpen:eD,onClose:eH,onConfirm:ez,worktreeId:e,sourcePath:eI.path,sourceType:eI.type}),a.jsx(th.Ix,{toasts:eO,onClose:eL})]})}):a.jsx(g,{componentName:"WorktreeDetailRefactored",children:(0,a.jsxs)("div",{className:"h-full flex flex-col relative",children:[a.jsx(rt,{worktreeName:e5,repositoryName:v?.repositoryName??"Unknown",description:v?.description,status:e1,gitStatus:v?.gitStatus,onBackClick:em,onInfoClick:ep,onMenuClick:n,hasUpdate:eZ}),(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,t2.He)(v?.sessionStatusByCli?.[e]),r=el.F4[t];return(0,a.jsxs)("button",{onClick:()=>U(e),className:`pb-2 px-2 border-b-2 font-medium text-sm transition-colors flex items-center gap-1.5 ${B===e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,"aria-current":B===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}`}),t7(e)]},e)})}),v?.sessionStatusByCli?.[B]?.isRunning&&(0,a.jsxs)("button",{onClick:eS,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 ${B} session`,children:[a.jsx("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),v?.gitStatus&&a.jsx(t1,{isBranchMismatch:v.gitStatus.isBranchMismatch,currentBranch:v.gitStatus.currentBranch,initialBranch:v.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(eY,{activeTab:e4,onTabChange:eu}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===e4&&a.jsx(X,{messages:o.messages,worktreeId:e,onFilePathClick:er,className:"h-full",showToast:eP}),"files"===e4&&a.jsx(g,{componentName:"FileTreeView",children:(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[a.jsx(eB,{query:Y.query,mode:Y.mode,isSearching:Y.isSearching,error:Y.error,onQueryChange:Y.setQuery,onModeChange:Y.setMode,onClear:Y.clearSearch}),a.jsx(eF,{worktreeId:e,onFileSelect:ea,onNewFile:eM,onNewDirectory:eA,onRename:eR,onDelete:e_,onUpload:eG,onMove:e$,refreshTrigger:V,searchQuery:Y.query,searchMode:Y.mode,searchResults:Y.results?.results,className:"flex-1 min-h-0"})]})}),"memo"===e4&&a.jsx(g,{componentName:"MemoPane",children:a.jsx(tD,{worktreeId:e,className:"h-full"})})]})]}),rightPane:a.jsx(L,{output:o.terminal.output,isActive:o.terminal.isActive,isThinking:o.terminal.isThinking,autoScroll:o.terminal.autoScroll,onScrollChange:ev}),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:ej,cliToolId:B,isSessionRunning:o.terminal.isActive})}),a.jsx(t0,{enabled:I,expiresAt:$,onToggle:eN,lastAutoResponse:eK,cliToolName:B}),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:ex,onDismiss:ey})}),a.jsx(rr,{worktreeId:e,worktree:v,isOpen:S,onClose:eh,onWorktreeUpdate:w}),a.jsx(eQ,{isOpen:null!==E,onClose:es,worktreeId:e,filePath:E??""}),R&&a.jsx(tZ.u,{isOpen:!0,onClose:eo,title:R.split("/").pop()||"Editor",size:"full",disableClose:O,children:a.jsx("div",{className:"h-[80vh]",children:a.jsx(tM,{worktreeId:e,filePath:R,onClose:eo,onSave:ec,onMaximizedChange:P})})}),a.jsx("input",{ref:eW,type:"file",accept:t_.join(","),onChange:eV,className:"hidden","aria-label":"Upload file"}),a.jsx(tZ.u,{isOpen:ek,onClose:eE,title:d("session.confirmEnd",{tool:t7(B)}),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:eE,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:eT,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(t6,{isOpen:eD,onClose:eH,onConfirm:ez,worktreeId:e,sourcePath:eI.path,sourceType:eI.type}),a.jsx(th.Ix,{toasts:eO,onClose:eL})]})})});function ro(){let e=(0,s.useParams)().id;return a.jsx(n.Vw,{children:a.jsx(ri,{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,1287,6621,8705,7458,7808,3860,9238],()=>r(80205));module.exports=a})();