@seqyuan/annovibe 0.8.111 → 0.8.112

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 (65) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +11 -11
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  25. package/.next/server/app/api/agent/runtime/route.js +1 -1
  26. package/.next/server/app/api/internal/runtime/route.js +1 -1
  27. package/.next/server/app/api/models/route.js +1 -1
  28. package/.next/server/app/api/version/route.js +1 -1
  29. package/.next/server/app/index.html +1 -1
  30. package/.next/server/app/index.rsc +2 -2
  31. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  32. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  33. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  34. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  35. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  36. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/login.html +1 -1
  38. package/.next/server/app/login.rsc +1 -1
  39. package/.next/server/app/login.segments/_full.segment.rsc +1 -1
  40. package/.next/server/app/login.segments/_head.segment.rsc +1 -1
  41. package/.next/server/app/login.segments/_index.segment.rsc +1 -1
  42. package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  43. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
  44. package/.next/server/app/login.segments/login.segment.rsc +1 -1
  45. package/.next/server/app/page.js +3 -3
  46. package/.next/server/app/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/smoke/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/smoke.html +1 -1
  49. package/.next/server/app/smoke.rsc +1 -1
  50. package/.next/server/app/smoke.segments/_full.segment.rsc +1 -1
  51. package/.next/server/app/smoke.segments/_head.segment.rsc +1 -1
  52. package/.next/server/app/smoke.segments/_index.segment.rsc +1 -1
  53. package/.next/server/app/smoke.segments/_tree.segment.rsc +1 -1
  54. package/.next/server/app/smoke.segments/smoke/__PAGE__.segment.rsc +1 -1
  55. package/.next/server/app/smoke.segments/smoke.segment.rsc +1 -1
  56. package/.next/server/app-paths-manifest.json +11 -11
  57. package/.next/server/chunks/6429.js +1 -1
  58. package/.next/server/middleware-build-manifest.js +1 -1
  59. package/.next/server/pages/404.html +1 -1
  60. package/.next/server/pages/500.html +1 -1
  61. package/.next/server/server-reference-manifest.json +1 -1
  62. package/.next/static/chunks/app/{page-ff67e486e055880b.js → page-f62f66bd3192712f.js} +3 -3
  63. package/package.json +3 -3
  64. /package/.next/static/{ed60keCxJ_yQf1h0-NAar → ezKK9rnqS18PDEy5uEu6B}/_buildManifest.js +0 -0
  65. /package/.next/static/{ed60keCxJ_yQf1h0-NAar → ezKK9rnqS18PDEy5uEu6B}/_ssgManifest.js +0 -0
@@ -1,9 +1,9 @@
1
- (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},478:(a,b,c)=>{Promise.resolve().then(c.bind(c,85644))},1708:a=>{"use strict";a.exports=require("node:process")},2798:(a,b,c)=>{let d=c(76708),e=c(95380),f=c(18994),g=c(32835);function h(a,b,c,f,g){let h=[].slice.call(arguments,1),i=h.length,j="function"==typeof h[i-1];if(!j&&!d())throw Error("Callback required as last argument");if(j){if(i<2)throw Error("Too few arguments provided");2===i?(g=c,c=b,b=f=void 0):3===i&&(b.getContext&&void 0===g?(g=f,f=void 0):(g=f,f=c,c=b,b=void 0))}else{if(i<1)throw Error("Too few arguments provided");return 1===i?(c=b,b=f=void 0):2!==i||b.getContext||(f=c,c=b,b=void 0),new Promise(function(d,g){try{let g=e.create(c,f);d(a(g,b,f))}catch(a){g(a)}})}try{let d=e.create(c,f);g(null,a(d,b,f))}catch(a){g(a)}}e.create,b.toCanvas=h.bind(null,f.render),h.bind(null,f.renderToDataURL),h.bind(null,function(a,b,c){return g.render(a,c)})},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},5206:(a,b,c)=>{Promise.resolve().then(c.bind(c,35790))},9709:(a,b,c)=>{"use strict";let d=!0,e=c(74075),f=c(80183);e.deflateSync||(d=!1);let g=c(81769),h=c(42516),i=c(96277),j=c(92858),k=c(83670);a.exports=function(a,b){let c,l,m,n;if(!d)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let o=[],p=new g(a);if(new i(b,{read:p.read.bind(p),error:function(a){c=a},metadata:function(a){l=a},gamma:function(a){m=a},palette:function(a){l.palette=a},transColor:function(a){l.transColor=a},inflateData:function(a){o.push(a)},simpleTransparency:function(){l.alpha=!0}}).start(),p.process(),c)throw c;let q=Buffer.concat(o);if(o.length=0,l.interlace)n=e.inflateSync(q);else{let a=((l.width*l.bpp*l.depth+7>>3)+1)*l.height;n=f(q,{chunkSize:a,maxLength:a})}if(q=null,!n||!n.length)throw Error("bad png - invalid inflate data response");let r=h.process(n,l);q=null;let s=j.dataToBitMap(r,l);r=null;let t=k(s,l);return l.data=t,l.gamma=m||0,l}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12097:(a,b)=>{b.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};b.isValid=function(a){return null!=a&&""!==a&&!isNaN(a)&&a>=0&&a<=7},b.from=function(a){return b.isValid(a)?parseInt(a,10):void 0},b.getPenaltyN1=function(a){let b=a.size,c=0,d=0,e=0,f=null,g=null;for(let h=0;h<b;h++){d=e=0,f=g=null;for(let i=0;i<b;i++){let b=a.get(h,i);b===f?d++:(d>=5&&(c+=3+(d-5)),f=b,d=1),(b=a.get(i,h))===g?e++:(e>=5&&(c+=3+(e-5)),g=b,e=1)}d>=5&&(c+=3+(d-5)),e>=5&&(c+=3+(e-5))}return c},b.getPenaltyN2=function(a){let b=a.size,c=0;for(let d=0;d<b-1;d++)for(let e=0;e<b-1;e++){let b=a.get(d,e)+a.get(d,e+1)+a.get(d+1,e)+a.get(d+1,e+1);(4===b||0===b)&&c++}return 3*c},b.getPenaltyN3=function(a){let b=a.size,c=0,d=0,e=0;for(let f=0;f<b;f++){d=e=0;for(let g=0;g<b;g++)d=d<<1&2047|a.get(f,g),g>=10&&(1488===d||93===d)&&c++,e=e<<1&2047|a.get(g,f),g>=10&&(1488===e||93===e)&&c++}return 40*c},b.getPenaltyN4=function(a){let b=0,c=a.data.length;for(let d=0;d<c;d++)b+=a.data[d];return 10*Math.abs(Math.ceil(100*b/c/5)-10)},b.applyMask=function(a,c){let d=c.size;for(let e=0;e<d;e++)for(let f=0;f<d;f++)c.isReserved(f,e)||c.xor(f,e,function(a,c,d){switch(a){case b.Patterns.PATTERN000:return(c+d)%2==0;case b.Patterns.PATTERN001:return c%2==0;case b.Patterns.PATTERN010:return d%3==0;case b.Patterns.PATTERN011:return(c+d)%3==0;case b.Patterns.PATTERN100:return(Math.floor(c/2)+Math.floor(d/3))%2==0;case b.Patterns.PATTERN101:return c*d%2+c*d%3==0;case b.Patterns.PATTERN110:return(c*d%2+c*d%3)%2==0;case b.Patterns.PATTERN111:return(c*d%3+(c+d)%2)%2==0;default:throw Error("bad maskPattern:"+a)}}(a,f,e))},b.getBestMask=function(a,c){let d=Object.keys(b.Patterns).length,e=0,f=1/0;for(let g=0;g<d;g++){c(g),b.applyMask(g,a);let d=b.getPenaltyN1(a)+b.getPenaltyN2(a)+b.getPenaltyN3(a)+b.getPenaltyN4(a);b.applyMask(g,a),d<f&&(f=d,e=g)}return e}},12412:a=>{"use strict";a.exports=require("assert")},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},18994:(a,b,c)=>{let d=c(88397);b.render=function(a,b,c){var e;let f=c,g=b;void 0!==f||b&&b.getContext||(f=b,b=void 0),b||(g=function(){try{return document.createElement("canvas")}catch(a){throw Error("You need to specify a canvas element")}}()),f=d.getOptions(f);let h=d.getImageWidth(a.modules.size,f),i=g.getContext("2d"),j=i.createImageData(h,h);return d.qrToImageData(j.data,a,f),e=g,i.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=h,e.width=h,e.style.height=h+"px",e.style.width=h+"px",i.putImageData(j,0,0),g},b.renderToDataURL=function(a,c,d){let e=d;void 0!==e||c&&c.getContext||(e=c,c=void 0),e||(e={});let f=b.render(a,c,e),g=e.type||"image/png",h=e.rendererOpts||{};return f.toDataURL(g,h.quality)}},19099:(a,b,c)=>{"use strict";var d=c(54839);c.o(d,"useRouter")&&c.d(b,{useRouter:function(){return d.useRouter}}),c.o(d,"useSearchParams")&&c.d(b,{useSearchParams:function(){return d.useSearchParams}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19477:(a,b,c)=>{let d=c(58856),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],f=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];b.getBlocksCount=function(a,b){switch(b){case d.L:return e[(a-1)*4+0];case d.M:return e[(a-1)*4+1];case d.Q:return e[(a-1)*4+2];case d.H:return e[(a-1)*4+3];default:return}},b.getTotalCodewordsCount=function(a,b){switch(b){case d.L:return f[(a-1)*4+0];case d.M:return f[(a-1)*4+1];case d.Q:return f[(a-1)*4+2];case d.H:return f[(a-1)*4+3];default:return}}},23372:(a,b,c)=>{"use strict";let d=c(28354),e=c(74075),f=c(57949),g=c(27459),h=c(96277),i=c(92858),j=c(83670),k=a.exports=function(a){f.call(this),this._parser=new h(a,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=a,this.writable=!0,this._parser.start()};d.inherits(k,f),k.prototype._handleError=function(a){this.emit("error",a),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},k.prototype._inflateData=function(a){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=e.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let a=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,b=Math.max(a,e.Z_MIN_CHUNK);this._inflate=e.createInflate({chunkSize:b});let c=a,d=this.emit.bind(this,"error");this._inflate.on("error",function(a){c&&d(a)}),this._filter.on("complete",this._complete.bind(this));let f=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){c&&(a.length>c&&(a=a.slice(0,c)),c-=a.length,f(a))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(a)},k.prototype._handleMetaData=function(a){this._metaData=a,this._bitmapInfo=Object.create(a),this._filter=new g(this._bitmapInfo)},k.prototype._handleTransColor=function(a){this._bitmapInfo.transColor=a},k.prototype._handlePalette=function(a){this._bitmapInfo.palette=a},k.prototype._simpleTransparency=function(){this._metaData.alpha=!0},k.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},k.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},k.prototype._complete=function(a){let b;if(!this.errord){try{let c=i.dataToBitMap(a,this._bitmapInfo);b=j(c,this._bitmapInfo),c=null}catch(a){this._handleError(a);return}this.emit("parsed",b)}}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},27137:(a,b,c)=>{let d=c(93669),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function f(a){this.mode=d.ALPHANUMERIC,this.data=a}f.getBitsLength=function(a){return 11*Math.floor(a/2)+a%2*6},f.prototype.getLength=function(){return this.data.length},f.prototype.getBitsLength=function(){return f.getBitsLength(this.data.length)},f.prototype.write=function(a){let b;for(b=0;b+2<=this.data.length;b+=2){let c=45*e.indexOf(this.data[b]);c+=e.indexOf(this.data[b+1]),a.put(c,11)}this.data.length%2&&a.put(e.indexOf(this.data[b]),6)},a.exports=f},27459:(a,b,c)=>{"use strict";let d=c(28354),e=c(57949),f=c(27734),g=a.exports=function(a){e.call(this);let b=[],c=this;this._filter=new f(a,{read:this.read.bind(this),write:function(a){b.push(a)},complete:function(){c.emit("complete",Buffer.concat(b))}}),this._filter.start()};d.inherits(g,e)},27734:(a,b,c)=>{"use strict";let d=c(59725),e=c(55211);function f(a,b,c){let d=a*b;return 8!==c&&(d=Math.ceil(d/(8/c))),d}let g=a.exports=function(a,b){let c=a.width,e=a.height,g=a.interlace,h=a.bpp,i=a.depth;if(this.read=b.read,this.write=b.write,this.complete=b.complete,this._imageIndex=0,this._images=[],g){let a=d.getImagePasses(c,e);for(let b=0;b<a.length;b++)this._images.push({byteWidth:f(a[b].width,h,i),height:a[b].height,lineIndex:0})}else this._images.push({byteWidth:f(c,h,i),height:e,lineIndex:0});8===i?this._xComparison=h:16===i?this._xComparison=2*h:this._xComparison=1};g.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},g.prototype._unFilterType1=function(a,b,c){let d=this._xComparison,e=d-1;for(let f=0;f<c;f++){let c=a[1+f],g=f>e?b[f-d]:0;b[f]=c+g}},g.prototype._unFilterType2=function(a,b,c){let d=this._lastLine;for(let e=0;e<c;e++){let c=a[1+e],f=d?d[e]:0;b[e]=c+f}},g.prototype._unFilterType3=function(a,b,c){let d=this._xComparison,e=d-1,f=this._lastLine;for(let g=0;g<c;g++){let c=a[1+g],h=f?f[g]:0,i=Math.floor(((g>e?b[g-d]:0)+h)/2);b[g]=c+i}},g.prototype._unFilterType4=function(a,b,c){let d=this._xComparison,f=d-1,g=this._lastLine;for(let h=0;h<c;h++){let c=a[1+h],i=g?g[h]:0,j=e(h>f?b[h-d]:0,i,h>f&&g?g[h-d]:0);b[h]=c+j}},g.prototype._reverseFilterLine=function(a){let b,c=a[0],d=this._images[this._imageIndex],e=d.byteWidth;if(0===c)b=a.slice(1,e+1);else switch(b=Buffer.alloc(e),c){case 1:this._unFilterType1(a,b,e);break;case 2:this._unFilterType2(a,b,e);break;case 3:this._unFilterType3(a,b,e);break;case 4:this._unFilterType4(a,b,e);break;default:throw Error("Unrecognised filter type - "+c)}this.write(b),d.lineIndex++,d.lineIndex>=d.height?(this._lastLine=null,this._imageIndex++,d=this._images[this._imageIndex]):this._lastLine=b,d?this.read(d.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28964:(a,b,c)=>{let d=c(93669);function e(a){this.mode=d.NUMERIC,this.data=a.toString()}e.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(a){let b,c;for(b=0;b+3<=this.data.length;b+=3)c=parseInt(this.data.substr(b,3),10),a.put(c,10);let d=this.data.length-b;d>0&&(c=parseInt(this.data.substr(b),10),a.put(c,3*d+1))},a.exports=e},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31964:(a,b,c)=>{"use strict";let d=c(55211),e={0:function(a,b,c,d,e){for(let f=0;f<c;f++)d[e+f]=a[b+f]},1:function(a,b,c,d,e,f){for(let g=0;g<c;g++){let c=g>=f?a[b+g-f]:0,h=a[b+g]-c;d[e+g]=h}},2:function(a,b,c,d,e){for(let f=0;f<c;f++){let g=b>0?a[b+f-c]:0,h=a[b+f]-g;d[e+f]=h}},3:function(a,b,c,d,e,f){for(let g=0;g<c;g++){let h=g>=f?a[b+g-f]:0,i=b>0?a[b+g-c]:0,j=a[b+g]-(h+i>>1);d[e+g]=j}},4:function(a,b,c,e,f,g){for(let h=0;h<c;h++){let i=h>=g?a[b+h-g]:0,j=b>0?a[b+h-c]:0,k=b>0&&h>=g?a[b+h-(c+g)]:0,l=a[b+h]-d(i,j,k);e[f+h]=l}}},f={0:function(a,b,c){let d=0,e=b+c;for(let c=b;c<e;c++)d+=Math.abs(a[c]);return d},1:function(a,b,c,d){let e=0;for(let f=0;f<c;f++){let c=f>=d?a[b+f-d]:0;e+=Math.abs(a[b+f]-c)}return e},2:function(a,b,c){let d=0,e=b+c;for(let f=b;f<e;f++){let e=b>0?a[f-c]:0;d+=Math.abs(a[f]-e)}return d},3:function(a,b,c,d){let e=0;for(let f=0;f<c;f++){let g=f>=d?a[b+f-d]:0,h=b>0?a[b+f-c]:0;e+=Math.abs(a[b+f]-(g+h>>1))}return e},4:function(a,b,c,e){let f=0;for(let g=0;g<c;g++){let h=g>=e?a[b+g-e]:0,i=b>0?a[b+g-c]:0,j=b>0&&g>=e?a[b+g-(c+e)]:0;f+=Math.abs(a[b+g]-d(h,i,j))}return f}};a.exports=function(a,b,c,d,g){let h;if("filterType"in d&&-1!==d.filterType)if("number"==typeof d.filterType)h=[d.filterType];else throw Error("unrecognised filter types");else h=[0,1,2,3,4];16===d.bitDepth&&(g*=2);let i=b*g,j=0,k=0,l=Buffer.alloc((i+1)*c),m=h[0];for(let b=0;b<c;b++){if(h.length>1){let b=1/0;for(let c=0;c<h.length;c++){let d=f[h[c]](a,k,i,g);d<b&&(m=h[c],b=d)}}l[j]=m,j++,e[m](a,k,i,l,j,g),j+=i,k+=i}return l}},32835:(a,b,c)=>{let d=c(88397);function e(a,b){let c=a.a/255,d=b+'="'+a.hex+'"';return c<1?d+" "+b+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function f(a,b,c){let d=a+b;return void 0!==c&&(d+=" "+c),d}b.render=function(a,b,c){let g=d.getOptions(b),h=a.modules.size,i=a.modules.data,j=h+2*g.margin,k=g.color.light.a?"<path "+e(g.color.light,"fill")+' d="M0 0h'+j+"v"+j+'H0z"/>':"",l="<path "+e(g.color.dark,"stroke")+' d="'+function(a,b,c){let d="",e=0,g=!1,h=0;for(let i=0;i<a.length;i++){let j=Math.floor(i%b),k=Math.floor(i/b);j||g||(g=!0),a[i]?(h++,i>0&&j>0&&a[i-1]||(d+=g?f("M",j+c,.5+k+c):f("m",e,0),e=0,g=!1),j+1<b&&a[i+1]||(d+=f("h",h),h=0)):e++}return d}(i,h,g.margin)+'"/>',m='<svg xmlns="http://www.w3.org/2000/svg" '+(g.width?'width="'+g.width+'" height="'+g.width+'" ':"")+('viewBox="0 0 '+j+" ")+j+'" shape-rendering="crispEdges">'+k+l+"</svg>\n";return"function"==typeof c&&c(null,m),m}},33873:a=>{"use strict";a.exports=require("path")},34447:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=c(23372),g=c(49149),h=c(58879),i=b.O=function(a){e.call(this),a=a||{},this.width=0|a.width,this.height=0|a.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,a.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new f(a),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(a){this.data=a,this.emit("parsed",a)}).bind(this)),this._packer=new g(a),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};d.inherits(i,e),i.sync=h,i.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},i.prototype.parse=function(a,b){if(b){let a,c;a=(function(a){this.removeListener("error",c),this.data=a,b(null,this)}).bind(this),c=(function(c){this.removeListener("parsed",a),b(c,null)}).bind(this),this.once("parsed",a),this.once("error",c)}return this.end(a),this},i.prototype.write=function(a){return this._parser.write(a),!0},i.prototype.end=function(a){this._parser.end(a)},i.prototype._metadata=function(a){this.width=a.width,this.height=a.height,this.emit("metadata",a)},i.prototype._gamma=function(a){this.gamma=a},i.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},i.bitblt=function(a,b,c,d,e,f,g,h){if(d|=0,e|=0,f|=0,g|=0,h|=0,(c|=0)>a.width||d>a.height||c+e>a.width||d+f>a.height)throw Error("bitblt reading outside image");if(g>b.width||h>b.height||g+e>b.width||h+f>b.height)throw Error("bitblt writing outside image");for(let i=0;i<f;i++)a.data.copy(b.data,(h+i)*b.width+g<<2,(d+i)*a.width+c<<2,(d+i)*a.width+c+e<<2)},i.prototype.bitblt=function(a,b,c,d,e,f,g){return i.bitblt(this,a,b,c,d,e,f,g),this},i.adjustGamma=function(a){if(a.gamma){for(let b=0;b<a.height;b++)for(let c=0;c<a.width;c++){let d=a.width*b+c<<2;for(let b=0;b<3;b++){let c=a.data[d+b]/255;c=Math.pow(c,1/2.2/a.gamma),a.data[d+b]=Math.round(255*c)}}a.gamma=0}},i.prototype.adjustGamma=function(){i.adjustGamma(this)}},35790:(a,b,c)=>{"use strict";c.d(b,{AppShell:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call AppShell() from the server but AppShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/annovibe/annovibe/components/AppShell.tsx","AppShell")},38937:(a,b,c)=>{let d=c(93669);function e(a){this.mode=d.BYTE,"string"==typeof a?this.data=new TextEncoder().encode(a):this.data=new Uint8Array(a)}e.getBitsLength=function(a){return 8*a},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(a){for(let b=0,c=this.data.length;b<c;b++)a.put(this.data[b],8)},a.exports=e},39477:(a,b,c)=>{let d=c(58305).getSymbolSize;b.getPositions=function(a){let b=d(a);return[[0,0],[b-7,0],[0,b-7]]}},39588:(a,b,c)=>{let d=c(93669),e=c(28964),f=c(27137),g=c(38937),h=c(64424),i=c(64323),j=c(58305),k=c(84879);function l(a){return unescape(encodeURIComponent(a)).length}function m(a,b,c){let d,e=[];for(;null!==(d=a.exec(c));)e.push({data:d[0],index:d.index,mode:b,length:d[0].length});return e}function n(a){let b,c,e=m(i.NUMERIC,d.NUMERIC,a),f=m(i.ALPHANUMERIC,d.ALPHANUMERIC,a);return j.isKanjiModeEnabled()?(b=m(i.BYTE,d.BYTE,a),c=m(i.KANJI,d.KANJI,a)):(b=m(i.BYTE_KANJI,d.BYTE,a),c=[]),e.concat(f,b,c).sort(function(a,b){return a.index-b.index}).map(function(a){return{data:a.data,mode:a.mode,length:a.length}})}function o(a,b){switch(b){case d.NUMERIC:return e.getBitsLength(a);case d.ALPHANUMERIC:return f.getBitsLength(a);case d.KANJI:return h.getBitsLength(a);case d.BYTE:return g.getBitsLength(a)}}function p(a,b){let c,i=d.getBestModeForData(a);if((c=d.from(b,i))!==d.BYTE&&c.bit<i.bit)throw Error('"'+a+'" cannot be encoded with mode '+d.toString(c)+".\n Suggested mode is: "+d.toString(i));switch(c===d.KANJI&&!j.isKanjiModeEnabled()&&(c=d.BYTE),c){case d.NUMERIC:return new e(a);case d.ALPHANUMERIC:return new f(a);case d.KANJI:return new h(a);case d.BYTE:return new g(a)}}b.fromArray=function(a){return a.reduce(function(a,b){return"string"==typeof b?a.push(p(b,null)):b.data&&a.push(p(b.data,b.mode)),a},[])},b.fromString=function(a,c){let e=function(a,b){let c={},e={start:{}},f=["start"];for(let g=0;g<a.length;g++){let h=a[g],i=[];for(let a=0;a<h.length;a++){let j=h[a],k=""+g+a;i.push(k),c[k]={node:j,lastCount:0},e[k]={};for(let a=0;a<f.length;a++){let g=f[a];c[g]&&c[g].node.mode===j.mode?(e[g][k]=o(c[g].lastCount+j.length,j.mode)-o(c[g].lastCount,j.mode),c[g].lastCount+=j.length):(c[g]&&(c[g].lastCount=j.length),e[g][k]=o(j.length,j.mode)+4+d.getCharCountIndicator(j.mode,b))}}f=i}for(let a=0;a<f.length;a++)e[f[a]].end=0;return{map:e,table:c}}(function(a){let b=[];for(let c=0;c<a.length;c++){let e=a[c];switch(e.mode){case d.NUMERIC:b.push([e,{data:e.data,mode:d.ALPHANUMERIC,length:e.length},{data:e.data,mode:d.BYTE,length:e.length}]);break;case d.ALPHANUMERIC:b.push([e,{data:e.data,mode:d.BYTE,length:e.length}]);break;case d.KANJI:b.push([e,{data:e.data,mode:d.BYTE,length:l(e.data)}]);break;case d.BYTE:b.push([{data:e.data,mode:d.BYTE,length:l(e.data)}])}}return b}(n(a,j.isKanjiModeEnabled())),c),f=k.find_path(e.map,"start","end"),g=[];for(let a=1;a<f.length-1;a++)g.push(e.table[f[a]].node);return b.fromArray(g.reduce(function(a,b){let c=a.length-1>=0?a[a.length-1]:null;return c&&c.mode===b.mode?a[a.length-1].data+=b.data:a.push(b),a},[]))},b.rawSplit=function(a){return b.fromArray(n(a,j.isKanjiModeEnabled()))}},40355:(a,b,c)=>{let d=c(76708),e=c(95380),f=c(46387),g=c(72081),h=c(66530),i=c(90082);function j(a,b,c){if(void 0===a)throw Error("String required as first argument");if(void 0===c&&(c=b,b={}),"function"!=typeof c)if(d())b=c||{},c=null;else throw Error("Callback required as last argument");return{opts:b,cb:c}}function k(a){switch(a){case"svg":return i;case"txt":case"utf8":return g;default:return f}}function l(a,b,c){if(!c.cb)return new Promise(function(d,f){try{let g=e.create(b,c.opts);return a(g,c.opts,function(a,b){return a?f(a):d(b)})}catch(a){f(a)}});try{let d=e.create(b,c.opts);return a(d,c.opts,c.cb)}catch(a){c.cb(a)}}b.create=e.create,b.toCanvas=c(2798).toCanvas,b.toString=function(a,b,c){let d=j(a,b,c);return l(function(a){switch(a){case"svg":return i;case"terminal":return h;default:return g}}(d.opts?d.opts.type:void 0).render,a,d)},b.toDataURL=function(a,b,c){let d=j(a,b,c);return l(k(d.opts.type).renderToDataURL,a,d)},b.toBuffer=function(a,b,c){let d=j(a,b,c);return l(k(d.opts.type).renderToBuffer,a,d)},b.toFile=function(a,b,c,e){if("string"!=typeof a||"string"!=typeof b&&"object"!=typeof b)throw Error("Invalid argument");if(arguments.length<3&&!d())throw Error("Too few arguments provided");let f=j(b,c,e);return l(k(f.opts.type||a.slice((a.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,a),b,f)},b.toFileStream=function(a,b,c){if(arguments.length<2)throw Error("Too few arguments provided");let d=j(b,c,a.emit.bind(a,"error"));l(k("png").renderToFileStream.bind(null,a),b,d)}},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},42516:(a,b,c)=>{"use strict";let d=c(81769),e=c(27734);b.process=function(a,b){let c=[],f=new d(a);return new e(b,{read:f.read.bind(f),write:function(a){c.push(a)},complete:function(){}}).start(),f.process(),Buffer.concat(c)}},43144:(a,b,c)=>{let d=c(81754);b.mul=function(a,b){let c=new Uint8Array(a.length+b.length-1);for(let e=0;e<a.length;e++)for(let f=0;f<b.length;f++)c[e+f]^=d.mul(a[e],b[f]);return c},b.mod=function(a,b){let c=new Uint8Array(a);for(;c.length-b.length>=0;){let a=c[0];for(let e=0;e<b.length;e++)c[e]^=d.mul(b[e],a);let e=0;for(;e<c.length&&0===c[e];)e++;c=c.slice(e)}return c},b.generateECPolynomial=function(a){let c=new Uint8Array([1]);for(let e=0;e<a;e++)c=b.mul(c,new Uint8Array([1,d.exp(e)]));return c}},43894:a=>{"use strict";let b=[];for(let a=0;a<256;a++){let c=a;for(let a=0;a<8;a++)1&c?c=0xedb88320^c>>>1:c>>>=1;b[a]=c}let c=a.exports=function(){this._crc=-1};c.prototype.write=function(a){for(let c=0;c<a.length;c++)this._crc=b[(this._crc^a[c])&255]^this._crc>>>8;return!0},c.prototype.crc32=function(){return -1^this._crc},c.crc32=function(a){let c=-1;for(let d=0;d<a.length;d++)c=b[(c^a[d])&255]^c>>>8;return -1^c}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},46349:a=>{function b(a){if(!a||a<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=a,this.data=new Uint8Array(a*a),this.reservedBit=new Uint8Array(a*a)}b.prototype.set=function(a,b,c,d){let e=a*this.size+b;this.data[e]=c,d&&(this.reservedBit[e]=!0)},b.prototype.get=function(a,b){return this.data[a*this.size+b]},b.prototype.xor=function(a,b,c){this.data[a*this.size+b]^=c},b.prototype.isReserved=function(a,b){return this.reservedBit[a*this.size+b]},a.exports=b},46387:(a,b,c)=>{let d=c(29021),e=c(34447).O,f=c(88397);b.render=function(a,b){let c=f.getOptions(b),d=c.rendererOpts,g=f.getImageWidth(a.modules.size,c);d.width=g,d.height=g;let h=new e(d);return f.qrToImageData(h.data,a,c),h},b.renderToDataURL=function(a,c,d){void 0===d&&(d=c,c=void 0),b.renderToBuffer(a,c,function(a,b){a&&d(a);let c="data:image/png;base64,";c+=b.toString("base64"),d(null,c)})},b.renderToBuffer=function(a,c,d){void 0===d&&(d=c,c=void 0);let e=b.render(a,c),f=[];e.on("error",d),e.on("data",function(a){f.push(a)}),e.on("end",function(){d(null,Buffer.concat(f))}),e.pack()},b.renderToFile=function(a,c,e,f){void 0===f&&(f=e,e=void 0);let g=!1,h=(...a)=>{g||(g=!0,f.apply(null,a))},i=d.createWriteStream(a);i.on("error",h),i.on("close",h),b.renderToFileStream(i,c,e)},b.renderToFileStream=function(a,c,d){b.render(c,d).pack().pipe(a)}},49149:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=c(67269),g=c(98052),h=a.exports=function(a){e.call(this),this._packer=new g(a||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};d.inherits(h,e),h.prototype.pack=function(a,b,c,d){this.emit("data",Buffer.from(f.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(b,c)),d&&this.emit("data",this._packer.packGAMA(d));let e=this._packer.filterData(a,b,c);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(a){this.emit("data",this._packer.packIDAT(a))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(e)}},49998:(a,b,c)=>{"use strict";a.exports=c(40355)},52002:a=>{function b(){this.buffer=[],this.length=0}b.prototype={get:function(a){let b=Math.floor(a/8);return(this.buffer[b]>>>7-a%8&1)==1},put:function(a,b){for(let c=0;c<b;c++)this.putBit((a>>>b-c-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(a){let b=Math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0),a&&(this.buffer[b]|=128>>>this.length%8),this.length++}},a.exports=b},52324:(a,b,c)=>{let d=c(58305),e=c(19477),f=c(58856),g=c(93669),h=c(83929),i=d.getBCHDigit(7973);function j(a,b){return g.getCharCountIndicator(a,b)+4}b.from=function(a,b){return h.isValid(a)?parseInt(a,10):b},b.getCapacity=function(a,b,c){if(!h.isValid(a))throw Error("Invalid QR Code version");void 0===c&&(c=g.BYTE);let f=(d.getSymbolTotalCodewords(a)-e.getTotalCodewordsCount(a,b))*8;if(c===g.MIXED)return f;let i=f-j(c,a);switch(c){case g.NUMERIC:return Math.floor(i/10*3);case g.ALPHANUMERIC:return Math.floor(i/11*2);case g.KANJI:return Math.floor(i/13);case g.BYTE:default:return Math.floor(i/8)}},b.getBestVersionForData=function(a,c){let d,e=f.from(c,f.M);if(Array.isArray(a)){if(a.length>1){for(let c=1;c<=40;c++)if(function(a,b){let c=0;return a.forEach(function(a){let d=j(a.mode,b);c+=d+a.getBitsLength()}),c}(a,c)<=b.getCapacity(c,e,g.MIXED))return c;return}if(0===a.length)return 1;d=a[0]}else d=a;return function(a,c,d){for(let e=1;e<=40;e++)if(c<=b.getCapacity(e,d,a))return e}(d.mode,d.getLength(),e)},b.getEncodedBits=function(a){if(!h.isValid(a)||a<7)throw Error("Invalid QR Code version");let b=a<<12;for(;d.getBCHDigit(b)-i>=0;)b^=7973<<d.getBCHDigit(b)-i;return a<<12|b}},55211:a=>{"use strict";a.exports=function(a,b,c){let d=a+b-c,e=Math.abs(d-a),f=Math.abs(d-b),g=Math.abs(d-c);return e<=f&&e<=g?a:f<=g?b:c}},55258:(a,b,c)=>{let d=c(58305),e=d.getBCHDigit(1335);b.getEncodedBits=function(a,b){let c=a.bit<<3|b,f=c<<10;for(;d.getBCHDigit(f)-e>=0;)f^=1335<<d.getBCHDigit(f)-e;return(c<<10|f)^21522}},57949:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=a.exports=function(){e.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};d.inherits(f,e),f.prototype.read=function(a,b){this._reads.push({length:Math.abs(a),allowLess:a<0,func:b}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},f.prototype.write=function(a,b){let c;return this.writable?(c=Buffer.isBuffer(a)?a:Buffer.from(a,b||this._encoding),this._buffers.push(c),this._buffered+=c.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},f.prototype.end=function(a,b){a&&this.write(a,b),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},f.prototype.destroySoon=f.prototype.end,f.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},f.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},f.prototype._processReadAllowingLess=function(a){this._reads.shift();let b=this._buffers[0];b.length>a.length?(this._buffered-=a.length,this._buffers[0]=b.slice(a.length),a.func.call(this,b.slice(0,a.length))):(this._buffered-=b.length,this._buffers.shift(),a.func.call(this,b))},f.prototype._processRead=function(a){this._reads.shift();let b=0,c=0,d=Buffer.alloc(a.length);for(;b<a.length;){let e=this._buffers[c++],f=Math.min(e.length,a.length-b);e.copy(d,b,0,f),b+=f,f!==e.length&&(this._buffers[--c]=e.slice(f))}c>0&&this._buffers.splice(0,c),this._buffered-=a.length,a.func.call(this,d)},f.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let a=this._reads[0];if(a.allowLess)this._processReadAllowingLess(a);else if(this._buffered>=a.length)this._processRead(a);else break}this._buffers&&!this.writable&&this._end()}catch(a){this.emit("error",a)}}},58305:(a,b)=>{let c,d=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];b.getSymbolSize=function(a){if(!a)throw Error('"version" cannot be null or undefined');if(a<1||a>40)throw Error('"version" should be in range from 1 to 40');return 4*a+17},b.getSymbolTotalCodewords=function(a){return d[a]},b.getBCHDigit=function(a){let b=0;for(;0!==a;)b++,a>>>=1;return b},b.setToSJISFunction=function(a){if("function"!=typeof a)throw Error('"toSJISFunc" is not a valid function.');c=a},b.isKanjiModeEnabled=function(){return void 0!==c},b.toSJIS=function(a){return c(a)}},58856:(a,b)=>{b.L={bit:1},b.M={bit:0},b.Q={bit:3},b.H={bit:2},b.isValid=function(a){return a&&void 0!==a.bit&&a.bit>=0&&a.bit<4},b.from=function(a,c){if(b.isValid(a))return a;try{if("string"!=typeof a)throw Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return b.L;case"m":case"medium":return b.M;case"q":case"quartile":return b.Q;case"h":case"high":return b.H;default:throw Error("Unknown EC Level: "+a)}}catch(a){return c}}},58879:(a,b,c)=>{"use strict";let d=c(9709),e=c(80706);b.read=function(a,b){return d(a,b||{})},b.write=function(a,b){return e(a,b)}},59725:(a,b)=>{"use strict";let c=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];b.getImagePasses=function(a,b){let d=[],e=a%8,f=b%8,g=(a-e)/8,h=(b-f)/8;for(let a=0;a<c.length;a++){let b=c[a],i=g*b.x.length,j=h*b.y.length;for(let a=0;a<b.x.length;a++)if(b.x[a]<e)i++;else break;for(let a=0;a<b.y.length;a++)if(b.y[a]<f)j++;else break;i>0&&j>0&&d.push({width:i,height:j,index:a})}return d},b.getInterlaceIterator=function(a){return function(b,d,e){let f=b%c[e].x.length,g=(b-f)/c[e].x.length*8+c[e].x[f],h=d%c[e].y.length;return 4*g+((d-h)/c[e].y.length*8+c[e].y[h])*a*4}}},61345:(a,b)=>{b.render=function(a,b,c){let d=a.modules.size,e=a.modules.data,f="\x1b[47m \x1b[0m",g="",h=Array(d+3).join(f),i=[,,].join(f);g+=h+"\n";for(let a=0;a<d;++a){g+=f;for(let b=0;b<d;b++)g+=e[a*d+b]?"\x1b[40m \x1b[0m":f;g+=i+"\n"}return g+=h+"\n","function"==typeof c&&c(null,g),g}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},64323:(a,b)=>{let c="[0-9]+",d="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",e="(?:(?![A-Z0-9 $%*+\\-./:]|"+(d=d.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";b.KANJI=RegExp(d,"g"),b.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),b.BYTE=RegExp(e,"g"),b.NUMERIC=RegExp(c,"g"),b.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let f=RegExp("^"+d+"$"),g=RegExp("^"+c+"$"),h=RegExp("^[A-Z0-9 $%*+\\-./:]+$");b.testKanji=function(a){return f.test(a)},b.testNumeric=function(a){return g.test(a)},b.testAlphanumeric=function(a){return h.test(a)}},64424:(a,b,c)=>{let d=c(93669),e=c(58305);function f(a){this.mode=d.KANJI,this.data=a}f.getBitsLength=function(a){return 13*a},f.prototype.getLength=function(){return this.data.length},f.prototype.getBitsLength=function(){return f.getBitsLength(this.data.length)},f.prototype.write=function(a){let b;for(b=0;b<this.data.length;b++){let c=e.toSJIS(this.data[b]);if(c>=33088&&c<=40956)c-=33088;else if(c>=57408&&c<=60351)c-=49472;else throw Error("Invalid SJIS character: "+this.data[b]+"\nMake sure your charset is UTF-8");c=(c>>>8&255)*192+(255&c),a.put(c,13)}},a.exports=f},66530:(a,b,c)=>{let d=c(61345),e=c(86491);b.render=function(a,b,c){return b&&b.small?e.render(a,b,c):d.render(a,b,c)}},67269:a=>{"use strict";a.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},72081:(a,b,c)=>{let d=c(88397),e={WW:" ",WB:"▄",BB:"█",BW:"▀"},f={BB:" ",BW:"▄",WW:"█",WB:"▀"};b.render=function(a,b,c){let g=d.getOptions(b),h=e;("#ffffff"===g.color.dark.hex||"#000000"===g.color.light.hex)&&(h=f);let i=a.modules.size,j=a.modules.data,k="",l=Array(i+2*g.margin+1).join(h.WW);l=Array(g.margin/2+1).join(l+"\n");let m=Array(g.margin+1).join(h.WW);k+=l;for(let a=0;a<i;a+=2){k+=m;for(let b=0;b<i;b++){var n;let c=j[a*i+b],d=j[(a+1)*i+b];k+=(n=h,c&&d?n.BB:c&&!d?n.BW:!c&&d?n.WB:n.WW)}k+=m+"\n"}return k+=l.slice(0,-1),"function"==typeof c&&c(null,k),k},b.renderToFile=function(a,d,e,f){void 0===f&&(f=e,e=void 0);let g=c(29021),h=b.render(d,e);g.writeFile(a,h,f)}},73136:a=>{"use strict";a.exports=require("node:url")},74075:a=>{"use strict";a.exports=require("zlib")},76708:a=>{a.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78908:a=>{"use strict";a.exports=import("shiki")},79428:a=>{"use strict";a.exports=require("buffer")},80183:(a,b,c)=>{"use strict";let d=c(12412).ok,e=c(74075),f=c(28354),g=c(79428).kMaxLength;function h(a){if(!(this instanceof h))return new h(a);a&&a.chunkSize<e.Z_MIN_CHUNK&&(a.chunkSize=e.Z_MIN_CHUNK),e.Inflate.call(this,a),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,a&&null!=a.maxLength&&(this._maxLength=a.maxLength)}function i(a,b){b&&process.nextTick(b),a._handle&&(a._handle.close(),a._handle=null)}function j(a,b){var c=new h(b),d=a;if("string"==typeof d&&(d=Buffer.from(d)),!(d instanceof Buffer))throw TypeError("Not a string or buffer");let f=c._finishFlushFlag;return null==f&&(f=e.Z_FINISH),c._processChunk(d,f)}h.prototype._processChunk=function(a,b,c){let f,h;if("function"==typeof c)return e.Inflate._processChunk.call(this,a,b,c);let j=this,k=a&&a.length,l=this._chunkSize-this._offset,m=this._maxLength,n=0,o=[],p=0;this.on("error",function(a){f=a}),d(this._handle,"zlib binding closed");do h=(h=this._handle.writeSync(b,a,n,k,this._buffer,this._offset,l))||this._writeState;while(!this._hadError&&function(a,b){if(j._hadError)return;let c=l-b;if(d(c>=0,"have should not go down"),c>0){let a=j._buffer.slice(j._offset,j._offset+c);if(j._offset+=c,a.length>m&&(a=a.slice(0,m)),o.push(a),p+=a.length,0==(m-=a.length))return!1}return(0===b||j._offset>=j._chunkSize)&&(l=j._chunkSize,j._offset=0,j._buffer=Buffer.allocUnsafe(j._chunkSize)),0===b&&(n+=k-a,k=a,!0)}(h[0],h[1]));if(this._hadError)throw f;if(p>=g)throw i(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+g.toString(16)+" bytes");let q=Buffer.concat(o,p);return i(this),q},f.inherits(h,e.Inflate),a.exports=b=j,b.Inflate=h,b.createInflate=function(a){return new h(a)},b.inflateSync=j},80706:(a,b,c)=>{"use strict";let d=!0,e=c(74075);e.deflateSync||(d=!1);let f=c(67269),g=c(98052);a.exports=function(a,b){if(!d)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let c=new g(b||{}),h=[];h.push(Buffer.from(f.PNG_SIGNATURE)),h.push(c.packIHDR(a.width,a.height)),a.gamma&&h.push(c.packGAMA(a.gamma));let i=c.filterData(a.data,a.width,a.height),j=e.deflateSync(i,c.getDeflateOptions());if(i=null,!j||!j.length)throw Error("bad png - invalid compressed data response");return h.push(c.packIDAT(j)),h.push(c.packIEND()),Buffer.concat(h)}},81754:(a,b)=>{let c=new Uint8Array(512),d=new Uint8Array(256),e=1;for(let a=0;a<255;a++)c[a]=e,d[e]=a,256&(e<<=1)&&(e^=285);for(let a=255;a<512;a++)c[a]=c[a-255];b.log=function(a){if(a<1)throw Error("log("+a+")");return d[a]},b.exp=function(a){return c[a]},b.mul=function(a,b){return 0===a||0===b?0:c[d[a]+d[b]]}},81769:a=>{"use strict";let b=a.exports=function(a){this._buffer=a,this._reads=[]};b.prototype.read=function(a,b){this._reads.push({length:Math.abs(a),allowLess:a<0,func:b})},b.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let a=this._reads[0];if(this._buffer.length&&(this._buffer.length>=a.length||a.allowLess)){this._reads.shift();let b=this._buffer;this._buffer=b.slice(a.length),a.func.call(this,b.slice(0,a.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},83670:a=>{"use strict";a.exports=function(a,b){let c=b.depth,d=b.width,e=b.height,f=b.colorType,g=b.transColor,h=b.palette,i=a;return 3===f?!function(a,b,c,d,e){let f=0;for(let g=0;g<d;g++)for(let d=0;d<c;d++){let c=e[a[f]];if(!c)throw Error("index "+a[f]+" not in palette");for(let a=0;a<4;a++)b[f+a]=c[a];f+=4}}(a,i,d,e,h):(g&&function(a,b,c,d,e){let f=0;for(let g=0;g<d;g++)for(let d=0;d<c;d++){let c=!1;if(1===e.length?e[0]===a[f]&&(c=!0):e[0]===a[f]&&e[1]===a[f+1]&&e[2]===a[f+2]&&(c=!0),c)for(let a=0;a<4;a++)b[f+a]=0;f+=4}}(a,i,d,e,g),8!==c&&(16===c&&(i=Buffer.alloc(d*e*4)),!function(a,b,c,d,e){let f=Math.pow(2,e)-1,g=0;for(let e=0;e<d;e++)for(let d=0;d<c;d++){for(let c=0;c<4;c++)b[g+c]=Math.floor(255*a[g+c]/f+.5);g+=4}}(a,i,d,e,c))),i}},83929:(a,b)=>{b.isValid=function(a){return!isNaN(a)&&a>=1&&a<=40}},84879:a=>{"use strict";var b={single_source_shortest_paths:function(a,c,d){var e,f,g,h,i,j,k,l={},m={};m[c]=0;var n=b.PriorityQueue.make();for(n.push(c,0);!n.empty();)for(g in f=(e=n.pop()).value,h=e.cost,i=a[f]||{})i.hasOwnProperty(g)&&(j=h+i[g],k=m[g],(void 0===m[g]||k>j)&&(m[g]=j,n.push(g,j),l[g]=f));if(void 0!==d&&void 0===m[d])throw Error("Could not find a path from "+c+" to "+d+".");return l},extract_shortest_path_from_predecessor_list:function(a,b){for(var c=[],d=b;d;)c.push(d),a[d],d=a[d];return c.reverse(),c},find_path:function(a,c,d){var e=b.single_source_shortest_paths(a,c,d);return b.extract_shortest_path_from_predecessor_list(e,d)},PriorityQueue:{make:function(a){var c,d=b.PriorityQueue,e={};for(c in a=a||{},d)d.hasOwnProperty(c)&&(e[c]=d[c]);return e.queue=[],e.sorter=a.sorter||d.default_sorter,e},default_sorter:function(a,b){return a.cost-b.cost},push:function(a,b){this.queue.push({value:a,cost:b}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};a.exports=b},85644:(a,b,c)=>{"use strict";c.d(b,{AppShell:()=>dZ});var d=c(48249),e=c(67484),f=c.n(e),g=c(19099);function h(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"..."+d+e.slice(-2).join(d)}function i(a){let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function j({open:a,cwd:b,homeDir:c,onClose:f,onSelectSession:g}){let[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)("current"),[o,p]=(0,e.useState)([]),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!1),w=(0,e.useRef)(null);if(!a)return null;let x=k.trim(),y=o.reduce((a,b)=>a+b.matches.length,0);return(0,d.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Search conversation history",style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"8vh 16px 16px",background:"rgba(0,0,0,0.28)"},onMouseDown:a=>{a.target===a.currentTarget&&f()},children:(0,d.jsxs)("div",{style:{width:"min(760px, 100%)",maxHeight:"78vh",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 16px 48px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,padding:"0 10px"},children:[(0,d.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,d.jsx)("path",{d:"M10.5 10.5 13.5 13.5"})]}),(0,d.jsx)("input",{ref:w,value:k,onChange:a=>l(a.target.value),placeholder:"Search conversation history...",style:{flex:1,minWidth:0,height:38,background:"transparent",border:"none",outline:"none",color:"var(--text)",fontSize:14}})]}),(0,d.jsx)("button",{type:"button",onClick:f,title:"Close",style:{width:34,height:34,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderRadius:7,color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color="var(--text-dim)"},children:(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,d.jsx)("path",{d:"M4 4 12 12"}),(0,d.jsx)("path",{d:"M12 4 4 12"})]})})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[(0,d.jsx)("div",{style:{display:"inline-flex",padding:2,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7},children:[{value:"current",label:"Current project",disabled:!b},{value:"all",label:"All history",disabled:!1}].map(a=>(0,d.jsx)("button",{type:"button",disabled:a.disabled,onClick:()=>n(a.value),style:{height:24,padding:"0 9px",background:m===a.value?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,color:a.disabled?"var(--text-dim)":m===a.value?"var(--text)":"var(--text-muted)",cursor:a.disabled?"not-allowed":"pointer",fontSize:11,fontWeight:500},children:a.label},a.value))}),(0,d.jsx)("div",{style:{flex:1,minWidth:0,color:"var(--text-dim)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"current"===m&&b?h(b,c):"Searching every saved session"})]})]}),(0,d.jsxs)("div",{style:{flex:1,overflowY:"auto",minHeight:180},children:[x.length<2&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Type at least 2 characters to search saved conversations."}),x.length>=2&&q&&0===o.length&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Searching..."}),s&&(0,d.jsx)("div",{style:{padding:18,color:"#ef4444",fontSize:13},children:s}),x.length>=2&&!q&&!s&&0===o.length&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"No matching conversations found."}),o.map(a=>(0,d.jsxs)("div",{style:{borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>{g(a.session),f()},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:"var(--bg-panel)",border:"none",borderBottom:"1px solid var(--border)",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-panel)"},children:[(0,d.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:600},children:a.session.name||a.session.firstMessage||"(no messages)"}),(0,d.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:11},children:i(a.session.modified)})]}),(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h(a.session.cwd,c)})]}),a.matchCount>a.matches.length&&(0,d.jsxs)("span",{style:{flexShrink:0,color:"var(--text-muted)",fontSize:11},children:[a.matchCount," matches"]})]}),a.matches.map(b=>(0,d.jsxs)("button",{type:"button",onClick:()=>{g(a.session),f()},style:{width:"100%",padding:"9px 14px 9px 28px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[(0,d.jsx)("span",{style:{minWidth:54,color:"user"===b.role?"var(--accent)":"var(--text-dim)",fontSize:11,fontWeight:600,textTransform:"capitalize"},children:b.role}),(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:i(b.timestamp)})]}),(0,d.jsx)("div",{style:{fontSize:12,lineHeight:1.45,color:"var(--text-muted)"},children:function(a,b){let c=b.trim();if(!c)return a;let e=a.toLowerCase().indexOf(c.toLowerCase());return e<0?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,e),(0,d.jsx)("mark",{style:{background:"rgba(37,99,235,0.16)",color:"var(--text)",borderRadius:3,padding:"0 2px"},children:a.slice(e,e+c.length)}),a.slice(e+c.length)]})}(b.snippet,x)})]},b.entryId))]},a.session.id))]}),(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 12px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11},children:[(0,d.jsx)("span",{children:y>0?`${y}${u?"+":""} results`:"Esc to close"}),q&&o.length>0&&(0,d.jsx)("span",{children:"Updating..."})]})]})})}function k({open:a,initialPath:b,onClose:c,onSelect:f}){let[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(null),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),v=(0,e.useCallback)(async a=>{s(!0),u(null);try{let b=a?`/api/projects/browse?dir=${encodeURIComponent(a)}`:"/api/projects/browse",c=await fetch(b),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);h(d.current??""),j(d.parent??null),m(d.directories??[]),o(d.drives??[]),q(d.current??"")}catch(a){u(a instanceof Error?a.message:String(a))}finally{s(!1)}},[]);return a?(0,d.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.34)"},children:(0,d.jsxs)("div",{style:{width:"min(560px, 100%)",maxHeight:"min(720px, 88dvh)",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{height:48,padding:"0 14px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Select project path"}),(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11},children:"Server filesystem"})]}),(0,d.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:30,height:30,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"x"})]}),(0,d.jsx)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let b=p.trim();b&&f(b)},style:{display:"flex",gap:8},children:[(0,d.jsx)("input",{value:p,onChange:a=>q(a.target.value),placeholder:"/path/to/project",style:{flex:1,minWidth:0,height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:12,outline:"none"}}),(0,d.jsx)("button",{type:"button",onClick:()=>{let a=p.trim();a&&v(a)},disabled:!p.trim()||r,style:{height:32,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:p.trim()&&!r?"var(--text-muted)":"var(--text-dim)",cursor:p.trim()&&!r?"pointer":"default",fontSize:12},children:"Browse"}),(0,d.jsx)("button",{type:"submit",disabled:!p.trim(),style:{height:32,padding:"0 11px",border:"none",borderRadius:6,background:p.trim()?"var(--accent)":"var(--bg-hover)",color:p.trim()?"#fff":"var(--text-dim)",cursor:p.trim()?"pointer":"default",fontSize:12,fontWeight:650},children:"Use Path"})]})}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,d.jsx)("button",{type:"button",onClick:()=>i&&void v(i),disabled:!i,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:6,background:i?"var(--bg)":"transparent",color:i?"var(--text-muted)":"var(--text-dim)",cursor:i?"pointer":"default",padding:0},title:"Up",children:(0,d.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("polyline",{points:"2 6.5 5 3.5 8 6.5"})})}),n.length>0&&(0,d.jsxs)("select",{value:n.find(a=>g.toLowerCase().startsWith(a.toLowerCase()))??"",onChange:a=>{a.target.value&&v(a.target.value)},style:{height:28,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text-muted)",fontSize:12},children:[(0,d.jsx)("option",{value:"",children:"Drive"}),n.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:g,children:g})]}),(0,d.jsx)("div",{style:{flex:1,minHeight:220,maxHeight:360,overflowY:"auto",padding:6},children:r?(0,d.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"Loading..."}):t?(0,d.jsx)("div",{style:{padding:18,color:"#f87171",fontSize:12},children:t}):0===l.length?(0,d.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"No subdirectories"}):l.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>void v(a.path),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 9px",border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},title:a.path,children:[(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)",flexShrink:0},children:(0,d.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name}),(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:(0,d.jsx)("polyline",{points:"3.5 2 6.5 5 3.5 8"})})]},a.path))}),(0,d.jsxs)("div",{style:{padding:12,borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,d.jsx)("div",{style:{minWidth:0,color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g,children:g}),(0,d.jsxs)("div",{style:{display:"flex",gap:7,flexShrink:0},children:[(0,d.jsx)("button",{type:"button",onClick:c,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}),(0,d.jsx)("button",{type:"button",onClick:()=>g&&f(g),disabled:!g,style:{height:32,padding:"0 12px",border:"none",borderRadius:6,background:g?"var(--accent)":"var(--bg-hover)",color:g?"#fff":"var(--text-dim)",cursor:g?"pointer":"default",fontSize:12,fontWeight:650},children:"Select"})]})]})]})}):null}let l="AnnoVibe";function m(a){}async function n(a,b){let c=`${a}: HTTP ${b.status}`;try{let d=await b.json();return"string"==typeof d.error&&d.error?`${a}: ${d.error}`:c}catch{return c}}function o(a){return new DOMException(a,"TimeoutError")}function p(a,b){return a instanceof DOMException&&("AbortError"===a.name||"TimeoutError"===a.name)||a instanceof Error&&/aborted without reason|AbortError/i.test(a.message)?b:a instanceof Error?a.message:String(a)}function q(a){let b=new Date(a),c=new Date().getTime()-b.getTime(),d=Math.floor(c/6e4),e=Math.floor(c/36e5),f=Math.floor(c/864e5);return d<1?"just now":d<60?`${d}m ago`:e<24?`${e}h ago`:f<7?`${f}d ago`:b.toLocaleDateString()}function r(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"…/"+e.slice(-2).join(d)}function s(a,b){if(!a)return"No Project";let c=a.replace(/[\\/]+$/,""),d=c.includes("/")?"/":"\\";return c.split(d).filter(Boolean).pop()||r(a,b)}function t(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(!1),g=(0,e.useRef)(null),h=function(a){let[b,c]=(0,e.useState)(a);return(0,e.useRef)(null),(0,e.useRef)(0),b}(a?"v0.8.111":l),i=(0,e.useCallback)(a=>{b(a),f(!0),setTimeout(()=>f(!1),(a?6:8)*4*(1e3/60)+100)},[]),j=(0,e.useCallback)(()=>{g.current&&clearTimeout(g.current);let b=!a;i(b),b&&(g.current=setTimeout(()=>i(!1),3e3))},[a,i]);return(0,d.jsx)("button",{onClick:j,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:a?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"9ch"},children:h})}function u({selectedSessionId:a,onSelectSession:b,onNewSession:c,onNewWorkbench:f,initialSessionId:g,onInitialRestoreDone:h,refreshKey:i,onSessionDeleted:l,selectedCwd:q,onCwdChange:A}){let[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)({}),[F,G]=(0,e.useState)(()=>new Set),H=(0,e.useRef)(!1),[I,J]=(0,e.useState)(!0),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(null),[O,P]=(0,e.useState)(null),[Q,R]=(0,e.useState)(""),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(!1),[W,X]=(0,e.useState)("project"),[Y,Z]=(0,e.useState)(null),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)(!1),[ac,ad]=(0,e.useState)(()=>new Set),[ae,af]=(0,e.useState)(()=>new Set),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(null),[ak,al]=(0,e.useState)(null),[am,an]=(0,e.useState)(!1),ao=(0,e.useRef)(null),ap=(0,e.useRef)(!1),aq=(0,e.useRef)(!1);(0,e.useRef)(!1);let ar=(0,e.useRef)(new Map),as=(0,e.useCallback)(async(a=!1)=>{try{let b;a&&(N(null),J(!0));let c=new AbortController;try{b=setTimeout(()=>c.abort(o("Project loading timed out")),3e4);let a=await fetch("/api/projects?sessions=false",{signal:c.signal});if(!a.ok)throw Error(await n("projects",a));let d=await a.json();C(d.projects),N(null)}finally{clearTimeout(b)}}catch(a){N(p(a,"Loading projects timed out. Codex may still be starting; click Refresh to retry."))}finally{a&&J(!1)}},[]),at=(0,e.useCallback)(async(a,b=!1)=>{if(!a)return;let c=ar.current.get(a);if(c)return c;let d=(async()=>{E(b=>({...b,[a]:{sessions:b[a]?.sessions??[],loaded:b[a]?.loaded??!1,error:null,loading:!0,stale:b[a]?.stale??!1}}));try{let c;b&&J(!0);let d=new AbortController;try{c=setTimeout(()=>d.abort(o("Chat loading timed out")),3e4);let b=await fetch(`/api/sessions?cwd=${encodeURIComponent(a)}`,{signal:d.signal});if(!b.ok)throw Error(await n("sessions",b));let e=await b.json();e.runningSessionIds&&!H.current&&G(new Set(e.runningSessionIds)),E(b=>({...b,[a]:{sessions:e.sessions,loaded:!0,loading:!1,error:null,stale:!1}}))}finally{clearTimeout(c)}}catch(c){let b=p(c,"Loading chats timed out. Codex may still be starting; click Refresh to retry.");E(c=>({...c,[a]:{sessions:c[a]?.sessions??[],loaded:c[a]?.loaded??!1,loading:!1,error:b,stale:(c[a]?.sessions?.length??0)>0}}))}finally{b&&J(!1),ar.current.delete(a)}})();return ar.current.set(a,d),d},[]);(0,e.useRef)(!1),(0,e.useRef)(!1);let au=(0,e.useCallback)(async(a,b=!1)=>{try{let c=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,create:b})}),d=await c.json();if(!c.ok||d.error)return T(d.error??`HTTP ${c.status}`),!1;return as(!1),!0}catch(a){return T(a instanceof Error?a.message:String(a)),!1}},[as]),av=(0,e.useCallback)(a=>{fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,touch:!0})}).catch(()=>{})},[]),aw=(0,e.useCallback)(a=>{aq.current=!0,P(a),T(null),af(b=>{if(!b.has(a))return b;let c=new Set(b);return c.delete(a),m(c),c}),A?.(a),av(a),at(a,!1)},[at,A,av]),ax=q??O,ay=(0,e.useCallback)(a=>{if(!a){X("agent"),V(!0);return}let b="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;c?.(b,a)},[c]),az=(0,e.useCallback)(a=>{if(!a){X("workbench"),V(!0);return}f?.(a)},[f]),aA=(0,e.useCallback)(async a=>{await au(a,!0)&&(aw(a),V(!1),T(null),"agent"===W&&ay(a),"workbench"===W&&az(a))},[aw,ay,az,W,au]),aB=(0,e.useCallback)(a=>{Z(a),_(!0)},[]),aC=(0,e.useCallback)(()=>{_(!1),Z(null)},[]),aD=(0,e.useCallback)(a=>{let b=Y??ax;aC(),"agent"===a?ay(b):az(b)},[aC,ay,az,ax,Y]),aE=(0,e.useCallback)(()=>{aB(ax)},[ax,aB]),aF=(0,e.useCallback)(()=>{X("project"),T(null),V(!0)},[]),aG=(0,e.useMemo)(()=>[...ax&&!B.some(a=>a.cwd===ax)?[{cwd:ax,displayName:s(ax,Q),chatCount:D[ax]?.sessions.length??0,lastAccessed:null,created:null,pinned:!1,sortOrder:null,exists:!0,source:"manual"}]:[],...B].sort((a,b)=>{let c=!0===a.pinned;if(c!==(!0===b.pinned))return c?-1:1;let d="number"==typeof a.sortOrder?a.sortOrder:Number.MAX_SAFE_INTEGER,e="number"==typeof b.sortOrder?b.sortOrder:Number.MAX_SAFE_INTEGER;return d!==e?d-e:(a.displayName||"").localeCompare(b.displayName||"",void 0,{numeric:!0,sensitivity:"base"})}),[ax,Q,B,D]),aH=(0,e.useMemo)(()=>{let a=a=>{let b=D[a.cwd],c=[...b?.sessions??[]].sort((a,b)=>(b.modified||"").localeCompare(a.modified||""));return{project:a,cwd:a.cwd,displayName:a.displayName||s(a.cwd,Q),sessions:c,sessionsState:b,lastAccessed:(a.lastAccessed??a.created??"")||c[0]?.modified||""}},b=aG.filter(a=>!0===a.pinned).map(a);if(ax){let c=aG.find(a=>a.cwd===ax);c&&!0!==c.pinned&&b.push(a(c))}return b},[ax,Q,D,aG]),aI=(0,e.useCallback)((a,c=!1)=>{a.cwd!==ax&&(ap.current=!0,P(a.cwd)),af(b=>{if(!b.has(a.cwd))return b;let c=new Set(b);return c.delete(a.cwd),m(c),c}),av(a.cwd),b(a,c)},[b,ax,av]),aJ=(0,e.useCallback)(a=>{af(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),m(c),c})},[]),aK=(0,e.useCallback)(a=>{ad(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aL=(0,e.useCallback)(async a=>{al("reorder");try{let b=await fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:a})}),c=await b.json();if(!b.ok||c.error)throw Error(c.error??`HTTP ${b.status}`);C(c.projects??[]),N(null)}catch(a){N(a instanceof Error?a.message:String(a)),as(!1)}finally{al(null)}},[as]),aM=(0,e.useCallback)(async(a,b)=>{al(`pin:${a}`);try{let c=await fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,pinned:b})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);C(d.projects??[]),N(null)}catch(a){N(a instanceof Error?a.message:String(a)),as(!1)}finally{al(null)}},[as]),aN=(0,e.useCallback)((a,b)=>{if(!a||!b||a===b)return;let c=aG.map(a=>a.cwd).filter(Boolean),d=c.indexOf(a),e=c.indexOf(b);if(-1===d||-1===e)return;let f=[...c];f.splice(d,1);let g=f.indexOf(b);f.splice(g,0,a),aL(f)},[aL,aG]),aO=(0,e.useCallback)(async()=>{L(!0);try{await as(!1);let a=new Set([...Object.entries(D).filter(([,a])=>a.loaded||a.loading).map(([a])=>a),...ax?[ax]:[]]);await Promise.all([...a].map(a=>at(a,!1)))}finally{L(!1)}},[ax,as,at,D]);return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,d.jsx)(t,{}),(0,d.jsxs)("div",{style:{display:"flex",gap:6,minWidth:0},children:[(0,d.jsxs)("button",{onClick:aE,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:ax?`New chat in ${ax}`:"New chat in a project path",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,d.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"New Chat"]}),(0,d.jsx)("button",{onClick:()=>ab(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:"Search conversations",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,d.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]})})]})]})}),(0,d.jsx)(j,{open:aa,cwd:ax,homeDir:Q,onClose:()=>ab(!1),onSelectSession:a=>{aI(a)}}),(0,d.jsxs)("div",{ref:ao,style:{position:"relative",marginTop:8,padding:"0 10px",display:"flex",alignItems:"stretch",gap:4},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>an(a=>!a),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,padding:"6px 10px",background:ax?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:ax?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left"},title:ax??"Select project",children:[(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)"},children:(0,d.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,d.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:ax?"var(--text)":"var(--text-dim)"},children:ax?aG.find(a=>a.cwd===ax)?.displayName??r(ax,Q):"Select project…"}),(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:am?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),ax&&(0,d.jsx)(w,{pinned:aG.find(a=>a.cwd===ax)?.pinned===!0,onToggle:()=>void aM(ax,aG.find(a=>a.cwd===ax)?.pinned!==!0)}),am&&(0,d.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:10,right:10,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden",maxHeight:280,overflowY:"auto"},children:[0===aG.length&&(0,d.jsx)("div",{style:{padding:"10px 12px",color:"var(--text-dim)",fontSize:11},children:"No projects yet"}),aG.map(a=>{let b=a.cwd===ax;return(0,d.jsx)(x,{project:a,homeDir:Q,isCurrent:b,onSelect:()=>{aw(a.cwd),an(!1)},onTogglePinned:()=>void aM(a.cwd,!0!==a.pinned)},a.cwd)}),(0,d.jsxs)("button",{type:"button",onClick:()=>{an(!1),aF()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",borderTop:aG.length>0?"1px solid var(--border)":"none",color:"var(--accent)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,d.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"Add project…"]})]})]}),(0,d.jsxs)("div",{style:{flexShrink:0,padding:"10px 10px 6px"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:"Projects"}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[(0,d.jsx)("button",{type:"button",onClick:aO,disabled:K,title:"Refresh projects and chats","aria-label":"Refresh projects and chats",style:{width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:K?"var(--accent)":"var(--text-dim)",cursor:K?"default":"pointer",flexShrink:0},children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:K?"spin 0.9s linear infinite":void 0},children:[(0,d.jsx)("path",{d:"M21 12a9 9 0 0 1-15.5 6.2"}),(0,d.jsx)("path",{d:"M3 12A9 9 0 0 1 18.5 5.8"}),(0,d.jsx)("path",{d:"M7 18H5.5v1.5"}),(0,d.jsx)("path",{d:"M17 6h1.5V4.5"})]})}),(0,d.jsxs)("button",{type:"button",onClick:aF,title:"New project","aria-label":"New project",style:{height:26,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"0 8px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,transition:"background 0.12s, color 0.12s, border-color 0.12s",flexShrink:0},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M1.5 4.5A1.5 1.5 0 0 1 3 3h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6v4.5A1.5 1.5 0 0 1 13 12H3a1.5 1.5 0 0 1-1.5-1.5v-6Z"}),(0,d.jsx)("path",{d:"M11 7v3M9.5 8.5h3"})]}),"New Project"]})]})]}),S&&(0,d.jsx)("div",{style:{marginTop:6,color:"#f87171",fontSize:11,lineHeight:1.4,overflowWrap:"anywhere"},children:S})]}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",overflowY:"auto",padding:"6px 8px 8px",minHeight:80,scrollbarWidth:"thin",overscrollBehavior:"contain"},children:[I&&(0,d.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Loading..."}),M&&(0,d.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:M}),!I&&!M&&0===aH.length&&(0,d.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Open or create a project to start chatting."}),!I&&!M&&aH.map(b=>{let c,e=ae.has(b.cwd),f=b.cwd===ax,g=ac.has(b.cwd),h=function(a){let b=new Map;for(let c of a)b.set(c.id,{session:c,children:[]});let c=new Map;for(let b of a)b.parentSessionId&&c.set(b.id,b.parentSessionId);let d=[];for(let a of b.values()){let e=function(a){let d=c.get(a),e=new Set;for(;d&&!e.has(d);){if(e.add(d),b.has(d))return d;d=c.get(d)}return null}(a.session.id);e?b.get(e).children.push(a):d.push(a)}let e=a=>{a.sort((a,b)=>(b.session.modified||"").localeCompare(a.session.modified||"")),a.forEach(a=>e(a.children))};return e(d),d}(b.sessions),i=h.length,j=h;if(i>10&&!g){j=h.slice(0,10);let b=h.find(b=>(function a(b,c){return!!c&&(b.session.id===c||b.children.some(b=>a(b,c)))})(b,a));b&&!j.includes(b)&&(j=[...j,b])}let k=i-j.length;return(0,d.jsxs)("div",{style:{marginBottom:6,borderTop:ai===b.cwd?"2px solid var(--accent)":"2px solid transparent",paddingTop:2*(ai===b.cwd),opacity:ag===b.cwd?.55:1},onDragOver:a=>{ag&&ag!==b.cwd&&(a.preventDefault(),a.dataTransfer.dropEffect="move",aj(b.cwd))},onDragLeave:()=>{ai===b.cwd&&aj(null)},onDrop:a=>{a.preventDefault();let c=a.dataTransfer.getData("text/project-cwd")||ag;aj(null),ah(null),c&&aN(c,b.cwd)},children:[(0,d.jsx)(y,{group:b,isCurrent:f,isCollapsed:e,isDragging:ag===b.cwd,pinBusy:ak===`pin:${b.cwd}`,onToggle:()=>aJ(b.cwd),onSelect:()=>aw(b.cwd),onTogglePinned:()=>void aM(b.cwd,!0!==b.project.pinned),onDragStart:a=>{ah(b.cwd),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/project-cwd",b.cwd)},onDragEnd:()=>{ah(null),aj(null)}}),!e&&(0,d.jsxs)("div",{style:{marginTop:2,overflow:"hidden",borderRadius:7},children:[(c=b.sessionsState,c?.loading&&!c?.loaded?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"var(--text-dim)",textAlign:"left",fontSize:12,fontStyle:"italic"},children:"Loading chats…"}):c?.error&&!c?.stale?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"#f87171",textAlign:"left",fontSize:12},children:c.error}):0===b.sessions.length?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"var(--text-muted)",textAlign:"left",fontSize:12},children:"No sessions yet. Use New Chat above to start one."}):(0,d.jsxs)(d.Fragment,{children:[c?.stale&&(0,d.jsx)("div",{style:{width:"100%",padding:"4px 12px",color:"var(--text-dim)",textAlign:"left",fontSize:10,fontStyle:"italic"},children:"Showing cached data — refresh failed"}),j.map(c=>(0,d.jsx)(z,{node:c,selectedSessionId:a,onSelectSession:aI,onRenamed:()=>void at(b.cwd,!1),onSessionDeleted:a=>{l?.(a),at(b.cwd,!1)},depth:0,runningSessionIds:F},c.session.id))]})),(g||k>0)&&i>10&&(0,d.jsx)("button",{type:"button",onClick:()=>aK(b.cwd),style:{width:"100%",padding:"6px 10px",background:"transparent",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11,textAlign:"center"},children:g?"Show less":`Show ${Math.max(0,k)} more`})]})]},b.cwd||"__no_project")})]}),$&&(0,d.jsx)(v,{cwd:Y,onChoose:aD,onClose:aC}),(0,d.jsx)(k,{open:U,initialPath:ax,onClose:()=>V(!1),onSelect:a=>aA(a)})]})}function v({cwd:a,onChoose:b,onClose:c}){let e=a?s(a):"Choose a project path next";return(0,d.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.28)"},children:(0,d.jsxs)("div",{style:{width:"min(420px, 100%)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 12px 40px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid var(--border)",display:"flex",justifyContent:"space-between",gap:12},children:[(0,d.jsxs)("div",{style:{minWidth:0},children:[(0,d.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Start a new session"}),(0,d.jsx)("div",{style:{marginTop:5,color:"var(--text-dim)",fontSize:11},children:"Current project"}),(0,d.jsx)("div",{title:a??void 0,style:{marginTop:2,color:"var(--text)",fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),a&&(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a})]}),(0,d.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:28,height:28,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},children:"x"})]}),(0,d.jsxs)("div",{style:{padding:14,display:"grid",gap:10},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b("agent"),style:{display:"grid",gap:5,textAlign:"left",padding:"13px 14px",border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer"},children:[(0,d.jsx)("span",{style:{fontSize:13,fontWeight:750},children:"Agent Chat"}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.45},children:"General coding or analysis chat in this project."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b("workbench"),style:{display:"grid",gap:5,textAlign:"left",padding:"13px 14px",border:"1px solid rgba(37,99,235,0.45)",borderRadius:10,background:"rgba(37,99,235,0.08)",color:"var(--text)",cursor:"pointer"},children:[(0,d.jsx)("span",{style:{fontSize:13,fontWeight:750,color:"var(--accent)"},children:"Workbench"}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.45},children:"Dedicated R/Python warm-runtime session for data loading, plots, and artifacts."})]})]})]})})}function w({pinned:a,onToggle:b}){return(0,d.jsx)("button",{type:"button",onClick:b,title:a?"Unpin project":"Pin project to sidebar",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:"auto",padding:0,border:"1px solid var(--border)",borderRadius:7,background:a?"rgba(234,179,8,0.12)":"var(--bg-hover)",color:a?"#ca8a04":"var(--text-muted)",cursor:"pointer",flexShrink:0},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:a?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})})}function x({project:a,homeDir:b,isCurrent:c,onSelect:f,onTogglePinned:g}){let[h,i]=(0,e.useState)(!1),j=a.displayName||s(a.cwd,b);return(0,d.jsxs)("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{display:"flex",alignItems:"center",gap:4,background:c?"var(--bg-selected)":h?"var(--bg-hover)":"none",borderBottom:"1px solid var(--border)"},children:[(0,d.jsx)("span",{style:{width:10,marginLeft:6,flexShrink:0}}),(0,d.jsxs)("button",{type:"button",onClick:f,title:a.cwd,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:7,padding:"8px 10px 8px 0",background:"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)"},children:[c?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j}),!a.exists&&(0,d.jsx)("span",{style:{flexShrink:0,color:"#f87171",fontSize:10},children:"missing"})]}),(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),g()},title:"Pin to sidebar",tabIndex:h?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,marginRight:4,padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,opacity:+!!h,pointerEvents:h?"auto":"none"},children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})})]})}function y({group:a,isCurrent:b,isCollapsed:c,isDragging:f,pinBusy:g,onToggle:h,onSelect:i,onTogglePinned:j,onDragStart:k,onDragEnd:l}){let[m,n]=(0,e.useState)(!1),o=a.lastAccessed,p=Math.max(0,a.project.chatCount??a.sessions.length??0),r=!0===a.project.pinned,s=(0,e.useCallback)(()=>{b?h():i()},[b,i,h]);return(0,d.jsxs)("div",{role:"button",tabIndex:0,draggable:!0,onClick:s,onDragStart:k,onDragEnd:l,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),s())},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),title:a.cwd,style:{width:"100%",height:32,display:"flex",alignItems:"center",gap:5,padding:"0 8px",background:b?"var(--bg-selected)":m?"var(--bg-hover)":"transparent",border:"none",borderRadius:6,color:"var(--text)",cursor:f?"grabbing":"pointer",textAlign:"left",overflow:"hidden",transition:"background 0.12s, opacity 0.12s",opacity:f?.55:1},children:[(0,d.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:c?"none":"rotate(90deg)",transition:"transform 0.15s",flexShrink:0,color:"var(--text-dim)"},children:(0,d.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:b?"var(--accent)":"var(--text-dim)"},children:c?(0,d.jsx)("path",{d:"M1.5 4.5A1.5 1.5 0 0 1 3 3h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6v5A1.5 1.5 0 0 1 13 12.5H3A1.5 1.5 0 0 1 1.5 11V4.5Z"}):(0,d.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:b?650:560,color:"var(--text)"},children:a.displayName}),!a.project.exists&&(0,d.jsx)("span",{style:{flexShrink:0,color:"#f87171",fontSize:10},children:"missing"}),!m&&p>0&&(0,d.jsxs)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:[p," ",1===p?"chat":"chats"]}),!m&&o&&(0,d.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:q(o)}),r?(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),j()},title:"Unpin project",tabIndex:m?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,border:"none",borderRadius:5,background:"rgba(234,179,8,0.12)",color:"#ca8a04",cursor:"pointer",flexShrink:0,opacity:m?1:.85,transition:"opacity 0.12s"},children:(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})}):(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),j()},disabled:g,title:"Pin project to sidebar",tabIndex:m?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:g?"wait":"pointer",flexShrink:0,opacity:+!!m,transition:"opacity 0.12s, background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="#ca8a04"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})}),(0,d.jsx)("span",{title:"Drag to reorder",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:22,flexShrink:0,color:"var(--text-dim)",opacity:m?1:.35,transition:"opacity 0.12s",cursor:"grab"},children:(0,d.jsxs)("svg",{width:"10",height:"12",viewBox:"0 0 10 12",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"2",cy:"2",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"2",r:"1"}),(0,d.jsx)("circle",{cx:"2",cy:"6",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"6",r:"1"}),(0,d.jsx)("circle",{cx:"2",cy:"10",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"10",r:"1"})]})})]})}function z({node:a,selectedSessionId:b,onSelectSession:c,onRenamed:f,onSessionDeleted:g,depth:h,runningSessionIds:i}){let[j,k]=(0,e.useState)(!1),l=a.children.length>0;return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{style:{position:"relative"},children:[h>0&&(0,d.jsx)("div",{style:{position:"absolute",left:12*h+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,d.jsx)(A,{session:a.session,isSelected:a.session.id===b,onClick:()=>c(a.session),onRenamed:f,onDeleted:a=>g?.(a),depth:h,hasChildren:l,collapsed:j,onToggleCollapse:()=>k(a=>!a),isRunning:i.has(a.session.id)})]}),l&&!j&&(0,d.jsx)("div",{children:a.children.map(a=>(0,d.jsx)(z,{node:a,selectedSessionId:b,onSelectSession:c,onRenamed:f,onSessionDeleted:g,depth:h+1,runningSessionIds:i},a.session.id))})]})}function A({session:a,isSelected:b,onClick:c,onRenamed:f,onDeleted:g,depth:h=0,hasChildren:i=!1,collapsed:j=!1,onToggleCollapse:k,isRunning:l=!1}){let[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(!1),x=(0,e.useRef)(null),y=a.name||a.firstMessage.slice(0,50)||a.id.slice(0,12),z=(0,e.useCallback)(b=>{b.stopPropagation(),s(a.name??""),p(!0),setTimeout(()=>x.current?.select(),0)},[a.name]),B=(0,e.useCallback)(async()=>{let b=r.trim();if(p(!1),b!==(a.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})}),f?.()}catch{}},[r,a.id,a.name,f]),C=(0,e.useCallback)(a=>{a.stopPropagation(),u(!0)},[]),D=(0,e.useCallback)(async b=>{b.stopPropagation(),u(!1),w(!0);try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"DELETE"}),g?.(a.id)}catch{w(!1)}},[a.id,g]),E=(0,e.useCallback)(a=>{a.stopPropagation(),u(!1)},[]),F="workbench"===a.sessionKind;return(0,d.jsx)("div",{onClick:t||o?void 0:c,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1)},style:{display:"flex",alignItems:"center",padding:"7px 8px",paddingLeft:h>0?12*h+14:14,paddingRight:8,cursor:t||o?"default":"pointer",background:t?"rgba(239,68,68,0.06)":b?"var(--bg-selected)":m?"var(--bg-hover)":"transparent",borderLeft:t?"2px solid #ef4444":b?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:v?.5:1,gap:6,overflow:"hidden"},children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,d.jsxs)("span",{style:{fontWeight:600},children:["“",y.slice(0,22),y.length>22?"…":"","”"]}),"?"]}),(0,d.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,d.jsxs)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,d.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,d.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,d.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,d.jsx)("button",{onClick:E,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):o?(0,d.jsx)("input",{ref:x,value:r,onChange:a=>s(a.target.value),onBlur:B,onKeyDown:a=>{"Enter"===a.key&&B(),"Escape"===a.key&&p(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:28}}):(0,d.jsxs)(d.Fragment,{children:[h>0&&(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,d.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),0===h&&(0,d.jsx)("span",{"aria-hidden":"true",style:{width:l?7:5,height:l?7:5,borderRadius:"50%",background:l?"#22c55e":b?"var(--accent)":"var(--text-dim)",opacity:b?1:.35,flexShrink:0,...l?{boxShadow:"0 0 6px rgba(34,197,94,0.5)",animation:"pulse 2s infinite"}:{}}}),F&&(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M4 19V5"}),(0,d.jsx)("path",{d:"M4 19h16"}),(0,d.jsx)("path",{d:"m7 16 3-5 4 3 4-7"})]}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[(0,d.jsx)("div",{style:{fontSize:13,fontWeight:b?600:500,lineHeight:"18px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:F?"var(--accent)":"var(--text)"},title:y,children:y}),(0,d.jsxs)("div",{style:{display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,d.jsx)("span",{title:a.modified,children:q(a.modified)}),(0,d.jsxs)("span",{children:[a.messageCount," msgs"]}),!1===a.cwdExists&&(0,d.jsx)("span",{title:`Project path missing: ${a.cwd}`,style:{color:"#f87171"},children:"missing path"})]})]}),i&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k?.()},title:j?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:j?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),m&&(0,d.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,d.jsx)("button",{onClick:z,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,d.jsx)("button",{onClick:C,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)",a.currentTarget.style.color="#ef4444",a.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,d.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,d.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,d.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}var B=c(62418);let C="subagent",D=["retain","recall","reflect"],E=[],F=["read","bash","edit","write"],G=["bash","read","edit","write","grep","find","ls"],H=[...G,"kernel_plot_run","kernel_plot_render","kernel_plot_inspect","kernel_plot_stop","kernel_plot_artifacts"],I=[...G,C];function J(a){return[...a].sort().join(",")}function K(a){switch(a){case"none":return E;case"default":return F;case"workbench":return H;case"agent":return I;default:return G}}function L(a,b){return[...new Set([...K(a),...b])]}let M=new Map,N=["off","default","full","agent"],O={off:"none",default:"default",full:"full",agent:"agent"},P={off:"无工具,纯聊天",default:"4 项内置工具",full:"全部内置工具",agent:"High + 子代理"},Q={retain:{label:"retain",description:"保存稳定事实或决策到项目记忆"},recall:{label:"recall",description:"检索项目记忆中的相关上下文"},reflect:{label:"reflect",description:"基于已存记忆做综合回应"}},R=["auto","off","minimal","low","medium","high","xhigh"],S={auto:"沿用 pi 默认设置",off:"关闭推理",minimal:"最少推理",low:"低强度推理",medium:"中等推理",high:"高强度推理",xhigh:"最高强度推理"},T=[{command:"/compact",label:"/compact",description:"压缩当前上下文",kind:"native"},{command:"/init",label:"/init",description:"快捷插入,交给模型处理初始化任务",kind:"shortcut"},{command:"/memory",label:"/memory",description:"快捷插入,交给模型处理项目记忆任务",kind:"shortcut"}];function U({doc:a,onRemove:b}){var c;let e=a.fileName.split(".").pop()?.toLowerCase()??"",f=function(a){switch(a){case"pdf":return{emoji:"\uD83D\uDCC4",color:"#ef4444"};case"docx":case"doc":return{emoji:"\uD83D\uDCDD",color:"#3b82f6"};case"xlsx":case"xls":return{emoji:"\uD83D\uDCCA",color:"#22c55e"};case"pptx":case"ppt":return{emoji:"\uD83D\uDCFD",color:"#f97316"};default:return{emoji:"\uD83D\uDCCE",color:"var(--text-muted)"}}}(e),g=(c=a.size)<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`;return(0,d.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:6,padding:"5px 10px 5px 7px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,maxWidth:200},title:a.fileName,children:[(0,d.jsx)("span",{style:{color:f.color,fontSize:14,flexShrink:0},children:f.emoji}),(0,d.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3},children:a.fileName}),(0,d.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.3},children:[e.toUpperCase()," \xb7 ",g,a.extractionError?" \xb7 no text":a.truncated?" \xb7 truncated":a.extractedText?" \xb7 text":""]})]}),(0,d.jsx)("button",{onClick:b,style:{flexShrink:0,width:14,height:14,borderRadius:"50%",background:"var(--bg-hover)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-dim)"},onMouseEnter:a=>{a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--text-dim)"},children:(0,d.jsxs)("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"1",y1:"1",x2:"6",y2:"6"}),(0,d.jsx)("line",{x1:"6",y1:"1",x2:"1",y2:"6"})]})})]})}function V(a){return a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&apos;/g,"'")}async function W(a){let b=await c.e(1688).then(c.bind(c,81688));b.GlobalWorkerOptions.workerSrc=new c.U(c(19224)).toString();let d=await b.getDocument({data:a.slice(0)}).promise,e=[];for(let a=1;a<=d.numPages;a+=1){let b=await d.getPage(a),c=(await b.getTextContent()).items.map(a=>"str"in a?a.str:"").filter(Boolean).join(" ");c.trim()&&e.push(`Page ${a}
1
+ (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},478:(a,b,c)=>{Promise.resolve().then(c.bind(c,85644))},1708:a=>{"use strict";a.exports=require("node:process")},2798:(a,b,c)=>{let d=c(76708),e=c(95380),f=c(18994),g=c(32835);function h(a,b,c,f,g){let h=[].slice.call(arguments,1),i=h.length,j="function"==typeof h[i-1];if(!j&&!d())throw Error("Callback required as last argument");if(j){if(i<2)throw Error("Too few arguments provided");2===i?(g=c,c=b,b=f=void 0):3===i&&(b.getContext&&void 0===g?(g=f,f=void 0):(g=f,f=c,c=b,b=void 0))}else{if(i<1)throw Error("Too few arguments provided");return 1===i?(c=b,b=f=void 0):2!==i||b.getContext||(f=c,c=b,b=void 0),new Promise(function(d,g){try{let g=e.create(c,f);d(a(g,b,f))}catch(a){g(a)}})}try{let d=e.create(c,f);g(null,a(d,b,f))}catch(a){g(a)}}e.create,b.toCanvas=h.bind(null,f.render),h.bind(null,f.renderToDataURL),h.bind(null,function(a,b,c){return g.render(a,c)})},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},5206:(a,b,c)=>{Promise.resolve().then(c.bind(c,35790))},9709:(a,b,c)=>{"use strict";let d=!0,e=c(74075),f=c(80183);e.deflateSync||(d=!1);let g=c(81769),h=c(42516),i=c(96277),j=c(92858),k=c(83670);a.exports=function(a,b){let c,l,m,n;if(!d)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let o=[],p=new g(a);if(new i(b,{read:p.read.bind(p),error:function(a){c=a},metadata:function(a){l=a},gamma:function(a){m=a},palette:function(a){l.palette=a},transColor:function(a){l.transColor=a},inflateData:function(a){o.push(a)},simpleTransparency:function(){l.alpha=!0}}).start(),p.process(),c)throw c;let q=Buffer.concat(o);if(o.length=0,l.interlace)n=e.inflateSync(q);else{let a=((l.width*l.bpp*l.depth+7>>3)+1)*l.height;n=f(q,{chunkSize:a,maxLength:a})}if(q=null,!n||!n.length)throw Error("bad png - invalid inflate data response");let r=h.process(n,l);q=null;let s=j.dataToBitMap(r,l);r=null;let t=k(s,l);return l.data=t,l.gamma=m||0,l}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12097:(a,b)=>{b.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};b.isValid=function(a){return null!=a&&""!==a&&!isNaN(a)&&a>=0&&a<=7},b.from=function(a){return b.isValid(a)?parseInt(a,10):void 0},b.getPenaltyN1=function(a){let b=a.size,c=0,d=0,e=0,f=null,g=null;for(let h=0;h<b;h++){d=e=0,f=g=null;for(let i=0;i<b;i++){let b=a.get(h,i);b===f?d++:(d>=5&&(c+=3+(d-5)),f=b,d=1),(b=a.get(i,h))===g?e++:(e>=5&&(c+=3+(e-5)),g=b,e=1)}d>=5&&(c+=3+(d-5)),e>=5&&(c+=3+(e-5))}return c},b.getPenaltyN2=function(a){let b=a.size,c=0;for(let d=0;d<b-1;d++)for(let e=0;e<b-1;e++){let b=a.get(d,e)+a.get(d,e+1)+a.get(d+1,e)+a.get(d+1,e+1);(4===b||0===b)&&c++}return 3*c},b.getPenaltyN3=function(a){let b=a.size,c=0,d=0,e=0;for(let f=0;f<b;f++){d=e=0;for(let g=0;g<b;g++)d=d<<1&2047|a.get(f,g),g>=10&&(1488===d||93===d)&&c++,e=e<<1&2047|a.get(g,f),g>=10&&(1488===e||93===e)&&c++}return 40*c},b.getPenaltyN4=function(a){let b=0,c=a.data.length;for(let d=0;d<c;d++)b+=a.data[d];return 10*Math.abs(Math.ceil(100*b/c/5)-10)},b.applyMask=function(a,c){let d=c.size;for(let e=0;e<d;e++)for(let f=0;f<d;f++)c.isReserved(f,e)||c.xor(f,e,function(a,c,d){switch(a){case b.Patterns.PATTERN000:return(c+d)%2==0;case b.Patterns.PATTERN001:return c%2==0;case b.Patterns.PATTERN010:return d%3==0;case b.Patterns.PATTERN011:return(c+d)%3==0;case b.Patterns.PATTERN100:return(Math.floor(c/2)+Math.floor(d/3))%2==0;case b.Patterns.PATTERN101:return c*d%2+c*d%3==0;case b.Patterns.PATTERN110:return(c*d%2+c*d%3)%2==0;case b.Patterns.PATTERN111:return(c*d%3+(c+d)%2)%2==0;default:throw Error("bad maskPattern:"+a)}}(a,f,e))},b.getBestMask=function(a,c){let d=Object.keys(b.Patterns).length,e=0,f=1/0;for(let g=0;g<d;g++){c(g),b.applyMask(g,a);let d=b.getPenaltyN1(a)+b.getPenaltyN2(a)+b.getPenaltyN3(a)+b.getPenaltyN4(a);b.applyMask(g,a),d<f&&(f=d,e=g)}return e}},12412:a=>{"use strict";a.exports=require("assert")},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},18994:(a,b,c)=>{let d=c(88397);b.render=function(a,b,c){var e;let f=c,g=b;void 0!==f||b&&b.getContext||(f=b,b=void 0),b||(g=function(){try{return document.createElement("canvas")}catch(a){throw Error("You need to specify a canvas element")}}()),f=d.getOptions(f);let h=d.getImageWidth(a.modules.size,f),i=g.getContext("2d"),j=i.createImageData(h,h);return d.qrToImageData(j.data,a,f),e=g,i.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=h,e.width=h,e.style.height=h+"px",e.style.width=h+"px",i.putImageData(j,0,0),g},b.renderToDataURL=function(a,c,d){let e=d;void 0!==e||c&&c.getContext||(e=c,c=void 0),e||(e={});let f=b.render(a,c,e),g=e.type||"image/png",h=e.rendererOpts||{};return f.toDataURL(g,h.quality)}},19099:(a,b,c)=>{"use strict";var d=c(54839);c.o(d,"useRouter")&&c.d(b,{useRouter:function(){return d.useRouter}}),c.o(d,"useSearchParams")&&c.d(b,{useSearchParams:function(){return d.useSearchParams}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19477:(a,b,c)=>{let d=c(58856),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],f=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];b.getBlocksCount=function(a,b){switch(b){case d.L:return e[(a-1)*4+0];case d.M:return e[(a-1)*4+1];case d.Q:return e[(a-1)*4+2];case d.H:return e[(a-1)*4+3];default:return}},b.getTotalCodewordsCount=function(a,b){switch(b){case d.L:return f[(a-1)*4+0];case d.M:return f[(a-1)*4+1];case d.Q:return f[(a-1)*4+2];case d.H:return f[(a-1)*4+3];default:return}}},23372:(a,b,c)=>{"use strict";let d=c(28354),e=c(74075),f=c(57949),g=c(27459),h=c(96277),i=c(92858),j=c(83670),k=a.exports=function(a){f.call(this),this._parser=new h(a,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=a,this.writable=!0,this._parser.start()};d.inherits(k,f),k.prototype._handleError=function(a){this.emit("error",a),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},k.prototype._inflateData=function(a){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=e.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let a=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,b=Math.max(a,e.Z_MIN_CHUNK);this._inflate=e.createInflate({chunkSize:b});let c=a,d=this.emit.bind(this,"error");this._inflate.on("error",function(a){c&&d(a)}),this._filter.on("complete",this._complete.bind(this));let f=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){c&&(a.length>c&&(a=a.slice(0,c)),c-=a.length,f(a))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(a)},k.prototype._handleMetaData=function(a){this._metaData=a,this._bitmapInfo=Object.create(a),this._filter=new g(this._bitmapInfo)},k.prototype._handleTransColor=function(a){this._bitmapInfo.transColor=a},k.prototype._handlePalette=function(a){this._bitmapInfo.palette=a},k.prototype._simpleTransparency=function(){this._metaData.alpha=!0},k.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},k.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},k.prototype._complete=function(a){let b;if(!this.errord){try{let c=i.dataToBitMap(a,this._bitmapInfo);b=j(c,this._bitmapInfo),c=null}catch(a){this._handleError(a);return}this.emit("parsed",b)}}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},27137:(a,b,c)=>{let d=c(93669),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function f(a){this.mode=d.ALPHANUMERIC,this.data=a}f.getBitsLength=function(a){return 11*Math.floor(a/2)+a%2*6},f.prototype.getLength=function(){return this.data.length},f.prototype.getBitsLength=function(){return f.getBitsLength(this.data.length)},f.prototype.write=function(a){let b;for(b=0;b+2<=this.data.length;b+=2){let c=45*e.indexOf(this.data[b]);c+=e.indexOf(this.data[b+1]),a.put(c,11)}this.data.length%2&&a.put(e.indexOf(this.data[b]),6)},a.exports=f},27459:(a,b,c)=>{"use strict";let d=c(28354),e=c(57949),f=c(27734),g=a.exports=function(a){e.call(this);let b=[],c=this;this._filter=new f(a,{read:this.read.bind(this),write:function(a){b.push(a)},complete:function(){c.emit("complete",Buffer.concat(b))}}),this._filter.start()};d.inherits(g,e)},27734:(a,b,c)=>{"use strict";let d=c(59725),e=c(55211);function f(a,b,c){let d=a*b;return 8!==c&&(d=Math.ceil(d/(8/c))),d}let g=a.exports=function(a,b){let c=a.width,e=a.height,g=a.interlace,h=a.bpp,i=a.depth;if(this.read=b.read,this.write=b.write,this.complete=b.complete,this._imageIndex=0,this._images=[],g){let a=d.getImagePasses(c,e);for(let b=0;b<a.length;b++)this._images.push({byteWidth:f(a[b].width,h,i),height:a[b].height,lineIndex:0})}else this._images.push({byteWidth:f(c,h,i),height:e,lineIndex:0});8===i?this._xComparison=h:16===i?this._xComparison=2*h:this._xComparison=1};g.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},g.prototype._unFilterType1=function(a,b,c){let d=this._xComparison,e=d-1;for(let f=0;f<c;f++){let c=a[1+f],g=f>e?b[f-d]:0;b[f]=c+g}},g.prototype._unFilterType2=function(a,b,c){let d=this._lastLine;for(let e=0;e<c;e++){let c=a[1+e],f=d?d[e]:0;b[e]=c+f}},g.prototype._unFilterType3=function(a,b,c){let d=this._xComparison,e=d-1,f=this._lastLine;for(let g=0;g<c;g++){let c=a[1+g],h=f?f[g]:0,i=Math.floor(((g>e?b[g-d]:0)+h)/2);b[g]=c+i}},g.prototype._unFilterType4=function(a,b,c){let d=this._xComparison,f=d-1,g=this._lastLine;for(let h=0;h<c;h++){let c=a[1+h],i=g?g[h]:0,j=e(h>f?b[h-d]:0,i,h>f&&g?g[h-d]:0);b[h]=c+j}},g.prototype._reverseFilterLine=function(a){let b,c=a[0],d=this._images[this._imageIndex],e=d.byteWidth;if(0===c)b=a.slice(1,e+1);else switch(b=Buffer.alloc(e),c){case 1:this._unFilterType1(a,b,e);break;case 2:this._unFilterType2(a,b,e);break;case 3:this._unFilterType3(a,b,e);break;case 4:this._unFilterType4(a,b,e);break;default:throw Error("Unrecognised filter type - "+c)}this.write(b),d.lineIndex++,d.lineIndex>=d.height?(this._lastLine=null,this._imageIndex++,d=this._images[this._imageIndex]):this._lastLine=b,d?this.read(d.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28964:(a,b,c)=>{let d=c(93669);function e(a){this.mode=d.NUMERIC,this.data=a.toString()}e.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(a){let b,c;for(b=0;b+3<=this.data.length;b+=3)c=parseInt(this.data.substr(b,3),10),a.put(c,10);let d=this.data.length-b;d>0&&(c=parseInt(this.data.substr(b),10),a.put(c,3*d+1))},a.exports=e},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31964:(a,b,c)=>{"use strict";let d=c(55211),e={0:function(a,b,c,d,e){for(let f=0;f<c;f++)d[e+f]=a[b+f]},1:function(a,b,c,d,e,f){for(let g=0;g<c;g++){let c=g>=f?a[b+g-f]:0,h=a[b+g]-c;d[e+g]=h}},2:function(a,b,c,d,e){for(let f=0;f<c;f++){let g=b>0?a[b+f-c]:0,h=a[b+f]-g;d[e+f]=h}},3:function(a,b,c,d,e,f){for(let g=0;g<c;g++){let h=g>=f?a[b+g-f]:0,i=b>0?a[b+g-c]:0,j=a[b+g]-(h+i>>1);d[e+g]=j}},4:function(a,b,c,e,f,g){for(let h=0;h<c;h++){let i=h>=g?a[b+h-g]:0,j=b>0?a[b+h-c]:0,k=b>0&&h>=g?a[b+h-(c+g)]:0,l=a[b+h]-d(i,j,k);e[f+h]=l}}},f={0:function(a,b,c){let d=0,e=b+c;for(let c=b;c<e;c++)d+=Math.abs(a[c]);return d},1:function(a,b,c,d){let e=0;for(let f=0;f<c;f++){let c=f>=d?a[b+f-d]:0;e+=Math.abs(a[b+f]-c)}return e},2:function(a,b,c){let d=0,e=b+c;for(let f=b;f<e;f++){let e=b>0?a[f-c]:0;d+=Math.abs(a[f]-e)}return d},3:function(a,b,c,d){let e=0;for(let f=0;f<c;f++){let g=f>=d?a[b+f-d]:0,h=b>0?a[b+f-c]:0;e+=Math.abs(a[b+f]-(g+h>>1))}return e},4:function(a,b,c,e){let f=0;for(let g=0;g<c;g++){let h=g>=e?a[b+g-e]:0,i=b>0?a[b+g-c]:0,j=b>0&&g>=e?a[b+g-(c+e)]:0;f+=Math.abs(a[b+g]-d(h,i,j))}return f}};a.exports=function(a,b,c,d,g){let h;if("filterType"in d&&-1!==d.filterType)if("number"==typeof d.filterType)h=[d.filterType];else throw Error("unrecognised filter types");else h=[0,1,2,3,4];16===d.bitDepth&&(g*=2);let i=b*g,j=0,k=0,l=Buffer.alloc((i+1)*c),m=h[0];for(let b=0;b<c;b++){if(h.length>1){let b=1/0;for(let c=0;c<h.length;c++){let d=f[h[c]](a,k,i,g);d<b&&(m=h[c],b=d)}}l[j]=m,j++,e[m](a,k,i,l,j,g),j+=i,k+=i}return l}},32835:(a,b,c)=>{let d=c(88397);function e(a,b){let c=a.a/255,d=b+'="'+a.hex+'"';return c<1?d+" "+b+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function f(a,b,c){let d=a+b;return void 0!==c&&(d+=" "+c),d}b.render=function(a,b,c){let g=d.getOptions(b),h=a.modules.size,i=a.modules.data,j=h+2*g.margin,k=g.color.light.a?"<path "+e(g.color.light,"fill")+' d="M0 0h'+j+"v"+j+'H0z"/>':"",l="<path "+e(g.color.dark,"stroke")+' d="'+function(a,b,c){let d="",e=0,g=!1,h=0;for(let i=0;i<a.length;i++){let j=Math.floor(i%b),k=Math.floor(i/b);j||g||(g=!0),a[i]?(h++,i>0&&j>0&&a[i-1]||(d+=g?f("M",j+c,.5+k+c):f("m",e,0),e=0,g=!1),j+1<b&&a[i+1]||(d+=f("h",h),h=0)):e++}return d}(i,h,g.margin)+'"/>',m='<svg xmlns="http://www.w3.org/2000/svg" '+(g.width?'width="'+g.width+'" height="'+g.width+'" ':"")+('viewBox="0 0 '+j+" ")+j+'" shape-rendering="crispEdges">'+k+l+"</svg>\n";return"function"==typeof c&&c(null,m),m}},33873:a=>{"use strict";a.exports=require("path")},34447:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=c(23372),g=c(49149),h=c(58879),i=b.O=function(a){e.call(this),a=a||{},this.width=0|a.width,this.height=0|a.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,a.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new f(a),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(a){this.data=a,this.emit("parsed",a)}).bind(this)),this._packer=new g(a),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};d.inherits(i,e),i.sync=h,i.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},i.prototype.parse=function(a,b){if(b){let a,c;a=(function(a){this.removeListener("error",c),this.data=a,b(null,this)}).bind(this),c=(function(c){this.removeListener("parsed",a),b(c,null)}).bind(this),this.once("parsed",a),this.once("error",c)}return this.end(a),this},i.prototype.write=function(a){return this._parser.write(a),!0},i.prototype.end=function(a){this._parser.end(a)},i.prototype._metadata=function(a){this.width=a.width,this.height=a.height,this.emit("metadata",a)},i.prototype._gamma=function(a){this.gamma=a},i.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},i.bitblt=function(a,b,c,d,e,f,g,h){if(d|=0,e|=0,f|=0,g|=0,h|=0,(c|=0)>a.width||d>a.height||c+e>a.width||d+f>a.height)throw Error("bitblt reading outside image");if(g>b.width||h>b.height||g+e>b.width||h+f>b.height)throw Error("bitblt writing outside image");for(let i=0;i<f;i++)a.data.copy(b.data,(h+i)*b.width+g<<2,(d+i)*a.width+c<<2,(d+i)*a.width+c+e<<2)},i.prototype.bitblt=function(a,b,c,d,e,f,g){return i.bitblt(this,a,b,c,d,e,f,g),this},i.adjustGamma=function(a){if(a.gamma){for(let b=0;b<a.height;b++)for(let c=0;c<a.width;c++){let d=a.width*b+c<<2;for(let b=0;b<3;b++){let c=a.data[d+b]/255;c=Math.pow(c,1/2.2/a.gamma),a.data[d+b]=Math.round(255*c)}}a.gamma=0}},i.prototype.adjustGamma=function(){i.adjustGamma(this)}},35790:(a,b,c)=>{"use strict";c.d(b,{AppShell:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call AppShell() from the server but AppShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/annovibe/annovibe/components/AppShell.tsx","AppShell")},38937:(a,b,c)=>{let d=c(93669);function e(a){this.mode=d.BYTE,"string"==typeof a?this.data=new TextEncoder().encode(a):this.data=new Uint8Array(a)}e.getBitsLength=function(a){return 8*a},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(a){for(let b=0,c=this.data.length;b<c;b++)a.put(this.data[b],8)},a.exports=e},39477:(a,b,c)=>{let d=c(58305).getSymbolSize;b.getPositions=function(a){let b=d(a);return[[0,0],[b-7,0],[0,b-7]]}},39588:(a,b,c)=>{let d=c(93669),e=c(28964),f=c(27137),g=c(38937),h=c(64424),i=c(64323),j=c(58305),k=c(84879);function l(a){return unescape(encodeURIComponent(a)).length}function m(a,b,c){let d,e=[];for(;null!==(d=a.exec(c));)e.push({data:d[0],index:d.index,mode:b,length:d[0].length});return e}function n(a){let b,c,e=m(i.NUMERIC,d.NUMERIC,a),f=m(i.ALPHANUMERIC,d.ALPHANUMERIC,a);return j.isKanjiModeEnabled()?(b=m(i.BYTE,d.BYTE,a),c=m(i.KANJI,d.KANJI,a)):(b=m(i.BYTE_KANJI,d.BYTE,a),c=[]),e.concat(f,b,c).sort(function(a,b){return a.index-b.index}).map(function(a){return{data:a.data,mode:a.mode,length:a.length}})}function o(a,b){switch(b){case d.NUMERIC:return e.getBitsLength(a);case d.ALPHANUMERIC:return f.getBitsLength(a);case d.KANJI:return h.getBitsLength(a);case d.BYTE:return g.getBitsLength(a)}}function p(a,b){let c,i=d.getBestModeForData(a);if((c=d.from(b,i))!==d.BYTE&&c.bit<i.bit)throw Error('"'+a+'" cannot be encoded with mode '+d.toString(c)+".\n Suggested mode is: "+d.toString(i));switch(c===d.KANJI&&!j.isKanjiModeEnabled()&&(c=d.BYTE),c){case d.NUMERIC:return new e(a);case d.ALPHANUMERIC:return new f(a);case d.KANJI:return new h(a);case d.BYTE:return new g(a)}}b.fromArray=function(a){return a.reduce(function(a,b){return"string"==typeof b?a.push(p(b,null)):b.data&&a.push(p(b.data,b.mode)),a},[])},b.fromString=function(a,c){let e=function(a,b){let c={},e={start:{}},f=["start"];for(let g=0;g<a.length;g++){let h=a[g],i=[];for(let a=0;a<h.length;a++){let j=h[a],k=""+g+a;i.push(k),c[k]={node:j,lastCount:0},e[k]={};for(let a=0;a<f.length;a++){let g=f[a];c[g]&&c[g].node.mode===j.mode?(e[g][k]=o(c[g].lastCount+j.length,j.mode)-o(c[g].lastCount,j.mode),c[g].lastCount+=j.length):(c[g]&&(c[g].lastCount=j.length),e[g][k]=o(j.length,j.mode)+4+d.getCharCountIndicator(j.mode,b))}}f=i}for(let a=0;a<f.length;a++)e[f[a]].end=0;return{map:e,table:c}}(function(a){let b=[];for(let c=0;c<a.length;c++){let e=a[c];switch(e.mode){case d.NUMERIC:b.push([e,{data:e.data,mode:d.ALPHANUMERIC,length:e.length},{data:e.data,mode:d.BYTE,length:e.length}]);break;case d.ALPHANUMERIC:b.push([e,{data:e.data,mode:d.BYTE,length:e.length}]);break;case d.KANJI:b.push([e,{data:e.data,mode:d.BYTE,length:l(e.data)}]);break;case d.BYTE:b.push([{data:e.data,mode:d.BYTE,length:l(e.data)}])}}return b}(n(a,j.isKanjiModeEnabled())),c),f=k.find_path(e.map,"start","end"),g=[];for(let a=1;a<f.length-1;a++)g.push(e.table[f[a]].node);return b.fromArray(g.reduce(function(a,b){let c=a.length-1>=0?a[a.length-1]:null;return c&&c.mode===b.mode?a[a.length-1].data+=b.data:a.push(b),a},[]))},b.rawSplit=function(a){return b.fromArray(n(a,j.isKanjiModeEnabled()))}},40355:(a,b,c)=>{let d=c(76708),e=c(95380),f=c(46387),g=c(72081),h=c(66530),i=c(90082);function j(a,b,c){if(void 0===a)throw Error("String required as first argument");if(void 0===c&&(c=b,b={}),"function"!=typeof c)if(d())b=c||{},c=null;else throw Error("Callback required as last argument");return{opts:b,cb:c}}function k(a){switch(a){case"svg":return i;case"txt":case"utf8":return g;default:return f}}function l(a,b,c){if(!c.cb)return new Promise(function(d,f){try{let g=e.create(b,c.opts);return a(g,c.opts,function(a,b){return a?f(a):d(b)})}catch(a){f(a)}});try{let d=e.create(b,c.opts);return a(d,c.opts,c.cb)}catch(a){c.cb(a)}}b.create=e.create,b.toCanvas=c(2798).toCanvas,b.toString=function(a,b,c){let d=j(a,b,c);return l(function(a){switch(a){case"svg":return i;case"terminal":return h;default:return g}}(d.opts?d.opts.type:void 0).render,a,d)},b.toDataURL=function(a,b,c){let d=j(a,b,c);return l(k(d.opts.type).renderToDataURL,a,d)},b.toBuffer=function(a,b,c){let d=j(a,b,c);return l(k(d.opts.type).renderToBuffer,a,d)},b.toFile=function(a,b,c,e){if("string"!=typeof a||"string"!=typeof b&&"object"!=typeof b)throw Error("Invalid argument");if(arguments.length<3&&!d())throw Error("Too few arguments provided");let f=j(b,c,e);return l(k(f.opts.type||a.slice((a.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,a),b,f)},b.toFileStream=function(a,b,c){if(arguments.length<2)throw Error("Too few arguments provided");let d=j(b,c,a.emit.bind(a,"error"));l(k("png").renderToFileStream.bind(null,a),b,d)}},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},42516:(a,b,c)=>{"use strict";let d=c(81769),e=c(27734);b.process=function(a,b){let c=[],f=new d(a);return new e(b,{read:f.read.bind(f),write:function(a){c.push(a)},complete:function(){}}).start(),f.process(),Buffer.concat(c)}},43144:(a,b,c)=>{let d=c(81754);b.mul=function(a,b){let c=new Uint8Array(a.length+b.length-1);for(let e=0;e<a.length;e++)for(let f=0;f<b.length;f++)c[e+f]^=d.mul(a[e],b[f]);return c},b.mod=function(a,b){let c=new Uint8Array(a);for(;c.length-b.length>=0;){let a=c[0];for(let e=0;e<b.length;e++)c[e]^=d.mul(b[e],a);let e=0;for(;e<c.length&&0===c[e];)e++;c=c.slice(e)}return c},b.generateECPolynomial=function(a){let c=new Uint8Array([1]);for(let e=0;e<a;e++)c=b.mul(c,new Uint8Array([1,d.exp(e)]));return c}},43894:a=>{"use strict";let b=[];for(let a=0;a<256;a++){let c=a;for(let a=0;a<8;a++)1&c?c=0xedb88320^c>>>1:c>>>=1;b[a]=c}let c=a.exports=function(){this._crc=-1};c.prototype.write=function(a){for(let c=0;c<a.length;c++)this._crc=b[(this._crc^a[c])&255]^this._crc>>>8;return!0},c.prototype.crc32=function(){return -1^this._crc},c.crc32=function(a){let c=-1;for(let d=0;d<a.length;d++)c=b[(c^a[d])&255]^c>>>8;return -1^c}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},46349:a=>{function b(a){if(!a||a<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=a,this.data=new Uint8Array(a*a),this.reservedBit=new Uint8Array(a*a)}b.prototype.set=function(a,b,c,d){let e=a*this.size+b;this.data[e]=c,d&&(this.reservedBit[e]=!0)},b.prototype.get=function(a,b){return this.data[a*this.size+b]},b.prototype.xor=function(a,b,c){this.data[a*this.size+b]^=c},b.prototype.isReserved=function(a,b){return this.reservedBit[a*this.size+b]},a.exports=b},46387:(a,b,c)=>{let d=c(29021),e=c(34447).O,f=c(88397);b.render=function(a,b){let c=f.getOptions(b),d=c.rendererOpts,g=f.getImageWidth(a.modules.size,c);d.width=g,d.height=g;let h=new e(d);return f.qrToImageData(h.data,a,c),h},b.renderToDataURL=function(a,c,d){void 0===d&&(d=c,c=void 0),b.renderToBuffer(a,c,function(a,b){a&&d(a);let c="data:image/png;base64,";c+=b.toString("base64"),d(null,c)})},b.renderToBuffer=function(a,c,d){void 0===d&&(d=c,c=void 0);let e=b.render(a,c),f=[];e.on("error",d),e.on("data",function(a){f.push(a)}),e.on("end",function(){d(null,Buffer.concat(f))}),e.pack()},b.renderToFile=function(a,c,e,f){void 0===f&&(f=e,e=void 0);let g=!1,h=(...a)=>{g||(g=!0,f.apply(null,a))},i=d.createWriteStream(a);i.on("error",h),i.on("close",h),b.renderToFileStream(i,c,e)},b.renderToFileStream=function(a,c,d){b.render(c,d).pack().pipe(a)}},49149:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=c(67269),g=c(98052),h=a.exports=function(a){e.call(this),this._packer=new g(a||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};d.inherits(h,e),h.prototype.pack=function(a,b,c,d){this.emit("data",Buffer.from(f.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(b,c)),d&&this.emit("data",this._packer.packGAMA(d));let e=this._packer.filterData(a,b,c);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(a){this.emit("data",this._packer.packIDAT(a))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(e)}},49998:(a,b,c)=>{"use strict";a.exports=c(40355)},52002:a=>{function b(){this.buffer=[],this.length=0}b.prototype={get:function(a){let b=Math.floor(a/8);return(this.buffer[b]>>>7-a%8&1)==1},put:function(a,b){for(let c=0;c<b;c++)this.putBit((a>>>b-c-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(a){let b=Math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0),a&&(this.buffer[b]|=128>>>this.length%8),this.length++}},a.exports=b},52324:(a,b,c)=>{let d=c(58305),e=c(19477),f=c(58856),g=c(93669),h=c(83929),i=d.getBCHDigit(7973);function j(a,b){return g.getCharCountIndicator(a,b)+4}b.from=function(a,b){return h.isValid(a)?parseInt(a,10):b},b.getCapacity=function(a,b,c){if(!h.isValid(a))throw Error("Invalid QR Code version");void 0===c&&(c=g.BYTE);let f=(d.getSymbolTotalCodewords(a)-e.getTotalCodewordsCount(a,b))*8;if(c===g.MIXED)return f;let i=f-j(c,a);switch(c){case g.NUMERIC:return Math.floor(i/10*3);case g.ALPHANUMERIC:return Math.floor(i/11*2);case g.KANJI:return Math.floor(i/13);case g.BYTE:default:return Math.floor(i/8)}},b.getBestVersionForData=function(a,c){let d,e=f.from(c,f.M);if(Array.isArray(a)){if(a.length>1){for(let c=1;c<=40;c++)if(function(a,b){let c=0;return a.forEach(function(a){let d=j(a.mode,b);c+=d+a.getBitsLength()}),c}(a,c)<=b.getCapacity(c,e,g.MIXED))return c;return}if(0===a.length)return 1;d=a[0]}else d=a;return function(a,c,d){for(let e=1;e<=40;e++)if(c<=b.getCapacity(e,d,a))return e}(d.mode,d.getLength(),e)},b.getEncodedBits=function(a){if(!h.isValid(a)||a<7)throw Error("Invalid QR Code version");let b=a<<12;for(;d.getBCHDigit(b)-i>=0;)b^=7973<<d.getBCHDigit(b)-i;return a<<12|b}},55211:a=>{"use strict";a.exports=function(a,b,c){let d=a+b-c,e=Math.abs(d-a),f=Math.abs(d-b),g=Math.abs(d-c);return e<=f&&e<=g?a:f<=g?b:c}},55258:(a,b,c)=>{let d=c(58305),e=d.getBCHDigit(1335);b.getEncodedBits=function(a,b){let c=a.bit<<3|b,f=c<<10;for(;d.getBCHDigit(f)-e>=0;)f^=1335<<d.getBCHDigit(f)-e;return(c<<10|f)^21522}},57949:(a,b,c)=>{"use strict";let d=c(28354),e=c(27910),f=a.exports=function(){e.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};d.inherits(f,e),f.prototype.read=function(a,b){this._reads.push({length:Math.abs(a),allowLess:a<0,func:b}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},f.prototype.write=function(a,b){let c;return this.writable?(c=Buffer.isBuffer(a)?a:Buffer.from(a,b||this._encoding),this._buffers.push(c),this._buffered+=c.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},f.prototype.end=function(a,b){a&&this.write(a,b),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},f.prototype.destroySoon=f.prototype.end,f.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},f.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},f.prototype._processReadAllowingLess=function(a){this._reads.shift();let b=this._buffers[0];b.length>a.length?(this._buffered-=a.length,this._buffers[0]=b.slice(a.length),a.func.call(this,b.slice(0,a.length))):(this._buffered-=b.length,this._buffers.shift(),a.func.call(this,b))},f.prototype._processRead=function(a){this._reads.shift();let b=0,c=0,d=Buffer.alloc(a.length);for(;b<a.length;){let e=this._buffers[c++],f=Math.min(e.length,a.length-b);e.copy(d,b,0,f),b+=f,f!==e.length&&(this._buffers[--c]=e.slice(f))}c>0&&this._buffers.splice(0,c),this._buffered-=a.length,a.func.call(this,d)},f.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let a=this._reads[0];if(a.allowLess)this._processReadAllowingLess(a);else if(this._buffered>=a.length)this._processRead(a);else break}this._buffers&&!this.writable&&this._end()}catch(a){this.emit("error",a)}}},58305:(a,b)=>{let c,d=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];b.getSymbolSize=function(a){if(!a)throw Error('"version" cannot be null or undefined');if(a<1||a>40)throw Error('"version" should be in range from 1 to 40');return 4*a+17},b.getSymbolTotalCodewords=function(a){return d[a]},b.getBCHDigit=function(a){let b=0;for(;0!==a;)b++,a>>>=1;return b},b.setToSJISFunction=function(a){if("function"!=typeof a)throw Error('"toSJISFunc" is not a valid function.');c=a},b.isKanjiModeEnabled=function(){return void 0!==c},b.toSJIS=function(a){return c(a)}},58856:(a,b)=>{b.L={bit:1},b.M={bit:0},b.Q={bit:3},b.H={bit:2},b.isValid=function(a){return a&&void 0!==a.bit&&a.bit>=0&&a.bit<4},b.from=function(a,c){if(b.isValid(a))return a;try{if("string"!=typeof a)throw Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return b.L;case"m":case"medium":return b.M;case"q":case"quartile":return b.Q;case"h":case"high":return b.H;default:throw Error("Unknown EC Level: "+a)}}catch(a){return c}}},58879:(a,b,c)=>{"use strict";let d=c(9709),e=c(80706);b.read=function(a,b){return d(a,b||{})},b.write=function(a,b){return e(a,b)}},59725:(a,b)=>{"use strict";let c=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];b.getImagePasses=function(a,b){let d=[],e=a%8,f=b%8,g=(a-e)/8,h=(b-f)/8;for(let a=0;a<c.length;a++){let b=c[a],i=g*b.x.length,j=h*b.y.length;for(let a=0;a<b.x.length;a++)if(b.x[a]<e)i++;else break;for(let a=0;a<b.y.length;a++)if(b.y[a]<f)j++;else break;i>0&&j>0&&d.push({width:i,height:j,index:a})}return d},b.getInterlaceIterator=function(a){return function(b,d,e){let f=b%c[e].x.length,g=(b-f)/c[e].x.length*8+c[e].x[f],h=d%c[e].y.length;return 4*g+((d-h)/c[e].y.length*8+c[e].y[h])*a*4}}},61345:(a,b)=>{b.render=function(a,b,c){let d=a.modules.size,e=a.modules.data,f="\x1b[47m \x1b[0m",g="",h=Array(d+3).join(f),i=[,,].join(f);g+=h+"\n";for(let a=0;a<d;++a){g+=f;for(let b=0;b<d;b++)g+=e[a*d+b]?"\x1b[40m \x1b[0m":f;g+=i+"\n"}return g+=h+"\n","function"==typeof c&&c(null,g),g}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},64323:(a,b)=>{let c="[0-9]+",d="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",e="(?:(?![A-Z0-9 $%*+\\-./:]|"+(d=d.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";b.KANJI=RegExp(d,"g"),b.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),b.BYTE=RegExp(e,"g"),b.NUMERIC=RegExp(c,"g"),b.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let f=RegExp("^"+d+"$"),g=RegExp("^"+c+"$"),h=RegExp("^[A-Z0-9 $%*+\\-./:]+$");b.testKanji=function(a){return f.test(a)},b.testNumeric=function(a){return g.test(a)},b.testAlphanumeric=function(a){return h.test(a)}},64424:(a,b,c)=>{let d=c(93669),e=c(58305);function f(a){this.mode=d.KANJI,this.data=a}f.getBitsLength=function(a){return 13*a},f.prototype.getLength=function(){return this.data.length},f.prototype.getBitsLength=function(){return f.getBitsLength(this.data.length)},f.prototype.write=function(a){let b;for(b=0;b<this.data.length;b++){let c=e.toSJIS(this.data[b]);if(c>=33088&&c<=40956)c-=33088;else if(c>=57408&&c<=60351)c-=49472;else throw Error("Invalid SJIS character: "+this.data[b]+"\nMake sure your charset is UTF-8");c=(c>>>8&255)*192+(255&c),a.put(c,13)}},a.exports=f},66530:(a,b,c)=>{let d=c(61345),e=c(86491);b.render=function(a,b,c){return b&&b.small?e.render(a,b,c):d.render(a,b,c)}},67269:a=>{"use strict";a.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},72081:(a,b,c)=>{let d=c(88397),e={WW:" ",WB:"▄",BB:"█",BW:"▀"},f={BB:" ",BW:"▄",WW:"█",WB:"▀"};b.render=function(a,b,c){let g=d.getOptions(b),h=e;("#ffffff"===g.color.dark.hex||"#000000"===g.color.light.hex)&&(h=f);let i=a.modules.size,j=a.modules.data,k="",l=Array(i+2*g.margin+1).join(h.WW);l=Array(g.margin/2+1).join(l+"\n");let m=Array(g.margin+1).join(h.WW);k+=l;for(let a=0;a<i;a+=2){k+=m;for(let b=0;b<i;b++){var n;let c=j[a*i+b],d=j[(a+1)*i+b];k+=(n=h,c&&d?n.BB:c&&!d?n.BW:!c&&d?n.WB:n.WW)}k+=m+"\n"}return k+=l.slice(0,-1),"function"==typeof c&&c(null,k),k},b.renderToFile=function(a,d,e,f){void 0===f&&(f=e,e=void 0);let g=c(29021),h=b.render(d,e);g.writeFile(a,h,f)}},73136:a=>{"use strict";a.exports=require("node:url")},74075:a=>{"use strict";a.exports=require("zlib")},76708:a=>{a.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78908:a=>{"use strict";a.exports=import("shiki")},79428:a=>{"use strict";a.exports=require("buffer")},80183:(a,b,c)=>{"use strict";let d=c(12412).ok,e=c(74075),f=c(28354),g=c(79428).kMaxLength;function h(a){if(!(this instanceof h))return new h(a);a&&a.chunkSize<e.Z_MIN_CHUNK&&(a.chunkSize=e.Z_MIN_CHUNK),e.Inflate.call(this,a),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,a&&null!=a.maxLength&&(this._maxLength=a.maxLength)}function i(a,b){b&&process.nextTick(b),a._handle&&(a._handle.close(),a._handle=null)}function j(a,b){var c=new h(b),d=a;if("string"==typeof d&&(d=Buffer.from(d)),!(d instanceof Buffer))throw TypeError("Not a string or buffer");let f=c._finishFlushFlag;return null==f&&(f=e.Z_FINISH),c._processChunk(d,f)}h.prototype._processChunk=function(a,b,c){let f,h;if("function"==typeof c)return e.Inflate._processChunk.call(this,a,b,c);let j=this,k=a&&a.length,l=this._chunkSize-this._offset,m=this._maxLength,n=0,o=[],p=0;this.on("error",function(a){f=a}),d(this._handle,"zlib binding closed");do h=(h=this._handle.writeSync(b,a,n,k,this._buffer,this._offset,l))||this._writeState;while(!this._hadError&&function(a,b){if(j._hadError)return;let c=l-b;if(d(c>=0,"have should not go down"),c>0){let a=j._buffer.slice(j._offset,j._offset+c);if(j._offset+=c,a.length>m&&(a=a.slice(0,m)),o.push(a),p+=a.length,0==(m-=a.length))return!1}return(0===b||j._offset>=j._chunkSize)&&(l=j._chunkSize,j._offset=0,j._buffer=Buffer.allocUnsafe(j._chunkSize)),0===b&&(n+=k-a,k=a,!0)}(h[0],h[1]));if(this._hadError)throw f;if(p>=g)throw i(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+g.toString(16)+" bytes");let q=Buffer.concat(o,p);return i(this),q},f.inherits(h,e.Inflate),a.exports=b=j,b.Inflate=h,b.createInflate=function(a){return new h(a)},b.inflateSync=j},80706:(a,b,c)=>{"use strict";let d=!0,e=c(74075);e.deflateSync||(d=!1);let f=c(67269),g=c(98052);a.exports=function(a,b){if(!d)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let c=new g(b||{}),h=[];h.push(Buffer.from(f.PNG_SIGNATURE)),h.push(c.packIHDR(a.width,a.height)),a.gamma&&h.push(c.packGAMA(a.gamma));let i=c.filterData(a.data,a.width,a.height),j=e.deflateSync(i,c.getDeflateOptions());if(i=null,!j||!j.length)throw Error("bad png - invalid compressed data response");return h.push(c.packIDAT(j)),h.push(c.packIEND()),Buffer.concat(h)}},81754:(a,b)=>{let c=new Uint8Array(512),d=new Uint8Array(256),e=1;for(let a=0;a<255;a++)c[a]=e,d[e]=a,256&(e<<=1)&&(e^=285);for(let a=255;a<512;a++)c[a]=c[a-255];b.log=function(a){if(a<1)throw Error("log("+a+")");return d[a]},b.exp=function(a){return c[a]},b.mul=function(a,b){return 0===a||0===b?0:c[d[a]+d[b]]}},81769:a=>{"use strict";let b=a.exports=function(a){this._buffer=a,this._reads=[]};b.prototype.read=function(a,b){this._reads.push({length:Math.abs(a),allowLess:a<0,func:b})},b.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let a=this._reads[0];if(this._buffer.length&&(this._buffer.length>=a.length||a.allowLess)){this._reads.shift();let b=this._buffer;this._buffer=b.slice(a.length),a.func.call(this,b.slice(0,a.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},83670:a=>{"use strict";a.exports=function(a,b){let c=b.depth,d=b.width,e=b.height,f=b.colorType,g=b.transColor,h=b.palette,i=a;return 3===f?!function(a,b,c,d,e){let f=0;for(let g=0;g<d;g++)for(let d=0;d<c;d++){let c=e[a[f]];if(!c)throw Error("index "+a[f]+" not in palette");for(let a=0;a<4;a++)b[f+a]=c[a];f+=4}}(a,i,d,e,h):(g&&function(a,b,c,d,e){let f=0;for(let g=0;g<d;g++)for(let d=0;d<c;d++){let c=!1;if(1===e.length?e[0]===a[f]&&(c=!0):e[0]===a[f]&&e[1]===a[f+1]&&e[2]===a[f+2]&&(c=!0),c)for(let a=0;a<4;a++)b[f+a]=0;f+=4}}(a,i,d,e,g),8!==c&&(16===c&&(i=Buffer.alloc(d*e*4)),!function(a,b,c,d,e){let f=Math.pow(2,e)-1,g=0;for(let e=0;e<d;e++)for(let d=0;d<c;d++){for(let c=0;c<4;c++)b[g+c]=Math.floor(255*a[g+c]/f+.5);g+=4}}(a,i,d,e,c))),i}},83929:(a,b)=>{b.isValid=function(a){return!isNaN(a)&&a>=1&&a<=40}},84879:a=>{"use strict";var b={single_source_shortest_paths:function(a,c,d){var e,f,g,h,i,j,k,l={},m={};m[c]=0;var n=b.PriorityQueue.make();for(n.push(c,0);!n.empty();)for(g in f=(e=n.pop()).value,h=e.cost,i=a[f]||{})i.hasOwnProperty(g)&&(j=h+i[g],k=m[g],(void 0===m[g]||k>j)&&(m[g]=j,n.push(g,j),l[g]=f));if(void 0!==d&&void 0===m[d])throw Error("Could not find a path from "+c+" to "+d+".");return l},extract_shortest_path_from_predecessor_list:function(a,b){for(var c=[],d=b;d;)c.push(d),a[d],d=a[d];return c.reverse(),c},find_path:function(a,c,d){var e=b.single_source_shortest_paths(a,c,d);return b.extract_shortest_path_from_predecessor_list(e,d)},PriorityQueue:{make:function(a){var c,d=b.PriorityQueue,e={};for(c in a=a||{},d)d.hasOwnProperty(c)&&(e[c]=d[c]);return e.queue=[],e.sorter=a.sorter||d.default_sorter,e},default_sorter:function(a,b){return a.cost-b.cost},push:function(a,b){this.queue.push({value:a,cost:b}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};a.exports=b},85644:(a,b,c)=>{"use strict";c.d(b,{AppShell:()=>dZ});var d=c(48249),e=c(67484),f=c.n(e),g=c(19099);function h(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"..."+d+e.slice(-2).join(d)}function i(a){let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function j({open:a,cwd:b,homeDir:c,onClose:f,onSelectSession:g}){let[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)("current"),[o,p]=(0,e.useState)([]),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!1),w=(0,e.useRef)(null);if(!a)return null;let x=k.trim(),y=o.reduce((a,b)=>a+b.matches.length,0);return(0,d.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Search conversation history",style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"8vh 16px 16px",background:"rgba(0,0,0,0.28)"},onMouseDown:a=>{a.target===a.currentTarget&&f()},children:(0,d.jsxs)("div",{style:{width:"min(760px, 100%)",maxHeight:"78vh",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 16px 48px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,padding:"0 10px"},children:[(0,d.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,d.jsx)("path",{d:"M10.5 10.5 13.5 13.5"})]}),(0,d.jsx)("input",{ref:w,value:k,onChange:a=>l(a.target.value),placeholder:"Search conversation history...",style:{flex:1,minWidth:0,height:38,background:"transparent",border:"none",outline:"none",color:"var(--text)",fontSize:14}})]}),(0,d.jsx)("button",{type:"button",onClick:f,title:"Close",style:{width:34,height:34,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderRadius:7,color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color="var(--text-dim)"},children:(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,d.jsx)("path",{d:"M4 4 12 12"}),(0,d.jsx)("path",{d:"M12 4 4 12"})]})})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[(0,d.jsx)("div",{style:{display:"inline-flex",padding:2,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7},children:[{value:"current",label:"Current project",disabled:!b},{value:"all",label:"All history",disabled:!1}].map(a=>(0,d.jsx)("button",{type:"button",disabled:a.disabled,onClick:()=>n(a.value),style:{height:24,padding:"0 9px",background:m===a.value?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,color:a.disabled?"var(--text-dim)":m===a.value?"var(--text)":"var(--text-muted)",cursor:a.disabled?"not-allowed":"pointer",fontSize:11,fontWeight:500},children:a.label},a.value))}),(0,d.jsx)("div",{style:{flex:1,minWidth:0,color:"var(--text-dim)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"current"===m&&b?h(b,c):"Searching every saved session"})]})]}),(0,d.jsxs)("div",{style:{flex:1,overflowY:"auto",minHeight:180},children:[x.length<2&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Type at least 2 characters to search saved conversations."}),x.length>=2&&q&&0===o.length&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Searching..."}),s&&(0,d.jsx)("div",{style:{padding:18,color:"#ef4444",fontSize:13},children:s}),x.length>=2&&!q&&!s&&0===o.length&&(0,d.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"No matching conversations found."}),o.map(a=>(0,d.jsxs)("div",{style:{borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>{g(a.session),f()},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:"var(--bg-panel)",border:"none",borderBottom:"1px solid var(--border)",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-panel)"},children:[(0,d.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:600},children:a.session.name||a.session.firstMessage||"(no messages)"}),(0,d.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:11},children:i(a.session.modified)})]}),(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h(a.session.cwd,c)})]}),a.matchCount>a.matches.length&&(0,d.jsxs)("span",{style:{flexShrink:0,color:"var(--text-muted)",fontSize:11},children:[a.matchCount," matches"]})]}),a.matches.map(b=>(0,d.jsxs)("button",{type:"button",onClick:()=>{g(a.session),f()},style:{width:"100%",padding:"9px 14px 9px 28px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[(0,d.jsx)("span",{style:{minWidth:54,color:"user"===b.role?"var(--accent)":"var(--text-dim)",fontSize:11,fontWeight:600,textTransform:"capitalize"},children:b.role}),(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:i(b.timestamp)})]}),(0,d.jsx)("div",{style:{fontSize:12,lineHeight:1.45,color:"var(--text-muted)"},children:function(a,b){let c=b.trim();if(!c)return a;let e=a.toLowerCase().indexOf(c.toLowerCase());return e<0?a:(0,d.jsxs)(d.Fragment,{children:[a.slice(0,e),(0,d.jsx)("mark",{style:{background:"rgba(37,99,235,0.16)",color:"var(--text)",borderRadius:3,padding:"0 2px"},children:a.slice(e,e+c.length)}),a.slice(e+c.length)]})}(b.snippet,x)})]},b.entryId))]},a.session.id))]}),(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 12px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11},children:[(0,d.jsx)("span",{children:y>0?`${y}${u?"+":""} results`:"Esc to close"}),q&&o.length>0&&(0,d.jsx)("span",{children:"Updating..."})]})]})})}function k({open:a,initialPath:b,onClose:c,onSelect:f}){let[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(null),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),v=(0,e.useCallback)(async a=>{s(!0),u(null);try{let b=a?`/api/projects/browse?dir=${encodeURIComponent(a)}`:"/api/projects/browse",c=await fetch(b),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);h(d.current??""),j(d.parent??null),m(d.directories??[]),o(d.drives??[]),q(d.current??"")}catch(a){u(a instanceof Error?a.message:String(a))}finally{s(!1)}},[]);return a?(0,d.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.34)"},children:(0,d.jsxs)("div",{style:{width:"min(560px, 100%)",maxHeight:"min(720px, 88dvh)",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{height:48,padding:"0 14px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border)"},children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Select project path"}),(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11},children:"Server filesystem"})]}),(0,d.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:30,height:30,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"x"})]}),(0,d.jsx)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let b=p.trim();b&&f(b)},style:{display:"flex",gap:8},children:[(0,d.jsx)("input",{value:p,onChange:a=>q(a.target.value),placeholder:"/path/to/project",style:{flex:1,minWidth:0,height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:12,outline:"none"}}),(0,d.jsx)("button",{type:"button",onClick:()=>{let a=p.trim();a&&v(a)},disabled:!p.trim()||r,style:{height:32,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:p.trim()&&!r?"var(--text-muted)":"var(--text-dim)",cursor:p.trim()&&!r?"pointer":"default",fontSize:12},children:"Browse"}),(0,d.jsx)("button",{type:"submit",disabled:!p.trim(),style:{height:32,padding:"0 11px",border:"none",borderRadius:6,background:p.trim()?"var(--accent)":"var(--bg-hover)",color:p.trim()?"#fff":"var(--text-dim)",cursor:p.trim()?"pointer":"default",fontSize:12,fontWeight:650},children:"Use Path"})]})}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,d.jsx)("button",{type:"button",onClick:()=>i&&void v(i),disabled:!i,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:6,background:i?"var(--bg)":"transparent",color:i?"var(--text-muted)":"var(--text-dim)",cursor:i?"pointer":"default",padding:0},title:"Up",children:(0,d.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("polyline",{points:"2 6.5 5 3.5 8 6.5"})})}),n.length>0&&(0,d.jsxs)("select",{value:n.find(a=>g.toLowerCase().startsWith(a.toLowerCase()))??"",onChange:a=>{a.target.value&&v(a.target.value)},style:{height:28,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text-muted)",fontSize:12},children:[(0,d.jsx)("option",{value:"",children:"Drive"}),n.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:g,children:g})]}),(0,d.jsx)("div",{style:{flex:1,minHeight:220,maxHeight:360,overflowY:"auto",padding:6},children:r?(0,d.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"Loading..."}):t?(0,d.jsx)("div",{style:{padding:18,color:"#f87171",fontSize:12},children:t}):0===l.length?(0,d.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"No subdirectories"}):l.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>void v(a.path),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 9px",border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},title:a.path,children:[(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)",flexShrink:0},children:(0,d.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name}),(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:(0,d.jsx)("polyline",{points:"3.5 2 6.5 5 3.5 8"})})]},a.path))}),(0,d.jsxs)("div",{style:{padding:12,borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,d.jsx)("div",{style:{minWidth:0,color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g,children:g}),(0,d.jsxs)("div",{style:{display:"flex",gap:7,flexShrink:0},children:[(0,d.jsx)("button",{type:"button",onClick:c,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}),(0,d.jsx)("button",{type:"button",onClick:()=>g&&f(g),disabled:!g,style:{height:32,padding:"0 12px",border:"none",borderRadius:6,background:g?"var(--accent)":"var(--bg-hover)",color:g?"#fff":"var(--text-dim)",cursor:g?"pointer":"default",fontSize:12,fontWeight:650},children:"Select"})]})]})]})}):null}let l="AnnoVibe";function m(a){}async function n(a,b){let c=`${a}: HTTP ${b.status}`;try{let d=await b.json();return"string"==typeof d.error&&d.error?`${a}: ${d.error}`:c}catch{return c}}function o(a){return new DOMException(a,"TimeoutError")}function p(a,b){return a instanceof DOMException&&("AbortError"===a.name||"TimeoutError"===a.name)||a instanceof Error&&/aborted without reason|AbortError/i.test(a.message)?b:a instanceof Error?a.message:String(a)}function q(a){let b=new Date(a),c=new Date().getTime()-b.getTime(),d=Math.floor(c/6e4),e=Math.floor(c/36e5),f=Math.floor(c/864e5);return d<1?"just now":d<60?`${d}m ago`:e<24?`${e}h ago`:f<7?`${f}d ago`:b.toLocaleDateString()}function r(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"…/"+e.slice(-2).join(d)}function s(a,b){if(!a)return"No Project";let c=a.replace(/[\\/]+$/,""),d=c.includes("/")?"/":"\\";return c.split(d).filter(Boolean).pop()||r(a,b)}function t(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(!1),g=(0,e.useRef)(null),h=function(a){let[b,c]=(0,e.useState)(a);return(0,e.useRef)(null),(0,e.useRef)(0),b}(a?"v0.8.112":l),i=(0,e.useCallback)(a=>{b(a),f(!0),setTimeout(()=>f(!1),(a?6:8)*4*(1e3/60)+100)},[]),j=(0,e.useCallback)(()=>{g.current&&clearTimeout(g.current);let b=!a;i(b),b&&(g.current=setTimeout(()=>i(!1),3e3))},[a,i]);return(0,d.jsx)("button",{onClick:j,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:a?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"9ch"},children:h})}function u({selectedSessionId:a,onSelectSession:b,onNewSession:c,onNewWorkbench:f,initialSessionId:g,onInitialRestoreDone:h,refreshKey:i,onSessionDeleted:l,selectedCwd:q,onCwdChange:A}){let[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)({}),[F,G]=(0,e.useState)(()=>new Set),H=(0,e.useRef)(!1),[I,J]=(0,e.useState)(!0),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(null),[O,P]=(0,e.useState)(null),[Q,R]=(0,e.useState)(""),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(!1),[W,X]=(0,e.useState)("project"),[Y,Z]=(0,e.useState)(null),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)(!1),[ac,ad]=(0,e.useState)(()=>new Set),[ae,af]=(0,e.useState)(()=>new Set),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(null),[ak,al]=(0,e.useState)(null),[am,an]=(0,e.useState)(!1),ao=(0,e.useRef)(null),ap=(0,e.useRef)(!1),aq=(0,e.useRef)(!1);(0,e.useRef)(!1);let ar=(0,e.useRef)(new Map),as=(0,e.useCallback)(async(a=!1)=>{try{let b;a&&(N(null),J(!0));let c=new AbortController;try{b=setTimeout(()=>c.abort(o("Project loading timed out")),3e4);let a=await fetch("/api/projects?sessions=false",{signal:c.signal});if(!a.ok)throw Error(await n("projects",a));let d=await a.json();C(d.projects),N(null)}finally{clearTimeout(b)}}catch(a){N(p(a,"Loading projects timed out. Codex may still be starting; click Refresh to retry."))}finally{a&&J(!1)}},[]),at=(0,e.useCallback)(async(a,b=!1)=>{if(!a)return;let c=ar.current.get(a);if(c)return c;let d=(async()=>{E(b=>({...b,[a]:{sessions:b[a]?.sessions??[],loaded:b[a]?.loaded??!1,error:null,loading:!0,stale:b[a]?.stale??!1}}));try{let c;b&&J(!0);let d=new AbortController;try{c=setTimeout(()=>d.abort(o("Chat loading timed out")),3e4);let b=await fetch(`/api/sessions?cwd=${encodeURIComponent(a)}`,{signal:d.signal});if(!b.ok)throw Error(await n("sessions",b));let e=await b.json();e.runningSessionIds&&!H.current&&G(new Set(e.runningSessionIds)),E(b=>({...b,[a]:{sessions:e.sessions,loaded:!0,loading:!1,error:null,stale:!1}}))}finally{clearTimeout(c)}}catch(c){let b=p(c,"Loading chats timed out. Codex may still be starting; click Refresh to retry.");E(c=>({...c,[a]:{sessions:c[a]?.sessions??[],loaded:c[a]?.loaded??!1,loading:!1,error:b,stale:(c[a]?.sessions?.length??0)>0}}))}finally{b&&J(!1),ar.current.delete(a)}})();return ar.current.set(a,d),d},[]);(0,e.useRef)(!1),(0,e.useRef)(!1);let au=(0,e.useCallback)(async(a,b=!1)=>{try{let c=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,create:b})}),d=await c.json();if(!c.ok||d.error)return T(d.error??`HTTP ${c.status}`),!1;return as(!1),!0}catch(a){return T(a instanceof Error?a.message:String(a)),!1}},[as]),av=(0,e.useCallback)(a=>{fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,touch:!0})}).catch(()=>{})},[]),aw=(0,e.useCallback)(a=>{aq.current=!0,P(a),T(null),af(b=>{if(!b.has(a))return b;let c=new Set(b);return c.delete(a),m(c),c}),A?.(a),av(a),at(a,!1)},[at,A,av]),ax=q??O,ay=(0,e.useCallback)(a=>{if(!a){X("agent"),V(!0);return}let b="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;c?.(b,a)},[c]),az=(0,e.useCallback)(a=>{if(!a){X("workbench"),V(!0);return}f?.(a)},[f]),aA=(0,e.useCallback)(async a=>{await au(a,!0)&&(aw(a),V(!1),T(null),"agent"===W&&ay(a),"workbench"===W&&az(a))},[aw,ay,az,W,au]),aB=(0,e.useCallback)(a=>{Z(a),_(!0)},[]),aC=(0,e.useCallback)(()=>{_(!1),Z(null)},[]),aD=(0,e.useCallback)(a=>{let b=Y??ax;aC(),"agent"===a?ay(b):az(b)},[aC,ay,az,ax,Y]),aE=(0,e.useCallback)(()=>{aB(ax)},[ax,aB]),aF=(0,e.useCallback)(()=>{X("project"),T(null),V(!0)},[]),aG=(0,e.useMemo)(()=>[...ax&&!B.some(a=>a.cwd===ax)?[{cwd:ax,displayName:s(ax,Q),chatCount:D[ax]?.sessions.length??0,lastAccessed:null,created:null,pinned:!1,sortOrder:null,exists:!0,source:"manual"}]:[],...B].sort((a,b)=>{let c=!0===a.pinned;if(c!==(!0===b.pinned))return c?-1:1;let d="number"==typeof a.sortOrder?a.sortOrder:Number.MAX_SAFE_INTEGER,e="number"==typeof b.sortOrder?b.sortOrder:Number.MAX_SAFE_INTEGER;return d!==e?d-e:(a.displayName||"").localeCompare(b.displayName||"",void 0,{numeric:!0,sensitivity:"base"})}),[ax,Q,B,D]),aH=(0,e.useMemo)(()=>{let a=a=>{let b=D[a.cwd],c=[...b?.sessions??[]].sort((a,b)=>(b.modified||"").localeCompare(a.modified||""));return{project:a,cwd:a.cwd,displayName:a.displayName||s(a.cwd,Q),sessions:c,sessionsState:b,lastAccessed:(a.lastAccessed??a.created??"")||c[0]?.modified||""}},b=aG.filter(a=>!0===a.pinned).map(a);if(ax){let c=aG.find(a=>a.cwd===ax);c&&!0!==c.pinned&&b.push(a(c))}return b},[ax,Q,D,aG]),aI=(0,e.useCallback)((a,c=!1)=>{a.cwd!==ax&&(ap.current=!0,P(a.cwd)),af(b=>{if(!b.has(a.cwd))return b;let c=new Set(b);return c.delete(a.cwd),m(c),c}),av(a.cwd),b(a,c)},[b,ax,av]),aJ=(0,e.useCallback)(a=>{af(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),m(c),c})},[]),aK=(0,e.useCallback)(a=>{ad(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aL=(0,e.useCallback)(async a=>{al("reorder");try{let b=await fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:a})}),c=await b.json();if(!b.ok||c.error)throw Error(c.error??`HTTP ${b.status}`);C(c.projects??[]),N(null)}catch(a){N(a instanceof Error?a.message:String(a)),as(!1)}finally{al(null)}},[as]),aM=(0,e.useCallback)(async(a,b)=>{al(`pin:${a}`);try{let c=await fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,pinned:b})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);C(d.projects??[]),N(null)}catch(a){N(a instanceof Error?a.message:String(a)),as(!1)}finally{al(null)}},[as]),aN=(0,e.useCallback)((a,b)=>{if(!a||!b||a===b)return;let c=aG.map(a=>a.cwd).filter(Boolean),d=c.indexOf(a),e=c.indexOf(b);if(-1===d||-1===e)return;let f=[...c];f.splice(d,1);let g=f.indexOf(b);f.splice(g,0,a),aL(f)},[aL,aG]),aO=(0,e.useCallback)(async()=>{L(!0);try{await as(!1);let a=new Set([...Object.entries(D).filter(([,a])=>a.loaded||a.loading).map(([a])=>a),...ax?[ax]:[]]);await Promise.all([...a].map(a=>at(a,!1)))}finally{L(!1)}},[ax,as,at,D]);return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,d.jsx)(t,{}),(0,d.jsxs)("div",{style:{display:"flex",gap:6,minWidth:0},children:[(0,d.jsxs)("button",{onClick:aE,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:ax?`New chat in ${ax}`:"New chat in a project path",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,d.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"New Chat"]}),(0,d.jsx)("button",{onClick:()=>ab(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:"Search conversations",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,d.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]})})]})]})}),(0,d.jsx)(j,{open:aa,cwd:ax,homeDir:Q,onClose:()=>ab(!1),onSelectSession:a=>{aI(a)}}),(0,d.jsxs)("div",{ref:ao,style:{position:"relative",marginTop:8,padding:"0 10px",display:"flex",alignItems:"stretch",gap:4},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>an(a=>!a),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,padding:"6px 10px",background:ax?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:ax?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left"},title:ax??"Select project",children:[(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--accent)"},children:(0,d.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,d.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:ax?"var(--text)":"var(--text-dim)"},children:ax?aG.find(a=>a.cwd===ax)?.displayName??r(ax,Q):"Select project…"}),(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:am?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),ax&&(0,d.jsx)(w,{pinned:aG.find(a=>a.cwd===ax)?.pinned===!0,onToggle:()=>void aM(ax,aG.find(a=>a.cwd===ax)?.pinned!==!0)}),am&&(0,d.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:10,right:10,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden",maxHeight:280,overflowY:"auto"},children:[0===aG.length&&(0,d.jsx)("div",{style:{padding:"10px 12px",color:"var(--text-dim)",fontSize:11},children:"No projects yet"}),aG.map(a=>{let b=a.cwd===ax;return(0,d.jsx)(x,{project:a,homeDir:Q,isCurrent:b,onSelect:()=>{aw(a.cwd),an(!1)},onTogglePinned:()=>void aM(a.cwd,!0!==a.pinned)},a.cwd)}),(0,d.jsxs)("button",{type:"button",onClick:()=>{an(!1),aF()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",borderTop:aG.length>0?"1px solid var(--border)":"none",color:"var(--accent)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,d.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"Add project…"]})]})]}),(0,d.jsxs)("div",{style:{flexShrink:0,padding:"10px 10px 6px"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase"},children:"Projects"}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[(0,d.jsx)("button",{type:"button",onClick:aO,disabled:K,title:"Refresh projects and chats","aria-label":"Refresh projects and chats",style:{width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:K?"var(--accent)":"var(--text-dim)",cursor:K?"default":"pointer",flexShrink:0},children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:K?"spin 0.9s linear infinite":void 0},children:[(0,d.jsx)("path",{d:"M21 12a9 9 0 0 1-15.5 6.2"}),(0,d.jsx)("path",{d:"M3 12A9 9 0 0 1 18.5 5.8"}),(0,d.jsx)("path",{d:"M7 18H5.5v1.5"}),(0,d.jsx)("path",{d:"M17 6h1.5V4.5"})]})}),(0,d.jsxs)("button",{type:"button",onClick:aF,title:"New project","aria-label":"New project",style:{height:26,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"0 8px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,transition:"background 0.12s, color 0.12s, border-color 0.12s",flexShrink:0},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M1.5 4.5A1.5 1.5 0 0 1 3 3h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6v4.5A1.5 1.5 0 0 1 13 12H3a1.5 1.5 0 0 1-1.5-1.5v-6Z"}),(0,d.jsx)("path",{d:"M11 7v3M9.5 8.5h3"})]}),"New Project"]})]})]}),S&&(0,d.jsx)("div",{style:{marginTop:6,color:"#f87171",fontSize:11,lineHeight:1.4,overflowWrap:"anywhere"},children:S})]}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",overflowY:"auto",padding:"6px 8px 8px",minHeight:80,scrollbarWidth:"thin",overscrollBehavior:"contain"},children:[I&&(0,d.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Loading..."}),M&&(0,d.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:M}),!I&&!M&&0===aH.length&&(0,d.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Open or create a project to start chatting."}),!I&&!M&&aH.map(b=>{let c,e=ae.has(b.cwd),f=b.cwd===ax,g=ac.has(b.cwd),h=function(a){let b=new Map;for(let c of a)b.set(c.id,{session:c,children:[]});let c=new Map;for(let b of a)b.parentSessionId&&c.set(b.id,b.parentSessionId);let d=[];for(let a of b.values()){let e=function(a){let d=c.get(a),e=new Set;for(;d&&!e.has(d);){if(e.add(d),b.has(d))return d;d=c.get(d)}return null}(a.session.id);e?b.get(e).children.push(a):d.push(a)}let e=a=>{a.sort((a,b)=>(b.session.modified||"").localeCompare(a.session.modified||"")),a.forEach(a=>e(a.children))};return e(d),d}(b.sessions),i=h.length,j=h;if(i>10&&!g){j=h.slice(0,10);let b=h.find(b=>(function a(b,c){return!!c&&(b.session.id===c||b.children.some(b=>a(b,c)))})(b,a));b&&!j.includes(b)&&(j=[...j,b])}let k=i-j.length;return(0,d.jsxs)("div",{style:{marginBottom:6,borderTop:ai===b.cwd?"2px solid var(--accent)":"2px solid transparent",paddingTop:2*(ai===b.cwd),opacity:ag===b.cwd?.55:1},onDragOver:a=>{ag&&ag!==b.cwd&&(a.preventDefault(),a.dataTransfer.dropEffect="move",aj(b.cwd))},onDragLeave:()=>{ai===b.cwd&&aj(null)},onDrop:a=>{a.preventDefault();let c=a.dataTransfer.getData("text/project-cwd")||ag;aj(null),ah(null),c&&aN(c,b.cwd)},children:[(0,d.jsx)(y,{group:b,isCurrent:f,isCollapsed:e,isDragging:ag===b.cwd,pinBusy:ak===`pin:${b.cwd}`,onToggle:()=>aJ(b.cwd),onSelect:()=>aw(b.cwd),onTogglePinned:()=>void aM(b.cwd,!0!==b.project.pinned),onDragStart:a=>{ah(b.cwd),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/project-cwd",b.cwd)},onDragEnd:()=>{ah(null),aj(null)}}),!e&&(0,d.jsxs)("div",{style:{marginTop:2,overflow:"hidden",borderRadius:7},children:[(c=b.sessionsState,c?.loading&&!c?.loaded?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"var(--text-dim)",textAlign:"left",fontSize:12,fontStyle:"italic"},children:"Loading chats…"}):c?.error&&!c?.stale?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"#f87171",textAlign:"left",fontSize:12},children:c.error}):0===b.sessions.length?(0,d.jsx)("div",{style:{width:"100%",padding:"10px 12px",color:"var(--text-muted)",textAlign:"left",fontSize:12},children:"No sessions yet. Use New Chat above to start one."}):(0,d.jsxs)(d.Fragment,{children:[c?.stale&&(0,d.jsx)("div",{style:{width:"100%",padding:"4px 12px",color:"var(--text-dim)",textAlign:"left",fontSize:10,fontStyle:"italic"},children:"Showing cached data — refresh failed"}),j.map(c=>(0,d.jsx)(z,{node:c,selectedSessionId:a,onSelectSession:aI,onRenamed:()=>void at(b.cwd,!1),onSessionDeleted:a=>{l?.(a),at(b.cwd,!1)},depth:0,runningSessionIds:F},c.session.id))]})),(g||k>0)&&i>10&&(0,d.jsx)("button",{type:"button",onClick:()=>aK(b.cwd),style:{width:"100%",padding:"6px 10px",background:"transparent",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11,textAlign:"center"},children:g?"Show less":`Show ${Math.max(0,k)} more`})]})]},b.cwd||"__no_project")})]}),$&&(0,d.jsx)(v,{cwd:Y,onChoose:aD,onClose:aC}),(0,d.jsx)(k,{open:U,initialPath:ax,onClose:()=>V(!1),onSelect:a=>aA(a)})]})}function v({cwd:a,onChoose:b,onClose:c}){let e=a?s(a):"Choose a project path next";return(0,d.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.28)"},children:(0,d.jsxs)("div",{style:{width:"min(420px, 100%)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 12px 40px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,d.jsxs)("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid var(--border)",display:"flex",justifyContent:"space-between",gap:12},children:[(0,d.jsxs)("div",{style:{minWidth:0},children:[(0,d.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Start a new session"}),(0,d.jsx)("div",{style:{marginTop:5,color:"var(--text-dim)",fontSize:11},children:"Current project"}),(0,d.jsx)("div",{title:a??void 0,style:{marginTop:2,color:"var(--text)",fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),a&&(0,d.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a})]}),(0,d.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:28,height:28,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},children:"x"})]}),(0,d.jsxs)("div",{style:{padding:14,display:"grid",gap:10},children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b("agent"),style:{display:"grid",gap:5,textAlign:"left",padding:"13px 14px",border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer"},children:[(0,d.jsx)("span",{style:{fontSize:13,fontWeight:750},children:"Agent Chat"}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.45},children:"General coding or analysis chat in this project."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b("workbench"),style:{display:"grid",gap:5,textAlign:"left",padding:"13px 14px",border:"1px solid rgba(37,99,235,0.45)",borderRadius:10,background:"rgba(37,99,235,0.08)",color:"var(--text)",cursor:"pointer"},children:[(0,d.jsx)("span",{style:{fontSize:13,fontWeight:750,color:"var(--accent)"},children:"Workbench"}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.45},children:"Dedicated R/Python warm-runtime session for data loading, plots, and artifacts."})]})]})]})})}function w({pinned:a,onToggle:b}){return(0,d.jsx)("button",{type:"button",onClick:b,title:a?"Unpin project":"Pin project to sidebar",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:"auto",padding:0,border:"1px solid var(--border)",borderRadius:7,background:a?"rgba(234,179,8,0.12)":"var(--bg-hover)",color:a?"#ca8a04":"var(--text-muted)",cursor:"pointer",flexShrink:0},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:a?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})})}function x({project:a,homeDir:b,isCurrent:c,onSelect:f,onTogglePinned:g}){let[h,i]=(0,e.useState)(!1),j=a.displayName||s(a.cwd,b);return(0,d.jsxs)("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{display:"flex",alignItems:"center",gap:4,background:c?"var(--bg-selected)":h?"var(--bg-hover)":"none",borderBottom:"1px solid var(--border)"},children:[(0,d.jsx)("span",{style:{width:10,marginLeft:6,flexShrink:0}}),(0,d.jsxs)("button",{type:"button",onClick:f,title:a.cwd,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:7,padding:"8px 10px 8px 0",background:"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)"},children:[c?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j}),!a.exists&&(0,d.jsx)("span",{style:{flexShrink:0,color:"#f87171",fontSize:10},children:"missing"})]}),(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),g()},title:"Pin to sidebar",tabIndex:h?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,marginRight:4,padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,opacity:+!!h,pointerEvents:h?"auto":"none"},children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})})]})}function y({group:a,isCurrent:b,isCollapsed:c,isDragging:f,pinBusy:g,onToggle:h,onSelect:i,onTogglePinned:j,onDragStart:k,onDragEnd:l}){let[m,n]=(0,e.useState)(!1),o=a.lastAccessed,p=Math.max(0,a.project.chatCount??a.sessions.length??0),r=!0===a.project.pinned,s=(0,e.useCallback)(()=>{b?h():i()},[b,i,h]);return(0,d.jsxs)("div",{role:"button",tabIndex:0,draggable:!0,onClick:s,onDragStart:k,onDragEnd:l,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),s())},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),title:a.cwd,style:{width:"100%",height:32,display:"flex",alignItems:"center",gap:5,padding:"0 8px",background:b?"var(--bg-selected)":m?"var(--bg-hover)":"transparent",border:"none",borderRadius:6,color:"var(--text)",cursor:f?"grabbing":"pointer",textAlign:"left",overflow:"hidden",transition:"background 0.12s, opacity 0.12s",opacity:f?.55:1},children:[(0,d.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:c?"none":"rotate(90deg)",transition:"transform 0.15s",flexShrink:0,color:"var(--text-dim)"},children:(0,d.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:b?"var(--accent)":"var(--text-dim)"},children:c?(0,d.jsx)("path",{d:"M1.5 4.5A1.5 1.5 0 0 1 3 3h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6v5A1.5 1.5 0 0 1 13 12.5H3A1.5 1.5 0 0 1 1.5 11V4.5Z"}):(0,d.jsx)("path",{d:"M1.5 5A1.5 1.5 0 0 1 3 3.5h3l1.2 1.5H13A1.5 1.5 0 0 1 14.5 6.5L13.6 11A1.5 1.5 0 0 1 12.1 12.5H3A1.5 1.5 0 0 1 1.5 11V5Z"})}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:b?650:560,color:"var(--text)"},children:a.displayName}),!a.project.exists&&(0,d.jsx)("span",{style:{flexShrink:0,color:"#f87171",fontSize:10},children:"missing"}),!m&&p>0&&(0,d.jsxs)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:[p," ",1===p?"chat":"chats"]}),!m&&o&&(0,d.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:q(o)}),r?(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),j()},title:"Unpin project",tabIndex:m?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,border:"none",borderRadius:5,background:"rgba(234,179,8,0.12)",color:"#ca8a04",cursor:"pointer",flexShrink:0,opacity:m?1:.85,transition:"opacity 0.12s"},children:(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})}):(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),j()},disabled:g,title:"Pin project to sidebar",tabIndex:m?0:-1,style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,border:"none",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:g?"wait":"pointer",flexShrink:0,opacity:+!!m,transition:"opacity 0.12s, background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="#ca8a04"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M12 17v5"}),(0,d.jsx)("path",{d:"M5 3h14l-4 7v4l-6 3v-7L5 3Z"})]})}),(0,d.jsx)("span",{title:"Drag to reorder",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:22,flexShrink:0,color:"var(--text-dim)",opacity:m?1:.35,transition:"opacity 0.12s",cursor:"grab"},children:(0,d.jsxs)("svg",{width:"10",height:"12",viewBox:"0 0 10 12",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"2",cy:"2",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"2",r:"1"}),(0,d.jsx)("circle",{cx:"2",cy:"6",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"6",r:"1"}),(0,d.jsx)("circle",{cx:"2",cy:"10",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"10",r:"1"})]})})]})}function z({node:a,selectedSessionId:b,onSelectSession:c,onRenamed:f,onSessionDeleted:g,depth:h,runningSessionIds:i}){let[j,k]=(0,e.useState)(!1),l=a.children.length>0;return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{style:{position:"relative"},children:[h>0&&(0,d.jsx)("div",{style:{position:"absolute",left:12*h+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,d.jsx)(A,{session:a.session,isSelected:a.session.id===b,onClick:()=>c(a.session),onRenamed:f,onDeleted:a=>g?.(a),depth:h,hasChildren:l,collapsed:j,onToggleCollapse:()=>k(a=>!a),isRunning:i.has(a.session.id)})]}),l&&!j&&(0,d.jsx)("div",{children:a.children.map(a=>(0,d.jsx)(z,{node:a,selectedSessionId:b,onSelectSession:c,onRenamed:f,onSessionDeleted:g,depth:h+1,runningSessionIds:i},a.session.id))})]})}function A({session:a,isSelected:b,onClick:c,onRenamed:f,onDeleted:g,depth:h=0,hasChildren:i=!1,collapsed:j=!1,onToggleCollapse:k,isRunning:l=!1}){let[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(!1),x=(0,e.useRef)(null),y=a.name||a.firstMessage.slice(0,50)||a.id.slice(0,12),z=(0,e.useCallback)(b=>{b.stopPropagation(),s(a.name??""),p(!0),setTimeout(()=>x.current?.select(),0)},[a.name]),B=(0,e.useCallback)(async()=>{let b=r.trim();if(p(!1),b!==(a.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})}),f?.()}catch{}},[r,a.id,a.name,f]),C=(0,e.useCallback)(a=>{a.stopPropagation(),u(!0)},[]),D=(0,e.useCallback)(async b=>{b.stopPropagation(),u(!1),w(!0);try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"DELETE"}),g?.(a.id)}catch{w(!1)}},[a.id,g]),E=(0,e.useCallback)(a=>{a.stopPropagation(),u(!1)},[]),F="workbench"===a.sessionKind;return(0,d.jsx)("div",{onClick:t||o?void 0:c,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1)},style:{display:"flex",alignItems:"center",padding:"7px 8px",paddingLeft:h>0?12*h+14:14,paddingRight:8,cursor:t||o?"default":"pointer",background:t?"rgba(239,68,68,0.06)":b?"var(--bg-selected)":m?"var(--bg-hover)":"transparent",borderLeft:t?"2px solid #ef4444":b?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:v?.5:1,gap:6,overflow:"hidden"},children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,d.jsxs)("span",{style:{fontWeight:600},children:["“",y.slice(0,22),y.length>22?"…":"","”"]}),"?"]}),(0,d.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,d.jsxs)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,d.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,d.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,d.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,d.jsx)("button",{onClick:E,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):o?(0,d.jsx)("input",{ref:x,value:r,onChange:a=>s(a.target.value),onBlur:B,onKeyDown:a=>{"Enter"===a.key&&B(),"Escape"===a.key&&p(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:28}}):(0,d.jsxs)(d.Fragment,{children:[h>0&&(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,d.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),0===h&&(0,d.jsx)("span",{"aria-hidden":"true",style:{width:l?7:5,height:l?7:5,borderRadius:"50%",background:l?"#22c55e":b?"var(--accent)":"var(--text-dim)",opacity:b?1:.35,flexShrink:0,...l?{boxShadow:"0 0 6px rgba(34,197,94,0.5)",animation:"pulse 2s infinite"}:{}}}),F&&(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M4 19V5"}),(0,d.jsx)("path",{d:"M4 19h16"}),(0,d.jsx)("path",{d:"m7 16 3-5 4 3 4-7"})]}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[(0,d.jsx)("div",{style:{fontSize:13,fontWeight:b?600:500,lineHeight:"18px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:F?"var(--accent)":"var(--text)"},title:y,children:y}),(0,d.jsxs)("div",{style:{display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,d.jsx)("span",{title:a.modified,children:q(a.modified)}),(0,d.jsxs)("span",{children:[a.messageCount," msgs"]}),!1===a.cwdExists&&(0,d.jsx)("span",{title:`Project path missing: ${a.cwd}`,style:{color:"#f87171"},children:"missing path"})]})]}),i&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k?.()},title:j?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:j?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),m&&(0,d.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,d.jsx)("button",{onClick:z,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,d.jsx)("button",{onClick:C,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)",a.currentTarget.style.color="#ef4444",a.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,d.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,d.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,d.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}var B=c(62418);let C="subagent",D=["retain","recall","reflect"],E=[],F=["read","bash","edit","write"],G=["bash","read","edit","write","grep","find","ls"],H=[...G,"kernel_plot_run","kernel_plot_render","kernel_plot_inspect","kernel_plot_stop","kernel_plot_artifacts"],I=[...G,C];function J(a){return[...a].sort().join(",")}function K(a){switch(a){case"none":return E;case"default":return F;case"workbench":return H;case"agent":return I;default:return G}}function L(a,b){return[...new Set([...K(a),...b])]}let M=new Map,N=["off","default","full","agent"],O={off:"none",default:"default",full:"full",agent:"agent"},P={off:"无工具,纯聊天",default:"4 项内置工具",full:"全部内置工具",agent:"High + 子代理"},Q={retain:{label:"retain",description:"保存稳定事实或决策到项目记忆"},recall:{label:"recall",description:"检索项目记忆中的相关上下文"},reflect:{label:"reflect",description:"基于已存记忆做综合回应"}},R=["auto","off","minimal","low","medium","high","xhigh"],S={auto:"沿用 pi 默认设置",off:"关闭推理",minimal:"最少推理",low:"低强度推理",medium:"中等推理",high:"高强度推理",xhigh:"最高强度推理"},T=[{command:"/compact",label:"/compact",description:"压缩当前上下文",kind:"native"},{command:"/init",label:"/init",description:"快捷插入,交给模型处理初始化任务",kind:"shortcut"},{command:"/memory",label:"/memory",description:"快捷插入,交给模型处理项目记忆任务",kind:"shortcut"}];function U({doc:a,onRemove:b}){var c;let e=a.fileName.split(".").pop()?.toLowerCase()??"",f=function(a){switch(a){case"pdf":return{emoji:"\uD83D\uDCC4",color:"#ef4444"};case"docx":case"doc":return{emoji:"\uD83D\uDCDD",color:"#3b82f6"};case"xlsx":case"xls":return{emoji:"\uD83D\uDCCA",color:"#22c55e"};case"pptx":case"ppt":return{emoji:"\uD83D\uDCFD",color:"#f97316"};default:return{emoji:"\uD83D\uDCCE",color:"var(--text-muted)"}}}(e),g=(c=a.size)<1024?`${c} B`:c<1048576?`${(c/1024).toFixed(1)} KB`:`${(c/1048576).toFixed(1)} MB`;return(0,d.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:6,padding:"5px 10px 5px 7px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,maxWidth:200},title:a.fileName,children:[(0,d.jsx)("span",{style:{color:f.color,fontSize:14,flexShrink:0},children:f.emoji}),(0,d.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3},children:a.fileName}),(0,d.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.3},children:[e.toUpperCase()," \xb7 ",g,a.extractionError?" \xb7 no text":a.truncated?" \xb7 truncated":a.extractedText?" \xb7 text":""]})]}),(0,d.jsx)("button",{onClick:b,style:{flexShrink:0,width:14,height:14,borderRadius:"50%",background:"var(--bg-hover)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-dim)"},onMouseEnter:a=>{a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--text-dim)"},children:(0,d.jsxs)("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"1",y1:"1",x2:"6",y2:"6"}),(0,d.jsx)("line",{x1:"6",y1:"1",x2:"1",y2:"6"})]})})]})}function V(a){return a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&apos;/g,"'")}async function W(a){let b=await c.e(1688).then(c.bind(c,81688));b.GlobalWorkerOptions.workerSrc=new c.U(c(19224)).toString();let d=await b.getDocument({data:a.slice(0)}).promise,e=[];for(let a=1;a<=d.numPages;a+=1){let b=await d.getPage(a),c=(await b.getTextContent()).items.map(a=>"str"in a?a.str:"").filter(Boolean).join(" ");c.trim()&&e.push(`Page ${a}
2
2
  ${c}`)}return e.join("\n\n")}async function X(a){let b=(await c.e(7890).then(c.t.bind(c,55509,23))).default,d=await b.loadAsync(a),e=["word/document.xml",...Object.keys(d.files).filter(a=>/^word\/(footnotes|endnotes|comments)\.xml$/i.test(a)).sort()],f=[];for(let a of e){let b=d.file(a);if(!b)continue;let c=[...(await b.async("string")).replace(/<w:(br|cr)[^>]*\/>/g,"\n").replace(/<\/w:p>/g,"\n").matchAll(/<w:t[^>]*>([\s\S]*?)<\/w:t>/g)];f.push(...c.map(a=>V(a[1])))}return f.join("").replace(/[ \t]+\n/g,"\n")}async function Y(a){let b=await c.e(7765).then(c.bind(c,77765)),d=b.read(a,{type:"array"});return d.SheetNames.map(a=>{let c=d.Sheets[a],e=b.utils.sheet_to_csv(c);return`Sheet: ${a}
3
3
  ${e}`}).join("\n\n")}async function Z(a){let b=(await c.e(7890).then(c.t.bind(c,55509,23))).default,d=await b.loadAsync(a),e=Object.keys(d.files).map(a=>({name:a,match:/^ppt\/slides\/slide(\d+)\.xml$/i.exec(a)})).filter(a=>null!==a.match).sort((a,b)=>Number(a.match[1])-Number(b.match[1])),f=[];for(let{name:a,match:b}of e){let c=[...(await d.file(a).async("string")).matchAll(/<a:t[^>]*>([\s\S]*?)<\/a:t>/g)].map(a=>V(a[1]).trim()).filter(Boolean);c.length&&f.push(`Slide ${b[1]}
4
4
  ${c.join("\n")}`)}return f.join("\n\n")}async function $(a,b){let c=a.name.split(".").pop()?.toLowerCase()??"";try{let d,e="";if(a.type.startsWith("text/")||["csv","tsv","md","txt","json","xml"].includes(c))e=new TextDecoder("utf-8").decode(b);else if("pdf"===c||"application/pdf"===a.type)e=await W(b);else if("docx"===c)e=await X(b);else if("xlsx"===c)e=await Y(b);else{if("pptx"!==c)return{extractionError:"Text extraction is not supported for this file type"};e=await Z(b)}let{text:f,truncated:g}=(d=e.replace(/\r\n/g,"\n").replace(/\n{4,}/g,"\n\n\n").trim()).length<=6e4?{text:d,truncated:!1}:{text:`${d.slice(0,6e4)}
5
5
 
6
- [truncated after 60000 characters]`,truncated:!0};if(!f)return{extractionError:"No extractable text found"};return{extractedText:f,truncated:g}}catch(a){return{extractionError:a instanceof Error?a.message:String(a)}}}let _=(0,e.forwardRef)(function({onSend:a,onAbort:b,onSteer:c,onFollowUp:f,isStreaming:g,model:h,modelNames:i,modelList:j,onModelChange:k,onCompact:l,onAbortCompaction:m,isCompacting:n,compactError:o,toolPreset:p,sessionKind:q,onToolPresetChange:r,memoryTools:s,onMemoryToolsChange:t,thinkingLevel:u,onThinkingLevelChange:v,availableThinkingLevels:w,thinkingLevelMap:x,retryInfo:y,soundEnabled:z,onSoundToggle:A,planMode:B,onPlanModeChange:C,cornerBadge:E,promptHistory:F,sessionHistoryKey:G,activeFilePath:H,onDismissFileContext:I},J){let K,L,V,[W,X]=(0,e.useState)(""),[Y,Z]=(0,e.useState)(!1),[_,aa]=(0,e.useState)(null),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)(!1),[af,ag]=(0,e.useState)(!1),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),[al,am]=(0,e.useState)(null),[an,ao]=(0,e.useState)([]),[ap,aq]=(0,e.useState)([]),ar=function(a=768){let[b,c]=(0,e.useState)(!1);return b}(),as=ar?{display:"none"}:void 0,at=ar?28:32,au=ar?"6px 8px":"8px 12px",av=ar?160:180,aw=ar&&!g,ax=aj?"var(--text)":"var(--text-muted)",ay={padding:"7px 8px",borderRadius:8,background:"var(--bg-panel)",border:"1px solid var(--border)",width:"100%",textAlign:"left",cursor:"pointer"},az=ar?{position:"sticky",bottom:0,zIndex:30,padding:"8px 0 calc(env(safe-area-inset-bottom, 0px) + 8px)",background:"linear-gradient(to top, color-mix(in srgb, var(--bg) 96%, transparent), color-mix(in srgb, var(--bg) 86%, transparent))",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",borderTop:"1px solid color-mix(in srgb, var(--border) 65%, transparent)"}:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:52},[aA,aB]=(0,e.useState)(null),aC=(0,e.useRef)(null),aD=(0,e.useRef)(null),aE=(0,e.useRef)(null),aF=(0,e.useRef)(null),aG=(0,e.useRef)(null),aH=(0,e.useRef)(null),aI=(0,e.useRef)(null),aJ=(0,e.useRef)(null),aK=(0,e.useRef)(null),aL=(0,e.useRef)(null),aM=(0,e.useCallback)(a=>{let b=aC.current;if(!b)return void X(b=>b+(b?" ":"")+a);let c=b.selectionStart??b.value.length,d=b.selectionEnd??b.value.length,e=b.value.slice(0,c),f=b.value.slice(d),g=!(e.length>0)||e.endsWith(" ")||e.endsWith("\n")?"":" ";X(e+g+a+f),requestAnimationFrame(()=>{let b=aC.current;if(!b)return;let d=c+g.length+a.length;b.setSelectionRange(d,d),b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`})},[]);(0,e.useImperativeHandle)(J,()=>({insertIfEmpty(a){let b=aC.current;(b?b.value:W).trim()||(X(a),requestAnimationFrame(()=>{b&&(b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)}))},insertText(a){aM(a)},addImages(a){aN(a)},addFiles(a){aO(a)}}));let aN=(0,e.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/"));if(!b.length)return;let c=await Promise.all(b.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{b({data:d.result.split(",")[1],mimeType:a.type,previewUrl:URL.createObjectURL(a)})},d.onerror=c,d.readAsDataURL(a)})));ao(a=>[...a,...c])},[]),aO=(0,e.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/")),c=a.filter(a=>!a.type.startsWith("image/"));if(b.length&&aN(b),c.length){let a=await Promise.all(c.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=async()=>{let c=d.result,e=await $(a,c);b({data:c,fileName:a.name,mimeType:a.type||"application/octet-stream",size:a.size,...e})},d.onerror=c,d.readAsArrayBuffer(a)})));aq(b=>[...b,...a])}},[aN]),aP=(0,e.useCallback)(a=>{ao(b=>{let c=[...b];return URL.revokeObjectURL(c[a].previewUrl),c.splice(a,1),c})},[]),aQ=(0,e.useCallback)(a=>{aq(b=>{let c=[...b];return c.splice(a,1),c})},[]),aR=(0,e.useCallback)(()=>{ao(a=>(a.forEach(a=>URL.revokeObjectURL(a.previewUrl)),[])),aq([])},[]),aS=j&&j.length>0?j.map(a=>({provider:a.provider,modelId:a.id,name:a.name,input:a.input})):Object.entries(i??{}).map(([a,b])=>({provider:h?.provider??"unknown",modelId:a,name:b})),aT=[];for(let a of aS){let b=aT.find(b=>b.provider===a.provider);b?b.options.push(a):aT.push({provider:a.provider,options:[a]})}let aU=h?aS.find(a=>a.modelId===h.modelId&&a.provider===h.provider)?.name??h.modelId:aS.length>0?aS[0].name:null,aV=h?aS.find(a=>a.modelId===h.modelId&&a.provider===h.provider):aS[0],aW=aV?.input?.includes("image")??!0,aX=an.length>0&&aV?.input!==void 0&&!aW,aY=(!!W.trim()||an.length>0||ap.length>0)&&!aX,aZ=l?T:T.filter(a=>"/compact"!==a.command),a$=aZ.filter(a=>"native"===a.kind),a_=aZ.filter(a=>"shortcut"===a.kind),a0=s??[],a1=a0.length>0?`${a0.length} enabled`:"off",a2=aS.length>0&&!!aU&&!!k,a3=!!v,a4=!!r&&"workbench"!==q,a5=!!t,a6=aU??"Default",a7=(()=>{let a=u??"auto";if("auto"===a||!x)return a;let b=x[a];return null!=b?b:a})(),a8=(p??"full")==="workbench"?"workbench":Object.entries(O).find(([,a])=>a===(p??"full"))?.[0]??"full",a9=ar?26:32,ba=ar?7:9,bb=ar?3:6,bc={position:"fixed",left:8,right:8,bottom:"calc(env(safe-area-inset-bottom, 0px) + 8px)",zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 -6px 24px rgba(0,0,0,0.14)",overflow:"hidden",maxHeight:"min(60dvh, 420px)"},bd=ar&&(Y||ab||ad||af||ah||aj);(0,e.useEffect)(()=>{aX||aB(null)},[aX]);let be=(0,e.useCallback)(a=>{if(!W.trim()){X(a),requestAnimationFrame(()=>{let b=aC.current;b&&(b.focus(),b.setSelectionRange(a.length,a.length),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)});return}aM(a)},[aM,W]),bf=(0,e.useCallback)(()=>{let b=W.trim();if(b||an.length||ap.length){if(an.length&&!aW)return void aB("当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。");if(!g){if("/compact"===b&&!an.length&&!ap.length&&l){n?m?.():l(),X(""),aC.current&&(aC.current.style.height="auto");return}a(b,an.length?an:void 0,ap.length?ap:void 0),X(""),aR(),aC.current&&(aC.current.style.height="auto")}}},[W,an,ap,aW,g,a,aR,l,m,n]),bg=(0,e.useCallback)(a=>{let b=W.trim();if(!b&&!an.length&&!ap.length)return;if(an.length&&!aW)return void aB("当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。");let d=an.length?an:void 0,e=ap.length?ap:void 0;"steer"===a&&c?c(b,d,e):"followup"===a&&f&&f(b,d,e),X(""),aR(),aC.current&&(aC.current.style.height="auto")},[W,an,ap,aW,c,f,aR]),bh=F??[],bi=G??null,bj=(0,e.useCallback)(a=>{if("ArrowUp"===a.key&&!a.shiftKey&&!a.ctrlKey&&!a.metaKey&&bh.length>0){let b=aC.current;if(!b)return;let c=b.selectionStart??0;if(b.value.slice(0,c).includes("\n"))return;a.preventDefault();let d=function(a,b,c){let d;if(!a||0===c.length)return null;let e=((d=M.get(a))||(d={cursor:-1,draftSnapshot:""},M.set(a,d)),d);if(-1===e.cursor)e.draftSnapshot=b,e.cursor=0;else{if(!(e.cursor<c.length-1))return null;e.cursor+=1}return c[e.cursor]??null}(bi,b.value,bh);null!==d&&(X(d),requestAnimationFrame(()=>{b.setSelectionRange(d.length,d.length)}));return}if("ArrowDown"===a.key&&!a.shiftKey&&!a.ctrlKey&&!a.metaKey&&function(a){if(!a)return!1;let b=M.get(a);return(b?.cursor??-1)>=0}(bi)){a.preventDefault();let b=function(a,b){if(!a)return null;let c=M.get(a);if(!c||-1===c.cursor)return null;if(c.cursor>0)return c.cursor-=1,{text:b[c.cursor]??"",returnedToPresent:!1};let d=c.draftSnapshot;return c.cursor=-1,c.draftSnapshot="",{text:d,returnedToPresent:!0}}(bi,bh);b&&(X(b.text),b.returnedToPresent&&requestAnimationFrame(()=>{let a=aC.current;a&&a.setSelectionRange(b.text.length,b.text.length)}));return}"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),bi&&M.set(bi,{cursor:-1,draftSnapshot:""}),g&&(c||f)?bg(c?"steer":"followup"):bf())},[g,c,f,bg,bf,bh,bi]),bk=(0,e.useCallback)(()=>{let a=aC.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,200)}px`)},[]),bl=(0,e.useCallback)(a=>{let b=Array.from(a.clipboardData?.items??[]).filter(a=>"file"===a.kind&&(a.type.startsWith("image/")||a.type.includes("pdf")||a.type.includes("officedocument")||a.type.includes("msword")||a.type.includes("ms-")));b.length&&(a.preventDefault(),aO(b.map(a=>a.getAsFile()).filter(a=>null!==a)))},[aO]);return(0,e.useEffect)(()=>{if(!Y&&!ab&&!ad&&!af&&!ah&&!aj)return;let a=a=>{let b=a.target;if(!(b instanceof Node))return;let c=!!aD.current?.contains(b),d=!!aE.current?.contains(b);c||d||Z(!1),aF.current?.contains(b)||ac(!1),aG.current?.contains(b)||ae(!1),aH.current?.contains(b)||ag(!1),aI.current?.contains(b)||ai(!1),aJ.current?.contains(b)||ak(!1)};return document.addEventListener("pointerdown",a,!0),()=>{document.removeEventListener("pointerdown",a,!0)}},[Y,ab,ad,af,ah,aj]),(0,e.useEffect)(()=>{if(!r)return;let a=!1;return fetch("/api/subagents/status").then(a=>a.ok?a.json():null).then(b=>{a||am(!!b?.ready)}).catch(()=>{a||am(!1)}),()=>{a=!0}},[r]),(0,d.jsxs)("div",{style:az,children:[bd&&(0,d.jsx)("div",{"aria-hidden":!0,onClick:()=>{Z(!1),ac(!1),ae(!1),ag(!1),ai(!1),ak(!1)},style:{position:"fixed",inset:0,zIndex:490,background:"rgba(15, 23, 42, 0.18)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)"}}),(0,d.jsx)("input",{ref:aK,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:a=>{aN(Array.from(a.target.files??[])),a.target.value=""}}),(0,d.jsx)("input",{ref:aL,type:"file",accept:".pdf,.docx,.xlsx,.pptx,.doc,.xls,.ppt,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,style:{display:"none"},onChange:a=>{aO(Array.from(a.target.files??[])),a.target.value=""}}),(0,d.jsxs)("div",{style:{maxWidth:ar?"100%":820,margin:"0 auto",position:"relative",width:"100%",padding:ar?"0 8px":void 0,boxSizing:"border-box"},children:[E&&(0,d.jsx)("div",{style:{position:"absolute",right:8,top:-22,display:"flex",alignItems:"center",justifyContent:"flex-end",maxWidth:"min(320px, 60vw)",minHeight:18,zIndex:2,fontFamily:"var(--font-mono)",overflow:"hidden"},children:E}),y&&(0,d.jsxs)("div",{style:{marginBottom:ar?6:8,padding:ar?"4px 8px":"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:ar?11:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,d.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",y.attempt,"/",y.maxAttempts,")…",y.errorMessage&&(0,d.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",y.errorMessage]})]}),H&&(0,d.jsxs)("div",{style:{marginBottom:ar?6:8,padding:ar?"3px 8px":"4px 10px",background:"color-mix(in srgb, var(--accent) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--accent) 25%, transparent)",borderRadius:6,fontSize:ar?11:12,color:"var(--text-muted)",display:"inline-flex",alignItems:"center",gap:6,maxWidth:"100%"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,d.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H.replace(/^.*[\\/]/,"")}),I&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),I()},title:"Stop including this file in context",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:14,lineHeight:1,padding:"0 2px",flexShrink:0},children:"\xd7"})]}),(an.length>0||ap.length>0)&&(0,d.jsxs)("div",{style:{marginBottom:6},children:[(0,d.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"flex-end"},children:[an.map((a,b)=>(0,d.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,d.jsx)("img",{src:a.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:`1px solid ${aX?"rgba(220,38,38,0.45)":"var(--border)"}`,display:"block"}}),(0,d.jsx)("button",{onClick:()=>aP(b),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,d.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},`img-${b}`)),ap.map((a,b)=>(0,d.jsx)(U,{doc:a,onRemove:()=>aQ(b)},`doc-${b}`))]}),(aX||aA)&&(0,d.jsxs)("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:6,fontSize:ar?11:12,color:"rgba(185,28,28,0.95)"},children:[(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,d.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,d.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),(0,d.jsx)("span",{children:aA??"当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。"})]})]}),(0,d.jsxs)("div",{style:{display:"flex",gap:ar?4:8,alignItems:ar?"flex-end":"center",background:"var(--bg)",border:`1px solid ${g&&(c||f)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:ar?13:14,padding:ar?"8px 8px 8px 10px":"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,d.jsx)("textarea",{ref:aC,value:W,onChange:a=>X(a.target.value),onKeyDown:bj,onInput:bk,onPaste:bl,placeholder:g&&(c||f)?"Steer 立即注入 / Follow-up 排队…":g?"Agent is running…":"Message…",rows:1,style:{flex:1,alignSelf:ar?"stretch":void 0,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto",paddingTop:+!!ar,paddingBottom:+!!ar}}),g?(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:ar?4:6,flexShrink:0,alignSelf:"flex-end"},children:[c&&(0,d.jsxs)("button",{onClick:()=>bg("steer"),disabled:!aY,title:aX?"当前模型不支持图片输入":"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5*!ar,padding:ar?"6px 8px":"7px 12px",background:aY?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:aY?"rgba(180,130,0,1)":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,d.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),!ar&&"Steer"]}),f&&(0,d.jsxs)("button",{onClick:()=>bg("followup"),disabled:!aY,title:aX?"当前模型不支持图片输入":"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5*!ar,padding:ar?"6px 8px":"7px 12px",background:aY?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:aY?"rgba(99,102,241,1)":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,d.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,d.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),!ar&&"Follow-up"]})]}):(0,d.jsxs)("button",{onClick:bf,disabled:!aY,title:aX?"当前模型不支持图片输入":"Send",style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:ar?3:6,padding:ar?"5px 9px":"7px 14px",marginBottom:+!!ar,background:aY?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:aY?"#fff":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:ar?11:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:aY?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,d.jsxs)("svg",{width:ar?13:14,height:ar?13:14,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,d.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,d.jsxs)("div",{className:"chat-input-toolbar",style:{marginTop:ar?5:8,display:"flex",alignItems:ar?"flex-start":"center",gap:bb,flexWrap:ar?"wrap":"nowrap"},children:[(0,d.jsxs)("div",{className:"chat-input-toolbar-left",style:{flex:ar?"1 1 100%":"0 0 auto",width:ar?"100%":void 0,display:"flex",alignItems:"center",gap:2*!ar,flexWrap:ar?"wrap":"nowrap",rowGap:4*!!ar},children:[(0,d.jsx)("button",{onClick:()=>aK.current?.click(),disabled:g,title:"Attach image (right-click for document)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:a9,height:a9,padding:0,background:"none",border:"none",borderRadius:ba,color:an.length||ap.length?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=an.length||ap.length?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=an.length||ap.length?"var(--accent)":"var(--text-muted)"},onContextMenu:a=>{a.preventDefault(),aL.current?.click()},children:(0,d.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),(0,d.jsxs)("div",{ref:aF,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>{g||(ac(a=>!a),ae(!1),Z(!1),ag(!1),ai(!1),ak(!1))},disabled:g,title:"插入斜杠命令",style:{position:"relative",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:a9,height:a9,padding:0,background:ab?"var(--bg-hover)":"none",border:"none",borderRadius:ba,color:o?"#ef4444":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,fontSize:15,fontWeight:700,fontFamily:"var(--font-mono)",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=o?"#ef4444":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ab?"var(--bg-hover)":"none",a.currentTarget.style.color=o?"#ef4444":"var(--text-muted)"},children:["/",o&&(0,d.jsx)("span",{style:{position:"absolute",top:7,right:7,width:5,height:5,borderRadius:"50%",background:"#ef4444"}})]}),ab&&(0,d.jsxs)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:100,minWidth:320,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)"},overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:o?"1px solid var(--border)":"none"},children:"Commands"}),o&&(0,d.jsx)("div",{style:{padding:"7px 10px",fontSize:11,color:"#ef4444",background:"rgba(239,68,68,0.06)",borderBottom:"1px solid var(--border)",lineHeight:1.45},children:o}),a$.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Native"}),a$.map(a=>(0,d.jsxs)("button",{onClick:()=>{(ac(!1),"/compact"===a.command&&n)?m?.():be(a.command)},style:{display:"flex",alignItems:"center",gap:ar?6:8,width:"100%",padding:au,background:"none",border:"none",color:"/compact"===a.command&&n?"#ef4444":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsx)("span",{style:{width:18,flexShrink:0,display:"flex",justifyContent:"center",color:"/compact"===a.command&&n?"#ef4444":"var(--text-dim)"},children:"/compact"===a.command&&n?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,d.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}):(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,d.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,d.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,d.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]})}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:"/compact"===a.command&&n?"停止压缩":a.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:"/compact"===a.command&&n?"中止当前压缩任务":a.description})]})]},a.command))]}),a_.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{style:{marginTop:2*(a$.length>0),padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:a$.length>0?"1px solid var(--border)":"none"},children:"Prompt Shortcuts"}),a_.map(a=>(0,d.jsxs)("button",{onClick:()=>{ac(!1),be(a.command)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:au,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsx)("span",{style:{width:18,flexShrink:0,display:"flex",justifyContent:"center",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:13},children:"/"}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:a.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:a.description})]})]},a.command))]})]})]}),t&&(0,d.jsxs)("div",{ref:aG,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>{g||(ae(a=>!a),ac(!1),Z(!1),ag(!1),ai(!1),ak(!1))},disabled:g,title:"选择 retain / recall / reflect",style:{position:"relative",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:38,height:at,padding:0,background:ad?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:a0.length>0?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,fontSize:13,fontWeight:700,fontFamily:"var(--font-mono)",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=a0.length>0?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ad?"var(--bg-hover)":"none",a.currentTarget.style.color=a0.length>0?"var(--accent)":"var(--text-muted)"},children:[" >_".trim(),a0.length>0&&(0,d.jsx)("span",{style:{position:"absolute",top:7,right:7,width:5,height:5,borderRadius:"50%",background:"currentColor"}})]}),ad&&(0,d.jsxs)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:100,minWidth:280,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)"},overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:"1px solid var(--border)"},children:"Memory Tools"}),D.map(a=>{let b=a0.includes(a),c=Q[a];return(0,d.jsxs)("button",{onClick:()=>{t(b?a0.filter(b=>b!==a):[...a0,a])},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:au,background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:c.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:c.description})]})]},a)})]})]}),a2&&(0,d.jsxs)("div",{ref:aD,style:{position:"relative",flex:ar?"1 1 160px":void 0,minWidth:0},children:[(0,d.jsxs)("button",{onClick:a=>{if(!ar){let b=a.currentTarget.getBoundingClientRect();aa({top:b.top,left:b.left,width:b.width})}ac(!1),ae(!1),ag(!1),ai(!1),ak(!1),Z(a=>!a)},disabled:g,style:{display:"flex",alignItems:"center",gap:6,padding:au,height:at,width:ar?"100%":void 0,maxWidth:ar?"100%":220,overflow:"hidden",background:Y?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=Y?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,d.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,d.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,d.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,d.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,d.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,d.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,d.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,d.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:aU})]}),Y&&(ar?(0,d.jsxs)("div",{ref:aE,style:{...bc,display:"flex",flexDirection:"column"},children:[(0,d.jsxs)("div",{style:{padding:"8px 12px 6px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,d.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Models"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:aU})]}),(0,d.jsx)("div",{style:{overflowY:"auto"},children:aT.map((a,b)=>(0,d.jsxs)("div",{children:[aT.length>1&&(0,d.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===h?.modelId&&a.provider===h?.provider;return(0,d.jsxs)("button",{onClick:()=>{Z(!1),b||k(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"10px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,whiteSpace:"normal",lineHeight:1.35},children:a.name}),a.input?.includes("image")&&(0,d.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontFamily:"var(--font-mono)",marginLeft:8},children:"image"})]},`${a.provider}:${a.modelId}`)})]},a.provider))})]}):_&&(L=(K=window.visualViewport?.height??window.innerHeight)-_.top+6,V=Math.max(120,Math.min(_.top-8,.6*K)),(0,d.jsx)("div",{ref:aE,style:{position:"fixed",bottom:L,left:_.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:_.width,maxHeight:V,overflowY:"auto"},children:aT.map((a,b)=>(0,d.jsxs)("div",{children:[aT.length>1&&(0,d.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===h?.modelId&&a.provider===h?.provider;return(0,d.jsxs)("button",{onClick:()=>{Z(!1),b||k(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,minWidth:0},children:a.name}),a.input?.includes("image")&&(0,d.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontFamily:"var(--font-mono)",marginLeft:12},children:"image"})]},`${a.provider}:${a.modelId}`)})]},a.provider))})))]}),ar&&!g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{ref:aJ,style:{position:"relative",flexShrink:0},children:[(0,d.jsx)("button",{onClick:()=>{ac(!1),ae(!1),Z(!1),ag(!1),ai(!1),ak(a=>!a)},title:"更多设置",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:aj?"var(--bg-hover)":"none",border:"none",borderRadius:8,color:ax,cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background=aj?"var(--bg-hover)":"none",a.currentTarget.style.color=aj?"var(--text)":"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"19",cy:"12",r:"1.5"})]})}),aj&&(0,d.jsxs)("div",{style:{...bc,zIndex:510,padding:"6px",display:"flex",flexDirection:"column",gap:4},children:[(0,d.jsx)("div",{style:{padding:"4px 6px 2px",fontSize:10,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"More"}),(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"0 6px 4px"},children:"模型、推理、工具等设置已收进这里。"}),(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[a2&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),ai(!1),ag(!1),ae(!1),Z(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Model"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2,wordBreak:"break-word",lineHeight:1.35},children:a6})]}),(a3||a4)&&(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4},children:[a3&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ag(!1),ae(!1),ai(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Thinking"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a7})]}),a4&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ae(!1),ag(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Tools"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a8})]})]}),a5&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ag(!1),ae(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Memory"}),(0,d.jsx)("div",{style:{fontSize:12,color:a0.length>0?"var(--accent)":"var(--text)",marginTop:2},children:a1})]}),void 0!==C&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),C(!B)},style:{...ay,border:B?"1px solid rgba(59,130,246,0.24)":"none",background:B?"rgba(59,130,246,0.06)":"none"},children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Mode"}),(0,d.jsx)("div",{style:{fontSize:12,color:B?"#3b82f6":"var(--text)",marginTop:2},children:B?"Plan(只读规划)":"Code(可执行)"})]})]})]})]}),(0,d.jsx)("button",{onClick:A,title:z?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:"none",border:"none",borderRadius:8,color:z?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:z?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=z?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=z?"1":"0.55"},children:z?(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,d.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,d.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]}),(0,d.jsx)("div",{className:"chat-input-toolbar-spacer",style:{display:aw?"none":void 0,flex:ar?"0 0 auto":1,width:ar?0:void 0,height:ar?0:void 0}}),(0,d.jsxs)("div",{className:"chat-input-toolbar-right",style:{flex:"0 0 auto",width:ar?"auto":void 0,display:"flex",alignItems:"center",gap:ar?4:2,marginLeft:ar?0:"auto",marginTop:0},children:[aw&&!ar&&(0,d.jsxs)("div",{ref:aJ,style:{position:"relative"},children:[(0,d.jsx)("button",{onClick:()=>{ac(!1),ae(!1),Z(!1),ag(!1),ai(!1),ak(a=>!a)},title:"更多设置",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:aj?"var(--bg-hover)":"none",border:"none",borderRadius:8,color:ax,cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background=aj?"var(--bg-hover)":"none",a.currentTarget.style.color=aj?"var(--text)":"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"19",cy:"12",r:"1.5"})]})}),aj&&(0,d.jsxs)("div",{style:{...bc,zIndex:510,padding:"6px",display:"flex",flexDirection:"column",gap:4},children:[(0,d.jsx)("div",{style:{padding:"4px 6px 2px",fontSize:10,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"More"}),(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"0 6px 4px"},children:"模型、推理、工具等设置已收进这里。"}),(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[a2&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),ai(!1),ag(!1),ae(!1),Z(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Model"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2,wordBreak:"break-word",lineHeight:1.35},children:a6})]}),(a3||a4)&&(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4},children:[a3&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ag(!1),ae(!1),ai(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Thinking"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a7})]}),a4&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ae(!1),ag(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Tools"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a8})]})]}),a5&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ag(!1),ae(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Memory"}),(0,d.jsx)("div",{style:{fontSize:12,color:a0.length>0?"var(--accent)":"var(--text)",marginTop:2},children:a1})]})]})]})]}),(!aw&&!g||ar&&ah)&&v&&(0,d.jsxs)("div",{ref:aI,style:{position:"relative"},children:[!aw&&!g&&(0,d.jsxs)("button",{onClick:()=>{g||(ac(!1),ae(!1),Z(!1),ag(!1),ak(!1),ai(a=>!a))},disabled:g,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:ar?3:5,padding:au,height:at,background:ah?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ah?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,d.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,d.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,d.jsx)("span",{style:as,children:(()=>{let a=u??"auto";if("auto"===a||!x)return a;let b=x[a];return null!=b?b:a})()})]}),ah&&(0,d.jsx)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",minWidth:av},overflow:"hidden"},children:R.filter(a=>!w||"auto"===a||w.includes(a)).map(a=>{let b=(u??"auto")===a,c=S[a],e="auto"!==a&&x?x[a]:void 0,f=null!=e&&e!==a?e:a,g=null!=e&&e!==a;return(0,d.jsxs)("button",{onClick:()=>{ai(!1),b||v(a)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsxs)("span",{style:{flex:1},children:[f,g&&(0,d.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",a,")"]})]}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:c})]},a)})})]}),(!aw&&!g||ar&&af)&&a4&&(0,d.jsxs)("div",{ref:aH,style:{position:"relative"},children:[!aw&&!g&&(0,d.jsxs)("button",{onClick:()=>{g||(ac(!1),ae(!1),Z(!1),ai(!1),ak(!1),ag(a=>!a))},disabled:g,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:ar?3:5,padding:au,height:at,background:af?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:(p??"full")==="workbench"?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=(p??"full")==="workbench"?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=af?"var(--bg-hover)":"none",a.currentTarget.style.color=(p??"full")==="workbench"?"var(--accent)":"var(--text-muted)"},children:[(0,d.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,d.jsx)("span",{style:as,children:a8})]}),af&&(0,d.jsx)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",minWidth:120},overflow:"hidden"},children:N.map(a=>{let b=O[a],c=(p??"full")===b,e="agent"===a&&!1===al,f=e?"需安装 pi-subagents":P[a];return(0,d.jsxs)("button",{onClick:()=>{!e&&(ag(!1),c||r(b))},disabled:e,title:e?"运行 pi install npm:pi-subagents 后再启用":void 0,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:c?"var(--bg-selected)":"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:ar?11:12,textAlign:"left",fontWeight:c?600:400,opacity:e?.5:1,whiteSpace:"nowrap"},onMouseEnter:a=>{c||e||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{c||(a.currentTarget.style.background="none")},children:[c?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1},children:a}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:f})]},a)})})]}),g&&(0,d.jsxs)("button",{onClick:b,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:at,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:ar?8:9,color:"#ef4444",cursor:"pointer",fontSize:ar?11:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,d.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),!aw&&void 0!==C&&(0,d.jsxs)("button",{onClick:()=>{g||C(!B)},disabled:g,title:B?"切换到 Code 模式(可执行代码)":"切换到 Plan 模式(只读规划)",style:{display:"flex",alignItems:"center",gap:6,padding:au,height:at,background:B?"rgba(59,130,246,0.08)":"none",border:B?"1px solid rgba(59,130,246,0.24)":"none",borderRadius:ar?8:9,color:B?"#3b82f6":"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background=B?"rgba(59,130,246,0.14)":"var(--bg-hover)",a.currentTarget.style.color=B?"#3b82f6":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=B?"rgba(59,130,246,0.08)":"none",a.currentTarget.style.color=B?"#3b82f6":"var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,d.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),(0,d.jsx)("span",{style:as,children:B?"Plan":"Code"})]}),!ar&&void 0!==A&&(0,d.jsx)("button",{onClick:A,title:z?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:ar?28:32,height:ar?28:32,padding:0,background:"none",border:"none",borderRadius:ar?8:9,color:z?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:z?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=z?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=z?"1":"0.55"},children:z?(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,d.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,d.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]})]})});function aa(a){return"user"===a.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function ab({messages:a,streamingMessage:b,scrollContainer:c,messageRefs:f}){let[g,h]=(0,e.useState)(0),[i,j]=(0,e.useState)(1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),s=(0,e.useRef)(!1),t=(0,e.useRef)(null),u=(0,e.useMemo)(()=>b?[...a,b]:a,[a,b]),v=(0,e.useRef)(u);v.current=u;let w=(0,e.useRef)(null);w.current=()=>{let a=c.current;if(!a)return;let b=a.scrollHeight,d=a.clientHeight,e=b-d;l(e>20),e<=0?(h(0),j(1)):(h(a.scrollTop/e),j(d/b));let g=f.current,i=[],k=0,m=v.current;for(let c=0;c<m.length;c++){let d=m[c];if("user"!==d.role&&"assistant"!==d.role)continue;let e=g?.[k];if(k++,("user"===d.role||"assistant"===d.role&&(d.content??[]).some(a=>"text"===a.type))&&e&&b>0){let c=e.getBoundingClientRect(),f=a.getBoundingClientRect(),g=c.top-f.top+a.scrollTop,h=c.height;i.push({topRatio:g/b,heightRatio:h/b,msg:d,index:i.length})}}n(i)},(0,e.useCallback)(()=>w.current(),[]);let x=(0,e.useCallback)(a=>{let b=c.current;if(!b)return;let d=b.scrollHeight-b.clientHeight;d<=0||(b.scrollTop=Math.max(0,Math.min(1-i,a))/(1-i)*d)},[c,i]),y=(0,e.useCallback)(a=>{if(!k)return;s.current=!0;let b=a.currentTarget.getBoundingClientRect(),c=(a.clientY-b.top)/b.height,d=c-g*(1-i),e=d>=0&&d<=i?d:i/2;x(c-e);let f=a=>{s.current&&x((a.clientY-b.top)/b.height-e)},h=()=>{s.current=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h)};window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[k,i,g,x]),z=t.current?.clientHeight??600,A=(0,e.useMemo)(()=>{if(!o||0===m.length)return[];let a=m.map(a=>Math.round(a.topRatio*z-11));for(let b=0;b<10;b++){for(let b=1;b<a.length;b++){let c=a[b-1]+22+2;a[b]<c&&(a[b]=c)}for(let b=a.length-2;b>=0;b--){let c=a[b+1]-22-2;a[b]>c&&(a[b]=c)}}for(let b=0;b<a.length;b++)a[b]=Math.max(0,Math.min(z-22,a[b]));return a},[o,m,z]);if(!k)return null;let B=g*(1-i)*100,C=100*i,D=null!==q&&m.length>0?m.reduce((a,b)=>Math.abs(b.topRatio-q)<Math.abs(m[a].topRatio-q)?b.index:a,0):null;return(0,d.jsxs)("div",{ref:t,onMouseDown:y,onMouseEnter:()=>p(!0),onMouseLeave:()=>{p(!1),r(null)},onMouseMove:a=>{let b=a.currentTarget.getBoundingClientRect();r((a.clientY-b.top)/b.height)},style:{width:36,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,d.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${B}%`,height:`${C}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),m.map(a=>{let b=aa(a.msg),c=o&&D===a.index,e="user"===a.msg.role,f=100*a.topRatio;return(0,d.jsx)("div",{style:{position:"absolute",top:`${f}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,d.jsx)("div",{style:{width:e?8:6,height:e?8:6,borderRadius:e?2:"50%",background:b.bg,border:`1.5px solid ${b.border}`,flexShrink:0,transition:"transform 0.1s",transform:c?"scale(1.6)":"scale(1)"}})},a.index)}),(0,d.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),o&&m.map((a,b)=>{let c=function(a){if("user"===a.role){let b=a.content;return"string"==typeof b?b.slice(0,200):Array.isArray(b)?b.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("\n").slice(0,200):""}if("assistant"===a.role){let b=a.content??[],c=b.filter(a=>"text"===a.type).map(a=>a.text).join(" ");if(c)return c.slice(0,200);let d=b.filter(a=>"toolCall"===a.type).map(a=>a.toolName);if(d.length)return d.join(", ")}return""}(a.msg),e=aa(a.msg),f=D===a.index;return c&&0!==A.length?(0,d.jsx)("div",{style:{position:"absolute",top:A[b],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${f?e.border:"var(--border)"}`,borderRight:`1px solid ${f?e.border:"var(--border)"}`,borderBottom:`1px solid ${f?e.border:"var(--border)"}`,borderLeft:`2px solid ${e.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:f?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,d.jsx)("div",{style:{fontSize:11,color:f?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c})},a.index):null})]})}function ac(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function ad(a,b=220){if(!a)return;let c=a.trim();if(c)return c.length>b?`${c.slice(0,b)}...`:c}function ae(...a){for(let b of a)if("string"==typeof b&&b.trim())return b}function af(...a){for(let b of a)if("number"==typeof b&&Number.isFinite(b))return b}function ag(a){let b=new Map;for(let c of a){if("custom"===c.role&&"subagent-notify"===c.customType&&"string"==typeof c.content){let a=c.content.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*(?:\s+\((.+?)\))?/);if(a){let d=`bg-${a[2]}-${c.timestamp??""}`;b.set(d,{id:d,agent:a[2],status:a[1],task:a[3],summary:ad(c.content.split("\n").slice(3).join("\n")),timestamp:c.timestamp})}}if("assistant"===c.role){let a=c.content;if(!a)continue;for(let d of a)if("toolCall"===d.type&&"subagent"===d.toolName&&d.input){let a=d.input,e=a.agent??(a.chain?"chain":a.tasks?"parallel":a.action??"subagent"),f="string"==typeof a.task?a.task:void 0,g=d.toolCallId??`sub-${e}-${c.timestamp??Date.now()}`;b.set(g,{id:g,agent:e,status:"running",task:f,timestamp:c.timestamp})}}if("toolResult"===c.role){if(c.toolName&&"subagent"!==c.toolName||!c.toolCallId||!b.has(c.toolCallId))continue;let a=b.get(c.toolCallId),d=c.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n");b.set(c.toolCallId,function(a,b,c){let d;if(!ac(b))return{...a,summary:ad(c)};let e=Array.isArray(b.results)?b.results.filter(ac):[],f=e[0],g=f?.progressSummary,h=f&&(d=f.artifactPaths)?Object.values(d).filter(a=>"string"==typeof a&&a.trim().length>0):[],i=ae(f?.finalOutput,f?.output,c);return{...a,mode:ae(b.mode),runId:ae(b.runId),agent:ae(f?.agent,a.agent)??a.agent,task:ae(f?.task,a.task),summary:ad(i),model:ae(f?.model),durationMs:af(g?.durationMs),toolCount:af(g?.toolCount),tokens:af(g?.tokens),outputPath:ae(f?.savedOutputPath,f?.artifactPaths?.outputPath),sessionFile:ae(f?.sessionFile,f?.artifactPaths?.jsonlPath),artifacts:h,resultCount:e.length||void 0}}({...a,status:function(a){if(a.isError)return"failed";let b=a.details;return ac(b)&&Array.isArray(b.results)&&b.results.some(a=>ac(a)&&"number"==typeof a.exitCode&&0!==a.exitCode)?"failed":"completed"}(c)},c.details,d))}}return Array.from(b.values()).sort((a,b)=>(b.timestamp??0)-(a.timestamp??0))}function ah({messages:a,runs:b}){let c=(0,e.useMemo)(()=>ag(a??[]),[a]),f=b??c,g=f.filter(a=>"running"===a.status),h=f.filter(a=>"running"!==a.status);return 0===f.length?null:(0,d.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:12},children:[g.length>0&&(0,d.jsx)(ai,{title:`Active (${g.length})`,runs:g}),h.length>0&&(0,d.jsx)(ai,{title:`Completed (${h.length})`,runs:h,compact:g.length>0})]})}function ai({title:a,runs:b,compact:c}){return(0,d.jsxs)("div",{style:{marginBottom:c?10:16},children:[(0,d.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em"},children:a}),b.map(a=>(0,d.jsx)(aj,{run:a},a.id))]})}function aj({run:a}){let[b,c]=(0,e.useState)(!1),f="running"===a.status,g="completed"===a.status?"#22c55e":"failed"===a.status?"#ef4444":f?"var(--accent)":"var(--text-dim)",h="failed"===a.status?"rgba(248,113,113,0.35)":f?"rgba(99,102,241,0.25)":"var(--border)",i="failed"===a.status?"rgba(248,113,113,0.05)":f?"rgba(99,102,241,0.05)":"var(--bg-panel)",j=[a.mode,a.resultCount&&a.resultCount>1?`${a.resultCount} results`:void 0,void 0!==a.toolCount?`${a.toolCount} tools`:void 0,void 0!==a.tokens?`${a.tokens.toLocaleString()} tok`:void 0,void 0!==a.durationMs?`${Math.round(a.durationMs/1e3)}s`:void 0].filter(Boolean).join(" \xb7 "),k=!!(a.summary||a.outputPath||a.sessionFile||a.artifacts?.length||a.model||a.runId);return(0,d.jsxs)("div",{style:{borderRadius:6,border:`1px solid ${h}`,background:i,marginBottom:6,fontSize:12,overflow:"hidden"},children:[(0,d.jsxs)("button",{onClick:()=>k&&c(a=>!a),style:{display:"flex",alignItems:"center",gap:7,width:"100%",border:"none",background:"transparent",padding:"8px 10px",color:"var(--text-muted)",textAlign:"left",cursor:k?"pointer":"default"},children:[(0,d.jsx)(ak,{running:f,color:g}),(0,d.jsx)("span",{style:{fontWeight:650,color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.agent}),(0,d.jsx)("span",{style:{color:g,fontSize:10,fontWeight:700,flexShrink:0},children:a.status}),j&&(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,marginLeft:"auto",whiteSpace:"nowrap"},children:j}),k&&(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:b?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),a.task&&(0,d.jsx)("div",{style:{padding:"0 10px 8px 25px",color:"var(--text-muted)",fontSize:11,lineHeight:1.4},children:ad(a.task,150)}),b&&k&&(0,d.jsxs)("div",{style:{borderTop:`1px solid ${h}`,background:"var(--bg)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:7},children:[a.summary&&(0,d.jsx)("pre",{style:{margin:0,color:"var(--text-muted)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:160,overflow:"auto"},children:a.summary}),(0,d.jsx)(al,{run:a})]})]})}function ak({running:a,color:b}){return(0,d.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:b,display:"inline-block",animation:a?"pulse 1.5s infinite":void 0,flexShrink:0}})}function al({run:a}){let b=[a.model?["model",a.model]:void 0,a.runId?["run",a.runId]:void 0,a.outputPath?["output",a.outputPath]:void 0,a.sessionFile?["session",a.sessionFile]:void 0,...(a.artifacts??[]).slice(0,4).map((a,b)=>[`artifact ${b+1}`,a])].filter(Boolean);return 0===b.length?null:(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:b.map(([a,b])=>(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"58px minmax(0, 1fr)",gap:6,fontSize:10},children:[(0,d.jsx)("span",{style:{color:"var(--text-dim)",textTransform:"uppercase"},children:a}),(0,d.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b})]},`${a}:${b}`))})}function am({sessionKind:a,toolPreset:b,initialSourcePath:c,initialKernel:e,isNew:f,isStreaming:g=!1,onResume:h,onDismiss:i}){if(f||"workbench"!==a)return null;let j=c?c.replace(/\\/g,"/").split("/").filter(Boolean).pop()??c:null,k="workbench"===b;return(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",background:"rgba(37,99,235,0.06)",borderBottom:"1px solid rgba(37,99,235,0.18)",fontSize:12,flexShrink:0},children:[(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M4 19V5"}),(0,d.jsx)("path",{d:"M4 19h16"}),(0,d.jsx)("path",{d:"m7 16 3-5 4 3 4-7"})]}),(0,d.jsxs)("span",{style:{color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["This is an ",(0,d.jsxs)("strong",{children:[k?"active":"inactive"," Workbench"]})," session",j&&(0,d.jsxs)("span",{style:{color:"var(--text-muted)"},children:[" \xb7 Source: ",(0,d.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--accent)"},children:j})]}),e&&(0,d.jsxs)("span",{style:{color:"var(--text-dim)"},children:[" \xb7 Kernel: ",e.toUpperCase()]})]}),(0,d.jsx)("div",{style:{flex:1}}),(0,d.jsx)("button",{type:"button",onClick:i,style:{border:"1px solid var(--border)",borderRadius:6,padding:"2px 10px",height:26,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"Dismiss"}),(0,d.jsx)("button",{type:"button",onClick:h,disabled:g,title:g?"Wait until the agent finishes before updating Workbench":k?"Reload the initial data source into the warm runtime":"Restore Workbench tools and reload the initial data source",style:{border:"1px solid rgba(37,99,235,0.45)",borderRadius:6,padding:"2px 12px",height:26,background:"rgba(37,99,235,0.12)",color:"var(--accent)",cursor:g?"not-allowed":"pointer",fontSize:11,fontWeight:600,opacity:g?.55:1,whiteSpace:"nowrap"},children:k?"Reload Initial Data":"Resume Workbench"})]})}function an(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>("object"!=typeof a||null===a||Array.isArray(a)||"toolCall"!==a.type?null:{type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input})??a);return{...a,content:c}}async function ao(a,b){let c=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);return d.data}var ap=c(31343);async function aq(a,b){if(!b.length)return[];let c=await fetch("/api/images/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,images:b.map(a=>({data:a.data,mimeType:a.mimeType,name:a.name}))})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`Upload failed (HTTP ${c.status})`);return(d.uploaded??[]).map((a,c)=>({...a,previewUrl:b[c]?.previewUrl}))}async function ar(a,b,c){let d=new TextDecoder,e="",f=new Promise(a=>{c?.aborted?a():c?.addEventListener("abort",()=>a(),{once:!0})});for(;;){let c=await Promise.race([a.read(),f.then(()=>({done:!0,value:void 0}))]);if(c.done)break;let g=(e+=d.decode(c.value,{stream:!0})).split("\n");for(let a of(e=g.pop()||"",g)){if(!a.startsWith("data: "))continue;let c=a.slice(6);if("[DONE]"!==c)try{b(c)}catch{}}}if(e.trim())for(let a of e.split("\n")){if(!a.startsWith("data: "))continue;let c=a.slice(6);if("[DONE]"!==c)try{b(c)}catch{}}}let as="__annovibeStreamSessions__",at="__annovibeStreamListeners__",au="__annovibeStreamErrorCallbacks__";function av(){let a=globalThis;return a[as]||(a[as]=new Map),a[as]}function aw(){let a=globalThis;return a[au]||(a[au]=new Map),a[au]}function ax(a){return{sessionId:a,phase:"idle",startedAt:null,lastEventAt:null,lastHeartbeatAt:null,reconnectCount:0,lastSyncReason:null,accumulatedText:"",toolCalls:[],toolResults:[],statusText:null,streamingMessage:null,isStreaming:!1,error:null}}function ay(a,b){let c;for(let d of(!(c=globalThis)[at]&&(c[at]=new Map),c[at]).get(a)??[])try{d(b)}catch{}}function az(a){a.textThrottleTimer&&(clearTimeout(a.textThrottleTimer),a.textThrottleTimer=null),a.textDirty&&(a.textDirty=!1,aB(a))}function aA(a,b=!1){let c=Date.now();if(a.snapshot.lastEventAt=c,!b){a.textDirty=!0,a.textThrottleTimer||(a.textThrottleTimer=setTimeout(()=>{a.textThrottleTimer=null,a.textDirty&&(a.textDirty=!1,aB(a))},100));return}az(a),aB(a)}function aB(a,b){let c=Date.now(),d=function(a){let b=[];for(let c of a.toolCalls.values())b.push({type:"toolCall",toolCallId:c.toolCallId,toolName:c.toolName,input:c.input??{}});let c=a.accumulatedText.trim();return c&&b.push({type:"text",text:c}),b}(a),e=(b??a.snapshot.phase)==="active";a.snapshot={...a.snapshot,phase:b??a.snapshot.phase,lastEventAt:c,accumulatedText:a.accumulatedText,toolCalls:[...a.toolCalls.values()],toolResults:[...a.toolResults.values()],statusText:e?function(a){if(a.activeToolId){let b=a.toolCalls.get(a.activeToolId);if(b){let a=Math.max(0,Math.floor((Date.now()-b.startedAt)/1e3));return`Running ${b.toolName||"tool"}… (${a}s)`}}return a.accumulatedText.trim()?"Generating response…":a.toolCalls.size>0?"Finishing tool results…":null}(a):a.snapshot.statusText,streamingMessage:e&&d.length>0?{role:"assistant",content:d}:null,isStreaming:e},ay(a.snapshot.sessionId,{type:"snapshot-updated",snapshot:a.snapshot})}function aC(a){aD(a),a.idleCheckTimer=setInterval(()=>{if("connected"!==a.connectionState)return;let b=Math.max(a.snapshot.lastEventAt??0,a.snapshot.lastHeartbeatAt??0);if(Date.now()-b>=18e4){aE(a),az(a);let b="Stream idle timeout — no activity for 180s.";a.snapshot={...a.snapshot,phase:"error",isStreaming:!1,streamingMessage:null,statusText:null,error:b},aD(a),ay(a.snapshot.sessionId,{type:"error",snapshot:a.snapshot});let c=aw().get(a.snapshot.sessionId);if(c)try{c(a.snapshot.sessionId,b)}catch{}}},1e4)}function aD(a){a.idleCheckTimer&&(clearInterval(a.idleCheckTimer),a.idleCheckTimer=null)}function aE(a){a.toolProgressTimer&&(clearInterval(a.toolProgressTimer),a.toolProgressTimer=null)}function aF(a){let b=av(),c=b.get(a);return c||(c={snapshot:ax(a),accumulatedText:"",toolCalls:new Map,toolResults:new Map,toolProgressTimer:null,activeToolId:null,textThrottleTimer:null,textDirty:!1,connectionState:"idle",idleCheckTimer:null},b.set(a,c)),c}function aG(a,b){let c=aw();return c.set(a,b),()=>{c.get(a)===b&&c.delete(a)}}function aH(a){let b=av(),c=b.get(a);c&&(aE(c),aD(c),az(c)),b.delete(a)}function aI(a,b){switch(b.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:b.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return a}}function aJ(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}-${Math.random().toString(36).slice(2,11)}`}let aK=["read","bash","grep","find","ls"];function aL(a,b){return a.trim()||0!==b?`text:${a}|images:${b}`:null}function aM(a){return"string"==typeof a?aL(a,0):Array.isArray(a)?aL(a.filter(a=>!!a&&"object"==typeof a&&"text"===a.type&&"string"==typeof a.text).map(a=>a.text).join("\n"),a.filter(a=>!!a&&"object"==typeof a&&"image"===a.type).length):null}function aN(a){let b=new Map;for(let c of a){let a="user"!==c.role?null:aM(c.content);a&&b.set(a,(b.get(a)??0)+1)}return b}function aO(a,b,c){return a.sessionId===b&&(!a.leafId||c.includes(a.leafId))}let aP=["image/","application/pdf","application/vnd.openxmlformats-officedocument","application/msword","application/vnd.ms-"];function aQ(a){return aP.some(b=>a.type.startsWith(b))}function aR({agentPhase:a,startedAt:b}){let[c,f]=(0,e.useState)(0);return(0,d.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,d.jsxs)("span",{className:"animate-[pulse_1.5s_infinite]",children:[function(a){if(a?.kind==="running_tools"){let b=a.tools.map(a=>a.args??a.name);return 0===b.length?"Running tool…":1===b.length?`Running ${b[0]}…`:`Running ${b.slice(0,2).join(", ")}${b.length>2?` (+${b.length-2})`:""}…`}return a?.kind==="waiting_model"?"Waiting for model…":"Working…"}(a),"\xa0\xa0",function(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);return`${b}m ${String(a%60).padStart(2,"0")}s`}(c)]})})}function aS(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function aT({goal:a,planTasks:b,isRunning:c,onExecutePlan:f,onContinuePlanning:g,onEditPlan:h}){let[i,j]=(0,e.useState)(!1),k=(0,e.useCallback)(()=>j(a=>!a),[]),l=a&&"dropped"!==a.status,m=b&&b.length>0;if(!l&&!m)return null;let n=(0,e.useMemo)(()=>!a?.tokenBudget||a.tokenBudget<=0?null:Math.min(100,Math.round(a.tokensUsed/a.tokenBudget*100)),[a?.tokenBudget,a?.tokensUsed]),o=b?.filter(a=>"completed"===a.status).length??0,p=!!b&&o===b.length;return(0,d.jsxs)("div",{style:{marginBottom:16,borderRadius:10,border:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"hidden"},children:[l&&(0,d.jsxs)("div",{style:{padding:"10px 14px",borderBottom:m?"1px solid var(--border)":"none"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[(0,d.jsx)("span",{style:{flexShrink:0,borderRadius:4,padding:"1px 6px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"#fff",background:function(a){switch(a){case"active":return"rgba(37,99,235,0.85)";case"complete":return"rgba(34,197,94,0.85)";case"budget-limited":return"rgba(245,158,11,0.85)";case"paused":return"rgba(148,163,184,0.85)";case"dropped":return"rgba(239,68,68,0.85)"}}(a.status)},children:function(a){switch(a){case"active":return"进行中";case"paused":return"已暂停";case"budget-limited":return"预算受限";case"complete":return"已完成";case"dropped":return"已放弃"}}(a.status)}),(0,d.jsx)("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-muted)"},children:"Goal"})]}),(0,d.jsx)("p",{style:{margin:"0 0 6px",fontSize:13,lineHeight:1.5,color:"var(--text)",whiteSpace:"pre-wrap"},children:a.objective}),(0,d.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 16px",fontSize:11,color:"var(--text-muted)"},children:[(0,d.jsx)("span",{children:function(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);if(b<60)return`${b}m ${String(a%60).padStart(2,"0")}s`;let c=Math.floor(b/60);return`${c}h ${b%60}m`}(a.timeUsedSeconds)}),(0,d.jsxs)("span",{children:[aS(a.tokensUsed),a.tokenBudget?` / ${aS(a.tokenBudget)} tokens`:" tokens"]}),null!=n&&(0,d.jsxs)("span",{children:[n,"%"]})]}),null!=n&&(0,d.jsx)("div",{style:{marginTop:6,height:3,borderRadius:999,overflow:"hidden",background:"var(--border)"},children:(0,d.jsx)("div",{style:{height:"100%",borderRadius:999,background:n>=100?"rgba(239,68,68,0.6)":"rgba(37,99,235,0.5)",width:`${Math.min(n,100)}%`,transition:"width 0.3s"}})})]}),m&&(0,d.jsxs)("div",{style:{padding:"4px 14px 10px"},children:[(0,d.jsxs)("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&k()},"aria-expanded":!i,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,cursor:"pointer",padding:"6px 0"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,d.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),(0,d.jsxs)("span",{style:{fontSize:12,fontWeight:500,color:"#3b82f6"},children:["Plan \xb7 ",b.length," 步"]}),p&&(0,d.jsxs)("span",{style:{borderRadius:4,padding:"0 6px",fontSize:10,fontWeight:600,background:"rgba(34,197,94,0.12)",color:"rgba(34,197,94,0.85)"},children:["已完成 ",o,"/",b.length]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(h||g||f)&&(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[h&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),h()},disabled:c,style:{borderRadius:5,padding:"3px 8px",fontSize:11,fontWeight:500,color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border)",cursor:c?"not-allowed":"pointer",opacity:c?.55:1},children:"修改计划"}),g&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),g()},disabled:c,style:{borderRadius:5,padding:"3px 8px",fontSize:11,fontWeight:500,color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border)",cursor:c?"not-allowed":"pointer",opacity:c?.55:1},children:"继续规划"}),f&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),f()},disabled:c,style:{borderRadius:5,padding:"3px 10px",fontSize:11,fontWeight:500,color:"#fff",background:c?"rgba(59,130,246,0.3)":"#3b82f6",border:"none",cursor:c?"not-allowed":"pointer"},children:"执行计划"})]}),(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:i?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"6 9 12 15 18 9"})})]})]}),!i&&(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:b.map(a=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,borderRadius:4,padding:"3px 8px",background:"inProgress"===a.status?"rgba(59,130,246,0.04)":"transparent"},children:[(0,d.jsx)("div",{style:{marginTop:1},children:function(a){switch(a){case"completed":return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgba(34,197,94,0.12)",stroke:"rgba(34,197,94,0.6)",strokeWidth:"1.5"}),(0,d.jsx)("path",{d:"M7 12.5l3 3 7-7",stroke:"rgba(34,197,94,0.9)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});case"inProgress":return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(59,130,246,0.2)",strokeWidth:"2.5"}),(0,d.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"rgba(59,130,246,0.85)",strokeWidth:"2.5",strokeLinecap:"round",children:(0,d.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"1.5s",repeatCount:"indefinite"})})]});default:return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"var(--border)",strokeWidth:"1.5"})})}}(a.status)}),(0,d.jsx)("span",{style:{fontSize:12,lineHeight:1.5,...function(a){switch(a){case"completed":return{color:"rgba(34,197,94,0.85)",textDecoration:"line-through"};case"inProgress":return{color:"#3b82f6",fontWeight:500};default:return{color:"var(--text-muted)"}}}(a.status)},children:a.step})]},a.id))})]})]})}let aU=["annotate and analyze.","vibe code bioinformatics.","turn data into figures.","inspect your project.","build a reproducible report.","run R/Python plots.","summarize that paper.","review the pipeline.","compare markers.","draft methods.","find the next analysis step."];function aV({phrases:a}){let[b,c]=(0,e.useState)(()=>Math.floor(Math.random()*a.length)),[f,g]=(0,e.useState)(""),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(!0);return(0,d.jsxs)("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[f,(0,d.jsx)("span",{style:{opacity:+!!j,color:"var(--accent)",marginLeft:1},children:"▍"})]})}function aW({status:a}){let b=a?.current??"0.8.111"??"0.0.0";if(a?.updateAvailable){let c=a.latest?`v${a.latest}`:"latest";return(0,d.jsxs)("span",{title:`Current v${b}; latest ${c}; run ${a.updateCommand}`,style:{display:"block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--accent)"},children:["Update: ",(0,d.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--accent)"},children:a.updateCommand})]})}return(0,d.jsxs)("span",{title:`AnnoVibe v${b}`,style:{fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:["v",b]})}function aX({session:a,newSessionCwd:b,onAgentEnd:c,onSessionCreated:f,onSessionForked:g,modelsRefreshKey:h,chatInputRef:i,onBranchDataChange:j,onSessionStatsChange:k,onContextUsageChange:m,onToolPresetActive:n,generativeUI:o,activeFilePath:p,onOpenFileAtLine:q}){var r;let s,[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)(""),[E,K]=(0,e.useState)(!1);(0,e.useRef)(!1);let[M,N]=(0,e.useState)(!1),O=p&&!M?p:null,{data:P,loading:Q,error:R,messages:S,entryIds:T,streamState:U,agentRunning:V,modelNames:W,modelList:X,modelThinkingLevels:Y,modelThinkingLevelMaps:Z,toolPreset:$,memoryTools:aa,thinkingLevel:ac,retryInfo:ad,contextUsage:ae,forkingEntryId:af,isCompacting:ai,compactError:aj,displayModel:ak,sessionStats:al,agentPhase:as,agentError:at,isNew:au,loadMoreMessages:aw,hasMoreMessages:aB,totalMessages:aP,loadedMessagesCount:aS,messagesEndRef:aY,scrollContainerRef:aZ,lastUserMsgRef:a$,handleSend:a_,handleAbort:a0,handleFork:a1,handleNavigate:a2,handleModelChange:a3,handleCompact:a4,handleSteer:a5,handleFollowUp:a6,handleAbortCompaction:a7,handleToolPresetChange:a8,handleMemoryToolsChange:a9,handleThinkingLevelChange:ba,handleAgentEventRef:bb}=function(a){let{session:b,newSessionCwd:c,planMode:d=!1,onAgentEnd:f,onSessionCreated:g,onSessionForked:h,modelsRefreshKey:i,onBranchDataChange:j,onPlanModeState:k}=a,l=null===b&&null!==c,[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!l),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)([]),[w,x]=(0,e.useState)([]),[y,z]=(0,e.useState)(0),[A,B]=(0,e.useState)(!1),[E,K]=(0,e.useState)(0),[M,N]=(0,e.useReducer)(aI,{isStreaming:!1,streamingMessage:null}),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)({}),[S,T]=(0,e.useState)([]),[U,V]=(0,e.useState)({}),[W,X]=(0,e.useState)({}),[Y,Z]=(0,e.useState)(null),[$,_]=(0,e.useState)("full"),[aa,ab]=(0,e.useState)([...D]),[ac,ad]=(0,e.useState)("auto"),[ae,af]=(0,e.useState)(null),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(null),[ak,al]=(0,e.useState)(null),[am,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(null),[aw,aB]=(0,e.useState)(!1),[aP,aQ]=(0,e.useState)(null),[aR,aS]=(0,e.useState)(null),[aT,aU]=(0,e.useState)(null),aV=(0,e.useRef)(null),aW=(0,e.useRef)(b?.id??null),aX=(0,e.useRef)(!1),aY=(0,e.useRef)(null);(0,e.useRef)(null);let aZ=(0,e.useRef)(null),a$=(0,e.useRef)(!1),a_=(0,e.useRef)(null),a0=(0,e.useRef)(!1),a1=(0,e.useRef)(null),a2=(0,e.useRef)(null),a3=(0,e.useRef)(new Map),a4=(0,e.useRef)(new Map),a5=(0,e.useRef)(null),a6=(0,e.useRef)(null),a7=(0,e.useRef)(0),a8=a.setNewSessionModel??Z,a9=a.setToolPreset??_,ba=a.setMemoryTools??ab,bb=am??m?.context.model??at??null,bc=l?Y:bb,bd=(0,e.useCallback)(()=>d?aK:L($,aa),[aa,d,$]),be=(0,e.useCallback)(a=>a?.length?a.map((a,b)=>{let c=`Attachment ${b+1}: ${a.fileName} (${a.mimeType||"application/octet-stream"}, ${a.size} bytes)`;if(a.extractedText){let b=a.truncated?"\n[The extracted text was truncated before sending.]":"";return`${c}
6
+ [truncated after 60000 characters]`,truncated:!0};if(!f)return{extractionError:"No extractable text found"};return{extractedText:f,truncated:g}}catch(a){return{extractionError:a instanceof Error?a.message:String(a)}}}let _=(0,e.forwardRef)(function({onSend:a,onAbort:b,onSteer:c,onFollowUp:f,isStreaming:g,model:h,modelNames:i,modelList:j,onModelChange:k,onCompact:l,onAbortCompaction:m,isCompacting:n,compactError:o,toolPreset:p,sessionKind:q,onToolPresetChange:r,memoryTools:s,onMemoryToolsChange:t,thinkingLevel:u,onThinkingLevelChange:v,availableThinkingLevels:w,thinkingLevelMap:x,retryInfo:y,soundEnabled:z,onSoundToggle:A,planMode:B,onPlanModeChange:C,cornerBadge:E,promptHistory:F,sessionHistoryKey:G,activeFilePath:H,onDismissFileContext:I},J){let K,L,V,[W,X]=(0,e.useState)(""),[Y,Z]=(0,e.useState)(!1),[_,aa]=(0,e.useState)(null),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)(!1),[af,ag]=(0,e.useState)(!1),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),[al,am]=(0,e.useState)(null),[an,ao]=(0,e.useState)([]),[ap,aq]=(0,e.useState)([]),ar=function(a=768){let[b,c]=(0,e.useState)(!1);return b}(),as=ar?{display:"none"}:void 0,at=ar?28:32,au=ar?"6px 8px":"8px 12px",av=ar?160:180,aw=ar&&!g,ax=aj?"var(--text)":"var(--text-muted)",ay={padding:"7px 8px",borderRadius:8,background:"var(--bg-panel)",border:"1px solid var(--border)",width:"100%",textAlign:"left",cursor:"pointer"},az=ar?{position:"sticky",bottom:0,zIndex:30,padding:"8px 0 calc(env(safe-area-inset-bottom, 0px) + 8px)",background:"linear-gradient(to top, color-mix(in srgb, var(--bg) 96%, transparent), color-mix(in srgb, var(--bg) 86%, transparent))",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",borderTop:"1px solid color-mix(in srgb, var(--border) 65%, transparent)"}:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:52},[aA,aB]=(0,e.useState)(null),aC=(0,e.useRef)(null),aD=(0,e.useRef)(null),aE=(0,e.useRef)(null),aF=(0,e.useRef)(null),aG=(0,e.useRef)(null),aH=(0,e.useRef)(null),aI=(0,e.useRef)(null),aJ=(0,e.useRef)(null),aK=(0,e.useRef)(null),aL=(0,e.useRef)(null),aM=(0,e.useCallback)(a=>{let b=aC.current;if(!b)return void X(b=>b+(b?" ":"")+a);let c=b.selectionStart??b.value.length,d=b.selectionEnd??b.value.length,e=b.value.slice(0,c),f=b.value.slice(d),g=!(e.length>0)||e.endsWith(" ")||e.endsWith("\n")?"":" ";X(e+g+a+f),requestAnimationFrame(()=>{let b=aC.current;if(!b)return;let d=c+g.length+a.length;b.setSelectionRange(d,d),b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`})},[]);(0,e.useImperativeHandle)(J,()=>({insertIfEmpty(a){let b=aC.current;(b?b.value:W).trim()||(X(a),requestAnimationFrame(()=>{b&&(b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)}))},insertText(a){aM(a)},addImages(a){aN(a)},addFiles(a){aO(a)}}));let aN=(0,e.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/"));if(!b.length)return;let c=await Promise.all(b.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{b({data:d.result.split(",")[1],mimeType:a.type,previewUrl:URL.createObjectURL(a)})},d.onerror=c,d.readAsDataURL(a)})));ao(a=>[...a,...c])},[]),aO=(0,e.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/")),c=a.filter(a=>!a.type.startsWith("image/"));if(b.length&&aN(b),c.length){let a=await Promise.all(c.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=async()=>{let c=d.result,e=await $(a,c);b({data:c,fileName:a.name,mimeType:a.type||"application/octet-stream",size:a.size,...e})},d.onerror=c,d.readAsArrayBuffer(a)})));aq(b=>[...b,...a])}},[aN]),aP=(0,e.useCallback)(a=>{ao(b=>{let c=[...b];return URL.revokeObjectURL(c[a].previewUrl),c.splice(a,1),c})},[]),aQ=(0,e.useCallback)(a=>{aq(b=>{let c=[...b];return c.splice(a,1),c})},[]),aR=(0,e.useCallback)(()=>{ao(a=>(a.forEach(a=>URL.revokeObjectURL(a.previewUrl)),[])),aq([])},[]),aS=j&&j.length>0?j.map(a=>({provider:a.provider,modelId:a.id,name:a.name,input:a.input})):Object.entries(i??{}).map(([a,b])=>({provider:h?.provider??"unknown",modelId:a,name:b})),aT=[];for(let a of aS){let b=aT.find(b=>b.provider===a.provider);b?b.options.push(a):aT.push({provider:a.provider,options:[a]})}let aU=h?aS.find(a=>a.modelId===h.modelId&&a.provider===h.provider)?.name??h.modelId:aS.length>0?aS[0].name:null,aV=h?aS.find(a=>a.modelId===h.modelId&&a.provider===h.provider):aS[0],aW=aV?.input?.includes("image")??!0,aX=an.length>0&&aV?.input!==void 0&&!aW,aY=(!!W.trim()||an.length>0||ap.length>0)&&!aX,aZ=l?T:T.filter(a=>"/compact"!==a.command),a$=aZ.filter(a=>"native"===a.kind),a_=aZ.filter(a=>"shortcut"===a.kind),a0=s??[],a1=a0.length>0?`${a0.length} enabled`:"off",a2=aS.length>0&&!!aU&&!!k,a3=!!v,a4=!!r&&"workbench"!==q,a5=!!t,a6=aU??"Default",a7=(()=>{let a=u??"auto";if("auto"===a||!x)return a;let b=x[a];return null!=b?b:a})(),a8=(p??"full")==="workbench"?"workbench":Object.entries(O).find(([,a])=>a===(p??"full"))?.[0]??"full",a9=ar?26:32,ba=ar?7:9,bb=ar?3:6,bc={position:"fixed",left:8,right:8,bottom:"calc(env(safe-area-inset-bottom, 0px) + 8px)",zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 -6px 24px rgba(0,0,0,0.14)",overflow:"hidden",maxHeight:"min(60dvh, 420px)"},bd=ar&&(Y||ab||ad||af||ah||aj);(0,e.useEffect)(()=>{aX||aB(null)},[aX]);let be=(0,e.useCallback)(a=>{if(!W.trim()){X(a),requestAnimationFrame(()=>{let b=aC.current;b&&(b.focus(),b.setSelectionRange(a.length,a.length),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)});return}aM(a)},[aM,W]),bf=(0,e.useCallback)(()=>{let b=W.trim();if(b||an.length||ap.length){if(an.length&&!aW)return void aB("当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。");if(!g){if("/compact"===b&&!an.length&&!ap.length&&l){n?m?.():l(),X(""),aC.current&&(aC.current.style.height="auto");return}a(b,an.length?an:void 0,ap.length?ap:void 0),X(""),aR(),aC.current&&(aC.current.style.height="auto")}}},[W,an,ap,aW,g,a,aR,l,m,n]),bg=(0,e.useCallback)(a=>{let b=W.trim();if(!b&&!an.length&&!ap.length)return;if(an.length&&!aW)return void aB("当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。");let d=an.length?an:void 0,e=ap.length?ap:void 0;"steer"===a&&c?c(b,d,e):"followup"===a&&f&&f(b,d,e),X(""),aR(),aC.current&&(aC.current.style.height="auto")},[W,an,ap,aW,c,f,aR]),bh=F??[],bi=G??null,bj=(0,e.useCallback)(a=>{if("ArrowUp"===a.key&&!a.shiftKey&&!a.ctrlKey&&!a.metaKey&&bh.length>0){let b=aC.current;if(!b)return;let c=b.selectionStart??0;if(b.value.slice(0,c).includes("\n"))return;a.preventDefault();let d=function(a,b,c){let d;if(!a||0===c.length)return null;let e=((d=M.get(a))||(d={cursor:-1,draftSnapshot:""},M.set(a,d)),d);if(-1===e.cursor)e.draftSnapshot=b,e.cursor=0;else{if(!(e.cursor<c.length-1))return null;e.cursor+=1}return c[e.cursor]??null}(bi,b.value,bh);null!==d&&(X(d),requestAnimationFrame(()=>{b.setSelectionRange(d.length,d.length)}));return}if("ArrowDown"===a.key&&!a.shiftKey&&!a.ctrlKey&&!a.metaKey&&function(a){if(!a)return!1;let b=M.get(a);return(b?.cursor??-1)>=0}(bi)){a.preventDefault();let b=function(a,b){if(!a)return null;let c=M.get(a);if(!c||-1===c.cursor)return null;if(c.cursor>0)return c.cursor-=1,{text:b[c.cursor]??"",returnedToPresent:!1};let d=c.draftSnapshot;return c.cursor=-1,c.draftSnapshot="",{text:d,returnedToPresent:!0}}(bi,bh);b&&(X(b.text),b.returnedToPresent&&requestAnimationFrame(()=>{let a=aC.current;a&&a.setSelectionRange(b.text.length,b.text.length)}));return}"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),bi&&M.set(bi,{cursor:-1,draftSnapshot:""}),g&&(c||f)?bg(c?"steer":"followup"):bf())},[g,c,f,bg,bf,bh,bi]),bk=(0,e.useCallback)(()=>{let a=aC.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,200)}px`)},[]),bl=(0,e.useCallback)(a=>{let b=Array.from(a.clipboardData?.items??[]).filter(a=>"file"===a.kind&&(a.type.startsWith("image/")||a.type.includes("pdf")||a.type.includes("officedocument")||a.type.includes("msword")||a.type.includes("ms-")));b.length&&(a.preventDefault(),aO(b.map(a=>a.getAsFile()).filter(a=>null!==a)))},[aO]);return(0,e.useEffect)(()=>{if(!Y&&!ab&&!ad&&!af&&!ah&&!aj)return;let a=a=>{let b=a.target;if(!(b instanceof Node))return;let c=!!aD.current?.contains(b),d=!!aE.current?.contains(b);c||d||Z(!1),aF.current?.contains(b)||ac(!1),aG.current?.contains(b)||ae(!1),aH.current?.contains(b)||ag(!1),aI.current?.contains(b)||ai(!1),aJ.current?.contains(b)||ak(!1)};return document.addEventListener("pointerdown",a,!0),()=>{document.removeEventListener("pointerdown",a,!0)}},[Y,ab,ad,af,ah,aj]),(0,e.useEffect)(()=>{if(!r)return;let a=!1;return fetch("/api/subagents/status").then(a=>a.ok?a.json():null).then(b=>{a||am(!!b?.ready)}).catch(()=>{a||am(!1)}),()=>{a=!0}},[r]),(0,d.jsxs)("div",{style:az,children:[bd&&(0,d.jsx)("div",{"aria-hidden":!0,onClick:()=>{Z(!1),ac(!1),ae(!1),ag(!1),ai(!1),ak(!1)},style:{position:"fixed",inset:0,zIndex:490,background:"rgba(15, 23, 42, 0.18)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)"}}),(0,d.jsx)("input",{ref:aK,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:a=>{aN(Array.from(a.target.files??[])),a.target.value=""}}),(0,d.jsx)("input",{ref:aL,type:"file",accept:".pdf,.docx,.xlsx,.pptx,.doc,.xls,.ppt,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,style:{display:"none"},onChange:a=>{aO(Array.from(a.target.files??[])),a.target.value=""}}),(0,d.jsxs)("div",{style:{maxWidth:ar?"100%":820,margin:"0 auto",position:"relative",width:"100%",padding:ar?"0 8px":void 0,boxSizing:"border-box"},children:[E&&(0,d.jsx)("div",{style:{position:"absolute",right:8,top:-22,display:"flex",alignItems:"center",justifyContent:"flex-end",maxWidth:"min(320px, 60vw)",minHeight:18,zIndex:2,fontFamily:"var(--font-mono)",overflow:"hidden"},children:E}),y&&(0,d.jsxs)("div",{style:{marginBottom:ar?6:8,padding:ar?"4px 8px":"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:ar?11:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,d.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",y.attempt,"/",y.maxAttempts,")…",y.errorMessage&&(0,d.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",y.errorMessage]})]}),H&&(0,d.jsxs)("div",{style:{marginBottom:ar?6:8,padding:ar?"3px 8px":"4px 10px",background:"color-mix(in srgb, var(--accent) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--accent) 25%, transparent)",borderRadius:6,fontSize:ar?11:12,color:"var(--text-muted)",display:"inline-flex",alignItems:"center",gap:6,maxWidth:"100%"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,d.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H.replace(/^.*[\\/]/,"")}),I&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),I()},title:"Stop including this file in context",style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:14,lineHeight:1,padding:"0 2px",flexShrink:0},children:"\xd7"})]}),(an.length>0||ap.length>0)&&(0,d.jsxs)("div",{style:{marginBottom:6},children:[(0,d.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"flex-end"},children:[an.map((a,b)=>(0,d.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,d.jsx)("img",{src:a.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:`1px solid ${aX?"rgba(220,38,38,0.45)":"var(--border)"}`,display:"block"}}),(0,d.jsx)("button",{onClick:()=>aP(b),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,d.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},`img-${b}`)),ap.map((a,b)=>(0,d.jsx)(U,{doc:a,onRemove:()=>aQ(b)},`doc-${b}`))]}),(aX||aA)&&(0,d.jsxs)("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:6,fontSize:ar?11:12,color:"rgba(185,28,28,0.95)"},children:[(0,d.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,d.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,d.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),(0,d.jsx)("span",{children:aA??"当前模型不支持图片输入。请切换到带 image 标记的模型后再发送。"})]})]}),(0,d.jsxs)("div",{style:{display:"flex",gap:ar?4:8,alignItems:ar?"flex-end":"center",background:"var(--bg)",border:`1px solid ${g&&(c||f)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:ar?13:14,padding:ar?"8px 8px 8px 10px":"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,d.jsx)("textarea",{ref:aC,value:W,onChange:a=>X(a.target.value),onKeyDown:bj,onInput:bk,onPaste:bl,placeholder:g&&(c||f)?"Steer 立即注入 / Follow-up 排队…":g?"Agent is running…":"Message…",rows:1,style:{flex:1,alignSelf:ar?"stretch":void 0,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto",paddingTop:+!!ar,paddingBottom:+!!ar}}),g?(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:ar?4:6,flexShrink:0,alignSelf:"flex-end"},children:[c&&(0,d.jsxs)("button",{onClick:()=>bg("steer"),disabled:!aY,title:aX?"当前模型不支持图片输入":"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5*!ar,padding:ar?"6px 8px":"7px 12px",background:aY?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:aY?"rgba(180,130,0,1)":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,d.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),!ar&&"Steer"]}),f&&(0,d.jsxs)("button",{onClick:()=>bg("followup"),disabled:!aY,title:aX?"当前模型不支持图片输入":"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5*!ar,padding:ar?"6px 8px":"7px 12px",background:aY?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:aY?"rgba(99,102,241,1)":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,d.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,d.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),!ar&&"Follow-up"]})]}):(0,d.jsxs)("button",{onClick:bf,disabled:!aY,title:aX?"当前模型不支持图片输入":"Send",style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:ar?3:6,padding:ar?"5px 9px":"7px 14px",marginBottom:+!!ar,background:aY?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:aY?"#fff":"var(--text-dim)",cursor:aY?"pointer":"not-allowed",fontSize:ar?11:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:aY?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,d.jsxs)("svg",{width:ar?13:14,height:ar?13:14,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,d.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,d.jsxs)("div",{className:"chat-input-toolbar",style:{marginTop:ar?5:8,display:"flex",alignItems:ar?"flex-start":"center",gap:bb,flexWrap:ar?"wrap":"nowrap"},children:[(0,d.jsxs)("div",{className:"chat-input-toolbar-left",style:{flex:ar?"1 1 100%":"0 0 auto",width:ar?"100%":void 0,display:"flex",alignItems:"center",gap:2*!ar,flexWrap:ar?"wrap":"nowrap",rowGap:4*!!ar},children:[(0,d.jsx)("button",{onClick:()=>aK.current?.click(),disabled:g,title:"Attach image (right-click for document)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:a9,height:a9,padding:0,background:"none",border:"none",borderRadius:ba,color:an.length||ap.length?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=an.length||ap.length?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=an.length||ap.length?"var(--accent)":"var(--text-muted)"},onContextMenu:a=>{a.preventDefault(),aL.current?.click()},children:(0,d.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),(0,d.jsxs)("div",{ref:aF,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>{g||(ac(a=>!a),ae(!1),Z(!1),ag(!1),ai(!1),ak(!1))},disabled:g,title:"插入斜杠命令",style:{position:"relative",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:a9,height:a9,padding:0,background:ab?"var(--bg-hover)":"none",border:"none",borderRadius:ba,color:o?"#ef4444":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,fontSize:15,fontWeight:700,fontFamily:"var(--font-mono)",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=o?"#ef4444":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ab?"var(--bg-hover)":"none",a.currentTarget.style.color=o?"#ef4444":"var(--text-muted)"},children:["/",o&&(0,d.jsx)("span",{style:{position:"absolute",top:7,right:7,width:5,height:5,borderRadius:"50%",background:"#ef4444"}})]}),ab&&(0,d.jsxs)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:100,minWidth:320,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)"},overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:o?"1px solid var(--border)":"none"},children:"Commands"}),o&&(0,d.jsx)("div",{style:{padding:"7px 10px",fontSize:11,color:"#ef4444",background:"rgba(239,68,68,0.06)",borderBottom:"1px solid var(--border)",lineHeight:1.45},children:o}),a$.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Native"}),a$.map(a=>(0,d.jsxs)("button",{onClick:()=>{(ac(!1),"/compact"===a.command&&n)?m?.():be(a.command)},style:{display:"flex",alignItems:"center",gap:ar?6:8,width:"100%",padding:au,background:"none",border:"none",color:"/compact"===a.command&&n?"#ef4444":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsx)("span",{style:{width:18,flexShrink:0,display:"flex",justifyContent:"center",color:"/compact"===a.command&&n?"#ef4444":"var(--text-dim)"},children:"/compact"===a.command&&n?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,d.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}):(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,d.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,d.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,d.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]})}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:"/compact"===a.command&&n?"停止压缩":a.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:"/compact"===a.command&&n?"中止当前压缩任务":a.description})]})]},a.command))]}),a_.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{style:{marginTop:2*(a$.length>0),padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:a$.length>0?"1px solid var(--border)":"none"},children:"Prompt Shortcuts"}),a_.map(a=>(0,d.jsxs)("button",{onClick:()=>{ac(!1),be(a.command)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:au,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,d.jsx)("span",{style:{width:18,flexShrink:0,display:"flex",justifyContent:"center",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:13},children:"/"}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:a.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:a.description})]})]},a.command))]})]})]}),t&&(0,d.jsxs)("div",{ref:aG,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>{g||(ae(a=>!a),ac(!1),Z(!1),ag(!1),ai(!1),ak(!1))},disabled:g,title:"选择 retain / recall / reflect",style:{position:"relative",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:38,height:at,padding:0,background:ad?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:a0.length>0?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",opacity:g?.5:1,fontSize:13,fontWeight:700,fontFamily:"var(--font-mono)",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=a0.length>0?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ad?"var(--bg-hover)":"none",a.currentTarget.style.color=a0.length>0?"var(--accent)":"var(--text-muted)"},children:[" >_".trim(),a0.length>0&&(0,d.jsx)("span",{style:{position:"absolute",top:7,right:7,width:5,height:5,borderRadius:"50%",background:"currentColor"}})]}),ad&&(0,d.jsxs)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:100,minWidth:280,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)"},overflow:"hidden"},children:[(0,d.jsx)("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:"1px solid var(--border)"},children:"Memory Tools"}),D.map(a=>{let b=a0.includes(a),c=Q[a];return(0,d.jsxs)("button",{onClick:()=>{t(b?a0.filter(b=>b!==a):[...a0,a])},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:au,background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsxs)("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsx)("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:c.label}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:c.description})]})]},a)})]})]}),a2&&(0,d.jsxs)("div",{ref:aD,style:{position:"relative",flex:ar?"1 1 160px":void 0,minWidth:0},children:[(0,d.jsxs)("button",{onClick:a=>{if(!ar){let b=a.currentTarget.getBoundingClientRect();aa({top:b.top,left:b.left,width:b.width})}ac(!1),ae(!1),ag(!1),ai(!1),ak(!1),Z(a=>!a)},disabled:g,style:{display:"flex",alignItems:"center",gap:6,padding:au,height:at,width:ar?"100%":void 0,maxWidth:ar?"100%":220,overflow:"hidden",background:Y?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=Y?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,d.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,d.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,d.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,d.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,d.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,d.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,d.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,d.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:aU})]}),Y&&(ar?(0,d.jsxs)("div",{ref:aE,style:{...bc,display:"flex",flexDirection:"column"},children:[(0,d.jsxs)("div",{style:{padding:"8px 12px 6px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,d.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Models"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:aU})]}),(0,d.jsx)("div",{style:{overflowY:"auto"},children:aT.map((a,b)=>(0,d.jsxs)("div",{children:[aT.length>1&&(0,d.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===h?.modelId&&a.provider===h?.provider;return(0,d.jsxs)("button",{onClick:()=>{Z(!1),b||k(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"10px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,minWidth:0,whiteSpace:"normal",lineHeight:1.35},children:a.name}),a.input?.includes("image")&&(0,d.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontFamily:"var(--font-mono)",marginLeft:8},children:"image"})]},`${a.provider}:${a.modelId}`)})]},a.provider))})]}):_&&(L=(K=window.visualViewport?.height??window.innerHeight)-_.top+6,V=Math.max(120,Math.min(_.top-8,.6*K)),(0,d.jsx)("div",{ref:aE,style:{position:"fixed",bottom:L,left:_.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:_.width,maxHeight:V,overflowY:"auto"},children:aT.map((a,b)=>(0,d.jsxs)("div",{children:[aT.length>1&&(0,d.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===h?.modelId&&a.provider===h?.provider;return(0,d.jsxs)("button",{onClick:()=>{Z(!1),b||k(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1,minWidth:0},children:a.name}),a.input?.includes("image")&&(0,d.jsx)("span",{style:{fontSize:10,color:"var(--accent)",fontFamily:"var(--font-mono)",marginLeft:12},children:"image"})]},`${a.provider}:${a.modelId}`)})]},a.provider))})))]}),ar&&!g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{ref:aJ,style:{position:"relative",flexShrink:0},children:[(0,d.jsx)("button",{onClick:()=>{ac(!1),ae(!1),Z(!1),ag(!1),ai(!1),ak(a=>!a)},title:"更多设置",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:aj?"var(--bg-hover)":"none",border:"none",borderRadius:8,color:ax,cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background=aj?"var(--bg-hover)":"none",a.currentTarget.style.color=aj?"var(--text)":"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"19",cy:"12",r:"1.5"})]})}),aj&&(0,d.jsxs)("div",{style:{...bc,zIndex:510,padding:"6px",display:"flex",flexDirection:"column",gap:4},children:[(0,d.jsx)("div",{style:{padding:"4px 6px 2px",fontSize:10,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"More"}),(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"0 6px 4px"},children:"模型、推理、工具等设置已收进这里。"}),(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[a2&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),ai(!1),ag(!1),ae(!1),Z(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Model"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2,wordBreak:"break-word",lineHeight:1.35},children:a6})]}),(a3||a4)&&(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4},children:[a3&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ag(!1),ae(!1),ai(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Thinking"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a7})]}),a4&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ae(!1),ag(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Tools"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a8})]})]}),a5&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ag(!1),ae(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Memory"}),(0,d.jsx)("div",{style:{fontSize:12,color:a0.length>0?"var(--accent)":"var(--text)",marginTop:2},children:a1})]}),void 0!==C&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),C(!B)},style:{...ay,border:B?"1px solid rgba(59,130,246,0.24)":"none",background:B?"rgba(59,130,246,0.06)":"none"},children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Mode"}),(0,d.jsx)("div",{style:{fontSize:12,color:B?"#3b82f6":"var(--text)",marginTop:2},children:B?"Plan(只读规划)":"Code(可执行)"})]})]})]})]}),(0,d.jsx)("button",{onClick:A,title:z?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:"none",border:"none",borderRadius:8,color:z?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:z?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=z?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=z?"1":"0.55"},children:z?(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,d.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,d.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]}),(0,d.jsx)("div",{className:"chat-input-toolbar-spacer",style:{display:aw?"none":void 0,flex:ar?"0 0 auto":1,width:ar?0:void 0,height:ar?0:void 0}}),(0,d.jsxs)("div",{className:"chat-input-toolbar-right",style:{flex:"0 0 auto",width:ar?"auto":void 0,display:"flex",alignItems:"center",gap:ar?4:2,marginLeft:ar?0:"auto",marginTop:0},children:[aw&&!ar&&(0,d.jsxs)("div",{ref:aJ,style:{position:"relative"},children:[(0,d.jsx)("button",{onClick:()=>{ac(!1),ae(!1),Z(!1),ag(!1),ai(!1),ak(a=>!a)},title:"更多设置",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,padding:0,background:aj?"var(--bg-hover)":"none",border:"none",borderRadius:8,color:ax,cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background=aj?"var(--bg-hover)":"none",a.currentTarget.style.color=aj?"var(--text)":"var(--text-muted)"},children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,d.jsx)("circle",{cx:"19",cy:"12",r:"1.5"})]})}),aj&&(0,d.jsxs)("div",{style:{...bc,zIndex:510,padding:"6px",display:"flex",flexDirection:"column",gap:4},children:[(0,d.jsx)("div",{style:{padding:"4px 6px 2px",fontSize:10,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"More"}),(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"0 6px 4px"},children:"模型、推理、工具等设置已收进这里。"}),(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[a2&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),ai(!1),ag(!1),ae(!1),Z(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Model"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2,wordBreak:"break-word",lineHeight:1.35},children:a6})]}),(a3||a4)&&(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4},children:[a3&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ag(!1),ae(!1),ai(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Thinking"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a7})]}),a4&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ae(!1),ag(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Tools"}),(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text)",marginTop:2},children:a8})]})]}),a5&&(0,d.jsxs)("button",{onClick:()=>{ak(!1),Z(!1),ai(!1),ag(!1),ae(!0)},style:ay,children:[(0,d.jsx)("div",{style:{fontSize:"10px",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Memory"}),(0,d.jsx)("div",{style:{fontSize:12,color:a0.length>0?"var(--accent)":"var(--text)",marginTop:2},children:a1})]})]})]})]}),(!aw&&!g||ar&&ah)&&v&&(0,d.jsxs)("div",{ref:aI,style:{position:"relative"},children:[!aw&&!g&&(0,d.jsxs)("button",{onClick:()=>{g||(ac(!1),ae(!1),Z(!1),ag(!1),ak(!1),ai(a=>!a))},disabled:g,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:ar?3:5,padding:au,height:at,background:ah?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=ah?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,d.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,d.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,d.jsx)("span",{style:as,children:(()=>{let a=u??"auto";if("auto"===a||!x)return a;let b=x[a];return null!=b?b:a})()})]}),ah&&(0,d.jsx)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",minWidth:av},overflow:"hidden"},children:R.filter(a=>!w||"auto"===a||w.includes(a)).map(a=>{let b=(u??"auto")===a,c=S[a],e="auto"!==a&&x?x[a]:void 0,f=null!=e&&e!==a?e:a,g=null!=e&&e!==a;return(0,d.jsxs)("button",{onClick:()=>{ai(!1),b||v(a)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:ar?11:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsxs)("span",{style:{flex:1},children:[f,g&&(0,d.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",a,")"]})]}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:c})]},a)})})]}),(!aw&&!g||ar&&af)&&a4&&(0,d.jsxs)("div",{ref:aH,style:{position:"relative"},children:[!aw&&!g&&(0,d.jsxs)("button",{onClick:()=>{g||(ac(!1),ae(!1),Z(!1),ai(!1),ak(!1),ag(a=>!a))},disabled:g,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:ar?3:5,padding:au,height:at,background:af?"var(--bg-hover)":"none",border:"none",borderRadius:ar?8:9,color:(p??"full")==="workbench"?"var(--accent)":"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=(p??"full")==="workbench"?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=af?"var(--bg-hover)":"none",a.currentTarget.style.color=(p??"full")==="workbench"?"var(--accent)":"var(--text-muted)"},children:[(0,d.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,d.jsx)("span",{style:as,children:a8})]}),af&&(0,d.jsx)("div",{style:{...ar?bc:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",minWidth:120},overflow:"hidden"},children:N.map(a=>{let b=O[a],c=(p??"full")===b,e="agent"===a&&!1===al,f=e?"需安装 pi-subagents":P[a];return(0,d.jsxs)("button",{onClick:()=>{!e&&(ag(!1),c||r(b))},disabled:e,title:e?"运行 pi install npm:pi-subagents 后再启用":void 0,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:c?"var(--bg-selected)":"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:ar?11:12,textAlign:"left",fontWeight:c?600:400,opacity:e?.5:1,whiteSpace:"nowrap"},onMouseEnter:a=>{c||e||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{c||(a.currentTarget.style.background="none")},children:[c?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,d.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,d.jsx)("span",{style:{width:10,flexShrink:0}}),(0,d.jsx)("span",{style:{flex:1},children:a}),(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:f})]},a)})})]}),g&&(0,d.jsxs)("button",{onClick:b,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:at,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:ar?8:9,color:"#ef4444",cursor:"pointer",fontSize:ar?11:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,d.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),!aw&&void 0!==C&&(0,d.jsxs)("button",{onClick:()=>{g||C(!B)},disabled:g,title:B?"切换到 Code 模式(可执行代码)":"切换到 Plan 模式(只读规划)",style:{display:"flex",alignItems:"center",gap:6,padding:au,height:at,background:B?"rgba(59,130,246,0.08)":"none",border:B?"1px solid rgba(59,130,246,0.24)":"none",borderRadius:ar?8:9,color:B?"#3b82f6":"var(--text-muted)",cursor:g?"not-allowed":"pointer",fontSize:ar?11:12,opacity:g?.5:1,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{g||(a.currentTarget.style.background=B?"rgba(59,130,246,0.14)":"var(--bg-hover)",a.currentTarget.style.color=B?"#3b82f6":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=B?"rgba(59,130,246,0.08)":"none",a.currentTarget.style.color=B?"#3b82f6":"var(--text-muted)"},children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,d.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),(0,d.jsx)("span",{style:as,children:B?"Plan":"Code"})]}),!ar&&void 0!==A&&(0,d.jsx)("button",{onClick:A,title:z?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:ar?28:32,height:ar?28:32,padding:0,background:"none",border:"none",borderRadius:ar?8:9,color:z?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:z?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=z?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=z?"1":"0.55"},children:z?(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,d.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,d.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,d.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]})]})});function aa(a){return"user"===a.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function ab({messages:a,streamingMessage:b,scrollContainer:c,messageRefs:f}){let[g,h]=(0,e.useState)(0),[i,j]=(0,e.useState)(1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),s=(0,e.useRef)(!1),t=(0,e.useRef)(null),u=(0,e.useMemo)(()=>b?[...a,b]:a,[a,b]),v=(0,e.useRef)(u);v.current=u;let w=(0,e.useRef)(null);w.current=()=>{let a=c.current;if(!a)return;let b=a.scrollHeight,d=a.clientHeight,e=b-d;l(e>20),e<=0?(h(0),j(1)):(h(a.scrollTop/e),j(d/b));let g=f.current,i=[],k=0,m=v.current;for(let c=0;c<m.length;c++){let d=m[c];if("user"!==d.role&&"assistant"!==d.role)continue;let e=g?.[k];if(k++,("user"===d.role||"assistant"===d.role&&(d.content??[]).some(a=>"text"===a.type))&&e&&b>0){let c=e.getBoundingClientRect(),f=a.getBoundingClientRect(),g=c.top-f.top+a.scrollTop,h=c.height;i.push({topRatio:g/b,heightRatio:h/b,msg:d,index:i.length})}}n(i)},(0,e.useCallback)(()=>w.current(),[]);let x=(0,e.useCallback)(a=>{let b=c.current;if(!b)return;let d=b.scrollHeight-b.clientHeight;d<=0||(b.scrollTop=Math.max(0,Math.min(1-i,a))/(1-i)*d)},[c,i]),y=(0,e.useCallback)(a=>{if(!k)return;s.current=!0;let b=a.currentTarget.getBoundingClientRect(),c=(a.clientY-b.top)/b.height,d=c-g*(1-i),e=d>=0&&d<=i?d:i/2;x(c-e);let f=a=>{s.current&&x((a.clientY-b.top)/b.height-e)},h=()=>{s.current=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h)};window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[k,i,g,x]),z=t.current?.clientHeight??600,A=(0,e.useMemo)(()=>{if(!o||0===m.length)return[];let a=m.map(a=>Math.round(a.topRatio*z-11));for(let b=0;b<10;b++){for(let b=1;b<a.length;b++){let c=a[b-1]+22+2;a[b]<c&&(a[b]=c)}for(let b=a.length-2;b>=0;b--){let c=a[b+1]-22-2;a[b]>c&&(a[b]=c)}}for(let b=0;b<a.length;b++)a[b]=Math.max(0,Math.min(z-22,a[b]));return a},[o,m,z]);if(!k)return null;let B=g*(1-i)*100,C=100*i,D=null!==q&&m.length>0?m.reduce((a,b)=>Math.abs(b.topRatio-q)<Math.abs(m[a].topRatio-q)?b.index:a,0):null;return(0,d.jsxs)("div",{ref:t,onMouseDown:y,onMouseEnter:()=>p(!0),onMouseLeave:()=>{p(!1),r(null)},onMouseMove:a=>{let b=a.currentTarget.getBoundingClientRect();r((a.clientY-b.top)/b.height)},style:{width:36,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,d.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${B}%`,height:`${C}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),m.map(a=>{let b=aa(a.msg),c=o&&D===a.index,e="user"===a.msg.role,f=100*a.topRatio;return(0,d.jsx)("div",{style:{position:"absolute",top:`${f}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,d.jsx)("div",{style:{width:e?8:6,height:e?8:6,borderRadius:e?2:"50%",background:b.bg,border:`1.5px solid ${b.border}`,flexShrink:0,transition:"transform 0.1s",transform:c?"scale(1.6)":"scale(1)"}})},a.index)}),(0,d.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),o&&m.map((a,b)=>{let c=function(a){if("user"===a.role){let b=a.content;return"string"==typeof b?b.slice(0,200):Array.isArray(b)?b.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("\n").slice(0,200):""}if("assistant"===a.role){let b=a.content??[],c=b.filter(a=>"text"===a.type).map(a=>a.text).join(" ");if(c)return c.slice(0,200);let d=b.filter(a=>"toolCall"===a.type).map(a=>a.toolName);if(d.length)return d.join(", ")}return""}(a.msg),e=aa(a.msg),f=D===a.index;return c&&0!==A.length?(0,d.jsx)("div",{style:{position:"absolute",top:A[b],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${f?e.border:"var(--border)"}`,borderRight:`1px solid ${f?e.border:"var(--border)"}`,borderBottom:`1px solid ${f?e.border:"var(--border)"}`,borderLeft:`2px solid ${e.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:f?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,d.jsx)("div",{style:{fontSize:11,color:f?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c})},a.index):null})]})}function ac(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function ad(a,b=220){if(!a)return;let c=a.trim();if(c)return c.length>b?`${c.slice(0,b)}...`:c}function ae(...a){for(let b of a)if("string"==typeof b&&b.trim())return b}function af(...a){for(let b of a)if("number"==typeof b&&Number.isFinite(b))return b}function ag(a){let b=new Map;for(let c of a){if("custom"===c.role&&"subagent-notify"===c.customType&&"string"==typeof c.content){let a=c.content.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*(?:\s+\((.+?)\))?/);if(a){let d=`bg-${a[2]}-${c.timestamp??""}`;b.set(d,{id:d,agent:a[2],status:a[1],task:a[3],summary:ad(c.content.split("\n").slice(3).join("\n")),timestamp:c.timestamp})}}if("assistant"===c.role){let a=c.content;if(!a)continue;for(let d of a)if("toolCall"===d.type&&"subagent"===d.toolName&&d.input){let a=d.input,e=a.agent??(a.chain?"chain":a.tasks?"parallel":a.action??"subagent"),f="string"==typeof a.task?a.task:void 0,g=d.toolCallId??`sub-${e}-${c.timestamp??Date.now()}`;b.set(g,{id:g,agent:e,status:"running",task:f,timestamp:c.timestamp})}}if("toolResult"===c.role){if(c.toolName&&"subagent"!==c.toolName||!c.toolCallId||!b.has(c.toolCallId))continue;let a=b.get(c.toolCallId),d=c.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n");b.set(c.toolCallId,function(a,b,c){let d;if(!ac(b))return{...a,summary:ad(c)};let e=Array.isArray(b.results)?b.results.filter(ac):[],f=e[0],g=f?.progressSummary,h=f&&(d=f.artifactPaths)?Object.values(d).filter(a=>"string"==typeof a&&a.trim().length>0):[],i=ae(f?.finalOutput,f?.output,c);return{...a,mode:ae(b.mode),runId:ae(b.runId),agent:ae(f?.agent,a.agent)??a.agent,task:ae(f?.task,a.task),summary:ad(i),model:ae(f?.model),durationMs:af(g?.durationMs),toolCount:af(g?.toolCount),tokens:af(g?.tokens),outputPath:ae(f?.savedOutputPath,f?.artifactPaths?.outputPath),sessionFile:ae(f?.sessionFile,f?.artifactPaths?.jsonlPath),artifacts:h,resultCount:e.length||void 0}}({...a,status:function(a){if(a.isError)return"failed";let b=a.details;return ac(b)&&Array.isArray(b.results)&&b.results.some(a=>ac(a)&&"number"==typeof a.exitCode&&0!==a.exitCode)?"failed":"completed"}(c)},c.details,d))}}return Array.from(b.values()).sort((a,b)=>(b.timestamp??0)-(a.timestamp??0))}function ah({messages:a,runs:b}){let c=(0,e.useMemo)(()=>ag(a??[]),[a]),f=b??c,g=f.filter(a=>"running"===a.status),h=f.filter(a=>"running"!==a.status);return 0===f.length?null:(0,d.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:12},children:[g.length>0&&(0,d.jsx)(ai,{title:`Active (${g.length})`,runs:g}),h.length>0&&(0,d.jsx)(ai,{title:`Completed (${h.length})`,runs:h,compact:g.length>0})]})}function ai({title:a,runs:b,compact:c}){return(0,d.jsxs)("div",{style:{marginBottom:c?10:16},children:[(0,d.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em"},children:a}),b.map(a=>(0,d.jsx)(aj,{run:a},a.id))]})}function aj({run:a}){let[b,c]=(0,e.useState)(!1),f="running"===a.status,g="completed"===a.status?"#22c55e":"failed"===a.status?"#ef4444":f?"var(--accent)":"var(--text-dim)",h="failed"===a.status?"rgba(248,113,113,0.35)":f?"rgba(99,102,241,0.25)":"var(--border)",i="failed"===a.status?"rgba(248,113,113,0.05)":f?"rgba(99,102,241,0.05)":"var(--bg-panel)",j=[a.mode,a.resultCount&&a.resultCount>1?`${a.resultCount} results`:void 0,void 0!==a.toolCount?`${a.toolCount} tools`:void 0,void 0!==a.tokens?`${a.tokens.toLocaleString()} tok`:void 0,void 0!==a.durationMs?`${Math.round(a.durationMs/1e3)}s`:void 0].filter(Boolean).join(" \xb7 "),k=!!(a.summary||a.outputPath||a.sessionFile||a.artifacts?.length||a.model||a.runId);return(0,d.jsxs)("div",{style:{borderRadius:6,border:`1px solid ${h}`,background:i,marginBottom:6,fontSize:12,overflow:"hidden"},children:[(0,d.jsxs)("button",{onClick:()=>k&&c(a=>!a),style:{display:"flex",alignItems:"center",gap:7,width:"100%",border:"none",background:"transparent",padding:"8px 10px",color:"var(--text-muted)",textAlign:"left",cursor:k?"pointer":"default"},children:[(0,d.jsx)(ak,{running:f,color:g}),(0,d.jsx)("span",{style:{fontWeight:650,color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.agent}),(0,d.jsx)("span",{style:{color:g,fontSize:10,fontWeight:700,flexShrink:0},children:a.status}),j&&(0,d.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,marginLeft:"auto",whiteSpace:"nowrap"},children:j}),k&&(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:b?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),a.task&&(0,d.jsx)("div",{style:{padding:"0 10px 8px 25px",color:"var(--text-muted)",fontSize:11,lineHeight:1.4},children:ad(a.task,150)}),b&&k&&(0,d.jsxs)("div",{style:{borderTop:`1px solid ${h}`,background:"var(--bg)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:7},children:[a.summary&&(0,d.jsx)("pre",{style:{margin:0,color:"var(--text-muted)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:160,overflow:"auto"},children:a.summary}),(0,d.jsx)(al,{run:a})]})]})}function ak({running:a,color:b}){return(0,d.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:b,display:"inline-block",animation:a?"pulse 1.5s infinite":void 0,flexShrink:0}})}function al({run:a}){let b=[a.model?["model",a.model]:void 0,a.runId?["run",a.runId]:void 0,a.outputPath?["output",a.outputPath]:void 0,a.sessionFile?["session",a.sessionFile]:void 0,...(a.artifacts??[]).slice(0,4).map((a,b)=>[`artifact ${b+1}`,a])].filter(Boolean);return 0===b.length?null:(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:b.map(([a,b])=>(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"58px minmax(0, 1fr)",gap:6,fontSize:10},children:[(0,d.jsx)("span",{style:{color:"var(--text-dim)",textTransform:"uppercase"},children:a}),(0,d.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b})]},`${a}:${b}`))})}function am({sessionKind:a,toolPreset:b,initialSourcePath:c,initialKernel:e,isNew:f,isStreaming:g=!1,onResume:h,onDismiss:i}){if(f||"workbench"!==a)return null;let j=c?c.replace(/\\/g,"/").split("/").filter(Boolean).pop()??c:null,k="workbench"===b;return(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",background:"rgba(37,99,235,0.06)",borderBottom:"1px solid rgba(37,99,235,0.18)",fontSize:12,flexShrink:0},children:[(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,d.jsx)("path",{d:"M4 19V5"}),(0,d.jsx)("path",{d:"M4 19h16"}),(0,d.jsx)("path",{d:"m7 16 3-5 4 3 4-7"})]}),(0,d.jsxs)("span",{style:{color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["This is an ",(0,d.jsxs)("strong",{children:[k?"active":"inactive"," Workbench"]})," session",j&&(0,d.jsxs)("span",{style:{color:"var(--text-muted)"},children:[" \xb7 Source: ",(0,d.jsx)("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--accent)"},children:j})]}),e&&(0,d.jsxs)("span",{style:{color:"var(--text-dim)"},children:[" \xb7 Kernel: ",e.toUpperCase()]})]}),(0,d.jsx)("div",{style:{flex:1}}),(0,d.jsx)("button",{type:"button",onClick:i,style:{border:"1px solid var(--border)",borderRadius:6,padding:"2px 10px",height:26,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"Dismiss"}),(0,d.jsx)("button",{type:"button",onClick:h,disabled:g,title:g?"Wait until the agent finishes before updating Workbench":k?"Reload the initial data source into the warm runtime":"Restore Workbench tools and reload the initial data source",style:{border:"1px solid rgba(37,99,235,0.45)",borderRadius:6,padding:"2px 12px",height:26,background:"rgba(37,99,235,0.12)",color:"var(--accent)",cursor:g?"not-allowed":"pointer",fontSize:11,fontWeight:600,opacity:g?.55:1,whiteSpace:"nowrap"},children:k?"Reload Initial Data":"Resume Workbench"})]})}function an(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>("object"!=typeof a||null===a||Array.isArray(a)||"toolCall"!==a.type?null:{type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input})??a);return{...a,content:c}}async function ao(a,b){let c=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);return d.data}var ap=c(31343);async function aq(a,b){if(!b.length)return[];let c=await fetch("/api/images/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,images:b.map(a=>({data:a.data,mimeType:a.mimeType,name:a.name}))})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`Upload failed (HTTP ${c.status})`);return(d.uploaded??[]).map((a,c)=>({...a,previewUrl:b[c]?.previewUrl}))}async function ar(a,b,c){let d=new TextDecoder,e="",f=new Promise(a=>{c?.aborted?a():c?.addEventListener("abort",()=>a(),{once:!0})});for(;;){let c=await Promise.race([a.read(),f.then(()=>({done:!0,value:void 0}))]);if(c.done)break;let g=(e+=d.decode(c.value,{stream:!0})).split("\n");for(let a of(e=g.pop()||"",g)){if(!a.startsWith("data: "))continue;let c=a.slice(6);if("[DONE]"!==c)try{b(c)}catch{}}}if(e.trim())for(let a of e.split("\n")){if(!a.startsWith("data: "))continue;let c=a.slice(6);if("[DONE]"!==c)try{b(c)}catch{}}}let as="__annovibeStreamSessions__",at="__annovibeStreamListeners__",au="__annovibeStreamErrorCallbacks__";function av(){let a=globalThis;return a[as]||(a[as]=new Map),a[as]}function aw(){let a=globalThis;return a[au]||(a[au]=new Map),a[au]}function ax(a){return{sessionId:a,phase:"idle",startedAt:null,lastEventAt:null,lastHeartbeatAt:null,reconnectCount:0,lastSyncReason:null,accumulatedText:"",toolCalls:[],toolResults:[],statusText:null,streamingMessage:null,isStreaming:!1,error:null}}function ay(a,b){let c;for(let d of(!(c=globalThis)[at]&&(c[at]=new Map),c[at]).get(a)??[])try{d(b)}catch{}}function az(a){a.textThrottleTimer&&(clearTimeout(a.textThrottleTimer),a.textThrottleTimer=null),a.textDirty&&(a.textDirty=!1,aB(a))}function aA(a,b=!1){let c=Date.now();if(a.snapshot.lastEventAt=c,!b){a.textDirty=!0,a.textThrottleTimer||(a.textThrottleTimer=setTimeout(()=>{a.textThrottleTimer=null,a.textDirty&&(a.textDirty=!1,aB(a))},100));return}az(a),aB(a)}function aB(a,b){let c=Date.now(),d=function(a){let b=[];for(let c of a.toolCalls.values())b.push({type:"toolCall",toolCallId:c.toolCallId,toolName:c.toolName,input:c.input??{}});let c=a.accumulatedText.trim();return c&&b.push({type:"text",text:c}),b}(a),e=(b??a.snapshot.phase)==="active";a.snapshot={...a.snapshot,phase:b??a.snapshot.phase,lastEventAt:c,accumulatedText:a.accumulatedText,toolCalls:[...a.toolCalls.values()],toolResults:[...a.toolResults.values()],statusText:e?function(a){if(a.activeToolId){let b=a.toolCalls.get(a.activeToolId);if(b){let a=Math.max(0,Math.floor((Date.now()-b.startedAt)/1e3));return`Running ${b.toolName||"tool"}… (${a}s)`}}return a.accumulatedText.trim()?"Generating response…":a.toolCalls.size>0?"Finishing tool results…":null}(a):a.snapshot.statusText,streamingMessage:e&&d.length>0?{role:"assistant",content:d}:null,isStreaming:e},ay(a.snapshot.sessionId,{type:"snapshot-updated",snapshot:a.snapshot})}function aC(a){aD(a),a.idleCheckTimer=setInterval(()=>{if("connected"!==a.connectionState)return;let b=Math.max(a.snapshot.lastEventAt??0,a.snapshot.lastHeartbeatAt??0);if(Date.now()-b>=18e4){aE(a),az(a);let b="Stream idle timeout — no activity for 180s.";a.snapshot={...a.snapshot,phase:"error",isStreaming:!1,streamingMessage:null,statusText:null,error:b},aD(a),ay(a.snapshot.sessionId,{type:"error",snapshot:a.snapshot});let c=aw().get(a.snapshot.sessionId);if(c)try{c(a.snapshot.sessionId,b)}catch{}}},1e4)}function aD(a){a.idleCheckTimer&&(clearInterval(a.idleCheckTimer),a.idleCheckTimer=null)}function aE(a){a.toolProgressTimer&&(clearInterval(a.toolProgressTimer),a.toolProgressTimer=null)}function aF(a){let b=av(),c=b.get(a);return c||(c={snapshot:ax(a),accumulatedText:"",toolCalls:new Map,toolResults:new Map,toolProgressTimer:null,activeToolId:null,textThrottleTimer:null,textDirty:!1,connectionState:"idle",idleCheckTimer:null},b.set(a,c)),c}function aG(a,b){let c=aw();return c.set(a,b),()=>{c.get(a)===b&&c.delete(a)}}function aH(a){let b=av(),c=b.get(a);c&&(aE(c),aD(c),az(c)),b.delete(a)}function aI(a,b){switch(b.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:b.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return a}}function aJ(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}-${Math.random().toString(36).slice(2,11)}`}let aK=["read","bash","grep","find","ls"];function aL(a,b){return a.trim()||0!==b?`text:${a}|images:${b}`:null}function aM(a){return"string"==typeof a?aL(a,0):Array.isArray(a)?aL(a.filter(a=>!!a&&"object"==typeof a&&"text"===a.type&&"string"==typeof a.text).map(a=>a.text).join("\n"),a.filter(a=>!!a&&"object"==typeof a&&"image"===a.type).length):null}function aN(a){let b=new Map;for(let c of a){let a="user"!==c.role?null:aM(c.content);a&&b.set(a,(b.get(a)??0)+1)}return b}function aO(a,b,c){return a.sessionId===b&&(!a.leafId||c.includes(a.leafId))}let aP=["image/","application/pdf","application/vnd.openxmlformats-officedocument","application/msword","application/vnd.ms-"];function aQ(a){return aP.some(b=>a.type.startsWith(b))}function aR({agentPhase:a,startedAt:b}){let[c,f]=(0,e.useState)(0);return(0,d.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,d.jsxs)("span",{className:"animate-[pulse_1.5s_infinite]",children:[function(a){if(a?.kind==="running_tools"){let b=a.tools.map(a=>a.args??a.name);return 0===b.length?"Running tool…":1===b.length?`Running ${b[0]}…`:`Running ${b.slice(0,2).join(", ")}${b.length>2?` (+${b.length-2})`:""}…`}return a?.kind==="waiting_model"?"Waiting for model…":"Working…"}(a),"\xa0\xa0",function(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);return`${b}m ${String(a%60).padStart(2,"0")}s`}(c)]})})}function aS(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function aT({goal:a,planTasks:b,isRunning:c,onExecutePlan:f,onContinuePlanning:g,onEditPlan:h}){let[i,j]=(0,e.useState)(!1),k=(0,e.useCallback)(()=>j(a=>!a),[]),l=a&&"dropped"!==a.status,m=b&&b.length>0;if(!l&&!m)return null;let n=(0,e.useMemo)(()=>!a?.tokenBudget||a.tokenBudget<=0?null:Math.min(100,Math.round(a.tokensUsed/a.tokenBudget*100)),[a?.tokenBudget,a?.tokensUsed]),o=b?.filter(a=>"completed"===a.status).length??0,p=!!b&&o===b.length;return(0,d.jsxs)("div",{style:{marginBottom:16,borderRadius:10,border:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"hidden"},children:[l&&(0,d.jsxs)("div",{style:{padding:"10px 14px",borderBottom:m?"1px solid var(--border)":"none"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[(0,d.jsx)("span",{style:{flexShrink:0,borderRadius:4,padding:"1px 6px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"#fff",background:function(a){switch(a){case"active":return"rgba(37,99,235,0.85)";case"complete":return"rgba(34,197,94,0.85)";case"budget-limited":return"rgba(245,158,11,0.85)";case"paused":return"rgba(148,163,184,0.85)";case"dropped":return"rgba(239,68,68,0.85)"}}(a.status)},children:function(a){switch(a){case"active":return"进行中";case"paused":return"已暂停";case"budget-limited":return"预算受限";case"complete":return"已完成";case"dropped":return"已放弃"}}(a.status)}),(0,d.jsx)("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-muted)"},children:"Goal"})]}),(0,d.jsx)("p",{style:{margin:"0 0 6px",fontSize:13,lineHeight:1.5,color:"var(--text)",whiteSpace:"pre-wrap"},children:a.objective}),(0,d.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 16px",fontSize:11,color:"var(--text-muted)"},children:[(0,d.jsx)("span",{children:function(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);if(b<60)return`${b}m ${String(a%60).padStart(2,"0")}s`;let c=Math.floor(b/60);return`${c}h ${b%60}m`}(a.timeUsedSeconds)}),(0,d.jsxs)("span",{children:[aS(a.tokensUsed),a.tokenBudget?` / ${aS(a.tokenBudget)} tokens`:" tokens"]}),null!=n&&(0,d.jsxs)("span",{children:[n,"%"]})]}),null!=n&&(0,d.jsx)("div",{style:{marginTop:6,height:3,borderRadius:999,overflow:"hidden",background:"var(--border)"},children:(0,d.jsx)("div",{style:{height:"100%",borderRadius:999,background:n>=100?"rgba(239,68,68,0.6)":"rgba(37,99,235,0.5)",width:`${Math.min(n,100)}%`,transition:"width 0.3s"}})})]}),m&&(0,d.jsxs)("div",{style:{padding:"4px 14px 10px"},children:[(0,d.jsxs)("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&k()},"aria-expanded":!i,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,cursor:"pointer",padding:"6px 0"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,d.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),(0,d.jsxs)("span",{style:{fontSize:12,fontWeight:500,color:"#3b82f6"},children:["Plan \xb7 ",b.length," 步"]}),p&&(0,d.jsxs)("span",{style:{borderRadius:4,padding:"0 6px",fontSize:10,fontWeight:600,background:"rgba(34,197,94,0.12)",color:"rgba(34,197,94,0.85)"},children:["已完成 ",o,"/",b.length]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(h||g||f)&&(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[h&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),h()},disabled:c,style:{borderRadius:5,padding:"3px 8px",fontSize:11,fontWeight:500,color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border)",cursor:c?"not-allowed":"pointer",opacity:c?.55:1},children:"修改计划"}),g&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),g()},disabled:c,style:{borderRadius:5,padding:"3px 8px",fontSize:11,fontWeight:500,color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border)",cursor:c?"not-allowed":"pointer",opacity:c?.55:1},children:"继续规划"}),f&&(0,d.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),f()},disabled:c,style:{borderRadius:5,padding:"3px 10px",fontSize:11,fontWeight:500,color:"#fff",background:c?"rgba(59,130,246,0.3)":"#3b82f6",border:"none",cursor:c?"not-allowed":"pointer"},children:"执行计划"})]}),(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:i?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:(0,d.jsx)("polyline",{points:"6 9 12 15 18 9"})})]})]}),!i&&(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:b.map(a=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,borderRadius:4,padding:"3px 8px",background:"inProgress"===a.status?"rgba(59,130,246,0.04)":"transparent"},children:[(0,d.jsx)("div",{style:{marginTop:1},children:function(a){switch(a){case"completed":return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgba(34,197,94,0.12)",stroke:"rgba(34,197,94,0.6)",strokeWidth:"1.5"}),(0,d.jsx)("path",{d:"M7 12.5l3 3 7-7",stroke:"rgba(34,197,94,0.9)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});case"inProgress":return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"rgba(59,130,246,0.2)",strokeWidth:"2.5"}),(0,d.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"rgba(59,130,246,0.85)",strokeWidth:"2.5",strokeLinecap:"round",children:(0,d.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"1.5s",repeatCount:"indefinite"})})]});default:return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"var(--border)",strokeWidth:"1.5"})})}}(a.status)}),(0,d.jsx)("span",{style:{fontSize:12,lineHeight:1.5,...function(a){switch(a){case"completed":return{color:"rgba(34,197,94,0.85)",textDecoration:"line-through"};case"inProgress":return{color:"#3b82f6",fontWeight:500};default:return{color:"var(--text-muted)"}}}(a.status)},children:a.step})]},a.id))})]})]})}let aU=["annotate and analyze.","vibe code bioinformatics.","turn data into figures.","inspect your project.","build a reproducible report.","run R/Python plots.","summarize that paper.","review the pipeline.","compare markers.","draft methods.","find the next analysis step."];function aV({phrases:a}){let[b,c]=(0,e.useState)(()=>Math.floor(Math.random()*a.length)),[f,g]=(0,e.useState)(""),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(!0);return(0,d.jsxs)("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[f,(0,d.jsx)("span",{style:{opacity:+!!j,color:"var(--accent)",marginLeft:1},children:"▍"})]})}function aW({status:a}){let b=a?.current??"0.8.112"??"0.0.0";if(a?.updateAvailable){let c=a.latest?`v${a.latest}`:"latest";return(0,d.jsxs)("span",{title:`Current v${b}; latest ${c}; run ${a.updateCommand}`,style:{display:"block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--accent)"},children:["Update: ",(0,d.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--accent)"},children:a.updateCommand})]})}return(0,d.jsxs)("span",{title:`AnnoVibe v${b}`,style:{fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:["v",b]})}function aX({session:a,newSessionCwd:b,onAgentEnd:c,onSessionCreated:f,onSessionForked:g,modelsRefreshKey:h,chatInputRef:i,onBranchDataChange:j,onSessionStatsChange:k,onContextUsageChange:m,onToolPresetActive:n,generativeUI:o,activeFilePath:p,onOpenFileAtLine:q}){var r;let s,[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)(""),[E,K]=(0,e.useState)(!1);(0,e.useRef)(!1);let[M,N]=(0,e.useState)(!1),O=p&&!M?p:null,{data:P,loading:Q,error:R,messages:S,entryIds:T,streamState:U,agentRunning:V,modelNames:W,modelList:X,modelThinkingLevels:Y,modelThinkingLevelMaps:Z,toolPreset:$,memoryTools:aa,thinkingLevel:ac,retryInfo:ad,contextUsage:ae,forkingEntryId:af,isCompacting:ai,compactError:aj,displayModel:ak,sessionStats:al,agentPhase:as,agentError:at,isNew:au,loadMoreMessages:aw,hasMoreMessages:aB,totalMessages:aP,loadedMessagesCount:aS,messagesEndRef:aY,scrollContainerRef:aZ,lastUserMsgRef:a$,handleSend:a_,handleAbort:a0,handleFork:a1,handleNavigate:a2,handleModelChange:a3,handleCompact:a4,handleSteer:a5,handleFollowUp:a6,handleAbortCompaction:a7,handleToolPresetChange:a8,handleMemoryToolsChange:a9,handleThinkingLevelChange:ba,handleAgentEventRef:bb}=function(a){let{session:b,newSessionCwd:c,planMode:d=!1,onAgentEnd:f,onSessionCreated:g,onSessionForked:h,modelsRefreshKey:i,onBranchDataChange:j,onPlanModeState:k}=a,l=null===b&&null!==c,[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!l),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)([]),[w,x]=(0,e.useState)([]),[y,z]=(0,e.useState)(0),[A,B]=(0,e.useState)(!1),[E,K]=(0,e.useState)(0),[M,N]=(0,e.useReducer)(aI,{isStreaming:!1,streamingMessage:null}),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)({}),[S,T]=(0,e.useState)([]),[U,V]=(0,e.useState)({}),[W,X]=(0,e.useState)({}),[Y,Z]=(0,e.useState)(null),[$,_]=(0,e.useState)("full"),[aa,ab]=(0,e.useState)([...D]),[ac,ad]=(0,e.useState)("auto"),[ae,af]=(0,e.useState)(null),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(null),[ak,al]=(0,e.useState)(null),[am,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(null),[aw,aB]=(0,e.useState)(!1),[aP,aQ]=(0,e.useState)(null),[aR,aS]=(0,e.useState)(null),[aT,aU]=(0,e.useState)(null),aV=(0,e.useRef)(null),aW=(0,e.useRef)(b?.id??null),aX=(0,e.useRef)(!1),aY=(0,e.useRef)(null);(0,e.useRef)(null);let aZ=(0,e.useRef)(null),a$=(0,e.useRef)(!1),a_=(0,e.useRef)(null),a0=(0,e.useRef)(!1),a1=(0,e.useRef)(null),a2=(0,e.useRef)(null),a3=(0,e.useRef)(new Map),a4=(0,e.useRef)(new Map),a5=(0,e.useRef)(null),a6=(0,e.useRef)(null),a7=(0,e.useRef)(0),a8=a.setNewSessionModel??Z,a9=a.setToolPreset??_,ba=a.setMemoryTools??ab,bb=am??m?.context.model??at??null,bc=l?Y:bb,bd=(0,e.useCallback)(()=>d?aK:L($,aa),[aa,d,$]),be=(0,e.useCallback)(a=>a?.length?a.map((a,b)=>{let c=`Attachment ${b+1}: ${a.fileName} (${a.mimeType||"application/octet-stream"}, ${a.size} bytes)`;if(a.extractedText){let b=a.truncated?"\n[The extracted text was truncated before sending.]":"";return`${c}
7
7
  ${b}
8
8
  ${a.extractedText}`.trim()}return`${c}
9
9
  [Text extraction unavailable: ${a.extractionError??"unsupported file type"}]`}).join("\n\n---\n\n"):"",[]),bf=(0,e.useCallback)(async a=>{let b=await fetch(`/api/agent/${encodeURIComponent(a)}/prepare`,{method:"POST"});if(!b.ok)throw Error((await b.json().catch(()=>({}))).error??`Failed to prepare session (HTTP ${b.status})`)},[]),bg=(()=>{let a={input:0,output:0,cacheRead:0,cacheWrite:0},b=0;for(let c of u){if("assistant"!==c.role)continue;let d=c.usage;d&&(a.input+=d.input??0,a.output+=d.output??0,a.cacheRead+=d.cacheRead??0,a.cacheWrite+=d.cacheWrite??0,b+=d.cost?.total??0)}return a.input+a.output+a.cacheRead+a.cacheWrite>0?{tokens:a,cost:b}:null})(),bh=(0,e.useCallback)(async(a,b=!1,c=!1)=>{try{b&&p(!0);let d=c?`/api/sessions/${encodeURIComponent(a)}?includeState`:`/api/sessions/${encodeURIComponent(a)}?limit=50&offset=0`,e=await fetch(d);if(aW.current&&aW.current!==a)return null;if(404===e.status)return b&&(n(null),t(null),v([]),r(null)),null;if(!e.ok)throw Error(`HTTP ${e.status}`);let f=await e.json();c||(z(f.totalMessages??f.context.messages.length),B(f.hasMore??!1),K(f.context.messages.length)),n(f),t(f.leafId);let g=f.context.messages,h=aN(g),i=new Map,j=Date.now();for(let[b,c]of a3.current)if(c.sessionId===a){if(j-c.createdAt>12e4){a3.current.delete(b);continue}if(c.confirmKey){let a=h.get(c.confirmKey)??0,d=i.get(c.confirmKey)??0;a-d>c.confirmCountAtCreate&&(a3.current.delete(b),i.set(c.confirmKey,d+1))}}a4.current=h;let l=f.context.entryIds??[],m=[...a3.current.values()].filter(b=>aO(b,a,l)).map(a=>a.message);return v(m.length>0?[...g,...m]:g),x(f.context.entryIds??[]),as(a=>{if(!a)return null;let b=f.context.model;return b?.provider===a.provider&&b.modelId===a.modelId?null:a}),r(null),!f.agentState?.state?.thinkingLevel&&f.context.thinkingLevel&&"off"!==f.context.thinkingLevel&&ad(f.context.thinkingLevel),f.agentState?.state?.planMode&&k?.(f.agentState.state.planMode),f.agentState??null}catch(a){return r(String(a)),null}finally{b&&p(!1)}},[k]),bi=(0,e.useRef)(!1),bj=(0,e.useCallback)(async()=>{if(bi.current)return;bi.current=!0;let a=aW.current;if(!a){bi.current=!1;return}try{let b=await fetch(`/api/sessions/${encodeURIComponent(a)}?limit=50&offset=${E}`);if(!b.ok)return;let c=await b.json();v(a=>[...c.context.messages,...a]),x(a=>[...c.context.entryIds??[],...a]),K(a=>a+c.context.messages.length),B(c.hasMore??!1)}catch{}finally{bi.current=!1}},[E]),bk=(0,e.useCallback)(async(a,b)=>{try{let c=b?`/api/sessions/${encodeURIComponent(a)}/context?leafId=${encodeURIComponent(b)}`:`/api/sessions/${encodeURIComponent(a)}/context`,d=await fetch(c);if(!d.ok)throw Error(`HTTP ${d.status}`);let e=await d.json(),f=e.context.messages,g=e.context.entryIds??[],h=aN(f),i=new Map,j=Date.now();for(let[b,c]of a3.current)if(c.sessionId===a){if(j-c.createdAt>12e4){a3.current.delete(b);continue}if(c.confirmKey){let a=h.get(c.confirmKey)??0,d=i.get(c.confirmKey)??0;a-d>c.confirmCountAtCreate&&(a3.current.delete(b),i.set(c.confirmKey,d+1))}}a4.current=h;let k=[...a3.current.values()].filter(b=>aO(b,a,g)).map(a=>a.message);v(k.length>0?[...f,...k]:f),x(g)}catch(a){console.error("Failed to load context:",a)}},[]),bl=(0,e.useCallback)(async a=>{try{let b=await ao(a,{type:"get_tools"});if(b){let a,c,d,e;a9((c=(a=b.filter(a=>a.active).map(a=>a.name)).filter(a=>!D.includes(a)),d=J(a),e=J(c),""===d?"none":d===J(F)?"default":d===J(G)?"full":d===J(H)?"workbench":d===J(I)?"agent":""===e?"none":e===J(F)?"default":e===J(G)?"full":e===J(H)?"workbench":e===J(I)||a.includes(C)?"agent":"default")),ba(D.filter(a=>b.some(b=>b.active&&b.name===a)))}}catch(a){console.error("Failed to load tools:",a)}},[ba,a9]),bm=(0,e.useCallback)((a,b={})=>{aV.current?.close(),aV.current=null;let c=`/api/agent/${encodeURIComponent(a)}/events${b.replay?"?replay=1":""}`;return!function(a){let b=aF(a);if("active"===b.snapshot.phase)return aA(b,!0),aC(b),b.snapshot;let c=Date.now();b.snapshot={...ax(a),phase:"active",startedAt:c,lastEventAt:c,isStreaming:!0,streamingMessage:{role:"assistant",content:[]}},aC(b),aA(b,!0),b.snapshot}(a),new Promise((d,e)=>{let f=!1,g=null,h=a=>{if(!f){if(f=!0,clearTimeout(i),a){g?.close(),aV.current===g&&(aV.current=null),e(a);return}d()}},i=setTimeout(()=>{b.requireConnected?h(Error("Timed out waiting for event stream connection")):h()},b.timeoutMs??3e4);aV.current=g=function(a){let{url:b,onEvent:c,onStateChange:d,onFatalError:e,maxReconnectAttempts:f=1/0,reconnectBaseMs:g=1e3,reconnectMaxMs:h=3e4,autoReconnect:i=!0}=a,j="idle",k=new AbortController,l=0,m=null,n=!1,o=a=>{j!==a&&(j=a,d?.(a))},p=()=>{null!==m&&(clearTimeout(m),m=null)},q=()=>{if(n)return;if(!i)return void o("error");if(l>=f){o("error"),e?.(Error(`Max reconnect attempts (${f}) reached`));return}let a=Math.min(h,g*2**l);l+=1,o("connecting"),m=setTimeout(()=>{m=null,r()},a)},r=async()=>{if(!n){p(),k=new AbortController,o("connecting");try{let a=await fetch(b,{signal:k.signal,headers:{Accept:"text/event-stream","Cache-Control":"no-cache"}});if(!a.ok)throw Error(`HTTP ${a.status}: ${a.statusText}`);let d=a.body;if(!d)throw Error("Response has no readable body");let e=d.getReader();o("connected"),l=0,await ar(e,c,k.signal),e.releaseLock(),o("closed"),!n&&i&&q()}catch(a){if(n||a instanceof DOMException&&"AbortError"===a.name)return void o("closed");o("error"),i&&q()}}};return{get state(){return j},connect:()=>{n=!1,l=0,p(),r()},close:()=>{n=!0,p(),k.abort(),o("closed")},get abortController(){return k}}}({url:c,onEvent:a=>{try{let b=JSON.parse(a);"connected"===b.type&&h(),aY.current?.(b)}catch{}},onStateChange:c=>{!function(a,b){let c=av().get(a);if(!c)return;let d=c.connectionState;c.connectionState=b,"connected"===b&&"connected"!==d&&(c.snapshot={...c.snapshot,lastEventAt:Date.now(),lastHeartbeatAt:Date.now()},aC(c)),"connected"!==b&&"connected"===d&&aD(c)}(a,c),b.requireConnected&&"error"===c&&h(Error("Failed to connect event stream"))},reconnectBaseMs:1e3,reconnectMaxMs:3e4}),g.connect()})},[]),bn=(0,e.useCallback)(async(a,b="manual")=>{if(!a||aW.current!==a)return;let c=a7.current;try{let b=await fetch(`/api/agent/${encodeURIComponent(a)}`),d=await b.json().catch(()=>({}));if(aW.current!==a||a7.current!==c)return;if(d.running){if(aX.current=!0,P(!0),aS(a=>a??{kind:"waiting_model"}),!aV.current||"closed"===aV.current.state||"error"===aV.current.state){let b;(b=av().get(a))&&(b.snapshot={...b.snapshot,reconnectCount:b.snapshot.reconnectCount+1,lastSyncReason:"sse-reconnect",lastEventAt:Date.now()},aA(b,!0)),bm(a,{replay:!0})}}else aX.current=!1,aV.current?.close(),aV.current=null,aH(a),P(!1),aS(null),af(null),N({type:"end"}),await bh(a);d.state?.contextUsage!==void 0&&ah(d.state.contextUsage??null),d.state?.systemPrompt!==void 0&&aj(d.state.systemPrompt??null),d.state?.isCompacting!==void 0&&aB(d.state.isCompacting),d.state?.thinkingLevel!==void 0&&ad(d.state.thinkingLevel??"auto"),d.state?.planMode!==void 0&&k?.(d.state.planMode)}catch{}},[bm,bh,k]);aY.current=(0,e.useCallback)(a=>{let b=aW.current;switch(b&&function(a,b){let c=aF(a),d=Date.now();switch(b.type){case"agent_start":if("active"===c.snapshot.phase)return aA(c,!0),c.snapshot;return aE(c),c.accumulatedText="",c.toolCalls.clear(),c.toolResults.clear(),c.activeToolId=null,c.snapshot={...ax(a),phase:"active",startedAt:d,lastEventAt:d,isStreaming:!0,streamingMessage:{role:"assistant",content:[]}},aC(c),aA(c,!0),c.snapshot;case"message_update":{let a=b.message;if(!a||"assistant"!==a.role)return c.snapshot;let e=a.content;for(let a of Array.isArray(e)?e:[])"object"==typeof a&&null!==a&&"type"in a&&("text"===a.type?c.accumulatedText=a.text??"":"toolCall"===a.type&&a.toolCallId&&!c.toolCalls.has(a.toolCallId)&&c.toolCalls.set(a.toolCallId,{...a,startedAt:d}));return aA(c,!1),c.snapshot}case"tool_execution_start":{let a="string"==typeof b.toolCallId?b.toolCallId:"",e="string"==typeof b.toolName?b.toolName:"tool",f=b.input??{};if(!a)return c.snapshot;let g=c.toolCalls.get(a);return c.toolCalls.set(a,{type:"toolCall",toolCallId:a,toolName:e,input:g?.input??f,startedAt:g?.startedAt??d}),c.activeToolId=a,aE(c),c.activeToolId&&(c.toolProgressTimer=setInterval(()=>aA(c,!0),1e3)),aA(c,!0),c.snapshot}case"tool_execution_end":{let a="string"==typeof b.toolCallId?b.toolCallId:"",e="string"==typeof b.toolName?b.toolName:"tool",f="string"==typeof b.result?b.result:JSON.stringify(b.result??"");if(a){let g=c.toolCalls.get(a);g&&c.toolCalls.set(a,{...g,endedAt:d}),c.toolResults.set(a,{role:"toolResult",toolCallId:a,toolName:e,content:[{type:"text",text:f}],isError:!!b.isError,timestamp:d}),c.activeToolId===a&&(c.activeToolId=null,aE(c))}return aA(c,!0),c.snapshot}case"message_end":return az(c),aA(c,!0),c.snapshot;case"agent_end":{az(c),aE(c),aD(c);let d="string"==typeof b.error?b.error:null;return c.activeToolId=null,c.snapshot={...c.snapshot,phase:d?"error":"completed",isStreaming:!1,streamingMessage:null,statusText:null,error:d},ay(a,d?{type:"error",snapshot:c.snapshot}:{type:"completed",snapshot:c.snapshot}),c.snapshot}case"heartbeat":return c.snapshot={...c.snapshot,lastHeartbeatAt:d},c.snapshot;default:return c.snapshot}}(b,a),a.type){case"agent_start":aU(null),aX.current=!0,P(!0),aS({kind:"waiting_model"}),N({type:"start"});break;case"agent_end":aX.current=!1,aV.current?.close(),aV.current=null,P(!1),aS(null),af(null),N({type:"end"}),aW.current&&(bh(aW.current),fetch(`/api/agent/${encodeURIComponent(aW.current)}`).then(a=>a.json()).then(a=>{!1===a.running&&(P(!1),aS(null),N({type:"end"})),a.state?.contextUsage!==void 0&&ah(a.state.contextUsage??null),a.state?.systemPrompt!==void 0&&aj(a.state.systemPrompt??null),a.state?.isCompacting!==void 0&&aB(a.state.isCompacting)}).catch(()=>{})),f?.();break;case"message_start":case"message_update":{if(!aX.current)break;let b=a.message;if(b?.role==="user")break;b&&N({type:"update",message:an(b)}),aS(null);break}case"message_end":{if(!aX.current)break;let b=a.message;b&&"user"!==b.role&&v(a=>[...a,an(b)]),N({type:"reset"}),aS({kind:"waiting_model"});break}case"prompt_done":if(!aX.current)break;bn(aW.current??"","prompt_done");break;case"tool_execution_start":{let b=a.toolCallId,c=a.toolName,d=a.args,e="bash"===c&&"string"==typeof d?.command?d.command:void 0;aS(a=>{let d=a?.kind==="running_tools"?[...a.tools]:[];return d.some(a=>a.id===b)||d.push({id:b,name:c,args:e}),{kind:"running_tools",tools:d}});break}case"tool_execution_end":{let b=a.toolCallId;aS(a=>{if(a?.kind!=="running_tools")return a;let c=a.tools.filter(a=>a.id!==b);return 0===c.length?{kind:"waiting_model"}:{kind:"running_tools",tools:c}});break}case"auto_retry_start":af({attempt:a.attempt,maxAttempts:a.maxAttempts,errorMessage:a.errorMessage});break;case"auto_retry_end":af(null);break;case"auto_compaction_start":case"compaction_start":aB(!0),aQ(null);break;case"auto_compaction_end":case"compaction_end":aB(!1),a.errorMessage?aQ(a.errorMessage):!a.aborted&&aW.current&&bh(aW.current)}},[bh,f]);let bo=(0,e.useCallback)(async(a,e,f,h)=>{if(!a.trim()&&!e?.length&&!f?.length||O)return;a7.current+=1;let i=be(f),j=a.trim()?i?`${a}
@@ -12,7 +12,7 @@ Attached document text:
12
12
 
13
13
  ${i}`:a:i?`Attached document text:
14
14
 
15
- ${i}`:"",k=[],n=l?c:b?.cwd??m?.info?.cwd;if(e?.length&&n)try{k=await aq(n,e)}catch(a){aU(a instanceof Error?a.message:String(a));return}let o=k.length?k.map(a=>{var b;return{type:"image",path:a.path,mimeType:a.mimeType,name:a.name,source:{type:"url",url:(b=a.path,`/api/files/${(0,ap.HG)(b)}?type=read`),media_type:a.mimeType}}}):e?.map(a=>({type:"image",source:{type:"base64",media_type:a.mimeType,data:a.data}})),p={role:"user",content:o?.length?[...j.trim()?[{type:"text",text:j}]:[],...o]:j,timestamp:Date.now()},q=aJ(),r=l?null:b?.id??null,s=a5.current,t=aM(p.content);a3.current.set(q,{localId:q,sessionId:r??"__new__",leafId:s,message:p,createdAt:Date.now(),kind:"prompt",confirmKey:t,confirmCountAtCreate:l?0:t?a4.current.get(t)??0:0}),v(a=>[...a,p]),aU(null),aX.current=!0,P(!0),aS({kind:"waiting_model"}),N({type:"start"}),a0.current=!0;let u=S.find(a=>a.provider===bb?.provider&&a.id===bb?.modelId)?.input,w=!u||0===u.length||u.includes("image")?e?.map(a=>({type:"image",data:a.data,mimeType:a.mimeType})):void 0;try{if(l&&c){Y&&au(Y);let b=h??bd(),e=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:c,type:"prompt",message:j,toolNames:b,planMode:d,deferPrompt:!0,...w?.length?{images:w}:{},...Y?{provider:Y.provider,modelId:Y.modelId}:{},..."auto"!==ac?{thinkingLevel:ac}:{}})}),f=await e.json().catch(()=>({}));if(!e.ok||f.error||!f.sessionId)throw Error(f.error??`HTTP ${e.status}`);let i=f.sessionId;aW.current=i;let k=a3.current.get(q);k&&(k.sessionId=i),aZ.current?.(),aZ.current=aG(i,()=>{aW.current===i&&(P(!1),aS(null))}),a6.current=i,await bm(i,{requireConnected:!0}),await ao(i,{type:"prompt",message:j,toolNames:b,planMode:d,...w?.length?{images:w}:{}}),g?.({id:i,path:"",cwd:c,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:1,firstMessage:a})}else if(b){let a=h??bd();await bf(b.id),aZ.current?.(),aZ.current=aG(b.id,()=>{aW.current===b.id&&(P(!1),aS(null))}),await bm(b.id,{requireConnected:!0}),await ao(b.id,{type:"prompt",message:j,toolNames:a,planMode:d,...w?.length?{images:w}:{}})}}catch(a){a3.current.delete(q),console.error("Failed to send message:",a),aU(a instanceof Error?a.message:String(a)),aX.current=!1,P(!1),aS(null),N({type:"end"})}},[l,c,Y,bd,ac,b,m?.info?.cwd,O,bm,g,be,d,S,bb,bf]),bp=(0,e.useCallback)(async()=>{let a=aW.current;if(a){aX.current=!1,aU(null),P(!1),aS(null),N({type:"end"}),aV.current?.close(),aV.current=null,aH(a);try{await ao(a,{type:"abort"}),await bh(a)}catch(b){console.error("Failed to abort:",b),await bh(a)}}},[bh]),bq=(0,e.useCallback)(async a=>{let b=aW.current;if(b){al(a);try{let{cancelled:c,newSessionId:d}=await ao(b,{type:"fork",entryId:a})??{};!c&&d&&h?.(d)}catch(a){console.error("Fork failed:",a)}finally{al(null)}}},[h]),br=(0,e.useCallback)(async a=>{let b=aW.current;b&&(ao(b,{type:"navigate_tree",targetId:a}).catch(()=>{}),t(a),await bk(b,a))},[bk]);(0,e.useCallback)(async a=>{t(a);let b=aW.current;b&&(await bk(b,a),a&&ao(b,{type:"navigate_tree",targetId:a}).catch(()=>{}))},[bk]);let bs=(0,e.useCallback)(async(a,b)=>{if(l)return void a8({provider:a,modelId:b});let c=aW.current;if(c)try{aU(null);let d=await ao(c,{type:"set_model",provider:a,modelId:b}),e={provider:d.provider,modelId:d.id};as(e),n(a=>a?{...a,context:{...a.context,model:e}}:a)}catch(b){let a=b instanceof Error?b.message:String(b);console.error("Failed to set model:",b),aU(a)}},[l,a8]),bt=(0,e.useCallback)(async()=>{let a=aW.current;if(a&&!aw){aB(!0),aQ(null);try{await ao(a,{type:"compact"}),await bh(a,!0)}catch(a){aQ(a instanceof Error?a.message:String(a))}finally{aB(!1)}}},[aw,bh]),bu=(0,e.useCallback)(async(a,b,c)=>{let d=aW.current;if(!d)return;let e=be(c),f=a.trim()?e?`${a}
15
+ ${i}`:"",k=[],n=l?c:b?.cwd??m?.info?.cwd;if(e?.length&&n)try{k=await aq(n,e)}catch(a){aU(a instanceof Error?a.message:String(a));return}let o=k.length?k.map(a=>{var b;return{type:"image",path:a.path,mimeType:a.mimeType,name:a.name,source:{type:"url",url:(b=a.path,`/api/files/${(0,ap.HG)(b)}?type=read`),media_type:a.mimeType}}}):e?.map(a=>({type:"image",source:{type:"base64",media_type:a.mimeType,data:a.data}})),p={role:"user",content:o?.length?[...j.trim()?[{type:"text",text:j}]:[],...o]:j,timestamp:Date.now()},q=aJ(),r=l?null:b?.id??null,s=a5.current,t=aM(p.content);a3.current.set(q,{localId:q,sessionId:r??"__new__",leafId:s,message:p,createdAt:Date.now(),kind:"prompt",confirmKey:t,confirmCountAtCreate:l?0:t?a4.current.get(t)??0:0}),v(a=>[...a,p]),aU(null),aX.current=!0,P(!0),aS({kind:"waiting_model"}),N({type:"start"}),a0.current=!0;let u=S.find(a=>a.provider===bb?.provider&&a.id===bb?.modelId)?.input,w=!u||0===u.length||u.includes("image")?e?.map(a=>({type:"image",data:a.data,mimeType:a.mimeType})):void 0;try{if(l&&c){Y&&au(Y);let b=h??bd(),e=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:c,type:"prompt",message:j,toolNames:b,planMode:d,deferPrompt:!0,...w?.length?{images:w}:{},...Y?{provider:Y.provider,modelId:Y.modelId}:{},..."auto"!==ac?{thinkingLevel:ac}:{}})}),f=await e.json().catch(()=>({}));if(!e.ok||f.error||!f.sessionId)throw Error(f.error??`HTTP ${e.status}`);let i=f.sessionId;aW.current=i;let k=a3.current.get(q);k&&(k.sessionId=i),aZ.current?.(),aZ.current=aG(i,()=>{aW.current===i&&(P(!1),aS(null))}),a6.current=i,await bm(i,{requireConnected:!0}),await ao(i,{type:"prompt",message:j,toolNames:b,planMode:d,...w?.length?{images:w}:{}}),g?.({id:i,path:"",cwd:c,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:1,firstMessage:a})}else if(b){let a=h??bd();await bf(b.id),aZ.current?.(),aZ.current=aG(b.id,()=>{aW.current===b.id&&(P(!1),aS(null))}),await bm(b.id,{requireConnected:!0}),await ao(b.id,{type:"prompt",message:j,toolNames:a,planMode:d,...w?.length?{images:w}:{}})}}catch(a){a3.current.delete(q),console.error("Failed to send message:",a),aU(a instanceof Error?a.message:String(a)),aX.current=!1,P(!1),aS(null),N({type:"end"})}},[l,c,Y,bd,ac,b,m?.info?.cwd,O,bm,g,be,d,S,bb,bf]),bp=(0,e.useCallback)(async()=>{let a=aW.current;if(a){aX.current=!1,aU(null),P(!1),aS(null),N({type:"end"}),aV.current?.close(),aV.current=null,aH(a);try{await ao(a,{type:"abort"}),await bh(a)}catch(b){console.error("Failed to abort:",b),await bh(a)}}},[bh]),bq=(0,e.useCallback)(async a=>{let b=aW.current;if(b){al(a);try{let{cancelled:c,newSessionId:d}=await ao(b,{type:"fork",entryId:a})??{};!c&&d&&h?.(d)}catch(a){console.error("Fork failed:",a)}finally{al(null)}}},[h]),br=(0,e.useCallback)(async a=>{let b=aW.current;b&&(ao(b,{type:"navigate_tree",targetId:a}).catch(()=>{}),t(a),await bk(b,a))},[bk]);(0,e.useCallback)(async a=>{t(a);let b=aW.current;b&&(await bk(b,a),a&&ao(b,{type:"navigate_tree",targetId:a}).catch(()=>{}))},[bk]);let bs=(0,e.useCallback)(async(a,b)=>{if(l)return void a8({provider:a,modelId:b});let c=aW.current;if(c)try{var d;aU(null);let e=await ao(c,{type:"set_model",provider:a,modelId:b}),f={provider:e.provider,modelId:e.id};e.thinkingLevel&&(d=e.thinkingLevel,"auto"===d||"off"===d||"minimal"===d||"low"===d||"medium"===d||"high"===d||"xhigh"===d)&&ad(e.thinkingLevel),as(f),n(a=>a?{...a,context:{...a.context,model:f}}:a)}catch(b){let a=b instanceof Error?b.message:String(b);console.error("Failed to set model:",b),aU(a)}},[l,a8]),bt=(0,e.useCallback)(async()=>{let a=aW.current;if(a&&!aw){aB(!0),aQ(null);try{await ao(a,{type:"compact"}),await bh(a,!0)}catch(a){aQ(a instanceof Error?a.message:String(a))}finally{aB(!1)}}},[aw,bh]),bu=(0,e.useCallback)(async(a,b,c)=>{let d=aW.current;if(!d)return;let e=be(c),f=a.trim()?e?`${a}
16
16
 
17
17
  Attached document text:
18
18